From d5ac7376b33e9e1cd06f9214857a5ac2c0ef1c8c Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Sun, 20 Mar 2011 22:49:31 -0300 Subject: [PATCH] Fix image mappings issue during export/import to freemind. --- .gitignore | 1 + .../exporter/freemind/FreemindExporter.java | 12 +- .../exporter/freemind/FreemindIconMapper.java | 86 ------- .../freemind/FreemindIconConverter.java | 99 ++++++++ .../importer/freemind/FreemindIconMapper.java | 84 ------- .../importer/freemind/FreemindImporter.java | 21 +- .../{ImageFamily.java => IconFamily.java} | 6 +- .../{MindmapImage.java => MindmapIcon.java} | 8 +- .../com/wisemapping/model/MindmapIcons.java | 226 ++++++++++++++++++ .../model/MindmapImagesFactory.java | 216 ----------------- wise-webapp/src/main/webapp/icons/icons.xml | 9 + wise-webapp/src/test/data/freemind/icons.mm | 154 ++++++++++++ wise-webapp/src/test/data/freemind/icons.mmr | 1 + 13 files changed, 518 insertions(+), 405 deletions(-) delete mode 100755 wise-webapp/src/main/java/com/wisemapping/exporter/freemind/FreemindIconMapper.java create mode 100755 wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindIconConverter.java delete mode 100755 wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindIconMapper.java rename wise-webapp/src/main/java/com/wisemapping/model/{ImageFamily.java => IconFamily.java} (90%) rename wise-webapp/src/main/java/com/wisemapping/model/{MindmapImage.java => MindmapIcon.java} (84%) create mode 100755 wise-webapp/src/main/java/com/wisemapping/model/MindmapIcons.java delete mode 100755 wise-webapp/src/main/java/com/wisemapping/model/MindmapImagesFactory.java create mode 100644 wise-webapp/src/main/webapp/icons/icons.xml create mode 100644 wise-webapp/src/test/data/freemind/icons.mm create mode 100644 wise-webapp/src/test/data/freemind/icons.mmr diff --git a/.gitignore b/.gitignore index 3a64bbab..c57810ae 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ wisemapping.ipr wisemapping.iws wisemapping.iml +wise-webapp/wisemapping.log diff --git a/wise-webapp/src/main/java/com/wisemapping/exporter/freemind/FreemindExporter.java b/wise-webapp/src/main/java/com/wisemapping/exporter/freemind/FreemindExporter.java index d7f0a093..45bed69a 100755 --- a/wise-webapp/src/main/java/com/wisemapping/exporter/freemind/FreemindExporter.java +++ b/wise-webapp/src/main/java/com/wisemapping/exporter/freemind/FreemindExporter.java @@ -20,6 +20,7 @@ package com.wisemapping.exporter.freemind; import com.wisemapping.exporter.ExportException; import com.wisemapping.exporter.Exporter; +import com.wisemapping.importer.freemind.FreemindIconConverter; import com.wisemapping.model.MindMap; import com.wisemapping.util.JAXBUtils; import com.wisemapping.xml.freemind.*; @@ -174,10 +175,13 @@ public class FreemindExporter final List iconsList = mindmapTopic.getIcon(); for (Icon icon : iconsList) { final String id = icon.getId(); - com.wisemapping.xml.freemind.Icon freemindIcon = new com.wisemapping.xml.freemind.Icon(); - final String freemindIconId = FreemindIconMapper.getFreemindIcon(id); - freemindIcon.setBUILTIN(freemindIconId); - freemindNode.getArrowlinkOrCloudOrEdge().add(freemindIcon); + final String freemindIconId = FreemindIconConverter.toFreemindId(id); + if (freemindIconId != null) { + + com.wisemapping.xml.freemind.Icon freemindIcon = new com.wisemapping.xml.freemind.Icon(); + freemindIcon.setBUILTIN(freemindIconId); + freemindNode.getArrowlinkOrCloudOrEdge().add(freemindIcon); + } } } } diff --git a/wise-webapp/src/main/java/com/wisemapping/exporter/freemind/FreemindIconMapper.java b/wise-webapp/src/main/java/com/wisemapping/exporter/freemind/FreemindIconMapper.java deleted file mode 100755 index db0eefbb..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/exporter/freemind/FreemindIconMapper.java +++ /dev/null @@ -1,86 +0,0 @@ -/* -* Copyright [2011] [wisemapping] -* -* Licensed under WiseMapping Public License, Version 1.0 (the "License"). -* It is basically the Apache License, Version 2.0 (the "License") plus the -* "powered by wisemapping" text requirement on every single page; -* you may not use this file except in compliance with the License. -* You may obtain a copy of the license at -* -* http://www.wisemapping.org/license -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -package com.wisemapping.exporter.freemind; - -import com.wisemapping.model.MindmapImagesFactory; -import com.wisemapping.model.ImageFamily; -import com.wisemapping.model.MindmapImage; - -import java.util.Map; -import java.util.HashMap; -import java.util.List; - -public class FreemindIconMapper { - - - private static Map mindmapImageToFreemind = new HashMap(); - private static final String DEFAULT_ICON = "button_ok"; - - public FreemindIconMapper() - { - - } - - public static String getFreemindIcon(String mindmapImageId) - { - - String freemindIconId = mindmapImageToFreemind.get(mindmapImageId); - - // The image doesn´t exists in freemind select he default image - if (freemindIconId == null) - { - freemindIconId = DEFAULT_ICON; - } - return freemindIconId; - } - - static { - - List images = MindmapImagesFactory.getImagesByFamily(ImageFamily.BULLET); - - for (int idx=0; idx < images.size() ; idx++) - { - mindmapImageToFreemind.put(images.get(idx).getId(), "full-"+(idx+1)); - } - - images = MindmapImagesFactory.getImagesByFamily(ImageFamily.FLAG); - for (MindmapImage mindmapImage : images) { - mindmapImageToFreemind.put(mindmapImage.getId(), "flag"); - } - - images = MindmapImagesFactory.getImagesByFamily(ImageFamily.BULB); - mindmapImageToFreemind.put(images.get(0).getId(), "idea"); - - images = MindmapImagesFactory.getImagesByFamily(ImageFamily.TICK); - mindmapImageToFreemind.put(images.get(0).getId(), "button_ok"); - mindmapImageToFreemind.put(images.get(1).getId(), "button_cancel"); - - images = MindmapImagesFactory.getImagesByFamily(ImageFamily.ARROW); - mindmapImageToFreemind.put(images.get(2).getId(), "back"); - mindmapImageToFreemind.put(images.get(3).getId(), "forward"); - - images = MindmapImagesFactory.getImagesByFamily(ImageFamily.FACE); - mindmapImageToFreemind.put(images.get(3).getId(), "ksmiletris"); - - images = MindmapImagesFactory.getImagesByFamily(ImageFamily.FLAG); - for (MindmapImage mindmapImage : images) { - mindmapImageToFreemind.put(mindmapImage.getId(), "flag"); - } - } -} diff --git a/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindIconConverter.java b/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindIconConverter.java new file mode 100755 index 00000000..a08e25cf --- /dev/null +++ b/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindIconConverter.java @@ -0,0 +1,99 @@ +/* +* Copyright [2011] [wisemapping] +* +* Licensed under WiseMapping Public License, Version 1.0 (the "License"). +* It is basically the Apache License, Version 2.0 (the "License") plus the +* "powered by wisemapping" text requirement on every single page; +* you may not use this file except in compliance with the License. +* You may obtain a copy of the license at +* +* http://www.wisemapping.org/license +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package com.wisemapping.importer.freemind; + +import com.wisemapping.model.MindmapIcon; +import com.wisemapping.model.MindmapIcons; +import com.wisemapping.model.IconFamily; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Map; +import java.util.HashMap; +import java.util.List; +import java.util.Set; + +final public class FreemindIconConverter { + + + private final static Map freeIdToIcon = new HashMap(); + private final static Map iconToFreeId = new HashMap(); + + private static final MindmapIcon DEFAULT_ICON = MindmapIcons.getIconByFamily(IconFamily.BULLET).get(3); + + private FreemindIconConverter() { + + } + + @Nullable + public static String toWiseId(@NotNull String iconId) { + final MindmapIcon result = freeIdToIcon.get(iconId); + return result!=null?result.getId():null; + } + + @Nullable + public static String toFreemindId(@NotNull String iconId) { + return iconToFreeId.get(MindmapIcons.findById(iconId)); + } + + + static { + + // Load bullets image mapping ... + final List bulletsImages = MindmapIcons.getIconByFamily(IconFamily.BULLET); + for (int i = 0; i < bulletsImages.size(); i++) { + final MindmapIcon icon = bulletsImages.get(i); + iconToFreeId.put(icon, "full-" + i); + } + + final List bulbImages = MindmapIcons.getIconByFamily(IconFamily.BULB); + iconToFreeId.put(bulbImages.get(0), "idea"); + + final List tickImages = MindmapIcons.getIconByFamily(IconFamily.TICK); + iconToFreeId.put(tickImages.get(0), "button_ok"); + iconToFreeId.put(tickImages.get(1), "button_cancel"); + + // Map arrow icons ... + iconToFreeId.put(MindmapIcons.ARROW_UP, "up"); + iconToFreeId.put(MindmapIcons.ARROW_DOWN, "down"); + iconToFreeId.put(MindmapIcons.ARROW_RIGHT, "back"); + iconToFreeId.put(MindmapIcons.ARROW_LEFT, "forward"); + + // Map smile icons ... + iconToFreeId.put(MindmapIcons.FACE_PLAIN, "smiley-neutral"); + iconToFreeId.put(MindmapIcons.FACE_SMILE, "ksmiletris"); + iconToFreeId.put(MindmapIcons.FACE_SURPRISE, "smiley-oh"); + iconToFreeId.put(MindmapIcons.FACE_SAD, "smiley_bad"); + + + // Maps Flag familly Icons ... + final List flagImages = MindmapIcons.getIconByFamily(IconFamily.FLAG); + for (MindmapIcon flagImage : flagImages) { + iconToFreeId.put(flagImage, "flag-" + flagImage.getName()); + } + + + final Set mindmapIcons = iconToFreeId.keySet(); + for (MindmapIcon mindmapIcon : mindmapIcons) { + freeIdToIcon.put(iconToFreeId.get(mindmapIcon), mindmapIcon); + } + + + } +} diff --git a/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindIconMapper.java b/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindIconMapper.java deleted file mode 100755 index 66c102dc..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindIconMapper.java +++ /dev/null @@ -1,84 +0,0 @@ -/* -* Copyright [2011] [wisemapping] -* -* Licensed under WiseMapping Public License, Version 1.0 (the "License"). -* It is basically the Apache License, Version 2.0 (the "License") plus the -* "powered by wisemapping" text requirement on every single page; -* you may not use this file except in compliance with the License. -* You may obtain a copy of the license at -* -* http://www.wisemapping.org/license -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -package com.wisemapping.importer.freemind; - -import com.wisemapping.model.MindmapImage; -import com.wisemapping.model.MindmapImagesFactory; -import com.wisemapping.model.ImageFamily; - -import java.util.Map; -import java.util.HashMap; -import java.util.List; - -public class FreemindIconMapper { - - - private static Map freemindToMindmapIcon = new HashMap(); - private static final MindmapImage DEFAULT_ICON = MindmapImagesFactory.getImagesByFamily(ImageFamily.BULLET).get(3); - - public FreemindIconMapper() - { - - } - - public static String getMindmapIcon(String freemindIconId) - { - - String iconId = freemindToMindmapIcon.get(freemindIconId); - - // The image doesn´t exists in freemind select he default image - if (iconId == null) - { - iconId = DEFAULT_ICON.getId(); - } - return iconId; - } - - static { - - List images = MindmapImagesFactory.getImagesByFamily(ImageFamily.BULLET); - - freemindToMindmapIcon.put( "full-1",images.get(0).getId()); - freemindToMindmapIcon.put( "full-2",images.get(1).getId()); - freemindToMindmapIcon.put( "full-3",images.get(2).getId()); - freemindToMindmapIcon.put( "full-4",images.get(3).getId()); - freemindToMindmapIcon.put( "full-5",images.get(4).getId()); - freemindToMindmapIcon.put( "full-6",images.get(5).getId()); - freemindToMindmapIcon.put( "full-7",images.get(6).getId()); - - images = MindmapImagesFactory.getImagesByFamily(ImageFamily.BULB); - freemindToMindmapIcon.put( "idea",images.get(0).getId()); - - images = MindmapImagesFactory.getImagesByFamily(ImageFamily.TICK); - freemindToMindmapIcon.put( "button_ok",images.get(0).getId()); - freemindToMindmapIcon.put( "button_cancel",images.get(1).getId()); - - images = MindmapImagesFactory.getImagesByFamily(ImageFamily.ARROW); - freemindToMindmapIcon.put( "back",images.get(2).getId()); - freemindToMindmapIcon.put( "forward",images.get(3).getId()); - - images = MindmapImagesFactory.getImagesByFamily(ImageFamily.FACE); - freemindToMindmapIcon.put( "ksmiletris",images.get(3).getId()); - - images = MindmapImagesFactory.getImagesByFamily(ImageFamily.FLAG); - - final MindmapImage orangeFlag = images.get(2); - freemindToMindmapIcon.put("flag", orangeFlag.getId()); - } -} 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 b57ee640..58f30b56 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 @@ -266,17 +266,22 @@ public class FreemindImporter currentTopic.setBrColor(edge.getCOLOR()); } else if (freemindNode instanceof Icon) { final Icon freemindIcon = (Icon) freemindNode; - final com.wisemapping.xml.mindmap.Icon mindmapIcon = new com.wisemapping.xml.mindmap.Icon(); - final String mindmapIconId = FreemindIconMapper.getMindmapIcon(freemindIcon.getBUILTIN()); - mindmapIcon.setId(mindmapIconId); - currentTopic.getIcon().add(mindmapIcon); + + 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); + } + } else if (freemindNode instanceof Hook) { final Hook hook = (Hook) freemindNode; 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 = textNote != null ? textNote.replaceAll("\n", "%0A") : EMPTY_NOTE; + textNote = EMPTY_NOTE; mindmapNote.setText(textNote); currentTopic.setNote(mindmapNote); } @@ -285,9 +290,9 @@ public class FreemindImporter final String type = content.getTYPE(); if (type.equals("NODE")) { - final String text = getText(content); - text.replaceAll("\n", ""); - text.trim(); + String text = getText(content); + text = text.replaceAll("\n", ""); + text = text.trim(); currentTopic.setText(text); } else { String text = getRichContent(content); diff --git a/wise-webapp/src/main/java/com/wisemapping/model/ImageFamily.java b/wise-webapp/src/main/java/com/wisemapping/model/IconFamily.java similarity index 90% rename from wise-webapp/src/main/java/com/wisemapping/model/ImageFamily.java rename to wise-webapp/src/main/java/com/wisemapping/model/IconFamily.java index 9f0405ca..56a6f4bf 100755 --- a/wise-webapp/src/main/java/com/wisemapping/model/ImageFamily.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/IconFamily.java @@ -18,12 +18,12 @@ package com.wisemapping.model; -public enum ImageFamily { +public enum IconFamily { FLAG("FLAG","flag_"), BULLET("BULLET","bullet_"), TAG("TAG","tag_"), NUMBER("NUMBER","number_"), - FACE("FACE","face_"), + SMILEY("FACE","face_"), FACE_FUNY("FACEFUNY","facefuny_"), ARROW("ARROW","arrow_"), ARROWC("ARROWC","arrowc_"), @@ -39,7 +39,7 @@ public enum ImageFamily { private String prefix; private String name; - ImageFamily(String name, String prefix) { + IconFamily(String name, String prefix) { this.name = name; this.prefix = prefix; } diff --git a/wise-webapp/src/main/java/com/wisemapping/model/MindmapImage.java b/wise-webapp/src/main/java/com/wisemapping/model/MindmapIcon.java similarity index 84% rename from wise-webapp/src/main/java/com/wisemapping/model/MindmapImage.java rename to wise-webapp/src/main/java/com/wisemapping/model/MindmapIcon.java index d30b9fbc..33af8099 100755 --- a/wise-webapp/src/main/java/com/wisemapping/model/MindmapImage.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/MindmapIcon.java @@ -18,12 +18,12 @@ package com.wisemapping.model; -public class MindmapImage +public class MindmapIcon { private String name; - private ImageFamily family; + private IconFamily family; - public MindmapImage(String name, ImageFamily family) + MindmapIcon(IconFamily family, String name) { this.name = name; this.family = family; @@ -34,7 +34,7 @@ public class MindmapImage return name; } - public ImageFamily getFamily() + public IconFamily getFamily() { return family; } diff --git a/wise-webapp/src/main/java/com/wisemapping/model/MindmapIcons.java b/wise-webapp/src/main/java/com/wisemapping/model/MindmapIcons.java new file mode 100755 index 00000000..24b4005d --- /dev/null +++ b/wise-webapp/src/main/java/com/wisemapping/model/MindmapIcons.java @@ -0,0 +1,226 @@ +/* +* Copyright [2011] [wisemapping] +* +* Licensed under WiseMapping Public License, Version 1.0 (the "License"). +* It is basically the Apache License, Version 2.0 (the "License") plus the +* "powered by wisemapping" text requirement on every single page; +* you may not use this file except in compliance with the License. +* You may obtain a copy of the license at +* +* http://www.wisemapping.org/license +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package com.wisemapping.model; + +import org.jetbrains.annotations.NotNull; + +import java.util.*; + +public class MindmapIcons { + + private static Map> images = new HashMap>(); + + public static final MindmapIcon FACE_PLAIN = new MindmapIcon(IconFamily.SMILEY, "plain"); + public static final MindmapIcon FACE_SAD = new MindmapIcon(IconFamily.SMILEY, "sad"); + public static final MindmapIcon FACE_CRYING = new MindmapIcon(IconFamily.SMILEY, "crying"); + public static final MindmapIcon FACE_SMILE = new MindmapIcon(IconFamily.SMILEY, "smile"); + public static final MindmapIcon FACE_SURPRISE = new MindmapIcon(IconFamily.SMILEY, "surprise"); + public static final MindmapIcon FACE_WINK = new MindmapIcon(IconFamily.SMILEY, "wink"); + + public static final MindmapIcon THUMB__UP = new MindmapIcon(IconFamily.THUMB, "thumb_up"); + public static final MindmapIcon THUMB_DOWN = new MindmapIcon(IconFamily.THUMB, "thumb_down"); + + public static final MindmapIcon ARROW_UP = new MindmapIcon(IconFamily.ARROW, "up"); + public static final MindmapIcon ARROW_DOWN = new MindmapIcon(IconFamily.ARROW, "down"); + public static final MindmapIcon ARROW_LEFT = new MindmapIcon(IconFamily.ARROW, "left"); + public static final MindmapIcon ARROW_RIGHT = new MindmapIcon(IconFamily.ARROW, "right"); + + static { + images.put(IconFamily.BULLET, getImagesBullet()); + images.put(IconFamily.FLAG, getImagesFlag()); + images.put(IconFamily.NUMBER, getImagesNumber()); + images.put(IconFamily.TAG, getImagesTag()); + images.put(IconFamily.TASK, getImagesTask()); + images.put(IconFamily.SMILEY, getImagesFaces()); + images.put(IconFamily.BULB, getImagesBulb()); + images.put(IconFamily.ARROW, getImagesArrow()); + images.put(IconFamily.ARROWC, getImagesArrowC()); + images.put(IconFamily.CONN, getImagesConn()); + images.put(IconFamily.THUMB, getImagesThumbs()); + images.put(IconFamily.TICK, getImagesTick()); + images.put(IconFamily.ONOFF, getImagesOnOff()); + images.put(IconFamily.MONEY, getImagesMoney()); + images.put(IconFamily.CHART, getImagesChart()); + } + + private static List getImagesFaces() { + final List images = new ArrayList(); + images.add(FACE_PLAIN); + images.add(FACE_SAD); + images.add(FACE_CRYING); + images.add(FACE_SMILE); + images.add(FACE_SURPRISE); + images.add(FACE_WINK); + return images; + } + + private static List getImagesArrow() { + final List result = new ArrayList(); + result.add(ARROW_UP); + result.add(ARROW_DOWN); + result.add(ARROW_LEFT); + result.add(ARROW_RIGHT); + return result; + } + + private static List getImagesArrowC() { + final List result = new ArrayList(); + result.add(new MindmapIcon(IconFamily.ARROWC, "undo")); + result.add(new MindmapIcon(IconFamily.ARROWC, "rotate_anticlockwise")); + result.add(new MindmapIcon(IconFamily.ARROWC, "rotate_clockwise")); + result.add(new MindmapIcon(IconFamily.ARROWC, "turn_left")); + result.add(new MindmapIcon(IconFamily.ARROWC, "turn_right")); + return result; + } + + private static List getImagesBulb() { + final List images = new ArrayList(); + images.add(new MindmapIcon(IconFamily.BULB, "light_on")); + images.add(new MindmapIcon(IconFamily.BULB, "light_off")); + return images; + } + + private static List getImagesTick() { + final List images = new ArrayList(); + images.add(new MindmapIcon(IconFamily.TICK, "tick")); + images.add(new MindmapIcon(IconFamily.TICK, "cross")); + return images; + } + + private static List getImagesChart() { + final List images = new ArrayList(); + images.add(new MindmapIcon(IconFamily.CHART, "bar")); + images.add(new MindmapIcon(IconFamily.CHART, "line")); + images.add(new MindmapIcon(IconFamily.CHART, "curve")); + images.add(new MindmapIcon(IconFamily.CHART, "pie")); + images.add(new MindmapIcon(IconFamily.CHART, "organisation")); + return images; + } + + private static List getImagesOnOff() { + final List images = new ArrayList(); + images.add(new MindmapIcon(IconFamily.ONOFF, "clock")); + images.add(new MindmapIcon(IconFamily.ONOFF, "clock_red")); + images.add(new MindmapIcon(IconFamily.ONOFF, "add")); + images.add(new MindmapIcon(IconFamily.ONOFF, "delete")); + return images; + } + + private static List getImagesMoney() { + final List images = new ArrayList(); + images.add(new MindmapIcon(IconFamily.MONEY, "money")); + images.add(new MindmapIcon(IconFamily.MONEY, "dollar")); + images.add(new MindmapIcon(IconFamily.MONEY, "euro")); + images.add(new MindmapIcon(IconFamily.MONEY, "pound")); + images.add(new MindmapIcon(IconFamily.MONEY, "yen")); + images.add(new MindmapIcon(IconFamily.MONEY, "coins")); + images.add(new MindmapIcon(IconFamily.MONEY, "ruby")); + return images; + } + + private static List getImagesThumbs() { + final List images = new ArrayList(); + images.add(THUMB__UP); + images.add(THUMB_DOWN); + return images; + } + + private static List getImagesConn() { + final List images = new ArrayList(); + images.add(new MindmapIcon(IconFamily.CONN, "connect")); + images.add(new MindmapIcon(IconFamily.CONN, "disconnect")); + return images; + } + + private static List getImagesBullet() { + final List images = new ArrayList(); + images.add(new MindmapIcon(IconFamily.BULLET, "black")); + images.add(new MindmapIcon(IconFamily.BULLET, "blue")); + images.add(new MindmapIcon(IconFamily.BULLET, "green")); + images.add(new MindmapIcon(IconFamily.BULLET, "orange")); + images.add(new MindmapIcon(IconFamily.BULLET, "red")); + images.add(new MindmapIcon(IconFamily.BULLET, "pink")); + images.add(new MindmapIcon(IconFamily.BULLET, "purple")); + return images; + } + + private static List getImagesFlag() { + final List images = new ArrayList(); + images.add(new MindmapIcon(IconFamily.FLAG, "blue")); + images.add(new MindmapIcon(IconFamily.FLAG, "green")); + images.add(new MindmapIcon(IconFamily.FLAG, "orange")); + images.add(new MindmapIcon(IconFamily.FLAG, "pink")); + images.add(new MindmapIcon(IconFamily.FLAG, "purple")); + images.add(new MindmapIcon(IconFamily.FLAG, "yellow")); + return images; + } + + private static List getImagesNumber() { + final List images = new ArrayList(); + images.add(new MindmapIcon(IconFamily.NUMBER, "one")); + images.add(new MindmapIcon(IconFamily.NUMBER, "two")); + images.add(new MindmapIcon(IconFamily.NUMBER, "three")); + images.add(new MindmapIcon(IconFamily.NUMBER, "four")); + images.add(new MindmapIcon(IconFamily.NUMBER, "five")); + images.add(new MindmapIcon(IconFamily.NUMBER, "six")); + images.add(new MindmapIcon(IconFamily.NUMBER, "seven")); + images.add(new MindmapIcon(IconFamily.NUMBER, "eight")); + images.add(new MindmapIcon(IconFamily.NUMBER, "nine")); + return images; + } + + private static List getImagesTag() { + final List images = new ArrayList(); + images.add(new MindmapIcon(IconFamily.TAG, "blue")); + images.add(new MindmapIcon(IconFamily.TAG, "green")); + images.add(new MindmapIcon(IconFamily.TAG, "orange")); + images.add(new MindmapIcon(IconFamily.TAG, "red")); + images.add(new MindmapIcon(IconFamily.TAG, "pink")); + images.add(new MindmapIcon(IconFamily.TAG, "yellow")); + return images; + } + + private static List getImagesTask() { + final List images = new ArrayList(); + images.add(new MindmapIcon(IconFamily.TASK, "one")); + images.add(new MindmapIcon(IconFamily.TASK, "two")); + images.add(new MindmapIcon(IconFamily.TASK, "three")); + images.add(new MindmapIcon(IconFamily.TASK, "four")); + images.add(new MindmapIcon(IconFamily.TASK, "five")); + return images; + } + + + public static List getIconByFamily(IconFamily family) { + return images.get(family); + } + + public static MindmapIcon findById(final @NotNull String id) { + for (IconFamily imageFamily : images.keySet()) { + final List mindmapIcons = images.get(imageFamily); + for (MindmapIcon mindmapIcon : mindmapIcons) { + if (mindmapIcon.getId().equals(id)) { + return mindmapIcon; + } + } + } + + throw new IllegalArgumentException("Image could not be found. Id:" + id); + } +} diff --git a/wise-webapp/src/main/java/com/wisemapping/model/MindmapImagesFactory.java b/wise-webapp/src/main/java/com/wisemapping/model/MindmapImagesFactory.java deleted file mode 100755 index dcbfb139..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/model/MindmapImagesFactory.java +++ /dev/null @@ -1,216 +0,0 @@ -/* -* Copyright [2011] [wisemapping] -* -* Licensed under WiseMapping Public License, Version 1.0 (the "License"). -* It is basically the Apache License, Version 2.0 (the "License") plus the -* "powered by wisemapping" text requirement on every single page; -* you may not use this file except in compliance with the License. -* You may obtain a copy of the license at -* -* http://www.wisemapping.org/license -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -package com.wisemapping.model; - -import java.util.*; - -public class MindmapImagesFactory { - - private static Map> images = new HashMap>(); - - static { - images.put(ImageFamily.BULLET, getImagesBullet()); - images.put(ImageFamily.FLAG,getImagesFlag()); - images.put(ImageFamily.NUMBER,getImagesNumber()); - images.put(ImageFamily.TAG,getImagesTag()); - images.put(ImageFamily.TASK,getImagesTask()); - images.put(ImageFamily.FACE,getImagesFaces()); - images.put(ImageFamily.BULB,getImagesBulb()); - images.put(ImageFamily.ARROW,getImagesArrow()); - images.put(ImageFamily.ARROWC,getImagesArrowC()); - images.put(ImageFamily.CONN,getImagesConn()); - images.put(ImageFamily.THUMB,getImagesThumbs()); - images.put(ImageFamily.TICK,getImagesTick()); - images.put(ImageFamily.ONOFF,getImagesOnOff()); - images.put(ImageFamily.MONEY,getImagesMoney()); - images.put(ImageFamily.CHART,getImagesChart()); - } - - private static List getImagesFaces() - { - final List images = new ArrayList(); - images.add(new MindmapImage("plain",ImageFamily.FACE)); - images.add(new MindmapImage("sad",ImageFamily.FACE)); - images.add(new MindmapImage("crying",ImageFamily.FACE)); - images.add(new MindmapImage("smile",ImageFamily.FACE)); - images.add(new MindmapImage("surprise",ImageFamily.FACE)); - images.add(new MindmapImage("wink",ImageFamily.FACE)); - return images; - } - - private static List getImagesArrow() - { - final List images = new ArrayList(); - images.add(new MindmapImage("up",ImageFamily.ARROW)); - images.add(new MindmapImage("down",ImageFamily.ARROW)); - images.add(new MindmapImage("left",ImageFamily.ARROW)); - images.add(new MindmapImage("right",ImageFamily.ARROW)); - return images; - } - - private static List getImagesArrowC() - { - final List images = new ArrayList(); - images.add(new MindmapImage("undo",ImageFamily.ARROWC)); - images.add(new MindmapImage("rotate_anticlockwise",ImageFamily.ARROWC)); - images.add(new MindmapImage("rotate_clockwise",ImageFamily.ARROWC)); - images.add(new MindmapImage("turn_left",ImageFamily.ARROWC)); - images.add(new MindmapImage("turn_right",ImageFamily.ARROWC)); - return images; - } - - private static List getImagesBulb() - { - final List images = new ArrayList(); - images.add(new MindmapImage("light_on",ImageFamily.BULB)); - images.add(new MindmapImage("light_off",ImageFamily.BULB)); - return images; - } - - private static List getImagesTick() - { - final List images = new ArrayList(); - images.add(new MindmapImage("tick",ImageFamily.TICK)); - images.add(new MindmapImage("cross",ImageFamily.TICK)); - return images; - } - - private static List getImagesChart() - { - final List images = new ArrayList(); - images.add(new MindmapImage("bar",ImageFamily.CHART)); - images.add(new MindmapImage("line",ImageFamily.CHART)); - images.add(new MindmapImage("curve",ImageFamily.CHART)); - images.add(new MindmapImage("pie",ImageFamily.CHART)); - images.add(new MindmapImage("organisation",ImageFamily.CHART)); - return images; - } - - private static List getImagesOnOff() - { - final List images = new ArrayList(); - images.add(new MindmapImage("clock",ImageFamily.ONOFF)); - images.add(new MindmapImage("clock_red",ImageFamily.ONOFF)); - images.add(new MindmapImage("add",ImageFamily.ONOFF)); - images.add(new MindmapImage("delete",ImageFamily.ONOFF)); - return images; - } - - private static List getImagesMoney() - { - final List images = new ArrayList(); - images.add(new MindmapImage("money",ImageFamily.MONEY)); - images.add(new MindmapImage("dollar",ImageFamily.MONEY)); - images.add(new MindmapImage("euro",ImageFamily.MONEY)); - images.add(new MindmapImage("pound",ImageFamily.MONEY)); - images.add(new MindmapImage("yen",ImageFamily.MONEY)); - images.add(new MindmapImage("coins",ImageFamily.MONEY)); - images.add(new MindmapImage("ruby",ImageFamily.MONEY)); - return images; - } - - private static List getImagesThumbs() - { - final List images = new ArrayList(); - images.add(new MindmapImage("thumb_up",ImageFamily.THUMB)); - images.add(new MindmapImage("thumb_down",ImageFamily.THUMB)); - return images; - } - - private static List getImagesConn() - { - final List images = new ArrayList(); - images.add(new MindmapImage("connect",ImageFamily.CONN)); - images.add(new MindmapImage("disconnect",ImageFamily.CONN)); - return images; - } - - private static List getImagesBullet() - { - final List images = new ArrayList(); - images.add(new MindmapImage("black",ImageFamily.BULLET)); - images.add(new MindmapImage("blue",ImageFamily.BULLET)); - images.add(new MindmapImage("green",ImageFamily.BULLET)); - images.add(new MindmapImage("orange",ImageFamily.BULLET)); - images.add(new MindmapImage("red",ImageFamily.BULLET)); - images.add(new MindmapImage("pink",ImageFamily.BULLET)); - images.add(new MindmapImage("purple",ImageFamily.BULLET)); - return images; - } - - private static List getImagesFlag() - { - final List images = new ArrayList(); - images.add(new MindmapImage("blue",ImageFamily.FLAG)); - images.add(new MindmapImage("green",ImageFamily.FLAG)); - images.add(new MindmapImage("orange",ImageFamily.FLAG)); - images.add(new MindmapImage("pink",ImageFamily.FLAG)); - images.add(new MindmapImage("purple",ImageFamily.FLAG)); - images.add(new MindmapImage("yellow",ImageFamily.FLAG)); - return images; - } - - private static List getImagesNumber() - { - final List images = new ArrayList(); - images.add(new MindmapImage("one",ImageFamily.NUMBER)); - images.add(new MindmapImage("two",ImageFamily.NUMBER)); - images.add(new MindmapImage("three",ImageFamily.NUMBER)); - images.add(new MindmapImage("four",ImageFamily.NUMBER)); - images.add(new MindmapImage("five",ImageFamily.NUMBER)); - images.add(new MindmapImage("six",ImageFamily.NUMBER)); - images.add(new MindmapImage("seven",ImageFamily.NUMBER)); - images.add(new MindmapImage("eight",ImageFamily.NUMBER)); - images.add(new MindmapImage("nine",ImageFamily.NUMBER)); - return images; - } - - private static List getImagesTag() - { - final List images = new ArrayList(); - images.add(new MindmapImage("blue",ImageFamily.TAG)); - images.add(new MindmapImage("green",ImageFamily.TAG)); - images.add(new MindmapImage("orange",ImageFamily.TAG)); - images.add(new MindmapImage("red",ImageFamily.TAG)); - images.add(new MindmapImage("pink",ImageFamily.TAG)); - images.add(new MindmapImage("yellow",ImageFamily.TAG)); - return images; - } - - private static List getImagesTask() - { - final List images = new ArrayList(); - images.add(new MindmapImage("one",ImageFamily.TASK)); - images.add(new MindmapImage("two",ImageFamily.TASK)); - images.add(new MindmapImage("three",ImageFamily.TASK)); - images.add(new MindmapImage("four",ImageFamily.TASK)); - images.add(new MindmapImage("five",ImageFamily.TASK)); - return images; - } - - public static Collection> getAllImages() - { - return images.values(); - } - - public static List getImagesByFamily(ImageFamily family) - { - return images.get(family); - } -} diff --git a/wise-webapp/src/main/webapp/icons/icons.xml b/wise-webapp/src/main/webapp/icons/icons.xml new file mode 100644 index 00000000..dc09f557 --- /dev/null +++ b/wise-webapp/src/main/webapp/icons/icons.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/wise-webapp/src/test/data/freemind/icons.mm b/wise-webapp/src/test/data/freemind/icons.mm new file mode 100644 index 00000000..6d64e04a --- /dev/null +++ b/wise-webapp/src/test/data/freemind/icons.mm @@ -0,0 +1,154 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wise-webapp/src/test/data/freemind/icons.mmr b/wise-webapp/src/test/data/freemind/icons.mmr new file mode 100644 index 00000000..6359a625 --- /dev/null +++ b/wise-webapp/src/test/data/freemind/icons.mmr @@ -0,0 +1 @@ + \ No newline at end of file