Commit af01ed18 authored by Akikonata's avatar Akikonata

changed data structure

parent 4ccb9c9b
...@@ -15,20 +15,18 @@ ...@@ -15,20 +15,18 @@
var minderHeight = document.body.clientHeight; var minderHeight = document.body.clientHeight;
var _root = minder.getRoot(); var _root = minder.getRoot();
_root.setData("data",{ _root.setData("style",{
style:{ radius:10,
radius:10, fill:"orange",
fill:"orange", stroke:"orange",
stroke:"orange", color:"black",
color:"black", padding:[10,10,10,10],
padding:[10,10,10,10], fontSize:20,
fontSize:20,
},
text:"I am the root",
}); });
_root.setData("x",minderWidth/2); _root.setData("x",minderWidth/2);
_root.setData("y",minderHeight/2); _root.setData("y",minderHeight/2);
_root.setData("align","center"); _root.setData("align","center");
_root.setData("text","I am the root");
minder.select(_root); minder.select(_root);
minder.execCommand("rendernode",_root); minder.execCommand("rendernode",_root);
......
...@@ -154,8 +154,8 @@ var ConnectModule = KityMinder.registerModule( "ConnectModule", function () { ...@@ -154,8 +154,8 @@ var ConnectModule = KityMinder.registerModule( "ConnectModule", function () {
connectExist.updateConnection(); connectExist.updateConnection();
} else { } else {
var _connect = new ConnectBezier( parent.getRenderContainer(), curnode.getRenderContainer() ); var _connect = new ConnectBezier( parent.getRenderContainer(), curnode.getRenderContainer() );
var nodeD = curnode.getData( "data" ); var nodeD = curnode.getData( "style" );
_connect.stroke( new kity.Pen( nodeD.style.stroke, nodeD.style.strokeWidth ) ); _connect.stroke( new kity.Pen( nodeD.stroke, nodeD.strokeWidth ) );
curnode.setData( "connect", _connect ); curnode.setData( "connect", _connect );
minder.getRenderContainer().addShape( _connect ); minder.getRenderContainer().addShape( _connect );
} }
......
...@@ -7,10 +7,7 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -7,10 +7,7 @@ KityMinder.registerModule( "LayoutModule", function () {
_node.setData( "x", parent.getData( "x" ) + 200 ); _node.setData( "x", parent.getData( "x" ) + 200 );
_node.setData( "y", Math.random() * 300 + 100 ); _node.setData( "y", Math.random() * 300 + 100 );
_node.setData( "align", "left" ); _node.setData( "align", "left" );
var _nodeD = { _node.setData( "text", "New Node" );
text: "New Node",
align: "left"
};
switch ( parent.branchside ) { switch ( parent.branchside ) {
case "left": case "left":
break; break;
...@@ -22,7 +19,6 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -22,7 +19,6 @@ KityMinder.registerModule( "LayoutModule", function () {
} )(); } )();
break; break;
} }
_node.setData( "data", _nodeD );
parent.insertChild( _node ); parent.insertChild( _node );
km.execCommand( 'rendernode', _node ); km.execCommand( 'rendernode', _node );
return _node; return _node;
......
...@@ -19,25 +19,22 @@ KityMinder.registerModule( "RenderModule", function () { ...@@ -19,25 +19,22 @@ KityMinder.registerModule( "RenderModule", function () {
} )() ); } )() );
var renderNode = function ( km, node ) { var renderNode = function ( km, node ) {
var node_default = { var styledefault = {
text: "Root", radius: 5,
style: { fill: "yellow",
radius: 10, stroke: "orange",
fill: "yellow", color: "black",
stroke: "orange", padding: [ 5, 5, 5, 5 ],
color: "black", fontSize: 14
padding: [ 5, 5, 5, 5 ],
fontSize: 12
}
}; };
var kR = node.getRenderContainer(); var kR = node.getRenderContainer();
var nodeShape = new MinderNodeShape( kR ); var nodeShape = new MinderNodeShape( kR );
var nd = JSON.parse( JSON.stringify( node_default ) ); var nd = JSON.parse( JSON.stringify( styledefault ) );
var nodeD = Utils.extend( nd, node.getData( "data" ) ); var nodeD = Utils.extend( nd, node.getData( "style" ) );
node.setData( "data", nodeD ); node.setData( "style", nodeD );
var _style = nodeD.style; var _style = nodeD;
nodeShape.text nodeShape.text
.setContent( nodeD.text || "Node" ) .setContent( node.getData( "text" ) || "Node" )
.setSize( nodeD.fontSize ) .setSize( nodeD.fontSize )
.fill( nodeD.color ); .fill( nodeD.color );
var txtWidth = nodeShape.text.getWidth(); var txtWidth = nodeShape.text.getWidth();
......
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