Basic plotting using Raphael

This commit is contained in:
Gonzalo Bellver
2011-12-30 15:28:03 -03:00
parent d9d89a24de
commit 9ed6df2158
7 changed files with 88 additions and 6 deletions

View File

@@ -118,6 +118,28 @@ mindplot.nlayout.RootedTreeSet = new Class({
return result;
},
plot: function(canvas) {
var branches = this._rootNodes;
for (var i=0; i<branches.length; i++) {
var branch = branches[i];
this._plot(canvas, branch);
}
},
_plot: function(canvas, node, root) {
var children = this.getChildren(node);
var cx = canvas.width / 2;
var cy = canvas.height / 2;
var rect = canvas.rect(cx + node.getPosition().x, cy + node.getPosition().y, node.getSize().width, node.getSize().height);
var fillColor = this._rootNodes.contains(node) ? "#000" : "#c00";
rect.attr('fill', fillColor);
for (var i=0; i<children.length; i++) {
var child = children[i];
this._plot(canvas, child);
}
},
updateBranchPosition : function(node, position) {
var oldPos = node.getPosition();