mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-27 00:04:55 +01:00
Node sizes for tests made more realistic
This commit is contained in:
parent
f3d4c3cd5d
commit
63876ccb38
@ -17,11 +17,11 @@
|
|||||||
*/
|
*/
|
||||||
mindplot.nlayout.TestSuite = new Class({
|
mindplot.nlayout.TestSuite = new Class({
|
||||||
Extends: mindplot.nlayout.ChildrenSorterStrategy,
|
Extends: mindplot.nlayout.ChildrenSorterStrategy,
|
||||||
|
|
||||||
initialize:function() {
|
initialize:function() {
|
||||||
this.testAligned();
|
this.testAligned();
|
||||||
this.testSymmetry();
|
this.testSymmetry();
|
||||||
this.testBalanced();
|
this.testBalanced();
|
||||||
this.testGrid();
|
|
||||||
this.testEvents();
|
this.testEvents();
|
||||||
this.testEventsComplex();
|
this.testEventsComplex();
|
||||||
this.testDisconnect();
|
this.testDisconnect();
|
||||||
@ -32,14 +32,13 @@ mindplot.nlayout.TestSuite = new Class({
|
|||||||
|
|
||||||
testAligned: function() {
|
testAligned: function() {
|
||||||
|
|
||||||
var size = {width:25,height:25};
|
|
||||||
var position = {x:0,y:0};
|
var position = {x:0,y:0};
|
||||||
var manager = new mindplot.nlayout.LayoutManager(0, size);
|
var manager = new mindplot.nlayout.LayoutManager(0, mindplot.nlayout.TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
manager.addNode(1, size, position);
|
manager.addNode(1, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(2, size, position);
|
manager.addNode(2, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(3, size, position);
|
manager.addNode(3, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(4, size, position);
|
manager.addNode(4, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.connectNode(0, 1, 0);
|
manager.connectNode(0, 1, 0);
|
||||||
manager.connectNode(1, 2, 0);
|
manager.connectNode(1, 2, 0);
|
||||||
manager.connectNode(2, 3, 0);
|
manager.connectNode(2, 3, 0);
|
||||||
@ -47,7 +46,7 @@ mindplot.nlayout.TestSuite = new Class({
|
|||||||
|
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.dump();
|
manager.dump();
|
||||||
manager.plot("testAligned", {width:300,height:200});
|
manager.plot("testAligned", {width:1200,height:200});
|
||||||
|
|
||||||
// All nodes should be vertically aligned
|
// All nodes should be vertically aligned
|
||||||
$assert(manager.find(0).getPosition().y == manager.find(1).getPosition().y, "Nodes are not aligned");
|
$assert(manager.find(0).getPosition().y == manager.find(1).getPosition().y, "Nodes are not aligned");
|
||||||
@ -57,24 +56,23 @@ mindplot.nlayout.TestSuite = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
testSymmetry: function() {
|
testSymmetry: function() {
|
||||||
var size = {width:25,height:25};
|
|
||||||
var position = {x:0,y:0};
|
var position = {x:0,y:0};
|
||||||
var manager = new mindplot.nlayout.LayoutManager(0, size);
|
var manager = new mindplot.nlayout.LayoutManager(0, mindplot.nlayout.TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
manager.addNode(1, size, position);
|
manager.addNode(1, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(2, size, position);
|
manager.addNode(2, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(3, size, position);
|
manager.addNode(3, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(4, size, position);
|
manager.addNode(4, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(5, size, position);
|
manager.addNode(5, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(6, size, position);
|
manager.addNode(6, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(7, size, position);
|
manager.addNode(7, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(8, size, position);
|
manager.addNode(8, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(9, size, position);
|
manager.addNode(9, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(10, size, position);
|
manager.addNode(10, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(11, size, position);
|
manager.addNode(11, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(12, size, position);
|
manager.addNode(12, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(13, size, position);
|
manager.addNode(13, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(14, size, position);
|
manager.addNode(14, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.connectNode(0, 14, 0);
|
manager.connectNode(0, 14, 0);
|
||||||
manager.connectNode(14, 13, 0);
|
manager.connectNode(14, 13, 0);
|
||||||
manager.connectNode(13, 1, 0);
|
manager.connectNode(13, 1, 0);
|
||||||
@ -92,115 +90,76 @@ mindplot.nlayout.TestSuite = new Class({
|
|||||||
|
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.dump();
|
manager.dump();
|
||||||
manager.plot("testSymmetry",{width:500, height:300});
|
manager.plot("testSymmetry",{width:1200, height:400});
|
||||||
|
|
||||||
//TODO(gb): make asserts
|
//TODO(gb): make asserts
|
||||||
},
|
},
|
||||||
|
|
||||||
testBalanced: function() {
|
testBalanced: function() {
|
||||||
var size = {width:80, height:30};
|
|
||||||
var plotsize = {width: 800, height:400};
|
|
||||||
var position = {x:0, y:0};
|
var position = {x:0, y:0};
|
||||||
var manager = new mindplot.nlayout.LayoutManager(0, {width:120, height:40});
|
var plotsize = {width:800, height:400};
|
||||||
|
var manager = new mindplot.nlayout.LayoutManager(0, mindplot.nlayout.TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
manager.addNode(1, size, position);
|
manager.addNode(1, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.connectNode(0, 1, 0);
|
manager.connectNode(0, 1, 0);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testBalanced1", plotsize);
|
manager.plot("testBalanced1", plotsize);
|
||||||
|
|
||||||
manager.addNode(2, size, position);
|
manager.addNode(2, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.connectNode(0, 2, 1);
|
manager.connectNode(0, 2, 1);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testBalanced2", plotsize);
|
manager.plot("testBalanced2", plotsize);
|
||||||
|
|
||||||
manager.addNode(3, size, position);
|
manager.addNode(3, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.connectNode(0, 3, 2);
|
manager.connectNode(0, 3, 2);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testBalanced3", plotsize);
|
manager.plot("testBalanced3", plotsize);
|
||||||
|
|
||||||
manager.addNode(4, size, position);
|
manager.addNode(4, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.connectNode(0, 4, 3);
|
manager.connectNode(0, 4, 3);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testBalanced4", plotsize);
|
manager.plot("testBalanced4", plotsize);
|
||||||
|
|
||||||
manager.addNode(5, size, position);
|
manager.addNode(5, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.connectNode(0, 5, 4);
|
manager.connectNode(0, 5, 4);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testBalanced5", plotsize);
|
manager.plot("testBalanced5", plotsize);
|
||||||
|
|
||||||
manager.addNode(6, size, position);
|
manager.addNode(6, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.connectNode(0, 6, 5);
|
manager.connectNode(0, 6, 5);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testBalanced6", plotsize);
|
manager.plot("testBalanced6", plotsize);
|
||||||
|
|
||||||
manager.addNode(7, size, position);
|
manager.addNode(7, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(8, size, position);
|
manager.addNode(8, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(9, size, position);
|
manager.addNode(9, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.connectNode(3, 7, 0)
|
manager.connectNode(3, 7, 0)
|
||||||
manager.connectNode(7, 8, 0)
|
manager.connectNode(7, 8, 0)
|
||||||
manager.connectNode(7, 9, 1);
|
manager.connectNode(7, 9, 1);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testBalanced7", plotsize);
|
manager.plot("testBalanced7", plotsize);
|
||||||
|
|
||||||
manager.addNode(10, size, position);
|
manager.addNode(10, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(11, size, position);
|
manager.addNode(11, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(12, size, position);
|
manager.addNode(12, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.connectNode(6, 10, 0)
|
manager.connectNode(6, 10, 0)
|
||||||
manager.connectNode(10, 11, 0)
|
manager.connectNode(10, 11, 0)
|
||||||
manager.connectNode(10, 12, 1);
|
manager.connectNode(10, 12, 1);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testBalanced8", plotsize);
|
manager.plot("testBalanced8", plotsize);
|
||||||
},
|
|
||||||
|
|
||||||
testGrid: function() {
|
|
||||||
var size = {width:25,height:25};
|
|
||||||
var position = {x:0,y:0};
|
|
||||||
var manager = new mindplot.nlayout.LayoutManager(0, size);
|
|
||||||
|
|
||||||
manager.addNode(1, size, position);
|
|
||||||
manager.connectNode(0, 1, 0);
|
|
||||||
manager.layout();
|
|
||||||
manager.plot("testGrid1");
|
|
||||||
|
|
||||||
manager.addNode(2, size, position);
|
|
||||||
manager.connectNode(0, 2, 1);
|
|
||||||
manager.layout();
|
|
||||||
manager.plot("testGrid2");
|
|
||||||
|
|
||||||
manager.addNode(3, size, position);
|
|
||||||
manager.connectNode(0, 3, 2);
|
|
||||||
manager.layout();
|
|
||||||
manager.plot("testGrid3");
|
|
||||||
|
|
||||||
manager.addNode(4, size, position);
|
|
||||||
manager.connectNode(0, 4, 3);
|
|
||||||
manager.layout();
|
|
||||||
manager.plot("testGrid4");
|
|
||||||
|
|
||||||
manager.addNode(5, size, position);
|
|
||||||
manager.addNode(6, size, position);
|
|
||||||
manager.addNode(7, size, position);
|
|
||||||
manager.connectNode(2, 5, 0);
|
|
||||||
manager.connectNode(2, 6, 1);
|
|
||||||
manager.connectNode(6, 7, 0);
|
|
||||||
manager.layout();
|
|
||||||
manager.plot("testGrid5", {width:300, height:300});
|
|
||||||
|
|
||||||
manager.dump();
|
|
||||||
|
|
||||||
//TODO(gb): make asserts
|
//TODO(gb): make asserts
|
||||||
},
|
},
|
||||||
|
|
||||||
testEvents: function() {
|
testEvents: function() {
|
||||||
var size = {width:25,height:25};
|
|
||||||
var position = {x:0,y:0};
|
var position = {x:0,y:0};
|
||||||
var manager = new mindplot.nlayout.LayoutManager(0, size);
|
var manager = new mindplot.nlayout.LayoutManager(0, mindplot.nlayout.TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
// Add 3 nodes...
|
// Add 3 nodes...
|
||||||
manager.addNode(1, size, position);
|
manager.addNode(1, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(2, size, position);
|
manager.addNode(2, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(3, size, position);
|
manager.addNode(3, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(4, size, position);
|
manager.addNode(4, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
|
|
||||||
// Now connect one with two....
|
// Now connect one with two....
|
||||||
manager.connectNode(0, 1, 0);
|
manager.connectNode(0, 1, 0);
|
||||||
@ -216,27 +175,28 @@ mindplot.nlayout.TestSuite = new Class({
|
|||||||
});
|
});
|
||||||
manager.layout(true);
|
manager.layout(true);
|
||||||
manager.dump();
|
manager.dump();
|
||||||
manager.plot("testEvents1");
|
manager.plot("testEvents1", {width:800, height:400});
|
||||||
|
|
||||||
// Ok, if a new node is added, this an event should be fired ...
|
// Ok, if a new node is added, this an event should be fired ...
|
||||||
console.log("---- Layout without changes should not affect the tree ---");
|
console.log("---- Layout without changes should not affect the tree ---");
|
||||||
events.empty();
|
events.empty();
|
||||||
manager.layout(true);
|
manager.layout(true);
|
||||||
manager.plot("testEvents2");
|
manager.plot("testEvents2", {width:800, height:400});
|
||||||
|
|
||||||
$assert(events.length == 0, "Unnecessary tree updated.");
|
$assert(events.length == 0, "Unnecessary tree updated.");
|
||||||
|
|
||||||
|
//TODO(gb): make asserts
|
||||||
},
|
},
|
||||||
|
|
||||||
testEventsComplex: function() {
|
testEventsComplex: function() {
|
||||||
var size = {width:25,height:25};
|
|
||||||
var position = {x:0,y:0};
|
var position = {x:0,y:0};
|
||||||
var manager = new mindplot.nlayout.LayoutManager(0, size);
|
var manager = new mindplot.nlayout.LayoutManager(0, mindplot.nlayout.TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
// Add 3 nodes...
|
// Add 3 nodes...
|
||||||
manager.addNode(1, size, position);
|
manager.addNode(1, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(2, size, position);
|
manager.addNode(2, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(3, size, position);
|
manager.addNode(3, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(4, size, position);
|
manager.addNode(4, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
|
|
||||||
// Now connect one with two....
|
// Now connect one with two....
|
||||||
manager.connectNode(0, 1, 0);
|
manager.connectNode(0, 1, 0);
|
||||||
@ -252,7 +212,7 @@ mindplot.nlayout.TestSuite = new Class({
|
|||||||
// Reposition ...
|
// Reposition ...
|
||||||
manager.layout(true);
|
manager.layout(true);
|
||||||
manager.dump();
|
manager.dump();
|
||||||
manager.plot("testEventsComplex1");
|
manager.plot("testEventsComplex1", {width:800, height:400});
|
||||||
|
|
||||||
// Add a new node and connect. Only children nodes should be affected.
|
// Add a new node and connect. Only children nodes should be affected.
|
||||||
console.log("---- Connect a new node ---");
|
console.log("---- Connect a new node ---");
|
||||||
@ -261,22 +221,23 @@ mindplot.nlayout.TestSuite = new Class({
|
|||||||
manager.connectNode(1, 4, 2);
|
manager.connectNode(1, 4, 2);
|
||||||
manager.layout(true);
|
manager.layout(true);
|
||||||
manager.dump();
|
manager.dump();
|
||||||
manager.plot("testEventsComplex2");
|
manager.plot("testEventsComplex2", {width:800, height:400});
|
||||||
|
|
||||||
// @todo: This seems no to be ok...
|
// @todo: This seems no to be ok...
|
||||||
$assert(events.length == 4, "Only 3 nodes should be repositioned.");
|
$assert(events.length == 4, "Only 3 nodes should be repositioned.");
|
||||||
|
|
||||||
|
//TODO(gb): make asserts
|
||||||
},
|
},
|
||||||
|
|
||||||
testDisconnect: function() {
|
testDisconnect: function() {
|
||||||
var size = {width:25,height:25};
|
|
||||||
var position = {x:0,y:0};
|
var position = {x:0,y:0};
|
||||||
var manager = new mindplot.nlayout.LayoutManager(0, size);
|
var manager = new mindplot.nlayout.LayoutManager(0, mindplot.nlayout.TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
// Prepare a sample graph ...
|
// Prepare a sample graph ...
|
||||||
manager.addNode(1, size, position);
|
manager.addNode(1, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(2, size, position);
|
manager.addNode(2, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(3, size, position);
|
manager.addNode(3, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(4, size, position);
|
manager.addNode(4, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
|
|
||||||
manager.connectNode(0, 1, 0);
|
manager.connectNode(0, 1, 0);
|
||||||
manager.connectNode(1, 2, 0);
|
manager.connectNode(1, 2, 0);
|
||||||
@ -294,7 +255,7 @@ mindplot.nlayout.TestSuite = new Class({
|
|||||||
});
|
});
|
||||||
manager.layout(true);
|
manager.layout(true);
|
||||||
manager.dump();
|
manager.dump();
|
||||||
manager.plot("testDisconnect1", {width:300, height:200});
|
manager.plot("testDisconnect1", {width:800, height:400});
|
||||||
|
|
||||||
// Now, disconnect one node ...
|
// Now, disconnect one node ...
|
||||||
console.log("--- Disconnect a single node ---");
|
console.log("--- Disconnect a single node ---");
|
||||||
@ -302,7 +263,7 @@ mindplot.nlayout.TestSuite = new Class({
|
|||||||
manager.disconnectNode(2);
|
manager.disconnectNode(2);
|
||||||
manager.layout(true);
|
manager.layout(true);
|
||||||
manager.dump();
|
manager.dump();
|
||||||
manager.plot("testDisconnect2", {width:300, height:200});
|
manager.plot("testDisconnect2", {width:800, height:400});
|
||||||
|
|
||||||
$assert(events.some(
|
$assert(events.some(
|
||||||
function(event) {
|
function(event) {
|
||||||
@ -314,31 +275,32 @@ mindplot.nlayout.TestSuite = new Class({
|
|||||||
manager.disconnectNode(3);
|
manager.disconnectNode(3);
|
||||||
manager.layout(true);
|
manager.layout(true);
|
||||||
manager.dump();
|
manager.dump();
|
||||||
manager.plot("testDisconnect3", {width:300, height:200});
|
manager.plot("testDisconnect3", {width:800, height:400});
|
||||||
|
|
||||||
$assert(events.some(
|
$assert(events.some(
|
||||||
function(event) {
|
function(event) {
|
||||||
return event.getId() == 2;
|
return event.getId() == 2;
|
||||||
}), "Event for disconnected node seems not to be propagated");
|
}), "Event for disconnected node seems not to be propagated");
|
||||||
|
|
||||||
|
//TODO(gb): make asserts
|
||||||
},
|
},
|
||||||
|
|
||||||
testReconnect: function() {
|
testReconnect: function() {
|
||||||
var size = {width:25,height:25};
|
|
||||||
var position = {x:0,y:0};
|
var position = {x:0,y:0};
|
||||||
var manager = new mindplot.nlayout.LayoutManager(0, size);
|
var manager = new mindplot.nlayout.LayoutManager(0, mindplot.nlayout.TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
manager.addNode(1, size, position);
|
manager.addNode(1, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(2, size, position);
|
manager.addNode(2, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(3, size, position);
|
manager.addNode(3, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(4, size, position);
|
manager.addNode(4, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(5, size, position);
|
manager.addNode(5, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(6, size, position);
|
manager.addNode(6, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(7, size, position);
|
manager.addNode(7, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(8, size, position);
|
manager.addNode(8, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(9, size, position);
|
manager.addNode(9, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(10, size, position);
|
manager.addNode(10, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(11, size, position);
|
manager.addNode(11, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(12, size, position);
|
manager.addNode(12, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.connectNode(0, 1, 0);
|
manager.connectNode(0, 1, 0);
|
||||||
manager.connectNode(0, 2, 1);
|
manager.connectNode(0, 2, 1);
|
||||||
manager.connectNode(0, 3, 2);
|
manager.connectNode(0, 3, 2);
|
||||||
@ -354,28 +316,27 @@ mindplot.nlayout.TestSuite = new Class({
|
|||||||
|
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.dump();
|
manager.dump();
|
||||||
manager.plot("testReconnect1",{width:400, height:300});
|
manager.plot("testReconnect1",{width:1000, height:400});
|
||||||
|
|
||||||
// Reconnect node 6 to node 4
|
// Reconnect node 6 to node 4
|
||||||
manager.disconnectNode(6);
|
manager.disconnectNode(6);
|
||||||
manager.connectNode(4,6,0);
|
manager.connectNode(4,6,0);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.dump();
|
manager.dump();
|
||||||
manager.plot("testReconnect2",{width:400, height:300});
|
manager.plot("testReconnect2",{width:1000, height:400});
|
||||||
|
|
||||||
//TODO(gb): make asserts
|
//TODO(gb): make asserts
|
||||||
},
|
},
|
||||||
|
|
||||||
testRemoveNode: function() {
|
testRemoveNode: function() {
|
||||||
var size = {width:25,height:25};
|
|
||||||
var position = {x:0,y:0};
|
var position = {x:0,y:0};
|
||||||
var manager = new mindplot.nlayout.LayoutManager(0, size);
|
var manager = new mindplot.nlayout.LayoutManager(0, mindplot.nlayout.TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
// Prepare a sample graph ...
|
// Prepare a sample graph ...
|
||||||
manager.addNode(1, size, position);
|
manager.addNode(1, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(2, size, position);
|
manager.addNode(2, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(3, size, position);
|
manager.addNode(3, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(4, size, position);
|
manager.addNode(4, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
|
|
||||||
manager.connectNode(0, 1, 0);
|
manager.connectNode(0, 1, 0);
|
||||||
manager.connectNode(1, 2, 0);
|
manager.connectNode(1, 2, 0);
|
||||||
@ -391,26 +352,27 @@ mindplot.nlayout.TestSuite = new Class({
|
|||||||
});
|
});
|
||||||
manager.layout(true);
|
manager.layout(true);
|
||||||
manager.dump();
|
manager.dump();
|
||||||
manager.plot("testRemoveNode1", {width:300, height:200});
|
manager.plot("testRemoveNode1", {width:800, height:200});
|
||||||
|
|
||||||
// Test removal of a connected node ...
|
// Test removal of a connected node ...
|
||||||
console.log("--- Remove node 3 ---");
|
console.log("--- Remove node 3 ---");
|
||||||
manager.removeNode(3);
|
manager.removeNode(3);
|
||||||
manager.layout(true);
|
manager.layout(true);
|
||||||
manager.dump();
|
manager.dump();
|
||||||
manager.plot("testRemoveNode2");
|
manager.plot("testRemoveNode2", {width:800, height:200});
|
||||||
|
|
||||||
|
//TODO(gb): make asserts
|
||||||
},
|
},
|
||||||
|
|
||||||
testFreePosition: function() {
|
testFreePosition: function() {
|
||||||
var size = {width:25,height:25};
|
|
||||||
var position = {x:0,y:0};
|
var position = {x:0,y:0};
|
||||||
var manager = new mindplot.nlayout.LayoutManager(0, size);
|
var manager = new mindplot.nlayout.LayoutManager(0, mindplot.nlayout.TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
// Prepare a sample graph ...
|
// Prepare a sample graph ...
|
||||||
manager.addNode(1, size, position);
|
manager.addNode(1, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(2, size, position);
|
manager.addNode(2, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(3, size, position);
|
manager.addNode(3, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(4, size, position);
|
manager.addNode(4, mindplot.nlayout.TestSuite.NODE_SIZE, position);
|
||||||
|
|
||||||
manager.connectNode(0, 4, 0);
|
manager.connectNode(0, 4, 0);
|
||||||
manager.connectNode(4, 1, 0);
|
manager.connectNode(4, 1, 0);
|
||||||
@ -418,9 +380,12 @@ mindplot.nlayout.TestSuite = new Class({
|
|||||||
manager.connectNode(4, 3, 2);
|
manager.connectNode(4, 3, 2);
|
||||||
|
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testFreePosition");
|
manager.plot("testFreePosition", {width:800, height:400});
|
||||||
|
|
||||||
|
//TODO(gb): make asserts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mindplot.nlayout.TestSuite.NODE_SIZE = {width:80, height:30},
|
||||||
|
mindplot.nlayout.TestSuite.ROOT_NODE_SIZE = {width:120, height:40}
|
||||||
|
|
||||||
|
@ -49,15 +49,6 @@
|
|||||||
<h2>testSymmetry:</h2>
|
<h2>testSymmetry:</h2>
|
||||||
<div id="testSymmetry"></div>
|
<div id="testSymmetry"></div>
|
||||||
|
|
||||||
<h2>testGrid:</h2>
|
|
||||||
<div>
|
|
||||||
<div id="testGrid1" class="col"></div>
|
|
||||||
<div id="testGrid2" class="col"></div>
|
|
||||||
<div id="testGrid3" class="col"></div>
|
|
||||||
<div id="testGrid4" class="col"></div>
|
|
||||||
<div id="testGrid5" class="col last"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h2>testBalanced:</h2>
|
<h2>testBalanced:</h2>
|
||||||
<div id="testBalanced1" class="col"></div>
|
<div id="testBalanced1" class="col"></div>
|
||||||
<div id="testBalanced2" class="col"></div>
|
<div id="testBalanced2" class="col"></div>
|
||||||
|
Loading…
Reference in New Issue
Block a user