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();
|
var dragPivot = this._getDragPivot();
|
||||||
|
|
||||||
dragPivot.addToWorkspace(workspace);
|
dragPivot.addToWorkspace(workspace);
|
||||||
dragPivot.setVisibility(true);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_getDragPivot : function() {
|
_getDragPivot : function() {
|
||||||
|
@ -225,7 +225,7 @@ mindplot.StandaloneActionDispatcher = new Class({
|
|||||||
};
|
};
|
||||||
|
|
||||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds, collapse);
|
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds, collapse);
|
||||||
this.execute(command);
|
this.execute(command, false);
|
||||||
},
|
},
|
||||||
|
|
||||||
execute:function(command) {
|
execute:function(command) {
|
||||||
|
@ -28,6 +28,7 @@ mindplot.commands.GenericFunctionCommand = new Class({
|
|||||||
this._oldValues = [];
|
this._oldValues = [];
|
||||||
this._id = mindplot.Command._nextUUID();
|
this._id = mindplot.Command._nextUUID();
|
||||||
},
|
},
|
||||||
|
|
||||||
execute: function(commandContext) {
|
execute: function(commandContext) {
|
||||||
if (!this.applied) {
|
if (!this.applied) {
|
||||||
var topics = commandContext.findTopics(this._topicsIds);
|
var topics = commandContext.findTopics(this._topicsIds);
|
||||||
@ -41,6 +42,7 @@ mindplot.commands.GenericFunctionCommand = new Class({
|
|||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
undoExecute: function(commandContext) {
|
undoExecute: function(commandContext) {
|
||||||
if (this.applied) {
|
if (this.applied) {
|
||||||
var topics = commandContext.findTopics(this._topicsIds);
|
var topics = commandContext.findTopics(this._topicsIds);
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mindplot.layout.AbstractBasicSorter = new Class({
|
mindplot.layout.AbstractBasicSorter = new Class({
|
||||||
Extends: mindplot.layout.ChildrenSorterStrategy,
|
Extends: mindplot.layout.ChildrenSorterStrategy,
|
||||||
|
|
||||||
@ -24,8 +25,12 @@ mindplot.layout.AbstractBasicSorter = new Class({
|
|||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_getVerticalPadding: function() {
|
||||||
|
return mindplot.layout.AbstractBasicSorter.INTERNODE_VERTICAL_PADDING;
|
||||||
|
},
|
||||||
|
|
||||||
_computeChildrenHeight : function(treeSet, node, heightCache) {
|
_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 result;
|
||||||
var children = treeSet.getChildren(node);
|
var children = treeSet.getChildren(node);
|
||||||
@ -54,6 +59,7 @@ mindplot.layout.AbstractBasicSorter = new Class({
|
|||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
mindplot.layout.AbstractBasicSorter.INTERNODE_VERTICAL_PADDING = 5;
|
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) {
|
predict : function(parent, graph, position) {
|
||||||
|
|
||||||
if (!position) {
|
if (!position) {
|
||||||
@ -76,7 +47,7 @@ mindplot.layout.BalancedSorter = new Class({
|
|||||||
if (position.y > cpos.y) {
|
if (position.y > cpos.y) {
|
||||||
yOffset = child == last ?
|
yOffset = child == last ?
|
||||||
child.getSize().height + mindplot.layout.BalancedSorter.INTERNODE_VERTICAL_PADDING * 2 :
|
child.getSize().height + mindplot.layout.BalancedSorter.INTERNODE_VERTICAL_PADDING * 2 :
|
||||||
(children[index + 1].getPosition().y - child.getPosition().y)/2;
|
(children[index + 1].getPosition().y - child.getPosition().y) / 2;
|
||||||
result = [child.getOrder() + 2,{x:cpos.x, y:cpos.y + yOffset}];
|
result = [child.getOrder() + 2,{x:cpos.x, y:cpos.y + yOffset}];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -108,7 +79,7 @@ mindplot.layout.BalancedSorter = new Class({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var newOrder = order > (max+1) ? (max + 2) : order;
|
var newOrder = order > (max + 1) ? (max + 2) : order;
|
||||||
child.setOrder(newOrder);
|
child.setOrder(newOrder);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -167,7 +138,7 @@ mindplot.layout.BalancedSorter = new Class({
|
|||||||
}
|
}
|
||||||
|
|
||||||
var yOffset = ysum + heights[i].height / 2;
|
var yOffset = ysum + heights[i].height / 2;
|
||||||
var xOffset = direction * (node.getSize().width/2 + heights[i].width/2 + + mindplot.layout.BalancedSorter.INTERNODE_HORIZONTAL_PADDING);
|
var xOffset = direction * (node.getSize().width / 2 + heights[i].width / 2 + + mindplot.layout.BalancedSorter.INTERNODE_HORIZONTAL_PADDING);
|
||||||
|
|
||||||
$assert(!isNaN(xOffset), "xOffset can not be null");
|
$assert(!isNaN(xOffset), "xOffset can not be null");
|
||||||
$assert(!isNaN(yOffset), "yOffset can not be null");
|
$assert(!isNaN(yOffset), "yOffset can not be null");
|
||||||
@ -200,13 +171,18 @@ mindplot.layout.BalancedSorter = new Class({
|
|||||||
var factor = node.getOrder() % 2 == 0 ? 2 : 1;
|
var factor = node.getOrder() % 2 == 0 ? 2 : 1;
|
||||||
for (var i = 0; i < children.length; i++) {
|
for (var i = 0; i < children.length; i++) {
|
||||||
var order = i == 0 && factor == 1 ? 1 : (factor * i);
|
var order = i == 0 && factor == 1 ? 1 : (factor * i);
|
||||||
$assert(children[i].getOrder() == order, "Missing order elements. Missing order: " + (i*factor));
|
$assert(children[i].getOrder() == order, "Missing order elements. Missing order: " + (i * factor));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
toString:function() {
|
toString:function() {
|
||||||
return "Balanced Sorter";
|
return "Balanced Sorter";
|
||||||
|
},
|
||||||
|
|
||||||
|
_getVerticalPadding:function() {
|
||||||
|
return mindplot.layout.BalancedSorter.INTERNODE_VERTICAL_PADDING;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
mindplot.layout.BalancedSorter.INTERNODE_VERTICAL_PADDING = 5;
|
mindplot.layout.BalancedSorter.INTERNODE_VERTICAL_PADDING = 5;
|
||||||
|
@ -27,8 +27,6 @@ mindplot.layout.EventBusDispatcher = new Class({
|
|||||||
this._layoutManager.addEvent('change', function(event) {
|
this._layoutManager.addEvent('change', function(event) {
|
||||||
var id = event.getId();
|
var id = event.getId();
|
||||||
var topic = designerModel.findTopicById(id);
|
var topic = designerModel.findTopicById(id);
|
||||||
console.log("Modify position to:" + id);
|
|
||||||
|
|
||||||
topic.setPosition(event.getPosition());
|
topic.setPosition(event.getPosition());
|
||||||
topic.setOrder(event.getOrder());
|
topic.setOrder(event.getOrder());
|
||||||
});
|
});
|
||||||
@ -88,9 +86,10 @@ mindplot.layout.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("---------");
|
||||||
|
// console.log("---------");
|
||||||
// }).delay(0, this);
|
// }).delay(0, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -39,9 +39,12 @@ mindplot.layout.LayoutManager = new Class({
|
|||||||
|
|
||||||
updateShrinkState: function(id, value) {
|
updateShrinkState: function(id, value) {
|
||||||
$assert($defined(id), "id can not be null");
|
$assert($defined(id), "id can not be null");
|
||||||
|
$assert($defined(value), "value can not be null");
|
||||||
|
|
||||||
var node = this._treeSet.find(id);
|
var node = this._treeSet.find(id);
|
||||||
node.setShrunken(value);
|
node.setShrunken(value);
|
||||||
|
|
||||||
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
find: function(id) {
|
find: function(id) {
|
||||||
@ -53,6 +56,7 @@ mindplot.layout.LayoutManager = new Class({
|
|||||||
$assert($defined(position), "position cannot be null");
|
$assert($defined(position), "position cannot be null");
|
||||||
$assert($defined(position.x), "x can not be null");
|
$assert($defined(position.x), "x can not be null");
|
||||||
$assert($defined(position.y), "y can not be null");
|
$assert($defined(position.y), "y can not be null");
|
||||||
|
|
||||||
var node = this._treeSet.find(id);
|
var node = this._treeSet.find(id);
|
||||||
node.setFree(true);
|
node.setFree(true);
|
||||||
node.setFreeDisplacement({x:position.x - node.getPosition().x, y:position.y-node.getPosition().y});
|
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._collectChanges(this._treeSet.getChildren(node));
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -135,12 +135,12 @@ mindplot.layout.Node = new Class({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only update if the property has changed ...
|
// 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.oldValue = prop.value;
|
||||||
prop.value = value;
|
prop.value = value;
|
||||||
prop.hasChanged = true;
|
prop.hasChanged = true;
|
||||||
this._properties[key] = prop;
|
|
||||||
}
|
}
|
||||||
|
this._properties[key] = prop;
|
||||||
},
|
},
|
||||||
|
|
||||||
_getProperty: function(key) {
|
_getProperty: function(key) {
|
||||||
@ -159,7 +159,7 @@ mindplot.layout.Node = new Class({
|
|||||||
|
|
||||||
|
|
||||||
toString: function() {
|
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);
|
var children = graph.getChildren(parent);
|
||||||
if (children.length == 0) {
|
if (children.length == 0) {
|
||||||
position = position || {x:parent.getPosition().x + direction, y:parent.getPosition().y};
|
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),
|
x: parent.getPosition().x + direction * (parent.getSize().width + mindplot.layout.SymmetricSorter.INTERNODE_HORIZONTAL_PADDING),
|
||||||
y:parent.getPosition().y
|
y:parent.getPosition().y
|
||||||
}
|
};
|
||||||
return [0, position];
|
return [0, pos];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to fit within ...
|
// Try to fit within ...
|
||||||
@ -43,9 +43,9 @@ mindplot.layout.SymmetricSorter = new Class({
|
|||||||
children.each(function(child, index) {
|
children.each(function(child, index) {
|
||||||
var cpos = child.getPosition();
|
var cpos = child.getPosition();
|
||||||
if (position.y > cpos.y) {
|
if (position.y > cpos.y) {
|
||||||
yOffset = child == last ?
|
var yOffset = child == last ?
|
||||||
child.getSize().height + mindplot.layout.SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2 :
|
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;
|
(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}];
|
result = [child.getOrder() + 1,{x:cpos.x, y:cpos.y + yOffset}];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -118,7 +118,7 @@ mindplot.layout.SymmetricSorter = new Class({
|
|||||||
var direction = parent.getPosition().x > rootNode.getPosition().x ? 1 : -1;
|
var direction = parent.getPosition().x > rootNode.getPosition().x ? 1 : -1;
|
||||||
|
|
||||||
var yOffset = ysum + heights[i].height / 2;
|
var yOffset = ysum + heights[i].height / 2;
|
||||||
var xOffset = direction * (heights[i].width/2 + node.getSize().width/2 + mindplot.layout.SymmetricSorter.INTERNODE_HORIZONTAL_PADDING);
|
var xOffset = direction * (heights[i].width / 2 + node.getSize().width / 2 + mindplot.layout.SymmetricSorter.INTERNODE_HORIZONTAL_PADDING);
|
||||||
|
|
||||||
$assert(!isNaN(xOffset), "xOffset can not be null");
|
$assert(!isNaN(xOffset), "xOffset can not be null");
|
||||||
$assert(!isNaN(yOffset), "yOffset can not be null");
|
$assert(!isNaN(yOffset), "yOffset can not be null");
|
||||||
|
@ -164,7 +164,8 @@ mindplot.model.INodeModel = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
areChildrenShrunken : function() {
|
areChildrenShrunken : function() {
|
||||||
return this.getProperty('shrunken');
|
var result = this.getProperty('shrunken');
|
||||||
|
return $defined(result) ? result : false;
|
||||||
},
|
},
|
||||||
|
|
||||||
setChildrenShrunken : function(value) {
|
setChildrenShrunken : function(value) {
|
||||||
|
Loading…
Reference in New Issue
Block a user