diff --git a/mindplot/src/main/javascript/layout/OriginalLayout.js b/mindplot/src/main/javascript/layout/OriginalLayout.js index 17ccc17d..c437ac06 100644 --- a/mindplot/src/main/javascript/layout/OriginalLayout.js +++ b/mindplot/src/main/javascript/layout/OriginalLayout.js @@ -53,6 +53,10 @@ mindplot.layout.OriginalLayout = new Class({ var parent = this._treeSet.getParent(node); $assert(parent, "Node already disconnected"); + // Make it fixed + node.setFree(false); + node.setFreeDisplacement({x:0, y:0}); + // Remove from children list. var sorter = parent.getSorter(); sorter.detach(this._treeSet, node); @@ -86,9 +90,6 @@ mindplot.layout.OriginalLayout = new Class({ var parent = this._treeSet.getParent(node); var childrenOrderMoved = children.some(function(child) { return child.hasOrderChanged(); }); - var childrenFreeChanged = children.some(function(child) { return child.hasFreeChanged(); }); - var freeChanged = node.hasFreeChanged() || childrenFreeChanged; - // If ether any of the nodes has been changed of position or the height of the children is not // the same, children nodes must be repositioned .... var newBranchHeight = heightById[nodeId]; diff --git a/mindplot/src/test/javascript/static/TestSuite.js b/mindplot/src/test/javascript/static/TestSuite.js index b5fc9887..9ac6c16b 100644 --- a/mindplot/src/test/javascript/static/TestSuite.js +++ b/mindplot/src/test/javascript/static/TestSuite.js @@ -19,20 +19,20 @@ mindplot.layout.TestSuite = new Class({ Extends: mindplot.layout.ChildrenSorterStrategy, initialize:function() { - this.testAligned(); - this.testSymmetry(); - this.testBalanced(); - this.testEvents(); - this.testEventsComplex(); - this.testDisconnect(); - this.testReconnect(); - this.testRemoveNode(); - this.testSymmetricPredict(); - this.testBalancedPredict(); - this.testSize(); - this.testFreePosition(); - this.testFreePredict(); -// this.testReconnectFreeNode(); +// this.testAligned(); +// this.testSymmetry(); +// this.testBalanced(); +// this.testEvents(); +// this.testEventsComplex(); +// this.testDisconnect(); +// this.testReconnect(); +// this.testRemoveNode(); +// this.testSymmetricPredict(); +// this.testBalancedPredict(); +// this.testSize(); +// this.testFreePosition(); +// this.testFreePredict(); + this.testReconnectFreeNode(); }, testAligned: function() { @@ -793,6 +793,73 @@ mindplot.layout.TestSuite = new Class({ this._plotPrediction(graph, predict2); this._plotPrediction(graph, predict3); this._plotPrediction(graph, predict4); + }, + + testReconnectFreeNode: function() { + console.log("testReconnectFreeNode:"); + var position = {x:0,y:0}; + var manager = new mindplot.layout.LayoutManager(0, mindplot.layout.TestSuite.ROOT_NODE_SIZE); + + // Prepare a sample graph ... + manager.addNode(1, mindplot.layout.TestSuite.NODE_SIZE, position); + manager.addNode(2, mindplot.layout.TestSuite.NODE_SIZE, position); + manager.addNode(3, mindplot.layout.TestSuite.NODE_SIZE, position); + manager.addNode(4, mindplot.layout.TestSuite.NODE_SIZE, position); + manager.addNode(5, mindplot.layout.TestSuite.NODE_SIZE, position); + manager.addNode(6, mindplot.layout.TestSuite.NODE_SIZE, position); + manager.addNode(7, mindplot.layout.TestSuite.NODE_SIZE, position); + manager.addNode(8, mindplot.layout.TestSuite.NODE_SIZE, position); + manager.addNode(9, mindplot.layout.TestSuite.NODE_SIZE, position); + manager.addNode(10, mindplot.layout.TestSuite.NODE_SIZE, position); + manager.addNode(11, mindplot.layout.TestSuite.NODE_SIZE, position); + + manager.connectNode(0, 1, 0); + manager.connectNode(0, 2, 1); + manager.connectNode(0, 3, 2); + manager.connectNode(3, 4, 0); + manager.connectNode(3, 5, 1); + manager.connectNode(3, 6, 2); + manager.connectNode(5, 7, 0); + manager.connectNode(5, 8, 1); + manager.connectNode(5, 11, 2); + manager.connectNode(2, 9, 0); + manager.connectNode(2, 10, 1); + + manager.layout(); + manager.plot("testReconnectFreeNode1", {width:1000, height:400}); + + console.log("move node 5"); + manager.moveNode(5, {x:250, y:30}); + manager.layout(); + manager.plot("testReconnectFreeNode2", {width:1000, height:400}); + + console.log("reconnect node 5 to node 2"); + manager.disconnectNode(5); + manager.connectNode(2,5,2); + manager.layout(); + manager.plot("testReconnectFreeNode3", {width:1000, height:400}); + + console.log("move node 8"); + manager.moveNode(8, {x:-370, y:60}); + manager.layout(); + manager.plot("testReconnectFreeNode4", {width:1000, height:400}); + + //TODO(gb): fix this. node 11 is not positioned correctly + console.log("reconnect node 5 to node 10"); + manager.disconnectNode(5); + manager.connectNode(10,5,0); + manager.layout(); + manager.plot("testReconnectFreeNode5", {width:1000, height:400}); + +// console.log("reconnect node 5 to node 3"); +// manager.disconnectNode(5); +// manager.connectNode(3,5,2); +// manager.layout(); +// manager.plot("testReconnectFreeNode6", {width:1000, height:400}); + +// manager.moveNode(8, {x:370, y:30}); +// manager.layout(); +// manager.plot("testReconnectFreeNode2", {width:1000, height:400}); } }); diff --git a/mindplot/src/test/javascript/static/layout.html b/mindplot/src/test/javascript/static/layout.html index 25f7fadf..fa15e882 100644 --- a/mindplot/src/test/javascript/static/layout.html +++ b/mindplot/src/test/javascript/static/layout.html @@ -123,5 +123,14 @@

testFreePredict:

+ +

testReconnectFreeNode:

+
+
+
+
+
+
+ \ No newline at end of file