Fixed bug for predict in free positioning
This commit is contained in:
@@ -35,7 +35,7 @@ mindplot.layout.BalancedSorter = new Class({
|
||||
(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}};
|
||||
return [0, {x: xPos, y:position.y}];
|
||||
}
|
||||
|
||||
var rootNode = graph.getRootNode(parent);
|
||||
|
@@ -110,9 +110,6 @@ mindplot.layout.LayoutManager = new Class({
|
||||
var sorter = parent.getSorter();
|
||||
|
||||
var result = sorter.predict(this._treeSet, parent, node, position, free);
|
||||
$assert(result[0] != null, "Prediction order cannot be null");
|
||||
$assert(result[1] != null, "Prediction position cannot be null");
|
||||
$assert(result[1].x != null && result[1].y != null, "Prediction position is not valid");
|
||||
return {order:result[0],position:result[1]};
|
||||
},
|
||||
|
||||
|
@@ -25,14 +25,15 @@ mindplot.layout.SymmetricSorter = new Class({
|
||||
// If its a free node...
|
||||
if (free) {
|
||||
$assert($defined(position), "position cannot be null for predict in free positioning");
|
||||
$assert($defined(node), "node 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 direction = this._getRelativeDirection(rootNode.getPosition(), parent.getPosition());
|
||||
var limitXPos = parent.getPosition().x + direction * (parent.getSize().width/2 + node.getSize().width/2 + mindplot.layout.SymmetricSorter.INTERNODE_HORIZONTAL_PADDING);
|
||||
|
||||
var xPos = direction > 0 ?
|
||||
(position.x >= parent.getPosition().x ? position.x : parent.getPosition().x) :
|
||||
(position.x <= parent.getPosition().x ? position.x : parent.getPosition().x);
|
||||
(position.x >= limitXPos ? position.x : limitXPos) :
|
||||
(position.x <= limitXPos ? position.x : limitXPos) ;
|
||||
|
||||
return [0, {x: xPos, y:position.y}];
|
||||
}
|
||||
|
Reference in New Issue
Block a user