Minor fixes for supporting shrink.

This commit is contained in:
Paulo Veiga 2012-01-12 00:49:18 -03:00
parent ef2902d724
commit aee1dfbff9
5 changed files with 36 additions and 34 deletions

View File

@ -444,16 +444,15 @@ mindplot.Designer = new Class({
_nodeModelToNodeGraph : function(nodeModel, isVisible) { _nodeModelToNodeGraph : function(nodeModel, isVisible) {
$assert(nodeModel, "Node model can not be null"); $assert(nodeModel, "Node model can not be null");
var children = nodeModel.getChildren().slice();
var nodeGraph = this._buildNodeGraph(nodeModel); var nodeGraph = this._buildNodeGraph(nodeModel);
if (isVisible) if (isVisible) {
nodeGraph.setVisibility(isVisible); nodeGraph.setVisibility(isVisible);
}
var children = nodeModel.getChildren(); this._workspace.appendChild(nodeGraph);
var workspace = this._workspace;
workspace.appendChild(nodeGraph);
for (var i = 0; i < children.length; i++) { for (var i = 0; i < children.length; i++) {
var child = children[i]; var child = children[i];
if ($defined(child)) if ($defined(child))

View File

@ -0,0 +1,12 @@
<map name="mapId" version="pela">
<topic central="true" id="0">
<topic position="156,-49" order="0" id="1"/>
<topic position="-156,-49" order="1" id="2"/>
<topic position="156,-16" order="2" id="3"/>
<topic position="-156,-16" order="3" id="4"/>
<topic position="156,16" order="4" id="5"/>
<topic position="-156,16" order="5" id="6"/>
<topic position="156,49" order="6" id="7"/>
<topic position="-156,49" order="7" id="8"/>
</topic>
</map>

View File

@ -77,6 +77,7 @@ mindplot.nlayout.EventBusDispatcher = new Class({
// Centra topic must not be added twice ... // Centra topic must not be added twice ...
if (node.getId() != 0) { if (node.getId() != 0) {
this._layoutManager.addNode(node.getId(), {width:10,height:10}, node.getPosition()); 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() { _doLayout: function() {
(function() { // (function() {
this._layoutManager.layout(true); this._layoutManager.layout(true);
console.log("---------"); console.log("---------");
this._layoutManager.dump(); this._layoutManager.dump();
console.log("---------"); console.log("---------");
}).delay(0, this); // }).delay(0, this);
} }
}); });

View File

@ -145,16 +145,11 @@ mindplot.nlayout.LayoutManager = new Class({
} }
// Update nodes ... // Update nodes ...
if (node.hasOrderChanged()) { event.setOrder(node.getOrder());
event.setOrder(node.getOrder()); event.setPosition(node.getPosition());
node.resetOrderState();
} node.resetPositionState();
node.resetOrderState();
if (node.hasPositionChanged()) {
event.setPosition(node.getPosition());
node.resetPositionState();
}
this._events.push(event); this._events.push(event);
} }
this._collectChanges(this._treeSet.getChildren(node)); this._collectChanges(this._treeSet.getChildren(node));

View File

@ -51,14 +51,14 @@ mindplot.nlayout.Node = new Class({
resetPositionState : function() { resetPositionState : function() {
var prop = this._properties['position']; var prop = this._properties['position'];
if (prop) { if (prop) {
prop.hasChanded = false; prop.hasChanged = false;
} }
}, },
resetOrderState : function() { resetOrderState : function() {
var prop = this._properties['order']; var prop = this._properties['order'];
if (prop) { if (prop) {
prop.hasChanded = false; prop.hasChanged = false;
} }
}, },
@ -71,8 +71,8 @@ mindplot.nlayout.Node = new Class({
}, },
hasPositionChanged: function() { hasPositionChanged: function() {
return this._isPropertyChanged('position');
return this._isPropertyChanged('position');
}, },
getPosition: function() { getPosition: function() {
@ -100,17 +100,19 @@ mindplot.nlayout.Node = new Class({
var prop = this._properties[key]; var prop = this._properties[key];
if (!prop) { if (!prop) {
prop = { prop = {
hasChanded:false, hasChanged:false,
value: null, value: null,
oldValue : null oldValue : null
}; };
} }
prop.oldValue = prop.value; // Only update if the property has changed ...
prop.value = value; if (JSON.encode(prop.oldValue) != JSON.encode(value)) {
prop.hasChanded = true; prop.oldValue = prop.value;
prop.value = value;
this._properties[key] = prop; prop.hasChanged = true;
this._properties[key] = prop;
}
}, },
_getProperty: function(key) { _getProperty: function(key) {
@ -120,14 +122,7 @@ mindplot.nlayout.Node = new Class({
_isPropertyChanged: function(key) { _isPropertyChanged: function(key) {
var prop = this._properties[key]; var prop = this._properties[key];
return prop ? prop.hasChanded : false; return prop ? prop.hasChanged : false;
},
_setPropertyUpdated : function(key) {
var prop = this._properties[key];
if (prop) {
this._properties[key] = true;
}
}, },
getSorter: function() { getSorter: function() {