From aee1dfbff99343c5e6e61d87a8bb31d1b416795b Mon Sep 17 00:00:00 2001 From: Paulo Veiga Date: Thu, 12 Jan 2012 00:49:18 -0300 Subject: [PATCH] Minor fixes for supporting shrink. --- mindplot/src/main/javascript/Designer.js | 11 ++++--- mindplot/src/main/javascript/layout/text.xml | 12 ++++++++ .../javascript/nlayout/EventBusDispatcher.js | 5 ++-- .../main/javascript/nlayout/LayoutManager.js | 13 +++------ mindplot/src/main/javascript/nlayout/Node.js | 29 ++++++++----------- 5 files changed, 36 insertions(+), 34 deletions(-) create mode 100644 mindplot/src/main/javascript/layout/text.xml diff --git a/mindplot/src/main/javascript/Designer.js b/mindplot/src/main/javascript/Designer.js index ad61ac34..6bcb7ad3 100644 --- a/mindplot/src/main/javascript/Designer.js +++ b/mindplot/src/main/javascript/Designer.js @@ -444,16 +444,15 @@ mindplot.Designer = new Class({ _nodeModelToNodeGraph : function(nodeModel, isVisible) { $assert(nodeModel, "Node model can not be null"); + var children = nodeModel.getChildren().slice(); + var nodeGraph = this._buildNodeGraph(nodeModel); - if (isVisible) + if (isVisible) { nodeGraph.setVisibility(isVisible); + } - var children = nodeModel.getChildren(); - - var workspace = this._workspace; - workspace.appendChild(nodeGraph); - + this._workspace.appendChild(nodeGraph); for (var i = 0; i < children.length; i++) { var child = children[i]; if ($defined(child)) diff --git a/mindplot/src/main/javascript/layout/text.xml b/mindplot/src/main/javascript/layout/text.xml new file mode 100644 index 00000000..0f3cdb6e --- /dev/null +++ b/mindplot/src/main/javascript/layout/text.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/mindplot/src/main/javascript/nlayout/EventBusDispatcher.js b/mindplot/src/main/javascript/nlayout/EventBusDispatcher.js index e7d164bf..fc46da03 100644 --- a/mindplot/src/main/javascript/nlayout/EventBusDispatcher.js +++ b/mindplot/src/main/javascript/nlayout/EventBusDispatcher.js @@ -77,6 +77,7 @@ mindplot.nlayout.EventBusDispatcher = new Class({ // Centra topic must not be added twice ... if (node.getId() != 0) { this._layoutManager.addNode(node.getId(), {width:10,height:10}, node.getPosition()); + this._layoutManager.updateShrinkState(node.getId(), node.areChildrenShrunken()); } }, @@ -85,12 +86,12 @@ mindplot.nlayout.EventBusDispatcher = new Class({ }, _doLayout: function() { - (function() { +// (function() { this._layoutManager.layout(true); console.log("---------"); this._layoutManager.dump(); console.log("---------"); - }).delay(0, this); +// }).delay(0, this); } }); \ No newline at end of file diff --git a/mindplot/src/main/javascript/nlayout/LayoutManager.js b/mindplot/src/main/javascript/nlayout/LayoutManager.js index edfb1b8d..522bca9d 100644 --- a/mindplot/src/main/javascript/nlayout/LayoutManager.js +++ b/mindplot/src/main/javascript/nlayout/LayoutManager.js @@ -145,16 +145,11 @@ mindplot.nlayout.LayoutManager = new Class({ } // Update nodes ... - if (node.hasOrderChanged()) { - event.setOrder(node.getOrder()); - node.resetOrderState(); + event.setOrder(node.getOrder()); + event.setPosition(node.getPosition()); - } - - if (node.hasPositionChanged()) { - event.setPosition(node.getPosition()); - node.resetPositionState(); - } + node.resetPositionState(); + node.resetOrderState(); this._events.push(event); } this._collectChanges(this._treeSet.getChildren(node)); diff --git a/mindplot/src/main/javascript/nlayout/Node.js b/mindplot/src/main/javascript/nlayout/Node.js index 7fcd8061..436299c2 100644 --- a/mindplot/src/main/javascript/nlayout/Node.js +++ b/mindplot/src/main/javascript/nlayout/Node.js @@ -51,14 +51,14 @@ mindplot.nlayout.Node = new Class({ resetPositionState : function() { var prop = this._properties['position']; if (prop) { - prop.hasChanded = false; + prop.hasChanged = false; } }, resetOrderState : function() { var prop = this._properties['order']; if (prop) { - prop.hasChanded = false; + prop.hasChanged = false; } }, @@ -71,8 +71,8 @@ mindplot.nlayout.Node = new Class({ }, hasPositionChanged: function() { - return this._isPropertyChanged('position'); + return this._isPropertyChanged('position'); }, getPosition: function() { @@ -100,17 +100,19 @@ mindplot.nlayout.Node = new Class({ var prop = this._properties[key]; if (!prop) { prop = { - hasChanded:false, + hasChanged:false, value: null, oldValue : null }; } - prop.oldValue = prop.value; - prop.value = value; - prop.hasChanded = true; - - this._properties[key] = prop; + // Only update if the property has changed ... + if (JSON.encode(prop.oldValue) != JSON.encode(value)) { + prop.oldValue = prop.value; + prop.value = value; + prop.hasChanged = true; + this._properties[key] = prop; + } }, _getProperty: function(key) { @@ -120,14 +122,7 @@ mindplot.nlayout.Node = new Class({ _isPropertyChanged: function(key) { var prop = this._properties[key]; - return prop ? prop.hasChanded : false; - }, - - _setPropertyUpdated : function(key) { - var prop = this._properties[key]; - if (prop) { - this._properties[key] = true; - } + return prop ? prop.hasChanged : false; }, getSorter: function() {