Adding model update, model migrator, curved line support, relationship lines, remove of web-services classes
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="header.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="Mindmap.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="NodeModel.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="RelationshipModel.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="MindmapDesigner.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="ScreenManager.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="Workspace.js"/>
|
||||
@@ -62,7 +63,11 @@
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="util/Shape.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="FixedDistanceBoard.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="BoardEntry.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="XMLMindmapSerializer.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="ModelCodeName.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="XMLMindmapSerializer_Pela.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="XMLMindmapSerializer_Beta.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="Beta2PelaMigrator.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="XMLMindmapSerializerFactory.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="PersistanceManager.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="EditorProperties.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="IconGroup.js"/>
|
||||
@@ -75,11 +80,10 @@
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="IconModel.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="LinkModel.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="NoteModel.js"/>
|
||||
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="Command.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="DesignerActionRunner.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="DesignerUndoManager.js"/>
|
||||
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="ControlPoint.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
files="commands/GenericFunctionCommand.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
@@ -100,7 +104,10 @@
|
||||
files="commands/AddNoteToTopicCommand.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
files="commands/RemoveNoteFromTopicCommand.js"/>
|
||||
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
files="commands/AddRelationshipCommand.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
files="commands/MoveControlPointCommand.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="footer.js"/>
|
||||
</concat>
|
||||
|
||||
@@ -144,6 +151,7 @@
|
||||
<include>header-min.js</include>
|
||||
<include>Mindmap-min.js</include>
|
||||
<include>NodeModel-min.js</include>
|
||||
<include>RelationshipModel-min.js</include>
|
||||
<include>MindmapDesigner-min.js</include>
|
||||
<include>ScreenManager-min.js</include>
|
||||
<include>Workspace-min.js</include>
|
||||
@@ -166,7 +174,11 @@
|
||||
<include>util/Shape-min.js</include>
|
||||
<include>FixedDistanceBoard-min.js</include>
|
||||
<include>BoardEntry-min.js</include>
|
||||
<include>XMLMindmapSerializer-min.js</include>
|
||||
<include>ModelCodeName-min.js</include>
|
||||
<include>XMLMindmapSerializer_Beta-min.js</include>
|
||||
<include>XMLMindmapSerializer_Pela-min.js</include>
|
||||
<include>Beta2PelaMigrator-min.js</include>
|
||||
<include>XMLMindmapSerializerFactory-min.js</include>
|
||||
<include>PersistanceManager-min.js</include>
|
||||
<include>EditorProperties-min.js</include>
|
||||
<include>IconGroup-min.js</include>
|
||||
@@ -194,6 +206,8 @@
|
||||
<include>commands/RemoveIconFromTopicCommand-min.js</include>
|
||||
<include>commands/AddNoteToTopicCommand-min.js</include>
|
||||
<include>commands/RemoveNoteFromTopicCommand-min.js</include>
|
||||
<include>commands/AddRelationshipCommand-min.js</include>
|
||||
<include>commands/MoveControlPointCommand-min.js</include>
|
||||
|
||||
<include>footer-min.js</include>
|
||||
|
||||
|
17
mindplot/src/main/javascript/Beta2PelaMigrator.js
Normal file
17
mindplot/src/main/javascript/Beta2PelaMigrator.js
Normal file
@@ -0,0 +1,17 @@
|
||||
mindplot.Beta2PelaMigrator = function(betaSerializer){
|
||||
this._betaSerializer=betaSerializer;
|
||||
this._pelaSerializer = new mindplot.XMLMindmapSerializer_Pela();
|
||||
};
|
||||
|
||||
mindplot.Beta2PelaMigrator.prototype.toXML = function(mindmap)
|
||||
{
|
||||
return this._pelaSerializer.toXML(mindmap);
|
||||
};
|
||||
|
||||
|
||||
mindplot.Beta2PelaMigrator.prototype.loadFromDom = function(dom)
|
||||
{
|
||||
var mindmap = this._betaSerializer.loadFromDom(dom);
|
||||
mindmap.setVersion(mindplot.ModelCodeName.PELA);
|
||||
return mindmap;
|
||||
};
|
@@ -1,22 +1,22 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
|
||||
*/
|
||||
|
||||
mindplot.CentralTopic = function(model)
|
||||
{
|
||||
core.assert(model, "Model can not be null");
|
||||
@@ -29,9 +29,29 @@ mindplot.CentralTopic = function(model)
|
||||
objects.extend(mindplot.CentralTopic, mindplot.Topic);
|
||||
|
||||
|
||||
mindplot.CentralTopic.prototype.workoutIncomingConnectionPoint = function(sourcePosition)
|
||||
mindplot.CentralTopic.prototype.workoutIncomingConnectionPoint = function(sourcePosition, onBoundingBox)
|
||||
{
|
||||
return this.getPosition();
|
||||
if(!core.Utils.isDefined(onBoundingBox)){
|
||||
onBoundingBox=false;
|
||||
}
|
||||
var pos = this.getPosition();
|
||||
var size = this.getSize();
|
||||
var isAtRight = mindplot.util.Shape.isAtRight(sourcePosition, pos);
|
||||
var result = null;
|
||||
if(onBoundingBox){
|
||||
result = new core.Point();
|
||||
if(isAtRight){
|
||||
console.log("incomming at right");
|
||||
result.x = pos.x - (size.width/2)-20;
|
||||
result.y = pos.y;
|
||||
} else {
|
||||
result.x = pos.x;
|
||||
result.y = pos.y;
|
||||
}
|
||||
}else{
|
||||
result = pos;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
mindplot.CentralTopic.prototype.getTopicType = function()
|
||||
|
@@ -1,23 +1,23 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
|
||||
*/
|
||||
|
||||
mindplot.ConnectionLine = function(sourceNode, targetNode)
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
|
||||
*/
|
||||
|
||||
mindplot.ConnectionLine = function(sourceNode, targetNode, lineType)
|
||||
{
|
||||
core.assert(targetNode, 'parentNode node can not be null');
|
||||
core.assert(sourceNode, 'childNode node can not be null');
|
||||
@@ -25,22 +25,50 @@ mindplot.ConnectionLine = function(sourceNode, targetNode)
|
||||
|
||||
this._targetTopic = targetNode;
|
||||
this._sourceTopic = sourceNode;
|
||||
this._isRelationship=false;
|
||||
|
||||
var strokeColor = mindplot.ConnectionLine.getStrokeColor();
|
||||
var line;
|
||||
if (targetNode.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE)
|
||||
{
|
||||
line = new web2d.Line();
|
||||
line = this._createLine(lineType,mindplot.ConnectionLine.SIMPLE);
|
||||
// line = new web2d.Line();
|
||||
line.setStroke(1, 'solid', strokeColor);
|
||||
} else
|
||||
{
|
||||
line = new web2d.PolyLine();
|
||||
line = this._createLine(lineType,mindplot.ConnectionLine.POLYLINE);
|
||||
// line = new web2d.PolyLine();
|
||||
line.setStroke(1, 'solid', strokeColor);
|
||||
}
|
||||
|
||||
this._line2d = line;
|
||||
};
|
||||
|
||||
mindplot.ConnectionLine.prototype._createLine = function(lineType, defaultStyle){
|
||||
if(!core.Utils.isDefined(lineType)){
|
||||
lineType = defaultStyle;
|
||||
}
|
||||
lineType = parseInt(lineType);
|
||||
this._lineType = lineType;
|
||||
var line = null;
|
||||
switch(lineType){
|
||||
case mindplot.ConnectionLine.POLYLINE:
|
||||
line = new web2d.PolyLine();
|
||||
break;
|
||||
case mindplot.ConnectionLine.CURVED:
|
||||
line = new web2d.CurvedLine();
|
||||
break;
|
||||
case mindplot.ConnectionLine.SIMPLE_CURVED:
|
||||
line = new web2d.CurvedLine();
|
||||
line.setStyle(web2d.CurvedLine.SIMPLE_LINE);
|
||||
break;
|
||||
default:
|
||||
line = new web2d.Line();
|
||||
break;
|
||||
}
|
||||
return line;
|
||||
}
|
||||
|
||||
mindplot.ConnectionLine.getStrokeColor = function()
|
||||
{
|
||||
return '#495879';
|
||||
@@ -61,11 +89,28 @@ mindplot.ConnectionLine.prototype.redraw = function()
|
||||
var targetTopic = this._targetTopic;
|
||||
var targetPosition = targetTopic.getPosition();
|
||||
|
||||
var sPos = sourceTopic.workoutOutgoingConnectionPoint(targetPosition);
|
||||
line2d.setTo(sPos.x, sPos.y);
|
||||
var sPos,tPos;
|
||||
if(this._isRelationship){
|
||||
this._line2d.setStroke(2);
|
||||
var ctrlPoints = this._line2d.getControlPoints();
|
||||
if(!core.Utils.isDefined(ctrlPoints[0].x) || !core.Utils.isDefined(ctrlPoints[1].x)){
|
||||
var defaultPoints = core.Utils.calculateDefaultControlPoints(sourceTopic.getPosition(), targetTopic.getPosition());
|
||||
ctrlPoints[0].x=defaultPoints[0].x;
|
||||
ctrlPoints[0].y=defaultPoints[0].y;
|
||||
ctrlPoints[1].x=defaultPoints[1].x;
|
||||
ctrlPoints[1].y=defaultPoints[1].y;
|
||||
}
|
||||
sPos = core.Utils.calculateRelationShipPointCoordinates(sourceTopic,ctrlPoints[0]);
|
||||
tPos = core.Utils.calculateRelationShipPointCoordinates(targetTopic,ctrlPoints[1]);
|
||||
}else{
|
||||
sPos = sourceTopic.workoutOutgoingConnectionPoint(targetPosition, false);
|
||||
tPos = targetTopic.workoutIncomingConnectionPoint(sourcePosition, false);
|
||||
}
|
||||
// console.log("source:"+sPos.x+":"+sPos.y);
|
||||
|
||||
var tPos = targetTopic.workoutIncomingConnectionPoint(sourcePosition);
|
||||
line2d.setFrom(tPos.x, tPos.y);
|
||||
line2d.setFrom(sPos.x, sPos.y);
|
||||
// console.log("target:"+tPos.x+":"+tPos.y);
|
||||
line2d.setTo(tPos.x, tPos.y);
|
||||
|
||||
line2d.moveToBack();
|
||||
|
||||
@@ -111,6 +156,14 @@ mindplot.ConnectionLine.prototype.setStroke = function(color, style, opacity)
|
||||
|
||||
mindplot.ConnectionLine.prototype.addToWorkspace = function(workspace)
|
||||
{
|
||||
if(this._line2d.getType() == "CurvedLine"){
|
||||
this._line2d.addEventListener('click',function(event){
|
||||
var controlPoints = workspace.getLineControlPoints();
|
||||
controlPoints.setLine(this);
|
||||
controlPoints.setVisibility(true);
|
||||
event.stopPropagation();
|
||||
}.bind(this));
|
||||
}
|
||||
workspace.appendChild(this._line2d);
|
||||
};
|
||||
|
||||
@@ -122,4 +175,38 @@ mindplot.ConnectionLine.prototype.removeFromWorkspace = function(workspace)
|
||||
mindplot.ConnectionLine.prototype.getTargetTopic = function()
|
||||
{
|
||||
return this._targetTopic;
|
||||
};
|
||||
};
|
||||
|
||||
mindplot.ConnectionLine.prototype.getSourceTopic = function()
|
||||
{
|
||||
return this._sourceTopic;
|
||||
};
|
||||
|
||||
mindplot.ConnectionLine.prototype.getLineType = function(){
|
||||
return this._lineType;
|
||||
};
|
||||
|
||||
mindplot.ConnectionLine.prototype.getLine = function(){
|
||||
return this._line2d;
|
||||
};
|
||||
|
||||
mindplot.ConnectionLine.prototype.getModel = function(){
|
||||
return this._model;
|
||||
};
|
||||
|
||||
mindplot.ConnectionLine.prototype.setModel = function(model){
|
||||
this._model = model;
|
||||
};
|
||||
|
||||
mindplot.ConnectionLine.prototype.setIsRelationship = function(isRelationship){
|
||||
this._isRelationship=isRelationship;
|
||||
};
|
||||
|
||||
mindplot.ConnectionLine.prototype.isRelationship = function(){
|
||||
return this._isRelationship;
|
||||
};
|
||||
|
||||
mindplot.ConnectionLine.SIMPLE=0;
|
||||
mindplot.ConnectionLine.POLYLINE=1;
|
||||
mindplot.ConnectionLine.CURVED=2;
|
||||
mindplot.ConnectionLine.SIMPLE_CURVED=3;
|
155
mindplot/src/main/javascript/ControlPoint.js
Normal file
155
mindplot/src/main/javascript/ControlPoint.js
Normal file
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
|
||||
*/
|
||||
|
||||
mindplot.ControlPoint = function()
|
||||
{
|
||||
this._controlPoints= [new web2d.Elipse({width:6, height:6, stroke:'1 solid #6589de',fillColor:'gray', visibility:false}),
|
||||
new web2d.Elipse({width:6, height:6, stroke:'1 solid #6589de',fillColor:'gray', visibility:false})];
|
||||
this._controlLines=[new web2d.Line({strokeColor:"#6589de", strokeWidth:1, opacity:0.3}),
|
||||
new web2d.Line({strokeColor:"#6589de", strokeWidth:1, opacity:0.3})];
|
||||
this._isBinded=false;
|
||||
this._controlPoints[0].addEventListener('mousedown',this._mouseDown.bindWithEvent(this, mindplot.ControlPoint.FROM));
|
||||
this._controlPoints[0].addEventListener('click',this._mouseClick.bindWithEvent(this));
|
||||
this._controlPoints[0].addEventListener('dblclick',this._mouseClick.bindWithEvent(this));
|
||||
this._controlPoints[1].addEventListener('mousedown',this._mouseDown.bindWithEvent(this,mindplot.ControlPoint.TO));
|
||||
this._controlPoints[1].addEventListener('click',this._mouseClick.bindWithEvent(this));
|
||||
this._controlPoints[1].addEventListener('dblclick',this._mouseClick.bindWithEvent(this));
|
||||
this._mouseClickOnBackgroundFunction = this._mouseClickOnBackground.bind(this);
|
||||
};
|
||||
|
||||
mindplot.ControlPoint.prototype.setSide= function(side) {
|
||||
this._side = side;
|
||||
};
|
||||
|
||||
mindplot.ControlPoint.prototype.setLine= function(line) {
|
||||
if(core.Utils.isDefined(this._line)){
|
||||
this._removeLine();
|
||||
}
|
||||
this._line= line;
|
||||
this._createControlPoint();
|
||||
};
|
||||
|
||||
mindplot.ControlPoint.prototype._createControlPoint = function() {
|
||||
this._controls= this._line.getLine().getControlPoints();
|
||||
this._controlPoints[0].setPosition(this._controls[mindplot.ControlPoint.FROM].x, this._controls[mindplot.ControlPoint.FROM].y-3);
|
||||
this._controlPoints[1].setPosition(this._controls[mindplot.ControlPoint.TO].x, this._controls[mindplot.ControlPoint.TO].y-3);
|
||||
var pos = this._line.getLine().getFrom();
|
||||
this._controlLines[0].setFrom(pos.x, pos.y);
|
||||
this._controlLines[0].setTo(this._controls[mindplot.ControlPoint.FROM].x+3, this._controls[mindplot.ControlPoint.FROM].y);
|
||||
pos = this._line.getLine().getTo();
|
||||
this._controlLines[1].setFrom(pos.x, pos.y);
|
||||
this._controlLines[1].setTo(this._controls[mindplot.ControlPoint.TO].x+3, this._controls[mindplot.ControlPoint.TO].y);
|
||||
|
||||
};
|
||||
|
||||
mindplot.ControlPoint.prototype._removeLine= function() {
|
||||
|
||||
};
|
||||
|
||||
mindplot.ControlPoint.prototype._mouseDown = function(event, point) {
|
||||
if(!this._isBinded){
|
||||
this._isBinded=true;
|
||||
this._mouseMoveFunction = this._mouseMove.bindWithEvent(this,point);
|
||||
this._workspace.getScreenManager().addEventListener('mousemove',this._mouseMoveFunction);
|
||||
this._mouseUpFunction = this._mouseUp.bindWithEvent(this,point);
|
||||
this._workspace.getScreenManager().addEventListener('mouseup',this._mouseUpFunction);
|
||||
}
|
||||
event.preventDefault();
|
||||
event.stop();
|
||||
return false;
|
||||
};
|
||||
|
||||
mindplot.ControlPoint.prototype._mouseMove = function(event, point) {
|
||||
var screen = this._workspace.getScreenManager();
|
||||
var pos = screen.getWorkspaceMousePosition(event);
|
||||
var topic = null;
|
||||
if(point==0){
|
||||
var cords = core.Utils.calculateRelationShipPointCoordinates(this._line.getSourceTopic(),pos);
|
||||
this._line.getLine().setFrom(cords.x, cords.y);
|
||||
}else{
|
||||
var cords = core.Utils.calculateRelationShipPointCoordinates(this._line.getTargetTopic(),pos);
|
||||
this._line.getLine().setTo(cords.x, cords.y);
|
||||
}
|
||||
this._controls[point].x=pos.x;
|
||||
this._controls[point].y=pos.y;
|
||||
this._controlPoints[point].setPosition(pos.x-5,pos.y-3);
|
||||
this._controlLines[point].setFrom(cords.x, cords.y);
|
||||
this._controlLines[point].setTo(pos.x-2,pos.y);
|
||||
this._line.getLine().updateLine(point);
|
||||
/*event.preventDefault();
|
||||
event.stop();
|
||||
return false;*/
|
||||
};
|
||||
|
||||
mindplot.ControlPoint.prototype._mouseUp = function(event, point) {
|
||||
this._workspace.getScreenManager().removeEventListener('mousemove',this._mouseMoveFunction);
|
||||
this._workspace.getScreenManager().removeEventListener('mouseup',this._mouseUpFunction);
|
||||
var command = new mindplot.commands.MoveControlPointCommand(this,point);
|
||||
designer._actionRunner.execute(command); //todo:Uggly!! designer is global!!
|
||||
this._isBinded=false;
|
||||
/*event.preventDefault();
|
||||
event.stop();
|
||||
return false;*/
|
||||
};
|
||||
|
||||
mindplot.ControlPoint.prototype._mouseClick = function(event){
|
||||
event.preventDefault();
|
||||
event.stop();
|
||||
return false;
|
||||
};
|
||||
|
||||
mindplot.ControlPoint.prototype._mouseClickOnBackground = function(event){
|
||||
this.setVisibility(false);
|
||||
};
|
||||
|
||||
mindplot.ControlPoint.prototype.setVisibility = function(visible){
|
||||
if(visible){
|
||||
this._workspace.getScreenManager().addEventListener('mousedown',this._mouseClickOnBackgroundFunction);
|
||||
this._controlLines[0].moveToFront();
|
||||
this._controlLines[1].moveToFront();
|
||||
this._controlPoints[0].moveToFront();
|
||||
this._controlPoints[1].moveToFront();
|
||||
}
|
||||
else{
|
||||
this._workspace.getScreenManager().removeEventListener('mousedown',this._mouseClickOnBackgroundFunction);
|
||||
}
|
||||
this._controlPoints[0].setVisibility(visible);
|
||||
this._controlPoints[1].setVisibility(visible);
|
||||
this._controlLines[0].setVisibility(visible);
|
||||
this._controlLines[1].setVisibility(visible);
|
||||
};
|
||||
|
||||
mindplot.ControlPoint.prototype.addToWorkspace = function(workspace){
|
||||
this._workspace = workspace;
|
||||
workspace.appendChild(this._controlPoints[0]);
|
||||
workspace.appendChild(this._controlPoints[1]);
|
||||
workspace.appendChild(this._controlLines[0]);
|
||||
workspace.appendChild(this._controlLines[1]);
|
||||
};
|
||||
|
||||
mindplot.ControlPoint.prototype.removeFromWorkspace = function(workspace){
|
||||
this._workspace = null;
|
||||
workspace.removeChild(this._controlPoints[0]);
|
||||
workspace.removeChild(this._controlPoints[1]);
|
||||
workspace.removeChild(this._controlLines[0]);
|
||||
workspace.removeChild(this._controlLines[1]);
|
||||
};
|
||||
|
||||
mindplot.ControlPoint.FROM = 0;
|
||||
mindplot.ControlPoint.TO = 1;
|
@@ -117,6 +117,14 @@ mindplot.CommandContext = new Class({
|
||||
disconnect:function(topic)
|
||||
{
|
||||
topic.disconnect(this._designer._workspace);
|
||||
},
|
||||
createRelationship:function(model){
|
||||
core.assert(model, "model cannot be null");
|
||||
var relationship = this._designer.createRelationship(model);
|
||||
return relationship;
|
||||
},
|
||||
removeRelationship:function(model) {
|
||||
this._designer.removeRelationship(model);
|
||||
}
|
||||
});
|
||||
|
||||
|
@@ -1,22 +1,22 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
|
||||
*/
|
||||
|
||||
mindplot.MainTopic = function(model)
|
||||
{
|
||||
core.assert(model, "Model can not be null");
|
||||
@@ -201,13 +201,18 @@ mindplot.MainTopic.prototype.setPosition = function(point)
|
||||
topicBoard.updateChildrenPosition(this);
|
||||
};
|
||||
|
||||
mindplot.MainTopic.prototype.workoutIncomingConnectionPoint = function(sourcePosition)
|
||||
mindplot.MainTopic.prototype.workoutIncomingConnectionPoint = function(sourcePosition, onBoundingBox)
|
||||
{
|
||||
if(!core.Utils.isDefined(onBoundingBox)){
|
||||
onBoundingBox=false;
|
||||
}
|
||||
|
||||
core.assert(sourcePosition, 'sourcePoint can not be null');
|
||||
var pos = this.getPosition();
|
||||
var size = this.getSize();
|
||||
|
||||
var isAtRight = mindplot.util.Shape.isAtRight(sourcePosition, pos);
|
||||
|
||||
var result = mindplot.util.Shape.calculateRectConnectionPoint(pos, size, isAtRight);
|
||||
if (this.getShapeType() == mindplot.NodeModel.SHAPE_TYPE_LINE)
|
||||
{
|
||||
@@ -223,54 +228,16 @@ mindplot.MainTopic.prototype.workoutIncomingConnectionPoint = function(sourcePos
|
||||
{
|
||||
result.x = result.x - offset;
|
||||
}
|
||||
return result;
|
||||
|
||||
};
|
||||
|
||||
mindplot.MainTopic.prototype.workoutOutgoingConnectionPoint = function(targetPosition)
|
||||
{
|
||||
core.assert(targetPosition, 'targetPoint can not be null');
|
||||
var pos = this.getPosition();
|
||||
var size = this.getSize();
|
||||
|
||||
var isAtRight = mindplot.util.Shape.isAtRight(targetPosition, pos);
|
||||
var result;
|
||||
if (this.getShapeType() == mindplot.NodeModel.SHAPE_TYPE_LINE)
|
||||
{
|
||||
if (!this.isConnectedToCentralTopic())
|
||||
{
|
||||
result = new core.Point();
|
||||
if (!isAtRight)
|
||||
{
|
||||
result.x = pos.x - (size.width / 2);
|
||||
} else
|
||||
{
|
||||
result.x = pos.x + (size.width / 2);
|
||||
}
|
||||
result.y = pos.y + (size.height / 2);
|
||||
} else
|
||||
{
|
||||
// In this case, connetion line is not used as shape figure.
|
||||
result = mindplot.util.Shape.calculateRectConnectionPoint(pos, size, isAtRight, true);
|
||||
result.y = pos.y + (size.height / 2);
|
||||
|
||||
// Correction factor ...
|
||||
if (!isAtRight)
|
||||
{
|
||||
result.x = result.x + 2;
|
||||
} else
|
||||
{
|
||||
result.x = result.x - 2;
|
||||
}
|
||||
|
||||
if(onBoundingBox){
|
||||
if(isAtRight){
|
||||
result.x -= 10;
|
||||
} else{
|
||||
result.x += 10;
|
||||
}
|
||||
} else
|
||||
{
|
||||
result = mindplot.util.Shape.calculateRectConnectionPoint(pos, size, isAtRight, true);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
mindplot.MainTopic.prototype.isConnectedToCentralTopic = function()
|
||||
{
|
||||
|
@@ -1,27 +1,29 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
|
||||
*/
|
||||
|
||||
mindplot.Mindmap = function()
|
||||
{
|
||||
this._branches = [];
|
||||
this._name = null;
|
||||
this._description = null;
|
||||
this._version=null;
|
||||
this._relationships=[];
|
||||
};
|
||||
|
||||
mindplot.Mindmap.prototype.getCentralTopic = function()
|
||||
@@ -45,6 +47,20 @@ mindplot.Mindmap.prototype.setId = function(id)
|
||||
this._iconType = id;
|
||||
};
|
||||
|
||||
|
||||
mindplot.Mindmap.prototype.getVersion = function()
|
||||
{
|
||||
return this._version;
|
||||
};
|
||||
|
||||
|
||||
mindplot.Mindmap.prototype.setVersion = function(version)
|
||||
{
|
||||
this._version = version;
|
||||
};
|
||||
|
||||
|
||||
|
||||
mindplot.Mindmap.prototype.addBranch = function(nodeModel)
|
||||
{
|
||||
core.assert(nodeModel && nodeModel.isNodeModel(), 'Add node must be invoked with model objects');
|
||||
@@ -65,6 +81,10 @@ mindplot.Mindmap.prototype.getBranches = function()
|
||||
return this._branches;
|
||||
};
|
||||
|
||||
mindplot.Mindmap.prototype.getRelationships = function() {
|
||||
return this._relationships;
|
||||
};
|
||||
|
||||
mindplot.Mindmap.prototype.connect = function(parent, child)
|
||||
{
|
||||
// Child already has a parent ?
|
||||
@@ -120,6 +140,21 @@ mindplot.Mindmap.prototype._createNode = function(type)
|
||||
return result;
|
||||
};
|
||||
|
||||
mindplot.Mindmap.prototype.createRelationship = function(fromNode, toNode){
|
||||
core.assert(fromNode, 'from node cannot be null');
|
||||
core.assert(toNode, 'to node cannot be null');
|
||||
|
||||
return new mindplot.RelationshipModel(fromNode, toNode);
|
||||
};
|
||||
|
||||
mindplot.Mindmap.prototype.addRelationship = function(relationship) {
|
||||
this._relationships.push(relationship);
|
||||
};
|
||||
|
||||
mindplot.Mindmap.prototype.removeRelationship = function(relationship) {
|
||||
this._relationships.remove(relationship);
|
||||
};
|
||||
|
||||
mindplot.Mindmap.prototype.inspect = function()
|
||||
{
|
||||
var result = '';
|
||||
|
@@ -17,9 +17,8 @@
|
||||
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
|
||||
*/
|
||||
|
||||
mindplot.MindmapDesigner = function(profile, divElement, persistanManager)
|
||||
mindplot.MindmapDesigner = function(profile, divElement)
|
||||
{
|
||||
core.assert(persistanManager, "Persistant manager must be defined");
|
||||
core.assert(core.Utils.isDefined(profile.zoom), "zoom must be defined");
|
||||
|
||||
// Undo manager ...
|
||||
@@ -53,11 +52,11 @@ mindplot.MindmapDesigner = function(profile, divElement, persistanManager)
|
||||
// Init dragger manager.
|
||||
this._dragger = this._buildDragManager(workspace);
|
||||
|
||||
this._persistantManager = persistanManager;
|
||||
|
||||
// Add shapes to speed up the loading process ...
|
||||
mindplot.DragTopic.initialize(workspace);
|
||||
|
||||
this._relationships={};
|
||||
|
||||
this._events = {};
|
||||
};
|
||||
|
||||
@@ -368,6 +367,62 @@ mindplot.MindmapDesigner.prototype.createSiblingForSelectedNode = function()
|
||||
}
|
||||
};
|
||||
|
||||
mindplot.MindmapDesigner.prototype.addRelationShip2SelectedNode = function(event)
|
||||
{
|
||||
var screen = this._workspace.getScreenManager();
|
||||
var pos = screen.getWorkspaceMousePosition(event);
|
||||
var selectedTopics = this.getSelectedNodes();
|
||||
if(selectedTopics.length >0){
|
||||
var fromNodePosition = selectedTopics[0].getPosition();
|
||||
this._relationship = new web2d.CurvedLine();
|
||||
this._relationship.setStyle(web2d.CurvedLine.SIMPLE_LINE);
|
||||
this._relationship.setDashed(2,2);
|
||||
this._relationship.setFrom(fromNodePosition.x, fromNodePosition.y);
|
||||
this._relationship.setTo(pos.x, pos.y);
|
||||
this._workspace.appendChild(this._relationship);
|
||||
this._relationshipMouseMoveFunction = this._relationshipMouseMove.bindWithEvent(this);
|
||||
this._relationshipMouseClickFunction = this._relationshipMouseClick.bindWithEvent(this, selectedTopics[0]);
|
||||
this._workspace.getScreenManager().addEventListener('mousemove',this._relationshipMouseMoveFunction);
|
||||
this._workspace.getScreenManager().addEventListener('click',this._relationshipMouseClickFunction);
|
||||
}
|
||||
};
|
||||
|
||||
mindplot.MindmapDesigner.prototype._relationshipMouseMove = function(event){
|
||||
var screen = this._workspace.getScreenManager();
|
||||
var pos = screen.getWorkspaceMousePosition(event);
|
||||
this._relationship.setTo(pos.x-1, pos.y-1); //to prevent click event target to be the line itself
|
||||
event.preventDefault();
|
||||
event.stop();
|
||||
return false;
|
||||
};
|
||||
|
||||
mindplot.MindmapDesigner.prototype._relationshipMouseClick = function (event, fromNode) {
|
||||
var target = event.target;
|
||||
while(target.tagName != "g" && core.Utils.isDefined(target.parentNode)){
|
||||
target=target.parentNode;
|
||||
}
|
||||
if(core.Utils.isDefined(target.virtualRef)){
|
||||
var targetNode = target.virtualRef;
|
||||
this.addRelationship(fromNode, targetNode);
|
||||
}
|
||||
this._workspace.removeChild(this._relationship);
|
||||
this._relationship = null;
|
||||
this._workspace.getScreenManager().removeEventListener('mousemove',this._relationshipMouseMoveFunction);
|
||||
this._workspace.getScreenManager().removeEventListener('click',this._relationshipMouseClickFunction);
|
||||
event.preventDefault();
|
||||
event.stop();
|
||||
return false;
|
||||
};
|
||||
|
||||
mindplot.MindmapDesigner.prototype.addRelationship= function(fromNode, toNode){
|
||||
// Create a new topic model ...
|
||||
var mindmap = this.getMindmap();
|
||||
var model = mindmap.createRelationship(fromNode.getModel().getId(), toNode.getModel().getId());
|
||||
|
||||
var command = new mindplot.commands.AddRelationshipCommand(model, mindmap);
|
||||
this._actionRunner.execute(command);
|
||||
};
|
||||
|
||||
mindplot.MindmapDesigner.prototype.needsSave = function()
|
||||
{
|
||||
return this._actionRunner.hasBeenChanged();
|
||||
@@ -390,7 +445,7 @@ mindplot.MindmapDesigner.prototype.autoSaveEnabled = function(value)
|
||||
|
||||
mindplot.MindmapDesigner.prototype.save = function(onSavedHandler, saveHistory)
|
||||
{
|
||||
var persistantManager = this._persistantManager;
|
||||
var persistantManager = mindplot.PersistanceManager;
|
||||
var mindmap = this._mindmap;
|
||||
|
||||
var xmlChart = this._workspace.dumpNativeChart();
|
||||
@@ -417,7 +472,7 @@ mindplot.MindmapDesigner.prototype.loadFromXML = function(mapId, xmlContent)
|
||||
// Explorer Hack with local files ...
|
||||
var domDocument = core.Utils.createDocumentFromText(xmlContent);
|
||||
|
||||
var serializer = new mindplot.XMLMindmapSerializer();
|
||||
var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromDocument(domDocument);
|
||||
var mindmap = serializer.loadFromDom(domDocument);
|
||||
|
||||
this._loadMap(mapId, mindmap);
|
||||
@@ -435,7 +490,7 @@ mindplot.MindmapDesigner.prototype.load = function(mapId)
|
||||
core.assert(mapId, 'mapName can not be null');
|
||||
|
||||
// Build load function ...
|
||||
var persistantManager = this._persistantManager;
|
||||
var persistantManager = mindplot.PersistanceManager;
|
||||
|
||||
// Loading mindmap ...
|
||||
var mindmap = persistantManager.load(mapId);
|
||||
@@ -469,6 +524,10 @@ mindplot.MindmapDesigner.prototype._loadMap = function(mapId, mindmapModel)
|
||||
// Update shrink render state...
|
||||
nodeGraph.setBranchVisibility(true);
|
||||
}
|
||||
var relationships = mindmapModel.getRelationships();
|
||||
for (var j=0; j<relationships.length; j++) {
|
||||
var relationship = this._relationshipModelToRelationship(relationships[j]);
|
||||
}
|
||||
}
|
||||
this._fireEvent("loadsuccess");
|
||||
|
||||
@@ -527,6 +586,86 @@ mindplot.MindmapDesigner.prototype._nodeModelToNodeGraph = function(nodeModel)
|
||||
return nodeGraph;
|
||||
};
|
||||
|
||||
mindplot.MindmapDesigner.prototype._relationshipModelToRelationship = function(model) {
|
||||
core.assert(model, "Node model can not be null");
|
||||
var relationship = this._buildRelationship(model);
|
||||
var sourceTopic = relationship.getSourceTopic();
|
||||
sourceTopic.addRelationship(relationship);
|
||||
var targetTopic = relationship.getTargetTopic();
|
||||
targetTopic.addRelationship(relationship);
|
||||
var workspace = this._workspace;
|
||||
workspace.appendChild(relationship);
|
||||
relationship.redraw();
|
||||
return relationship;
|
||||
};
|
||||
|
||||
mindplot.MindmapDesigner.prototype.createRelationship= function(model){
|
||||
this._mindmap.addRelationship(model);
|
||||
return this._relationshipModelToRelationship(model);
|
||||
};
|
||||
|
||||
mindplot.MindmapDesigner.prototype.removeRelationship = function(model) {
|
||||
this._mindmap.removeRelationship(model);
|
||||
var relationship = this._relationships[model.getId()];
|
||||
var sourceTopic = relationship.getSourceTopic();
|
||||
sourceTopic.removeRelationship(relationship);
|
||||
var targetTopic = relationship.getTargetTopic();
|
||||
targetTopic.removeRelationship(relationship);
|
||||
this._workspace.removeChild(relationship);
|
||||
delete this._relationships[model.getId()];
|
||||
};
|
||||
|
||||
mindplot.MindmapDesigner.prototype._buildRelationship = function (model) {
|
||||
var workspace = this._workspace;
|
||||
var elem = this;
|
||||
|
||||
var fromNodeId = model.getFromNode();
|
||||
var toNodeId = model.getToNode();
|
||||
|
||||
var fromTopic = null;
|
||||
var toTopic = null;
|
||||
var topics = this._topics;
|
||||
|
||||
for (var i = 0; i < topics.length; i++)
|
||||
{
|
||||
var t = topics[i];
|
||||
if (t.getModel().getId() == fromNodeId)
|
||||
{
|
||||
fromTopic= t;
|
||||
if(toTopic!=null){
|
||||
break;
|
||||
}
|
||||
}else if (t.getModel().getId() == toNodeId)
|
||||
{
|
||||
toTopic= t;
|
||||
if(fromTopic!=null){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create node graph ...
|
||||
var relationLine = new mindplot.ConnectionLine(fromTopic, toTopic, model.getLineType());
|
||||
relationLine.setIsRelationship(true);
|
||||
if(core.Utils.isDefined(model.getSrcCtrlPoint())){
|
||||
var srcPoint = model.getSrcCtrlPoint().clone();
|
||||
relationLine.getLine().setSrcControlPoint(srcPoint);
|
||||
}
|
||||
if(core.Utils.isDefined(model.getDestCtrlPoint())){
|
||||
var destPoint = model.getDestCtrlPoint().clone();
|
||||
relationLine.getLine().setDestControlPoint(destPoint);
|
||||
}
|
||||
|
||||
|
||||
relationLine.getLine().setDashed(3,2);
|
||||
relationLine.getLine().setShowArrow(model.getEndArrow());
|
||||
relationLine.setModel(model);
|
||||
// Append it to the workspace ...
|
||||
this._relationships[model.getId()]=relationLine;
|
||||
|
||||
return relationLine;
|
||||
};
|
||||
|
||||
mindplot.MindmapDesigner.prototype.getEditor = function()
|
||||
{
|
||||
return this._editor;
|
||||
|
4
mindplot/src/main/javascript/ModelCodeName.js
Normal file
4
mindplot/src/main/javascript/ModelCodeName.js
Normal file
@@ -0,0 +1,4 @@
|
||||
mindplot.ModelCodeName ={};
|
||||
|
||||
mindplot.ModelCodeName.BETA = "beta";
|
||||
mindplot.ModelCodeName.PELA = "pela";
|
@@ -1,22 +1,22 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
|
||||
*/
|
||||
|
||||
mindplot.NodeModel = function(type, mindmap)
|
||||
{
|
||||
core.assert(type, 'Node type can not be null');
|
||||
|
@@ -17,13 +17,9 @@
|
||||
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
|
||||
*/
|
||||
|
||||
mindplot.PersistanceManager = function(editorService)
|
||||
{
|
||||
this._editorService = editorService;
|
||||
this._serializer = new mindplot.XMLMindmapSerializer();
|
||||
};
|
||||
mindplot.PersistanceManager = {};
|
||||
|
||||
mindplot.PersistanceManager.prototype.save = function(mindmap, chartType, xmlChart, editorProperties, onSavedHandler,saveHistory)
|
||||
mindplot.PersistanceManager.save = function(mindmap, chartType, xmlChart, editorProperties, onSavedHandler,saveHistory)
|
||||
{
|
||||
core.assert(mindmap, "mindmap can not be null");
|
||||
core.assert(chartType, "chartType can not be null");
|
||||
@@ -32,11 +28,12 @@ mindplot.PersistanceManager.prototype.save = function(mindmap, chartType, xmlCha
|
||||
|
||||
var mapId = mindmap.getId();
|
||||
|
||||
var xmlMap = this._serializer.toXML(mindmap);
|
||||
var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromMindmap(mindmap);
|
||||
var xmlMap = serializer.toXML(mindmap);
|
||||
var xmlMapStr = core.Utils.innerXML(xmlMap);
|
||||
|
||||
var pref = Json.toString(editorProperties);
|
||||
this._editorService.saveMap(mapId, xmlMapStr, chartType, xmlChart, pref,saveHistory,
|
||||
window.MapEditorService.saveMap(mapId, xmlMapStr, chartType, xmlChart, pref,saveHistory,
|
||||
{
|
||||
callback:function(response) {
|
||||
|
||||
@@ -64,14 +61,12 @@ mindplot.PersistanceManager.prototype.save = function(mindmap, chartType, xmlCha
|
||||
|
||||
};
|
||||
|
||||
mindplot.PersistanceManager.prototype.load = function(mapId)
|
||||
mindplot.PersistanceManager.load = function(mapId)
|
||||
{
|
||||
core.assert(mapId, "mapId can not be null");
|
||||
|
||||
var deserializer = this;
|
||||
var result = {r:null};
|
||||
var serializer = this._serializer;
|
||||
this._editorService.loadMap(mapId, {
|
||||
window.MapEditorService.loadMap(mapId, {
|
||||
callback:function(response) {
|
||||
|
||||
if (response.msgCode == "OK")
|
||||
@@ -79,6 +74,7 @@ mindplot.PersistanceManager.prototype.load = function(mapId)
|
||||
// Explorer Hack with local files ...
|
||||
var xmlContent = response.content;
|
||||
var domDocument = core.Utils.createDocumentFromText(xmlContent);
|
||||
var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromDocument(domDocument);
|
||||
var mindmap = serializer.loadFromDom(domDocument);
|
||||
mindmap.setId(mapId);
|
||||
|
||||
|
88
mindplot/src/main/javascript/RelationshipModel.js
Normal file
88
mindplot/src/main/javascript/RelationshipModel.js
Normal file
@@ -0,0 +1,88 @@
|
||||
mindplot.RelationshipModel = function(fromNode, toNode)
|
||||
{
|
||||
core.assert(fromNode, 'from node type can not be null');
|
||||
core.assert(toNode, 'to node type can not be null');
|
||||
|
||||
this._id = mindplot.RelationshipModel._nextUUID();
|
||||
this._fromNode = fromNode;
|
||||
this._toNode = toNode;
|
||||
this._lineType=mindplot.ConnectionLine.SIMPLE_CURVED;
|
||||
this._srcCtrlPoint=null;
|
||||
this._destCtrlPoint=null;
|
||||
this._endArrow=true;
|
||||
|
||||
};
|
||||
|
||||
mindplot.RelationshipModel.prototype.getFromNode=function(){
|
||||
return this._fromNode;
|
||||
};
|
||||
|
||||
mindplot.RelationshipModel.prototype.getToNode=function(){
|
||||
return this._toNode;
|
||||
};
|
||||
|
||||
mindplot.RelationshipModel.prototype.getId=function(){
|
||||
return this._id;
|
||||
};
|
||||
|
||||
mindplot.RelationshipModel.prototype.getLineType = function(){
|
||||
return this._lineType;
|
||||
};
|
||||
|
||||
mindplot.RelationshipModel.prototype.setLineType = function(lineType){
|
||||
this._lineType = lineType;
|
||||
};
|
||||
|
||||
mindplot.RelationshipModel.prototype.getSrcCtrlPoint= function(){
|
||||
return this._srcCtrlPoint;
|
||||
};
|
||||
|
||||
mindplot.RelationshipModel.prototype.setSrcCtrlPoint= function(srcCtrlPoint){
|
||||
this._srcCtrlPoint = srcCtrlPoint;
|
||||
};
|
||||
|
||||
mindplot.RelationshipModel.prototype.getDestCtrlPoint= function(){
|
||||
return this._destCtrlPoint;
|
||||
};
|
||||
|
||||
mindplot.RelationshipModel.prototype.setDestCtrlPoint= function(destCtrlPoint){
|
||||
this._destCtrlPoint = destCtrlPoint;
|
||||
};
|
||||
|
||||
mindplot.RelationshipModel.prototype.getEndArrow= function(){
|
||||
return this._endArrow;
|
||||
};
|
||||
|
||||
mindplot.RelationshipModel.prototype.setEndArrow= function(endArrow){
|
||||
this._endArrow = endArrow;
|
||||
};
|
||||
|
||||
mindplot.RelationshipModel.prototype.clone = function(model){
|
||||
var result = new mindplot.RelationshipModel(this._fromNode, this._toNode);
|
||||
result._id = this._id;
|
||||
result._lineType = this._lineType;
|
||||
result._srcCtrlPoint = this._srcCtrlPoint;
|
||||
result._destCtrlPoint = this._destCtrlPoint;
|
||||
result._endArrow = this._endArrow;
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* @todo: This method must be implemented.
|
||||
*/
|
||||
mindplot.RelationshipModel._nextUUID = function()
|
||||
{
|
||||
if (!this._uuid)
|
||||
{
|
||||
this._uuid = 0;
|
||||
}
|
||||
|
||||
this._uuid = this._uuid + 1;
|
||||
return this._uuid;
|
||||
};
|
||||
|
||||
|
||||
mindplot.RelationshipModel.prototype.inspect = function()
|
||||
{
|
||||
return '(fromNode:' + this.getFromNode().getId() + ' , toNode: ' + this.getToNode().getId() + ')';
|
||||
};
|
@@ -1,22 +1,22 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
|
||||
*/
|
||||
|
||||
mindplot.Topic = function()
|
||||
{
|
||||
mindplot.Topic.superClass.initialize.call(this);
|
||||
@@ -31,6 +31,8 @@ mindplot.Topic.prototype.initialize = function(topicBoard)
|
||||
this._children = [];
|
||||
this._parent = null;
|
||||
this._lastIconId = -1;
|
||||
this._relationships = [];
|
||||
this._isInWorkspace = false;
|
||||
|
||||
this._topicBoard = topicBoard;
|
||||
this._buildShape();
|
||||
@@ -419,6 +421,18 @@ mindplot.Topic.prototype.removeNote = function(){
|
||||
this._hasNote=false;
|
||||
}
|
||||
|
||||
mindplot.Topic.prototype.addRelationship = function(relationship){
|
||||
this._relationships.push(relationship);
|
||||
};
|
||||
|
||||
mindplot.Topic.prototype.removeRelationship = function(relationship){
|
||||
this._relationships.remove(relationship);
|
||||
};
|
||||
|
||||
mindplot.Topic.prototype.getRelationships = function(){
|
||||
return this._relationships;
|
||||
};
|
||||
|
||||
mindplot.Topic.prototype._buildTextShape = function(disableEventsListeners)
|
||||
{
|
||||
var result = new web2d.Text();
|
||||
@@ -646,7 +660,7 @@ mindplot.Topic.prototype._setText = function(text, updateModel)
|
||||
{
|
||||
return function()
|
||||
{
|
||||
elem.updateNode();
|
||||
elem.updateNode();
|
||||
};
|
||||
};
|
||||
|
||||
@@ -741,6 +755,7 @@ mindplot.Topic.prototype._buildShape = function()
|
||||
{
|
||||
var groupAttributes = {width: 100, height:100,coordSizeWidth:100,coordSizeHeight:100};
|
||||
var group = new web2d.Group(groupAttributes);
|
||||
group._peer._native.virtualRef=this;
|
||||
this._set2DElement(group);
|
||||
|
||||
// Shape must be build based on the model width ...
|
||||
@@ -949,6 +964,11 @@ mindplot.Topic.prototype._updateConnectionLines = function()
|
||||
{
|
||||
incomingLines[i].redraw();
|
||||
}
|
||||
|
||||
// Update relationship lines
|
||||
for(var j=0; j<this._relationships.length; j++){
|
||||
this._relationships[j].redraw();
|
||||
}
|
||||
};
|
||||
|
||||
mindplot.Topic.prototype.setBranchVisibility = function(value)
|
||||
@@ -1222,12 +1242,18 @@ mindplot.Topic.prototype.removeFromWorkspace = function(workspace)
|
||||
{
|
||||
workspace.removeChild(line);
|
||||
}
|
||||
this._isInWorkspace=false;
|
||||
};
|
||||
|
||||
mindplot.Topic.prototype.addToWorkspace = function(workspace)
|
||||
{
|
||||
var elem = this.get2DElement();
|
||||
workspace.appendChild(elem);
|
||||
this._isInWorkspace=true;
|
||||
};
|
||||
|
||||
mindplot.Topic.prototype.isInWorkspace = function(){
|
||||
return this._isInWorkspace;
|
||||
};
|
||||
|
||||
mindplot.Topic.prototype.getTopicBoard = function()
|
||||
@@ -1250,16 +1276,78 @@ mindplot.Topic.prototype.createDragNode = function()
|
||||
|
||||
mindplot.Topic.prototype.updateNode = function()
|
||||
{
|
||||
var textShape = this.getTextShape();
|
||||
var sizeWidth = textShape.getWidth();
|
||||
var sizeHeight = textShape.getHeight();
|
||||
var font = textShape.getFont();
|
||||
var iconOffset = this.getIconOffset();
|
||||
if(this.isInWorkspace()){
|
||||
var textShape = this.getTextShape();
|
||||
var sizeWidth = textShape.getWidth();
|
||||
var sizeHeight = textShape.getHeight();
|
||||
var font = textShape.getFont();
|
||||
var iconOffset = this.getIconOffset();
|
||||
|
||||
var newSize = {width:sizeWidth + this._offset*2 + iconOffset,height:sizeHeight + this._offset};
|
||||
this.setSize(newSize);
|
||||
var newSize = {width:sizeWidth + this._offset*2 + iconOffset,height:sizeHeight + this._offset};
|
||||
this.setSize(newSize);
|
||||
|
||||
// Positionate node ...
|
||||
textShape.setPosition(iconOffset+this._offset, this._offset / 2);
|
||||
textShape.setTextSize(sizeWidth, sizeHeight);
|
||||
// Positionate node ...
|
||||
textShape.setPosition(iconOffset+this._offset, this._offset / 2);
|
||||
textShape.setTextSize(sizeWidth, sizeHeight);
|
||||
}
|
||||
};
|
||||
|
||||
mindplot.Topic.prototype.workoutOutgoingConnectionPoint = function(targetPosition, onBoundingBox)
|
||||
{
|
||||
if(!core.Utils.isDefined(onBoundingBox)){
|
||||
onBoundingBox=false;
|
||||
}
|
||||
|
||||
core.assert(targetPosition, 'targetPoint can not be null');
|
||||
var pos = this.getPosition();
|
||||
var size = this.getSize();
|
||||
|
||||
var isAtRight = mindplot.util.Shape.isAtRight(targetPosition, pos);
|
||||
var result;
|
||||
if(onBoundingBox){
|
||||
result = new core.Point();
|
||||
if(isAtRight){
|
||||
result.x = pos.x - (size.width/2)-5;
|
||||
result.y = pos.y;
|
||||
} else {
|
||||
result.x = pos.x + (size.width/2)+ 5;
|
||||
result.y = pos.y;
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (this.getShapeType() == mindplot.NodeModel.SHAPE_TYPE_LINE)
|
||||
{
|
||||
if (!this.isConnectedToCentralTopic())
|
||||
{
|
||||
result = new core.Point();
|
||||
if (!isAtRight)
|
||||
{
|
||||
result.x = pos.x - (size.width / 2);
|
||||
} else
|
||||
{
|
||||
result.x = pos.x + (size.width / 2);
|
||||
}
|
||||
result.y = pos.y + (size.height / 2);
|
||||
} else
|
||||
{
|
||||
// In this case, connetion line is not used as shape figure.
|
||||
result = mindplot.util.Shape.calculateRectConnectionPoint(pos, size, isAtRight, true);
|
||||
result.y = pos.y + (size.height / 2);
|
||||
|
||||
// Correction factor ...
|
||||
if (!isAtRight)
|
||||
{
|
||||
result.x = result.x + 2;
|
||||
} else
|
||||
{
|
||||
result.x = result.x - 2;
|
||||
}
|
||||
|
||||
}
|
||||
} else
|
||||
{
|
||||
result = mindplot.util.Shape.calculateRectConnectionPoint(pos, size, isAtRight, true);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
@@ -41,6 +41,9 @@ mindplot.Workspace = function(profile, screenManager, zoom)
|
||||
// Register drag events ...
|
||||
this._registerDragEvents();
|
||||
|
||||
//Create CurvedLineControlPoints
|
||||
this._createCuvedLineControlPoints();
|
||||
|
||||
this._eventsEnabled = true;
|
||||
|
||||
};
|
||||
@@ -234,3 +237,12 @@ mindplot.Workspace.prototype._registerDragEvents = function()
|
||||
screenManager.addEventListener('mousedown', mouseDownListener);
|
||||
};
|
||||
|
||||
mindplot.Workspace.prototype._createCuvedLineControlPoints = function(){
|
||||
this._lineControlPoints = new mindplot.ControlPoint();
|
||||
this.appendChild(this._lineControlPoints);
|
||||
};
|
||||
|
||||
mindplot.Workspace.prototype.getLineControlPoints = function(){
|
||||
return this._lineControlPoints;
|
||||
};
|
||||
|
||||
|
@@ -0,0 +1,46 @@
|
||||
mindplot.XMLMindmapSerializerFactory = {};
|
||||
|
||||
mindplot.XMLMindmapSerializerFactory.getSerializerFromMindmap = function(mindmap){
|
||||
return mindplot.XMLMindmapSerializerFactory.getSerializer(mindmap.getVersion());
|
||||
};
|
||||
|
||||
mindplot.XMLMindmapSerializerFactory.getSerializerFromDocument = function(domDocument){
|
||||
var rootElem = domDocument.documentElement;
|
||||
return mindplot.XMLMindmapSerializerFactory.getSerializer(rootElem.getAttribute("version"))
|
||||
};
|
||||
|
||||
|
||||
mindplot.XMLMindmapSerializerFactory.getSerializer = function(version){
|
||||
if(!core.Utils.isDefined(version)){
|
||||
version = mindplot.ModelCodeName.BETA;
|
||||
}
|
||||
var codeNames = mindplot.XMLMindmapSerializerFactory._codeNames;
|
||||
var found = false;
|
||||
var serializer = null;
|
||||
for(var i=0; i<codeNames.length; i++){
|
||||
if(!found){
|
||||
found = codeNames[i].codeName==version;
|
||||
if(found)
|
||||
serializer = new (codeNames[i].serializer)();
|
||||
} else{
|
||||
var migrator = codeNames[i].migrator;
|
||||
serializer = new migrator(serializer);
|
||||
}
|
||||
}
|
||||
|
||||
return serializer;
|
||||
};
|
||||
|
||||
mindplot.XMLMindmapSerializerFactory._codeNames =
|
||||
[{
|
||||
codeName:mindplot.ModelCodeName.BETA,
|
||||
serializer: mindplot.XMLMindmapSerializer_Beta,
|
||||
migrator:function(){//todo:error
|
||||
}
|
||||
},
|
||||
{
|
||||
codeName:mindplot.ModelCodeName.PELA,
|
||||
serializer:mindplot.XMLMindmapSerializer_Pela,
|
||||
migrator:mindplot.Beta2PelaMigrator
|
||||
}
|
||||
];
|
@@ -1,28 +1,9 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
|
||||
*/
|
||||
|
||||
mindplot.XMLMindmapSerializer = function()
|
||||
mindplot.XMLMindmapSerializer_Beta = function()
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
mindplot.XMLMindmapSerializer.prototype.toXML = function(mindmap)
|
||||
mindplot.XMLMindmapSerializer_Beta.prototype.toXML = function(mindmap)
|
||||
{
|
||||
core.assert(mindmap, "Can not save a null mindmap");
|
||||
|
||||
@@ -49,7 +30,7 @@ mindplot.XMLMindmapSerializer.prototype.toXML = function(mindmap)
|
||||
return document;
|
||||
};
|
||||
|
||||
mindplot.XMLMindmapSerializer.prototype._topicToXML = function(document, topic)
|
||||
mindplot.XMLMindmapSerializer_Beta.prototype._topicToXML = function(document, topic)
|
||||
{
|
||||
var parentTopic = document.createElement("topic");
|
||||
|
||||
@@ -158,37 +139,37 @@ mindplot.XMLMindmapSerializer.prototype._topicToXML = function(document, topic)
|
||||
return parentTopic;
|
||||
};
|
||||
|
||||
mindplot.XMLMindmapSerializer.prototype._iconToXML = function(document, icon)
|
||||
mindplot.XMLMindmapSerializer_Beta.prototype._iconToXML = function(document, icon)
|
||||
{
|
||||
var iconDom = document.createElement("icon");
|
||||
iconDom.setAttribute('id', icon.getIconType());
|
||||
return iconDom;
|
||||
};
|
||||
|
||||
mindplot.XMLMindmapSerializer.prototype._linkToXML = function(document, link)
|
||||
mindplot.XMLMindmapSerializer_Beta.prototype._linkToXML = function(document, link)
|
||||
{
|
||||
var linkDom = document.createElement("link");
|
||||
linkDom.setAttribute('url', link.getUrl());
|
||||
return linkDom;
|
||||
};
|
||||
|
||||
mindplot.XMLMindmapSerializer.prototype._noteToXML = function(document, note)
|
||||
mindplot.XMLMindmapSerializer_Beta.prototype._noteToXML = function(document, note)
|
||||
{
|
||||
var noteDom = document.createElement("note");
|
||||
noteDom.setAttribute('text', note.getText());
|
||||
return noteDom;
|
||||
};
|
||||
|
||||
mindplot.XMLMindmapSerializer.prototype.loadFromDom = function(dom)
|
||||
mindplot.XMLMindmapSerializer_Beta.prototype.loadFromDom = function(dom)
|
||||
{
|
||||
core.assert(dom, "Dom can not be null");
|
||||
var rootElem = dom.documentElement;
|
||||
|
||||
// Is a wisemap?.
|
||||
core.assert(rootElem.tagName == mindplot.XMLMindmapSerializer.MAP_ROOT_NODE, "This seem not to be a map document.");
|
||||
core.assert(rootElem.tagName == mindplot.XMLMindmapSerializer_Beta.MAP_ROOT_NODE, "This seem not to be a map document.");
|
||||
|
||||
// Start the loading process ...
|
||||
var mindmap = new mindplot.Mindmap();
|
||||
var mindmap = new mindplot.Mindmap();
|
||||
|
||||
var children = rootElem.childNodes;
|
||||
for (var i = 0; i < children.length; i++)
|
||||
@@ -203,7 +184,7 @@ mindplot.XMLMindmapSerializer.prototype.loadFromDom = function(dom)
|
||||
return mindmap;
|
||||
};
|
||||
|
||||
mindplot.XMLMindmapSerializer.prototype._deserializeNode = function(domElem, mindmap)
|
||||
mindplot.XMLMindmapSerializer_Beta.prototype._deserializeNode = function(domElem, mindmap)
|
||||
{
|
||||
var type = (domElem.getAttribute('central') != null) ? mindplot.NodeModel.CENTRAL_TOPIC_TYPE : mindplot.NodeModel.MAIN_TOPIC_TYPE;
|
||||
var topic = mindmap.createNode(type);
|
||||
@@ -303,19 +284,19 @@ mindplot.XMLMindmapSerializer.prototype._deserializeNode = function(domElem, min
|
||||
return topic;
|
||||
};
|
||||
|
||||
mindplot.XMLMindmapSerializer.prototype._deserializeIcon = function(domElem, topic)
|
||||
mindplot.XMLMindmapSerializer_Beta.prototype._deserializeIcon = function(domElem, topic)
|
||||
{
|
||||
return topic.createIcon(domElem.getAttribute("id"));
|
||||
};
|
||||
|
||||
mindplot.XMLMindmapSerializer.prototype._deserializeLink = function(domElem, topic)
|
||||
mindplot.XMLMindmapSerializer_Beta.prototype._deserializeLink = function(domElem, topic)
|
||||
{
|
||||
return topic.createLink(domElem.getAttribute("url"));
|
||||
};
|
||||
|
||||
mindplot.XMLMindmapSerializer.prototype._deserializeNote = function(domElem, topic)
|
||||
mindplot.XMLMindmapSerializer_Beta.prototype._deserializeNote = function(domElem, topic)
|
||||
{
|
||||
return topic.createNote(domElem.getAttribute("text"));
|
||||
};
|
||||
|
||||
mindplot.XMLMindmapSerializer.MAP_ROOT_NODE = 'map';
|
||||
mindplot.XMLMindmapSerializer_Beta.MAP_ROOT_NODE = 'map';
|
397
mindplot/src/main/javascript/XMLMindmapSerializer_Pela.js
Normal file
397
mindplot/src/main/javascript/XMLMindmapSerializer_Pela.js
Normal file
@@ -0,0 +1,397 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
|
||||
*/
|
||||
|
||||
mindplot.XMLMindmapSerializer_Pela = function()
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
mindplot.XMLMindmapSerializer_Pela.prototype.toXML = function(mindmap)
|
||||
{
|
||||
core.assert(mindmap, "Can not save a null mindmap");
|
||||
|
||||
var document = core.Utils.createDocument();
|
||||
|
||||
// Store map attributes ...
|
||||
var mapElem = document.createElement("map");
|
||||
var name = mindmap.getId();
|
||||
if (name)
|
||||
{
|
||||
mapElem.setAttribute('name', name);
|
||||
}
|
||||
var version = mindmap.getVersion();
|
||||
if (version)
|
||||
{
|
||||
mapElem.setAttribute('version', version);
|
||||
}
|
||||
|
||||
document.appendChild(mapElem);
|
||||
|
||||
// Create branches ...
|
||||
var topics = mindmap.getBranches();
|
||||
for (var i = 0; i < topics.length; i++)
|
||||
{
|
||||
var topic = topics[i];
|
||||
var topicDom = this._topicToXML(document, topic);
|
||||
mapElem.appendChild(topicDom);
|
||||
}
|
||||
|
||||
// Create Relationships
|
||||
var relationships = mindmap.getRelationships();
|
||||
if(relationships.length>0){
|
||||
// var relationshipDom=document.createElement("relationships");
|
||||
// mapElem.appendChild(relationshipDom);
|
||||
for (var j = 0; j<relationships.length; j++){
|
||||
var relationDom = this._relationshipToXML(document, relationships[j]);
|
||||
mapElem.appendChild(relationDom);
|
||||
}
|
||||
}
|
||||
|
||||
return document;
|
||||
};
|
||||
|
||||
mindplot.XMLMindmapSerializer_Pela.prototype._topicToXML = function(document, topic)
|
||||
{
|
||||
var parentTopic = document.createElement("topic");
|
||||
|
||||
// Set topic attributes...
|
||||
if (topic.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE)
|
||||
{
|
||||
parentTopic.setAttribute("central", true);
|
||||
} else
|
||||
{
|
||||
var parent = topic.getParent();
|
||||
if (parent == null || parent.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE)
|
||||
{
|
||||
var pos = topic.getPosition();
|
||||
parentTopic.setAttribute("position", pos.x + ',' + pos.y);
|
||||
} else
|
||||
{
|
||||
var order = topic.getOrder();
|
||||
parentTopic.setAttribute("order", order);
|
||||
}
|
||||
}
|
||||
|
||||
var text = topic.getText();
|
||||
if (text) {
|
||||
parentTopic.setAttribute('text', text);
|
||||
}
|
||||
|
||||
var shape = topic.getShapeType();
|
||||
if (shape) {
|
||||
parentTopic.setAttribute('shape', shape);
|
||||
}
|
||||
|
||||
if(topic.areChildrenShrinked())
|
||||
{
|
||||
parentTopic.setAttribute('shrink',true);
|
||||
}
|
||||
|
||||
// Font properties ...
|
||||
var id = topic.getId();
|
||||
parentTopic.setAttribute('id',id);
|
||||
|
||||
var font = "";
|
||||
|
||||
var fontFamily = topic.getFontFamily();
|
||||
font += (fontFamily ? fontFamily : '') + ';';
|
||||
|
||||
var fontSize = topic.getFontSize();
|
||||
font += (fontSize ? fontSize : '') + ';';
|
||||
|
||||
var fontColor = topic.getFontColor();
|
||||
font += (fontColor ? fontColor : '') + ';';
|
||||
|
||||
var fontWeight = topic.getFontWeight();
|
||||
font += (fontWeight ? fontWeight : '') + ';';
|
||||
|
||||
var fontStyle = topic.getFontStyle();
|
||||
font += (fontStyle ? fontStyle : '') + ';';
|
||||
|
||||
if (fontFamily || fontSize || fontColor || fontWeight || fontStyle)
|
||||
{
|
||||
parentTopic.setAttribute('fontStyle', font);
|
||||
}
|
||||
|
||||
var bgColor = topic.getBackgroundColor();
|
||||
if (bgColor) {
|
||||
parentTopic.setAttribute('bgColor', bgColor);
|
||||
}
|
||||
|
||||
var brColor = topic.getBorderColor();
|
||||
if (brColor) {
|
||||
parentTopic.setAttribute('brColor', brColor);
|
||||
}
|
||||
|
||||
//ICONS
|
||||
var icons = topic.getIcons();
|
||||
for (var i = 0; i < icons.length; i++)
|
||||
{
|
||||
var icon = icons[i];
|
||||
var iconDom = this._iconToXML(document, icon);
|
||||
parentTopic.appendChild(iconDom);
|
||||
}
|
||||
|
||||
//LINKS
|
||||
var links = topic.getLinks();
|
||||
for (var i = 0; i < links.length; i++)
|
||||
{
|
||||
var link = links[i];
|
||||
var linkDom = this._linkToXML(document, link);
|
||||
parentTopic.appendChild(linkDom);
|
||||
}
|
||||
|
||||
var notes = topic.getNotes();
|
||||
for (var i = 0; i < notes.length; i++)
|
||||
{
|
||||
var note = notes[i];
|
||||
var noteDom = this._noteToXML(document, note);
|
||||
parentTopic.appendChild(noteDom);
|
||||
}
|
||||
|
||||
//CHILDREN TOPICS
|
||||
var childTopics = topic.getChildren();
|
||||
for (var i = 0; i < childTopics.length; i++)
|
||||
{
|
||||
var childTopic = childTopics[i];
|
||||
var childDom = this._topicToXML(document, childTopic);
|
||||
parentTopic.appendChild(childDom);
|
||||
|
||||
}
|
||||
|
||||
return parentTopic;
|
||||
};
|
||||
|
||||
mindplot.XMLMindmapSerializer_Pela.prototype._iconToXML = function(document, icon)
|
||||
{
|
||||
var iconDom = document.createElement("icon");
|
||||
iconDom.setAttribute('id', icon.getIconType());
|
||||
return iconDom;
|
||||
};
|
||||
|
||||
mindplot.XMLMindmapSerializer_Pela.prototype._linkToXML = function(document, link)
|
||||
{
|
||||
var linkDom = document.createElement("link");
|
||||
linkDom.setAttribute('url', link.getUrl());
|
||||
return linkDom;
|
||||
};
|
||||
|
||||
mindplot.XMLMindmapSerializer_Pela.prototype._noteToXML = function(document, note)
|
||||
{
|
||||
var noteDom = document.createElement("note");
|
||||
noteDom.setAttribute('text', note.getText());
|
||||
return noteDom;
|
||||
};
|
||||
|
||||
mindplot.XMLMindmapSerializer_Pela.prototype._relationshipToXML = function(document,relationship){
|
||||
var relationDom = document.createElement("relationship");
|
||||
relationDom.setAttribute("srcTopicId",relationship.getFromNode());
|
||||
relationDom.setAttribute("destTopicId",relationship.getToNode());
|
||||
var lineType = relationship.getLineType();
|
||||
relationDom.setAttribute("lineType",lineType);
|
||||
if(lineType==mindplot.ConnectionLine.CURVED || lineType==mindplot.ConnectionLine.SIMPLE_CURVED){
|
||||
if(core.Utils.isDefined(relationship.getSrcCtrlPoint())){
|
||||
var srcPoint = relationship.getSrcCtrlPoint();
|
||||
relationDom.setAttribute("srcCtrlPoint",srcPoint.x+","+srcPoint.y);
|
||||
}
|
||||
if(core.Utils.isDefined(relationship.getDestCtrlPoint())){
|
||||
var destPoint = relationship.getDestCtrlPoint();
|
||||
relationDom.setAttribute("destCtrlPoint",destPoint.x+","+destPoint.y);
|
||||
}
|
||||
}
|
||||
relationDom.setAttribute("endArrow",relationship.getEndArrow());
|
||||
return relationDom;
|
||||
};
|
||||
|
||||
mindplot.XMLMindmapSerializer_Pela.prototype.loadFromDom = function(dom)
|
||||
{
|
||||
core.assert(dom, "Dom can not be null");
|
||||
var rootElem = dom.documentElement;
|
||||
|
||||
// Is a wisemap?.
|
||||
core.assert(rootElem.tagName == mindplot.XMLMindmapSerializer_Pela.MAP_ROOT_NODE, "This seem not to be a map document.");
|
||||
|
||||
// Start the loading process ...
|
||||
var mindmap = new mindplot.Mindmap();
|
||||
|
||||
var version = rootElem.getAttribute("version");
|
||||
mindmap.setVersion(version);
|
||||
|
||||
var children = rootElem.childNodes;
|
||||
for (var i = 0; i < children.length; i++)
|
||||
{
|
||||
var child = children[i];
|
||||
if (child.nodeType == 1)
|
||||
{
|
||||
switch(child.tagName){
|
||||
case "topic":
|
||||
var topic = this._deserializeNode(child, mindmap);
|
||||
mindmap.addBranch(topic);
|
||||
break;
|
||||
case "relationship":
|
||||
var relationship = this._deserializeRelationship(child,mindmap);
|
||||
mindmap.addRelationship(relationship);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return mindmap;
|
||||
};
|
||||
|
||||
mindplot.XMLMindmapSerializer_Pela.prototype._deserializeNode = function(domElem, mindmap)
|
||||
{
|
||||
var type = (domElem.getAttribute('central') != null) ? mindplot.NodeModel.CENTRAL_TOPIC_TYPE : mindplot.NodeModel.MAIN_TOPIC_TYPE;
|
||||
var topic = mindmap.createNode(type);
|
||||
|
||||
// Load attributes...
|
||||
var id = domElem.getAttribute('id');
|
||||
if(id) {
|
||||
topic.setId(id);
|
||||
}
|
||||
|
||||
var text = domElem.getAttribute('text');
|
||||
if (text) {
|
||||
topic.setText(text);
|
||||
}
|
||||
|
||||
var order = domElem.getAttribute('order');
|
||||
if (order) {
|
||||
topic.setOrder(order);
|
||||
}
|
||||
|
||||
var shape = domElem.getAttribute('shape');
|
||||
if (shape) {
|
||||
topic.setShapeType(shape);
|
||||
}
|
||||
|
||||
var isShrink = domElem.getAttribute('shrink');
|
||||
if(isShrink)
|
||||
{
|
||||
topic.setChildrenShrinked(isShrink);
|
||||
}
|
||||
|
||||
var fontStyle = domElem.getAttribute('fontStyle');
|
||||
if (fontStyle) {
|
||||
var font = fontStyle.split(';');
|
||||
|
||||
if (font[0])
|
||||
{
|
||||
topic.setFontFamily(font[0]);
|
||||
}
|
||||
|
||||
if (font[1])
|
||||
{
|
||||
topic.setFontSize(font[1]);
|
||||
}
|
||||
|
||||
if (font[2])
|
||||
{
|
||||
topic.setFontColor(font[2]);
|
||||
}
|
||||
|
||||
if (font[3])
|
||||
{
|
||||
topic.setFontWeight(font[3]);
|
||||
}
|
||||
|
||||
if (font[4])
|
||||
{
|
||||
topic.setFontStyle(font[4]);
|
||||
}
|
||||
}
|
||||
|
||||
var bgColor = domElem.getAttribute('bgColor');
|
||||
if (bgColor) {
|
||||
topic.setBackgroundColor(bgColor);
|
||||
}
|
||||
|
||||
var borderColor = domElem.getAttribute('brColor');
|
||||
if (borderColor) {
|
||||
topic.setBorderColor(borderColor);
|
||||
}
|
||||
|
||||
var position = domElem.getAttribute('position');
|
||||
if (position) {
|
||||
var pos = position.split(',');
|
||||
topic.setPosition(pos[0], pos[1]);
|
||||
}
|
||||
|
||||
//Creating icons and children nodes
|
||||
var children = domElem.childNodes;
|
||||
for (var i = 0; i < children.length; i++)
|
||||
{
|
||||
var child = children[i];
|
||||
if (child.nodeType == 1)
|
||||
{
|
||||
core.assert(child.tagName == "topic" || child.tagName == "icon" || child.tagName == "link" || child.tagName == "note", 'Illegal node type:' + child.tagName);
|
||||
if (child.tagName == "topic") {
|
||||
var childTopic = this._deserializeNode(child, mindmap);
|
||||
childTopic.connectTo(topic);
|
||||
} else if(child.tagName == "icon") {
|
||||
var icon = this._deserializeIcon(child, topic);
|
||||
topic.addIcon(icon);
|
||||
} else if(child.tagName == "link") {
|
||||
var link = this._deserializeLink(child, topic);
|
||||
topic.addLink(link);
|
||||
} else if(child.tagName == "note") {
|
||||
var note = this._deserializeNote(child, topic);
|
||||
topic.addNote(note);
|
||||
}
|
||||
}
|
||||
}
|
||||
;
|
||||
return topic;
|
||||
};
|
||||
|
||||
mindplot.XMLMindmapSerializer_Pela.prototype._deserializeIcon = function(domElem, topic)
|
||||
{
|
||||
return topic.createIcon(domElem.getAttribute("id"));
|
||||
};
|
||||
|
||||
mindplot.XMLMindmapSerializer_Pela.prototype._deserializeLink = function(domElem, topic)
|
||||
{
|
||||
return topic.createLink(domElem.getAttribute("url"));
|
||||
};
|
||||
|
||||
mindplot.XMLMindmapSerializer_Pela.prototype._deserializeNote = function(domElem, topic)
|
||||
{
|
||||
return topic.createNote(domElem.getAttribute("text"));
|
||||
};
|
||||
|
||||
mindplot.XMLMindmapSerializer_Pela.prototype._deserializeRelationship = function(domElement, mindmap)
|
||||
{
|
||||
var srcId = domElement.getAttribute("srcTopicId");
|
||||
var destId = domElement.getAttribute("destTopicId");
|
||||
var lineType = domElement.getAttribute("lineType");
|
||||
var srcCtrlPoint = domElement.getAttribute("srcCtrlPoint");
|
||||
var destCtrlPoint = domElement.getAttribute("destCtrlPoint");
|
||||
var endArrow = domElement.getAttribute("endArrow");
|
||||
var model = mindmap.createRelationship(srcId, destId);
|
||||
model.setLineType(lineType);
|
||||
if(core.Utils.isDefined(srcCtrlPoint) && srcCtrlPoint!=""){
|
||||
model.setSrcCtrlPoint(core.Point.fromString(srcCtrlPoint));
|
||||
}
|
||||
if(core.Utils.isDefined(destCtrlPoint) && destCtrlPoint!=""){
|
||||
model.setDestCtrlPoint(core.Point.fromString(destCtrlPoint));
|
||||
}
|
||||
model.setEndArrow(endArrow);
|
||||
return model;
|
||||
};
|
||||
|
||||
mindplot.XMLMindmapSerializer_Pela.MAP_ROOT_NODE = 'map';
|
@@ -0,0 +1,19 @@
|
||||
mindplot.commands.AddRelationshipCommand = mindplot.Command.extend(
|
||||
{
|
||||
initialize: function(model, mindmap)
|
||||
{
|
||||
core.assert(model, 'Relationship model can not be null');
|
||||
this._model = model;
|
||||
this._mindmap = mindmap;
|
||||
this._id = mindplot.Command._nextUUID();
|
||||
},
|
||||
execute: function(commandContext)
|
||||
{
|
||||
var relationship = commandContext.createRelationship(this._model);
|
||||
},
|
||||
undoExecute: function(commandContext)
|
||||
{
|
||||
var relationship = commandContext.removeRelationship(this._model);
|
||||
this._mindmap.removeRelationship(this._model);
|
||||
}
|
||||
});
|
@@ -25,6 +25,7 @@ mindplot.commands.DeleteTopicCommand = mindplot.Command.extend(
|
||||
this._topicId = topicsIds;
|
||||
this._deletedTopicModels = [];
|
||||
this._parentTopicIds = [];
|
||||
this._deletedRelationships = [];
|
||||
this._id = mindplot.Command._nextUUID();
|
||||
},
|
||||
execute: function(commandContext)
|
||||
@@ -34,6 +35,15 @@ mindplot.commands.DeleteTopicCommand = mindplot.Command.extend(
|
||||
function(topic, index)
|
||||
{
|
||||
var model = topic.getModel().clone();
|
||||
|
||||
//delete relationships
|
||||
var relationships = topic.getRelationships();
|
||||
while(relationships.length>0){
|
||||
var relationship = relationships[0];
|
||||
this._deletedRelationships.push(relationship.getModel().clone());
|
||||
commandContext.removeRelationship(relationship.getModel());
|
||||
}
|
||||
|
||||
this._deletedTopicModels.push(model);
|
||||
|
||||
// Is connected?.
|
||||
@@ -49,7 +59,7 @@ mindplot.commands.DeleteTopicCommand = mindplot.Command.extend(
|
||||
commandContext.deleteTopic(topic);
|
||||
|
||||
}.bind(this)
|
||||
)
|
||||
);
|
||||
},
|
||||
undoExecute: function(commandContext)
|
||||
{
|
||||
@@ -70,9 +80,14 @@ mindplot.commands.DeleteTopicCommand = mindplot.Command.extend(
|
||||
}
|
||||
|
||||
}.bind(this)
|
||||
)
|
||||
);
|
||||
this._deletedRelationships.forEach(
|
||||
function(relationship, index){
|
||||
commandContext.createRelationship(relationship);
|
||||
}.bind(this));
|
||||
|
||||
this._deletedTopicModels = [];
|
||||
this._parentTopicIds = [];
|
||||
this._deletedRelationships = [];
|
||||
}
|
||||
});
|
@@ -0,0 +1,59 @@
|
||||
mindplot.commands.MoveControlPointCommand = mindplot.Command.extend(
|
||||
{
|
||||
initialize: function(ctrlPointControler, point)
|
||||
{
|
||||
core.assert(ctrlPointControler, 'line can not be null');
|
||||
this._ctrlPointControler = ctrlPointControler;
|
||||
this._id = mindplot.Command._nextUUID();
|
||||
this._wasCustom=false;
|
||||
this._point = point;
|
||||
this._controlPoint = null;
|
||||
},
|
||||
execute: function(commandContext)
|
||||
{
|
||||
var line = this._ctrlPointControler._line;
|
||||
var ctrlPoints = line.getLine().getControlPoints();
|
||||
var model = line.getModel();
|
||||
var point = null;
|
||||
switch (this._point){
|
||||
case 0:
|
||||
if(core.Utils.isDefined(model.getSrcCtrlPoint())){
|
||||
this._controlPoint= model.getSrcCtrlPoint().clone();
|
||||
}
|
||||
model.setSrcCtrlPoint(ctrlPoints[0].clone());
|
||||
this._wasCustom = line.getLine().isSrcControlPointCustom();
|
||||
line.getLine().setIsSrcControlPointCustom(true);
|
||||
break;
|
||||
case 1:
|
||||
if(core.Utils.isDefined(model.getDestCtrlPoint())){
|
||||
this._controlPoint = model.getDestCtrlPoint().clone();
|
||||
}
|
||||
model.setDestCtrlPoint(ctrlPoints[1].clone());
|
||||
this._wasCustom = line.getLine().isDestControlPointCustom();
|
||||
line.getLine().setIsDestControlPointCustom(true);
|
||||
break;
|
||||
}
|
||||
},
|
||||
undoExecute: function(commandContext)
|
||||
{
|
||||
var line = this._ctrlPointControler._line;
|
||||
var model = line.getModel();
|
||||
switch (this._point){
|
||||
case 0:
|
||||
if(core.Utils.isDefined(this._controlPoint)){
|
||||
model.setSrcCtrlPoint(this._controlPoint.clone());
|
||||
line.getLine().setSrcControlPoint(this._controlPoint.clone());
|
||||
line.getLine().setIsSrcControlPointCustom(this._wasCustom);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if(core.Utils.isDefined(this._controlPoint)){
|
||||
model.setDestCtrlPoint(this._controlPoint.clone());
|
||||
line.getLine().setDestControlPoint(this._controlPoint.clone());
|
||||
line.getLine().setIsDestControlPointCustom(this._wasCustom);
|
||||
}
|
||||
break;
|
||||
}
|
||||
this._ctrlPointControler.setLine(line);
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user