changing default shapes to be all lines, and fixing text centering bug
This commit is contained in:
committed by
Paulo Gustavo Veiga
parent
d97121ce87
commit
405f0d9998
@@ -18,14 +18,16 @@
|
||||
|
||||
package com.wisemapping.importer;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
|
||||
public class ImporterException
|
||||
extends Exception
|
||||
{
|
||||
public ImporterException(String str)
|
||||
public ImporterException(@NotNull String str)
|
||||
{
|
||||
super(str);
|
||||
}
|
||||
public ImporterException(Throwable exc)
|
||||
public ImporterException(@NotNull Throwable exc)
|
||||
{
|
||||
super(exc);
|
||||
}
|
||||
|
@@ -0,0 +1,104 @@
|
||||
package com.wisemapping.importer;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class VersionNumber
|
||||
implements Comparable {
|
||||
|
||||
protected String version_d;
|
||||
|
||||
//~ Constructors .........................................................................................
|
||||
|
||||
public VersionNumber(final String version) {
|
||||
version_d = version;
|
||||
}
|
||||
|
||||
//~ Methods ..............................................................................................
|
||||
|
||||
/**
|
||||
* Answers whether the receiver is greater then the given version number.
|
||||
*
|
||||
* @param versionNumber the version number to compare to
|
||||
* @return true if the receiver has a greater version number, false otherwise
|
||||
*/
|
||||
public boolean isGreaterThan(final VersionNumber versionNumber) {
|
||||
return this.compareTo(versionNumber) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Answers whether the receiver is smaller then the given version number.
|
||||
*
|
||||
* @param versionNumber the version number to compare to
|
||||
* @return true if the receiver has a smaller version number, false otherwise
|
||||
*/
|
||||
public boolean isSmallerThan(final VersionNumber versionNumber) {
|
||||
return this.compareTo(versionNumber) < 0;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version_d;
|
||||
}
|
||||
|
||||
|
||||
public int compareTo(final Object otherObject) {
|
||||
if (this.equals(otherObject)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
final StringTokenizer ownTokenizer = this.getTokenizer();
|
||||
final StringTokenizer otherTokenizer = ((VersionNumber) otherObject).getTokenizer();
|
||||
|
||||
while (ownTokenizer.hasMoreTokens()) {
|
||||
final int ownNumber;
|
||||
final int otherNumber;
|
||||
|
||||
try {
|
||||
ownNumber = Integer.parseInt(ownTokenizer.nextToken());
|
||||
otherNumber = Integer.parseInt(otherTokenizer.nextToken());
|
||||
} catch (NoSuchElementException nseex) {
|
||||
// only possible if we have more tokens than the other version -
|
||||
// if we get to this point then we are always greater
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ownNumber > otherNumber) {
|
||||
return 1;
|
||||
} else if (ownNumber < otherNumber) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// if other version still has tokens then it is greater than me!
|
||||
otherTokenizer.nextToken();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(o instanceof VersionNumber)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final VersionNumber versionNumber = (VersionNumber) o;
|
||||
|
||||
if (version_d != null ? !version_d.equals(versionNumber.version_d)
|
||||
: versionNumber.version_d != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return (version_d != null ? version_d.hashCode() : 0);
|
||||
}
|
||||
|
||||
|
||||
protected StringTokenizer getTokenizer() {
|
||||
return new StringTokenizer(this.getVersion(), ".");
|
||||
}
|
||||
}
|
@@ -21,6 +21,7 @@ package com.wisemapping.importer.freemind;
|
||||
import com.sun.org.apache.xerces.internal.dom.TextImpl;
|
||||
import com.wisemapping.importer.Importer;
|
||||
import com.wisemapping.importer.ImporterException;
|
||||
import com.wisemapping.importer.VersionNumber;
|
||||
import com.wisemapping.model.MindMap;
|
||||
import com.wisemapping.model.ShapeStyle;
|
||||
import com.wisemapping.util.JAXBUtils;
|
||||
@@ -57,6 +58,8 @@ public class FreemindImporter
|
||||
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 static final VersionNumber SUPPORTED_FREEMIND_VERSION = new VersionNumber("0.9.0");
|
||||
|
||||
|
||||
private int currentId;
|
||||
|
||||
@@ -98,6 +101,16 @@ public class FreemindImporter
|
||||
try {
|
||||
String wiseXml;
|
||||
final Map freemindMap = (Map) JAXBUtils.getMapObject(input, "com.wisemapping.xml.freemind");
|
||||
|
||||
final String version = freemindMap.getVersion();
|
||||
if (version != null) {
|
||||
final VersionNumber mapVersion = new VersionNumber(version);
|
||||
if (SUPPORTED_FREEMIND_VERSION.isGreaterThan(mapVersion)) {
|
||||
throw new ImporterException("FreeMind map has been created with '" + mapVersion.getVersion() + "'. Supported FreeMind version is '" + SUPPORTED_FREEMIND_VERSION.getVersion() + "' or greater.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
||||
final com.wisemapping.xml.mindmap.Map mindmapMap = mindmapObjectFactory.createMap();
|
||||
|
Reference in New Issue
Block a user