Fixed bug for free positioning of balance sorted nodes

This commit is contained in:
Gonzalo Bellver
2012-01-26 17:20:48 -03:00
parent 015703d5b8
commit 306133cd5e
4 changed files with 82 additions and 15 deletions

View File

@@ -162,7 +162,10 @@ mindplot.layout.OriginalLayout = new Class({
}
}, this);
var branchesToShift = this._treeSet.getBranchesInVerticalDirection(node, node.getFreeDisplacement().y);
var branchesToShift = this._treeSet.getBranchesInVerticalDirection(node, node.getFreeDisplacement().y).filter(function(branch) {
return !shiftedBranches.contains(branch);
});
branchesToShift.forEach(function(branch) {
var overlappingOccurs = shiftedBranches.some(function(shiftedBranch) {
return this._branchesOverlap(shiftedBranch, branch, heightById);
@@ -177,6 +180,11 @@ mindplot.layout.OriginalLayout = new Class({
},
_branchesOverlap: function(branchA, branchB, heightById) {
// a branch doesn't really overlap with itself
if (branchA == branchB) {
return false;
}
var topA = branchA.getPosition().y - heightById[branchA.getId()]/2;
var bottomA = branchA.getPosition().y + heightById[branchA.getId()]/2;
var topB = branchB.getPosition().y - heightById[branchB.getId()]/2;