Commit b89df8da authored by Akikonata's avatar Akikonata

changed arrangement rule

parent 5768a7b8
...@@ -17,5 +17,6 @@ ...@@ -17,5 +17,6 @@
minder = KM.createMinder(kityminder); minder = KM.createMinder(kityminder);
minder.execCommand("switchlayout","default"); minder.execCommand("switchlayout","default");
minder.execCommand("appendchildnode",new MinderNode()); minder.execCommand("appendchildnode",new MinderNode());
minder.execCommand("appendsiblingnode",new MinderNode());
</script> </script>
</html> </html>
\ No newline at end of file
...@@ -140,6 +140,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -140,6 +140,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
radius: 10, radius: 10,
fill: "skyblue", fill: "skyblue",
stroke: "orange", stroke: "orange",
strokeWidth: 1,
color: "black", color: "black",
padding: [ 5, 10, 5, 10 ], padding: [ 5, 10, 5, 10 ],
fontSize: 20, fontSize: 20,
...@@ -174,6 +175,8 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -174,6 +175,8 @@ KityMinder.registerModule( "LayoutDefault", function () {
rect.fill( _style.fill ).stroke( _style.stroke ).setRadius( _style.radius ).setWidth( _rectWidth ).setHeight( _rectHeight ); rect.fill( _style.fill ).stroke( _style.stroke ).setRadius( _style.radius ).setWidth( _rectWidth ).setHeight( _rectHeight );
if ( node.getData( "highlight" ) ) { if ( node.getData( "highlight" ) ) {
rect.stroke( new kity.Pen( "white", 3 ) ); rect.stroke( new kity.Pen( "white", 3 ) );
} else {
rect.stroke( new kity.Pen( _style.stroke, _style.strokeWidth ) );
} }
} }
}; };
...@@ -216,6 +219,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -216,6 +219,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
else shape.update(); else shape.update();
updateConnect( minder, node ); updateConnect( minder, node );
}; };
//调整node的位置 //调整node的位置
var translateNode = function ( node ) { var translateNode = function ( node ) {
var _style = node._style; var _style = node._style;
...@@ -392,7 +396,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -392,7 +396,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
} }
} }
}, },
appendChildNode: function ( parent, node ) { appendChildNode: function ( parent, node, index ) {
var appendside = parent.getData( "appendside" ); var appendside = parent.getData( "appendside" );
if ( parent === root ) { if ( parent === root ) {
var leftList = parent.getData( "leftList" ); var leftList = parent.getData( "leftList" );
...@@ -407,21 +411,22 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -407,21 +411,22 @@ KityMinder.registerModule( "LayoutDefault", function () {
node.setData( "appendside", appendside ); node.setData( "appendside", appendside );
parent.getData( appendside + "List" ).push( node ); parent.getData( appendside + "List" ).push( node );
} }
node.setData( "appendside", appendside );
if ( appendside === "left" ) { if ( appendside === "left" ) {
node.setData( "align", "right" ); node.setData( "align", "right" );
} else { } else {
node.setData( "align", "left" ); node.setData( "align", "left" );
} }
if ( parent.getChildren().indexOf( node ) === -1 ) parent.appendChild( node ); if ( parent.getChildren().indexOf( node ) === -1 ) parent.appendChild( node, index );
drawNode( node ); drawNode( node );
updateArrangement( node, "append" ); updateArrangement( node, "append" );
}, },
appendSiblingNode: function ( sibling, node ) { appendSiblingNode: function ( sibling, node ) {
var parent = sibling.getParent(); var parent = sibling.getParent();
var index = sibling.getIndex() + 1; var index = sibling.getIndex() + 1;
parent.appendChild( node, index ); var appendside = sibling.getData( "appendside" );
drawNode( node ); node.setData( "appendside", appendside );
updateArrangement( node, "append" ); this.appendChildNode( parent, node, index );
}, },
removeNode: function ( nodes ) { removeNode: function ( nodes ) {
var root = this.getRoot(); var root = this.getRoot();
......
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