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) {
$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))

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 ...
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);
}
});

View File

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

View File

@ -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
};
}
// Only update if the property has changed ...
if (JSON.encode(prop.oldValue) != JSON.encode(value)) {
prop.oldValue = prop.value;
prop.value = value;
prop.hasChanded = true;
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() {