mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-26 07:44:56 +01:00
Baseline layout, first approach
This commit is contained in:
parent
731df774a8
commit
99d7a1faaf
@ -121,7 +121,7 @@ mindplot.layout.OriginalLayout = new Class({
|
||||
var parentX = parentPosition.x;
|
||||
var parentY = parentPosition.y;
|
||||
|
||||
var newPos = {x:parentX + offset.x, y:parentY + offset.y};
|
||||
var newPos = {x:parentX + offset.x, y:parentY + offset.y + this._calculateAlignOffset(node, child, heightById)};
|
||||
this._treeSet.updateBranchPosition(child, newPos);
|
||||
}.bind(this));
|
||||
|
||||
@ -134,6 +134,38 @@ mindplot.layout.OriginalLayout = new Class({
|
||||
}, this);
|
||||
},
|
||||
|
||||
_calculateAlignOffset: function(node, child, heightById) {
|
||||
if (child.isFree()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
var offset = 0;
|
||||
|
||||
var nodeHeight = node.getSize().height;
|
||||
var childHeight = child.getSize().height;
|
||||
|
||||
var children = this._treeSet.getChildren(child);
|
||||
|
||||
if (children.length == 1 && children[0].getSize().height > childHeight) { // A
|
||||
offset = children[0].getSize().height/2 - childHeight/2;
|
||||
} else if (children.length == 1 && childHeight > children[0].getSize().height) { // B
|
||||
offset = 0;
|
||||
} else if (children.length == 1 && nodeHeight > childHeight) {
|
||||
offset = nodeHeight/2 - childHeight/2;
|
||||
}
|
||||
else if (children.length == 0 && childHeight <= nodeHeight) {
|
||||
offset = nodeHeight/2 - childHeight/2;
|
||||
}
|
||||
else if (childHeight > nodeHeight && children.length > 0) {
|
||||
offset = nodeHeight/2 - childHeight/2;
|
||||
}
|
||||
else {
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
return offset;
|
||||
},
|
||||
|
||||
_fixOverlapping: function(node, heightById) {
|
||||
var children = this._treeSet.getChildren(node);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user