Set position integrated !

This commit is contained in:
Paulo Veiga
2012-01-11 19:47:00 -03:00
parent 8cf9e6d18e
commit d9cdcc5160
14 changed files with 82 additions and 40 deletions

View File

@@ -1044,7 +1044,7 @@ mindplot.Topic = new Class({
// Update the figure position(ej: central topic must be centered) and children position.
this._updatePositionOnChangeSize(oldSize, size);
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeResizeEvent, [this]);
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeResizeEvent, {node:this.getModel(),size:size});
}
},

View File

@@ -26,7 +26,7 @@ mindplot.layout.BaseLayoutManager = new Class({
this.setOptions(options);
this._createBoard();
this._designer = designer;
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeResizeEvent, this._nodeResizeEvent.bind(this));
// mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeResizeEvent, this._nodeResizeEvent.bind(this));
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeMoveEvent, this._nodeMoveEvent.bind(this));
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.ONodeDisconnectEvent, this._nodeDisconnectEvent.bind(this));
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.ONodeConnectEvent, this._nodeConnectEvent.bind(this));

View File

@@ -53,14 +53,5 @@ mindplot.nlayout.AbstractBasicSorter = new Class({
return a.getOrder() - b.getOrder()
});
return result;
},
verify:function(treeSet, node) {
// Check that all is consistent ...
var children = this._getSortedChildren(treeSet, node);
for (var i = 0; i < children.length; i++) {
$assert(children[i].getOrder() == i, "missing order elements");
}
}
});

View File

@@ -1,3 +1,20 @@
/*
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.nlayout.BalancedSorter = new Class({
Extends: mindplot.nlayout.AbstractBasicSorter,
@@ -66,13 +83,17 @@ mindplot.nlayout.BalancedSorter = new Class({
insert: function(treeSet, parent, child, order) {
var children = this._getSortedChildren(treeSet, parent);
$assert(order <= children.length, "Order must be continues and can not have holes. Order:" + order);
$assert(order <= children.length, "Order must be continues and can not have holes. Order:" + order);
// Shift all the elements in one .
// Shift all the elements in one. In case of balanced sorter, order don't need to be continues ...
var collision = order;
for (var i = order; i < children.length; i++) {
var node = children[i];
node.setOrder(i + 1);
// @Todo: This must be review. Order balance need to be defined ...
if (node.getOrder() == collision) {
collision = collision + 1;
node.setOrder(collision);
}
}
child.setOrder(order);
},
@@ -98,9 +119,10 @@ mindplot.nlayout.BalancedSorter = new Class({
var children = this._getSortedChildren(treeSet, node);
// Compute heights ...
var heights = children.map(function(child) {
return {id:child.getId(), order:child.getOrder(), height:this._computeChildrenHeight(treeSet, child)};
}, this).reverse();
var heights = children.map(
function(child) {
return {id:child.getId(), order:child.getOrder(), height:this._computeChildrenHeight(treeSet, child)};
}, this).reverse();
// Compute the center of the branch ...
@@ -114,8 +136,8 @@ mindplot.nlayout.BalancedSorter = new Class({
totalNHeight += elem.height;
}
});
var psum = totalPHeight/2;
var nsum = totalNHeight/2;
var psum = totalPHeight / 2;
var nsum = totalNHeight / 2;
var ysum = 0;
// Calculate the offsets ...
@@ -131,7 +153,7 @@ mindplot.nlayout.BalancedSorter = new Class({
ysum = nsum;
}
var yOffset = ysum + heights[i].height/2;
var yOffset = ysum + heights[i].height / 2;
var xOffset = direction * (node.getSize().width + mindplot.nlayout.SymmetricSorter.INTERNODE_HORIZONTAL_PADDING);
$assert(!isNaN(xOffset), "xOffset can not be null");
@@ -144,6 +166,10 @@ mindplot.nlayout.BalancedSorter = new Class({
toString:function() {
return "Balanced Sorter";
},
verify:function(treeSet, node) {
// @todo...
}
});

View File

@@ -27,7 +27,10 @@ mindplot.nlayout.EventBusDispatcher = new Class({
this._layoutManager.addEvent('change', function(event) {
var id = event.getId();
var topic = designerModel.findTopicById(id);
console.log("Modifing position to:" + id);
console.log("Modify position to:" + id);
topic.setPosition(event.getPosition());
topic.setOrder(event.getOrder());
});
},
@@ -43,8 +46,8 @@ mindplot.nlayout.EventBusDispatcher = new Class({
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.DoLayout, this._doLayout.bind(this));
},
_nodeResizeEvent: function(node) {
console.log("mindplot.nlayout.EventBusDispatcher._nodeResizeEvent: Not Implemented yet");
_nodeResizeEvent: function(args) {
this._layoutManager.updateNodeSize(args.node.getId(), args.size);
},
_nodeMoveEvent: function(node) {
@@ -82,11 +85,12 @@ mindplot.nlayout.EventBusDispatcher = new Class({
},
_doLayout: function() {
this._layoutManager.layout(true);
console.log("---------");
this._layoutManager.dump();
console.log("---------");
(function() {
this._layoutManager.layout(true);
console.log("---------");
this._layoutManager.dump();
console.log("---------");
}).delay(0, this);
}
});

View File

@@ -32,7 +32,9 @@ mindplot.nlayout.LayoutManager = new Class({
updateNodeSize: function(id, size) {
var node = this._treeSet.find(id);
node.setSize(size);
// @Todo: finish...
console.log("Size:"+size.width);
// Todo: This must be completed ...
},
updateShirkState: function(id, isShrink) {

View File

@@ -121,7 +121,6 @@ mindplot.nlayout.OriginalLayout = new Class({
});
mindplot.nlayout.OriginalLayout.SYMMETRIC_SORTER = new mindplot.nlayout.SymmetricSorter();
mindplot.nlayout.OriginalLayout.GRID_SORTER = new mindplot.nlayout.GridSorter();
mindplot.nlayout.OriginalLayout.BALANCED_SORTER = new mindplot.nlayout.BalancedSorter();

View File

@@ -54,7 +54,6 @@ mindplot.nlayout.SymmetricSorter = new Class({
insert: function(treeSet, parent, child, order) {
var children = this._getSortedChildren(treeSet, parent);
$assert(order <= children.length, "Order must be continues and can not have holes. Order:" + order);
$assert(order <= children.length, "Order must be continues and can not have holes. Order:" + order);
// Shift all the elements in one .
for (var i = order; i < children.length; i++) {
@@ -85,9 +84,10 @@ mindplot.nlayout.SymmetricSorter = new Class({
var children = this._getSortedChildren(treeSet, node);
// Compute heights ...
var heights = children.map(function(child) {
return {id:child.getId(), order:child.getOrder(), position: child.getPosition(), height: this._computeChildrenHeight(treeSet, child)};
}, this).reverse();
var heights = children.map(
function(child) {
return {id:child.getId(), order:child.getOrder(), position: child.getPosition(), height: this._computeChildrenHeight(treeSet, child)};
}, this).reverse();
// Compute the center of the branch ...
var totalHeight = 0;
@@ -104,7 +104,7 @@ mindplot.nlayout.SymmetricSorter = new Class({
var parent = treeSet.getParent(treeSet.find(heights[i].id));
var direction = parent.getPosition().x > 0 ? 1 : -1;
var yOffset = ysum + heights[i].height/2;
var yOffset = ysum + heights[i].height / 2;
var xOffset = direction * (node.getSize().width + mindplot.nlayout.SymmetricSorter.INTERNODE_HORIZONTAL_PADDING);
$assert(!isNaN(xOffset), "xOffset can not be null");
@@ -115,6 +115,15 @@ mindplot.nlayout.SymmetricSorter = new Class({
return result;
},
verify:function(treeSet, node) {
// Check that all is consistent ...
var children = this._getSortedChildren(treeSet, node);
for (var i = 0; i < children.length; i++) {
$assert(children[i].getOrder() == i, "missing order elements");
}
},
toString:function() {
return "Symmetric Sorter";
}

View File

@@ -1,387 +0,0 @@
/*
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mindplot.nlayout.TestSuite = new Class({
Extends: mindplot.nlayout.ChildrenSorterStrategy,
initialize:function() {
this.testAligned();
this.testSymmetry();
this.testBalanced();
this.testEvents();
this.testEventsComplex();
this.testDisconnect();
this.testReconnect();
this.testRemoveNode();
this.testFreePosition();
},
testAligned: function() {
var position = {x:0,y:0};
var manager = new mindplot.nlayout.LayoutManager(0, mindplot.nlayout.TestSuite.ROOT_NODE_SIZE);
manager.addNode(1, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(2, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(3, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(4, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.connectNode(0, 1, 0);
manager.connectNode(1, 2, 0);
manager.connectNode(2, 3, 0);
manager.connectNode(3, 4, 0);
manager.layout();
manager.plot("testAligned", {width:1200,height:200});
// 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(2).getPosition().y, "Nodes are not aligned");
$assert(manager.find(0).getPosition().y == manager.find(3).getPosition().y, "Nodes are not aligned");
$assert(manager.find(0).getPosition().y == manager.find(4).getPosition().y, "Nodes are not aligned");
},
testSymmetry: function() {
var position = {x:0,y:0};
var manager = new mindplot.nlayout.LayoutManager(0, mindplot.nlayout.TestSuite.ROOT_NODE_SIZE);
manager.addNode(1, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(2, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(3, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(4, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(5, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(6, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(7, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(8, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(9, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(10, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(11, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(12, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(13, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(14, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.connectNode(0, 14, 0);
manager.connectNode(14, 13, 0);
manager.connectNode(13, 1, 0);
manager.connectNode(13, 2, 1);
manager.connectNode(13, 3, 2);
manager.connectNode(13, 4, 3);
manager.connectNode(13, 5, 4);
manager.connectNode(1, 6, 0);
manager.connectNode(1, 7, 1);
manager.connectNode(7, 8, 0);
manager.connectNode(8, 9, 0);
manager.connectNode(5, 10, 0);
manager.connectNode(6, 11, 0);
manager.connectNode(6, 12, 1);
manager.layout();
manager.plot("testSymmetry",{width:1200, height:400});
//TODO(gb): make asserts
},
testBalanced: function() {
var position = {x:0, y:0};
var plotsize = {width:800, height:400};
var manager = new mindplot.nlayout.LayoutManager(0, mindplot.nlayout.TestSuite.ROOT_NODE_SIZE);
manager.addNode(1, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.connectNode(0, 1, 0);
manager.layout();
manager.plot("testBalanced1", plotsize);
manager.addNode(2, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.connectNode(0, 2, 1);
manager.layout();
manager.plot("testBalanced2", plotsize);
manager.addNode(3, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.connectNode(0, 3, 2);
manager.layout();
manager.plot("testBalanced3", plotsize);
manager.addNode(4, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.connectNode(0, 4, 3);
manager.layout();
manager.plot("testBalanced4", plotsize);
manager.addNode(5, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.connectNode(0, 5, 4);
manager.layout();
manager.plot("testBalanced5", plotsize);
manager.addNode(6, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.connectNode(0, 6, 5);
manager.layout();
manager.plot("testBalanced6", plotsize);
manager.addNode(7, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(8, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(9, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.connectNode(3, 7, 0)
manager.connectNode(7, 8, 0)
manager.connectNode(7, 9, 1);
manager.layout();
manager.plot("testBalanced7", plotsize);
manager.addNode(10, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(11, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(12, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.connectNode(6, 10, 0)
manager.connectNode(10, 11, 0)
manager.connectNode(10, 12, 1);
manager.layout();
manager.plot("testBalanced8", plotsize);
//TODO(gb): make asserts
},
testEvents: function() {
console.log("testEvents:"); //TODO(gb): Remove trace!!!
var position = {x:0,y:0};
var manager = new mindplot.nlayout.LayoutManager(0, mindplot.nlayout.TestSuite.ROOT_NODE_SIZE);
// Add 3 nodes...
manager.addNode(1, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(2, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(3, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(4, mindplot.nlayout.TestSuite.NODE_SIZE, position);
// Now connect one with two....
manager.connectNode(0, 1, 0);
manager.connectNode(0, 2, 0);
manager.connectNode(1, 3, 0);
// Basic layout repositioning ...
console.log("\t--- Updated tree ---");
var events = [];
manager.addEvent('change', function(event) {
console.log("\tUpdated nodes: {id:" + event.getId() + ", order: " + event.getOrder() + ",position: {" + event.getPosition().x + "," + event.getPosition().y + "}");
events.push(event);
});
manager.layout(true);
manager.plot("testEvents1", {width:800, height:400});
// Ok, if a new node is added, this an event should be fired ...
console.log("\t---- Layout without changes should not affect the tree ---");
events.empty();
manager.layout(true);
manager.plot("testEvents2", {width:800, height:400});
$assert(events.length == 0, "Unnecessary tree updated.");
//TODO(gb): make asserts
console.log("\n"); //TODO(gb): Remove trace!!!
},
testEventsComplex: function() {
console.log("testEventsComplex:"); //TODO(gb): Remove trace!!!
var position = {x:0,y:0};
var manager = new mindplot.nlayout.LayoutManager(0, mindplot.nlayout.TestSuite.ROOT_NODE_SIZE);
// Add 3 nodes...
manager.addNode(1, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(2, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(3, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(4, mindplot.nlayout.TestSuite.NODE_SIZE, position);
// Now connect one with two....
manager.connectNode(0, 1, 0);
manager.connectNode(1, 2, 0);
manager.connectNode(1, 3, 1);
var events = [];
manager.addEvent('change', function(event) {
console.log("\tUpdated nodes: {id:" + event.getId() + ", order: " + event.getOrder() + ",position: {" + event.getPosition().x + "," + event.getPosition().y + "}");
events.push(event);
});
// Reposition ...
manager.layout(true);
manager.plot("testEventsComplex1", {width:800, height:400});
// Add a new node and connect. Only children nodes should be affected.
console.log("\t---- Connect a new node ---");
events.empty();
manager.connectNode(1, 4, 2);
manager.layout(true);
manager.plot("testEventsComplex2", {width:800, height:400});
// @todo: This seems no to be ok...
$assert(events.length == 4, "Only 3 nodes should be repositioned.");
//TODO(gb): make asserts
console.log("\n"); //TODO(gb): Remove trace!!!
},
testDisconnect: function() {
console.log("testDisconnect:"); //TODO(gb): Remove trace!!!
var position = {x:0,y:0};
var manager = new mindplot.nlayout.LayoutManager(0, mindplot.nlayout.TestSuite.ROOT_NODE_SIZE);
// Prepare a sample graph ...
manager.addNode(1, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(2, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(3, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(4, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.connectNode(0, 1, 0);
manager.connectNode(1, 2, 0);
manager.connectNode(1, 3, 1);
manager.connectNode(3, 4, 0);
var events = [];
manager.addEvent('change', function(event) {
var pos = event.getPosition();
var posStr = pos ? ",position: {" + pos.x + "," + pos.y : "";
var node = manager.find(event.getId());
console.log("\tUpdated nodes: {id:" + event.getId() + ", order: " + event.getOrder() + posStr + "}");
events.push(event);
});
manager.layout(true);
manager.plot("testDisconnect1", {width:800, height:400});
// Now, disconnect one node ...
console.log("\t--- Disconnect a single node ---");
events.empty();
manager.disconnectNode(2);
manager.layout(true);
manager.plot("testDisconnect2", {width:800, height:400});
$assert(events.some(
function(event) {
return event.getId() == 2;
}), "Event for disconnected node seems not to be propagated");
// Great, let's disconnect a not with children.
console.log("\t--- Disconnect a node with children ---");
manager.disconnectNode(3);
manager.layout(true);
manager.plot("testDisconnect3", {width:800, height:400});
$assert(events.some(
function(event) {
return event.getId() == 2;
}), "Event for disconnected node seems not to be propagated");
//TODO(gb): make asserts
console.log("\n"); //TODO(gb): Remove trace!!!
},
testReconnect: function() {
var position = {x:0,y:0};
var manager = new mindplot.nlayout.LayoutManager(0, mindplot.nlayout.TestSuite.ROOT_NODE_SIZE);
manager.addNode(1, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(2, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(3, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(4, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(5, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(6, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(7, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(8, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(9, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(10, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(11, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(12, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.connectNode(0, 1, 0);
manager.connectNode(0, 2, 1);
manager.connectNode(0, 3, 2);
manager.connectNode(0, 4, 3);
manager.connectNode(0, 5, 4);
manager.connectNode(1, 6, 0);
manager.connectNode(1, 7, 1);
manager.connectNode(7, 8, 0);
manager.connectNode(8, 9, 0);
manager.connectNode(5, 10, 0);
manager.connectNode(6, 11, 0);
manager.connectNode(6, 12, 1);
manager.layout();
manager.plot("testReconnect1",{width:1000, height:400});
// Reconnect node 6 to node 4
manager.disconnectNode(6);
manager.connectNode(4,6,0);
manager.layout();
manager.plot("testReconnect2",{width:1000, height:400});
//TODO(gb): make asserts
},
testRemoveNode: function() {
console.log("testRemoveNode:"); //TODO(gb): Remove trace!!!
var position = {x:0,y:0};
var manager = new mindplot.nlayout.LayoutManager(0, mindplot.nlayout.TestSuite.ROOT_NODE_SIZE);
// Prepare a sample graph ...
manager.addNode(1, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(2, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(3, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(4, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.connectNode(0, 1, 0);
manager.connectNode(1, 2, 0);
manager.connectNode(1, 3, 1);
manager.connectNode(3, 4, 0);
var events = [];
manager.addEvent('change', function(event) {
var pos = event.getPosition();
var posStr = pos ? ",position: {" + pos.x + "," + event.getPosition().y : "";
console.log("\tUpdated nodes: {id:" + event.getId() + ", order: " + event.getOrder() + posStr + "}");
events.push(event);
});
manager.layout(true);
manager.plot("testRemoveNode1", {width:800, height:200});
// Test removal of a connected node ...
console.log("\t--- Remove node 3 ---");
manager.removeNode(3);
manager.layout(true);
manager.plot("testRemoveNode2", {width:800, height:200});
//TODO(gb): make asserts
console.log("\n"); //TODO(gb): Remove trace!!!
},
testFreePosition: function() {
var position = {x:0,y:0};
var manager = new mindplot.nlayout.LayoutManager(0, mindplot.nlayout.TestSuite.ROOT_NODE_SIZE);
// Prepare a sample graph ...
manager.addNode(1, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(2, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(3, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.addNode(4, mindplot.nlayout.TestSuite.NODE_SIZE, position);
manager.connectNode(0, 4, 0);
manager.connectNode(4, 1, 0);
manager.connectNode(4, 2, 1);
manager.connectNode(4, 3, 2);
manager.layout();
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}

File diff suppressed because one or more lines are too long

View File

@@ -1,29 +0,0 @@
Raphael.fn.drawGrid = function (x, y, w, h, wv, hv, color) {
color = color || "#999";
var path = ["M", x, y, "L", x + w, y, x + w, y + h, x, y + h, x, y],
rowHeight = h / hv,
columnWidth = w / wv;
for (var i = 0; i < hv + 1; i++) {
var offset = y + i * rowHeight;
path = this.path(["M", x, offset, "L", x + w, y + i * rowHeight]);
if (offset == 0 || offset == h) {
path.attr({stroke: "#000"});
} else if (offset == h/2) {
path.attr({stroke: "#c00"})
} else {
path.attr({stroke: "#999"})
}
}
for (var i = 0; i < wv + 1; i++) {
var offset = x + i * columnWidth;
path = this.path(["M", offset, y, "L", x + i * columnWidth, y + h]);
if (offset == 0 || offset == w) {
path.attr({stroke: "#000"});
} else if (offset == w/2) {
path.attr({stroke: "#c00"})
} else {
path.attr({stroke: "#999"})
}
}
return this.path;
};