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
2084f398
Commit
2084f398
authored
Feb 19, 2014
by
techird
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of
https://github.com/kitygraph/kityminder
into dev
parents
2407e80b
fedca98b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
218 deletions
+50
-218
layout.bottom.js
src/module/layout.bottom.js
+47
-216
layout.default.js
src/module/layout.default.js
+1
-1
markers.css
themes/default/_css/markers.css
+2
-1
No files found.
src/module/layout.bottom.js
View file @
2084f398
...
...
@@ -134,12 +134,6 @@ KityMinder.registerModule( "LayoutBottom", function () {
var
nodeStyle
=
nodeStyles
[
nodeType
];
var
txtShape
=
node
.
getTextShape
();
txtShape
.
fill
(
nodeStyle
.
color
).
setSize
(
nodeStyle
.
fontSize
).
setY
(
-
3
);
if
(
nodeType
===
"root"
)
{
Layout
.
leftList
=
[];
Layout
.
rightList
=
[];
Layout
.
leftHeight
=
0
;
Layout
.
rightHeight
=
0
;
}
};
//根据内容调整节点尺寸
var
updateShapeByCont
=
function
(
node
)
{
...
...
@@ -178,7 +172,33 @@ KityMinder.registerModule( "LayoutBottom", function () {
contRc
.
setTransform
(
new
kity
.
Matrix
().
translate
(
nodeStyle
.
padding
[
3
],
nodeStyle
.
padding
[
0
]
+
node
.
getTextShape
().
getHeight
()
)
);
};
//计算节点在垂直方向的位置
var
updateLayoutVertical
=
function
(
node
,
parent
,
action
)
{
var
updateLayoutVertical
=
function
(
node
)
{
var
nodeType
=
node
.
getType
();
var
parent
=
node
.
getParent
();
var
effectSet
=
[
node
];
var
Layout
=
node
.
getLayout
();
var
_buffer
=
[
node
];
while
(
_buffer
.
length
!==
0
)
{
var
prt
=
_buffer
[
0
].
getParent
();
_buffer
=
_buffer
.
concat
(
_buffer
[
0
].
getChildren
()
);
if
(
!
prt
)
{
Layout
.
y
=
100
;
_buffer
.
shift
();
continue
;
}
var
parentLayout
=
prt
.
getLayout
();
var
parentHeight
=
prt
.
getRenderContainer
().
getHeight
();
var
parentStyle
=
nodeStyles
[
prt
.
getType
()
];
var
childLayout
=
_buffer
[
0
].
getLayout
();
var
childStyle
=
nodeStyles
[
_buffer
[
0
].
getType
()
];
childLayout
.
y
=
parentLayout
.
y
+
parentHeight
+
parentStyle
.
margin
[
2
]
+
childStyle
.
margin
[
2
];
effectSet
.
push
(
_buffer
[
0
]
);
_buffer
.
shift
();
}
return
effectSet
;
};
//计算节点在水平方向的位置
var
updateLayoutHorizon
=
function
(
node
,
parent
,
action
)
{
var
root
=
minder
.
getRoot
();
var
effectSet
=
[
node
];
if
(
action
===
"remove"
)
{
...
...
@@ -188,65 +208,50 @@ KityMinder.registerModule( "LayoutBottom", function () {
var
nodeShape
=
node
.
getRenderContainer
();
var
nodeType
=
node
.
getType
();
var
nodeStyle
=
nodeStyles
[
nodeType
];
var
appendside
=
Layout
.
appendside
;
var
countBranchHeight
=
function
(
node
,
side
)
{
var
countBranchWidth
=
function
(
node
)
{
var
nodeStyle
=
nodeStyles
[
node
.
getType
()
];
var
self
Height
=
node
.
getRenderContainer
().
getHeight
()
+
nodeStyle
.
margin
[
0
]
+
nodeStyle
.
margin
[
2
];
var
child
Height
=
(
function
()
{
var
self
Width
=
node
.
getRenderContainer
().
getWidth
()
+
nodeStyle
.
margin
[
1
]
+
nodeStyle
.
margin
[
3
];
var
child
Width
=
(
function
()
{
var
sum
=
0
;
var
children
;
if
(
!
side
)
{
children
=
node
.
getChildren
();
}
else
{
children
=
node
.
getLayout
()[
side
+
"List"
];
}
var
children
=
node
.
getChildren
();
for
(
var
i
=
0
;
i
<
children
.
length
;
i
++
)
{
var
childLayout
=
children
[
i
].
getLayout
();
if
(
children
[
i
].
getRenderContainer
().
get
Height
()
!==
0
)
sum
+=
childLayout
.
branch
height
;
if
(
children
[
i
].
getRenderContainer
().
get
Width
()
!==
0
)
sum
+=
childLayout
.
branch
width
;
}
return
sum
;
}
)();
if
(
side
)
{
return
childHeight
;
}
else
{
return
(
selfHeight
>
childHeight
?
selfHeight
:
childHeight
);
}
return
(
selfWidth
>
childWidth
?
selfWidth
:
childWidth
);
};
if
(
nodeType
===
"root"
)
{
Layout
.
y
=
100
;
Layout
.
x
=
getMinderSize
().
width
/
2
;
effectSet
.
push
(
node
);
}
else
{
if
(
action
===
"append"
||
action
===
"contract"
)
{
Layout
.
branch
height
=
node
.
getRenderContainer
().
getHeight
()
+
nodeStyle
.
margin
[
0
]
+
nodeStyle
.
margin
[
2
];
}
else
if
(
action
===
"change"
)
{
//展开
Layout
.
branchheight
=
countBranch
Height
(
node
);
Layout
.
branch
width
=
node
.
getRenderContainer
().
getWidth
()
+
nodeStyle
.
margin
[
1
]
+
nodeStyle
.
margin
[
3
];
}
else
if
(
action
===
"change"
)
{
Layout
.
branchheight
=
countBranch
Width
(
node
);
}
var
parentLayout
=
parent
.
getLayout
();
var
parentShape
=
parent
.
getRenderContainer
();
var
prt
=
node
.
getParent
()
||
parent
;
//自底向上更新祖先元素的branch
height
值
//自底向上更新祖先元素的branch
width
值
while
(
prt
)
{
var
prtLayout
=
prt
.
getLayout
();
if
(
prt
.
getType
()
===
"root"
)
{
prtLayout
[
appendside
+
"Height"
]
=
countBranchHeight
(
prt
,
appendside
);
}
else
{
prtLayout
.
branchheight
=
countBranchHeight
(
prt
);
}
prtLayout
.
branchheight
=
countBranchWidth
(
prt
);
prt
=
prt
.
getParent
();
}
//自顶向下更新受影响一侧的y值
var
sideList
=
root
.
getLayout
()[
appendside
+
"List"
];
var
_buffer
=
[
root
];
while
(
_buffer
.
length
>
0
)
{
var
_buffer0Layout
=
_buffer
[
0
].
getLayout
();
var
children
=
_buffer
0Layout
[
appendside
+
"List"
]
||
_buffer
[
0
].
getChildren
();
var
children
=
_buffer
[
0
].
getChildren
();
_buffer
=
_buffer
.
concat
(
children
);
var
s
Y
=
_buffer0Layout
.
y
-
(
_buffer0Layout
[
appendside
+
"Height"
]
||
_buffer0Layout
.
branchheight
)
/
2
;
var
s
X
=
_buffer0Layout
.
x
-
_buffer0Layout
.
branchwidth
/
2
;
for
(
var
i
=
0
;
i
<
children
.
length
;
i
++
)
{
var
childLayout
=
children
[
i
].
getLayout
();
childLayout
.
y
=
sY
+
childLayout
.
branchheight
/
2
;
s
Y
+=
childLayout
.
branchheight
;
childLayout
.
x
=
sX
;
s
X
+=
childLayout
.
branchwidth
;
}
effectSet
.
push
(
_buffer
[
0
]
);
_buffer
.
shift
();
...
...
@@ -254,56 +259,13 @@ KityMinder.registerModule( "LayoutBottom", function () {
}
return
effectSet
;
};
//计算节点在水平方向的位置
var
updateLayoutHorizon
=
function
(
node
)
{
var
nodeType
=
node
.
getType
();
var
parent
=
node
.
getParent
();
var
effectSet
=
[
node
];
var
Layout
=
node
.
getLayout
();
var
_buffer
=
[
node
];
while
(
_buffer
.
length
!==
0
)
{
var
prt
=
_buffer
[
0
].
getParent
();
_buffer
=
_buffer
.
concat
(
_buffer
[
0
].
getChildren
()
);
if
(
!
prt
)
{
Layout
.
x
=
getMinderSize
().
width
/
2
;
_buffer
.
shift
();
continue
;
}
var
parentLayout
=
prt
.
getLayout
();
var
parentWidth
=
prt
.
getRenderContainer
().
getWidth
();
var
parentStyle
=
nodeStyles
[
prt
.
getType
()
];
var
childLayout
=
_buffer
[
0
].
getLayout
();
var
childStyle
=
nodeStyles
[
_buffer
[
0
].
getType
()
];
if
(
parentLayout
.
align
===
"center"
)
{
parentWidth
=
parentWidth
/
2
;
}
if
(
childLayout
.
appendside
===
"left"
)
{
childLayout
.
x
=
parentLayout
.
x
-
parentWidth
-
parentStyle
.
margin
[
1
]
-
childStyle
.
margin
[
3
];
}
else
{
childLayout
.
x
=
parentLayout
.
x
+
parentWidth
+
parentStyle
.
margin
[
1
]
+
childStyle
.
margin
[
3
];
}
effectSet
.
push
(
_buffer
[
0
]
);
_buffer
.
shift
();
}
return
effectSet
;
};
var
translateNode
=
function
(
node
)
{
var
Layout
=
node
.
getLayout
();
var
nodeShape
=
node
.
getRenderContainer
();
var
align
=
Layout
.
align
;
var
_rectHeight
=
nodeShape
.
getHeight
();
var
_rectWidth
=
nodeShape
.
getWidth
();
switch
(
align
)
{
case
"right"
:
nodeShape
.
setTransform
(
new
kity
.
Matrix
().
translate
(
Layout
.
x
-
_rectWidth
,
Layout
.
y
-
_rectHeight
/
2
)
);
break
;
case
"center"
:
nodeShape
.
setTransform
(
new
kity
.
Matrix
().
translate
(
Layout
.
x
-
_rectWidth
/
2
,
Layout
.
y
-
_rectHeight
/
2
)
);
break
;
default
:
nodeShape
.
setTransform
(
new
kity
.
Matrix
().
translate
(
Layout
.
x
,
Layout
.
y
-
_rectHeight
/
2
)
);
break
;
}
nodeShape
.
setTransform
(
new
kity
.
Matrix
().
translate
(
Layout
.
x
,
Layout
.
y
)
);
node
.
setPoint
(
Layout
.
x
,
Layout
.
y
);
};
var
updateConnectAndshIcon
=
function
(
node
)
{
...
...
@@ -465,66 +427,6 @@ KityMinder.registerModule( "LayoutBottom", function () {
}
},
appendChildNode
:
function
(
parent
,
node
,
sibling
)
{
minder
.
handelNodeInsert
(
node
);
node
.
clearLayout
();
var
Layout
=
node
.
getLayout
();
var
parentLayout
=
parent
.
getLayout
();
if
(
sibling
)
{
var
siblingLayout
=
sibling
.
getLayout
();
Layout
.
appendside
=
siblingLayout
.
appendside
;
Layout
.
align
=
siblingLayout
.
align
;
parent
.
insertChild
(
node
,
sibling
.
getIndex
()
+
1
);
if
(
parent
.
getType
()
===
"root"
)
{
var
len
=
parent
.
getChildren
().
length
;
if
(
len
<
7
)
{
if
(
len
%
2
)
{
Layout
.
appendside
=
"right"
;
Layout
.
align
=
"left"
;
}
else
{
Layout
.
appendside
=
"left"
;
Layout
.
align
=
"right"
;
}
}
var
sideList
=
parentLayout
[
Layout
.
appendside
+
"List"
];
var
idx
=
sideList
.
indexOf
(
sibling
);
sideList
.
splice
(
idx
+
1
,
0
,
node
);
}
}
else
{
if
(
parent
.
getType
()
!==
"root"
)
{
var
prtLayout
=
parent
.
getLayout
();
Layout
.
appendside
=
prtLayout
.
appendside
;
Layout
.
align
=
prtLayout
.
align
;
parent
.
appendChild
(
node
);
}
else
{
var
nodeP
=
node
.
getPoint
();
if
(
nodeP
&&
nodeP
.
x
&&
nodeP
.
y
)
{
if
(
nodeP
.
x
>
parentLayout
.
x
)
{
Layout
.
appendside
=
"right"
;
Layout
.
align
=
"left"
;
}
else
{
Layout
.
appendside
=
"left"
;
Layout
.
align
=
"right"
;
}
}
else
{
if
(
parentLayout
.
rightList
.
length
>
1
&&
parentLayout
.
rightList
.
length
>
parentLayout
.
leftList
.
length
)
{
Layout
.
appendside
=
"left"
;
Layout
.
align
=
"right"
;
}
else
{
Layout
.
appendside
=
"right"
;
Layout
.
align
=
"left"
;
}
}
var
sideList1
=
parentLayout
[
Layout
.
appendside
+
"List"
];
sideList1
.
push
(
node
);
var
idx1
;
if
(
Layout
.
appendside
===
"right"
)
{
idx1
=
sideList1
.
length
;
}
else
{
idx1
=
parent
.
getChildren
().
length
;
}
parent
.
insertChild
(
node
,
idx1
);
}
}
//设置分支类型
if
(
parent
.
getType
()
===
"root"
)
{
node
.
setType
(
"main"
);
...
...
@@ -550,84 +452,13 @@ KityMinder.registerModule( "LayoutBottom", function () {
}
},
appendSiblingNode
:
function
(
sibling
,
node
)
{
var
parent
=
sibling
.
getParent
();
this
.
appendChildNode
(
parent
,
node
,
sibling
);
},
removeNode
:
function
(
nodes
)
{
while
(
nodes
.
length
!==
0
)
{
var
parent
=
nodes
[
0
].
getParent
();
if
(
!
parent
)
{
nodes
.
splice
(
0
,
1
);
return
false
;
}
var
nodeLayout
=
nodes
[
0
].
getLayout
();
if
(
parent
.
getType
()
===
"root"
)
{
var
sideList
=
parent
.
getLayout
()[
nodeLayout
.
appendside
+
"List"
];
var
index
=
sideList
.
indexOf
(
nodes
[
0
]
);
sideList
.
splice
(
index
,
1
);
}
parent
.
removeChild
(
nodes
[
0
]
);
var
set
=
updateLayoutVertical
(
nodes
[
0
],
parent
,
"remove"
);
for
(
var
j
=
0
;
j
<
set
.
length
;
j
++
)
{
translateNode
(
set
[
j
]
);
updateConnectAndshIcon
(
set
[
j
]
);
}
var
_buffer
=
[
nodes
[
0
]
];
while
(
_buffer
.
length
!==
0
)
{
_buffer
=
_buffer
.
concat
(
_buffer
[
0
].
getChildren
()
);
try
{
_buffer
[
0
].
getRenderContainer
().
remove
();
var
Layout
=
_buffer
[
0
].
getLayout
();
Layout
.
connect
.
remove
();
Layout
.
shicon
.
remove
();
}
catch
(
error
)
{
console
.
log
(
"isRemoved"
);
}
//检测当前节点是否在选中的数组中,如果在的话,从选中数组中去除
var
idx
=
nodes
.
indexOf
(
_buffer
[
0
]
);
if
(
idx
!==
-
1
)
{
nodes
.
splice
(
idx
,
1
);
}
_buffer
.
shift
();
}
}
},
expandNode
:
function
(
ico
)
{
var
isExpand
=
ico
.
icon
.
switchState
();
var
node
=
ico
.
icon
.
_node
;
var
_buffer
=
node
.
getChildren
();
var
_cleanbuffer
=
[];
while
(
_buffer
.
length
!==
0
)
{
var
Layout
=
_buffer
[
0
].
getLayout
();
if
(
isExpand
)
{
var
parent
=
_buffer
[
0
].
getParent
();
Layout
.
parent
=
parent
;
_cleanbuffer
.
push
(
_buffer
[
0
]
);
//minder.appendChildNode( parent, _buffer[ 0 ] );
Layout
.
connect
=
null
;
Layout
.
shicon
=
null
;
}
else
{
_buffer
[
0
].
getRenderContainer
().
remove
();
Layout
.
connect
.
remove
();
Layout
.
shicon
.
remove
();
}
_buffer
=
_buffer
.
concat
(
_buffer
[
0
].
getChildren
()
);
_buffer
.
shift
();
}
if
(
isExpand
)
{
node
.
clearChildren
();
for
(
var
j
=
0
;
j
<
_cleanbuffer
.
length
;
j
++
)
{
_cleanbuffer
[
j
].
clearChildren
();
minder
.
appendChildNode
(
_cleanbuffer
[
j
].
getLayout
().
parent
,
_cleanbuffer
[
j
]
);
}
}
var
set
=
[];
if
(
!
isExpand
)
set
=
updateLayoutVertical
(
node
,
node
.
getParent
(),
"contract"
);
for
(
var
i
=
0
;
i
<
set
.
length
;
i
++
)
{
translateNode
(
set
[
i
]
);
updateConnectAndshIcon
(
set
[
i
]
);
}
}
};
this
.
addLayoutStyle
(
"bottom"
,
_style
);
...
...
src/module/layout.default.js
View file @
2084f398
...
...
@@ -219,7 +219,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
}
else
{
if
(
action
===
"append"
||
action
===
"contract"
)
{
Layout
.
branchheight
=
node
.
getRenderContainer
().
getHeight
()
+
nodeStyle
.
margin
[
0
]
+
nodeStyle
.
margin
[
2
];
}
else
if
(
action
===
"change"
)
{
//展开
}
else
if
(
action
===
"change"
)
{
Layout
.
branchheight
=
countBranchHeight
(
node
);
}
var
parentLayout
=
parent
.
getLayout
();
...
...
themes/default/_css/markers.css
View file @
2084f398
...
...
@@ -13,7 +13,8 @@
margin
:
0
;
list-style
:
none
;
cursor
:
pointer
;
color
:
#333
color
:
#333
;
font-family
:
Arial
,
"Heiti SC"
,
"Microsoft Yahei"
;
}
.icon-list
li
:hover
,
.icon-list
li
.active
{
background
:
#cfe0f7
...
...
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