Fix export of links in root node.

This commit is contained in:
Paulo Gustavo Veiga 2011-03-27 19:41:45 -03:00
parent c74adcbf54
commit cff3d7cc8a
4 changed files with 758 additions and 728 deletions

View File

@ -122,7 +122,7 @@ public class FreemindExporter
setTopicPropertiesToNode(newNode, topicType);
destNode.getArrowlinkOrCloudOrEdge().add(newNode);
addNodeFromTopic(topicType, newNode);
String position = topicType.getPosition();
final String position = topicType.getPosition();
if (position != null) {
String xPos = position.split(",")[0];
int x = Integer.valueOf(xPos);
@ -144,10 +144,13 @@ public class FreemindExporter
freemindNode.setSTYLE(style);
}
addIconNode(freemindNode, mindmapTopic);
addLinkNode(freemindNode, mindmapTopic);
addFontNode(freemindNode, mindmapTopic);
addEdgeNode(freemindNode, mindmapTopic);
addNote(freemindNode, mindmapTopic);
Boolean shrink = mindmapTopic.isShrink();
if (shrink != null && shrink)
freemindNode.setFOLDED(String.valueOf(shrink));

View File

@ -77,6 +77,7 @@ public class FreemindImporter
centralTopic.setShape(ShapeStyle.ELIPSE.getStyle());
mindmapMap.getTopic().add(centralTopic);
mindmapMap.setName(mapName);
nodesMap = new HashMap<String, TopicType>();
relationships = new ArrayList<RelationshipType>();
nodesMap.put(centralNode.getID(), centralTopic);
@ -232,7 +233,7 @@ public class FreemindImporter
return x < 0;
}
private void addTopicFromNode(Node mainNode, TopicType topic) {
private void addTopicFromNode(@NotNull Node mainNode, @NotNull TopicType topic) {
final List<Object> freemindNodes = mainNode.getArrowlinkOrCloudOrEdge();
TopicType currentTopic = topic;
int order = 0;
@ -244,25 +245,30 @@ public class FreemindImporter
newTopic.setId(String.valueOf(currentId++));
nodesMap.put(node.getID(), newTopic); //Lets use freemind id temporarily. This will be fixed when adding relationship to the map.
newTopic.setOrder(order++);
String url = node.getLINK();
// Is there any link ?
final String url = node.getLINK();
if (url != null) {
final Link link = new Link();
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)) {
topic.getTopic().add(newTopic);
}
currentTopic = newTopic;
} else if (freemindNode instanceof Font) {
final Font font = (Font) freemindNode;
final String fontStyle = generateFontStyle(mainNode, font);
if (fontStyle!=null) {
if (fontStyle != null) {
currentTopic.setFontStyle(fontStyle);
}
} else if (freemindNode instanceof Edge) {
@ -380,31 +386,44 @@ public class FreemindImporter
return text.toString();
}
private void setNodePropertiesToTopic(com.wisemapping.xml.mindmap.TopicType mindmapTopic, com.wisemapping.xml.freemind.Node freemindNode) {
mindmapTopic.setText(freemindNode.getTEXT());
mindmapTopic.setBgColor(freemindNode.getBACKGROUNDCOLOR());
private void setNodePropertiesToTopic(@NotNull com.wisemapping.xml.mindmap.TopicType wiseTopic, @NotNull com.wisemapping.xml.freemind.Node freemindNode) {
wiseTopic.setText(freemindNode.getTEXT());
wiseTopic.setBgColor(freemindNode.getBACKGROUNDCOLOR());
final String shape = getShapeFormFromNode(freemindNode);
mindmapTopic.setShape(shape);
wiseTopic.setShape(shape);
int pos = 1;
if (POSITION_LEFT.equals(freemindNode.getPOSITION())) {
pos = -1;
}
Integer orderPosition = mindmapTopic.getOrder() != null ? mindmapTopic.getOrder() : 0;
Integer orderPosition = wiseTopic.getOrder() != null ? wiseTopic.getOrder() : 0;
int position = pos * 200 + (orderPosition + 1) * 10;
mindmapTopic.setPosition(position + "," + 200 * orderPosition);
wiseTopic.setPosition(position + "," + 200 * orderPosition);
final String fontStyle = generateFontStyle(freemindNode, null);
if (fontStyle!=null) {
mindmapTopic.setFontStyle(fontStyle);
}
Boolean folded = Boolean.valueOf(freemindNode.getFOLDED());
if (folded) {
mindmapTopic.setShrink(folded);
}
if (fontStyle != null) {
wiseTopic.setFontStyle(fontStyle);
}
private @Nullable String generateFontStyle(@NotNull Node node, @Nullable Font font) {
// Is there any link ?
final String url = freemindNode.getLINK();
if (url != null) {
final Link link = new Link();
link.setUrl(url);
wiseTopic.setLink(link);
}
final Boolean folded = Boolean.valueOf(freemindNode.getFOLDED());
if (folded) {
wiseTopic.setShrink(folded);
}
}
private
@Nullable
String generateFontStyle(@NotNull Node node, @Nullable Font font) {
/*
* MindmapFont format : fontName ; size ; color ; bold; italic;
* eg: Verdana;10;#ffffff;bold;italic;

View File

@ -1,4 +1,12 @@
<map version="0.9.0">
<!-- To view this file, download free mind mapping software FreeMind from http://freemind.sourceforge.net -->
<node CREATED="1301250606816" ID="ID_189563190" LINK="http://www.google.com" MODIFIED="1301250665708" TEXT="Node Links"/>
<node CREATED="1301250606816" ID="ID_189563190" LINK="http://www.google.com" MODIFIED="1301265199448" TEXT="Node Links">
<icon BUILTIN="closed"/>
<node CREATED="1301265119915" FOLDED="true" ID="ID_955581041" LINK="http://www.bing.com" MODIFIED="1301265556534" POSITION="right" TEXT="Link Topic">
<icon BUILTIN="info"/>
<node CREATED="1301265126777" ID="ID_1127858248" LINK="http://bing.com" MODIFIED="1301265269136" TEXT="Link Topic Topic">
<icon BUILTIN="messagebox_warning"/>
</node>
</node>
</node>
</map>

View File

@ -1 +1 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><map version="0.9.0"><node TEXT="Node Links" STYLE="elipse" ID="ID_0"/></map>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><map version="0.9.0"><node TEXT="Node Links" STYLE="elipse" LINK="http://www.google.com" ID="ID_0"><icon BUILTIN="closed"/><node TEXT="Link Topic" POSITION="right" LINK="http://www.bing.com" ID="ID_1" FOLDED="true"><icon BUILTIN="info"/><node TEXT="Link Topic Topic" POSITION="right" LINK="http://bing.com" ID="ID_2"><icon BUILTIN="messagebox_warning"/></node></node></node></map>