mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-12-22 19:33:48 +01:00
- Freemind export store order and position using extended properties.
- Fix order calculation algorith during import. - Optimize JABX context initialization.
This commit is contained in:
parent
ae071f7fcb
commit
dd072ed958
@ -18,13 +18,11 @@
|
||||
|
||||
package com.wisemapping.exporter;
|
||||
|
||||
import com.wisemapping.exporter.ExportException;
|
||||
import com.wisemapping.exporter.Exporter;
|
||||
|
||||
import com.wisemapping.importer.freemind.FreemindIconConverter;
|
||||
import com.wisemapping.model.MindMap;
|
||||
import com.wisemapping.model.ShapeStyle;
|
||||
import com.wisemapping.util.JAXBUtils;
|
||||
import com.wisemapping.xml.Style;
|
||||
import com.wisemapping.xml.freemind.*;
|
||||
import com.wisemapping.xml.mindmap.RelationshipType;
|
||||
import com.wisemapping.xml.mindmap.TopicType;
|
||||
@ -140,7 +138,7 @@ public class FreemindExporter
|
||||
|
||||
final String shape = mindmapTopic.getShape();
|
||||
if (shape != null && !shape.isEmpty()) {
|
||||
if ( isRoot && !ShapeStyle.ROUNDED_RETAGLE.getStyle().endsWith(shape) || !isRoot && !ShapeStyle.LINE.getStyle().endsWith(shape) ) {
|
||||
if (isRoot && !ShapeStyle.ROUNDED_RETAGLE.getStyle().endsWith(shape) || !isRoot && !ShapeStyle.LINE.getStyle().endsWith(shape)) {
|
||||
|
||||
String style = shape;
|
||||
if (ShapeStyle.ROUNDED_RETAGLE.getStyle().equals(shape)) {
|
||||
@ -156,6 +154,16 @@ public class FreemindExporter
|
||||
addEdgeNode(freemindNode, mindmapTopic);
|
||||
addNote(freemindNode, mindmapTopic);
|
||||
|
||||
final String position = mindmapTopic.getPosition();
|
||||
if (position != null && !position.isEmpty()) {
|
||||
freemindNode.setWcoords(position);
|
||||
}
|
||||
|
||||
final Integer order = mindmapTopic.getOrder();
|
||||
if (order != null) {
|
||||
freemindNode.setWorder(BigInteger.valueOf(order));
|
||||
}
|
||||
|
||||
Boolean shrink = mindmapTopic.isShrink();
|
||||
if (shrink != null && shrink)
|
||||
freemindNode.setFOLDED(String.valueOf(shrink));
|
||||
|
@ -20,6 +20,7 @@ package com.wisemapping.importer;
|
||||
|
||||
import com.wisemapping.model.MindMap;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public interface Importer
|
||||
|
@ -45,6 +45,8 @@ import java.math.BigInteger;
|
||||
public class FreemindImporter
|
||||
implements Importer {
|
||||
|
||||
public static final String CODE_VERSION = "pela";
|
||||
public static final int HALF_ROOT_TOPICS_SEPARATION = 25;
|
||||
private com.wisemapping.xml.mindmap.ObjectFactory mindmapObjectFactory;
|
||||
private static final String POSITION_LEFT = "left";
|
||||
private static final String BOLD = "bold";
|
||||
@ -53,45 +55,80 @@ public class FreemindImporter
|
||||
private java.util.Map<String, TopicType> nodesMap = null;
|
||||
private List<RelationshipType> relationships = null;
|
||||
private static final String EMPTY_FONT_STYLE = ";;;;;";
|
||||
private final static Charset UTF_8_CHARSET = Charset.forName("UTF-8");
|
||||
private final static int ORDER_SEPARATION_FACTOR = 2;
|
||||
|
||||
private int currentId;
|
||||
|
||||
public static void main(String argv[]) {
|
||||
|
||||
|
||||
// Now, calculate the order it belongs to ...
|
||||
// 3 = -100 0
|
||||
// 1 = -50 1
|
||||
// 0 = 0 2
|
||||
// 2 = 50 3
|
||||
// 4 = 100 4
|
||||
|
||||
int total = 2;
|
||||
int center = (total - 1) / 2;
|
||||
|
||||
|
||||
for (int i = 0; i < total; i++) {
|
||||
|
||||
int result = i - center + ((total % 2 == 0) ? 0 : 1);
|
||||
if (result > 0) {
|
||||
result = (result - 1) * 2;
|
||||
} else {
|
||||
result = (result * -2) + 1;
|
||||
}
|
||||
|
||||
System.out.println(i + "->" + result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public MindMap importMap(String mapName, String description, InputStream input) throws ImporterException {
|
||||
|
||||
final MindMap map;
|
||||
final MindMap result = new MindMap();
|
||||
nodesMap = new HashMap<String, TopicType>();
|
||||
relationships = new ArrayList<RelationshipType>();
|
||||
mindmapObjectFactory = new com.wisemapping.xml.mindmap.ObjectFactory();
|
||||
|
||||
try {
|
||||
String wiseXml;
|
||||
final Map freemindMap = (Map) JAXBUtils.getMapObject(input, "com.wisemapping.xml.freemind");
|
||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
||||
final com.wisemapping.xml.mindmap.Map mindmapMap = mindmapObjectFactory.createMap();
|
||||
mindmapMap.setVersion("pela");
|
||||
mindmapMap.setVersion(CODE_VERSION);
|
||||
currentId = 0;
|
||||
|
||||
final Node centralNode = freemindMap.getNode();
|
||||
final TopicType centralTopic = mindmapObjectFactory.createTopicType();
|
||||
centralTopic.setId(String.valueOf(currentId++));
|
||||
centralTopic.setCentral(true);
|
||||
final Node freeNode = freemindMap.getNode();
|
||||
final TopicType wiseTopic = mindmapObjectFactory.createTopicType();
|
||||
wiseTopic.setId(String.valueOf(currentId++));
|
||||
wiseTopic.setCentral(true);
|
||||
|
||||
setNodePropertiesToTopic(centralTopic, centralNode);
|
||||
centralTopic.setShape(ShapeStyle.ROUNDED_RETAGLE.getStyle());
|
||||
mindmapMap.getTopic().add(centralTopic);
|
||||
convertNodeProperties(freeNode, wiseTopic);
|
||||
|
||||
wiseTopic.setShape(ShapeStyle.ROUNDED_RETAGLE.getStyle());
|
||||
mindmapMap.getTopic().add(wiseTopic);
|
||||
mindmapMap.setName(mapName);
|
||||
|
||||
nodesMap = new HashMap<String, TopicType>();
|
||||
relationships = new ArrayList<RelationshipType>();
|
||||
nodesMap.put(centralNode.getID(), centralTopic);
|
||||
addTopicFromNode(centralNode, centralTopic);
|
||||
fixCentralTopicChildOrder(centralTopic);
|
||||
nodesMap.put(freeNode.getID(), wiseTopic);
|
||||
|
||||
convertChildNodes(freeNode, wiseTopic, 1);
|
||||
|
||||
addRelationships(mindmapMap);
|
||||
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
JAXBUtils.saveMap(mindmapMap, out, "com.wisemapping.xml.mindmap");
|
||||
JAXBUtils.saveMap(mindmapMap, baos, "com.wisemapping.xml.mindmap");
|
||||
|
||||
map = new MindMap();
|
||||
map.setNativeXml(new String(out.toByteArray(), Charset.forName("UTF-8")));
|
||||
map.setTitle(mapName);
|
||||
map.setDescription(description);
|
||||
wiseXml = new String(baos.toByteArray(), UTF_8_CHARSET);
|
||||
|
||||
|
||||
result.setNativeXml(wiseXml);
|
||||
result.setTitle(mapName);
|
||||
result.setDescription(description);
|
||||
|
||||
} catch (JAXBException e) {
|
||||
throw new ImporterException(e);
|
||||
@ -99,7 +136,7 @@ public class FreemindImporter
|
||||
throw new ImporterException(e);
|
||||
}
|
||||
|
||||
return map;
|
||||
return result;
|
||||
}
|
||||
|
||||
private void addRelationships(@NotNull com.wisemapping.xml.mindmap.Map mindmapMap) {
|
||||
@ -122,7 +159,7 @@ public class FreemindImporter
|
||||
}
|
||||
}
|
||||
|
||||
private void fixRelationshipControlPoints(RelationshipType relationship) {
|
||||
private void fixRelationshipControlPoints(@NotNull 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());
|
||||
@ -139,7 +176,7 @@ public class FreemindImporter
|
||||
relationship.setDestCtrlPoint(x + "," + destCtrlPoint[1]);
|
||||
}
|
||||
|
||||
//Fix y coord
|
||||
//Fix coord
|
||||
if (srcTopic.getOrder() % 2 != 0) { //Odd order.
|
||||
String[] srcCtrlPoint = relationship.getSrcCtrlPoint().split(",");
|
||||
int y = Integer.valueOf(srcCtrlPoint[1]) * -1;
|
||||
@ -153,168 +190,110 @@ public class FreemindImporter
|
||||
|
||||
}
|
||||
|
||||
private void fixCentralTopicChildOrder(@NotNull TopicType centralTopic) {
|
||||
List<TopicType> topics = centralTopic.getTopic();
|
||||
List<TopicType> leftTopics = new ArrayList<TopicType>();
|
||||
List<TopicType> rightTopics = new ArrayList<TopicType>();
|
||||
|
||||
for (TopicType topic : topics) {
|
||||
if (isOnLeftSide(topic)) {
|
||||
leftTopics.add(topic);
|
||||
} else {
|
||||
rightTopics.add(topic);
|
||||
}
|
||||
}
|
||||
|
||||
if (leftTopics.size() > 0) {
|
||||
int size = leftTopics.size();
|
||||
int index = 0;
|
||||
int center = size / 2;
|
||||
if (size % 2 == 0) { //Even number, then place middle point in 1 index
|
||||
index = 1;
|
||||
center--;
|
||||
}
|
||||
int index2 = index;
|
||||
|
||||
leftTopics.get(center).setOrder(index);
|
||||
for (int i = center - 1; i >= 0; i--) {
|
||||
if (index == 0) {
|
||||
index++;
|
||||
} else {
|
||||
index += 2;
|
||||
}
|
||||
leftTopics.get(i).setOrder(index);
|
||||
}
|
||||
index = index2;
|
||||
for (int i = center + 1; i < size; i++) {
|
||||
if (index == 1) {
|
||||
index++;
|
||||
} else {
|
||||
index += 2;
|
||||
}
|
||||
leftTopics.get(i).setOrder(index);
|
||||
}
|
||||
}
|
||||
if (rightTopics.size() > 0) {
|
||||
int size = rightTopics.size();
|
||||
int index = 0;
|
||||
int center = size / 2;
|
||||
if (size % 2 == 0) { //Even number, then place middle point in 1 index
|
||||
index = 1;
|
||||
center--;
|
||||
}
|
||||
int index2 = index;
|
||||
rightTopics.get(center).setOrder(index);
|
||||
for (int i = center - 1; i >= 0; i--) {
|
||||
if (index == 0) {
|
||||
index++;
|
||||
} else {
|
||||
index += 2;
|
||||
}
|
||||
rightTopics.get(i).setOrder(index);
|
||||
}
|
||||
index = index2;
|
||||
for (int i = center + 1; i < size; i++) {
|
||||
if (index == 1) {
|
||||
index++;
|
||||
} else {
|
||||
index += 2;
|
||||
}
|
||||
rightTopics.get(i).setOrder(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isOnLeftSide(TopicType topic) {
|
||||
String[] position = topic.getPosition().split(",");
|
||||
int x = Integer.parseInt(position[0]);
|
||||
return x < 0;
|
||||
}
|
||||
|
||||
private void addTopicFromNode(@NotNull Node mainNode, @NotNull TopicType topic) {
|
||||
final List<Object> freemindNodes = mainNode.getArrowlinkOrCloudOrEdge();
|
||||
TopicType currentTopic = topic;
|
||||
private boolean isOnLeftSide(@NotNull String pos) {
|
||||
String[] position = pos.split(",");
|
||||
int x = Integer.parseInt(position[0]);
|
||||
return x < 0;
|
||||
}
|
||||
|
||||
private void convertChildNodes(@NotNull Node freeParent, @NotNull TopicType wiseParent, final int depth) {
|
||||
final List<Object> freeChilden = freeParent.getArrowlinkOrCloudOrEdge();
|
||||
TopicType currentWiseTopic = wiseParent;
|
||||
|
||||
int order = 0;
|
||||
for (Object freemindNode : freemindNodes) {
|
||||
for (Object element : freeChilden) {
|
||||
|
||||
if (freemindNode instanceof Node) {
|
||||
final Node node = (Node) freemindNode;
|
||||
TopicType newTopic = mindmapObjectFactory.createTopicType();
|
||||
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++);
|
||||
if (element instanceof Node) {
|
||||
final Node freeChild = (Node) element;
|
||||
final TopicType wiseChild = mindmapObjectFactory.createTopicType();
|
||||
|
||||
// Is there any link ?
|
||||
final String url = node.getLINK();
|
||||
if (url != null) {
|
||||
final Link link = new Link();
|
||||
link.setUrl(url);
|
||||
newTopic.setLink(link);
|
||||
// Set an incremental id ...
|
||||
wiseChild.setId(String.valueOf(currentId++));
|
||||
|
||||
// Lets use freemind id temporarily. This will be fixed when adding relationship to the map.
|
||||
nodesMap.put(freeChild.getID(), wiseChild);
|
||||
|
||||
// Set node order ...
|
||||
int norder;
|
||||
if (depth != 1) {
|
||||
norder = order++;
|
||||
} else {
|
||||
norder = calcFirstLevelOrder(freeChilden, freeChild);
|
||||
}
|
||||
wiseChild.setOrder(norder);
|
||||
|
||||
if (POSITION_LEFT.equals(mainNode.getPOSITION())) {
|
||||
node.setPOSITION(POSITION_LEFT);
|
||||
// Convert node position ...
|
||||
final String position = convertPosition(wiseParent, freeChild, depth, norder);
|
||||
wiseChild.setPosition(position);
|
||||
|
||||
// Convert the rest of the node properties ...
|
||||
convertNodeProperties(freeChild, wiseChild);
|
||||
|
||||
convertChildNodes(freeChild, wiseChild, depth + 1);
|
||||
|
||||
if (!wiseChild.equals(wiseParent)) {
|
||||
wiseParent.getTopic().add(wiseChild);
|
||||
}
|
||||
currentWiseTopic = wiseChild;
|
||||
|
||||
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);
|
||||
} else if (element instanceof Font) {
|
||||
final Font font = (Font) element;
|
||||
final String fontStyle = generateFontStyle(freeParent, font);
|
||||
if (fontStyle != null) {
|
||||
currentTopic.setFontStyle(fontStyle);
|
||||
currentWiseTopic.setFontStyle(fontStyle);
|
||||
}
|
||||
} else if (freemindNode instanceof Edge) {
|
||||
final Edge edge = (Edge) freemindNode;
|
||||
currentTopic.setBrColor(edge.getCOLOR());
|
||||
} else if (freemindNode instanceof Icon) {
|
||||
final Icon freemindIcon = (Icon) freemindNode;
|
||||
} else if (element instanceof Edge) {
|
||||
final Edge edge = (Edge) element;
|
||||
currentWiseTopic.setBrColor(edge.getCOLOR());
|
||||
} else if (element instanceof Icon) {
|
||||
final Icon freemindIcon = (Icon) element;
|
||||
|
||||
String iconId = freemindIcon.getBUILTIN();
|
||||
final String wiseIconId = FreemindIconConverter.toWiseId(iconId);
|
||||
if (wiseIconId != null) {
|
||||
final com.wisemapping.xml.mindmap.Icon mindmapIcon = new com.wisemapping.xml.mindmap.Icon();
|
||||
mindmapIcon.setId(wiseIconId);
|
||||
currentTopic.getIcon().add(mindmapIcon);
|
||||
currentWiseTopic.getIcon().add(mindmapIcon);
|
||||
}
|
||||
|
||||
} else if (freemindNode instanceof Hook) {
|
||||
final Hook hook = (Hook) freemindNode;
|
||||
} else if (element instanceof Hook) {
|
||||
final Hook hook = (Hook) element;
|
||||
final com.wisemapping.xml.mindmap.Note mindmapNote = new com.wisemapping.xml.mindmap.Note();
|
||||
String textNote = hook.getText();
|
||||
if (textNote == null) // It is not a note is a BlinkingNodeHook or AutomaticLayout Hook
|
||||
{
|
||||
textNote = EMPTY_NOTE;
|
||||
mindmapNote.setText(textNote);
|
||||
currentTopic.setNote(mindmapNote);
|
||||
currentWiseTopic.setNote(mindmapNote);
|
||||
}
|
||||
} else if (freemindNode instanceof Richcontent) {
|
||||
final Richcontent content = (Richcontent) freemindNode;
|
||||
} else if (element instanceof Richcontent) {
|
||||
final Richcontent content = (Richcontent) element;
|
||||
final String type = content.getTYPE();
|
||||
|
||||
if (type.equals("NODE")) {
|
||||
String text = getText(content);
|
||||
text = text.replaceAll("\n", "");
|
||||
text = text.trim();
|
||||
currentTopic.setText(text);
|
||||
currentWiseTopic.setText(text);
|
||||
} else {
|
||||
String text = getRichContent(content);
|
||||
final com.wisemapping.xml.mindmap.Note mindmapNote = new com.wisemapping.xml.mindmap.Note();
|
||||
text = text != null ? text.replaceAll("\n", "%0A") : EMPTY_NOTE;
|
||||
mindmapNote.setText(text);
|
||||
currentTopic.setNote(mindmapNote);
|
||||
currentWiseTopic.setNote(mindmapNote);
|
||||
|
||||
}
|
||||
} else if (freemindNode instanceof Arrowlink) {
|
||||
final Arrowlink arrow = (Arrowlink) freemindNode;
|
||||
} else if (element instanceof Arrowlink) {
|
||||
final Arrowlink arrow = (Arrowlink) element;
|
||||
RelationshipType relationship = mindmapObjectFactory.createRelationshipType();
|
||||
String destId = arrow.getDESTINATION();
|
||||
relationship.setSrcTopicId(mainNode.getID());
|
||||
relationship.setSrcTopicId(freeParent.getID());
|
||||
relationship.setDestTopicId(destId);
|
||||
String[] inclination = arrow.getENDINCLINATION().split(";");
|
||||
relationship.setDestCtrlPoint(inclination[0] + "," + inclination[1]);
|
||||
@ -329,6 +308,91 @@ public class FreemindImporter
|
||||
}
|
||||
}
|
||||
|
||||
private int calcFirstLevelOrder(@NotNull List<Object> freeChilden, @NotNull Node freeChild) {
|
||||
final List<Node> nodes = new ArrayList<Node>();
|
||||
int result;
|
||||
if (freeChild.getWorder() != null) {
|
||||
result = freeChild.getWorder().intValue();
|
||||
} else {
|
||||
for (Object child : freeChilden) {
|
||||
if (child instanceof Node) {
|
||||
Node node = (Node) child;
|
||||
|
||||
final String side = node.getPOSITION();
|
||||
if (freeChild.getPOSITION().equals(side)) {
|
||||
nodes.add(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// What is the index of the current node ?
|
||||
int nodeIndex = 0;
|
||||
for (Node node : nodes) {
|
||||
if (node == freeChild) {
|
||||
break;
|
||||
}
|
||||
nodeIndex++;
|
||||
}
|
||||
|
||||
int size = ORDER_SEPARATION_FACTOR * nodes.size();
|
||||
int center = (size - 1) / 2;
|
||||
result = (nodeIndex * ORDER_SEPARATION_FACTOR) - center + ((size % 2 == 0) ? 0 : 1);
|
||||
|
||||
if (result > 0) {
|
||||
result = (result - 1) * 2;
|
||||
} else {
|
||||
result = (result * -2) + 1;
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Position is (x,y).
|
||||
* x values greater than 0 are right axis
|
||||
* x values lower than 0 are left axis
|
||||
*/
|
||||
private
|
||||
@NotNull
|
||||
String convertPosition(@NotNull TopicType wiseParent, @NotNull Node freeChild, final int depth, int order) {
|
||||
|
||||
// Which side must be the node be positioned ?
|
||||
String result = freeChild.getWcoords();
|
||||
if (result == null) {
|
||||
|
||||
final int xaxis;
|
||||
int y;
|
||||
if (depth == 1) {
|
||||
|
||||
final String side = freeChild.getPOSITION();
|
||||
assert side != null : "This should not happen";
|
||||
xaxis = POSITION_LEFT.equals(side) ? -1 : 1;
|
||||
|
||||
// 3 = -100 1
|
||||
// 1 = -50 2
|
||||
// 0 = 0 3
|
||||
// 2 = 50 4
|
||||
// 4 = 100 5
|
||||
if (order % 2 == 0) {
|
||||
y = HALF_ROOT_TOPICS_SEPARATION * order;
|
||||
} else {
|
||||
y = -HALF_ROOT_TOPICS_SEPARATION * (order + 1);
|
||||
}
|
||||
|
||||
} else {
|
||||
final String position = wiseParent.getPosition();
|
||||
xaxis = isOnLeftSide(position) ? -1 : 1;
|
||||
y = 100 * depth; // Todo: This is not right at all. This must be changed. Position must be calculated based on the parent position
|
||||
|
||||
}
|
||||
int x = xaxis * 200 * depth;
|
||||
result = x + "," + y;
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private String getRichContent(Richcontent content) {
|
||||
String result = null;
|
||||
List<Element> elementList = content.getHtml().getAny();
|
||||
@ -346,6 +410,7 @@ public class FreemindImporter
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getText(Richcontent content) {
|
||||
String result = "";
|
||||
List<Element> elementList = content.getHtml().getAny();
|
||||
@ -384,34 +449,30 @@ public class FreemindImporter
|
||||
return text.toString();
|
||||
}
|
||||
|
||||
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());
|
||||
private void convertNodeProperties(@NotNull com.wisemapping.xml.freemind.Node freeNode, @NotNull com.wisemapping.xml.mindmap.TopicType wiseTopic) {
|
||||
final String text = freeNode.getTEXT();
|
||||
wiseTopic.setText(text);
|
||||
|
||||
final String shape = getShapeFormFromNode(freemindNode);
|
||||
final String bgcolor = freeNode.getBACKGROUNDCOLOR();
|
||||
wiseTopic.setBgColor(bgcolor);
|
||||
|
||||
final String shape = getShapeFormFromNode(freeNode);
|
||||
wiseTopic.setShape(shape);
|
||||
int pos = 1;
|
||||
if (POSITION_LEFT.equals(freemindNode.getPOSITION())) {
|
||||
pos = -1;
|
||||
}
|
||||
Integer orderPosition = wiseTopic.getOrder() != null ? wiseTopic.getOrder() : 0;
|
||||
int position = pos * 200 + (orderPosition + 1) * 10;
|
||||
|
||||
wiseTopic.setPosition(position + "," + 200 * orderPosition);
|
||||
final String fontStyle = generateFontStyle(freemindNode, null);
|
||||
final String fontStyle = generateFontStyle(freeNode, null);
|
||||
if (fontStyle != null) {
|
||||
wiseTopic.setFontStyle(fontStyle);
|
||||
}
|
||||
|
||||
// Is there any link ?
|
||||
final String url = freemindNode.getLINK();
|
||||
final String url = freeNode.getLINK();
|
||||
if (url != null) {
|
||||
final Link link = new Link();
|
||||
link.setUrl(url);
|
||||
wiseTopic.setLink(link);
|
||||
}
|
||||
|
||||
final Boolean folded = Boolean.valueOf(freemindNode.getFOLDED());
|
||||
final Boolean folded = Boolean.valueOf(freeNode.getFOLDED());
|
||||
if (folded) {
|
||||
wiseTopic.setShrink(folded);
|
||||
}
|
||||
@ -477,7 +538,9 @@ public class FreemindImporter
|
||||
return result;
|
||||
}
|
||||
|
||||
private @NotNull String getShapeFormFromNode(@NotNull Node node) {
|
||||
private
|
||||
@NotNull
|
||||
String getShapeFormFromNode(@NotNull Node node) {
|
||||
String result = node.getSTYLE();
|
||||
// In freemind a node without style is a line
|
||||
if ("bubble".equals(result)) {
|
||||
|
@ -18,28 +18,47 @@
|
||||
|
||||
package com.wisemapping.util;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class JAXBUtils {
|
||||
|
||||
public static Object getMapObject(InputStream stream,String pakage) throws JAXBException {
|
||||
private final static Map<String, JAXBContext> context = new HashMap<String, JAXBContext>();
|
||||
|
||||
final JAXBContext context = JAXBContext.newInstance(pakage);
|
||||
final Unmarshaller unmarshaller = context.createUnmarshaller() ;
|
||||
public static Object getMapObject(@NotNull InputStream stream, @NotNull final String pakage) throws JAXBException {
|
||||
|
||||
return unmarshaller.unmarshal (stream) ;
|
||||
final JAXBContext context = getInstance(pakage);
|
||||
final Unmarshaller unmarshaller = context.createUnmarshaller();
|
||||
|
||||
return unmarshaller.unmarshal(stream);
|
||||
}
|
||||
|
||||
public static void saveMap(Object obj, OutputStream out,String pakage) throws JAXBException {
|
||||
private static JAXBContext getInstance(@NotNull String pakage) throws JAXBException {
|
||||
|
||||
final JAXBContext context = JAXBContext.newInstance(pakage);
|
||||
final Marshaller marshaller = context.createMarshaller();
|
||||
JAXBContext result = context.get(pakage);
|
||||
if (result == null) {
|
||||
synchronized (context) {
|
||||
result = JAXBContext.newInstance(pakage);
|
||||
context.put(pakage, result);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
marshaller.marshal(obj, out) ;
|
||||
}
|
||||
|
||||
public static void saveMap(@NotNull Object obj, @NotNull OutputStream out, String pachage) throws JAXBException {
|
||||
|
||||
final JAXBContext context = getInstance(pachage);
|
||||
final Marshaller marshaller = context.createMarshaller();
|
||||
|
||||
marshaller.marshal(obj, out);
|
||||
}
|
||||
}
|
||||
|
@ -26,9 +26,9 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
/**
|
||||
* <p>Java class for anonymous complex type.
|
||||
*
|
||||
* <p/>
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <p/>
|
||||
* <pre>
|
||||
* <complexType>
|
||||
* <complexContent>
|
||||
@ -75,25 +75,23 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "", propOrder = {
|
||||
"arrowlinkOrCloudOrEdge"
|
||||
"arrowlinkOrCloudOrEdge"
|
||||
})
|
||||
@XmlRootElement(name = "node")
|
||||
public class Node {
|
||||
|
||||
@XmlElements({
|
||||
@XmlElement(name = "icon", type = Icon.class),
|
||||
@XmlElement(name = "node", type = Node.class),
|
||||
@XmlElement(name = "edge", type = Edge.class),
|
||||
@XmlElement(name = "arrowlink", type = Arrowlink.class),
|
||||
@XmlElement(name = "font", type = Font.class),
|
||||
@XmlElement(name = "hook", type = Hook.class),
|
||||
@XmlElement(name = "richcontent", type = Richcontent.class),
|
||||
@XmlElement(name = "cloud", type = Cloud.class)
|
||||
@XmlElement(name = "icon", type = Icon.class),
|
||||
@XmlElement(name = "node", type = Node.class),
|
||||
@XmlElement(name = "edge", type = Edge.class),
|
||||
@XmlElement(name = "arrowlink", type = Arrowlink.class),
|
||||
@XmlElement(name = "font", type = Font.class),
|
||||
@XmlElement(name = "hook", type = Hook.class),
|
||||
@XmlElement(name = "richcontent", type = Richcontent.class),
|
||||
@XmlElement(name = "cloud", type = Cloud.class)
|
||||
})
|
||||
protected List<Object> arrowlinkOrCloudOrEdge;
|
||||
@XmlAttribute(name = "BACKGROUND_COLOR")
|
||||
@ -123,28 +121,35 @@ public class Node {
|
||||
protected BigInteger hgap;
|
||||
@XmlAttribute(name = "VGAP")
|
||||
protected BigInteger vgap;
|
||||
|
||||
@XmlAttribute(name = "VSHIFT")
|
||||
protected BigInteger vshift;
|
||||
@XmlAttribute(name = "ENCRYPTED_CONTENT")
|
||||
protected String encryptedcontent;
|
||||
|
||||
// Wise Extensions
|
||||
@XmlAttribute(name = "wCOORDS")
|
||||
protected String wcoords;
|
||||
@XmlAttribute(name = "WORDER")
|
||||
protected BigInteger worder;
|
||||
|
||||
/**
|
||||
* Gets the value of the arrowlinkOrCloudOrEdge property.
|
||||
*
|
||||
* <p>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* This accessor method returns a reference to the live list,
|
||||
* not a snapshot. Therefore any modification you make to the
|
||||
* returned list will be present inside the JAXB object.
|
||||
* This is why there is not a <CODE>set</CODE> method for the arrowlinkOrCloudOrEdge property.
|
||||
*
|
||||
* <p>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* For example, to add a new item, do as follows:
|
||||
* <pre>
|
||||
* getArrowlinkOrCloudOrEdge().add(newItem);
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* Objects of the following type(s) are allowed in the list
|
||||
* {@link Icon }
|
||||
* {@link Node }
|
||||
@ -154,8 +159,6 @@ public class Node {
|
||||
* {@link Hook }
|
||||
* {@link Richcontent }
|
||||
* {@link Cloud }
|
||||
*
|
||||
*
|
||||
*/
|
||||
public List<Object> getArrowlinkOrCloudOrEdge() {
|
||||
if (arrowlinkOrCloudOrEdge == null) {
|
||||
@ -166,11 +169,9 @@ public class Node {
|
||||
|
||||
/**
|
||||
* Gets the value of the backgroundcolor property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*
|
||||
* @return possible object is
|
||||
* {@link String }
|
||||
*/
|
||||
public String getBACKGROUNDCOLOR() {
|
||||
return backgroundcolor;
|
||||
@ -178,11 +179,9 @@ public class Node {
|
||||
|
||||
/**
|
||||
* Sets the value of the backgroundcolor property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*
|
||||
* @param value allowed object is
|
||||
* {@link String }
|
||||
*/
|
||||
public void setBACKGROUNDCOLOR(String value) {
|
||||
this.backgroundcolor = value;
|
||||
@ -190,23 +189,27 @@ public class Node {
|
||||
|
||||
/**
|
||||
* Gets the value of the color property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*
|
||||
* @return possible object is
|
||||
* {@link String }
|
||||
*/
|
||||
public String getCOLOR() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public BigInteger getWorder() {
|
||||
return worder;
|
||||
}
|
||||
|
||||
public void setWorder(BigInteger worder) {
|
||||
this.worder = worder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the color property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*
|
||||
* @param value allowed object is
|
||||
* {@link String }
|
||||
*/
|
||||
public void setCOLOR(String value) {
|
||||
this.color = value;
|
||||
@ -214,11 +217,9 @@ public class Node {
|
||||
|
||||
/**
|
||||
* Gets the value of the folded property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*
|
||||
* @return possible object is
|
||||
* {@link String }
|
||||
*/
|
||||
public String getFOLDED() {
|
||||
return folded;
|
||||
@ -226,11 +227,9 @@ public class Node {
|
||||
|
||||
/**
|
||||
* Sets the value of the folded property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*
|
||||
* @param value allowed object is
|
||||
* {@link String }
|
||||
*/
|
||||
public void setFOLDED(String value) {
|
||||
this.folded = value;
|
||||
@ -238,11 +237,9 @@ public class Node {
|
||||
|
||||
/**
|
||||
* Gets the value of the id property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*
|
||||
* @return possible object is
|
||||
* {@link String }
|
||||
*/
|
||||
public String getID() {
|
||||
return id;
|
||||
@ -250,11 +247,9 @@ public class Node {
|
||||
|
||||
/**
|
||||
* Sets the value of the id property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*
|
||||
* @param value allowed object is
|
||||
* {@link String }
|
||||
*/
|
||||
public void setID(String value) {
|
||||
this.id = value;
|
||||
@ -262,11 +257,9 @@ public class Node {
|
||||
|
||||
/**
|
||||
* Gets the value of the link property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*
|
||||
* @return possible object is
|
||||
* {@link String }
|
||||
*/
|
||||
public String getLINK() {
|
||||
return link;
|
||||
@ -274,11 +267,9 @@ public class Node {
|
||||
|
||||
/**
|
||||
* Sets the value of the link property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*
|
||||
* @param value allowed object is
|
||||
* {@link String }
|
||||
*/
|
||||
public void setLINK(String value) {
|
||||
this.link = value;
|
||||
@ -286,11 +277,9 @@ public class Node {
|
||||
|
||||
/**
|
||||
* Gets the value of the position property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*
|
||||
* @return possible object is
|
||||
* {@link String }
|
||||
*/
|
||||
public String getPOSITION() {
|
||||
return position;
|
||||
@ -298,11 +287,9 @@ public class Node {
|
||||
|
||||
/**
|
||||
* Sets the value of the position property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*
|
||||
* @param value allowed object is
|
||||
* {@link String }
|
||||
*/
|
||||
public void setPOSITION(String value) {
|
||||
this.position = value;
|
||||
@ -310,11 +297,9 @@ public class Node {
|
||||
|
||||
/**
|
||||
* Gets the value of the style property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*
|
||||
* @return possible object is
|
||||
* {@link String }
|
||||
*/
|
||||
public String getSTYLE() {
|
||||
return style;
|
||||
@ -322,11 +307,9 @@ public class Node {
|
||||
|
||||
/**
|
||||
* Sets the value of the style property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*
|
||||
* @param value allowed object is
|
||||
* {@link String }
|
||||
*/
|
||||
public void setSTYLE(String value) {
|
||||
this.style = value;
|
||||
@ -334,11 +317,9 @@ public class Node {
|
||||
|
||||
/**
|
||||
* Gets the value of the text property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*
|
||||
* @return possible object is
|
||||
* {@link String }
|
||||
*/
|
||||
public String getTEXT() {
|
||||
return text;
|
||||
@ -346,11 +327,9 @@ public class Node {
|
||||
|
||||
/**
|
||||
* Sets the value of the text property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*
|
||||
* @param value allowed object is
|
||||
* {@link String }
|
||||
*/
|
||||
public void setTEXT(String value) {
|
||||
this.text = value;
|
||||
@ -358,11 +337,9 @@ public class Node {
|
||||
|
||||
/**
|
||||
* Gets the value of the created property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link BigInteger }
|
||||
*
|
||||
*
|
||||
* @return possible object is
|
||||
* {@link BigInteger }
|
||||
*/
|
||||
public BigInteger getCREATED() {
|
||||
return created;
|
||||
@ -370,11 +347,9 @@ public class Node {
|
||||
|
||||
/**
|
||||
* Sets the value of the created property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link BigInteger }
|
||||
*
|
||||
*
|
||||
* @param value allowed object is
|
||||
* {@link BigInteger }
|
||||
*/
|
||||
public void setCREATED(BigInteger value) {
|
||||
this.created = value;
|
||||
@ -382,23 +357,27 @@ public class Node {
|
||||
|
||||
/**
|
||||
* Gets the value of the modified property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link BigInteger }
|
||||
*
|
||||
*
|
||||
* @return possible object is
|
||||
* {@link BigInteger }
|
||||
*/
|
||||
public BigInteger getMODIFIED() {
|
||||
return modified;
|
||||
}
|
||||
|
||||
public String getWcoords() {
|
||||
return wcoords;
|
||||
}
|
||||
|
||||
public void setWcoords(String wcoords) {
|
||||
this.wcoords = wcoords;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the modified property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link BigInteger }
|
||||
*
|
||||
*
|
||||
* @param value allowed object is
|
||||
* {@link BigInteger }
|
||||
*/
|
||||
public void setMODIFIED(BigInteger value) {
|
||||
this.modified = value;
|
||||
@ -406,11 +385,9 @@ public class Node {
|
||||
|
||||
/**
|
||||
* Gets the value of the hgap property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link BigInteger }
|
||||
*
|
||||
*
|
||||
* @return possible object is
|
||||
* {@link BigInteger }
|
||||
*/
|
||||
public BigInteger getHGAP() {
|
||||
return hgap;
|
||||
@ -418,11 +395,9 @@ public class Node {
|
||||
|
||||
/**
|
||||
* Sets the value of the hgap property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link BigInteger }
|
||||
*
|
||||
*
|
||||
* @param value allowed object is
|
||||
* {@link BigInteger }
|
||||
*/
|
||||
public void setHGAP(BigInteger value) {
|
||||
this.hgap = value;
|
||||
@ -430,11 +405,9 @@ public class Node {
|
||||
|
||||
/**
|
||||
* Gets the value of the vgap property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link BigInteger }
|
||||
*
|
||||
*
|
||||
* @return possible object is
|
||||
* {@link BigInteger }
|
||||
*/
|
||||
public BigInteger getVGAP() {
|
||||
return vgap;
|
||||
@ -442,11 +415,9 @@ public class Node {
|
||||
|
||||
/**
|
||||
* Sets the value of the vgap property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link BigInteger }
|
||||
*
|
||||
*
|
||||
* @param value allowed object is
|
||||
* {@link BigInteger }
|
||||
*/
|
||||
public void setVGAP(BigInteger value) {
|
||||
this.vgap = value;
|
||||
@ -454,11 +425,9 @@ public class Node {
|
||||
|
||||
/**
|
||||
* Gets the value of the vshift property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link BigInteger }
|
||||
*
|
||||
*
|
||||
* @return possible object is
|
||||
* {@link BigInteger }
|
||||
*/
|
||||
public BigInteger getVSHIFT() {
|
||||
return vshift;
|
||||
@ -466,11 +435,9 @@ public class Node {
|
||||
|
||||
/**
|
||||
* Sets the value of the vshift property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link BigInteger }
|
||||
*
|
||||
*
|
||||
* @param value allowed object is
|
||||
* {@link BigInteger }
|
||||
*/
|
||||
public void setVSHIFT(BigInteger value) {
|
||||
this.vshift = value;
|
||||
@ -478,11 +445,9 @@ public class Node {
|
||||
|
||||
/**
|
||||
* Gets the value of the encryptedcontent property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*
|
||||
* @return possible object is
|
||||
* {@link String }
|
||||
*/
|
||||
public String getENCRYPTEDCONTENT() {
|
||||
return encryptedcontent;
|
||||
@ -490,11 +455,9 @@ public class Node {
|
||||
|
||||
/**
|
||||
* Sets the value of the encryptedcontent property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*
|
||||
* @param value allowed object is
|
||||
* {@link String }
|
||||
*/
|
||||
public void setENCRYPTEDCONTENT(String value) {
|
||||
this.encryptedcontent = value;
|
||||
|
@ -149,6 +149,9 @@
|
||||
<xs:attribute name='MODIFIED' type='xs:integer' use='optional'/>
|
||||
<xs:attribute name='HGAP' type='xs:integer' use='optional'/>
|
||||
<xs:attribute name='VGAP' type='xs:integer' use='optional'/>
|
||||
<xs:attribute name='WCOORDS' type='xs:string' use='optional'/>
|
||||
<xs:attribute name='WORDER' type='xs:integer' use='optional'/>
|
||||
|
||||
<xs:attribute name='VSHIFT' type='xs:integer' use='optional'/>
|
||||
<xs:attribute name='ENCRYPTED_CONTENT' type='xs:string' use='optional'/>
|
||||
</xs:complexType>
|
||||
|
@ -1 +1 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><map version="0.9.0"><node TEXT="This is the root node" ID="ID_0"><node TEXT="Child Level 1 Right 1" POSITION="right" ID="ID_1"/><node TEXT="Child Level 1 Left 1" POSITION="left" ID="ID_2"><node TEXT="Child Level 2 Left 11" POSITION="left" ID="ID_3"/><node TEXT="Child Level 2 Left 12" POSITION="left" ID="ID_4"/></node><node TEXT="Child Level 1 Right 2" POSITION="right" ID="ID_5"/><node TEXT="Child Level 1 Left 2" POSITION="left" ID="ID_6"><node TEXT="Child Level 2 Left 21 " POSITION="left" ID="ID_7"/><node TEXT="Child Level 2 Left 22" POSITION="left" ID="ID_8"/></node></node></map>
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><map version="0.9.0"><node TEXT="This is the root node" ID="ID_0"><node WORDER="3" wCOORDS="200,-100" TEXT="Child Level 1 Right 1" POSITION="right" ID="ID_1"/><node WORDER="3" wCOORDS="-200,-100" TEXT="Child Level 1 Left 1" POSITION="left" ID="ID_2"><node WORDER="0" wCOORDS="-400,200" TEXT="Child Level 2 Left 11" POSITION="left" ID="ID_3"/><node WORDER="1" wCOORDS="-400,200" TEXT="Child Level 2 Left 12" POSITION="left" ID="ID_4"/></node><node WORDER="0" wCOORDS="200,0" TEXT="Child Level 1 Right 2" POSITION="right" ID="ID_5"/><node WORDER="0" wCOORDS="-200,0" TEXT="Child Level 1 Left 2" POSITION="left" ID="ID_6"><node WORDER="0" wCOORDS="-400,200" TEXT="Child Level 2 Left 21 " POSITION="left" ID="ID_7"/><node WORDER="1" wCOORDS="-400,200" TEXT="Child Level 2 Left 22" POSITION="left" ID="ID_8"/></node></node></map>
|
1
wise-webapp/src/test/data/freemind/basic.wxml
Normal file
1
wise-webapp/src/test/data/freemind/basic.wxml
Normal file
@ -0,0 +1 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><map version="pela" name="basic"><topic id="0" central="true" shape="rounded rectagle" text="This is the root node"><topic id="1" position="200,-100" order="3" shape="line" text="Child Level 1 Right 1"/><topic id="2" position="-200,-100" order="3" shape="line" text="Child Level 1 Left 1"><topic id="3" position="-400,200" order="0" shape="line" text="Child Level 2 Left 11"/><topic id="4" position="-400,200" order="1" shape="line" text="Child Level 2 Left 12"/></topic><topic id="5" position="200,0" order="0" shape="line" text="Child Level 1 Right 2"/><topic id="6" position="-200,0" order="0" shape="line" text="Child Level 1 Left 2"><topic id="7" position="-400,200" order="0" shape="line" text="Child Level 2 Left 21 "/><topic id="8" position="-400,200" order="1" shape="line" text="Child Level 2 Left 22"/></topic></topic></map>
|
@ -1 +1 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><map version="0.9.0"><node TEXT="Fonts" ID="ID_0"><node TEXT="Styles" POSITION="right" ID="ID_1"><node TEXT="Bold" POSITION="right" ID="ID_2"><font SIZE="12" NAME="Arial" BOLD="true"/></node><node TEXT="Italic" POSITION="right" ID="ID_3"><font SIZE="12" NAME="Arial" ITALIC="true"/></node></node><node TEXT="Sizes" POSITION="left" ID="ID_4"><node TEXT="Normal----" POSITION="left" ID="ID_5"><font SIZE="8" NAME="Arial"/></node><node TEXT="Normal---" POSITION="left" ID="ID_6"><font SIZE="9" NAME="Arial"/></node><node TEXT="Normal--" POSITION="left" ID="ID_7"><font SIZE="10" NAME="Arial"/></node><node TEXT="Normal-" POSITION="left" ID="ID_8"><font SIZE="11" NAME="Arial"/></node><node TEXT="Normal" POSITION="left" ID="ID_9"/><node TEXT="Nomal+" POSITION="left" ID="ID_10"><font SIZE="13" NAME="Arial"/></node><node TEXT="Normal++" POSITION="left" ID="ID_11"><font SIZE="14" NAME="Arial"/></node><node TEXT="Normal+++" POSITION="left" ID="ID_12"><font SIZE="15" NAME="Arial"/></node><node TEXT="Normal++++" POSITION="left" ID="ID_13"><font SIZE="16" NAME="Arial"/></node></node></node></map>
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><map version="0.9.0"><node TEXT="Fonts" ID="ID_0"><node WORDER="1" wCOORDS="200,-50" TEXT="Styles" POSITION="right" ID="ID_1"><node WORDER="0" wCOORDS="400,200" TEXT="Bold" POSITION="right" ID="ID_2"><font SIZE="12" NAME="Arial" BOLD="true"/></node><node WORDER="1" wCOORDS="400,200" TEXT="Italic" POSITION="right" ID="ID_3"><font SIZE="12" NAME="Arial" ITALIC="true"/></node></node><node WORDER="1" wCOORDS="-200,-50" TEXT="Sizes" POSITION="left" ID="ID_4"><node WORDER="0" wCOORDS="-400,200" TEXT="Normal----" POSITION="left" ID="ID_5"><font SIZE="8" NAME="Arial"/></node><node WORDER="1" wCOORDS="-400,200" TEXT="Normal---" POSITION="left" ID="ID_6"><font SIZE="9" NAME="Arial"/></node><node WORDER="2" wCOORDS="-400,200" TEXT="Normal--" POSITION="left" ID="ID_7"><font SIZE="10" NAME="Arial"/></node><node WORDER="3" wCOORDS="-400,200" TEXT="Normal-" POSITION="left" ID="ID_8"><font SIZE="11" NAME="Arial"/></node><node WORDER="4" wCOORDS="-400,200" TEXT="Normal" POSITION="left" ID="ID_9"/><node WORDER="5" wCOORDS="-400,200" TEXT="Nomal+" POSITION="left" ID="ID_10"><font SIZE="13" NAME="Arial"/></node><node WORDER="6" wCOORDS="-400,200" TEXT="Normal++" POSITION="left" ID="ID_11"><font SIZE="14" NAME="Arial"/></node><node WORDER="7" wCOORDS="-400,200" TEXT="Normal+++" POSITION="left" ID="ID_12"><font SIZE="15" NAME="Arial"/></node><node WORDER="8" wCOORDS="-400,200" TEXT="Normal++++" POSITION="left" ID="ID_13"><font SIZE="16" NAME="Arial"/></node></node></node></map>
|
1
wise-webapp/src/test/data/freemind/fonts.wxml
Normal file
1
wise-webapp/src/test/data/freemind/fonts.wxml
Normal file
@ -0,0 +1 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><map version="pela" name="basic"><topic id="0" central="true" shape="rounded rectagle" text="Fonts"><topic id="1" position="200,-50" order="1" shape="line" text="Styles"><topic id="2" position="400,200" order="0" fontStyle="Arial;12;;bold;;" shape="line" text="Bold"/><topic id="3" position="400,200" order="1" fontStyle="Arial;12;;;italic;" shape="line" text="Italic"/></topic><topic id="4" position="-200,-50" order="1" shape="line" text="Sizes"><topic id="5" position="-400,200" order="0" fontStyle="Arial;8;;;;" shape="line" text="Normal----"/><topic id="6" position="-400,200" order="1" fontStyle="Arial;9;;;;" shape="line" text="Normal---"/><topic id="7" position="-400,200" order="2" fontStyle="Arial;10;;;;" shape="line" text="Normal--"/><topic id="8" position="-400,200" order="3" fontStyle="Arial;11;;;;" shape="line" text="Normal-"/><topic id="9" position="-400,200" order="4" shape="line" text="Normal"/><topic id="10" position="-400,200" order="5" fontStyle="Arial;13;;;;" shape="line" text="Nomal+"/><topic id="11" position="-400,200" order="6" fontStyle="Arial;14;;;;" shape="line" text="Normal++"/><topic id="12" position="-400,200" order="7" fontStyle="Arial;15;;;;" shape="line" text="Normal+++"/><topic id="13" position="-400,200" order="8" fontStyle="Arial;16;;;;" shape="line" text="Normal++++"/></topic></topic></map>
|
File diff suppressed because one or more lines are too long
1
wise-webapp/src/test/data/freemind/icons.wxml
Normal file
1
wise-webapp/src/test/data/freemind/icons.wxml
Normal file
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><map version="0.9.0"><node TEXT="Node Links" 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>
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><map version="0.9.0"><node TEXT="Node Links" LINK="http://www.google.com" ID="ID_0"><icon BUILTIN="closed"/><node WORDER="1" wCOORDS="200,-50" TEXT="Link Topic" POSITION="right" LINK="http://www.bing.com" ID="ID_1" FOLDED="true"><icon BUILTIN="info"/><node WORDER="0" wCOORDS="400,200" TEXT="Link Topic Topic" POSITION="right" LINK="http://bing.com" ID="ID_2"><icon BUILTIN="messagebox_warning"/></node></node></node></map>
|
1
wise-webapp/src/test/data/freemind/links.wxml
Normal file
1
wise-webapp/src/test/data/freemind/links.wxml
Normal file
@ -0,0 +1 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><map version="pela" name="basic"><topic id="0" central="true" shape="rounded rectagle" text="Node Links"><icon id="onoff_delete"/><link url="http://www.google.com"/><topic shrink="true" id="1" position="200,-50" order="1" shape="line" text="Link Topic"><icon id="sign_info"/><link url="http://www.bing.com"/><topic id="2" position="400,200" order="0" shape="line" text="Link Topic Topic"><icon id="sign_warning"/><link url="http://bing.com"/></topic></topic></topic></map>
|
@ -1 +1 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><map version="0.9.0"><node TEXT="Shapes" ID="ID_0"><node TEXT="Node Styles" POSITION="right" ID="ID_1"><node TEXT="Fork" POSITION="right" ID="ID_2"><edge COLOR="#808080"/></node><node TEXT="Bubble" STYLE="bubble" POSITION="right" ID="ID_3"><edge COLOR="#808080"/></node><node TEXT="As parent" POSITION="right" ID="ID_4"><edge COLOR="#808080"/></node><node TEXT="Combined" POSITION="right" ID="ID_5"><edge COLOR="#808080"/></node></node><node TEXT="Node Background Color" POSITION="left" ID="ID_6" BACKGROUND_COLOR="#f20707"><node TEXT="Fork" POSITION="left" ID="ID_7" BACKGROUND_COLOR="#0000cc"><edge COLOR="#808080"/></node><node TEXT="Bubble" STYLE="bubble" POSITION="left" ID="ID_8" BACKGROUND_COLOR="#ccffcc"><edge COLOR="#808080"/></node><node TEXT="As parent" POSITION="left" ID="ID_9" BACKGROUND_COLOR="#00ffff"><edge COLOR="#808080"/></node><node TEXT="Combined" POSITION="left" ID="ID_10" BACKGROUND_COLOR="#990099"><edge COLOR="#808080"/></node></node><node TEXT="Node Text Color" POSITION="left" ID="ID_11" BACKGROUND_COLOR="#f20707"><node TEXT="Fork" POSITION="left" ID="ID_12" COLOR="#ffff00" BACKGROUND_COLOR="#0000cc"><edge COLOR="#808080"/></node><node TEXT="Bubble" STYLE="bubble" POSITION="left" ID="ID_13" COLOR="#ff6666" BACKGROUND_COLOR="#ccffcc"><edge COLOR="#808080"/></node><node TEXT="As parent" POSITION="left" ID="ID_14" COLOR="#009999" BACKGROUND_COLOR="#00ffff"><edge COLOR="#808080"/></node><node TEXT="Combined" POSITION="left" ID="ID_15" COLOR="#009999" BACKGROUND_COLOR="#990099"><edge COLOR="#808080"/></node></node></node></map>
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><map version="0.9.0"><node TEXT="Shapes" ID="ID_0"><node WORDER="1" wCOORDS="200,-50" TEXT="Node Styles" POSITION="right" ID="ID_1"><node WORDER="0" wCOORDS="400,200" TEXT="Fork" POSITION="right" ID="ID_2"><edge COLOR="#808080"/></node><node WORDER="1" wCOORDS="400,200" TEXT="Bubble" STYLE="bubble" POSITION="right" ID="ID_3"><edge COLOR="#808080"/></node><node WORDER="2" wCOORDS="400,200" TEXT="As parent" POSITION="right" ID="ID_4"><edge COLOR="#808080"/></node><node WORDER="3" wCOORDS="400,200" TEXT="Combined" POSITION="right" ID="ID_5"><edge COLOR="#808080"/></node></node><node WORDER="3" wCOORDS="-200,-100" TEXT="Node Background Color" POSITION="left" ID="ID_6" BACKGROUND_COLOR="#f20707"><node WORDER="0" wCOORDS="-400,200" TEXT="Fork" POSITION="left" ID="ID_7" BACKGROUND_COLOR="#0000cc"><edge COLOR="#808080"/></node><node WORDER="1" wCOORDS="-400,200" TEXT="Bubble" STYLE="bubble" POSITION="left" ID="ID_8" BACKGROUND_COLOR="#ccffcc"><edge COLOR="#808080"/></node><node WORDER="2" wCOORDS="-400,200" TEXT="As parent" POSITION="left" ID="ID_9" BACKGROUND_COLOR="#00ffff"><edge COLOR="#808080"/></node><node WORDER="3" wCOORDS="-400,200" TEXT="Combined" POSITION="left" ID="ID_10" BACKGROUND_COLOR="#990099"><edge COLOR="#808080"/></node></node><node WORDER="0" wCOORDS="-200,0" TEXT="Node Text Color" POSITION="left" ID="ID_11" BACKGROUND_COLOR="#f20707"><node WORDER="0" wCOORDS="-400,200" TEXT="Fork" POSITION="left" ID="ID_12" COLOR="#ffff00" BACKGROUND_COLOR="#0000cc"><edge COLOR="#808080"/></node><node WORDER="1" wCOORDS="-400,200" TEXT="Bubble" STYLE="bubble" POSITION="left" ID="ID_13" COLOR="#ff6666" BACKGROUND_COLOR="#ccffcc"><edge COLOR="#808080"/></node><node WORDER="2" wCOORDS="-400,200" TEXT="As parent" POSITION="left" ID="ID_14" COLOR="#009999" BACKGROUND_COLOR="#00ffff"><edge COLOR="#808080"/></node><node WORDER="3" wCOORDS="-400,200" TEXT="Combined" POSITION="left" ID="ID_15" COLOR="#009999" BACKGROUND_COLOR="#990099"><edge COLOR="#808080"/></node></node></node></map>
|
1
wise-webapp/src/test/data/freemind/node-styles.wxml
Normal file
1
wise-webapp/src/test/data/freemind/node-styles.wxml
Normal file
@ -0,0 +1 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><map version="pela" name="basic"><topic id="0" central="true" shape="rounded rectagle" text="Shapes"><topic id="1" position="200,-50" order="1" shape="line" text="Node Styles"><topic id="2" position="400,200" order="0" brColor="#808080" shape="line" text="Fork"/><topic id="3" position="400,200" order="1" brColor="#808080" shape="rounded rectagle" text="Bubble"/><topic id="4" position="400,200" order="2" brColor="#808080" shape="line" text="As parent"/><topic id="5" position="400,200" order="3" brColor="#808080" shape="line" text="Combined"/></topic><topic id="6" position="-200,-100" order="3" bgColor="#f20707" shape="line" text="Node Background Color"><topic id="7" position="-400,200" order="0" brColor="#808080" bgColor="#0000cc" shape="line" text="Fork"/><topic id="8" position="-400,200" order="1" brColor="#808080" bgColor="#ccffcc" shape="rounded rectagle" text="Bubble"/><topic id="9" position="-400,200" order="2" brColor="#808080" bgColor="#00ffff" shape="line" text="As parent"/><topic id="10" position="-400,200" order="3" brColor="#808080" bgColor="#990099" shape="line" text="Combined"/></topic><topic id="11" position="-200,0" order="0" bgColor="#f20707" shape="line" text="Node Text Color"><topic id="12" position="-400,200" order="0" brColor="#808080" bgColor="#0000cc" fontStyle=";;#ffff00;;;" shape="line" text="Fork"/><topic id="13" position="-400,200" order="1" brColor="#808080" bgColor="#ccffcc" fontStyle=";;#ff6666;;;" shape="rounded rectagle" text="Bubble"/><topic id="14" position="-400,200" order="2" brColor="#808080" bgColor="#00ffff" fontStyle=";;#009999;;;" shape="line" text="As parent"/><topic id="15" position="-400,200" order="3" brColor="#808080" bgColor="#990099" fontStyle=";;#009999;;;" shape="line" text="Combined"/></topic></topic></map>
|
@ -29,45 +29,65 @@ public class ImportExportTest {
|
||||
|
||||
|
||||
@Test(dataProvider = "Data-Provider-Function")
|
||||
public void exportImportExportTest(@NotNull final File freeMindFile, @NotNull final File recFile) throws ImporterException, IOException, ExportException {
|
||||
public void exportImportExportTest(@NotNull final File freeMindFile, @NotNull final File wiseFile, @NotNull final File freeRecFile) throws ImporterException, IOException, ExportException {
|
||||
|
||||
|
||||
FileInputStream fileInputStream = new FileInputStream(freeMindFile.getAbsolutePath());
|
||||
final FileInputStream fileInputStream = new FileInputStream(freeMindFile.getAbsolutePath());
|
||||
final MindMap mindMap = importer.importMap("basic", "basic", fileInputStream);
|
||||
|
||||
if (recFile.exists()) {
|
||||
|
||||
// Compare mindmap output ...
|
||||
if (wiseFile.exists()) {
|
||||
// Compare rec and file ...
|
||||
final String recContent = readFile(wiseFile);
|
||||
|
||||
// Load rec file co
|
||||
final FileInputStream fis = new FileInputStream(recFile);
|
||||
final InputStreamReader isr = new InputStreamReader(fis);
|
||||
final BufferedReader br = new BufferedReader(isr);
|
||||
// Export mile content ...
|
||||
Assert.assertEquals(mindMap.getUnzippedXml(), recContent);
|
||||
|
||||
final StringBuilder recContent = new StringBuilder();
|
||||
String line = br.readLine();
|
||||
while (line != null) {
|
||||
recContent.append(line);
|
||||
line = br.readLine();
|
||||
} else {
|
||||
final FileOutputStream fos = new FileOutputStream(wiseFile);
|
||||
fos.write(mindMap.getUnzippedXml().getBytes());
|
||||
fos.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fis.close();
|
||||
// Compare freemind output ...
|
||||
if (freeRecFile.exists()) {
|
||||
// Compare rec and file ...
|
||||
final String recContent = readFile(freeRecFile);
|
||||
|
||||
// Export mile content ...
|
||||
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
exporter.export(mindMap, bos);
|
||||
final String exportContent = new String(bos.toByteArray());
|
||||
|
||||
Assert.assertEquals(recContent.toString(), exportContent);
|
||||
Assert.assertEquals(exportContent, recContent);
|
||||
|
||||
} else {
|
||||
final FileOutputStream fos = new FileOutputStream(recFile);
|
||||
final FileOutputStream fos = new FileOutputStream(freeRecFile);
|
||||
exporter.export(mindMap, fos);
|
||||
fos.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String readFile(@NotNull File file) throws IOException {
|
||||
// Load rec file co
|
||||
final FileInputStream fis = new FileInputStream(file);
|
||||
final InputStreamReader isr = new InputStreamReader(fis);
|
||||
final BufferedReader br = new BufferedReader(isr);
|
||||
|
||||
final StringBuilder result = new StringBuilder();
|
||||
String line = br.readLine();
|
||||
while (line != null) {
|
||||
result.append(line);
|
||||
line = br.readLine();
|
||||
|
||||
}
|
||||
|
||||
fis.close();
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
//This function will provide the parameter data
|
||||
@DataProvider(name = "Data-Provider-Function")
|
||||
public Object[][] parameterIntTestProvider() {
|
||||
@ -84,7 +104,8 @@ public class ImportExportTest {
|
||||
for (int i = 0; i < freeMindFiles.length; i++) {
|
||||
File freeMindFile = freeMindFiles[i];
|
||||
final String name = freeMindFile.getName();
|
||||
result[i] = new Object[]{freeMindFile, new File(DATA_DIR_PATH, name.substring(0, name.lastIndexOf(".")) + ".mmr")};
|
||||
String testName = name.substring(0, name.lastIndexOf("."));
|
||||
result[i] = new Object[]{freeMindFile, new File(DATA_DIR_PATH, testName + ".wxml"), new File(DATA_DIR_PATH, testName + ".mmr")};
|
||||
}
|
||||
|
||||
return result;
|
||||
|
Loading…
Reference in New Issue
Block a user