Commit 8cf56d08 authored by campaign's avatar campaign

Merge branch 'dev' of https://github.com/kitygraph/kityminder into dev

parents 970939ec 0537e3e0
/** /* @require <kityminder.js>
* @require <kityminder.js>
* @require <module.js> * @require <module.js>
* @require <event.js> * @require <event.js>
* @require <node.js> * @require <node.js>
......
...@@ -64,18 +64,18 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -64,18 +64,18 @@ KityMinder.registerModule( "LayoutDefault", function () {
return { return {
constructor: function ( node ) { constructor: function ( node ) {
this._node = node; this._node = node;
var container = node.getRenderContainer(); var bgRC = node.getBgRc();
var txt = this._txt = new kity.Text(); var contRC = node.getContRc();
var rect = this._rect = new kity.Rect(); var rect = this._rect = new kity.Rect();
var shicon = this._shicon = new ShIcon( node ); var shicon = this._shicon = new ShIcon( node );
container.addShapes( [ rect, txt ] ); bgRC.addShape( rect );
var connect = this._connect = new kity.Group(); var connect = this._connect = new kity.Group();
var bezier = connect.bezier = new kity.Bezier(); var bezier = connect.bezier = new kity.Bezier();
var circle = connect.circle = new kity.Circle(); var circle = connect.circle = new kity.Circle();
connect.addShapes( [ bezier, circle ] ); connect.addShapes( [ bezier, circle ] );
minder.getRenderContainer().addShape( connect ).bringTop( minder.getRoot().getRenderContainer() ); minder.getRenderContainer().addShape( connect ).bringTop( minder.getRoot().getRenderContainer() );
var Layout = { var Layout = {
radius: 0, radius: 5,
fill: "white", fill: "white",
color: "black", color: "black",
padding: [ 5.5, 20, 5.5, 20 ], padding: [ 5.5, 20, 5.5, 20 ],
...@@ -86,19 +86,20 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -86,19 +86,20 @@ KityMinder.registerModule( "LayoutDefault", function () {
appendside: node.getData( "layout" ).appendside appendside: node.getData( "layout" ).appendside
}; };
node.setData( "layout", Layout ); node.setData( "layout", Layout );
txt.translate( Layout.padding[ 3 ], Layout.padding[ 0 ] + 15 ); contRC.translate( Layout.padding[ 3 ], Layout.padding[ 0 ] + 15 );
this.update(); this.update();
}, },
update: function () { update: function () {
var txt = this._txt;
var rect = this._rect; var rect = this._rect;
var node = this._node; var node = this._node;
var txt = node.getTextShape();
var contRC = node.getContRc();
var Layout = node.getData( "layout" ); var Layout = node.getData( "layout" );
txt.setContent( node.getData( "text" ) ).fill( Layout.color ); txt.setContent( node.getData( "text" ) ).fill( Layout.color );
var _txtWidth = txt.getWidth(); var _contRCWidth = contRC.getWidth();
var _txtHeight = txt.getHeight(); var _contRCHeight = contRC.getHeight();
var _rectWidth = _txtWidth + Layout.padding[ 1 ] + Layout.padding[ 3 ]; var _rectWidth = _contRCWidth + Layout.padding[ 1 ] + Layout.padding[ 3 ];
var _rectHeight = _txtHeight + Layout.padding[ 0 ] + Layout.padding[ 2 ]; var _rectHeight = _contRCHeight + Layout.padding[ 0 ] + Layout.padding[ 2 ];
rect.setWidth( _rectWidth ).setHeight( _rectHeight ).fill( node.getData( "highlight" ) ? "chocolate" : Layout.fill ).setRadius( Layout.radius ); rect.setWidth( _rectWidth ).setHeight( _rectHeight ).fill( node.getData( "highlight" ) ? "chocolate" : Layout.fill ).setRadius( Layout.radius );
this.updateConnect(); this.updateConnect();
this.updateShIcon(); this.updateShIcon();
...@@ -131,7 +132,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -131,7 +132,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
this._shicon.update(); this._shicon.update();
}, },
clear: function () { clear: function () {
this._node.getRenderContainer().clear(); this._node.getBgRc().clear();
this._connect.remove(); this._connect.remove();
this._shicon.remove(); this._shicon.remove();
} }
...@@ -142,12 +143,12 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -142,12 +143,12 @@ KityMinder.registerModule( "LayoutDefault", function () {
return { return {
constructor: function ( node ) { constructor: function ( node ) {
this._node = node; this._node = node;
var container = node.getRenderContainer(); var bgRC = node.getBgRc();
var txt = this._txt = new kity.Text(); var contRC = node.getContRc();
var underline = this._underline = new kity.Path(); var underline = this._underline = new kity.Path();
var shicon = this._shicon = new ShIcon( node ); var shicon = this._shicon = new ShIcon( node );
var highlightshape = this._highlightshape = new kity.Rect(); var highlightshape = this._highlightshape = new kity.Rect();
container.addShapes( [ highlightshape, underline, txt ] ); bgRC.addShapes( [ highlightshape, underline ] );
var connect = this._connect = new kity.Path(); var connect = this._connect = new kity.Path();
minder.getRenderContainer().addShape( connect ).bringTop( minder.getRoot().getRenderContainer() ); minder.getRenderContainer().addShape( connect ).bringTop( minder.getRoot().getRenderContainer() );
var Layout = { var Layout = {
...@@ -161,7 +162,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -161,7 +162,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
appendside: node.getData( "layout" ).appendside appendside: node.getData( "layout" ).appendside
}; };
node.setData( "layout", Layout ); node.setData( "layout", Layout );
txt.translate( Layout.padding[ 3 ], Layout.padding[ 0 ] + 10 ); contRC.translate( Layout.padding[ 3 ], Layout.padding[ 0 ] + 10 );
highlightshape.fill( "chocolate" ).translate( -1, 0 ); highlightshape.fill( "chocolate" ).translate( -1, 0 );
this.update(); this.update();
}, },
...@@ -170,7 +171,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -170,7 +171,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
var Layout = node.getData( "layout" ); var Layout = node.getData( "layout" );
var underline = this._underline; var underline = this._underline;
var highlightshape = this._highlightshape; var highlightshape = this._highlightshape;
var txt = this._txt; var txt = node.getTextShape();
txt.setContent( node.getData( "text" ) ).fill( Layout.color ).setSize( Layout.fontSize ); txt.setContent( node.getData( "text" ) ).fill( Layout.color ).setSize( Layout.fontSize );
var _txtWidth = txt.getWidth(); var _txtWidth = txt.getWidth();
var _txtHeight = txt.getHeight(); var _txtHeight = txt.getHeight();
...@@ -223,7 +224,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -223,7 +224,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
this._shicon.update(); this._shicon.update();
}, },
clear: function () { clear: function () {
this._node.getRenderContainer().clear(); this._node.getBgRc().clear();
this._connect.remove(); this._connect.remove();
this._shicon.remove(); this._shicon.remove();
} }
...@@ -274,7 +275,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -274,7 +275,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
rect.setWidth( _rectWidth ).setHeight( _rectHeight ).fill( node.getData( "highlight" ) ? "chocolate" : Layout.fill ).setRadius( Layout.radius ); rect.setWidth( _rectWidth ).setHeight( _rectHeight ).fill( node.getData( "highlight" ) ? "chocolate" : Layout.fill ).setRadius( Layout.radius );
}, },
clear: function () { clear: function () {
this._node.getRenderContainer().clear(); this._node.getBgRc().clear();
} }
}; };
} )() ); } )() );
...@@ -549,6 +550,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -549,6 +550,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
while ( _buffer.length !== 0 ) { while ( _buffer.length !== 0 ) {
_buffer = _buffer.concat( _buffer[ 0 ].getChildren() ); _buffer = _buffer.concat( _buffer[ 0 ].getChildren() );
_buffer[ 0 ].getData( "layout" ).shape.clear(); _buffer[ 0 ].getData( "layout" ).shape.clear();
_buffer[ 0 ].getRenderContainer().remove();
var prt = _buffer[ 0 ].getParent(); var prt = _buffer[ 0 ].getParent();
prt.removeChild( _buffer[ 0 ] ); prt.removeChild( _buffer[ 0 ] );
_buffer.shift(); _buffer.shift();
...@@ -594,6 +596,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -594,6 +596,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
while ( _buffer.length !== 0 ) { while ( _buffer.length !== 0 ) {
try { try {
_buffer[ 0 ].getData( "layout" ).shape.clear(); _buffer[ 0 ].getData( "layout" ).shape.clear();
_buffer[ 0 ].getRenderContainer().remove();
} catch ( error ) {} } catch ( error ) {}
_buffer = _buffer.concat( _buffer[ 0 ].getChildren() ); _buffer = _buffer.concat( _buffer[ 0 ].getChildren() );
_buffer.shift(); _buffer.shift();
......
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