--- a/client/js/model.js Thu Jul 26 18:06:05 2012 +0200
+++ b/client/js/model.js Fri Jul 27 12:22:10 2012 +0200
@@ -7,7 +7,6 @@
this.title = _props.title || "(untitled " + this.type + ")";
this.description = _props.description || "";
this.uri = _props.uri || "";
-// this._backRefs = [];
}
}
@@ -17,6 +16,24 @@
this[ _propName ] = _element;
}
+Rkns.Model._BaseElement.prototype.updateGraphics = function() {
+ this._project._renderer.redraw();
+}
+
+Rkns.Model._BaseElement.prototype.updateData = function() {
+}
+
+Rkns.Model._BaseElement.prototype.propagateChanges = function(_from) {
+ switch(_from) {
+ case Rkns._FROM_GRAPHICS:
+ this.updateData();
+ break;
+ case Rkns._FROM_DATA:
+ this.updateGraphics();
+ break;
+ }
+}
+
/* Element Class Generator */
Rkns.Model._elementClass = function(_type) {
@@ -42,6 +59,26 @@
this.position = _props.position;
}
+Rkns.Model.Node.prototype.setPosition = function(_from, _x, _y) {
+ if (typeof _x === "object") {
+ if (typeof _x.x !== "undefined" && typeof _x.y !== "undefined") {
+ this.position.x = _x.x;
+ this.position.y = _x.y;
+ } else {
+ if (typeof _x.length !== "undefined") {
+ this.position.x = _x[0];
+ this.position.y = _x[1];
+ }
+ }
+ } else {
+ if (typeof _y !== "undefined") {
+ this.position.x = +_x;
+ this.position.y = +_y;
+ }
+ }
+ this.propagateChanges(_from);
+}
+
/* Edge Model */
Rkns.Model.Edge = Rkns.Model._elementClass("edge");