Fix error connecting to the central node.
This commit is contained in:
@@ -1,144 +1,144 @@
|
||||
/*
|
||||
* 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.model.IMindmap = new Class({
|
||||
initialize : function() {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
getCentralTopic : function() {
|
||||
return this.getBranches()[0];
|
||||
},
|
||||
|
||||
getDescription : function() {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
setDescription : function(value) {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
getId : function() {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
setId : function(id) {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
getVersion : function() {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
setVersion : function(version) {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
addBranch : function(nodeModel) {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
getBranches : function() {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
removeBranch : function(node) {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
getRelationships : function() {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
connect : function(parent, child) {
|
||||
// Child already has a parent ?
|
||||
$assert(!child.getParent(), 'Child model seems to be already connected');
|
||||
|
||||
// Connect node...
|
||||
parent.appendChild(child);
|
||||
|
||||
// Remove from the branch ...
|
||||
this.removeBranch(child);
|
||||
},
|
||||
|
||||
disconnect : function(child) {
|
||||
var parent = child.getParent();
|
||||
$assert(child, 'Child can not be null.');
|
||||
$assert(parent, 'Child model seems to be already connected');
|
||||
|
||||
parent.removeChild(child);
|
||||
this.addBranch(child);
|
||||
},
|
||||
|
||||
hasAlreadyAdded : function(node) {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
createNode : function(type, id) {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
createRelationship : function(fromNode, toNode) {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
addRelationship : function(rel) {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
removeRelationship : function(relationship) {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
inspect : function() {
|
||||
var result = '';
|
||||
result = '{ ';
|
||||
|
||||
var branches = this.getBranches();
|
||||
result = result + "version:" + this.getVersion();
|
||||
result = result + " , [";
|
||||
|
||||
for (var i = 0; i < branches.length; i++) {
|
||||
var node = branches[i];
|
||||
if (i != 0) {
|
||||
result = result + ',\n ';
|
||||
}
|
||||
result = result + "(" + i + ") =>" + node.inspect();
|
||||
}
|
||||
result = result + "]";
|
||||
|
||||
result = result + ' } ';
|
||||
return result;
|
||||
},
|
||||
|
||||
copyTo : function(target) {
|
||||
var source = this;
|
||||
var version = source.getVersion();
|
||||
target.setVersion(version);
|
||||
|
||||
var desc = this.getDescription();
|
||||
target.setDescription(desc);
|
||||
|
||||
// Then the rest of the branches ...
|
||||
var sbranchs = source.getBranches();
|
||||
sbranchs.forEach(function(snode) {
|
||||
var tnode = target.createNode(snode.getType(), snode.getId());
|
||||
snode.copyTo(tnode);
|
||||
target.addBranch(tnode);
|
||||
});
|
||||
}
|
||||
/*
|
||||
* 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.model.IMindmap = new Class({
|
||||
initialize : function() {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
getCentralTopic : function() {
|
||||
return this.getBranches()[0];
|
||||
},
|
||||
|
||||
getDescription : function() {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
setDescription : function(value) {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
getId : function() {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
setId : function(id) {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
getVersion : function() {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
setVersion : function(version) {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
addBranch : function(nodeModel) {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
getBranches : function() {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
removeBranch : function(node) {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
getRelationships : function() {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
connect : function(parent, child) {
|
||||
// Child already has a parent ?
|
||||
$assert(!child.getParent(), 'Child model seems to be already connected');
|
||||
|
||||
// Connect node...
|
||||
parent.appendChild(child);
|
||||
|
||||
// Remove from the branch ...
|
||||
this.removeBranch(child);
|
||||
},
|
||||
|
||||
disconnect : function(child) {
|
||||
var parent = child.getParent();
|
||||
$assert(child, 'Child can not be null.');
|
||||
$assert(parent, 'Child model seems to be already connected');
|
||||
|
||||
parent.removeChild(child);
|
||||
this.addBranch(child);
|
||||
},
|
||||
|
||||
hasAlreadyAdded : function(node) {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
createNode : function(type, id) {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
createRelationship : function(fromNode, toNode) {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
addRelationship : function(rel) {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
deleteRelationship : function(relationship) {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
inspect : function() {
|
||||
var result = '';
|
||||
result = '{ ';
|
||||
|
||||
var branches = this.getBranches();
|
||||
result = result + "version:" + this.getVersion();
|
||||
result = result + " , [";
|
||||
|
||||
for (var i = 0; i < branches.length; i++) {
|
||||
var node = branches[i];
|
||||
if (i != 0) {
|
||||
result = result + ',\n ';
|
||||
}
|
||||
result = result + "(" + i + ") =>" + node.inspect();
|
||||
}
|
||||
result = result + "]";
|
||||
|
||||
result = result + ' } ';
|
||||
return result;
|
||||
},
|
||||
|
||||
copyTo : function(target) {
|
||||
var source = this;
|
||||
var version = source.getVersion();
|
||||
target.setVersion(version);
|
||||
|
||||
var desc = this.getDescription();
|
||||
target.setDescription(desc);
|
||||
|
||||
// Then the rest of the branches ...
|
||||
var sbranchs = source.getBranches();
|
||||
sbranchs.forEach(function(snode) {
|
||||
var tnode = target.createNode(snode.getType(), snode.getId());
|
||||
snode.copyTo(tnode);
|
||||
target.addBranch(tnode);
|
||||
});
|
||||
}
|
||||
});
|
@@ -106,7 +106,7 @@ mindplot.model.Mindmap = new Class({
|
||||
this._relationships.push(relationship);
|
||||
},
|
||||
|
||||
removeRelationship : function(relationship) {
|
||||
deleteRelationship : function(relationship) {
|
||||
this._relationships.erase(relationship);
|
||||
}
|
||||
}
|
||||
|
@@ -16,7 +16,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
mindplot.model.RelationshipModel = new Class({
|
||||
initialize:function(sourceTopicId, targetTopicId) {
|
||||
Static:{
|
||||
_nextUUID:function () {
|
||||
if (!$defined(mindplot.model.RelationshipModel._uuid)) {
|
||||
mindplot.model.RelationshipModel._uuid = 0;
|
||||
}
|
||||
mindplot.model.RelationshipModel._uuid = mindplot.model.RelationshipModel._uuid + 1;
|
||||
return mindplot.model.RelationshipModel._uuid;
|
||||
}
|
||||
},
|
||||
|
||||
initialize:function (sourceTopicId, targetTopicId) {
|
||||
$assert($defined(sourceTopicId), 'from node type can not be null');
|
||||
$assert($defined(targetTopicId), 'to node type can not be null');
|
||||
|
||||
@@ -30,59 +40,60 @@ mindplot.model.RelationshipModel = new Class({
|
||||
this._startArrow = false;
|
||||
},
|
||||
|
||||
getFromNode : function() {
|
||||
getFromNode:function () {
|
||||
return this._sourceTargetId;
|
||||
},
|
||||
|
||||
getToNode : function() {
|
||||
getToNode:function () {
|
||||
return this._targetTopicId;
|
||||
},
|
||||
|
||||
getId : function() {
|
||||
getId:function () {
|
||||
$assert(this._id, "id is null");
|
||||
return this._id;
|
||||
},
|
||||
|
||||
getLineType : function() {
|
||||
getLineType:function () {
|
||||
return this._lineType;
|
||||
},
|
||||
|
||||
setLineType : function(lineType) {
|
||||
setLineType:function (lineType) {
|
||||
this._lineType = lineType;
|
||||
},
|
||||
|
||||
getSrcCtrlPoint : function() {
|
||||
getSrcCtrlPoint:function () {
|
||||
return this._srcCtrlPoint;
|
||||
},
|
||||
|
||||
setSrcCtrlPoint : function(srcCtrlPoint) {
|
||||
setSrcCtrlPoint:function (srcCtrlPoint) {
|
||||
this._srcCtrlPoint = srcCtrlPoint;
|
||||
},
|
||||
|
||||
getDestCtrlPoint : function() {
|
||||
getDestCtrlPoint:function () {
|
||||
return this._destCtrlPoint;
|
||||
},
|
||||
|
||||
setDestCtrlPoint : function(destCtrlPoint) {
|
||||
setDestCtrlPoint:function (destCtrlPoint) {
|
||||
this._destCtrlPoint = destCtrlPoint;
|
||||
},
|
||||
|
||||
getEndArrow : function() {
|
||||
getEndArrow:function () {
|
||||
return this._endArrow;
|
||||
},
|
||||
|
||||
setEndArrow : function(endArrow) {
|
||||
setEndArrow:function (endArrow) {
|
||||
this._endArrow = endArrow;
|
||||
},
|
||||
|
||||
getStartArrow : function() {
|
||||
getStartArrow:function () {
|
||||
return this._startArrow;
|
||||
},
|
||||
|
||||
setStartArrow : function(startArrow) {
|
||||
setStartArrow:function (startArrow) {
|
||||
this._startArrow = startArrow;
|
||||
},
|
||||
|
||||
clone : function(model) {
|
||||
clone:function (model) {
|
||||
var result = new mindplot.model.RelationshipModel(this._sourceTargetId, this._targetTopicId);
|
||||
result._id = this._id;
|
||||
result._lineType = this._lineType;
|
||||
@@ -93,21 +104,9 @@ mindplot.model.RelationshipModel = new Class({
|
||||
return result;
|
||||
},
|
||||
|
||||
inspect : function() {
|
||||
inspect:function () {
|
||||
return '(fromNode:' + this.getFromNode().getId() + ' , toNode: ' + this.getToNode().getId() + ')';
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @todo: This method must be implemented.
|
||||
*/
|
||||
mindplot.model.RelationshipModel._nextUUID = function() {
|
||||
if (!$defined(this._uuid)) {
|
||||
this._uuid = 0;
|
||||
}
|
||||
|
||||
this._uuid = this._uuid + 1;
|
||||
return this._uuid;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user