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
3f7ded0c
Commit
3f7ded0c
authored
Jan 03, 2014
by
Akikonata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dev
parent
c4682f0e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
90 additions
and
31 deletions
+90
-31
dev.html
demo/dev.html
+34
-11
connect.js
src/module/connect.js
+26
-5
layout.js
src/module/layout.js
+7
-5
render.js
src/module/render.js
+23
-10
No files found.
demo/dev.html
View file @
3f7ded0c
...
...
@@ -10,7 +10,7 @@
</body>
<script>
minder
=
new
KM
.
createMinder
(
document
.
body
,
{
modules
:
[
"ExampleModule"
,
"RenderModule"
,
"KeyboardModule"
]
modules
:
[
"ExampleModule"
,
"LayoutModule"
,
"RenderModule"
,
"KeyboardModule"
,
"ConnectModule"
]
});
minder
.
importData
({
...
...
@@ -42,19 +42,42 @@
});
var
minderWidth
=
document
.
body
.
clientWidth
;
var
minderHeight
=
document
.
body
.
clientHeight
;
console
.
log
(
minderWidth
,
minderHeight
);
minder
.
execCommand
(
'rendernode'
,
minder
,{
var
_node
=
new
MinderNode
();
_node
.
data
=
{
centerX
:
minderWidth
/
2
,
centerY
:
minderHeight
/
2
,
style
:{
radius
:
10
,
fill
:
"yellow"
,
stroke
:
"whit
e"
,
stroke
:
"orang
e"
,
color
:
"black"
,
padding
:[
10
,
10
,
10
,
10
],
fontSize
:
12
},
text
:
"node"
,
};
var
_childnode
=
new
MinderNode
();
_node
.
insertChild
(
_childnode
);
_childnode
.
data
=
{
centerX
:
minderWidth
/
2
+
200
,
centerY
:
minderHeight
/
2
+
200
,
style
:{
radius
:
10
,
fill
:
"yellow"
,
stroke
:
"orange"
,
color
:
"black"
,
padding
:[
10
,
10
,
10
,
10
],
fontSize
:
12
});
},
text
:
"node"
,
};
console
.
log
(
minderWidth
,
minderHeight
);
minder
.
execCommand
(
"createchildnode"
,
minder
,
minder
.
getRoot
(),
_node
);
minder
.
execCommand
(
"rendernode"
,
minder
,
_node
);
minder
.
execCommand
(
"rendernode"
,
minder
,
_childnode
);
minder
.
reset
();
</script>
</html>
\ No newline at end of file
src/module/connect.js
View file @
3f7ded0c
var
ConnectModule
=
KityMinder
.
registerModule
(
"ConnectModule"
,
function
()
{
return
{
"commands"
:
{
},
"events"
:
{
"command"
:
function
(
e
)
{
var
command
=
e
;
switch
(
command
.
commandName
)
{
case
"rendernode"
:
(
function
()
{
var
minder
=
command
.
commandArgs
[
0
];
var
node
=
command
.
commandArgs
[
1
];
if
(
!
node
.
parent
)
{
return
false
;
}
else
{
var
parent
=
node
.
parent
;
// var _connect = new kity.Bezier(
// [ new kity.Point( parent.data.centerX, parent.data.centerY ),
// new kity.Point( node.data.centerX, node.data.centerY )
// ] );
_connect
.
stroke
(
new
Pen
(
node
.
data
.
stroke
,
node
.
data
.
strokeWidth
)
);
minder
.
addShape
(
_connect
);
}
}
)();
break
;
case
"erasenode"
:
break
;
default
:
break
;
};
}
}
};
}
);
\ No newline at end of file
src/module/layout.js
View file @
3f7ded0c
...
...
@@ -3,8 +3,8 @@ KityMinder.registerModule( "LayoutModule", function () {
return
{
base
:
Command
,
execute
:
function
(
km
,
parent
)
{
execute
:
function
(
km
,
parent
,
node
)
{
parent
.
insertChild
(
node
);
}
}
}
)()
);
...
...
@@ -12,8 +12,9 @@ KityMinder.registerModule( "LayoutModule", function () {
return
{
base
:
Command
,
execute
:
function
(
km
,
sibling
)
{
execute
:
function
(
km
,
sibling
,
node
)
{
var
parent
=
sibling
.
getParent
();
parent
.
insertChild
(
node
);
}
}
}
)()
);
...
...
@@ -22,7 +23,8 @@ KityMinder.registerModule( "LayoutModule", function () {
return
{
base
:
Command
,
execute
:
function
(
km
,
node
)
{
var
parent
=
sibling
.
getParent
();
parent
.
removeChild
(
node
);
}
}
}
)()
);
...
...
src/module/render.js
View file @
3f7ded0c
...
...
@@ -3,14 +3,18 @@ KityMinder.registerModule( "RenderModule", function () {
var
node_default
=
{
centerX
:
0
,
centerY
:
0
,
radius
:
5
,
text
:
"Root"
,
style
:
{
fill
:
"#7ecef4"
,
stroke
:
"white"
,
padding
:
5
strokeWidth
:
3
,
padding
:
5
,
radius
:
5
}
};
var
renderNode
=
function
(
km
,
node
)
{
var
nodeD
=
Utils
.
extend
(
node_default
,
node
);
var
nodeD
=
Utils
.
extend
(
node_default
,
node
.
data
);
var
_style
=
nodeD
.
style
;
var
kR
=
km
.
getRenderContainer
();
var
_node
=
new
kity
.
Group
();
var
_txt
=
new
kity
.
Text
(
nodeD
.
text
||
"Node"
);
...
...
@@ -19,13 +23,13 @@ KityMinder.registerModule( "RenderModule", function () {
kR
.
addShape
(
_node
);
var
txtWidth
=
_txt
.
getWidth
();
var
txtHeight
=
_txt
.
getHeight
();
var
_padding
=
nodeD
.
padding
;
var
_padding
=
_style
.
padding
;
var
_rectWidth
=
txtWidth
+
_padding
[
1
]
+
_padding
[
3
];
var
_rectHeight
=
txtHeight
+
_padding
[
0
]
+
_padding
[
2
];
console
.
log
(
_rectWidth
,
_rectHeight
);
var
_rect
=
new
kity
.
Rect
(
_rectWidth
,
_rectHeight
,
0
,
0
,
nodeD
.
radius
);
_rect
.
stroke
(
n
odeD
.
stroke
).
fill
(
nodeD
.
fill
);
var
_rect
=
new
kity
.
Rect
(
_rectWidth
,
_rectHeight
,
0
,
0
,
_style
.
radius
);
_rect
.
stroke
(
n
ew
kity
.
Pen
(
_style
.
stroke
,
_style
.
strokeWidth
)
).
fill
(
_style
.
fill
);
_node
.
addShape
(
_rect
).
bringTop
(
_txt
);
_node
.
translate
(
nodeD
.
centerX
-
_rectWidth
/
2
,
nodeD
.
centerY
-
_rectHeight
/
2
);
_txt
.
setX
(
_padding
[
3
]
).
setY
(
_padding
[
0
]
+
txtHeight
);
...
...
@@ -33,19 +37,28 @@ KityMinder.registerModule( "RenderModule", function () {
return
{
base
:
Command
,
execute
:
function
(
km
,
node
Data
)
{
execute
:
function
(
km
,
node
)
{
renderNode
(
km
,
node
);
}
};
}
)()
);
var
EraseNodeCommand
=
kity
.
createClass
(
"EraseNodeCommand"
,
(
function
()
{
return
{
base
:
Command
,
execute
:
function
(
km
,
node
)
{
}
}
}
)()
);
return
{
"init"
:
function
(
config
)
{
},
"commands"
:
{
//todo:command字典,name-action 键值对模式编写
"rendernode"
:
RenderNodeCommand
"rendernode"
:
RenderNodeCommand
,
"erasenode"
:
EraseNodeCommand
},
"events"
:
{
...
...
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