mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 14:17:57 +01:00
Adding model update, model migrator, curved line support, relationship lines, remove of web-services classes
This commit is contained in:
parent
28aba40f6f
commit
67c4968aca
@ -1,51 +0,0 @@
|
|||||||
# WiseMapping: a Web based mindmapping application
|
|
||||||
|
|
||||||
## Project Information
|
|
||||||
|
|
||||||
The goal of this project is to provide a high quality product that can be deployed by educational and academic institutions, private and public companies and anyone who needs to have a mindmapping application. WiseMapping is based on the same code source supporting WiseMapping.com.
|
|
||||||
|
|
||||||
## Compiling and Running
|
|
||||||
|
|
||||||
### Prerequisites
|
|
||||||
|
|
||||||
The following products must be installed:
|
|
||||||
|
|
||||||
* Java Development Kit 6 or higher (http://java.sun.com/javase/downloads/index.jsp)
|
|
||||||
* Maven 2.2.1 or higher (http://maven.apache.org/)
|
|
||||||
|
|
||||||
### Compiling
|
|
||||||
|
|
||||||
WiseMapping uses Maven as packaging and project management. The project is composed of 4 maven sub-modules:
|
|
||||||
|
|
||||||
* core-js: Utilities JavaScript libraries
|
|
||||||
* web2d: JavaScript 2D VML/SVG abstraction library used by the mind map editor
|
|
||||||
* mindplot: JavaScript mind map designer core
|
|
||||||
* wise-webapp: J2EE web application
|
|
||||||
|
|
||||||
Full compilation of the project can be done executing within <project-dir>:
|
|
||||||
|
|
||||||
`mvn install`
|
|
||||||
|
|
||||||
Once this command is execute, the file <project-dir>/wise-webapp/target/wisemapping.war will be generated.
|
|
||||||
|
|
||||||
### Testing
|
|
||||||
The previously generated war can be deployed locally executing within the directory <project-dir>/wise-webapp the following command:
|
|
||||||
|
|
||||||
`mvn jetty:run-war`
|
|
||||||
|
|
||||||
This will start the application on the URL: http://localhost:8080/wise-webapp/. Additionally, a file based database is automatically populated with a test user.
|
|
||||||
|
|
||||||
User: test@wisemapping.org
|
|
||||||
Password: test
|
|
||||||
|
|
||||||
## Author
|
|
||||||
|
|
||||||
Pablo Luna
|
|
||||||
Paulo Veiga
|
|
||||||
Ignacio Manzano
|
|
||||||
Nicolas Damonte
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
The source code is Licensed under the Apache License, Version 2.0 (the “License”);
|
|
||||||
You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
|
|
51
README.md
51
README.md
@ -1,51 +0,0 @@
|
|||||||
# WiseMapping: a Web based mindmapping application
|
|
||||||
|
|
||||||
## Project Information
|
|
||||||
|
|
||||||
The goal of this project is to provide a high quality product that can be deployed by educational and academic institutions, private and public companies and anyone who needs to have a mindmapping application. WiseMapping is based on the same code source supporting WiseMapping.com.
|
|
||||||
|
|
||||||
## Compiling and Running
|
|
||||||
|
|
||||||
### Prerequisites
|
|
||||||
|
|
||||||
The following products must be installed:
|
|
||||||
|
|
||||||
* Java Development Kit 6 or higher (http://java.sun.com/javase/downloads/index.jsp)
|
|
||||||
* Maven 2.2.1 or higher (http://maven.apache.org/)
|
|
||||||
|
|
||||||
### Compiling
|
|
||||||
|
|
||||||
WiseMapping uses Maven as packaging and project management. The project is composed of 4 maven sub-modules:
|
|
||||||
|
|
||||||
* core-js: Utilities JavaScript libraries
|
|
||||||
* web2d: JavaScript 2D VML/SVG abstraction library used by the mind map editor
|
|
||||||
* mindplot: JavaScript mind map designer core
|
|
||||||
* wise-webapp: J2EE web application
|
|
||||||
|
|
||||||
Full compilation of the project can be done executing within <project-dir>:
|
|
||||||
|
|
||||||
`mvn install`
|
|
||||||
|
|
||||||
Once this command is execute, the file <project-dir>/wise-webapp/target/wisemapping.war will be generated.
|
|
||||||
|
|
||||||
### Testing
|
|
||||||
The previously generated war can be deployed locally executing within the directory <project-dir>/wise-webapp the following command:
|
|
||||||
|
|
||||||
`mvn jetty:run-war`
|
|
||||||
|
|
||||||
This will start the application on the URL: http://localhost:8080/wise-webapp/. Additionally, a file based database is automatically populated with a test user.
|
|
||||||
|
|
||||||
User: test@wisemapping.org
|
|
||||||
Password: test
|
|
||||||
|
|
||||||
## Author
|
|
||||||
|
|
||||||
* Pablo Luna
|
|
||||||
* Paulo Veiga
|
|
||||||
* Ignacio Manzano
|
|
||||||
* Nicolas Damonte
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
The source code is Licensed under the Apache License, Version 2.0 (the “License”);
|
|
||||||
You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
|
|
@ -38,3 +38,8 @@ core.Point.prototype.clone = function()
|
|||||||
{
|
{
|
||||||
return new core.Point(this.x, this.y);
|
return new core.Point(this.x, this.y);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
core.Point.fromString = function(point) {
|
||||||
|
var values = point.split(',');
|
||||||
|
return new core.Point(values[0], values[1]);
|
||||||
|
};
|
||||||
|
@ -64,7 +64,8 @@ core.assert = function(assert, message)
|
|||||||
{
|
{
|
||||||
stack = e;
|
stack = e;
|
||||||
}
|
}
|
||||||
core.Logger.logError(message + "," + stack);
|
wLogger.error(message + "," + stack);
|
||||||
|
// core.Logger.logError(message + "," + stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -220,3 +221,54 @@ core.Utils.createDocumentFromText = function(/*string*/str, /*string?*/mimetype)
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
core.Utils.calculateRelationShipPointCoordinates = function(topic,controlPoint){
|
||||||
|
var size = topic.getSize();
|
||||||
|
var position = topic.getPosition();
|
||||||
|
var m = (position.y-controlPoint.y)/(position.x-controlPoint.x);
|
||||||
|
var y,x;
|
||||||
|
var gap = 5;
|
||||||
|
if(controlPoint.y>position.y+(size.height/2)){
|
||||||
|
y = position.y+(size.height/2)+gap;
|
||||||
|
x = position.x-((position.y-y)/m);
|
||||||
|
if(x>position.x+(size.width/2)){
|
||||||
|
x=position.x+(size.width/2);
|
||||||
|
}else if(x<position.x-(size.width/2)){
|
||||||
|
x=position.x-(size.width/2);
|
||||||
|
}
|
||||||
|
}else if(controlPoint.y<position.y-(size.height/2)){
|
||||||
|
y = position.y-(size.height/2) - gap;
|
||||||
|
x = position.x-((position.y-y)/m);
|
||||||
|
if(x>position.x+(size.width/2)){
|
||||||
|
x=position.x+(size.width/2);
|
||||||
|
}else if(x<position.x-(size.width/2)){
|
||||||
|
x=position.x-(size.width/2);
|
||||||
|
}
|
||||||
|
}else if(controlPoint.x<(position.x-size.width/2)){
|
||||||
|
x = position.x-(size.width/2) -gap;
|
||||||
|
y = position.y-(m*(position.x-x));
|
||||||
|
}else{
|
||||||
|
x = position.x+(size.width/2) + gap;
|
||||||
|
y = position.y-(m*(position.x-x));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new core.Point(x,y);
|
||||||
|
};
|
||||||
|
|
||||||
|
core.Utils.calculateDefaultControlPoints = function(srcPos, tarPos){
|
||||||
|
var y = srcPos.y-tarPos.y;
|
||||||
|
var x = srcPos.x-tarPos.x;
|
||||||
|
var m = y/x;
|
||||||
|
var l = Math.sqrt(y*y+x*x)/3;
|
||||||
|
var fix=1;
|
||||||
|
if(srcPos.x>tarPos.x){
|
||||||
|
fix=-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
var x1 = srcPos.x + Math.sqrt(l*l/(1+(m*m)))*fix;
|
||||||
|
var y1 = m*(x1-srcPos.x)+srcPos.y;
|
||||||
|
var x2 = tarPos.x + Math.sqrt(l*l/(1+(m*m)))*fix*-1;
|
||||||
|
var y2= m*(x2-tarPos.x)+tarPos.y;
|
||||||
|
|
||||||
|
return [new core.Point(x1,y1),new core.Point(x2,y2)];
|
||||||
|
};
|
@ -40,6 +40,7 @@
|
|||||||
<filelist dir="${basedir}/src/main/javascript/" files="header.js"/>
|
<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="Mindmap.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="NodeModel.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="MindmapDesigner.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="ScreenManager.js"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="ScreenManager.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="Workspace.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="util/Shape.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="FixedDistanceBoard.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="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="PersistanceManager.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="EditorProperties.js"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="EditorProperties.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="IconGroup.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="IconModel.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="LinkModel.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="NoteModel.js"/>
|
||||||
|
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="Command.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="DesignerActionRunner.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="DesignerUndoManager.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/"
|
<filelist dir="${basedir}/src/main/javascript/"
|
||||||
files="commands/GenericFunctionCommand.js"/>
|
files="commands/GenericFunctionCommand.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/"
|
<filelist dir="${basedir}/src/main/javascript/"
|
||||||
@ -100,7 +104,10 @@
|
|||||||
files="commands/AddNoteToTopicCommand.js"/>
|
files="commands/AddNoteToTopicCommand.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/"
|
<filelist dir="${basedir}/src/main/javascript/"
|
||||||
files="commands/RemoveNoteFromTopicCommand.js"/>
|
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"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="footer.js"/>
|
||||||
</concat>
|
</concat>
|
||||||
|
|
||||||
@ -144,6 +151,7 @@
|
|||||||
<include>header-min.js</include>
|
<include>header-min.js</include>
|
||||||
<include>Mindmap-min.js</include>
|
<include>Mindmap-min.js</include>
|
||||||
<include>NodeModel-min.js</include>
|
<include>NodeModel-min.js</include>
|
||||||
|
<include>RelationshipModel-min.js</include>
|
||||||
<include>MindmapDesigner-min.js</include>
|
<include>MindmapDesigner-min.js</include>
|
||||||
<include>ScreenManager-min.js</include>
|
<include>ScreenManager-min.js</include>
|
||||||
<include>Workspace-min.js</include>
|
<include>Workspace-min.js</include>
|
||||||
@ -166,7 +174,11 @@
|
|||||||
<include>util/Shape-min.js</include>
|
<include>util/Shape-min.js</include>
|
||||||
<include>FixedDistanceBoard-min.js</include>
|
<include>FixedDistanceBoard-min.js</include>
|
||||||
<include>BoardEntry-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>PersistanceManager-min.js</include>
|
||||||
<include>EditorProperties-min.js</include>
|
<include>EditorProperties-min.js</include>
|
||||||
<include>IconGroup-min.js</include>
|
<include>IconGroup-min.js</include>
|
||||||
@ -194,6 +206,8 @@
|
|||||||
<include>commands/RemoveIconFromTopicCommand-min.js</include>
|
<include>commands/RemoveIconFromTopicCommand-min.js</include>
|
||||||
<include>commands/AddNoteToTopicCommand-min.js</include>
|
<include>commands/AddNoteToTopicCommand-min.js</include>
|
||||||
<include>commands/RemoveNoteFromTopicCommand-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>
|
<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;
|
||||||
|
};
|
@ -29,9 +29,29 @@ mindplot.CentralTopic = function(model)
|
|||||||
objects.extend(mindplot.CentralTopic, mindplot.Topic);
|
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()
|
mindplot.CentralTopic.prototype.getTopicType = function()
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
|
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mindplot.ConnectionLine = function(sourceNode, targetNode)
|
mindplot.ConnectionLine = function(sourceNode, targetNode, lineType)
|
||||||
{
|
{
|
||||||
core.assert(targetNode, 'parentNode node can not be null');
|
core.assert(targetNode, 'parentNode node can not be null');
|
||||||
core.assert(sourceNode, 'childNode 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._targetTopic = targetNode;
|
||||||
this._sourceTopic = sourceNode;
|
this._sourceTopic = sourceNode;
|
||||||
|
this._isRelationship=false;
|
||||||
|
|
||||||
var strokeColor = mindplot.ConnectionLine.getStrokeColor();
|
var strokeColor = mindplot.ConnectionLine.getStrokeColor();
|
||||||
var line;
|
var line;
|
||||||
if (targetNode.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE)
|
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);
|
line.setStroke(1, 'solid', strokeColor);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
line = new web2d.PolyLine();
|
line = this._createLine(lineType,mindplot.ConnectionLine.POLYLINE);
|
||||||
|
// line = new web2d.PolyLine();
|
||||||
line.setStroke(1, 'solid', strokeColor);
|
line.setStroke(1, 'solid', strokeColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._line2d = line;
|
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()
|
mindplot.ConnectionLine.getStrokeColor = function()
|
||||||
{
|
{
|
||||||
return '#495879';
|
return '#495879';
|
||||||
@ -61,11 +89,28 @@ mindplot.ConnectionLine.prototype.redraw = function()
|
|||||||
var targetTopic = this._targetTopic;
|
var targetTopic = this._targetTopic;
|
||||||
var targetPosition = targetTopic.getPosition();
|
var targetPosition = targetTopic.getPosition();
|
||||||
|
|
||||||
var sPos = sourceTopic.workoutOutgoingConnectionPoint(targetPosition);
|
var sPos,tPos;
|
||||||
line2d.setTo(sPos.x, sPos.y);
|
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(sPos.x, sPos.y);
|
||||||
line2d.setFrom(tPos.x, tPos.y);
|
// console.log("target:"+tPos.x+":"+tPos.y);
|
||||||
|
line2d.setTo(tPos.x, tPos.y);
|
||||||
|
|
||||||
line2d.moveToBack();
|
line2d.moveToBack();
|
||||||
|
|
||||||
@ -111,6 +156,14 @@ mindplot.ConnectionLine.prototype.setStroke = function(color, style, opacity)
|
|||||||
|
|
||||||
mindplot.ConnectionLine.prototype.addToWorkspace = function(workspace)
|
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);
|
workspace.appendChild(this._line2d);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -123,3 +176,37 @@ mindplot.ConnectionLine.prototype.getTargetTopic = function()
|
|||||||
{
|
{
|
||||||
return this._targetTopic;
|
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)
|
disconnect:function(topic)
|
||||||
{
|
{
|
||||||
topic.disconnect(this._designer._workspace);
|
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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -201,13 +201,18 @@ mindplot.MainTopic.prototype.setPosition = function(point)
|
|||||||
topicBoard.updateChildrenPosition(this);
|
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');
|
core.assert(sourcePosition, 'sourcePoint can not be null');
|
||||||
var pos = this.getPosition();
|
var pos = this.getPosition();
|
||||||
var size = this.getSize();
|
var size = this.getSize();
|
||||||
|
|
||||||
var isAtRight = mindplot.util.Shape.isAtRight(sourcePosition, pos);
|
var isAtRight = mindplot.util.Shape.isAtRight(sourcePosition, pos);
|
||||||
|
|
||||||
var result = mindplot.util.Shape.calculateRectConnectionPoint(pos, size, isAtRight);
|
var result = mindplot.util.Shape.calculateRectConnectionPoint(pos, size, isAtRight);
|
||||||
if (this.getShapeType() == mindplot.NodeModel.SHAPE_TYPE_LINE)
|
if (this.getShapeType() == mindplot.NodeModel.SHAPE_TYPE_LINE)
|
||||||
{
|
{
|
||||||
@ -223,55 +228,17 @@ mindplot.MainTopic.prototype.workoutIncomingConnectionPoint = function(sourcePos
|
|||||||
{
|
{
|
||||||
result.x = result.x - offset;
|
result.x = result.x - offset;
|
||||||
}
|
}
|
||||||
|
if(onBoundingBox){
|
||||||
|
if(isAtRight){
|
||||||
|
result.x -= 10;
|
||||||
|
} else{
|
||||||
|
result.x += 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
return result;
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
result = mindplot.util.Shape.calculateRectConnectionPoint(pos, size, isAtRight, true);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
mindplot.MainTopic.prototype.isConnectedToCentralTopic = function()
|
mindplot.MainTopic.prototype.isConnectedToCentralTopic = function()
|
||||||
{
|
{
|
||||||
var model = this.getModel();
|
var model = this.getModel();
|
||||||
|
@ -22,6 +22,8 @@ mindplot.Mindmap = function()
|
|||||||
this._branches = [];
|
this._branches = [];
|
||||||
this._name = null;
|
this._name = null;
|
||||||
this._description = null;
|
this._description = null;
|
||||||
|
this._version=null;
|
||||||
|
this._relationships=[];
|
||||||
};
|
};
|
||||||
|
|
||||||
mindplot.Mindmap.prototype.getCentralTopic = function()
|
mindplot.Mindmap.prototype.getCentralTopic = function()
|
||||||
@ -45,6 +47,20 @@ mindplot.Mindmap.prototype.setId = function(id)
|
|||||||
this._iconType = 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)
|
mindplot.Mindmap.prototype.addBranch = function(nodeModel)
|
||||||
{
|
{
|
||||||
core.assert(nodeModel && nodeModel.isNodeModel(), 'Add node must be invoked with model objects');
|
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;
|
return this._branches;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mindplot.Mindmap.prototype.getRelationships = function() {
|
||||||
|
return this._relationships;
|
||||||
|
};
|
||||||
|
|
||||||
mindplot.Mindmap.prototype.connect = function(parent, child)
|
mindplot.Mindmap.prototype.connect = function(parent, child)
|
||||||
{
|
{
|
||||||
// Child already has a parent ?
|
// Child already has a parent ?
|
||||||
@ -120,6 +140,21 @@ mindplot.Mindmap.prototype._createNode = function(type)
|
|||||||
return result;
|
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()
|
mindplot.Mindmap.prototype.inspect = function()
|
||||||
{
|
{
|
||||||
var result = '';
|
var result = '';
|
||||||
|
@ -17,9 +17,8 @@
|
|||||||
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
|
* $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");
|
core.assert(core.Utils.isDefined(profile.zoom), "zoom must be defined");
|
||||||
|
|
||||||
// Undo manager ...
|
// Undo manager ...
|
||||||
@ -53,11 +52,11 @@ mindplot.MindmapDesigner = function(profile, divElement, persistanManager)
|
|||||||
// Init dragger manager.
|
// Init dragger manager.
|
||||||
this._dragger = this._buildDragManager(workspace);
|
this._dragger = this._buildDragManager(workspace);
|
||||||
|
|
||||||
this._persistantManager = persistanManager;
|
|
||||||
|
|
||||||
// Add shapes to speed up the loading process ...
|
// Add shapes to speed up the loading process ...
|
||||||
mindplot.DragTopic.initialize(workspace);
|
mindplot.DragTopic.initialize(workspace);
|
||||||
|
|
||||||
|
this._relationships={};
|
||||||
|
|
||||||
this._events = {};
|
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()
|
mindplot.MindmapDesigner.prototype.needsSave = function()
|
||||||
{
|
{
|
||||||
return this._actionRunner.hasBeenChanged();
|
return this._actionRunner.hasBeenChanged();
|
||||||
@ -390,7 +445,7 @@ mindplot.MindmapDesigner.prototype.autoSaveEnabled = function(value)
|
|||||||
|
|
||||||
mindplot.MindmapDesigner.prototype.save = function(onSavedHandler, saveHistory)
|
mindplot.MindmapDesigner.prototype.save = function(onSavedHandler, saveHistory)
|
||||||
{
|
{
|
||||||
var persistantManager = this._persistantManager;
|
var persistantManager = mindplot.PersistanceManager;
|
||||||
var mindmap = this._mindmap;
|
var mindmap = this._mindmap;
|
||||||
|
|
||||||
var xmlChart = this._workspace.dumpNativeChart();
|
var xmlChart = this._workspace.dumpNativeChart();
|
||||||
@ -417,7 +472,7 @@ mindplot.MindmapDesigner.prototype.loadFromXML = function(mapId, xmlContent)
|
|||||||
// Explorer Hack with local files ...
|
// Explorer Hack with local files ...
|
||||||
var domDocument = core.Utils.createDocumentFromText(xmlContent);
|
var domDocument = core.Utils.createDocumentFromText(xmlContent);
|
||||||
|
|
||||||
var serializer = new mindplot.XMLMindmapSerializer();
|
var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromDocument(domDocument);
|
||||||
var mindmap = serializer.loadFromDom(domDocument);
|
var mindmap = serializer.loadFromDom(domDocument);
|
||||||
|
|
||||||
this._loadMap(mapId, mindmap);
|
this._loadMap(mapId, mindmap);
|
||||||
@ -435,7 +490,7 @@ mindplot.MindmapDesigner.prototype.load = function(mapId)
|
|||||||
core.assert(mapId, 'mapName can not be null');
|
core.assert(mapId, 'mapName can not be null');
|
||||||
|
|
||||||
// Build load function ...
|
// Build load function ...
|
||||||
var persistantManager = this._persistantManager;
|
var persistantManager = mindplot.PersistanceManager;
|
||||||
|
|
||||||
// Loading mindmap ...
|
// Loading mindmap ...
|
||||||
var mindmap = persistantManager.load(mapId);
|
var mindmap = persistantManager.load(mapId);
|
||||||
@ -469,6 +524,10 @@ mindplot.MindmapDesigner.prototype._loadMap = function(mapId, mindmapModel)
|
|||||||
// Update shrink render state...
|
// Update shrink render state...
|
||||||
nodeGraph.setBranchVisibility(true);
|
nodeGraph.setBranchVisibility(true);
|
||||||
}
|
}
|
||||||
|
var relationships = mindmapModel.getRelationships();
|
||||||
|
for (var j=0; j<relationships.length; j++) {
|
||||||
|
var relationship = this._relationshipModelToRelationship(relationships[j]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this._fireEvent("loadsuccess");
|
this._fireEvent("loadsuccess");
|
||||||
|
|
||||||
@ -527,6 +586,86 @@ mindplot.MindmapDesigner.prototype._nodeModelToNodeGraph = function(nodeModel)
|
|||||||
return nodeGraph;
|
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()
|
mindplot.MindmapDesigner.prototype.getEditor = function()
|
||||||
{
|
{
|
||||||
return this._editor;
|
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";
|
@ -17,13 +17,9 @@
|
|||||||
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
|
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mindplot.PersistanceManager = function(editorService)
|
mindplot.PersistanceManager = {};
|
||||||
{
|
|
||||||
this._editorService = editorService;
|
|
||||||
this._serializer = new mindplot.XMLMindmapSerializer();
|
|
||||||
};
|
|
||||||
|
|
||||||
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(mindmap, "mindmap can not be null");
|
||||||
core.assert(chartType, "chartType 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 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 xmlMapStr = core.Utils.innerXML(xmlMap);
|
||||||
|
|
||||||
var pref = Json.toString(editorProperties);
|
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) {
|
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");
|
core.assert(mapId, "mapId can not be null");
|
||||||
|
|
||||||
var deserializer = this;
|
|
||||||
var result = {r:null};
|
var result = {r:null};
|
||||||
var serializer = this._serializer;
|
window.MapEditorService.loadMap(mapId, {
|
||||||
this._editorService.loadMap(mapId, {
|
|
||||||
callback:function(response) {
|
callback:function(response) {
|
||||||
|
|
||||||
if (response.msgCode == "OK")
|
if (response.msgCode == "OK")
|
||||||
@ -79,6 +74,7 @@ mindplot.PersistanceManager.prototype.load = function(mapId)
|
|||||||
// Explorer Hack with local files ...
|
// Explorer Hack with local files ...
|
||||||
var xmlContent = response.content;
|
var xmlContent = response.content;
|
||||||
var domDocument = core.Utils.createDocumentFromText(xmlContent);
|
var domDocument = core.Utils.createDocumentFromText(xmlContent);
|
||||||
|
var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromDocument(domDocument);
|
||||||
var mindmap = serializer.loadFromDom(domDocument);
|
var mindmap = serializer.loadFromDom(domDocument);
|
||||||
mindmap.setId(mapId);
|
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() + ')';
|
||||||
|
};
|
@ -31,6 +31,8 @@ mindplot.Topic.prototype.initialize = function(topicBoard)
|
|||||||
this._children = [];
|
this._children = [];
|
||||||
this._parent = null;
|
this._parent = null;
|
||||||
this._lastIconId = -1;
|
this._lastIconId = -1;
|
||||||
|
this._relationships = [];
|
||||||
|
this._isInWorkspace = false;
|
||||||
|
|
||||||
this._topicBoard = topicBoard;
|
this._topicBoard = topicBoard;
|
||||||
this._buildShape();
|
this._buildShape();
|
||||||
@ -419,6 +421,18 @@ mindplot.Topic.prototype.removeNote = function(){
|
|||||||
this._hasNote=false;
|
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)
|
mindplot.Topic.prototype._buildTextShape = function(disableEventsListeners)
|
||||||
{
|
{
|
||||||
var result = new web2d.Text();
|
var result = new web2d.Text();
|
||||||
@ -741,6 +755,7 @@ mindplot.Topic.prototype._buildShape = function()
|
|||||||
{
|
{
|
||||||
var groupAttributes = {width: 100, height:100,coordSizeWidth:100,coordSizeHeight:100};
|
var groupAttributes = {width: 100, height:100,coordSizeWidth:100,coordSizeHeight:100};
|
||||||
var group = new web2d.Group(groupAttributes);
|
var group = new web2d.Group(groupAttributes);
|
||||||
|
group._peer._native.virtualRef=this;
|
||||||
this._set2DElement(group);
|
this._set2DElement(group);
|
||||||
|
|
||||||
// Shape must be build based on the model width ...
|
// Shape must be build based on the model width ...
|
||||||
@ -949,6 +964,11 @@ mindplot.Topic.prototype._updateConnectionLines = function()
|
|||||||
{
|
{
|
||||||
incomingLines[i].redraw();
|
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)
|
mindplot.Topic.prototype.setBranchVisibility = function(value)
|
||||||
@ -1222,12 +1242,18 @@ mindplot.Topic.prototype.removeFromWorkspace = function(workspace)
|
|||||||
{
|
{
|
||||||
workspace.removeChild(line);
|
workspace.removeChild(line);
|
||||||
}
|
}
|
||||||
|
this._isInWorkspace=false;
|
||||||
};
|
};
|
||||||
|
|
||||||
mindplot.Topic.prototype.addToWorkspace = function(workspace)
|
mindplot.Topic.prototype.addToWorkspace = function(workspace)
|
||||||
{
|
{
|
||||||
var elem = this.get2DElement();
|
var elem = this.get2DElement();
|
||||||
workspace.appendChild(elem);
|
workspace.appendChild(elem);
|
||||||
|
this._isInWorkspace=true;
|
||||||
|
};
|
||||||
|
|
||||||
|
mindplot.Topic.prototype.isInWorkspace = function(){
|
||||||
|
return this._isInWorkspace;
|
||||||
};
|
};
|
||||||
|
|
||||||
mindplot.Topic.prototype.getTopicBoard = function()
|
mindplot.Topic.prototype.getTopicBoard = function()
|
||||||
@ -1250,6 +1276,7 @@ mindplot.Topic.prototype.createDragNode = function()
|
|||||||
|
|
||||||
mindplot.Topic.prototype.updateNode = function()
|
mindplot.Topic.prototype.updateNode = function()
|
||||||
{
|
{
|
||||||
|
if(this.isInWorkspace()){
|
||||||
var textShape = this.getTextShape();
|
var textShape = this.getTextShape();
|
||||||
var sizeWidth = textShape.getWidth();
|
var sizeWidth = textShape.getWidth();
|
||||||
var sizeHeight = textShape.getHeight();
|
var sizeHeight = textShape.getHeight();
|
||||||
@ -1262,4 +1289,65 @@ mindplot.Topic.prototype.updateNode = function()
|
|||||||
// Positionate node ...
|
// Positionate node ...
|
||||||
textShape.setPosition(iconOffset+this._offset, this._offset / 2);
|
textShape.setPosition(iconOffset+this._offset, this._offset / 2);
|
||||||
textShape.setTextSize(sizeWidth, sizeHeight);
|
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 ...
|
// Register drag events ...
|
||||||
this._registerDragEvents();
|
this._registerDragEvents();
|
||||||
|
|
||||||
|
//Create CurvedLineControlPoints
|
||||||
|
this._createCuvedLineControlPoints();
|
||||||
|
|
||||||
this._eventsEnabled = true;
|
this._eventsEnabled = true;
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -234,3 +237,12 @@ mindplot.Workspace.prototype._registerDragEvents = function()
|
|||||||
screenManager.addEventListener('mousedown', mouseDownListener);
|
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 @@
|
|||||||
/*
|
mindplot.XMLMindmapSerializer_Beta = function()
|
||||||
* 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.prototype.toXML = function(mindmap)
|
mindplot.XMLMindmapSerializer_Beta.prototype.toXML = function(mindmap)
|
||||||
{
|
{
|
||||||
core.assert(mindmap, "Can not save a null mindmap");
|
core.assert(mindmap, "Can not save a null mindmap");
|
||||||
|
|
||||||
@ -49,7 +30,7 @@ mindplot.XMLMindmapSerializer.prototype.toXML = function(mindmap)
|
|||||||
return document;
|
return document;
|
||||||
};
|
};
|
||||||
|
|
||||||
mindplot.XMLMindmapSerializer.prototype._topicToXML = function(document, topic)
|
mindplot.XMLMindmapSerializer_Beta.prototype._topicToXML = function(document, topic)
|
||||||
{
|
{
|
||||||
var parentTopic = document.createElement("topic");
|
var parentTopic = document.createElement("topic");
|
||||||
|
|
||||||
@ -158,34 +139,34 @@ mindplot.XMLMindmapSerializer.prototype._topicToXML = function(document, topic)
|
|||||||
return parentTopic;
|
return parentTopic;
|
||||||
};
|
};
|
||||||
|
|
||||||
mindplot.XMLMindmapSerializer.prototype._iconToXML = function(document, icon)
|
mindplot.XMLMindmapSerializer_Beta.prototype._iconToXML = function(document, icon)
|
||||||
{
|
{
|
||||||
var iconDom = document.createElement("icon");
|
var iconDom = document.createElement("icon");
|
||||||
iconDom.setAttribute('id', icon.getIconType());
|
iconDom.setAttribute('id', icon.getIconType());
|
||||||
return iconDom;
|
return iconDom;
|
||||||
};
|
};
|
||||||
|
|
||||||
mindplot.XMLMindmapSerializer.prototype._linkToXML = function(document, link)
|
mindplot.XMLMindmapSerializer_Beta.prototype._linkToXML = function(document, link)
|
||||||
{
|
{
|
||||||
var linkDom = document.createElement("link");
|
var linkDom = document.createElement("link");
|
||||||
linkDom.setAttribute('url', link.getUrl());
|
linkDom.setAttribute('url', link.getUrl());
|
||||||
return linkDom;
|
return linkDom;
|
||||||
};
|
};
|
||||||
|
|
||||||
mindplot.XMLMindmapSerializer.prototype._noteToXML = function(document, note)
|
mindplot.XMLMindmapSerializer_Beta.prototype._noteToXML = function(document, note)
|
||||||
{
|
{
|
||||||
var noteDom = document.createElement("note");
|
var noteDom = document.createElement("note");
|
||||||
noteDom.setAttribute('text', note.getText());
|
noteDom.setAttribute('text', note.getText());
|
||||||
return noteDom;
|
return noteDom;
|
||||||
};
|
};
|
||||||
|
|
||||||
mindplot.XMLMindmapSerializer.prototype.loadFromDom = function(dom)
|
mindplot.XMLMindmapSerializer_Beta.prototype.loadFromDom = function(dom)
|
||||||
{
|
{
|
||||||
core.assert(dom, "Dom can not be null");
|
core.assert(dom, "Dom can not be null");
|
||||||
var rootElem = dom.documentElement;
|
var rootElem = dom.documentElement;
|
||||||
|
|
||||||
// Is a wisemap?.
|
// 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 ...
|
// Start the loading process ...
|
||||||
var mindmap = new mindplot.Mindmap();
|
var mindmap = new mindplot.Mindmap();
|
||||||
@ -203,7 +184,7 @@ mindplot.XMLMindmapSerializer.prototype.loadFromDom = function(dom)
|
|||||||
return mindmap;
|
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 type = (domElem.getAttribute('central') != null) ? mindplot.NodeModel.CENTRAL_TOPIC_TYPE : mindplot.NodeModel.MAIN_TOPIC_TYPE;
|
||||||
var topic = mindmap.createNode(type);
|
var topic = mindmap.createNode(type);
|
||||||
@ -303,19 +284,19 @@ mindplot.XMLMindmapSerializer.prototype._deserializeNode = function(domElem, min
|
|||||||
return topic;
|
return topic;
|
||||||
};
|
};
|
||||||
|
|
||||||
mindplot.XMLMindmapSerializer.prototype._deserializeIcon = function(domElem, topic)
|
mindplot.XMLMindmapSerializer_Beta.prototype._deserializeIcon = function(domElem, topic)
|
||||||
{
|
{
|
||||||
return topic.createIcon(domElem.getAttribute("id"));
|
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"));
|
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"));
|
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._topicId = topicsIds;
|
||||||
this._deletedTopicModels = [];
|
this._deletedTopicModels = [];
|
||||||
this._parentTopicIds = [];
|
this._parentTopicIds = [];
|
||||||
|
this._deletedRelationships = [];
|
||||||
this._id = mindplot.Command._nextUUID();
|
this._id = mindplot.Command._nextUUID();
|
||||||
},
|
},
|
||||||
execute: function(commandContext)
|
execute: function(commandContext)
|
||||||
@ -34,6 +35,15 @@ mindplot.commands.DeleteTopicCommand = mindplot.Command.extend(
|
|||||||
function(topic, index)
|
function(topic, index)
|
||||||
{
|
{
|
||||||
var model = topic.getModel().clone();
|
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);
|
this._deletedTopicModels.push(model);
|
||||||
|
|
||||||
// Is connected?.
|
// Is connected?.
|
||||||
@ -49,7 +59,7 @@ mindplot.commands.DeleteTopicCommand = mindplot.Command.extend(
|
|||||||
commandContext.deleteTopic(topic);
|
commandContext.deleteTopic(topic);
|
||||||
|
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
)
|
);
|
||||||
},
|
},
|
||||||
undoExecute: function(commandContext)
|
undoExecute: function(commandContext)
|
||||||
{
|
{
|
||||||
@ -70,9 +80,14 @@ mindplot.commands.DeleteTopicCommand = mindplot.Command.extend(
|
|||||||
}
|
}
|
||||||
|
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
)
|
);
|
||||||
|
this._deletedRelationships.forEach(
|
||||||
|
function(relationship, index){
|
||||||
|
commandContext.createRelationship(relationship);
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
this._deletedTopicModels = [];
|
this._deletedTopicModels = [];
|
||||||
this._parentTopicIds = [];
|
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);
|
||||||
|
}
|
||||||
|
});
|
@ -91,6 +91,7 @@
|
|||||||
<include>${basedir}/target/tmp/peer/svg/Font-min.js</include>
|
<include>${basedir}/target/tmp/peer/svg/Font-min.js</include>
|
||||||
<include>${basedir}/target/tmp/peer/svg/ArialFont-min.js</include>
|
<include>${basedir}/target/tmp/peer/svg/ArialFont-min.js</include>
|
||||||
<include>${basedir}/target/tmp/peer/svg/PolyLinePeer-min.js</include>
|
<include>${basedir}/target/tmp/peer/svg/PolyLinePeer-min.js</include>
|
||||||
|
<include>${basedir}/target/tmp/peer/svg/CurvedLinePeer-min.js</include>
|
||||||
<include>${basedir}/target/tmp/peer/svg/TextPeer-min.js</include>
|
<include>${basedir}/target/tmp/peer/svg/TextPeer-min.js</include>
|
||||||
<include>${basedir}/target/tmp/peer/svg/WorkspacePeer-min.js</include>
|
<include>${basedir}/target/tmp/peer/svg/WorkspacePeer-min.js</include>
|
||||||
<include>${basedir}/target/tmp/peer/svg/GroupPeer-min.js</include>
|
<include>${basedir}/target/tmp/peer/svg/GroupPeer-min.js</include>
|
||||||
@ -109,6 +110,7 @@
|
|||||||
<include>${basedir}/target/tmp/Image-min.js</include>
|
<include>${basedir}/target/tmp/Image-min.js</include>
|
||||||
<include>${basedir}/target/tmp/Line-min.js</include>
|
<include>${basedir}/target/tmp/Line-min.js</include>
|
||||||
<include>${basedir}/target/tmp/PolyLine-min.js</include>
|
<include>${basedir}/target/tmp/PolyLine-min.js</include>
|
||||||
|
<include>${basedir}/target/tmp/CurvedLine-min.js</include>
|
||||||
<include>${basedir}/target/tmp/Rect-min.js</include>
|
<include>${basedir}/target/tmp/Rect-min.js</include>
|
||||||
<include>${basedir}/target/tmp/Text-min.js</include>
|
<include>${basedir}/target/tmp/Text-min.js</include>
|
||||||
<include>${basedir}/target/tmp/Toolkit-min.js</include>
|
<include>${basedir}/target/tmp/Toolkit-min.js</include>
|
||||||
|
112
web2d/src/main/javascript/CurvedLine.js
Normal file
112
web2d/src/main/javascript/CurvedLine.js
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
/*
|
||||||
|
* 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 $
|
||||||
|
*/
|
||||||
|
|
||||||
|
web2d.CurvedLine = function(attributes)
|
||||||
|
{
|
||||||
|
var peer = web2d.peer.Toolkit.createCurvedLine();
|
||||||
|
var defaultAttributes = {strokeColor:'blue',strokeWidth:1,strokeStyle:'solid',strokeOpacity:1};
|
||||||
|
for (var key in attributes)
|
||||||
|
{
|
||||||
|
defaultAttributes[key] = attributes[key];
|
||||||
|
}
|
||||||
|
web2d.Element.call(this, peer, defaultAttributes);
|
||||||
|
};
|
||||||
|
objects.extend(web2d.CurvedLine, web2d.Element);
|
||||||
|
|
||||||
|
web2d.CurvedLine.prototype.getType = function()
|
||||||
|
{
|
||||||
|
return "CurvedLine";
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.CurvedLine.prototype.setFrom = function(x, y)
|
||||||
|
{
|
||||||
|
this._peer.setFrom(x, y);
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.CurvedLine.prototype.setTo = function(x, y)
|
||||||
|
{
|
||||||
|
this._peer.setTo(x, y);
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.CurvedLine.prototype.getFrom = function()
|
||||||
|
{
|
||||||
|
return this._peer.getFrom();
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.CurvedLine.prototype.getTo = function()
|
||||||
|
{
|
||||||
|
return this._peer.getTo();
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.CurvedLine.prototype.setShowArrow = function(visible){
|
||||||
|
this._peer.setShowArrow(visible);
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.CurvedLine.prototype.isShowArrow = function(){
|
||||||
|
return this._peer.isShowArrow();
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.CurvedLine.prototype.setSrcControlPoint = function(control){
|
||||||
|
this._peer.setSrcControlPoint(control);
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.CurvedLine.prototype.setDestControlPoint = function(control){
|
||||||
|
this._peer.setDestControlPoint(control);
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.CurvedLine.prototype.getControlPoints = function(){
|
||||||
|
return this._peer.getControlPoints();
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.CurvedLine.prototype.isSrcControlPointCustom = function(){
|
||||||
|
return this._peer.isSrcControlPointCustom();
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.CurvedLine.prototype.isDestControlPointCustom = function(){
|
||||||
|
return this._peer.isDestControlPointCustom();
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.CurvedLine.prototype.setIsSrcControlPointCustom = function(isCustom){
|
||||||
|
this._peer.setIsSrcControlPointCustom(isCustom);
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.CurvedLine.prototype.setIsDestControlPointCustom = function(isCustom){
|
||||||
|
this._peer.setIsDestControlPointCustom(isCustom);
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.CurvedLine.prototype.updateLine= function(avoidControlPointFix){
|
||||||
|
return this._peer.updateLine(avoidControlPointFix);
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.CurvedLine.prototype.setStyle = function(style){
|
||||||
|
this._peer.setLineStyle(style);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.CurvedLine.prototype.getStyle = function(){
|
||||||
|
return this._peer.getLineStyle();
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.CurvedLine.prototype.setDashed = function(length,spacing){
|
||||||
|
this._peer.setDashed(length, spacing);
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.CurvedLine.SIMPLE_LINE = false;
|
||||||
|
web2d.CurvedLine.NICE_LINE = true;
|
||||||
|
|
@ -44,6 +44,16 @@ web2d.Line.prototype.setTo = function(x, y)
|
|||||||
this._peer.setTo(x, y);
|
this._peer.setTo(x, y);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
web2d.Line.prototype.getFrom = function()
|
||||||
|
{
|
||||||
|
return this._peer.getFrom();
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.Line.prototype.getTo = function()
|
||||||
|
{
|
||||||
|
return this._peer.getTo();
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the start and the end line arrow style.
|
* Defines the start and the end line arrow style.
|
||||||
* Can have values "none | block | classic | diamond | oval | open | chevron | doublechevron"
|
* Can have values "none | block | classic | diamond | oval | open | chevron | doublechevron"
|
||||||
|
@ -74,9 +74,13 @@ web2d.peer.ToolkitVML =
|
|||||||
{
|
{
|
||||||
return new web2d.peer.vml.LinePeer();
|
return new web2d.peer.vml.LinePeer();
|
||||||
},
|
},
|
||||||
createPolyLine: function()
|
createCurvedLine: function()
|
||||||
{
|
{
|
||||||
return new web2d.peer.vml.PolyLinePeer();
|
return new web2d.peer.vml.CurvedLinePeer();
|
||||||
|
},
|
||||||
|
createCurvedLine: function()
|
||||||
|
{
|
||||||
|
return new web2d.peer.vml.CurvedLinePeer();
|
||||||
},
|
},
|
||||||
createImage: function ()
|
createImage: function ()
|
||||||
{
|
{
|
||||||
@ -135,6 +139,10 @@ web2d.peer.ToolkitSVG =
|
|||||||
{
|
{
|
||||||
return new web2d.peer.svg.PolyLinePeer();
|
return new web2d.peer.svg.PolyLinePeer();
|
||||||
},
|
},
|
||||||
|
createCurvedLine: function()
|
||||||
|
{
|
||||||
|
return new web2d.peer.svg.CurvedLinePeer();
|
||||||
|
},
|
||||||
createText: function ()
|
createText: function ()
|
||||||
{
|
{
|
||||||
return new web2d.peer.svg.TextPeer();
|
return new web2d.peer.svg.TextPeer();
|
||||||
|
223
web2d/src/main/javascript/peer/svg/CurvedLinePeer.js
Normal file
223
web2d/src/main/javascript/peer/svg/CurvedLinePeer.js
Normal file
@ -0,0 +1,223 @@
|
|||||||
|
/*
|
||||||
|
* 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 $
|
||||||
|
*/
|
||||||
|
|
||||||
|
web2d.peer.svg.CurvedLinePeer = function()
|
||||||
|
{
|
||||||
|
var svgElement = window.document.createElementNS(this.svgNamespace, 'path');
|
||||||
|
web2d.peer.svg.ElementPeer.call(this, svgElement);
|
||||||
|
this._style={fill:'gray'};
|
||||||
|
this._updateStyle();
|
||||||
|
this._customControlPoint_1 = false;
|
||||||
|
this._customControlPoint_2 = false;
|
||||||
|
this._control1=new core.Point();
|
||||||
|
this._control2=new core.Point();
|
||||||
|
this._lineStyle=true;
|
||||||
|
};
|
||||||
|
|
||||||
|
objects.extend(web2d.peer.svg.CurvedLinePeer, web2d.peer.svg.ElementPeer);
|
||||||
|
|
||||||
|
web2d.peer.svg.CurvedLinePeer.prototype.setSrcControlPoint = function(control){
|
||||||
|
this._customControlPoint_1 = true;
|
||||||
|
if(core.Utils.isDefined(control.x)){
|
||||||
|
this._control1 = control;
|
||||||
|
}
|
||||||
|
this._updatePath();
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.peer.svg.CurvedLinePeer.prototype.setDestControlPoint = function(control){
|
||||||
|
this._customControlPoint_2 = true;
|
||||||
|
if(core.Utils.isDefined(control.x)){
|
||||||
|
this._control2 = control;
|
||||||
|
}
|
||||||
|
this._updatePath();
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.peer.svg.CurvedLinePeer.prototype.isSrcControlPointCustom = function() {
|
||||||
|
return this._customControlPoint_1;
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.peer.svg.CurvedLinePeer.prototype.isDestControlPointCustom = function() {
|
||||||
|
return this._customControlPoint_2;
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.peer.svg.CurvedLinePeer.prototype.setIsSrcControlPointCustom = function(isCustom) {
|
||||||
|
this._customControlPoint_1 = isCustom;
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.peer.svg.CurvedLinePeer.prototype.setIsDestControlPointCustom = function(isCustom) {
|
||||||
|
this._customControlPoint_2 = isCustom;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
web2d.peer.svg.CurvedLinePeer.prototype.getControlPoints = function(){
|
||||||
|
return [this._control1, this._control2];
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.peer.svg.CurvedLinePeer.prototype.setFrom = function(x1, y1)
|
||||||
|
{
|
||||||
|
if(this._customControlPoint_1 && core.Utils.isDefined(this._x1)){
|
||||||
|
this._control1.x-=this._x1-x1;
|
||||||
|
this._control1.y-=this._y1-y1;
|
||||||
|
}
|
||||||
|
this._x1 = x1;
|
||||||
|
this._y1 = y1;
|
||||||
|
this._updatePath();
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.peer.svg.CurvedLinePeer.prototype.setTo = function(x2, y2)
|
||||||
|
{
|
||||||
|
if(this._customControlPoint_2 && core.Utils.isDefined(this._x2)){
|
||||||
|
this._control2.x-=this._x2-x2;
|
||||||
|
this._control2.y-=this._y2-y2;
|
||||||
|
}
|
||||||
|
this._x2 = x2;
|
||||||
|
this._y2 = y2;
|
||||||
|
this._updatePath();
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.peer.svg.CurvedLinePeer.prototype.getFrom = function()
|
||||||
|
{
|
||||||
|
return new core.Point(this._x1,this._y1);
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.peer.svg.CurvedLinePeer.prototype.getTo = function()
|
||||||
|
{
|
||||||
|
return new core.Point(this._x2,this._y2);
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.peer.svg.CurvedLinePeer.prototype.setStrokeWidth = function(width)
|
||||||
|
{
|
||||||
|
this._style['stroke-width']= width;
|
||||||
|
this._updateStyle();
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.peer.svg.CurvedLinePeer.prototype.setColor = function(color)
|
||||||
|
{
|
||||||
|
this._style['stroke']= color;
|
||||||
|
this._style['fill']=color;
|
||||||
|
this._updateStyle();
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.peer.svg.CurvedLinePeer.prototype.updateLine = function(avoidControlPointFix){
|
||||||
|
this._updatePath(avoidControlPointFix);
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.peer.svg.CurvedLinePeer.prototype.setLineStyle = function (style){
|
||||||
|
this._lineStyle=style;
|
||||||
|
if(this._lineStyle){
|
||||||
|
this._style['fill']=this._fill;
|
||||||
|
} else {
|
||||||
|
this._fill = this._style['fill'];
|
||||||
|
this._style['fill']='none';
|
||||||
|
}
|
||||||
|
this._updateStyle();
|
||||||
|
this.updateLine();
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.peer.svg.CurvedLinePeer.prototype.getLineStyle = function (){
|
||||||
|
return this._lineStyle;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
web2d.peer.svg.CurvedLinePeer.prototype.setShowArrow = function(visible){
|
||||||
|
this._showArrow =visible;
|
||||||
|
this.updateLine();
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.peer.svg.CurvedLinePeer.prototype.isShowArrow = function(){
|
||||||
|
return this._showArrow;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
web2d.peer.svg.CurvedLinePeer.prototype._updatePath = function(avoidControlPointFix)
|
||||||
|
{
|
||||||
|
this._calculateAutoControlPoints(avoidControlPointFix);
|
||||||
|
var x,y, xp, yp;
|
||||||
|
if(this._showArrow){
|
||||||
|
if(this._control2.y == 0)
|
||||||
|
this._control2.y=1;
|
||||||
|
var y0 = parseInt(this._control2.y) - this._y2;
|
||||||
|
var x0 = parseInt(this._control2.x) - this._x2;
|
||||||
|
var x2=x0+y0;
|
||||||
|
var y2 = y0-x0;
|
||||||
|
var x3 = x0-y0;
|
||||||
|
var y3 = y0+x0;
|
||||||
|
var m = y2/x2;
|
||||||
|
var mp = y3/x3;
|
||||||
|
var l = 6;
|
||||||
|
var pow = Math.pow;
|
||||||
|
x = (x2==0?0:Math.sqrt(pow(l,2)/(1+pow(m,2))));
|
||||||
|
x *=Math.sign(x2);
|
||||||
|
y = (x2==0?l*Math.sign(y2):m*x);
|
||||||
|
xp = (x3==0?0:Math.sqrt(pow(l,2)/(1+pow(mp,2))));
|
||||||
|
xp *=Math.sign(x3);
|
||||||
|
yp = (x3==0?l*Math.sign(y3):mp*xp);
|
||||||
|
}
|
||||||
|
var path = "M"+this._x1+","+this._y1
|
||||||
|
+" C"+this._control1.x+","+this._control1.y+" "
|
||||||
|
+this._control2.x+","+this._control2.y+" "
|
||||||
|
+this._x2+","+this._y2+
|
||||||
|
(this._lineStyle?" "
|
||||||
|
+this._control2.x+","+(parseInt(this._control2.y)+3)+" "
|
||||||
|
+this._control1.x+","+(parseInt(this._control1.y)+3)+" "
|
||||||
|
+this._x1+","+(parseInt(this._y1)+3)+" Z"
|
||||||
|
:""
|
||||||
|
)+
|
||||||
|
(this._showArrow?" "
|
||||||
|
+"M"+this._x2+","+this._y2+" "
|
||||||
|
+"L"+(x+this._x2)+","+(y+this._y2)
|
||||||
|
+"M"+this._x2+","+this._y2+" "
|
||||||
|
+"L"+(xp+this._x2)+","+(yp+this._y2)
|
||||||
|
:"");
|
||||||
|
this._native.setAttribute("d",path);
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.peer.svg.CurvedLinePeer.prototype._updateStyle = function()
|
||||||
|
{
|
||||||
|
var style = "";
|
||||||
|
for(var key in this._style){
|
||||||
|
style+=key+":"+this._style[key]+" ";
|
||||||
|
}
|
||||||
|
this._native.setAttribute("style",style);
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.peer.svg.CurvedLinePeer.prototype._calculateAutoControlPoints = function(avoidControlPointFix){
|
||||||
|
if(core.Utils.isDefined(this._x1) && core.Utils.isDefined(this._x2)){
|
||||||
|
//Both points available, calculate real points
|
||||||
|
var defaultpoints = core.Utils.calculateDefaultControlPoints(new core.Point(this._x1, this._y1),new core.Point(this._x2,this._y2));
|
||||||
|
if(!this._customControlPoint_1 && !(core.Utils.isDefined(avoidControlPointFix) && avoidControlPointFix==0)){
|
||||||
|
this._control1.x = defaultpoints[0].x;
|
||||||
|
this._control1.y = defaultpoints[0].y;
|
||||||
|
}
|
||||||
|
if(!this._customControlPoint_2 && !(core.Utils.isDefined(avoidControlPointFix) && avoidControlPointFix==1)){
|
||||||
|
this._control2.x = defaultpoints[1].x;
|
||||||
|
this._control2.y = defaultpoints[1].y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.peer.svg.CurvedLinePeer.prototype.setDashed = function(length,spacing){
|
||||||
|
if(core.Utils.isDefined(length) && core.Utils.isDefined(spacing)){
|
||||||
|
this._native.setAttribute("stroke-dasharray",length+","+spacing);
|
||||||
|
} else {
|
||||||
|
this._native.setAttribute("stroke-dasharray","");
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
@ -28,16 +28,29 @@ objects.extend(web2d.peer.svg.LinePeer, web2d.peer.svg.ElementPeer);
|
|||||||
|
|
||||||
web2d.peer.svg.LinePeer.prototype.setFrom = function(x1, y1)
|
web2d.peer.svg.LinePeer.prototype.setFrom = function(x1, y1)
|
||||||
{
|
{
|
||||||
|
this._x1=x1;
|
||||||
|
this._y1=y1;
|
||||||
this._native.setAttribute('x1', x1);
|
this._native.setAttribute('x1', x1);
|
||||||
this._native.setAttribute('y1', y1);
|
this._native.setAttribute('y1', y1);
|
||||||
};
|
};
|
||||||
|
|
||||||
web2d.peer.svg.LinePeer.prototype.setTo = function(x2, y2)
|
web2d.peer.svg.LinePeer.prototype.setTo = function(x2, y2)
|
||||||
{
|
{
|
||||||
|
this._x2=x2;
|
||||||
|
this._y2=y2;
|
||||||
this._native.setAttribute('x2', x2);
|
this._native.setAttribute('x2', x2);
|
||||||
this._native.setAttribute('y2', y2);
|
this._native.setAttribute('y2', y2);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
web2d.peer.svg.LinePeer.prototype.getFrom = function(){
|
||||||
|
return new core.Point(this._x1,this._y1);
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.peer.svg.LinePeer.prototype.getTo = function(){
|
||||||
|
return new core.Point(this._x2,this._y2);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* http://www.zvon.org/HowTo/Output/howto_jj_svg_27.html?at=marker-end
|
* http://www.zvon.org/HowTo/Output/howto_jj_svg_27.html?at=marker-end
|
||||||
*/
|
*/
|
||||||
|
@ -82,7 +82,7 @@ web2d.peer.svg.PolyLinePeer.prototype._updateStraightPath = function()
|
|||||||
{
|
{
|
||||||
if (core.Utils.isDefined(this._x1) && core.Utils.isDefined(this._x2) && core.Utils.isDefined(this._y1) && core.Utils.isDefined(this._y2))
|
if (core.Utils.isDefined(this._x1) && core.Utils.isDefined(this._x2) && core.Utils.isDefined(this._y1) && core.Utils.isDefined(this._y2))
|
||||||
{
|
{
|
||||||
this.buildStraightPath(this.breakDistance, this._x1, this._y1, this._x2, this._y2);
|
var path = web2d.PolyLine.buildStraightPath(this.breakDistance, this._x1, this._y1, this._x2, this._y2);
|
||||||
this._native.setAttribute('points', path);
|
this._native.setAttribute('points', path);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
116
web2d/src/test/javascript/render/curvedLine.html
Normal file
116
web2d/src/test/javascript/render/curvedLine.html
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
|
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
<!--[if gte IE 9]>
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=9" >
|
||||||
|
<![endif]-->
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
web2d = {
|
||||||
|
peer: {}
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.peer =
|
||||||
|
{
|
||||||
|
svg: {},
|
||||||
|
vml: {}
|
||||||
|
};
|
||||||
|
|
||||||
|
web2d.peer.utils = {};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/javascript" src="mootools.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../../core-js/target/classes/core.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/EventDispatcher.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/peer/vml/ElementPeer.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/peer/svg/ElementPeer.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/Element.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/Workspace.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/peer/svg/WorkspacePeer.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/peer/vml/WorkspacePeer.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/Toolkit.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/Elipse.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/peer/svg/ElipsePeer.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/peer/vml/ElipsePeer.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/Line.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/peer/svg/LinePeer.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/peer/vml/LinePeer.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/PolyLine.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/CurvedLine.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/peer/svg/PolyLinePeer.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/peer/vml/PolyLinePeer.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/peer/svg/CurvedLinePeer.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/Group.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/peer/svg/GroupPeer.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/peer/vml/GroupPeer.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/Rect.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/peer/svg/RectPeer.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/peer/vml/RectPeer.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/Text.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/peer/svg/TextPeer.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/peer/vml/TextPeer.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/peer/vml/TextBoxPeer.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/peer/utils/TransformUtils.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/peer/utils/EventUtils.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/Font.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/peer/svg/Font.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/peer/vml/Font.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/peer/svg/TahomaFont.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/peer/svg/TimesFont.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/peer/svg/ArialFont.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/peer/svg/VerdanaFont.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/peer/vml/TahomaFont.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/peer/vml/TimesFont.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/peer/vml/ArialFont.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../../src/main/javascript/peer/vml/VerdanaFont.js"></script>
|
||||||
|
<script type="text/javascript" src="utils.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
function initialize(){
|
||||||
|
web2d.peer.Toolkit.init();
|
||||||
|
|
||||||
|
var overflowWorkspace = new web2d.Workspace({fillColor:'green'});
|
||||||
|
overflowWorkspace.setSize("200px", "200px");
|
||||||
|
line1 = new web2d.CurvedLine();
|
||||||
|
line1.setStyle(web2d.CurvedLine.SIMPLE_LINE);
|
||||||
|
line1.setFrom(200, 200);
|
||||||
|
line1.setTo(100, 100);
|
||||||
|
// line1.setControlPoints({x:150,y:100},{x:150,y:200});
|
||||||
|
overflowWorkspace.appendChild(line1);
|
||||||
|
|
||||||
|
overflowWorkspace.addItAsChildTo($("overflowExample"));
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body onload="initialize();">
|
||||||
|
|
||||||
|
<h1>PolyLines Render Tests </h1>
|
||||||
|
|
||||||
|
<table border="1">
|
||||||
|
<colgroup style="width:80%;">
|
||||||
|
<col style="width:30%"/>
|
||||||
|
<col style="width:60%"/>
|
||||||
|
</colgroup>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
Different types of PolyLines that can be used.
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div id="overflowExample"/>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
This is how multiple childs will look in each style line
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div id="multipleLineExample"/>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -417,7 +417,7 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<!-- <plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<artifactId>jaxws-maven-plugin</artifactId>
|
<artifactId>jaxws-maven-plugin</artifactId>
|
||||||
<executions>
|
<executions>
|
||||||
@ -439,7 +439,7 @@
|
|||||||
</wsdlFiles>
|
</wsdlFiles>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
-->
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
@ -83,7 +83,7 @@ public final class Mailer {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.mailSender.send(preparator);
|
//this.mailSender.send(preparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMailSender(JavaMailSender mailer) {
|
public void setMailSender(JavaMailSender mailer) {
|
||||||
|
@ -24,6 +24,7 @@ import com.wisemapping.exceptions.WiseMappingException;
|
|||||||
import com.wisemapping.mail.Mailer;
|
import com.wisemapping.mail.Mailer;
|
||||||
import com.wisemapping.model.User;
|
import com.wisemapping.model.User;
|
||||||
import com.wisemapping.model.Colaborator;
|
import com.wisemapping.model.Colaborator;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -35,6 +36,7 @@ public class UserServiceImpl
|
|||||||
private UserManager userManager;
|
private UserManager userManager;
|
||||||
private MindmapService mindmapService;
|
private MindmapService mindmapService;
|
||||||
private Mailer mailer;
|
private Mailer mailer;
|
||||||
|
final static Logger logger = Logger.getLogger("org.wisemapping.service");
|
||||||
|
|
||||||
public void activateAcount(long code)
|
public void activateAcount(long code)
|
||||||
throws InvalidActivationCodeException
|
throws InvalidActivationCodeException
|
||||||
@ -113,6 +115,7 @@ public class UserServiceImpl
|
|||||||
model.put("user", user);
|
model.put("user", user);
|
||||||
// TODO: ver como no hacer hardcode el url
|
// TODO: ver como no hacer hardcode el url
|
||||||
final String activationUrl = "http://wisemapping.com/c/activation.htm?code=" + user.getActivationCode();
|
final String activationUrl = "http://wisemapping.com/c/activation.htm?code=" + user.getActivationCode();
|
||||||
|
logger.info("create User - acrivationUrl: "+activationUrl);
|
||||||
model.put("emailcheck", activationUrl);
|
model.put("emailcheck", activationUrl);
|
||||||
mailer.sendEmail(mailer.getRegistrationEmail(), user.getEmail(), "Welcome to Wisemapping!", model,
|
mailer.sendEmail(mailer.getRegistrationEmail(), user.getEmail(), "Welcome to Wisemapping!", model,
|
||||||
"confirmationMail.vm");
|
"confirmationMail.vm");
|
||||||
|
@ -1,160 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 $
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.wisemapping.ws;
|
|
||||||
|
|
||||||
import org.springframework.ws.server.endpoint.annotation.Endpoint;
|
|
||||||
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import com.wisemapping.service.MindmapService;
|
|
||||||
import com.wisemapping.service.UserService;
|
|
||||||
import com.wisemapping.model.MindMap;
|
|
||||||
import com.wisemapping.model.User;
|
|
||||||
import com.wisemapping.exceptions.NoMapFoundException;
|
|
||||||
|
|
||||||
import javax.xml.bind.*;
|
|
||||||
import javax.xml.transform.stream.StreamSource;
|
|
||||||
import java.io.StringReader;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.util.Calendar;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* WiseMapping Web Services API
|
|
||||||
*/
|
|
||||||
@Endpoint
|
|
||||||
public class WiseWsEndpoint {
|
|
||||||
|
|
||||||
MindmapService mindmapService;
|
|
||||||
private UserService userService;
|
|
||||||
final static Logger logger = Logger.getLogger("org.wisemapping.ws");
|
|
||||||
private JAXBContext jaxbContext;
|
|
||||||
|
|
||||||
|
|
||||||
public WiseWsEndpoint(MindmapService mindmapService, UserService userService) throws JAXBException {
|
|
||||||
this.mindmapService = mindmapService;
|
|
||||||
this.userService = userService;
|
|
||||||
jaxbContext = JAXBContext.newInstance("com.wisemapping.ws");
|
|
||||||
}
|
|
||||||
|
|
||||||
@PayloadRoot(localPart = "loadMindmapRequest", namespace = "http://www.wisemapping.org/ws")
|
|
||||||
public LoadMindmapResponse loadMindmap(final LoadMindmapRequest request) throws Throwable {
|
|
||||||
|
|
||||||
logger.debug("Invoking loadMindmap");
|
|
||||||
final LoadMindmapResponse result = new LoadMindmapResponse();
|
|
||||||
|
|
||||||
try {
|
|
||||||
final MindMap mindmap = mindmapService.getMindmapById((int) request.getMapdId());
|
|
||||||
if(mindmap==null)
|
|
||||||
{
|
|
||||||
throw new NoMapFoundException(request.getMapdId());
|
|
||||||
}
|
|
||||||
|
|
||||||
String xml = mindmap.getNativeXml();
|
|
||||||
|
|
||||||
// Hack, we need to unify to only one XSD schema definitions per map ...
|
|
||||||
xml = "<map xmlns=\"http://www.wisemapping.org/mindmap\"" + xml.substring(4,xml.length());
|
|
||||||
|
|
||||||
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
|
|
||||||
|
|
||||||
final StringReader stringReader = new StringReader(xml);
|
|
||||||
final StreamSource streamSource = new StreamSource(stringReader);
|
|
||||||
final JAXBElement<MapType> mapElement = unmarshaller.unmarshal(streamSource,MapType.class);
|
|
||||||
|
|
||||||
// Load map data ...
|
|
||||||
result.creator = mindmap.getCreator();
|
|
||||||
result.setMap(mapElement.getValue());
|
|
||||||
} catch (Throwable e) {
|
|
||||||
logger.fatal("Unexpexted Exception", e);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@PayloadRoot(localPart = "addMindmapRequest", namespace = "http://www.wisemapping.org/ws")
|
|
||||||
public AddMindmapResponse createMindmap(final AddMindmapRequest request) throws Throwable {
|
|
||||||
|
|
||||||
logger.debug("Invoking createMindmap");
|
|
||||||
final AddMindmapResponse response = new AddMindmapResponse();
|
|
||||||
try {
|
|
||||||
|
|
||||||
final String creator = request.getCreator();
|
|
||||||
final User user = userService.getUserBy(creator);
|
|
||||||
if(user==null)
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("Invalid addMindmapRequest.' " + creator+"' is not valid wisemapping user.");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
final MindMap mindmap = new MindMap();
|
|
||||||
mindmap.setCreationTime(Calendar.getInstance());
|
|
||||||
|
|
||||||
// Set title ...
|
|
||||||
final String title = request.getTitle();
|
|
||||||
if(title==null)
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("Invalid addMindmapRequest. Title element can not be null.");
|
|
||||||
}
|
|
||||||
mindmap.setTitle(title);
|
|
||||||
|
|
||||||
// Set description ...
|
|
||||||
final String description = request.getDescription();
|
|
||||||
if(description==null)
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("Invalid addMindmapRequest. Description element can not be null.");
|
|
||||||
}
|
|
||||||
mindmap.setDescription(description);
|
|
||||||
|
|
||||||
// Convert Map to XML
|
|
||||||
final MapType mapType = request.getMap();
|
|
||||||
if(mapType==null)
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("Invalid addMindmapRequest. Map element can not be null.");
|
|
||||||
}
|
|
||||||
|
|
||||||
ObjectFactory factory = new ObjectFactory();
|
|
||||||
final Marshaller marshaller = jaxbContext.createMarshaller();
|
|
||||||
StringWriter stringWriter = new StringWriter();
|
|
||||||
marshaller.marshal(factory.createMap(mapType),stringWriter);
|
|
||||||
|
|
||||||
mindmap.setNativeXml(stringWriter.toString());
|
|
||||||
mindmapService.addMindmap(mindmap,user);
|
|
||||||
|
|
||||||
|
|
||||||
// Prepare result ...
|
|
||||||
response.setMapId(mindmap.getId());
|
|
||||||
|
|
||||||
} catch (Throwable e) {
|
|
||||||
logger.fatal("Unexpexted Exception", e);
|
|
||||||
throw e;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public MindmapService getMindmapService() {
|
|
||||||
return mindmapService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMindmapService(MindmapService mindmapService) {
|
|
||||||
this.mindmapService = mindmapService;
|
|
||||||
}
|
|
||||||
}
|
|
@ -10,11 +10,12 @@
|
|||||||
<xsd:complexType name="mapType">
|
<xsd:complexType name="mapType">
|
||||||
<xsd:sequence>
|
<xsd:sequence>
|
||||||
<xsd:element ref="topic" minOccurs="1" maxOccurs='unbounded'/>
|
<xsd:element ref="topic" minOccurs="1" maxOccurs='unbounded'/>
|
||||||
|
<xsd:element ref="relationship" minOccurs="0" maxOccurs='unbounded'/>
|
||||||
</xsd:sequence>
|
</xsd:sequence>
|
||||||
<xsd:attribute name="name" type="xsd:string"/>
|
<xsd:attribute name="name" type="xsd:string"/>
|
||||||
|
<xsd:attribute name="version" type="xsd:string"/>
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
|
|
||||||
|
|
||||||
<xsd:element name="topic" type="topicType"/>
|
<xsd:element name="topic" type="topicType"/>
|
||||||
|
|
||||||
<xsd:complexType name="topicType">
|
<xsd:complexType name="topicType">
|
||||||
@ -32,6 +33,7 @@
|
|||||||
<xsd:attribute name="order" type="xsd:int"/>
|
<xsd:attribute name="order" type="xsd:int"/>
|
||||||
<xsd:attribute name="position" type="xsd:string"/>
|
<xsd:attribute name="position" type="xsd:string"/>
|
||||||
<xsd:attribute name="central" type="xsd:boolean"/>
|
<xsd:attribute name="central" type="xsd:boolean"/>
|
||||||
|
<xsd:attribute name="id" type="xsd:ID" use="optional"/>
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
|
|
||||||
<xsd:complexType name="icon">
|
<xsd:complexType name="icon">
|
||||||
@ -48,4 +50,15 @@
|
|||||||
<xsd:attribute name="text" type="xsd:string"/>
|
<xsd:attribute name="text" type="xsd:string"/>
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
|
|
||||||
|
<xsd:element name="relationship" type="relationshipType"/>
|
||||||
|
<xsd:complexType name="relationshipType">
|
||||||
|
<xsd:attribute name="id" type="xsd:ID"/>
|
||||||
|
<xsd:attribute name="srcTopicId" type="xsd:ID"/>
|
||||||
|
<xsd:attribute name="destTopicId" type="xsd:ID"/>
|
||||||
|
<xsd:attribute name="lineType" type="xsd:string"/>
|
||||||
|
<xsd:attribute name="srcCtrlPoint" type="xsd:string"/>
|
||||||
|
<xsd:attribute name="destCtrlPoint" type="xsd:string"/>
|
||||||
|
<xsd:attribute name="endArrow" type="xsd:boolean"/>
|
||||||
|
</xsd:complexType>
|
||||||
|
|
||||||
</xsd:schema>
|
</xsd:schema>
|
@ -216,11 +216,11 @@ div#node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
div#font {
|
div#font {
|
||||||
left: 619px; /*left:581px;*/
|
left: 656px; /*left:581px;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
div#share {
|
div#share {
|
||||||
left: 815px; /*left:777px;*/
|
left: 852px; /*left:777px;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
div#saveButton {
|
div#saveButton {
|
||||||
@ -311,6 +311,12 @@ div#topicLink {
|
|||||||
z-index: 4;
|
z-index: 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div#topicRelation {
|
||||||
|
background: url(../images/topic_link.png) no-repeat center top;
|
||||||
|
behavior: url(../css/iepngfix.htc);
|
||||||
|
z-index: 4;
|
||||||
|
}
|
||||||
|
|
||||||
div#topicNote {
|
div#topicNote {
|
||||||
background-image: url(../images/note.png);
|
background-image: url(../images/note.png);
|
||||||
behavior: url(../css/iepngfix.htc);
|
behavior: url(../css/iepngfix.htc);
|
||||||
|
@ -269,7 +269,7 @@ function afterMindpotLibraryLoading()
|
|||||||
designer.deleteCurrentNode();
|
designer.deleteCurrentNode();
|
||||||
});
|
});
|
||||||
var context = this;
|
var context = this;
|
||||||
var colorPicker1 = new MooRainbow('topicColor', {
|
/*var colorPicker1 = new MooRainbow('topicColor', {
|
||||||
id: 'topicColor',
|
id: 'topicColor',
|
||||||
imgPath: '../images/',
|
imgPath: '../images/',
|
||||||
startColor: [255, 255, 255],
|
startColor: [255, 255, 255],
|
||||||
@ -298,12 +298,16 @@ function afterMindpotLibraryLoading()
|
|||||||
onComplete: function(color) {
|
onComplete: function(color) {
|
||||||
removeCurrentColorPicker.attempt(colorPicker2, context);
|
removeCurrentColorPicker.attempt(colorPicker2, context);
|
||||||
}
|
}
|
||||||
});
|
});*/
|
||||||
$('topicLink').addEvent('click', function(event) {
|
$('topicLink').addEvent('click', function(event) {
|
||||||
designer.addLink2SelectedNode();
|
designer.addLink2SelectedNode();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('topicRelation').addEvent('click', function(event) {
|
||||||
|
designer.addRelationShip2SelectedNode(event);
|
||||||
|
});
|
||||||
|
|
||||||
$('topicNote').addEvent('click', function(event) {
|
$('topicNote').addEvent('click', function(event) {
|
||||||
designer.addNote2SelectedNode();
|
designer.addNote2SelectedNode();
|
||||||
|
|
||||||
@ -318,7 +322,7 @@ function afterMindpotLibraryLoading()
|
|||||||
designer.setStyle2SelectedNode();
|
designer.setStyle2SelectedNode();
|
||||||
});
|
});
|
||||||
|
|
||||||
var colorPicker3 = new MooRainbow('fontColor', {
|
/*var colorPicker3 = new MooRainbow('fontColor', {
|
||||||
id: 'fontColor',
|
id: 'fontColor',
|
||||||
imgPath: '../images/',
|
imgPath: '../images/',
|
||||||
startColor: [255, 255, 255],
|
startColor: [255, 255, 255],
|
||||||
@ -332,7 +336,7 @@ function afterMindpotLibraryLoading()
|
|||||||
onComplete: function(color) {
|
onComplete: function(color) {
|
||||||
removeCurrentColorPicker.attempt(colorPicker3, context);
|
removeCurrentColorPicker.attempt(colorPicker3, context);
|
||||||
}
|
}
|
||||||
});
|
});*/
|
||||||
|
|
||||||
// Save event handler ....
|
// Save event handler ....
|
||||||
var saveButton = $('saveButton');
|
var saveButton = $('saveButton');
|
||||||
@ -520,7 +524,6 @@ function buildMindmapDesigner()
|
|||||||
var container = $('mindplot');
|
var container = $('mindplot');
|
||||||
|
|
||||||
// Initialize Editor ...
|
// Initialize Editor ...
|
||||||
var persistantManager = new mindplot.PersistanceManager(window.MapEditorService);
|
|
||||||
|
|
||||||
var screenWidth = window.getWidth();
|
var screenWidth = window.getWidth();
|
||||||
var screenHeight = window.getHeight();
|
var screenHeight = window.getHeight();
|
||||||
@ -533,7 +536,7 @@ function buildMindmapDesigner()
|
|||||||
editorProperties.width = screenWidth;
|
editorProperties.width = screenWidth;
|
||||||
editorProperties.height = screenHeight;
|
editorProperties.height = screenHeight;
|
||||||
|
|
||||||
designer = new mindplot.MindmapDesigner(editorProperties, container, persistantManager);
|
designer = new mindplot.MindmapDesigner(editorProperties, container);
|
||||||
designer.loadFromXML(mapId, mapXml);
|
designer.loadFromXML(mapId, mapXml);
|
||||||
|
|
||||||
// If a node has focus, focus can be move to another node using the keys.
|
// If a node has focus, focus can be move to another node using the keys.
|
||||||
|
@ -67,7 +67,6 @@ function buildMindmapDesigner()
|
|||||||
var container = $('mindplot');
|
var container = $('mindplot');
|
||||||
|
|
||||||
// Initialize Editor ...
|
// Initialize Editor ...
|
||||||
var persistantManager = new mindplot.PersistanceManager(window.MapEditorService);
|
|
||||||
|
|
||||||
var screenWidth = window.getWidth();
|
var screenWidth = window.getWidth();
|
||||||
var screenHeight = window.getHeight();
|
var screenHeight = window.getHeight();
|
||||||
@ -77,7 +76,7 @@ function buildMindmapDesigner()
|
|||||||
editorProperties.height = screenHeight;
|
editorProperties.height = screenHeight;
|
||||||
editorProperties.viewMode = true;
|
editorProperties.viewMode = true;
|
||||||
|
|
||||||
designer = new mindplot.MindmapDesigner(editorProperties, container, persistantManager);
|
designer = new mindplot.MindmapDesigner(editorProperties, container);
|
||||||
designer.loadFromXML(mapId, mapXml);
|
designer.loadFromXML(mapId, mapXml);
|
||||||
|
|
||||||
// If a node has focus, focus can be move to another node using the keys.
|
// If a node has focus, focus can be move to another node using the keys.
|
||||||
|
@ -15,9 +15,10 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<%--
|
||||||
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
|
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
|
||||||
</script>
|
</script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
_uacct = "UA-2347723-1";
|
_uacct = "UA-2347723-1";
|
||||||
urchinTracker();
|
urchinTracker();
|
||||||
</script>
|
</script>--%>
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
<%@page pageEncoding="UTF-8"%>
|
||||||
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
|
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
|
||||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||||
|
@ -192,6 +192,9 @@
|
|||||||
<div id="topicLink" class="button" title="<spring:message code="TOPIC_LINK"/>">
|
<div id="topicLink" class="button" title="<spring:message code="TOPIC_LINK"/>">
|
||||||
<div class="toolbarLabel"><p><spring:message code="LINK"/></p></div>
|
<div class="toolbarLabel"><p><spring:message code="LINK"/></p></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="topicRelation" class="button" title="<spring:message code="TOPIC_RELATIONSHIP"/>">
|
||||||
|
<div class="toolbarLabel"><p><spring:message code="TOPIC_RELATIONSHIP"/></p></div>
|
||||||
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
<div id="font" class="buttonContainer" title="Font Properties">
|
<div id="font" class="buttonContainer" title="Font Properties">
|
||||||
@ -332,11 +335,11 @@
|
|||||||
<script type="text/javascript" src="../dwr/interface/MapEditorService.js"></script>
|
<script type="text/javascript" src="../dwr/interface/MapEditorService.js"></script>
|
||||||
</c:if>
|
</c:if>
|
||||||
<script type="text/javascript" src="../js/editor.js"></script>
|
<script type="text/javascript" src="../js/editor.js"></script>
|
||||||
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
|
<%--<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
|
||||||
</script>
|
</script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
_uacct = "UA-2347723-1";
|
_uacct = "UA-2347723-1";
|
||||||
urchinTracker();
|
urchinTracker();
|
||||||
</script>
|
</script>--%>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||||
|
<%@page pageEncoding="UTF-8"%>
|
||||||
<%@ taglib prefix="tiles" uri="http://struts.apache.org/tags-tiles" %>
|
<%@ taglib prefix="tiles" uri="http://struts.apache.org/tags-tiles" %>
|
||||||
<%@ include file="/jsp/init.jsp" %>
|
<%@ include file="/jsp/init.jsp" %>
|
||||||
|
|
||||||
|
@ -1,100 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 $
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.wisemapping.ws.test;
|
|
||||||
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import javax.xml.bind.JAXBContext;
|
|
||||||
import javax.xml.bind.JAXBException;
|
|
||||||
import javax.xml.bind.Marshaller;
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.wisemapping.ws.*;
|
|
||||||
|
|
||||||
|
|
||||||
@Test(groups = {"wsintegration"})
|
|
||||||
public class WiseWebServicesTest {
|
|
||||||
|
|
||||||
|
|
||||||
@Test(dependsOnMethods = "addMapTest")
|
|
||||||
public void loadMapTest() throws MalformedURLException, JAXBException {
|
|
||||||
|
|
||||||
final WiseServicesPortTypeService portTypeService = new WiseServicesPortTypeService();
|
|
||||||
final WiseServicesPortType servicesPortType = portTypeService.getWiseServicesPortTypeSoap11();
|
|
||||||
|
|
||||||
final LoadMindmapRequest request = new LoadMindmapRequest();
|
|
||||||
request.setMapdId(1);
|
|
||||||
LoadMindmapResponse response = servicesPortType.loadMindmap(request);
|
|
||||||
|
|
||||||
JAXBContext jc = JAXBContext.newInstance("com.wisemapping.ws.test");
|
|
||||||
Marshaller marshaller = jc.createMarshaller();
|
|
||||||
|
|
||||||
final StringWriter xmlContext = new StringWriter();
|
|
||||||
marshaller.marshal(response,xmlContext);
|
|
||||||
System.out.println("Response:"+xmlContext);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addMapTest() throws MalformedURLException, JAXBException {
|
|
||||||
|
|
||||||
final WiseServicesPortTypeService portTypeService = new WiseServicesPortTypeService();
|
|
||||||
final WiseServicesPortType servicesPortType = portTypeService.getWiseServicesPortTypeSoap11();
|
|
||||||
|
|
||||||
final AddMindmapRequest request = new AddMindmapRequest();
|
|
||||||
|
|
||||||
request.setCreator("test@wisemapping.org");
|
|
||||||
|
|
||||||
request.setTitle("MyFirstMap");
|
|
||||||
request.setDescription("My First Map Description");
|
|
||||||
|
|
||||||
// Set Map ...
|
|
||||||
MapType sampleMap = createMockMap();
|
|
||||||
request.setMap(sampleMap);
|
|
||||||
|
|
||||||
|
|
||||||
AddMindmapResponse response = servicesPortType.addMindmap(request);
|
|
||||||
|
|
||||||
JAXBContext jc = JAXBContext.newInstance("com.wisemapping.ws.test");
|
|
||||||
Marshaller marshaller = jc.createMarshaller();
|
|
||||||
|
|
||||||
final StringWriter xmlContext = new StringWriter();
|
|
||||||
marshaller.marshal(response,xmlContext);
|
|
||||||
System.out.println("Response:"+xmlContext);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private MapType createMockMap() {
|
|
||||||
ObjectFactory factory = new ObjectFactory();
|
|
||||||
MapType mapType = factory.createMapType();
|
|
||||||
mapType.setName("map name");
|
|
||||||
|
|
||||||
TopicType topicType = factory.createTopicType();
|
|
||||||
topicType.setCentral(true);
|
|
||||||
topicType.setText("Central topic value");
|
|
||||||
|
|
||||||
List<TopicType> topics = mapType.getTopic();
|
|
||||||
topics.add(topicType);
|
|
||||||
|
|
||||||
return mapType;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user