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
cddde595
Commit
cddde595
authored
Jan 20, 2014
by
Akikonata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
layout style switch
parent
fcb507ae
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
15 deletions
+35
-15
dev.html
demo/dev.html
+9
-1
layout.default.js
src/module/layout.default.js
+4
-1
layout.green.js
src/module/layout.green.js
+20
-13
layout.js
src/module/layout.js
+2
-0
No files found.
demo/dev.html
View file @
cddde595
...
...
@@ -17,6 +17,14 @@
<script>
minder
=
KM
.
createMinder
(
kityminder
);
//minder.execCommand("switchlayout","green");
//minder.execCommand("appendchildnode",new MinderNode("test"));
minder
.
execCommand
(
"appendchildnode"
,
new
MinderNode
(
"test1"
));
minder
.
execCommand
(
"appendsiblingnode"
,
new
MinderNode
(
"test2"
));
minder
.
execCommand
(
"appendchildnode"
,
new
MinderNode
(
"test3"
));
minder
.
execCommand
(
"appendsiblingnode"
,
new
MinderNode
(
"test4"
));
minder
.
execCommand
(
"appendchildnode"
,
new
MinderNode
(
"test5"
));
minder
.
execCommand
(
"appendsiblingnode"
,
new
MinderNode
(
"test6"
));
minder
.
execCommand
(
"appendchildnode"
,
new
MinderNode
(
"test7"
));
minder
.
execCommand
(
"appendsiblingnode"
,
new
MinderNode
(
"test8"
));
//minder.execCommand("switchlayout","green");
</script>
</html>
\ No newline at end of file
src/module/layout.default.js
View file @
cddde595
...
...
@@ -247,6 +247,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
}
else
{
for
(
var
i
=
0
;
i
<
nodeChildren
.
length
;
i
++
)
{
var
childrenLayout1
=
nodeChildren
[
i
].
getData
(
"layout"
);
if
(
!
childrenLayout1
.
shape
)
break
;
var
childBranchHeight
=
childrenLayout1
.
branchheight
;
childrenLayout1
.
y
=
sY
+
marginTop
+
childBranchHeight
/
2
;
sY
+=
childBranchHeight
;
...
...
@@ -263,7 +264,8 @@ KityMinder.registerModule( "LayoutDefault", function () {
var
nodeLayout
=
node
.
getData
(
"layout"
);
var
children
=
nodeLayout
[
appendside
+
"List"
]
||
node
.
getChildren
();
for
(
var
i
=
0
;
i
<
children
.
length
;
i
++
)
{
sum
+=
children
[
i
].
getData
(
"layout"
).
branchheight
;
var
childLayout
=
children
[
i
].
getData
(
"layout"
);
if
(
childLayout
.
shape
)
sum
+=
childLayout
.
branchheight
;
}
return
sum
;
};
...
...
@@ -398,6 +400,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
while
(
_buffer
.
length
!==
0
)
{
_buffer
=
_buffer
.
concat
(
_buffer
[
0
].
getChildren
()
);
var
prt
=
_buffer
[
0
].
getParent
();
_buffer
[
0
].
children
=
[];
this
.
appendChildNode
(
prt
,
_buffer
[
0
]
);
_buffer
.
shift
();
}
...
...
src/module/layout.green.js
View file @
cddde595
...
...
@@ -247,6 +247,7 @@ KityMinder.registerModule( "LayoutGreen", function () {
}
else
{
for
(
var
i
=
0
;
i
<
nodeChildren
.
length
;
i
++
)
{
var
childrenLayout1
=
nodeChildren
[
i
].
getData
(
"layout"
);
if
(
!
childrenLayout1
.
shape
)
break
;
var
childBranchHeight
=
childrenLayout1
.
branchheight
;
childrenLayout1
.
y
=
sY
+
marginTop
+
childBranchHeight
/
2
;
sY
+=
childBranchHeight
;
...
...
@@ -263,7 +264,8 @@ KityMinder.registerModule( "LayoutGreen", function () {
var
nodeLayout
=
node
.
getData
(
"layout"
);
var
children
=
nodeLayout
[
appendside
+
"List"
]
||
node
.
getChildren
();
for
(
var
i
=
0
;
i
<
children
.
length
;
i
++
)
{
sum
+=
children
[
i
].
getData
(
"layout"
).
branchheight
;
var
childLayout
=
children
[
i
].
getData
(
"layout"
);
if
(
childLayout
.
shape
)
sum
+=
childLayout
.
branchheight
;
}
return
sum
;
};
...
...
@@ -286,8 +288,7 @@ KityMinder.registerModule( "LayoutGreen", function () {
prt
=
prt
.
getParent
();
}
while
(
prt
);
//遍历
var
effectRange
=
[
root
];
var
_buffer
=
effectRange
;
var
_buffer
=
[
root
];
while
(
_buffer
.
length
!==
0
)
{
_buffer
=
_buffer
.
concat
(
countY
(
_buffer
[
0
],
appendside
)
);
effectSet
.
push
(
_buffer
[
0
]
);
...
...
@@ -299,9 +300,10 @@ KityMinder.registerModule( "LayoutGreen", function () {
//以某个节点为seed对水平方向进行调整(包括调整子树)
var
updateLayoutHorizon
=
function
(
node
)
{
var
nodeLayout
=
node
.
getData
(
"layout"
);
var
effectSet
=
[
node
];
//返回受影响(即需要进行下一步translate的节点)
var
parent
=
node
.
getParent
();
var
appendside
=
node
.
getData
(
"appendside"
)
;
var
appendside
=
node
Layout
.
appendside
;
var
selfWidth
=
node
.
getRenderContainer
().
getWidth
();
var
countX
=
function
(
n
)
{
...
...
@@ -333,13 +335,13 @@ KityMinder.registerModule( "LayoutGreen", function () {
countX
(
node
);
}
//判断是否存在已绘制的孩子并对孩子位置进行调整(用于外部调用renderNode,如文本编时)
var
_buffer
=
node
.
getChildren
();
while
(
_buffer
.
length
!==
0
)
{
countX
(
_buffer
[
0
]
);
effectSet
.
push
(
_buffer
[
0
]
);
_buffer
=
_buffer
.
concat
(
_buffer
[
0
].
getChildren
()
);
_buffer
.
shift
();
}
//
var _buffer = node.getChildren();
//
while ( _buffer.length !== 0 ) {
//
countX( _buffer[ 0 ] );
//
effectSet.push( _buffer[ 0 ] );
//
_buffer = _buffer.concat( _buffer[ 0 ].getChildren() );
//
_buffer.shift();
//
}
return
effectSet
;
};
...
...
@@ -361,7 +363,6 @@ KityMinder.registerModule( "LayoutGreen", function () {
nodeShape
.
setTransform
(
new
kity
.
Matrix
().
translate
(
Layout
.
x
,
Layout
.
y
-
_rectHeight
/
2
)
);
break
;
}
updateConnect
(
minder
,
node
);
};
var
_style
=
{
renderNode
:
function
(
node
)
{
...
...
@@ -399,6 +400,7 @@ KityMinder.registerModule( "LayoutGreen", function () {
while
(
_buffer
.
length
!==
0
)
{
_buffer
=
_buffer
.
concat
(
_buffer
[
0
].
getChildren
()
);
var
prt
=
_buffer
[
0
].
getParent
();
_buffer
[
0
].
children
=
[];
this
.
appendChildNode
(
prt
,
_buffer
[
0
]
);
_buffer
.
shift
();
}
...
...
@@ -411,8 +413,8 @@ KityMinder.registerModule( "LayoutGreen", function () {
if
(
parent
.
getChildren
().
indexOf
(
node
)
===
-
1
)
{
if
(
!
index
)
parent
.
appendChild
(
node
);
else
parent
.
insertChild
(
node
,
index
);
minder
.
handelNodeInsert
(
node
);
}
minder
.
handelNodeInsert
(
node
);
if
(
parent
===
root
)
{
var
leftList
=
parentLayout
.
leftList
;
var
rightList
=
parentLayout
.
rightList
;
...
...
@@ -437,6 +439,7 @@ KityMinder.registerModule( "LayoutGreen", function () {
}
else
{
Layout
.
align
=
"left"
;
}
drawNode
(
node
);
var
set1
=
updateLayoutVertical
(
node
,
parent
,
"append"
);
var
set2
=
updateLayoutHorizon
(
node
);
...
...
@@ -453,6 +456,10 @@ KityMinder.registerModule( "LayoutGreen", function () {
},
appendSiblingNode
:
function
(
sibling
,
node
)
{
var
siblingLayout
=
sibling
.
getData
(
"layout"
);
console
.
log
(
sibling
);
if
(
!
node
.
getData
(
"layout"
)
)
{
node
.
setData
(
"layout"
,
{}
);
}
var
Layout
=
node
.
getData
(
"layout"
);
var
parent
=
sibling
.
getParent
();
var
index
=
sibling
.
getIndex
()
+
1
;
...
...
src/module/layout.js
View file @
cddde595
...
...
@@ -17,6 +17,8 @@ KityMinder.registerModule( "LayoutModule", function () {
return
this
.
getData
(
'layout'
)[
k
];
},
clearLayout
:
function
()
{
var
nLayout
=
this
.
getData
(
'layout'
);
if
(
nLayout
&&
nLayout
.
connect
)
nLayout
.
connect
.
remove
();
this
.
setData
(
'layout'
,
{}
);
this
.
getRenderContainer
().
clear
();
}
...
...
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