Symmetric Sorter adapted to work on both directions

This commit is contained in:
Gonzalo Bellver
2012-01-10 09:44:33 -03:00
parent f355c5a23a
commit f3d4c3cd5d
4 changed files with 43 additions and 26 deletions

View File

@@ -132,7 +132,7 @@ mindplot.nlayout.SymetricSorter = new Class({
// Compute heights ...
var heights = children.map(function(child) {
return {id:child.getId(),height:this._computeChildrenHeight(treeSet, child)};
return {id:child.getId(), position: child.getPosition(), height: this._computeChildrenHeight(treeSet, child)};
}, this);
@@ -148,18 +148,24 @@ mindplot.nlayout.SymetricSorter = new Class({
for (var i = 0; i < heights.length; i++) {
ysum = ysum - heights[i].height;
var parent = treeSet.getParent(treeSet.find(heights[i].id));
var direction = parent.getPosition().x > 0 ? 1 : -1;
var yOffset = ysum + heights[i].height/2;
var xOffset = node.getSize().width + mindplot.nlayout.SymetricSorter.INTERNODE_HORIZONTAL_PADDING;
var xOffset = direction * (node.getSize().width + mindplot.nlayout.SymetricSorter.INTERNODE_HORIZONTAL_PADDING);
$assert(!isNaN(xOffset), "xOffset can not be null");
$assert(!isNaN(yOffset), "yOffset can not be null");
result[heights[i].id] = {x:xOffset,y:yOffset};
}
return result;
},
_getRootNode: function(treeSet) {
var roots = treeSet.getTreeRoots();
},
toString:function() {
return "Symmetric Sorter";
}