diff --git a/mindplot/src/main/javascript/ControlPoint.js b/mindplot/src/main/javascript/ControlPoint.js index 83099bfd..47f41853 100644 --- a/mindplot/src/main/javascript/ControlPoint.js +++ b/mindplot/src/main/javascript/ControlPoint.js @@ -52,14 +52,14 @@ mindplot.ControlPoint.prototype.setLine= function(line) { mindplot.ControlPoint.prototype._createControlPoint = function() { this._controls= this._line.getLine().getControlPoints(); - this._controlPointsController[0].setPosition(this._controls[mindplot.ControlPoint.FROM].x, this._controls[mindplot.ControlPoint.FROM].y-3); - this._controlPointsController[1].setPosition(this._controls[mindplot.ControlPoint.TO].x, this._controls[mindplot.ControlPoint.TO].y-3); var pos = this._line.getLine().getFrom(); + this._controlPointsController[0].setPosition(this._controls[mindplot.ControlPoint.FROM].x+pos.x, this._controls[mindplot.ControlPoint.FROM].y+pos.y-3); 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); + this._controlLines[0].setTo(this._controls[mindplot.ControlPoint.FROM].x+pos.x+3, this._controls[mindplot.ControlPoint.FROM].y+pos.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); + this._controlLines[1].setTo(this._controls[mindplot.ControlPoint.TO].x+pos.x+3, this._controls[mindplot.ControlPoint.TO].y+pos.y); + this._controlPointsController[1].setPosition(this._controls[mindplot.ControlPoint.TO].x+pos.x, this._controls[mindplot.ControlPoint.TO].y+pos.y-3); }; @@ -91,8 +91,8 @@ mindplot.ControlPoint.prototype._mouseMove = function(event, point) { 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._controls[point].x=(pos.x - cords.x); + this._controls[point].y=(pos.y - cords.y); this._controlPointsController[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); diff --git a/mindplot/src/main/javascript/RelationshipLine.js b/mindplot/src/main/javascript/RelationshipLine.js index 1dab9ca1..5ae74196 100644 --- a/mindplot/src/main/javascript/RelationshipLine.js +++ b/mindplot/src/main/javascript/RelationshipLine.js @@ -30,14 +30,20 @@ mindplot.RelationshipLine.prototype.redraw = function() 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; + var defaultPoints = core.Utils.calculateDefaultControlPoints(sourcePosition, targetPosition); + ctrlPoints[0].x=sourcePosition.x - defaultPoints[0].x; + ctrlPoints[0].y=sourcePosition.y - defaultPoints[0].y; + ctrlPoints[1].x=targetPosition.x - defaultPoints[1].x; + ctrlPoints[1].y=targetPosition.y - defaultPoints[1].y; } - sPos = core.Utils.calculateRelationShipPointCoordinates(sourceTopic,ctrlPoints[0]); - tPos = core.Utils.calculateRelationShipPointCoordinates(targetTopic,ctrlPoints[1]); + var spoint = new core.Point(); + spoint.x=parseInt(ctrlPoints[0].x)+parseInt(sourcePosition.x); + spoint.y=parseInt(ctrlPoints[0].y)+parseInt(sourcePosition.y); + var tpoint = new core.Point(); + tpoint.x=parseInt(ctrlPoints[1].x)+parseInt(targetPosition.x); + tpoint.y=parseInt(ctrlPoints[1].y)+parseInt(targetPosition.y); + sPos = core.Utils.calculateRelationShipPointCoordinates(sourceTopic,spoint); + tPos = core.Utils.calculateRelationShipPointCoordinates(targetTopic,tpoint); line2d.setFrom(sPos.x, sPos.y); line2d.setTo(tPos.x, tPos.y); diff --git a/mindplot/src/main/javascript/RelationshipModel.js b/mindplot/src/main/javascript/RelationshipModel.js index 337f3c83..87af3d0d 100644 --- a/mindplot/src/main/javascript/RelationshipModel.js +++ b/mindplot/src/main/javascript/RelationshipModel.js @@ -10,6 +10,7 @@ mindplot.RelationshipModel = function(fromNode, toNode) this._srcCtrlPoint=null; this._destCtrlPoint=null; this._endArrow=true; + this._ctrlPointRelative=false; }; diff --git a/web2d/src/main/javascript/peer/svg/CurvedLinePeer.js b/web2d/src/main/javascript/peer/svg/CurvedLinePeer.js index 66286ca4..7a0a16dc 100644 --- a/web2d/src/main/javascript/peer/svg/CurvedLinePeer.js +++ b/web2d/src/main/javascript/peer/svg/CurvedLinePeer.js @@ -36,6 +36,8 @@ web2d.peer.svg.CurvedLinePeer.prototype.setSrcControlPoint = function(control){ this._customControlPoint_1 = true; if(core.Utils.isDefined(control.x)){ this._control1 = control; + this._control1.x = parseInt(this._control1.x); + this._control1.y = parseInt(this._control1.y) } this._updatePath(); }; @@ -44,6 +46,8 @@ web2d.peer.svg.CurvedLinePeer.prototype.setDestControlPoint = function(control){ this._customControlPoint_2 = true; if(core.Utils.isDefined(control.x)){ this._control2 = control; + this._control2.x = parseInt(this._control2.x); + this._control2.y = parseInt(this._control2.y) } this._updatePath(); }; @@ -72,23 +76,15 @@ web2d.peer.svg.CurvedLinePeer.prototype.getControlPoints = function(){ 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._x1 = parseInt(x1); + this._y1 = parseInt(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._x2 = parseInt(x2); + this._y2 = parseInt(y2); this._updatePath(); }; @@ -153,8 +149,8 @@ web2d.peer.svg.CurvedLinePeer.prototype._updatePath = function(avoidControlPoint 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 y0 = this._control2.y; + var x0 = this._control2.x; var x2=x0+y0; var y2 = y0-x0; var x3 = x0-y0; @@ -171,13 +167,13 @@ web2d.peer.svg.CurvedLinePeer.prototype._updatePath = function(avoidControlPoint 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+" " + +" C"+(this._control1.x+this._x1)+","+(this._control1.y+this._y1)+" " + +(this._control2.x+this._x2)+","+(this._control2.y+this._y2)+" " +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._control2.x+this._x2)+","+(this._control2.y+this._y2+3)+" " + +(this._control1.x+this._x1)+","+(this._control1.y+this._y1+3)+" " + +this._x1+","+(this._y1+3)+" Z" :"" )+ (this._showArrow?" " diff --git a/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindImporter.java b/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindImporter.java index a00dd0c6..f5d1047d 100755 --- a/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindImporter.java +++ b/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindImporter.java @@ -76,6 +76,7 @@ public class FreemindImporter mindmapMap.setName(mapName); nodesMap = new HashMap(); relationships = new ArrayList(); + nodesMap.put(centralNode.getID(), centralTopic); addTopicFromNode(centralNode,centralTopic); fixCentralTopicChildOrder(centralTopic); @@ -103,13 +104,53 @@ public class FreemindImporter List mapRelationships = mindmapMap.getRelationship(); for(RelationshipType relationship : relationships){ relationship.setId(String.valueOf(currentId++)); + + fixRelationshipControlPoints(relationship); + + //Fix dest ID String destId = relationship.getDestTopicId(); TopicType destTopic = nodesMap.get(destId); relationship.setDestTopicId(destTopic.getId()); + //Fix src ID + String srcId = relationship.getSrcTopicId(); + TopicType srcTopic = nodesMap.get(srcId); + relationship.setSrcTopicId(srcTopic.getId()); + mapRelationships.add(relationship); } } + private void fixRelationshipControlPoints(RelationshipType relationship) { + //Both relationship node's ids should be freemind ones at this point. + TopicType srcTopic = nodesMap.get(relationship.getSrcTopicId()); + TopicType destTopicType = nodesMap.get(relationship.getDestTopicId()); + + //Fix x coord + if(isOnLeftSide(srcTopic)){ + String[] srcCtrlPoint = relationship.getSrcCtrlPoint().split(","); + int x = Integer.valueOf(srcCtrlPoint[0]) * -1; + relationship.setSrcCtrlPoint(x+","+srcCtrlPoint[1]); + } + if(isOnLeftSide(destTopicType)){ + String[] destCtrlPoint = relationship.getDestCtrlPoint().split(","); + int x = Integer.valueOf(destCtrlPoint[0]) * -1; + relationship.setDestCtrlPoint(x+","+destCtrlPoint[1]); + } + + //Fix y coord + if(srcTopic.getOrder()%2!=0){ //Odd order. + String[] srcCtrlPoint = relationship.getSrcCtrlPoint().split(","); + int y = Integer.valueOf(srcCtrlPoint[1]) * -1; + relationship.setSrcCtrlPoint(srcCtrlPoint[0]+","+y); + } + if(destTopicType.getOrder()%2!=0){ //Odd order. + String[] destCtrlPoint = relationship.getDestCtrlPoint().split(","); + int y = Integer.valueOf(destCtrlPoint[1]) * -1; + relationship.setDestCtrlPoint(destCtrlPoint[0]+","+y); + } + + } + private void fixCentralTopicChildOrder(TopicType centralTopic){ List topics = centralTopic.getTopic(); List leftTopics = new ArrayList(); @@ -209,6 +250,9 @@ public class FreemindImporter link.setUrl(url); newTopic.setLink(link); } + if(POSITION_LEFT.equals(mainNode.getPOSITION())){ + node.setPOSITION(POSITION_LEFT); + } setNodePropertiesToTopic(newTopic, node); addTopicFromNode(node,newTopic); if (!newTopic.equals(topic)) @@ -272,12 +316,13 @@ public class FreemindImporter final Arrowlink arrow = (Arrowlink) freemindNode; RelationshipType relationship = mindmapObjectFactory.createRelationshipType(); String destId = arrow.getDESTINATION(); - relationship.setSrcTopicId(currentTopic.getId()); + relationship.setSrcTopicId(mainNode.getID()); relationship.setDestTopicId(destId); - /*String[] inclination = arrow.getENDINCLINATION().split(";"); + String[] inclination = arrow.getENDINCLINATION().split(";"); relationship.setDestCtrlPoint(inclination[0]+","+inclination[1]); inclination = arrow.getSTARTINCLINATION().split(";"); - relationship.setSrcCtrlPoint(inclination[0]+","+inclination[1]);*/ + relationship.setSrcCtrlPoint(inclination[0]+","+inclination[1]); + //relationship.setCtrlPointRelative(true); relationship.setEndArrow(!arrow.getENDARROW().equals("None")); relationship.setLineType("3"); relationships.add(relationship); diff --git a/wise-webapp/src/main/java/com/wisemapping/xml/mindmap.xsd b/wise-webapp/src/main/java/com/wisemapping/xml/mindmap.xsd index 7928ff60..37d66613 100755 --- a/wise-webapp/src/main/java/com/wisemapping/xml/mindmap.xsd +++ b/wise-webapp/src/main/java/com/wisemapping/xml/mindmap.xsd @@ -59,6 +59,7 @@ + \ No newline at end of file diff --git a/wise-webapp/src/main/java/com/wisemapping/xml/mindmap/Icon.java b/wise-webapp/src/main/java/com/wisemapping/xml/mindmap/Icon.java index 4ad6e984..835f6c66 100644 --- a/wise-webapp/src/main/java/com/wisemapping/xml/mindmap/Icon.java +++ b/wise-webapp/src/main/java/com/wisemapping/xml/mindmap/Icon.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.01.11 at 02:17:09 PM ART +// Generated on: 2011.01.11 at 06:58:42 PM ART // diff --git a/wise-webapp/src/main/java/com/wisemapping/xml/mindmap/Link.java b/wise-webapp/src/main/java/com/wisemapping/xml/mindmap/Link.java index 665ab719..df942f75 100644 --- a/wise-webapp/src/main/java/com/wisemapping/xml/mindmap/Link.java +++ b/wise-webapp/src/main/java/com/wisemapping/xml/mindmap/Link.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.01.11 at 02:17:09 PM ART +// Generated on: 2011.01.11 at 06:58:42 PM ART // diff --git a/wise-webapp/src/main/java/com/wisemapping/xml/mindmap/Map.java b/wise-webapp/src/main/java/com/wisemapping/xml/mindmap/Map.java index 3a38b0fd..9ea916c4 100644 --- a/wise-webapp/src/main/java/com/wisemapping/xml/mindmap/Map.java +++ b/wise-webapp/src/main/java/com/wisemapping/xml/mindmap/Map.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.01.11 at 02:17:09 PM ART +// Generated on: 2011.01.11 at 06:58:42 PM ART // diff --git a/wise-webapp/src/main/java/com/wisemapping/xml/mindmap/Note.java b/wise-webapp/src/main/java/com/wisemapping/xml/mindmap/Note.java index d8f1556e..f140a6b6 100644 --- a/wise-webapp/src/main/java/com/wisemapping/xml/mindmap/Note.java +++ b/wise-webapp/src/main/java/com/wisemapping/xml/mindmap/Note.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.01.11 at 02:17:09 PM ART +// Generated on: 2011.01.11 at 06:58:42 PM ART // diff --git a/wise-webapp/src/main/java/com/wisemapping/xml/mindmap/ObjectFactory.java b/wise-webapp/src/main/java/com/wisemapping/xml/mindmap/ObjectFactory.java index 94d6b9f2..8b3ea937 100644 --- a/wise-webapp/src/main/java/com/wisemapping/xml/mindmap/ObjectFactory.java +++ b/wise-webapp/src/main/java/com/wisemapping/xml/mindmap/ObjectFactory.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.01.11 at 02:17:09 PM ART +// Generated on: 2011.01.11 at 06:58:42 PM ART // @@ -42,11 +42,11 @@ public class ObjectFactory { } /** - * Create an instance of {@link RelationshipType } + * Create an instance of {@link Note } * */ - public RelationshipType createRelationshipType() { - return new RelationshipType(); + public Note createNote() { + return new Note(); } /** @@ -74,11 +74,11 @@ public class ObjectFactory { } /** - * Create an instance of {@link Note } + * Create an instance of {@link RelationshipType } * */ - public Note createNote() { - return new Note(); + public RelationshipType createRelationshipType() { + return new RelationshipType(); } /** diff --git a/wise-webapp/src/main/java/com/wisemapping/xml/mindmap/RelationshipType.java b/wise-webapp/src/main/java/com/wisemapping/xml/mindmap/RelationshipType.java index 620b0642..38d2ced5 100644 --- a/wise-webapp/src/main/java/com/wisemapping/xml/mindmap/RelationshipType.java +++ b/wise-webapp/src/main/java/com/wisemapping/xml/mindmap/RelationshipType.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.01.11 at 02:17:09 PM ART +// Generated on: 2011.01.11 at 06:58:42 PM ART // @@ -30,6 +30,7 @@ import javax.xml.bind.annotation.XmlType; * <attribute name="srcCtrlPoint" type="{http://www.w3.org/2001/XMLSchema}string" /> * <attribute name="destCtrlPoint" type="{http://www.w3.org/2001/XMLSchema}string" /> * <attribute name="endArrow" type="{http://www.w3.org/2001/XMLSchema}boolean" /> + * <attribute name="ctrlPointRelative" type="{http://www.w3.org/2001/XMLSchema}boolean" /> * </restriction> * </complexContent> * </complexType> @@ -55,6 +56,8 @@ public class RelationshipType { protected String destCtrlPoint; @XmlAttribute protected Boolean endArrow; + @XmlAttribute + protected Boolean ctrlPointRelative; /** * Gets the value of the id property. @@ -224,4 +227,28 @@ public class RelationshipType { this.endArrow = value; } + /** + * Gets the value of the ctrlPointRelative property. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isCtrlPointRelative() { + return ctrlPointRelative; + } + + /** + * Sets the value of the ctrlPointRelative property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setCtrlPointRelative(Boolean value) { + this.ctrlPointRelative = value; + } + } diff --git a/wise-webapp/src/main/java/com/wisemapping/xml/mindmap/TopicType.java b/wise-webapp/src/main/java/com/wisemapping/xml/mindmap/TopicType.java index b4a50d14..2e7f0632 100644 --- a/wise-webapp/src/main/java/com/wisemapping/xml/mindmap/TopicType.java +++ b/wise-webapp/src/main/java/com/wisemapping/xml/mindmap/TopicType.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.01.11 at 02:17:09 PM ART +// Generated on: 2011.01.11 at 06:58:42 PM ART //