Adding start and end arrows to relationship lines

This commit is contained in:
Pablo Luna 2011-01-16 11:48:53 -03:00
parent 4777ccf6fb
commit 8ddb66eebb
15 changed files with 107 additions and 45 deletions

View File

@ -652,7 +652,8 @@ mindplot.MindmapDesigner.prototype._buildRelationship = function (model) {
relationLine.getLine().setDashed(3,2); relationLine.getLine().setDashed(3,2);
relationLine.getLine().setShowArrow(model.getEndArrow()); relationLine.getLine().setShowEndArrow(model.getEndArrow());
relationLine.getLine().setShowStartArrow(model.getStartArrow());
relationLine.setModel(model); relationLine.setModel(model);
//Add Listeners //Add Listeners

View File

@ -10,6 +10,7 @@ mindplot.RelationshipModel = function(fromNode, toNode)
this._srcCtrlPoint=null; this._srcCtrlPoint=null;
this._destCtrlPoint=null; this._destCtrlPoint=null;
this._endArrow=true; this._endArrow=true;
this._startArrow=false;
this._ctrlPointRelative=false; this._ctrlPointRelative=false;
}; };
@ -58,6 +59,14 @@ mindplot.RelationshipModel.prototype.setEndArrow= function(endArrow){
this._endArrow = endArrow; this._endArrow = endArrow;
}; };
mindplot.RelationshipModel.prototype.getStartArrow= function(){
return this._startArrow;
};
mindplot.RelationshipModel.prototype.setStartArrow= function(startArrow){
this._startArrow = startArrow;
};
mindplot.RelationshipModel.prototype.clone = function(model){ mindplot.RelationshipModel.prototype.clone = function(model){
var result = new mindplot.RelationshipModel(this._fromNode, this._toNode); var result = new mindplot.RelationshipModel(this._fromNode, this._toNode);
result._id = this._id; result._id = this._id;
@ -65,6 +74,7 @@ mindplot.RelationshipModel.prototype.clone = function(model){
result._srcCtrlPoint = this._srcCtrlPoint; result._srcCtrlPoint = this._srcCtrlPoint;
result._destCtrlPoint = this._destCtrlPoint; result._destCtrlPoint = this._destCtrlPoint;
result._endArrow = this._endArrow; result._endArrow = this._endArrow;
result._startArrow = this._startArrow;
return result; return result;
}; };

View File

@ -216,6 +216,7 @@ mindplot.XMLMindmapSerializer_Pela.prototype._relationshipToXML = function(docum
} }
} }
relationDom.setAttribute("endArrow",relationship.getEndArrow()); relationDom.setAttribute("endArrow",relationship.getEndArrow());
relationDom.setAttribute("startArrow",relationship.getStartArrow());
return relationDom; return relationDom;
}; };
@ -382,6 +383,7 @@ mindplot.XMLMindmapSerializer_Pela.prototype._deserializeRelationship = function
var srcCtrlPoint = domElement.getAttribute("srcCtrlPoint"); var srcCtrlPoint = domElement.getAttribute("srcCtrlPoint");
var destCtrlPoint = domElement.getAttribute("destCtrlPoint"); var destCtrlPoint = domElement.getAttribute("destCtrlPoint");
var endArrow = domElement.getAttribute("endArrow"); var endArrow = domElement.getAttribute("endArrow");
var startArrow = domElement.getAttribute("startArrow");
var model = mindmap.createRelationship(srcId, destId); var model = mindmap.createRelationship(srcId, destId);
model.setLineType(lineType); model.setLineType(lineType);
if(core.Utils.isDefined(srcCtrlPoint) && srcCtrlPoint!=""){ if(core.Utils.isDefined(srcCtrlPoint) && srcCtrlPoint!=""){
@ -390,7 +392,8 @@ mindplot.XMLMindmapSerializer_Pela.prototype._deserializeRelationship = function
if(core.Utils.isDefined(destCtrlPoint) && destCtrlPoint!=""){ if(core.Utils.isDefined(destCtrlPoint) && destCtrlPoint!=""){
model.setDestCtrlPoint(core.Point.fromString(destCtrlPoint)); model.setDestCtrlPoint(core.Point.fromString(destCtrlPoint));
} }
model.setEndArrow(endArrow); model.setEndArrow(endArrow=="true");
model.setStartArrow(startArrow=="true");
return model; return model;
}; };

View File

@ -54,12 +54,20 @@ web2d.CurvedLine.prototype.getTo = function()
return this._peer.getTo(); return this._peer.getTo();
}; };
web2d.CurvedLine.prototype.setShowArrow = function(visible){ web2d.CurvedLine.prototype.setShowEndArrow = function(visible){
this._peer.setShowArrow(visible); this._peer.setShowEndArrow(visible);
}; };
web2d.CurvedLine.prototype.isShowArrow = function(){ web2d.CurvedLine.prototype.isShowEndArrow = function(){
return this._peer.isShowArrow(); return this._peer.isShowEndArrow();
};
web2d.CurvedLine.prototype.setShowStartArrow = function(visible){
this._peer.setShowStartArrow(visible);
};
web2d.CurvedLine.prototype.isShowStartArrow = function(){
return this._peer.isShowStartArrow();
}; };
web2d.CurvedLine.prototype.setSrcControlPoint = function(control){ web2d.CurvedLine.prototype.setSrcControlPoint = function(control){

View File

@ -132,13 +132,22 @@ web2d.peer.svg.CurvedLinePeer.prototype.getLineStyle = function (){
}; };
web2d.peer.svg.CurvedLinePeer.prototype.setShowArrow = function(visible){ web2d.peer.svg.CurvedLinePeer.prototype.setShowEndArrow = function(visible){
this._showArrow =visible; this._showEndArrow =visible;
this.updateLine(); this.updateLine();
}; };
web2d.peer.svg.CurvedLinePeer.prototype.isShowArrow = function(){ web2d.peer.svg.CurvedLinePeer.prototype.isShowEndArrow = function(){
return this._showArrow; return this._showEndArrow;
};
web2d.peer.svg.CurvedLinePeer.prototype.setShowStartArrow = function(visible){
this._showStartArrow =visible;
this.updateLine();
};
web2d.peer.svg.CurvedLinePeer.prototype.isShowStartArrow = function(){
return this._showStartArrow;
}; };
@ -146,7 +155,7 @@ web2d.peer.svg.CurvedLinePeer.prototype._updatePath = function(avoidControlPoint
{ {
this._calculateAutoControlPoints(avoidControlPointFix); this._calculateAutoControlPoints(avoidControlPointFix);
var x,y, xp, yp; var x,y, xp, yp;
if(this._showArrow){ if(this._showEndArrow){
if(this._control2.y == 0) if(this._control2.y == 0)
this._control2.y=1; this._control2.y=1;
var y0 = this._control2.y; var y0 = this._control2.y;
@ -166,7 +175,35 @@ web2d.peer.svg.CurvedLinePeer.prototype._updatePath = function(avoidControlPoint
xp *=Math.sign(x3); xp *=Math.sign(x3);
yp = (x3==0?l*Math.sign(y3):mp*xp); yp = (x3==0?l*Math.sign(y3):mp*xp);
} }
var path = "M"+this._x1+","+this._y1 var xs2,ys2, xp2, yp2;
if(this._showStartArrow){
if(this._control1.y == 0)
this._control1.y=1;
var y02 = this._control1.y;
var x02 = this._control1.x;
var x22=x02+y02;
var y22 = y02-x02;
var x32 = x02-y02;
var y32 = y02+x02;
var m2 = y22/x22;
var mp2 = y32/x32;
var l2 = 6;
var pow2 = Math.pow;
xs2 = (x22==0?0:Math.sqrt(pow2(l2,2)/(1+pow2(m2,2))));
xs2 *=Math.sign(x22);
ys2 = (x22==0?l2*Math.sign(y22):m2*xs2);
xp2 = (x32==0?0:Math.sqrt(pow2(l2,2)/(1+pow2(mp2,2))));
xp2 *=Math.sign(x32);
yp2 = (x32==0?l2*Math.sign(y32):mp2*xp2);
}
var path = (this._showStartArrow?" "
+"M"+this._x1+","+this._y1+" "
+"L"+(xs2+this._x1)+","+(ys2+this._y1)
+"M"+this._x1+","+this._y1+" "
+"L"+(xp2+this._x1)+","+(yp2+this._y1)
:"")+
"M"+this._x1+","+this._y1
+" C"+(this._control1.x+this._x1)+","+(this._control1.y+this._y1)+" " +" C"+(this._control1.x+this._x1)+","+(this._control1.y+this._y1)+" "
+(this._control2.x+this._x2)+","+(this._control2.y+this._y2)+" " +(this._control2.x+this._x2)+","+(this._control2.y+this._y2)+" "
+this._x2+","+this._y2+ +this._x2+","+this._y2+
@ -176,7 +213,7 @@ web2d.peer.svg.CurvedLinePeer.prototype._updatePath = function(avoidControlPoint
+this._x1+","+(this._y1+3)+" Z" +this._x1+","+(this._y1+3)+" Z"
:"" :""
)+ )+
(this._showArrow?" " (this._showEndArrow?" "
+"M"+this._x2+","+this._y2+" " +"M"+this._x2+","+this._y2+" "
+"L"+(x+this._x2)+","+(y+this._y2) +"L"+(x+this._x2)+","+(y+this._y2)
+"M"+this._x2+","+this._y2+" " +"M"+this._x2+","+this._y2+" "

View File

@ -99,6 +99,8 @@ public class FreemindExporter
arrowlink.setDESTINATION(dstNode.getID()); arrowlink.setDESTINATION(dstNode.getID());
if(relationship.isEndArrow()) if(relationship.isEndArrow())
arrowlink.setENDARROW("Default"); arrowlink.setENDARROW("Default");
if(relationship.isStartArrow())
arrowlink.setSTARTARROW("Default");
List<Object> cloudOrEdge = srcNode.getArrowlinkOrCloudOrEdge(); List<Object> cloudOrEdge = srcNode.getArrowlinkOrCloudOrEdge();
cloudOrEdge.add(arrowlink); cloudOrEdge.add(arrowlink);
} }

View File

@ -323,7 +323,8 @@ public class FreemindImporter
inclination = arrow.getSTARTINCLINATION().split(";"); inclination = arrow.getSTARTINCLINATION().split(";");
relationship.setSrcCtrlPoint(inclination[0]+","+inclination[1]); relationship.setSrcCtrlPoint(inclination[0]+","+inclination[1]);
//relationship.setCtrlPointRelative(true); //relationship.setCtrlPointRelative(true);
relationship.setEndArrow(!arrow.getENDARROW().equals("None")); relationship.setEndArrow(!arrow.getENDARROW().toLowerCase().equals("none"));
relationship.setStartArrow(!arrow.getSTARTARROW().toLowerCase().equals("none"));
relationship.setLineType("3"); relationship.setLineType("3");
relationships.add(relationship); relationships.add(relationship);
} }

View File

@ -59,7 +59,7 @@
<xsd:attribute name="srcCtrlPoint" type="xsd:string"/> <xsd:attribute name="srcCtrlPoint" type="xsd:string"/>
<xsd:attribute name="destCtrlPoint" type="xsd:string"/> <xsd:attribute name="destCtrlPoint" type="xsd:string"/>
<xsd:attribute name="endArrow" type="xsd:boolean"/> <xsd:attribute name="endArrow" type="xsd:boolean"/>
<xsd:attribute name="ctrlPointRelative" type="xsd:boolean"/> <xsd:attribute name="startArrow" type="xsd:boolean"/>
</xsd:complexType> </xsd:complexType>
</xsd:schema> </xsd:schema>

View File

@ -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 // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema. // Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2011.01.11 at 06:58:42 PM ART // Generated on: 2011.01.16 at 11:06:29 AM ART
// //

View File

@ -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 // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema. // Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2011.01.11 at 06:58:42 PM ART // Generated on: 2011.01.16 at 11:06:29 AM ART
// //

View File

@ -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 // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema. // Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2011.01.11 at 06:58:42 PM ART // Generated on: 2011.01.16 at 11:06:29 AM ART
// //

View File

@ -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 // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema. // Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2011.01.11 at 06:58:42 PM ART // Generated on: 2011.01.16 at 11:06:29 AM ART
// //

View File

@ -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 // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema. // Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2011.01.11 at 06:58:42 PM ART // Generated on: 2011.01.16 at 11:06:29 AM ART
// //
@ -50,19 +50,11 @@ public class ObjectFactory {
} }
/** /**
* Create an instance of {@link Map } * Create an instance of {@link Icon }
* *
*/ */
public Map createMap() { public Icon createIcon() {
return new Map(); return new Icon();
}
/**
* Create an instance of {@link Link }
*
*/
public Link createLink() {
return new Link();
} }
/** /**
@ -73,6 +65,14 @@ public class ObjectFactory {
return new TopicType(); return new TopicType();
} }
/**
* Create an instance of {@link Map }
*
*/
public Map createMap() {
return new Map();
}
/** /**
* Create an instance of {@link RelationshipType } * Create an instance of {@link RelationshipType }
* *
@ -82,11 +82,11 @@ public class ObjectFactory {
} }
/** /**
* Create an instance of {@link Icon } * Create an instance of {@link Link }
* *
*/ */
public Icon createIcon() { public Link createLink() {
return new Icon(); return new Link();
} }
/** /**

View File

@ -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 // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema. // Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2011.01.11 at 06:58:42 PM ART // Generated on: 2011.01.16 at 11:06:29 AM ART
// //
@ -30,7 +30,7 @@ import javax.xml.bind.annotation.XmlType;
* &lt;attribute name="srcCtrlPoint" type="{http://www.w3.org/2001/XMLSchema}string" /> * &lt;attribute name="srcCtrlPoint" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;attribute name="destCtrlPoint" type="{http://www.w3.org/2001/XMLSchema}string" /> * &lt;attribute name="destCtrlPoint" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;attribute name="endArrow" type="{http://www.w3.org/2001/XMLSchema}boolean" /> * &lt;attribute name="endArrow" type="{http://www.w3.org/2001/XMLSchema}boolean" />
* &lt;attribute name="ctrlPointRelative" type="{http://www.w3.org/2001/XMLSchema}boolean" /> * &lt;attribute name="startArrow" type="{http://www.w3.org/2001/XMLSchema}boolean" />
* &lt;/restriction> * &lt;/restriction>
* &lt;/complexContent> * &lt;/complexContent>
* &lt;/complexType> * &lt;/complexType>
@ -57,7 +57,7 @@ public class RelationshipType {
@XmlAttribute @XmlAttribute
protected Boolean endArrow; protected Boolean endArrow;
@XmlAttribute @XmlAttribute
protected Boolean ctrlPointRelative; protected Boolean startArrow;
/** /**
* Gets the value of the id property. * Gets the value of the id property.
@ -228,27 +228,27 @@ public class RelationshipType {
} }
/** /**
* Gets the value of the ctrlPointRelative property. * Gets the value of the startArrow property.
* *
* @return * @return
* possible object is * possible object is
* {@link Boolean } * {@link Boolean }
* *
*/ */
public Boolean isCtrlPointRelative() { public Boolean isStartArrow() {
return ctrlPointRelative; return startArrow;
} }
/** /**
* Sets the value of the ctrlPointRelative property. * Sets the value of the startArrow property.
* *
* @param value * @param value
* allowed object is * allowed object is
* {@link Boolean } * {@link Boolean }
* *
*/ */
public void setCtrlPointRelative(Boolean value) { public void setStartArrow(Boolean value) {
this.ctrlPointRelative = value; this.startArrow = value;
} }
} }

View File

@ -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 // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema. // Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2011.01.11 at 06:58:42 PM ART // Generated on: 2011.01.16 at 11:06:29 AM ART
// //