diff --git a/mindplot/src/main/javascript/collaboration/framework/brix/model/Mindmap.js b/mindplot/src/main/javascript/collaboration/framework/brix/model/Mindmap.js index 7c8694ae..f5d78c6b 100644 --- a/mindplot/src/main/javascript/collaboration/framework/brix/model/Mindmap.js +++ b/mindplot/src/main/javascript/collaboration/framework/brix/model/Mindmap.js @@ -16,92 +16,75 @@ * limitations under the License. */ mindplot.collaboration.framework.brix.model.Mindmap = new Class({ - Extends:mindplot.model.Mindmap, - initialize:function(brixModel, brixFramework){ - this.parent(); + Extends:mindplot.model.IMindmap, + initialize:function(brixModel, brixFramework) { this._brixModel = brixModel; this._brixFramework = brixFramework; - if(!$defined(this._brixModel)){ + if (!$defined(this._brixModel)) { this._brixModel = this._createBrixModel(); - }else{ + } else { var branches = this._brixModel.get("branches"); - for(var i=0; i 0) { - gap += Math.abs(targetPosition.y - targetModel.getChildren()[0].getPosition().y); - } - - if (yDistance <= gap) { - // Circular connection ? - if (!sourceModel._isChildNode(this)) { - var toleranceDistance = (targetTopicSize.width / 2) + targetTopicHeight; - - var xDistance = sourcePosition.x - targetPosition.x; - var isTargetAtRightFromCentral = targetPosition.x >= 0; - - if (isTargetAtRightFromCentral) { - if (xDistance >= -targetTopicSize.width / 2 && xDistance <= mindplot.model.NodeModel.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE / 2 + (targetTopicSize.width / 2)) { - result = true; - } - - } else { - if (xDistance <= targetTopicSize.width / 2 && Math.abs(xDistance) <= mindplot.model.NodeModel.MAIN_TOPIC_TO_MAIN_TOPIC_DISTANCE / 2 + (targetTopicSize.width / 2)) { - result = true; - } - } - } - } - } else { - throw "No implemented yet"; - } - return result; - } - , - - _isChildNode : function(node) { - var result = false; - if (node == this) { - result = true; - } else { - var children = this.getChildren(); - for (var i = 0; i < children.length; i++) { - var child = children[i]; - result = child._isChildNode(node); - if (result) { - break; - } - } - } - return result; - - } - , - - disconnect : function() { - var mindmap = this.getMindmap(); - mindmap.disconnect(this); - } - , - - getOrder : function() { - return this._order; - }, - - setOrder : function(value) { - this._order = value; - }, - - deleteNode : function() { - var mindmap = this._mindmap; - - // if it has children nodes, Their must be disconnected. - var lenght = this._children; - for (var i = 0; i < lenght; i++) { - var child = this._children[i]; - mindmap.disconnect(child); - } - - var parent = this._parent; - if ($defined(parent)) { - // if it is connected, I must remove it from the parent.. - mindmap.disconnect(this); - } - - // It's an isolated node. It must be a hole branch ... - var branches = mindmap.getBranches(); - branches.erase(this); - - } - , - - inspect : function() { - return '(type:' + this.getType() + ' , id: ' + this.getId() + ')'; - } }); + +mindplot.collaboration.framework.brix.model.NodeModel.create = function(brixFramework, type, id, mindmap) { + var brixModel = brixFramework.getBrixModel().create("Map"); + brixModel.put("type", type); + brixModel.put("id", this._id); // @todo... + + var children = brixFramework.getBrixModel().create("List"); + brixModel.put("children", children); + + return new mindplot.collaboration.framework.brix.model.NodeModel(brixFramework, brixModel, mindmap); +}; \ No newline at end of file