Fix freeming import issue with fonts.

This commit is contained in:
Paulo Gustavo Veiga 2011-03-27 14:44:09 -03:00
parent 334c9820b3
commit 308250ab73
4 changed files with 52 additions and 7 deletions

View File

@ -31,6 +31,7 @@ import com.wisemapping.xml.freemind.Node;
import com.wisemapping.xml.mindmap.RelationshipType; import com.wisemapping.xml.mindmap.RelationshipType;
import com.wisemapping.xml.mindmap.TopicType; import com.wisemapping.xml.mindmap.TopicType;
import com.wisemapping.xml.mindmap.Link; import com.wisemapping.xml.mindmap.Link;
import org.jetbrains.annotations.NotNull;
import org.w3c.dom.*; import org.w3c.dom.*;
import javax.xml.bind.JAXBException; import javax.xml.bind.JAXBException;
@ -421,23 +422,23 @@ public class FreemindImporter
boolean hasBold = Boolean.parseBoolean(font.getBOLD()); boolean hasBold = Boolean.parseBoolean(font.getBOLD());
fontStyle.append(hasBold ? BOLD : null); fontStyle.append(hasBold ? BOLD : "");
fontStyle.append(";"); fontStyle.append(";");
boolean hasItalic = Boolean.parseBoolean(font.getITALIC()); boolean hasItalic = Boolean.parseBoolean(font.getITALIC());
fontStyle.append(hasItalic ? ITALIC : null); fontStyle.append(hasItalic ? ITALIC : "");
fontStyle.append(";"); fontStyle.append(";");
} }
return fontStyle.toString(); return fontStyle.toString();
} }
private String fixFontName(Font font) { private @NotNull String fixFontName(@NotNull Font font) {
String fontName = com.wisemapping.model.Font.ARIAL.getFontName(); // Default Font String result = com.wisemapping.model.Font.ARIAL.getFontName(); // Default Font
if (com.wisemapping.model.Font.isValidFont(font.getNAME())) { if (com.wisemapping.model.Font.isValidFont(font.getNAME())) {
fontName = font.getNAME(); result = font.getNAME();
} }
return fontName; return result;
} }
private String getShapeFormFromNode(Node node) { private String getShapeFormFromNode(Node node) {

View File

@ -18,6 +18,8 @@
package com.wisemapping.model; package com.wisemapping.model;
import org.jetbrains.annotations.NotNull;
public enum Font { public enum Font {
VERDANA("Verdana"), VERDANA("Verdana"),
@ -37,7 +39,7 @@ public enum Font {
return fontName; return fontName;
} }
public static boolean isValidFont(String font) { public static boolean isValidFont(@NotNull String font) {
boolean isValid = false; boolean isValid = false;
try { try {
if (font != null) { if (font != null) {
@ -45,6 +47,7 @@ public enum Font {
} }
} }
catch (IllegalArgumentException ignote) { catch (IllegalArgumentException ignote) {
// Ignore ...
} }
return isValid; return isValid;

View File

@ -0,0 +1,40 @@
<map version="0.9.0">
<!-- To view this file, download free mind mapping software FreeMind from http://freemind.sourceforge.net -->
<node CREATED="1301246214383" ID="ID_886000454" MODIFIED="1301246809450" TEXT="Fonts">
<node CREATED="1301246745581" ID="ID_1660145973" MODIFIED="1301246791264" POSITION="right" TEXT="Styles">
<node CREATED="1301246795175" ID="ID_377120709" MODIFIED="1301246807857" TEXT="Bold">
<font BOLD="true" NAME="SansSerif" SIZE="12"/>
</node>
<node CREATED="1301246801304" ID="ID_634022293" MODIFIED="1301246805049" TEXT="Italic">
<font ITALIC="true" NAME="SansSerif" SIZE="12"/>
</node>
</node>
<node CREATED="1301246811914" ID="ID_985556570" MODIFIED="1301246828567" POSITION="left" TEXT="Sizes">
<node CREATED="1301246830694" ID="ID_1639638373" MODIFIED="1301247011414" TEXT="Normal----">
<font NAME="SansSerif" SIZE="8"/>
</node>
<node CREATED="1301246896679" ID="ID_75566823" MODIFIED="1301247008837" TEXT="Normal---">
<font NAME="SansSerif" SIZE="9"/>
</node>
<node CREATED="1301246906578" ID="ID_1461302973" MODIFIED="1301247006341" TEXT="Normal--">
<font NAME="SansSerif" SIZE="10"/>
</node>
<node CREATED="1301246910322" ID="ID_665416540" MODIFIED="1301247003973" TEXT="Normal-">
<font NAME="SansSerif" SIZE="11"/>
</node>
<node CREATED="1301246912939" ID="ID_233600021" MODIFIED="1301246915096" TEXT="Normal"/>
<node CREATED="1301246859184" ID="ID_896947877" MODIFIED="1301247013502" TEXT="Nomal+">
<font NAME="SansSerif" SIZE="13"/>
</node>
<node CREATED="1301246865377" ID="ID_1683824358" MODIFIED="1301247015230" TEXT="Normal++">
<font NAME="SansSerif" SIZE="14"/>
</node>
<node CREATED="1301246869962" ID="ID_1125002733" MODIFIED="1301247017383" TEXT="Normal+++">
<font NAME="SansSerif" SIZE="15"/>
</node>
<node CREATED="1301246885853" ID="ID_878767930" MODIFIED="1301247021344" TEXT="Normal++++">
<font NAME="SansSerif" SIZE="16"/>
</node>
</node>
</node>
</map>

View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><map version="0.9.0"><node TEXT="Fonts" STYLE="elipse" 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>