fix vertical order when export to freemind versions.

This commit is contained in:
Claudio Barril 2014-09-07 16:10:06 -03:00
parent 26a18ae7d0
commit 2a121f91d2
2 changed files with 20 additions and 0 deletions

View File

@ -42,6 +42,7 @@ import java.io.OutputStream;
import java.io.ByteArrayInputStream;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -136,6 +137,7 @@ public class FreemindExporter
private void addNodeFromTopic(@NotNull final TopicType mainTopic, @NotNull final Node destNode) throws IOException, SAXException, ParserConfigurationException {
final List<TopicType> currentTopic = mainTopic.getTopic();
Collections.sort(currentTopic, new VerticalPositionComparator());
for (TopicType topicType : currentTopic) {
final Node newNode = objectFactory.createNode();
nodesMap.put(topicType.getId(), newNode);

View File

@ -0,0 +1,18 @@
package com.wisemapping.exporter;
import com.wisemapping.jaxb.wisemap.TopicType;
import java.util.Comparator;
public class VerticalPositionComparator implements Comparator<TopicType> {
@Override
public int compare(TopicType o1, TopicType o2) {
final String myPosition = o1.getPosition();
final String otherPosition = o2.getPosition();
int myPositionY = Integer.parseInt(myPosition.split(",")[1]);
int otherPositionY = Integer.parseInt(otherPosition.split(",")[1]);
return myPositionY - otherPositionY;
}
}