mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-29 09:04:54 +01:00
Fix collapse.
This commit is contained in:
parent
171c3aee8f
commit
e5beb4f034
@ -122,7 +122,6 @@ mindplot.DragTopic = new Class({
|
||||
var dragPivot = this._getDragPivot();
|
||||
|
||||
dragPivot.addToWorkspace(workspace);
|
||||
dragPivot.setVisibility(true);
|
||||
},
|
||||
|
||||
_getDragPivot : function() {
|
||||
|
@ -225,7 +225,7 @@ mindplot.StandaloneActionDispatcher = new Class({
|
||||
};
|
||||
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds, collapse);
|
||||
this.execute(command);
|
||||
this.execute(command, false);
|
||||
},
|
||||
|
||||
execute:function(command) {
|
||||
|
@ -28,6 +28,7 @@ mindplot.commands.GenericFunctionCommand = new Class({
|
||||
this._oldValues = [];
|
||||
this._id = mindplot.Command._nextUUID();
|
||||
},
|
||||
|
||||
execute: function(commandContext) {
|
||||
if (!this.applied) {
|
||||
var topics = commandContext.findTopics(this._topicsIds);
|
||||
@ -41,6 +42,7 @@ mindplot.commands.GenericFunctionCommand = new Class({
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
undoExecute: function(commandContext) {
|
||||
if (this.applied) {
|
||||
var topics = commandContext.findTopics(this._topicsIds);
|
||||
|
@ -15,6 +15,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.layout.AbstractBasicSorter = new Class({
|
||||
Extends: mindplot.layout.ChildrenSorterStrategy,
|
||||
|
||||
@ -24,8 +25,12 @@ mindplot.layout.AbstractBasicSorter = new Class({
|
||||
return result;
|
||||
},
|
||||
|
||||
_getVerticalPadding: function() {
|
||||
return mindplot.layout.AbstractBasicSorter.INTERNODE_VERTICAL_PADDING;
|
||||
},
|
||||
|
||||
_computeChildrenHeight : function(treeSet, node, heightCache) {
|
||||
var height = node.getSize().height + (mindplot.layout.AbstractBasicSorter.INTERNODE_VERTICAL_PADDING * 2); // 2* Top and down padding;
|
||||
var height = node.getSize().height + (this._getVerticalPadding() * 2); // 2* Top and down padding;
|
||||
|
||||
var result;
|
||||
var children = treeSet.getChildren(node);
|
||||
@ -54,6 +59,7 @@ mindplot.layout.AbstractBasicSorter = new Class({
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
mindplot.layout.AbstractBasicSorter.INTERNODE_VERTICAL_PADDING = 5;
|
||||
|
@ -22,35 +22,6 @@ mindplot.layout.BalancedSorter = new Class({
|
||||
|
||||
},
|
||||
|
||||
computeChildrenIdByHeights: function(treeSet, node) {
|
||||
var result = {};
|
||||
this._computeChildrenHeight(treeSet, node, result);
|
||||
return result;
|
||||
},
|
||||
|
||||
_computeChildrenHeight : function(treeSet, node, heightCache) {
|
||||
var height = node.getSize().height + (mindplot.layout.BalancedSorter.INTERNODE_VERTICAL_PADDING * 2); // 2* Top and down padding;
|
||||
|
||||
var result;
|
||||
var children = treeSet.getChildren(node);
|
||||
if (children.length == 0 || node.areChildrenShrunken()) {
|
||||
result = height;
|
||||
} else {
|
||||
var childrenHeight = 0;
|
||||
children.forEach(function(child) {
|
||||
childrenHeight += this._computeChildrenHeight(treeSet, child, heightCache);
|
||||
}, this);
|
||||
|
||||
result = Math.max(height, childrenHeight);
|
||||
}
|
||||
|
||||
if (heightCache) {
|
||||
heightCache[node.getId()] = result;
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
predict : function(parent, graph, position) {
|
||||
|
||||
if (!position) {
|
||||
@ -206,7 +177,12 @@ mindplot.layout.BalancedSorter = new Class({
|
||||
|
||||
toString:function() {
|
||||
return "Balanced Sorter";
|
||||
},
|
||||
|
||||
_getVerticalPadding:function() {
|
||||
return mindplot.layout.BalancedSorter.INTERNODE_VERTICAL_PADDING;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
mindplot.layout.BalancedSorter.INTERNODE_VERTICAL_PADDING = 5;
|
||||
|
@ -27,8 +27,6 @@ mindplot.layout.EventBusDispatcher = new Class({
|
||||
this._layoutManager.addEvent('change', function(event) {
|
||||
var id = event.getId();
|
||||
var topic = designerModel.findTopicById(id);
|
||||
console.log("Modify position to:" + id);
|
||||
|
||||
topic.setPosition(event.getPosition());
|
||||
topic.setOrder(event.getOrder());
|
||||
});
|
||||
@ -88,9 +86,10 @@ mindplot.layout.EventBusDispatcher = new Class({
|
||||
_doLayout: function() {
|
||||
// (function() {
|
||||
this._layoutManager.layout(true);
|
||||
console.log("---------");
|
||||
// console.log("---------");
|
||||
this._layoutManager.dump();
|
||||
console.log("---------");
|
||||
// console.log("---------");
|
||||
// console.log("---------");
|
||||
// }).delay(0, this);
|
||||
},
|
||||
|
||||
|
@ -39,9 +39,12 @@ mindplot.layout.LayoutManager = new Class({
|
||||
|
||||
updateShrinkState: function(id, value) {
|
||||
$assert($defined(id), "id can not be null");
|
||||
$assert($defined(value), "value can not be null");
|
||||
|
||||
var node = this._treeSet.find(id);
|
||||
node.setShrunken(value);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
find: function(id) {
|
||||
@ -53,6 +56,7 @@ mindplot.layout.LayoutManager = new Class({
|
||||
$assert($defined(position), "position cannot be null");
|
||||
$assert($defined(position.x), "x can not be null");
|
||||
$assert($defined(position.y), "y can not be null");
|
||||
|
||||
var node = this._treeSet.find(id);
|
||||
node.setFree(true);
|
||||
node.setFreeDisplacement({x:position.x - node.getPosition().x, y:position.y-node.getPosition().y});
|
||||
@ -169,7 +173,6 @@ mindplot.layout.LayoutManager = new Class({
|
||||
}
|
||||
this._collectChanges(this._treeSet.getChildren(node));
|
||||
}, this);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -135,12 +135,12 @@ mindplot.layout.Node = new Class({
|
||||
}
|
||||
|
||||
// Only update if the property has changed ...
|
||||
if (JSON.encode(prop.oldValue) != JSON.encode(value)) {
|
||||
if (JSON.encode(prop.value) != JSON.encode(value)) {
|
||||
prop.oldValue = prop.value;
|
||||
prop.value = value;
|
||||
prop.hasChanged = true;
|
||||
this._properties[key] = prop;
|
||||
}
|
||||
this._properties[key] = prop;
|
||||
},
|
||||
|
||||
_getProperty: function(key) {
|
||||
@ -159,7 +159,7 @@ mindplot.layout.Node = new Class({
|
||||
|
||||
|
||||
toString: function() {
|
||||
return "[id:" + this.getId() + ", order:" + this.getOrder() + ", position: {" + this.getPosition().x + "," + this.getPosition().y + "}, size: {" + this.getSize().width + "," + this.getSize().height + "}";
|
||||
return "[id:" + this.getId() + ", order:" + this.getOrder() + ", position: {" + this.getPosition().x + "," + this.getPosition().y + "}, size: {" + this.getSize().width + "}," + this.getSize().height + ", shrink:" + this.areChildrenShrunken() + "]";
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -29,11 +29,11 @@ mindplot.layout.SymmetricSorter = new Class({
|
||||
var children = graph.getChildren(parent);
|
||||
if (children.length == 0) {
|
||||
position = position || {x:parent.getPosition().x + direction, y:parent.getPosition().y};
|
||||
var position = {
|
||||
var pos = {
|
||||
x: parent.getPosition().x + direction * (parent.getSize().width + mindplot.layout.SymmetricSorter.INTERNODE_HORIZONTAL_PADDING),
|
||||
y:parent.getPosition().y
|
||||
}
|
||||
return [0, position];
|
||||
};
|
||||
return [0, pos];
|
||||
}
|
||||
|
||||
// Try to fit within ...
|
||||
@ -43,7 +43,7 @@ mindplot.layout.SymmetricSorter = new Class({
|
||||
children.each(function(child, index) {
|
||||
var cpos = child.getPosition();
|
||||
if (position.y > cpos.y) {
|
||||
yOffset = child == last ?
|
||||
var yOffset = child == last ?
|
||||
child.getSize().height + mindplot.layout.SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2 :
|
||||
(children[index + 1].getPosition().y + children[index + 1].getSize().height / 2 - child.getPosition().y) / 2;
|
||||
result = [child.getOrder() + 1,{x:cpos.x, y:cpos.y + yOffset}];
|
||||
|
@ -164,7 +164,8 @@ mindplot.model.INodeModel = new Class({
|
||||
},
|
||||
|
||||
areChildrenShrunken : function() {
|
||||
return this.getProperty('shrunken');
|
||||
var result = this.getProperty('shrunken');
|
||||
return $defined(result) ? result : false;
|
||||
},
|
||||
|
||||
setChildrenShrunken : function(value) {
|
||||
|
Loading…
Reference in New Issue
Block a user