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