Root nodes support any position

This commit is contained in:
Gonzalo Bellver
2012-01-15 15:41:03 -03:00
parent 3eea7b9e88
commit 75af2aac87
5 changed files with 24 additions and 12 deletions

View File

@@ -22,7 +22,8 @@ mindplot.layout.SymmetricSorter = new Class({
},
predict : function(parent, graph, position) {
var direction = parent.getPosition().x > 0 ? 1 : -1;
var rootNode = graph.getRootNode(parent);
var direction = parent.getPosition().x > rootNode.getPosition().x ? 1 : -1;
// No children...
var children = graph.getChildren(parent);
@@ -112,8 +113,8 @@ mindplot.layout.SymmetricSorter = new Class({
ysum = ysum - heights[i].height;
var parent = treeSet.getParent(treeSet.find(heights[i].id));
//TODO(gb): actually compare to branch's root node position
var direction = parent.getPosition().x > 0 ? 1 : -1;
var rootNode = treeSet.getRootNode(treeSet.find(heights[i].id));
var direction = parent.getPosition().x > rootNode.getPosition().x ? 1 : -1;
var yOffset = ysum + heights[i].height / 2;
var xOffset = direction * (heights[i].width/2 + node.getSize().width/2 + mindplot.layout.SymmetricSorter.INTERNODE_HORIZONTAL_PADDING);