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 e419e6fd..c02676a5 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 @@ -33,9 +33,7 @@ import com.wisemapping.jaxb.wisemap.Link; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jsoup.Jsoup; -import org.jsoup.nodes.*; import org.jsoup.nodes.Document; -import org.w3c.dom.*; import org.w3c.dom.Element; import javax.xml.bind.JAXBException; @@ -61,6 +59,7 @@ public class FreemindImporter public static final String NODE_TYPE = "NODE"; private com.wisemapping.jaxb.wisemap.ObjectFactory mindmapObjectFactory; private static final String POSITION_LEFT = "left"; + private static final String POSITION_RIGHT = "right"; private static final String BOLD = "bold"; private static final String ITALIC = "italic"; private static final String EMPTY_NOTE = ""; @@ -249,7 +248,7 @@ public class FreemindImporter if (depth != 1) { norder = order++; } else { - if (freeChild.getPOSITION().equals(POSITION_LEFT)) { + if (freeChild.getPOSITION() != null && freeChild.getPOSITION().equals(POSITION_LEFT)) { norder = firstLevelLeftOrder; firstLevelLeftOrder = firstLevelLeftOrder + 2; } else { @@ -260,8 +259,8 @@ public class FreemindImporter wiseChild.setOrder(norder); // Convert node position - int childrenCount = freeChilden.size(); - final String position = convertPosition(wiseParent, freeChild, depth, norder, childrenCount); + int childrenCountSameSide = getChildrenCountSameSide(freeChilden, freeChild); + final String position = convertPosition(wiseParent, freeChild, depth, norder, childrenCountSameSide); wiseChild.setPosition(position); // Convert the rest of the node properties ... @@ -351,6 +350,30 @@ public class FreemindImporter } } + private int getChildrenCountSameSide(@NotNull List freeChildren, Node freeChild) { + int result = 0; + String childSide = freeChild.getPOSITION(); + if (childSide == null) { + childSide = POSITION_RIGHT; + } + + // Count all the nodes of the same side ... + for (Object child : freeChildren) { + if (child instanceof Node) { + Node node = (Node) child; + + String side = node.getPOSITION(); + if (side == null) { + side = POSITION_RIGHT; + } + if (childSide.equals(side)) { + result++; + } + } + } + return result; + } + /** * Position is (x,y). * x values greater than 0 are right axis @@ -384,10 +407,10 @@ public class FreemindImporter // pair order numbers represent nodes at the right // odd order numbers represent nodes at the left if (order % 2 == 0) { - int multiplier = (int) ((order - Math.floor((childrenCount - 1) / 2)) * 2); + int multiplier = ((order + 1) - childrenCount) * 2; y = multiplier * ROOT_LEVEL_TOPIC_HEIGHT; } else { - int multiplier = (int) ((order - Math.floor(childrenCount / 2)) * 2); + int multiplier = (order - childrenCount) * 2; y = multiplier * ROOT_LEVEL_TOPIC_HEIGHT; } } else { diff --git a/wise-webapp/src/test/resources/data/freemind/basic.wxml b/wise-webapp/src/test/resources/data/freemind/basic.wxml index be867357..4a356961 100644 --- a/wise-webapp/src/test/resources/data/freemind/basic.wxml +++ b/wise-webapp/src/test/resources/data/freemind/basic.wxml @@ -2,27 +2,27 @@ - + - + - + - + - + - + - + - + diff --git a/wise-webapp/src/test/resources/data/freemind/bug.wxml b/wise-webapp/src/test/resources/data/freemind/bug.wxml index 1d7805bf..d0df12ee 100644 --- a/wise-webapp/src/test/resources/data/freemind/bug.wxml +++ b/wise-webapp/src/test/resources/data/freemind/bug.wxml @@ -2,141 +2,141 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/wise-webapp/src/test/resources/data/freemind/fonts.wxml b/wise-webapp/src/test/resources/data/freemind/fonts.wxml index 5c66d648..ff9703dc 100644 --- a/wise-webapp/src/test/resources/data/freemind/fonts.wxml +++ b/wise-webapp/src/test/resources/data/freemind/fonts.wxml @@ -13,7 +13,7 @@ - + diff --git a/wise-webapp/src/test/resources/data/freemind/i18n.wxml b/wise-webapp/src/test/resources/data/freemind/i18n.wxml index 678c2c6c..36d3d2a7 100644 --- a/wise-webapp/src/test/resources/data/freemind/i18n.wxml +++ b/wise-webapp/src/test/resources/data/freemind/i18n.wxml @@ -2,13 +2,13 @@ - + - + - + diff --git a/wise-webapp/src/test/resources/data/freemind/i18n2.wxml b/wise-webapp/src/test/resources/data/freemind/i18n2.wxml index 94ce5659..f35b6a75 100644 --- a/wise-webapp/src/test/resources/data/freemind/i18n2.wxml +++ b/wise-webapp/src/test/resources/data/freemind/i18n2.wxml @@ -6,7 +6,7 @@ - + diff --git a/wise-webapp/src/test/resources/data/freemind/icons.wxml b/wise-webapp/src/test/resources/data/freemind/icons.wxml index f36c8dd1..662aa487 100644 --- a/wise-webapp/src/test/resources/data/freemind/icons.wxml +++ b/wise-webapp/src/test/resources/data/freemind/icons.wxml @@ -2,7 +2,7 @@ - + @@ -40,7 +40,7 @@ - + @@ -80,7 +80,7 @@ - + @@ -111,7 +111,7 @@ - + @@ -132,7 +132,7 @@ - + @@ -161,7 +161,7 @@ - + @@ -190,7 +190,7 @@ - + @@ -269,7 +269,7 @@ - + diff --git a/wise-webapp/src/test/resources/data/freemind/links.wxml b/wise-webapp/src/test/resources/data/freemind/links.wxml index ff0d6497..3749d9d4 100644 --- a/wise-webapp/src/test/resources/data/freemind/links.wxml +++ b/wise-webapp/src/test/resources/data/freemind/links.wxml @@ -8,7 +8,7 @@ - + diff --git a/wise-webapp/src/test/resources/data/freemind/node-styles.wxml b/wise-webapp/src/test/resources/data/freemind/node-styles.wxml index 58a2ab7f..8c03902d 100644 --- a/wise-webapp/src/test/resources/data/freemind/node-styles.wxml +++ b/wise-webapp/src/test/resources/data/freemind/node-styles.wxml @@ -17,45 +17,45 @@ - + + position="-290,-100" shape="rectagle"> + position="-290,-75" shape="rounded rectagle"> + position="-290,-50" shape="rectagle"> + position="-290,-25" shape="rectagle"> - + + position="-290,0" shape="rectagle"> + position="-290,25" shape="rounded rectagle"> + position="-290,50" shape="rectagle"> + position="-290,75" shape="rectagle"> diff --git a/wise-webapp/src/test/resources/data/freemind/numerosity.wxml b/wise-webapp/src/test/resources/data/freemind/numerosity.wxml index a1a3b098..1a3cec59 100644 --- a/wise-webapp/src/test/resources/data/freemind/numerosity.wxml +++ b/wise-webapp/src/test/resources/data/freemind/numerosity.wxml @@ -2,7 +2,7 @@ - + @@ -131,58 +131,58 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/wise-webapp/src/test/resources/data/freemind/process.wxml b/wise-webapp/src/test/resources/data/freemind/process.wxml index b423097e..65e426bd 100644 --- a/wise-webapp/src/test/resources/data/freemind/process.wxml +++ b/wise-webapp/src/test/resources/data/freemind/process.wxml @@ -2,7 +2,7 @@ - + @@ -26,7 +26,7 @@ - + @@ -41,7 +41,7 @@ - + @@ -77,68 +77,68 @@ - + - + - + + position="380,-250" shape="rounded rectagle"> - + + position="380,-225" shape="rounded rectagle"> + position="290,-225" shape="rounded rectagle"> - + + position="290,-200" shape="rounded rectagle"> - + - + - + - + - + - + + position="380,-100" shape="rounded rectagle"> - + + position="290,-75" shape="rounded rectagle"> - + @@ -147,74 +147,74 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/wise-webapp/src/test/resources/data/freemind/richtextnode.wxml b/wise-webapp/src/test/resources/data/freemind/richtextnode.wxml index e8624c3e..c9d1a4f0 100644 --- a/wise-webapp/src/test/resources/data/freemind/richtextnode.wxml +++ b/wise-webapp/src/test/resources/data/freemind/richtextnode.wxml @@ -10,185 +10,185 @@ + position="290,-50" shape="line"> - + + position="380,-75" shape="line"> + position="380,-50" shape="line"> + position="380,-25" shape="line"> + position="290,-25" shape="rounded rectagle"> + position="380,-100" shape="rectagle"> + position="470,-150" shape="rectagle"> + position="470,-125" shape="rectagle"> + position="470,-100" shape="rectagle"> + position="470,-75" shape="rectagle"> + position="470,-50" shape="rectagle"> - + + position="380,-75" shape="rectagle" shrink="true"> - + + position="380,-50" shape="rectagle"> - + + position="380,-25" shape="rectagle"> - + + position="380,0" shape="rectagle"> - + + position="380,25" shape="rectagle"> - + + position="380,50" shape="rectagle"> - + + position="290,0" shape="rounded rectagle"> + position="380,-25" shape="rectagle"> - + + position="380,0" shape="rectagle"> - + + position="380,25" shape="rectagle"> - + + position="290,25" shape="rounded rectagle"> + position="380,-25" shape="rectagle"> - + + position="380,0" shape="rectagle"> - + + position="380,25" shape="rectagle"> - + + position="380,50" shape="rectagle"> - +