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
5699f69c
Commit
5699f69c
authored
Feb 12, 2014
by
techird
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of
https://github.com/kitygraph/kityminder
into dev
parents
083a7f97
4d55616b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
111 additions
and
86 deletions
+111
-86
node.js
src/core/node.js
+4
-1
font.js
src/module/font.js
+42
-19
layout.default.js
src/module/layout.default.js
+60
-65
layout.js
src/module/layout.js
+5
-1
No files found.
src/core/node.js
View file @
5699f69c
...
...
@@ -227,7 +227,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
},
clone
:
function
()
{
function
cloneNode
(
parent
,
isClonedNode
)
{
var
_tmp
=
new
KM
.
MinderNode
(
isClonedNode
.
getText
()
);
var
_tmp
=
new
KM
.
MinderNode
(
isClonedNode
.
getText
()
);
_tmp
.
data
=
Utils
.
clonePlainObject
(
isClonedNode
.
getData
()
);
_tmp
.
parent
=
parent
;
...
...
@@ -266,5 +266,8 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
},
isSelected
:
function
()
{
return
this
.
getData
(
'highlight'
)
===
true
;
},
clearChildren
:
function
()
{
this
.
children
=
[];
}
}
);
\ No newline at end of file
src/module/font.js
View file @
5699f69c
KityMinder
.
registerModule
(
"fontmodule"
,
function
()
{
return
{
defaultOptions
:{
'fontfamily'
:
[
{
name
:
'songti'
,
val
:
'宋体,SimSun'
},
{
name
:
'yahei'
,
val
:
'微软雅黑,Microsoft YaHei'
},
{
name
:
'kaiti'
,
val
:
'楷体,楷体_GB2312, SimKai'
},
{
name
:
'heiti'
,
val
:
'黑体, SimHei'
},
{
name
:
'lishu'
,
val
:
'隶书, SimLi'
},
{
name
:
'andaleMono'
,
val
:
'andale mono'
},
{
name
:
'arial'
,
val
:
'arial, helvetica,sans-serif'
},
{
name
:
'arialBlack'
,
val
:
'arial black,avant garde'
},
{
name
:
'comicSansMs'
,
val
:
'comic sans ms'
},
{
name
:
'impact'
,
val
:
'impact,chicago'
},
{
name
:
'timesNewRoman'
,
val
:
'times new roman'
},
{
name
:
'sans-serif'
,
val
:
'sans-serif'
}
],
'fontsize'
:
[
10
,
12
,
16
,
18
,
24
,
32
,
48
]
defaultOptions
:
{
'fontfamily'
:
[
{
name
:
'songti'
,
val
:
'宋体,SimSun'
},
{
name
:
'yahei'
,
val
:
'微软雅黑,Microsoft YaHei'
},
{
name
:
'kaiti'
,
val
:
'楷体,楷体_GB2312, SimKai'
},
{
name
:
'heiti'
,
val
:
'黑体, SimHei'
},
{
name
:
'lishu'
,
val
:
'隶书, SimLi'
},
{
name
:
'andaleMono'
,
val
:
'andale mono'
},
{
name
:
'arial'
,
val
:
'arial, helvetica,sans-serif'
},
{
name
:
'arialBlack'
,
val
:
'arial black,avant garde'
},
{
name
:
'comicSansMs'
,
val
:
'comic sans ms'
},
{
name
:
'impact'
,
val
:
'impact,chicago'
},
{
name
:
'timesNewRoman'
,
val
:
'times new roman'
},
{
name
:
'sans-serif'
,
val
:
'sans-serif'
}
],
'fontsize'
:
[
10
,
12
,
16
,
18
,
24
,
32
,
48
]
},
"commands"
:
{
"forecolor"
:
kity
.
createClass
(
"fontcolorCommand"
,
{
...
...
@@ -39,7 +62,7 @@ KityMinder.registerModule( "fontmodule", function () {
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'fontfamily'
,
family
);
n
.
getTextShape
().
setAttr
(
'font-family'
,
family
);
km
.
updateLayout
(
n
)
km
.
updateLayout
(
n
)
}
)
}
}
),
...
...
@@ -50,8 +73,8 @@ KityMinder.registerModule( "fontmodule", function () {
var
nodes
=
km
.
getSelectedNodes
();
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'fontsize'
,
size
);
n
.
getTextShape
().
setSize
(
size
);
km
.
updateLayout
(
n
)
n
.
getTextShape
().
setSize
(
size
);
km
.
updateLayout
(
n
)
}
)
}
}
)
...
...
src/module/layout.default.js
View file @
5699f69c
...
...
@@ -27,7 +27,6 @@ KityMinder.registerModule( "LayoutDefault", function () {
dec
.
stroke
(
"gray"
);
minder
.
getRenderContainer
().
addShape
(
iconShape
);
iconShape
.
addShapes
(
[
circle
,
plus
,
dec
]
);
node
.
setData
(
"shicon"
,
this
);
this
.
update
();
this
.
switchState
();
},
...
...
@@ -107,15 +106,13 @@ KityMinder.registerModule( "LayoutDefault", function () {
switch
(
node
.
getType
()
)
{
case
"root"
:
case
"main"
:
if
(
!
Layout
.
bgRect
)
{
node
.
getBgRc
().
addShape
(
Layout
.
bgRect
=
new
kity
.
Rect
()
);
}
node
.
getBgRc
().
clear
().
addShape
(
Layout
.
bgRect
=
new
kity
.
Rect
()
);
Layout
.
bgRect
.
fill
(
nodeStyle
.
fill
).
setRadius
(
nodeStyle
.
radius
);
break
;
case
"sub"
:
var
underline
=
Layout
.
underline
=
new
kity
.
Path
();
var
highlightshape
=
Layout
.
highlightshape
=
new
kity
.
Rect
();
node
.
getBgRc
().
addShapes
(
[
highlightshape
,
underline
]
);
node
.
getBgRc
().
clear
().
addShapes
(
[
highlightshape
,
underline
]
);
break
;
default
:
break
;
...
...
@@ -153,7 +150,6 @@ KityMinder.registerModule( "LayoutDefault", function () {
var
_contWidth
=
contRc
.
getWidth
();
var
_contHeight
=
contRc
.
getHeight
();
Layout
.
underline
.
getDrawer
()
.
clear
()
.
moveTo
(
0
,
_contHeight
+
nodeStyle
.
padding
[
2
]
+
nodeStyle
.
padding
[
0
]
)
.
lineTo
(
_contWidth
+
nodeStyle
.
padding
[
1
]
+
nodeStyle
.
padding
[
3
],
_contHeight
+
nodeStyle
.
padding
[
2
]
+
nodeStyle
.
padding
[
0
]
);
Layout
.
underline
.
stroke
(
nodeStyle
.
stroke
);
...
...
@@ -208,7 +204,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
===
"
expand"
||
action
===
"
change"
)
{
//展开
}
else
if
(
action
===
"change"
)
{
//展开
Layout
.
branchheight
=
countBranchHeight
(
node
);
}
var
parentLayout
=
parent
.
getData
(
"layout"
);
...
...
@@ -293,6 +289,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
nodeShape
.
setTransform
(
new
kity
.
Matrix
().
translate
(
Layout
.
x
,
Layout
.
y
-
_rectHeight
/
2
)
);
break
;
}
node
.
setPoint
(
Layout
.
x
,
Layout
.
y
);
};
var
updateConnectAndshIcon
=
function
(
node
)
{
var
nodeType
=
node
.
getType
();
...
...
@@ -430,11 +427,27 @@ KityMinder.registerModule( "LayoutDefault", function () {
updateLayoutHorizon
(
_root
);
updateLayoutVertical
(
_root
);
translateNode
(
_root
);
console
.
log
(
_root
);
var
_buffer
=
[
_root
];
var
_cleanbuffer
=
[];
//打散结构
while
(
_buffer
.
length
!==
0
)
{
var
children
=
_buffer
[
0
].
getChildren
();
_buffer
=
_buffer
.
concat
(
children
);
for
(
var
i
=
0
;
i
<
children
.
length
;
i
++
)
{
children
[
i
].
getData
(
"layout"
).
parent
=
_buffer
[
0
];
}
_buffer
[
0
].
clearChildren
();
if
(
_buffer
[
0
]
!==
_root
)
_cleanbuffer
.
push
(
_buffer
[
0
]
);
_buffer
.
shift
();
}
//重组结构
for
(
var
j
=
0
;
j
<
_cleanbuffer
.
length
;
j
++
)
{
this
.
appendChildNode
(
_cleanbuffer
[
j
].
getData
(
"layout"
).
parent
,
_cleanbuffer
[
j
]
);
}
},
appendChildNode
:
function
(
parent
,
node
,
sibling
)
{
minder
.
handelNodeInsert
(
node
);
//设置align和appendside属性并在合适的位置插入节点
var
insert
=
(
parent
.
getChildren
().
indexOf
(
node
)
===
-
1
);
var
Layout
=
node
.
getData
(
"layout"
);
var
parentLayout
=
parent
.
getData
(
"layout"
);
if
(
sibling
)
{
...
...
@@ -452,24 +465,35 @@ KityMinder.registerModule( "LayoutDefault", function () {
var
prtLayout
=
parent
.
getData
(
"layout"
);
Layout
.
appendside
=
prtLayout
.
appendside
;
Layout
.
align
=
prtLayout
.
align
;
parent
.
appendChild
(
node
);
}
else
{
if
(
parentLayout
.
rightList
.
length
>
1
&&
parentLayout
.
rightList
.
length
>
parentLayout
.
leftList
.
length
)
{
Layout
.
appendside
=
"left"
;
Layout
.
align
=
"right"
;
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
{
Layout
.
appendside
=
"right"
;
Layout
.
align
=
"left"
;
if
(
parentLayout
.
rightList
.
length
>
1
&&
parentLayout
.
rightList
.
length
>
parentLayout
.
leftList
.
length
)
{
Layout
.
appendside
=
"left"
;
Layout
.
align
=
"right"
;
}
else
{
Layout
.
appendside
=
"right"
;
Layout
.
align
=
"left"
;
}
}
}
if
(
insert
)
{
if
(
parent
.
getType
()
===
"root"
)
{
var
sideList1
=
parentLayout
[
Layout
.
appendside
+
"List"
];
var
idx1
=
sideList1
.
length
;
parent
.
insertChild
(
node
,
idx1
);
sideList1
.
push
(
node
);
var
sideList1
=
parentLayout
[
Layout
.
appendside
+
"List"
];
sideList1
.
push
(
node
);
var
idx1
;
if
(
Layout
.
appendside
===
"right"
)
{
idx1
=
sideList1
.
length
;
}
else
{
parent
.
insertChild
(
node
)
;
idx1
=
parent
.
getChildren
().
length
;
}
parent
.
insertChild
(
node
,
idx1
);
}
}
//设置分支类型
...
...
@@ -539,12 +563,15 @@ KityMinder.registerModule( "LayoutDefault", function () {
var
isExpand
=
ico
.
icon
.
switchState
();
var
node
=
ico
.
icon
.
_node
;
var
_buffer
=
node
.
getChildren
();
var
_cleanbuffer
=
[];
while
(
_buffer
.
length
!==
0
)
{
var
Layout
=
_buffer
[
0
].
getData
(
"layout"
);
if
(
isExpand
)
{
var
parent
=
_buffer
[
0
].
getParent
();
minder
.
appendChildNode
(
parent
,
_buffer
[
0
]
);
Layout
.
parent
=
parent
;
_cleanbuffer
.
push
(
_buffer
[
0
]
);
//minder.appendChildNode( parent, _buffer[ 0 ] );
Layout
.
connect
=
null
;
Layout
.
shicon
=
null
;
}
else
{
...
...
@@ -555,53 +582,21 @@ KityMinder.registerModule( "LayoutDefault", function () {
_buffer
=
_buffer
.
concat
(
_buffer
[
0
].
getChildren
()
);
_buffer
.
shift
();
}
var
set
;
if
(
isExpand
)
set
=
updateLayoutVertical
(
node
,
node
.
getParent
(),
"expand"
);
else
set
=
updateLayoutVertical
(
node
,
node
.
getParent
(),
"contract"
);
if
(
isExpand
)
{
node
.
clearChildren
();
for
(
var
j
=
0
;
j
<
_cleanbuffer
.
length
;
j
++
)
{
_cleanbuffer
[
j
].
clearChildren
();
minder
.
appendChildNode
(
_cleanbuffer
[
j
].
getData
(
"layout"
).
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
(
"default"
,
_style
);
return
{
// "events": {
// "click": function ( e ) {
// var ico = e.kityEvent.targetShape.container;
// if ( ico.class === "shicon" ) {
// var isShow = ico.icon.switchState();
// var node = ico.icon._node;
// var _buffer;
// if ( isShow ) {
// _buffer = node.getChildren();
// while ( _buffer.length !== 0 ) {
// minder.appendChildNode( _buffer[ 0 ].getParent(), _buffer[ 0 ] );
// _buffer = _buffer.concat( _buffer[ 0 ].getChildren() );
// _buffer.shift();
// }
// } else {
// var Layout = node.getData( "layout" );
// var marginTop = Layout.margin[ 0 ];
// var marginBottom = Layout.margin[ 2 ];
// Layout.branchheight = node.getRenderContainer().getHeight() + marginTop + marginBottom;
// _buffer = node.getChildren();
// while ( _buffer.length !== 0 ) {
// try {
// _buffer[ 0 ].getData( "layout" ).shape.clear();
// _buffer[ 0 ].getRenderContainer().remove();
// } catch ( error ) {}
// _buffer = _buffer.concat( _buffer[ 0 ].getChildren() );
// _buffer.shift();
// }
// var set = updateLayoutVertical( node, node.getParent(), "append" );
// for ( var i = 0; i < set.length; i++ ) {
// translateNode( set[ i ] );
// }
// }
// }
// }
// }
};
return
{};
}
);
\ No newline at end of file
src/module/layout.js
View file @
5699f69c
...
...
@@ -26,6 +26,10 @@ KityMinder.registerModule( "LayoutModule", function () {
initStyle
:
function
()
{
var
curStyle
=
this
.
getCurrentStyle
();
this
.
getRenderContainer
().
clear
();
var
_root
=
this
.
getRoot
();
_root
.
preTraverse
(
function
(
n
)
{
n
.
clearLayout
();
}
);
this
.
getLayoutStyle
(
curStyle
).
initStyle
.
call
(
this
);
},
appendChildNode
:
function
(
parent
,
node
,
index
)
{
...
...
@@ -79,7 +83,7 @@ KityMinder.registerModule( "LayoutModule", function () {
var
switchLayout
=
function
(
km
,
style
)
{
var
_root
=
km
.
getRoot
();
_root
.
preTraverse
(
function
(
n
)
{
n
.
clearLayout
();
//
n.clearLayout();
n
.
setPoint
();
n
.
getBgRc
().
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