Making curved line control point relative and Importing Freemind relationship lines curve control points

This commit is contained in:
Pablo Luna
2011-01-14 14:10:15 -03:00
parent 8db75a940d
commit 4777ccf6fb
13 changed files with 124 additions and 48 deletions

View File

@@ -76,6 +76,7 @@ public class FreemindImporter
mindmapMap.setName(mapName);
nodesMap = new HashMap<String, TopicType>();
relationships = new ArrayList<RelationshipType>();
nodesMap.put(centralNode.getID(), centralTopic);
addTopicFromNode(centralNode,centralTopic);
fixCentralTopicChildOrder(centralTopic);
@@ -103,13 +104,53 @@ public class FreemindImporter
List<RelationshipType> 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<TopicType> topics = centralTopic.getTopic();
List<TopicType> leftTopics = new ArrayList<TopicType>();
@@ -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);

View File

@@ -59,6 +59,7 @@
<xsd:attribute name="srcCtrlPoint" type="xsd:string"/>
<xsd:attribute name="destCtrlPoint" type="xsd:string"/>
<xsd:attribute name="endArrow" type="xsd:boolean"/>
<xsd:attribute name="ctrlPointRelative" type="xsd:boolean"/>
</xsd:complexType>
</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
// 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.
// Generated on: 2011.01.11 at 02:17:09 PM ART
// Generated on: 2011.01.11 at 06:58:42 PM 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
// 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.
// Generated on: 2011.01.11 at 02:17:09 PM ART
// Generated on: 2011.01.11 at 06:58:42 PM 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
// 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.
// Generated on: 2011.01.11 at 02:17:09 PM ART
// Generated on: 2011.01.11 at 06:58:42 PM 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
// 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.
// Generated on: 2011.01.11 at 02:17:09 PM ART
// Generated on: 2011.01.11 at 06:58:42 PM 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
// 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.
// 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();
}
/**

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
// 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.
// 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;
* &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="endArrow" type="{http://www.w3.org/2001/XMLSchema}boolean" />
* &lt;attribute name="ctrlPointRelative" type="{http://www.w3.org/2001/XMLSchema}boolean" />
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/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;
}
}

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
// 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.
// Generated on: 2011.01.11 at 02:17:09 PM ART
// Generated on: 2011.01.11 at 06:58:42 PM ART
//