Commit 3f9f070f authored by Akikonata's avatar Akikonata

test

parent 8e87eb5e
...@@ -227,7 +227,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", { ...@@ -227,7 +227,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
}, },
clone: function () { clone: function () {
function cloneNode( parent, isClonedNode ) { function cloneNode( parent, isClonedNode ) {
var _tmp = new KM.MinderNode(isClonedNode.getText()); var _tmp = new KM.MinderNode( isClonedNode.getText() );
_tmp.data = Utils.clonePlainObject( isClonedNode.getData() ); _tmp.data = Utils.clonePlainObject( isClonedNode.getData() );
_tmp.parent = parent; _tmp.parent = parent;
...@@ -266,5 +266,8 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", { ...@@ -266,5 +266,8 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
}, },
isSelected: function () { isSelected: function () {
return this.getData( 'highlight' ) === true; return this.getData( 'highlight' ) === true;
},
clearChildren: function () {
this.children = [];
} }
} ); } );
\ No newline at end of file
...@@ -151,7 +151,6 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -151,7 +151,6 @@ KityMinder.registerModule( "LayoutDefault", function () {
var _contWidth = contRc.getWidth(); var _contWidth = contRc.getWidth();
var _contHeight = contRc.getHeight(); var _contHeight = contRc.getHeight();
Layout.underline.getDrawer() Layout.underline.getDrawer()
.clear()
.moveTo( 0, _contHeight + nodeStyle.padding[ 2 ] + nodeStyle.padding[ 0 ] ) .moveTo( 0, _contHeight + nodeStyle.padding[ 2 ] + nodeStyle.padding[ 0 ] )
.lineTo( _contWidth + nodeStyle.padding[ 1 ] + nodeStyle.padding[ 3 ], _contHeight + nodeStyle.padding[ 2 ] + nodeStyle.padding[ 0 ] ); .lineTo( _contWidth + nodeStyle.padding[ 1 ] + nodeStyle.padding[ 3 ], _contHeight + nodeStyle.padding[ 2 ] + nodeStyle.padding[ 0 ] );
Layout.underline.stroke( nodeStyle.stroke ); Layout.underline.stroke( nodeStyle.stroke );
...@@ -291,6 +290,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -291,6 +290,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
nodeShape.setTransform( new kity.Matrix().translate( Layout.x, Layout.y - _rectHeight / 2 ) ); nodeShape.setTransform( new kity.Matrix().translate( Layout.x, Layout.y - _rectHeight / 2 ) );
break; break;
} }
node.setPoint( Layout.x, Layout.y );
}; };
var updateConnectAndshIcon = function ( node ) { var updateConnectAndshIcon = function ( node ) {
var nodeType = node.getType(); var nodeType = node.getType();
...@@ -417,7 +417,6 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -417,7 +417,6 @@ KityMinder.registerModule( "LayoutDefault", function () {
//设置root的align //设置root的align
_root.getData( "layout" ).align = "center"; _root.getData( "layout" ).align = "center";
updateBg( _root ); updateBg( _root );
console.log( _root.getData( "layout" ), _root.getRenderContainer() );
initLayout( _root ); initLayout( _root );
this._fire( new MinderEvent( "beforeRenderNode", { this._fire( new MinderEvent( "beforeRenderNode", {
node: _root node: _root
...@@ -429,11 +428,27 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -429,11 +428,27 @@ KityMinder.registerModule( "LayoutDefault", function () {
updateLayoutHorizon( _root ); updateLayoutHorizon( _root );
updateLayoutVertical( _root ); updateLayoutVertical( _root );
translateNode( _root ); translateNode( _root );
console.log( _root );
var _buffer = [ _root ];
var _cleanbuffer = [];
//打散结构
while ( _buffer.length !== 0 ) {
var children = _buffer[ 0 ].getChildren();
_buffer = _buffer.concat( children );
for ( var i = 0; i < children.length; i++ ) {
children[ i ].getData( "layout" ).parent = _buffer[ 0 ];
}
_buffer[ 0 ].clearChildren();
if ( _buffer[ 0 ] !== _root ) _cleanbuffer.push( _buffer[ 0 ] );
_buffer.shift();
}
//重组结构
for ( var j = 0; j < _cleanbuffer.length; j++ ) {
this.appendChildNode( _cleanbuffer[ j ].getData( "layout" ).parent, _cleanbuffer[ j ] );
}
}, },
appendChildNode: function ( parent, node, sibling ) { appendChildNode: function ( parent, node, sibling ) {
minder.handelNodeInsert( node ); minder.handelNodeInsert( node );
//设置align和appendside属性并在合适的位置插入节点
var insert = ( parent.getChildren().indexOf( node ) === -1 );
var Layout = node.getData( "layout" ); var Layout = node.getData( "layout" );
var parentLayout = parent.getData( "layout" ); var parentLayout = parent.getData( "layout" );
if ( sibling ) { if ( sibling ) {
...@@ -451,24 +466,35 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -451,24 +466,35 @@ KityMinder.registerModule( "LayoutDefault", function () {
var prtLayout = parent.getData( "layout" ); var prtLayout = parent.getData( "layout" );
Layout.appendside = prtLayout.appendside; Layout.appendside = prtLayout.appendside;
Layout.align = prtLayout.align; Layout.align = prtLayout.align;
parent.appendChild( node );
} else { } else {
if ( parentLayout.rightList.length > 1 && parentLayout.rightList.length > parentLayout.leftList.length ) { var nodeP = node.getPoint();
Layout.appendside = "left"; if ( nodeP && nodeP.x && nodeP.y ) {
Layout.align = "right"; if ( nodeP.x > parentLayout.x ) {
Layout.appendside = "right";
Layout.align = "left";
} else {
Layout.appendside = "left";
Layout.align = "right";
}
} else { } else {
Layout.appendside = "right"; if ( parentLayout.rightList.length > 1 && parentLayout.rightList.length > parentLayout.leftList.length ) {
Layout.align = "left"; Layout.appendside = "left";
Layout.align = "right";
} else {
Layout.appendside = "right";
Layout.align = "left";
}
} }
} var sideList1 = parentLayout[ Layout.appendside + "List" ];
if ( insert ) { sideList1.push( node );
if ( parent.getType() === "root" ) { var idx1;
var sideList1 = parentLayout[ Layout.appendside + "List" ]; if ( Layout.appendside === "right" ) {
var idx1 = sideList1.length; idx1 = sideList1.length;
parent.insertChild( node, idx1 );
sideList1.push( node );
} else { } else {
parent.insertChild( node ); idx1 = parent.getChildren().length;
} }
parent.insertChild( node, idx1 );
} }
} }
//设置分支类型 //设置分支类型
......
...@@ -25,7 +25,13 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -25,7 +25,13 @@ KityMinder.registerModule( "LayoutModule", function () {
}, },
initStyle: function () { initStyle: function () {
var curStyle = this.getCurrentStyle(); var curStyle = this.getCurrentStyle();
debugger;
this.getRenderContainer().clear(); this.getRenderContainer().clear();
debugger;
var _root = this.getRoot();
_root.preTraverse( function ( n ) {
n.clearLayout();
} );
this.getLayoutStyle( curStyle ).initStyle.call( this ); this.getLayoutStyle( curStyle ).initStyle.call( this );
}, },
appendChildNode: function ( parent, node, index ) { appendChildNode: function ( parent, node, index ) {
...@@ -79,7 +85,7 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -79,7 +85,7 @@ KityMinder.registerModule( "LayoutModule", function () {
var switchLayout = function ( km, style ) { var switchLayout = function ( km, style ) {
var _root = km.getRoot(); var _root = km.getRoot();
_root.preTraverse( function ( n ) { _root.preTraverse( function ( n ) {
n.clearLayout(); //n.clearLayout();
n.setPoint(); n.setPoint();
n.getBgRc().clear(); n.getBgRc().clear();
} ); } );
......
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