Commit 3f7ded0c authored by Akikonata's avatar Akikonata

dev

parent c4682f0e
......@@ -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,
radius:10,
fill:"yellow",
stroke:"white",
color:"black",
padding:[10,10,10,10],
style:{
radius:10,
fill:"yellow",
stroke:"orange",
color:"black",
padding:[10,10,10,10],
fontSize:12
},
text:"node",
fontSize:12
});
};
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
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
......@@ -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 );
}
}
} )() );
......
......@@ -3,14 +3,18 @@ KityMinder.registerModule( "RenderModule", function () {
var node_default = {
centerX: 0,
centerY: 0,
radius: 5,
text: "Root",
fill: "#7ecef4",
stroke: "white",
padding: 5
style: {
fill: "#7ecef4",
stroke: "white",
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( nodeD.stroke ).fill( nodeD.fill );
var _rect = new kity.Rect( _rectWidth, _rectHeight, 0, 0, _style.radius );
_rect.stroke( new 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, nodeData ) {
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": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment