predict method refactored: it now includes the node for the prediction

This commit is contained in:
Gonzalo Bellver
2012-02-01 12:15:19 -03:00
parent 23f3ef71bb
commit cb23c48740
10 changed files with 99 additions and 63 deletions

View File

@@ -22,7 +22,23 @@ mindplot.layout.BalancedSorter = new Class({
},
predict : function(parent, graph, position) {
predict : function(graph, parent, node, position, free) {
// If its a free node...
if (free) {
$assert($defined(position), "position cannot be null for predict in free positioning");
//TODO(gb): check this. Should direction be obtained by the sorter?
var rootNode = graph.getRootNode(parent);
var direction = parent.getPosition().x > rootNode.getPosition().x ? 1 : -1;
var xPos = direction > 0 ?
(position.x >= parent.getPosition().x ? position.x : parent.getPosition().x) :
(position.x <= parent.getPosition().x ? position.x : parent.getPosition().x);
return {order:0, position:{x: xPos, y:position.y}};
}
// Regular node
var rootNode = graph.getRootNode(parent);
if (!position) {