Commit af01ed18 authored by Akikonata's avatar Akikonata

changed data structure

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