Commit d6858fca authored by Akikonata's avatar Akikonata

changed update

parent d17305ff
...@@ -127,8 +127,6 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -127,8 +127,6 @@ KityMinder.registerModule( "LayoutDefault", function () {
var nodeType = node.getType(); var nodeType = node.getType();
var nodeStyle = nodeStyles[ nodeType ]; var nodeStyle = nodeStyles[ nodeType ];
var txtShape = node.getTextShape(); var txtShape = node.getTextShape();
var contRc = node.getContRc();
contRc.setTransform( new kity.Matrix().translate( nodeStyle.padding[ 3 ], nodeStyle.padding[ 0 ] + nodeStyle.fontSize ) );
txtShape.fill( nodeStyle.color ).setSize( nodeStyle.fontSize ); txtShape.fill( nodeStyle.color ).setSize( nodeStyle.fontSize );
if ( nodeType === "root" ) { if ( nodeType === "root" ) {
Layout.leftList = []; Layout.leftList = [];
...@@ -166,11 +164,12 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -166,11 +164,12 @@ KityMinder.registerModule( "LayoutDefault", function () {
default: default:
break; break;
} }
contRc.setTransform( new kity.Matrix().translate( nodeStyle.padding[ 3 ], nodeStyle.padding[ 0 ] + node.getTextShape().getHeight() ) );
}; };
//计算节点在垂直方向的位置 //计算节点在垂直方向的位置
var updateLayoutVertical = function ( node, parent, action ) { var updateLayoutVertical = function ( node, parent, action ) {
var root = minder.getRoot(); var root = minder.getRoot();
var effectSet = []; var effectSet = [ node ];
var Layout = node.getData( "layout" ); var Layout = node.getData( "layout" );
var nodeShape = node.getRenderContainer(); var nodeShape = node.getRenderContainer();
var nodeType = node.getType(); var nodeType = node.getType();
...@@ -194,15 +193,20 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -194,15 +193,20 @@ KityMinder.registerModule( "LayoutDefault", function () {
} }
return sum; return sum;
} )(); } )();
return ( selfHeight > childHeight ? selfHeight : childHeight ); if ( side ) {
return childHeight;
} else {
return ( selfHeight > childHeight ? selfHeight : childHeight );
}
}; };
if ( nodeType === "root" ) { if ( nodeType === "root" ) {
effectSet.push( node );
Layout.y = minderHeight / 2; Layout.y = minderHeight / 2;
Layout.leftHeight = Layout.rightHeight = node.getRenderContainer().getHeight(); effectSet.push( node );
} else { } else {
if ( action === "append" || action === "contract" ) { //添加 if ( action === "append" || action === "contract" ) {
Layout.branchheight = node.getRenderContainer().getHeight() + nodeStyle.margin[ 0 ] + nodeStyle.margin[ 2 ]; Layout.branchheight = node.getRenderContainer().getHeight() + nodeStyle.margin[ 0 ] + nodeStyle.margin[ 2 ];
} else if ( action === "expand" || action === "change" ) { //展开
Layout.branchheight = countBranchHeight( node );
} }
var parentLayout = parent.getData( "layout" ); var parentLayout = parent.getData( "layout" );
var parentShape = parent.getRenderContainer(); var parentShape = parent.getRenderContainer();
...@@ -240,32 +244,32 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -240,32 +244,32 @@ KityMinder.registerModule( "LayoutDefault", function () {
var updateLayoutHorizon = function ( node ) { var updateLayoutHorizon = function ( node ) {
var nodeType = node.getType(); var nodeType = node.getType();
var parent = node.getParent(); var parent = node.getParent();
var effectSet = []; var effectSet = [ node ];
var Layout = node.getData( "layout" ); var Layout = node.getData( "layout" );
if ( nodeType === "root" ) { var _buffer = [ node ];
effectSet.push( node ); while ( _buffer.length !== 0 ) {
Layout.x = minderWidth / 2; var prt = _buffer[ 0 ].getParent();
} else { _buffer = _buffer.concat( _buffer[ 0 ].getChildren() );
var _buffer = [ node ]; if ( !prt ) {
while ( _buffer.length !== 0 ) { Layout.x = minderWidth / 2;
var prt = _buffer[ 0 ].getParent();
_buffer = _buffer.concat( _buffer[ 0 ].getChildren() );
var parentLayout = prt.getData( "layout" );
var parentWidth = prt.getRenderContainer().getWidth();
var parentStyle = nodeStyles[ prt.getType() ];
var childLayout = _buffer[ 0 ].getData( "layout" );
var childStyle = nodeStyles[ _buffer[ 0 ].getType() ];
if ( parentLayout.align === "center" ) {
parentWidth = parentWidth / 2;
}
if ( childLayout.appendside === "left" ) {
childLayout.x = parentLayout.x - parentWidth - parentStyle.margin[ 1 ] - childStyle.margin[ 3 ];
} else {
childLayout.x = parentLayout.x + parentWidth + parentStyle.margin[ 1 ] + childStyle.margin[ 3 ];
}
effectSet.push( _buffer[ 0 ] );
_buffer.shift(); _buffer.shift();
continue;
}
var parentLayout = prt.getData( "layout" );
var parentWidth = prt.getRenderContainer().getWidth();
var parentStyle = nodeStyles[ prt.getType() ];
var childLayout = _buffer[ 0 ].getData( "layout" );
var childStyle = nodeStyles[ _buffer[ 0 ].getType() ];
if ( parentLayout.align === "center" ) {
parentWidth = parentWidth / 2;
}
if ( childLayout.appendside === "left" ) {
childLayout.x = parentLayout.x - parentWidth - parentStyle.margin[ 1 ] - childStyle.margin[ 3 ];
} else {
childLayout.x = parentLayout.x + parentWidth + parentStyle.margin[ 1 ] + childStyle.margin[ 3 ];
} }
effectSet.push( _buffer[ 0 ] );
_buffer.shift();
} }
return effectSet; return effectSet;
}; };
...@@ -399,9 +403,12 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -399,9 +403,12 @@ KityMinder.registerModule( "LayoutDefault", function () {
}, false ) ); }, false ) );
updateShapeByCont( node ); updateShapeByCont( node );
var set1 = updateLayoutHorizon( node ); var set1 = updateLayoutHorizon( node );
var set2 = updateLayoutVertical( node ); var set2 = updateLayoutVertical( node, node.getParent(), "change" );
var set = uSet( set1, set2 ); var set = uSet( set1, set2 );
updateConnectAndshIcon( node ); for ( var i = 0; i < set.length; i++ ) {
translateNode( set[ i ] );
updateConnectAndshIcon( set[ i ] );
}
}, },
initStyle: function () { initStyle: function () {
var _root = minder.getRoot(); var _root = minder.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