mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 14:17:57 +01:00
Fixed bug for predict in free positioning
This commit is contained in:
parent
a0b838a7a6
commit
7c3ffebc84
@ -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}];
|
||||
}
|
||||
|
@ -160,27 +160,26 @@ mindplot.layout.FreeTestSuite = new Class({
|
||||
var graph = manager.plot("testFreePredict1", {width:1000, height:400});
|
||||
|
||||
var pos1 = {x: 370, y:80};
|
||||
var predict1 = manager.predict(11, null, pos1, true);
|
||||
var predict1 = manager.predict(5, 11, pos1, true);
|
||||
this._plotPrediction(graph, predict1);
|
||||
$assert(predict1.position.x == pos1.x && predict1.position.y == pos1.y, "free predict should return the same position");
|
||||
|
||||
var pos2 = {x: -200, y:80};
|
||||
var predict2 = manager.predict(2, null, pos2, true);
|
||||
var predict2 = manager.predict(0, 2, pos2, true);
|
||||
this._plotPrediction(graph, predict2);
|
||||
$assert(predict2.position.x == pos2.x && predict2.position.y == pos2.y, "free predict should return the same position");
|
||||
|
||||
var pos3 = {x: 200, y:30};
|
||||
var node5 = manager.find(5);
|
||||
var predict3 = manager.predict(5, null, pos3, true);
|
||||
var predict3 = manager.predict(3, 5, pos3, true);
|
||||
this._plotPrediction(graph, predict3);
|
||||
$assert(predict3.position.x == node5.getPosition().x && predict3.position.y == pos3.y, "free predict should return the x-coordinate of the node");
|
||||
|
||||
var pos4 = {x: -100, y:45};
|
||||
var node10 = manager.find(10);
|
||||
var predict4 = manager.predict(10, null, pos4, true);
|
||||
$assert(predict4.position.x == node10.getPosition().x && predict4.position.y == pos4.y, "free predict should return the x-coordinate of the node");
|
||||
|
||||
this._plotPrediction(graph, predict1);
|
||||
this._plotPrediction(graph, predict2);
|
||||
this._plotPrediction(graph, predict3);
|
||||
var predict4 = manager.predict(2, 10, pos4, true);
|
||||
this._plotPrediction(graph, predict4);
|
||||
$assert(predict4.position.x == node10.getPosition().x && predict4.position.y == pos4.y, "free predict should return the x-coordinate of the node");
|
||||
|
||||
console.log("OK!\n\n");
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user