Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kityminder-core
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
吴志俊
kityminder-core
Commits
2bbb3cde
Commit
2bbb3cde
authored
Jan 22, 2014
by
Akikonata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed bug
parent
ebb2c77e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
86 additions
and
67 deletions
+86
-67
node.js
src/core/node.js
+48
-61
layout.default.js
src/module/layout.default.js
+37
-6
layout.js
src/module/layout.js
+1
-0
No files found.
src/core/node.js
View file @
2bbb3cde
...
@@ -3,30 +3,35 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
...
@@ -3,30 +3,35 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
this
.
parent
=
null
;
this
.
parent
=
null
;
this
.
children
=
[];
this
.
children
=
[];
this
.
data
=
{};
this
.
data
=
{};
if
(
u
tils
.
isString
(
options
)
)
{
if
(
U
tils
.
isString
(
options
)
)
{
this
.
setData
(
'text'
,
options
)
this
.
setData
(
'text'
,
options
)
;
}
else
{
}
else
{
this
.
setData
(
options
);
this
.
setData
(
options
);
}
}
this
.
rc
=
new
kity
.
Group
();
this
.
rc
=
new
kity
.
Group
();
this
.
rc
.
minderNode
=
this
;
this
.
rc
.
minderNode
=
this
;
},
},
setPoint
:
function
(
x
,
y
){
setPoint
:
function
(
x
,
y
)
{
this
.
setData
(
'point'
,{
if
(
arguments
.
length
===
0
)
{
x
:
x
,
y
:
y
this
.
setData
(
'point'
,
null
);
})
}
else
{
this
.
setData
(
'point'
,
{
x
:
x
,
y
:
y
}
);
}
},
},
getPoint
:
function
()
{
getPoint
:
function
()
{
return
this
.
getData
(
'point'
)
return
this
.
getData
(
'point'
);
},
},
setText
:
function
(
text
)
{
setText
:
function
(
text
)
{
this
.
setData
(
'text'
,
text
)
this
.
setData
(
'text'
,
text
)
;
},
},
getText
:
function
()
{
getText
:
function
()
{
return
this
.
getData
(
'text'
)
return
this
.
getData
(
'text'
)
;
},
},
isRoot
:
function
()
{
isRoot
:
function
()
{
return
this
.
getParent
()
==
null
?
true
:
false
;
return
this
.
getParent
()
==
=
null
?
true
:
false
;
},
},
getParent
:
function
()
{
getParent
:
function
()
{
return
this
.
parent
;
return
this
.
parent
;
...
@@ -89,17 +94,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
...
@@ -89,17 +94,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
node
.
root
=
parent
.
root
;
node
.
root
=
parent
.
root
;
this
.
children
.
splice
(
index
,
0
,
node
);
this
.
children
.
splice
(
index
,
0
,
node
);
// this.handelInsert( node );
},
},
//
// handelInsert: function ( node ) {
// var root = this.getRoot();
// if ( root.tnh ) {
// root.tnh.handelNodeInsert.call( root.tnh, node );
// }
// },
appendChild
:
function
(
node
)
{
appendChild
:
function
(
node
)
{
return
this
.
insertChild
(
node
);
return
this
.
insertChild
(
node
);
},
},
...
@@ -117,25 +112,17 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
...
@@ -117,25 +112,17 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
if
(
index
>=
0
)
{
if
(
index
>=
0
)
{
removed
=
this
.
children
.
splice
(
index
,
1
)[
0
];
removed
=
this
.
children
.
splice
(
index
,
1
)[
0
];
removed
.
parent
=
null
;
removed
.
parent
=
null
;
// this.handelRemove( removed );
}
}
},
},
// handelRemove: function ( node ) {
// var root = this.getRoot();
// if ( root.tnh ) {
// root.tnh.handelNodeRemove.call( root.tnh, node );
// }
// },
getChild
:
function
(
index
)
{
getChild
:
function
(
index
)
{
return
this
.
children
[
index
];
return
this
.
children
[
index
];
},
},
getFirstChild
:
function
()
{
getFirstChild
:
function
()
{
return
this
.
children
[
0
]
return
this
.
children
[
0
]
;
},
},
getLastChild
:
function
()
{
getLastChild
:
function
()
{
return
this
.
children
[
this
.
children
.
length
-
1
]
return
this
.
children
[
this
.
children
.
length
-
1
]
;
},
},
getData
:
function
(
name
)
{
getData
:
function
(
name
)
{
if
(
name
===
undefined
)
{
if
(
name
===
undefined
)
{
...
@@ -145,17 +132,17 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
...
@@ -145,17 +132,17 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
},
},
setData
:
function
(
name
,
value
)
{
setData
:
function
(
name
,
value
)
{
if
(
name
===
undefined
)
{
if
(
name
===
undefined
)
{
this
.
data
=
{}
this
.
data
=
{}
;
}
else
if
(
utils
.
isObject
(
name
))
{
}
else
if
(
Utils
.
isObject
(
name
)
)
{
utils
.
extend
(
this
.
data
,
name
)
Utils
.
extend
(
this
.
data
,
name
);
}
else
{
}
else
{
if
(
value
===
undefined
)
{
if
(
value
===
undefined
)
{
this
.
data
[
name
]
=
null
;
this
.
data
[
name
]
=
null
;
delete
this
.
data
[
name
]
delete
this
.
data
[
name
];
}
else
{
}
else
{
this
.
data
[
name
]
=
value
;
this
.
data
[
name
]
=
value
;
}
}
}
}
},
},
...
@@ -164,13 +151,13 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
...
@@ -164,13 +151,13 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
},
},
getCommonAncestor
:
function
(
node
)
{
getCommonAncestor
:
function
(
node
)
{
if
(
this
===
node
)
{
if
(
this
===
node
)
{
return
this
.
parent
return
this
.
parent
;
}
}
if
(
this
.
contains
(
node
)
)
{
if
(
this
.
contains
(
node
)
)
{
return
this
return
this
;
}
}
if
(
node
.
contains
(
this
)
)
{
if
(
node
.
contains
(
this
)
)
{
return
node
return
node
;
}
}
var
parent
=
this
.
parent
;
var
parent
=
this
.
parent
;
while
(
!
parent
.
contains
(
node
)
)
{
while
(
!
parent
.
contains
(
node
)
)
{
...
@@ -186,44 +173,44 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
...
@@ -186,44 +173,44 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
return
true
;
return
true
;
}
}
var
isContain
=
false
;
var
isContain
=
false
;
u
tils
.
each
(
this
.
getChildren
(),
function
(
i
,
n
)
{
U
tils
.
each
(
this
.
getChildren
(),
function
(
i
,
n
)
{
isContain
=
n
.
contains
(
node
);
isContain
=
n
.
contains
(
node
);
if
(
isContain
===
true
)
{
if
(
isContain
===
true
)
{
return
false
return
false
;
}
}
}
);
}
);
return
isContain
;
return
isContain
;
},
},
clone
:
function
()
{
clone
:
function
()
{
function
cloneNode
(
parent
,
isClonedNode
)
{
function
cloneNode
(
parent
,
isClonedNode
)
{
var
_tmp
=
new
KM
.
MinderNode
();
var
_tmp
=
new
KM
.
MinderNode
();
_tmp
.
data
=
utils
.
clonePlainObject
(
isClonedNode
.
getData
()
);
_tmp
.
data
=
Utils
.
clonePlainObject
(
isClonedNode
.
getData
()
);
_tmp
.
parent
=
parent
;
_tmp
.
parent
=
parent
;
if
(
parent
)
{
if
(
parent
)
{
parent
.
children
.
push
(
_tmp
);
parent
.
children
.
push
(
_tmp
);
}
}
for
(
var
i
=
0
,
ci
;
ci
=
isClonedNode
.
children
[
i
++
];)
{
for
(
var
i
=
0
,
ci
;
ci
=
isClonedNode
.
children
[
i
++
];
)
{
cloneNode
(
_tmp
,
ci
);
cloneNode
(
_tmp
,
ci
);
}
}
return
_tmp
;
return
_tmp
;
}
}
return
function
()
{
return
function
()
{
return
cloneNode
(
null
,
this
);
return
cloneNode
(
null
,
this
);
}
}
}(),
}(),
equals
:
function
(
node
)
{
equals
:
function
(
node
)
{
if
(
node
.
children
.
length
!=
this
.
children
.
length
)
{
if
(
node
.
children
.
length
!=
this
.
children
.
length
)
{
return
false
;
return
false
;
}
}
if
(
utils
.
compareObject
(
node
.
getData
(),
this
.
getData
())
===
false
)
{
if
(
utils
.
compareObject
(
node
.
getData
(),
this
.
getData
()
)
===
false
)
{
return
false
;
return
false
;
}
}
for
(
var
i
=
0
,
ci
;
ci
=
this
.
children
[
i
++
];)
{
for
(
var
i
=
0
,
ci
;
ci
=
this
.
children
[
i
++
];
)
{
if
(
ci
.
equals
(
node
)
===
false
)
{
if
(
ci
.
equals
(
node
)
===
false
)
{
return
false
;
return
false
;
}
}
}
}
...
...
src/module/layout.default.js
View file @
2bbb3cde
...
@@ -345,8 +345,14 @@ KityMinder.registerModule( "LayoutDefault", function () {
...
@@ -345,8 +345,14 @@ KityMinder.registerModule( "LayoutDefault", function () {
//调整node的位置
//调整node的位置
var
translateNode
=
function
(
node
)
{
var
translateNode
=
function
(
node
)
{
var
Layout
=
node
.
getData
(
"layout"
);
var
nodeShape
=
node
.
getRenderContainer
();
var
nodeShape
=
node
.
getRenderContainer
();
// var nodePoint = node.getPoint();
// console.log( nodePoint );
// if ( nodePoint ) {
// nodeShape.setTransform( new kity.Matrix().translate( nodePoint.x, nodePoint.y ) );
// return false;
// }
var
Layout
=
node
.
getData
(
"layout"
);
var
align
=
Layout
.
align
;
var
align
=
Layout
.
align
;
var
_rectHeight
=
nodeShape
.
getHeight
();
var
_rectHeight
=
nodeShape
.
getHeight
();
var
_rectWidth
=
nodeShape
.
getWidth
();
var
_rectWidth
=
nodeShape
.
getWidth
();
...
@@ -361,6 +367,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
...
@@ -361,6 +367,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
nodeShape
.
setTransform
(
new
kity
.
Matrix
().
translate
(
Layout
.
x
,
Layout
.
y
-
_rectHeight
/
2
)
);
nodeShape
.
setTransform
(
new
kity
.
Matrix
().
translate
(
Layout
.
x
,
Layout
.
y
-
_rectHeight
/
2
)
);
break
;
break
;
}
}
return
true
;
};
};
var
_style
=
{
var
_style
=
{
renderNode
:
function
(
node
)
{
renderNode
:
function
(
node
)
{
...
@@ -393,12 +400,28 @@ KityMinder.registerModule( "LayoutDefault", function () {
...
@@ -393,12 +400,28 @@ KityMinder.registerModule( "LayoutDefault", function () {
var
_rootRenderContainer
=
_root
.
getRenderContainer
();
var
_rootRenderContainer
=
_root
.
getRenderContainer
();
var
rootHeight
=
_rootRenderContainer
.
getHeight
();
var
rootHeight
=
_rootRenderContainer
.
getHeight
();
Layout
.
leftHeight
=
Layout
.
rightHeight
=
rootHeight
;
Layout
.
leftHeight
=
Layout
.
rightHeight
=
rootHeight
;
drawNode
(
_root
);
drawNode
(
_root
);
translateNode
(
_root
);
translateNode
(
_root
);
//如果是从其他style切过来的,需要重新布局
var
box
=
_root
.
getRenderContainer
().
getRenderBox
();
var
_buffer
=
_root
.
getChildren
();
var
_buffer
=
_root
.
getChildren
();
_root
.
setPoint
(
box
.
x
,
box
.
y
);
if
(
_buffer
.
length
!==
0
)
{
for
(
var
i
=
0
;
i
<
_buffer
.
length
;
i
++
)
{
var
point
=
_buffer
[
i
].
getPoint
();
if
(
point
)
{
if
(
point
.
x
>
Layout
.
x
)
{
Layout
.
rightList
.
push
(
_buffer
[
i
]
);
}
else
{
Layout
.
leftList
.
push
(
_buffer
[
i
]
);
}
}
else
{
break
;
}
}
}
//如果是从其他style切过来的,需要重新布局
while
(
_buffer
.
length
!==
0
)
{
while
(
_buffer
.
length
!==
0
)
{
_buffer
=
_buffer
.
concat
(
_buffer
[
0
].
getChildren
()
);
_buffer
=
_buffer
.
concat
(
_buffer
[
0
].
getChildren
()
);
var
prt
=
_buffer
[
0
].
getParent
();
var
prt
=
_buffer
[
0
].
getParent
();
...
@@ -432,11 +455,17 @@ KityMinder.registerModule( "LayoutDefault", function () {
...
@@ -432,11 +455,17 @@ KityMinder.registerModule( "LayoutDefault", function () {
}
}
Layout
.
appendside
=
aside
;
Layout
.
appendside
=
aside
;
}
}
parentLayout
.
appendside
=
aside
;
if
(
leftList
.
indexOf
(
node
)
!==
-
1
)
{
parentLayout
[
aside
+
"List"
].
push
(
node
);
Layout
.
appendside
=
"left"
;
}
else
if
(
rightList
.
indexOf
(
node
)
!==
-
1
)
{
Layout
.
appendside
=
"right"
;
}
else
{
parentLayout
.
appendside
=
aside
;
parentLayout
[
aside
+
"List"
].
push
(
node
);
}
}
}
var
appendside
=
parentLayout
.
appendside
;
var
appendside
=
Layout
.
appendside
||
parentLayout
.
appendside
;
Layout
.
appendside
=
appendside
;
Layout
.
appendside
=
appendside
;
if
(
appendside
===
"left"
)
{
if
(
appendside
===
"left"
)
{
Layout
.
align
=
"right"
;
Layout
.
align
=
"right"
;
...
@@ -450,6 +479,8 @@ KityMinder.registerModule( "LayoutDefault", function () {
...
@@ -450,6 +479,8 @@ KityMinder.registerModule( "LayoutDefault", function () {
var
set
=
uSet
(
set1
,
set2
);
var
set
=
uSet
(
set1
,
set2
);
for
(
var
i
=
0
;
i
<
set
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
set
.
length
;
i
++
)
{
translateNode
(
set
[
i
]
);
translateNode
(
set
[
i
]
);
var
box
=
set
[
i
].
getRenderContainer
().
getRenderBox
();
set
[
i
].
setPoint
(
box
.
x
,
box
.
y
);
}
}
},
},
updateLayout
:
function
(
node
)
{
updateLayout
:
function
(
node
)
{
...
...
src/module/layout.js
View file @
2bbb3cde
...
@@ -67,6 +67,7 @@ KityMinder.registerModule( "LayoutModule", function () {
...
@@ -67,6 +67,7 @@ KityMinder.registerModule( "LayoutModule", function () {
km
.
getRenderContainer
().
clear
().
addShape
(
_root
.
getRenderContainer
().
clear
()
);
km
.
getRenderContainer
().
clear
().
addShape
(
_root
.
getRenderContainer
().
clear
()
);
_root
.
preTraverse
(
function
(
n
)
{
_root
.
preTraverse
(
function
(
n
)
{
n
.
clearLayout
();
n
.
clearLayout
();
n
.
setPoint
();
}
);
}
);
km
.
setCurrentStyle
(
style
);
km
.
setCurrentStyle
(
style
);
km
.
initStyle
();
km
.
initStyle
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment