Move icons to icons directory. Now, start working on tests to check that all the icons has his image.
This commit is contained in:
@@ -20,11 +20,14 @@ package com.wisemapping.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.IllegalStateException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public class MindmapIcons {
|
||||
|
||||
private static Map<IconFamily, List<MindmapIcon>> images = new HashMap<IconFamily, List<MindmapIcon>>();
|
||||
private static Map<IconFamily, List<MindmapIcon>> iconsByFamily;
|
||||
|
||||
public static final MindmapIcon FACE_PLAIN = new MindmapIcon(IconFamily.SMILEY, "plain");
|
||||
public static final MindmapIcon FACE_SAD = new MindmapIcon(IconFamily.SMILEY, "sad");
|
||||
@@ -41,179 +44,116 @@ public class MindmapIcons {
|
||||
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());
|
||||
public static final MindmapIcon TASK_ONE = new MindmapIcon(IconFamily.TASK, "one");
|
||||
public static final MindmapIcon TASK_TWO = new MindmapIcon(IconFamily.TASK, "two");
|
||||
public static final MindmapIcon TASK_THREE = new MindmapIcon(IconFamily.TASK, "three");
|
||||
public static final MindmapIcon TASK_FOUR = new MindmapIcon(IconFamily.TASK, "four");
|
||||
public static final MindmapIcon TASK_FIVE = new MindmapIcon(IconFamily.TASK, "five");
|
||||
|
||||
public static final MindmapIcon ARROWC_UNDO = new MindmapIcon(IconFamily.ARROWC, "undo");
|
||||
public static final MindmapIcon ARROWC_ANTICLOCK_WISE = new MindmapIcon(IconFamily.ARROWC, "rotate_anticlockwise");
|
||||
public static final MindmapIcon ARROWC_CLOCK_WISE = new MindmapIcon(IconFamily.ARROWC, "rotate_clockwise");
|
||||
public static final MindmapIcon ARROWC_LEFT = new MindmapIcon(IconFamily.ARROWC, "turn_left");
|
||||
public static final MindmapIcon ARROWC_RIGHT = new MindmapIcon(IconFamily.ARROWC, "turn_right");
|
||||
|
||||
public static final MindmapIcon BULB_LIGHT_ON = new MindmapIcon(IconFamily.BULB, "light_on");
|
||||
public static final MindmapIcon BULB_LIGHT__OFF = new MindmapIcon(IconFamily.BULB, "light_off");
|
||||
|
||||
public static final MindmapIcon TICK_TICK = new MindmapIcon(IconFamily.TICK, "tick");
|
||||
public static final MindmapIcon TICK_CROSS = new MindmapIcon(IconFamily.TICK, "cross");
|
||||
|
||||
public static final MindmapIcon CHART_BAR = new MindmapIcon(IconFamily.CHART, "bar");
|
||||
public static final MindmapIcon CHART_LINE = new MindmapIcon(IconFamily.CHART, "line");
|
||||
public static final MindmapIcon CHART_CURVE = new MindmapIcon(IconFamily.CHART, "curve");
|
||||
public static final MindmapIcon CHART_PIE = new MindmapIcon(IconFamily.CHART, "pie");
|
||||
public static final MindmapIcon CHART_ORGANISATION = new MindmapIcon(IconFamily.CHART, "organisation");
|
||||
|
||||
public static final MindmapIcon ONOFF_CLOCK = new MindmapIcon(IconFamily.ONOFF, "clock");
|
||||
public static final MindmapIcon ONOFF_CLOCK__RED = new MindmapIcon(IconFamily.ONOFF, "clock_red");
|
||||
public static final MindmapIcon ONOFF_ADD = new MindmapIcon(IconFamily.ONOFF, "add");
|
||||
public static final MindmapIcon ONOFF_DELETE = new MindmapIcon(IconFamily.ONOFF, "delete");
|
||||
|
||||
public static final MindmapIcon TAG_BLUE = new MindmapIcon(IconFamily.TAG, "blue");
|
||||
public static final MindmapIcon TAG_GREEN = new MindmapIcon(IconFamily.TAG, "green");
|
||||
public static final MindmapIcon TAG_ORANGE = new MindmapIcon(IconFamily.TAG, "orange");
|
||||
public static final MindmapIcon TAG_RED = new MindmapIcon(IconFamily.TAG, "red");
|
||||
public static final MindmapIcon TAG_PINK = new MindmapIcon(IconFamily.TAG, "pink");
|
||||
public static final MindmapIcon TAG_YELLOW = new MindmapIcon(IconFamily.TAG, "yellow");
|
||||
|
||||
public static final MindmapIcon NUMBER_ONE = new MindmapIcon(IconFamily.NUMBER, "one");
|
||||
public static final MindmapIcon NUMBER_TWO = new MindmapIcon(IconFamily.NUMBER, "two");
|
||||
public static final MindmapIcon NUMBER_THREE = new MindmapIcon(IconFamily.NUMBER, "three");
|
||||
public static final MindmapIcon NUMBER_FOUR = new MindmapIcon(IconFamily.NUMBER, "four");
|
||||
public static final MindmapIcon NUMBER_FIVE = new MindmapIcon(IconFamily.NUMBER, "five");
|
||||
public static final MindmapIcon NUMBER_SIX = new MindmapIcon(IconFamily.NUMBER, "six");
|
||||
public static final MindmapIcon NUMBER_SEVEN = new MindmapIcon(IconFamily.NUMBER, "seven");
|
||||
public static final MindmapIcon NUMBER_EIGHT = new MindmapIcon(IconFamily.NUMBER, "eight");
|
||||
public static final MindmapIcon NUMBER_NINE = new MindmapIcon(IconFamily.NUMBER, "nine");
|
||||
|
||||
public static final MindmapIcon FLAG_BLUE = new MindmapIcon(IconFamily.FLAG, "blue");
|
||||
public static final MindmapIcon FLAG_GREEN = new MindmapIcon(IconFamily.FLAG, "green");
|
||||
public static final MindmapIcon FLAG_ORANGE = new MindmapIcon(IconFamily.FLAG, "orange");
|
||||
public static final MindmapIcon FLAG_PINK = new MindmapIcon(IconFamily.FLAG, "pink");
|
||||
public static final MindmapIcon FLAG_PURPLE = new MindmapIcon(IconFamily.FLAG, "purple");
|
||||
public static final MindmapIcon FLAG_YELLOW = new MindmapIcon(IconFamily.FLAG, "yellow");
|
||||
|
||||
public static final MindmapIcon BULLET_BLACK = new MindmapIcon(IconFamily.BULLET, "black");
|
||||
public static final MindmapIcon BULLET_BLUE = new MindmapIcon(IconFamily.BULLET, "blue");
|
||||
public static final MindmapIcon BULLET_BLUEGREEN = new MindmapIcon(IconFamily.BULLET, "green");
|
||||
public static final MindmapIcon BULLET_BLUEORANGE = new MindmapIcon(IconFamily.BULLET, "orange");
|
||||
public static final MindmapIcon BULLET_BLUERED = new MindmapIcon(IconFamily.BULLET, "red");
|
||||
public static final MindmapIcon BULLET_BLUEPINK = new MindmapIcon(IconFamily.BULLET, "pink");
|
||||
public static final MindmapIcon BULLET_BLUEPURPLE = new MindmapIcon(IconFamily.BULLET, "purple");
|
||||
|
||||
public static final MindmapIcon MONEY_GENERIC = new MindmapIcon(IconFamily.MONEY, "money");
|
||||
public static final MindmapIcon MONEY_DOLLAR = new MindmapIcon(IconFamily.MONEY, "dollar");
|
||||
public static final MindmapIcon MONEY_EURO = new MindmapIcon(IconFamily.MONEY, "euro");
|
||||
public static final MindmapIcon MONEY_POUND = new MindmapIcon(IconFamily.MONEY, "pound");
|
||||
public static final MindmapIcon MONEY_YEN = new MindmapIcon(IconFamily.MONEY, "yen");
|
||||
public static final MindmapIcon MONEY_COINS = new MindmapIcon(IconFamily.MONEY, "coins");
|
||||
public static final MindmapIcon MONEY_RUBY = new MindmapIcon(IconFamily.MONEY, "ruby");
|
||||
public static final MindmapIcon MONEY_CONNECT = new MindmapIcon(IconFamily.CONN, "connect");
|
||||
public static final MindmapIcon MONEY_DISCONNECT = new MindmapIcon(IconFamily.CONN, "disconnect");
|
||||
|
||||
@NotNull
|
||||
public static List<MindmapIcon> getIconByFamily(@NotNull IconFamily family) {
|
||||
|
||||
load();
|
||||
return iconsByFamily.get(family);
|
||||
}
|
||||
|
||||
private static List<MindmapIcon> getImagesFaces() {
|
||||
final List<MindmapIcon> images = new ArrayList<MindmapIcon>();
|
||||
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 void load() {
|
||||
try {
|
||||
if (iconsByFamily == null) {
|
||||
iconsByFamily = new HashMap<IconFamily, List<MindmapIcon>>();
|
||||
|
||||
private static List<MindmapIcon> getImagesArrow() {
|
||||
final List<MindmapIcon> result = new ArrayList<MindmapIcon>();
|
||||
result.add(ARROW_UP);
|
||||
result.add(ARROW_DOWN);
|
||||
result.add(ARROW_LEFT);
|
||||
result.add(ARROW_RIGHT);
|
||||
return result;
|
||||
}
|
||||
Field[] fields = MindmapIcons.class.getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
final Object object = field.get(null);
|
||||
|
||||
private static List<MindmapIcon> getImagesArrowC() {
|
||||
final List<MindmapIcon> result = new ArrayList<MindmapIcon>();
|
||||
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;
|
||||
}
|
||||
if (object instanceof MindmapIcon) {
|
||||
|
||||
private static List<MindmapIcon> getImagesBulb() {
|
||||
final List<MindmapIcon> images = new ArrayList<MindmapIcon>();
|
||||
images.add(new MindmapIcon(IconFamily.BULB, "light_on"));
|
||||
images.add(new MindmapIcon(IconFamily.BULB, "light_off"));
|
||||
return images;
|
||||
}
|
||||
|
||||
private static List<MindmapIcon> getImagesTick() {
|
||||
final List<MindmapIcon> images = new ArrayList<MindmapIcon>();
|
||||
images.add(new MindmapIcon(IconFamily.TICK, "tick"));
|
||||
images.add(new MindmapIcon(IconFamily.TICK, "cross"));
|
||||
return images;
|
||||
}
|
||||
|
||||
private static List<MindmapIcon> getImagesChart() {
|
||||
final List<MindmapIcon> images = new ArrayList<MindmapIcon>();
|
||||
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<MindmapIcon> getImagesOnOff() {
|
||||
final List<MindmapIcon> images = new ArrayList<MindmapIcon>();
|
||||
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<MindmapIcon> getImagesMoney() {
|
||||
final List<MindmapIcon> images = new ArrayList<MindmapIcon>();
|
||||
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<MindmapIcon> getImagesThumbs() {
|
||||
final List<MindmapIcon> images = new ArrayList<MindmapIcon>();
|
||||
images.add(THUMB__UP);
|
||||
images.add(THUMB_DOWN);
|
||||
return images;
|
||||
}
|
||||
|
||||
private static List<MindmapIcon> getImagesConn() {
|
||||
final List<MindmapIcon> images = new ArrayList<MindmapIcon>();
|
||||
images.add(new MindmapIcon(IconFamily.CONN, "connect"));
|
||||
images.add(new MindmapIcon(IconFamily.CONN, "disconnect"));
|
||||
return images;
|
||||
}
|
||||
|
||||
private static List<MindmapIcon> getImagesBullet() {
|
||||
final List<MindmapIcon> images = new ArrayList<MindmapIcon>();
|
||||
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<MindmapIcon> getImagesFlag() {
|
||||
final List<MindmapIcon> images = new ArrayList<MindmapIcon>();
|
||||
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<MindmapIcon> getImagesNumber() {
|
||||
final List<MindmapIcon> images = new ArrayList<MindmapIcon>();
|
||||
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<MindmapIcon> getImagesTag() {
|
||||
final List<MindmapIcon> images = new ArrayList<MindmapIcon>();
|
||||
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<MindmapIcon> getImagesTask() {
|
||||
final List<MindmapIcon> images = new ArrayList<MindmapIcon>();
|
||||
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;
|
||||
}
|
||||
final MindmapIcon icon = (MindmapIcon) object;
|
||||
final IconFamily iconFamily = icon.getFamily();
|
||||
List<MindmapIcon> mindmapIcons = iconsByFamily.get(iconFamily);
|
||||
if (mindmapIcons == null) {
|
||||
mindmapIcons = new ArrayList<MindmapIcon>();
|
||||
iconsByFamily.put(iconFamily, mindmapIcons);
|
||||
}
|
||||
mindmapIcons.add(icon);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static List<MindmapIcon> getIconByFamily(IconFamily family) {
|
||||
return images.get(family);
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static MindmapIcon findById(final @NotNull String id) {
|
||||
for (IconFamily imageFamily : images.keySet()) {
|
||||
final List<MindmapIcon> mindmapIcons = images.get(imageFamily);
|
||||
for (IconFamily imageFamily : iconsByFamily.keySet()) {
|
||||
final List<MindmapIcon> mindmapIcons = iconsByFamily.get(imageFamily);
|
||||
for (MindmapIcon mindmapIcon : mindmapIcons) {
|
||||
if (mindmapIcon.getId().equals(id)) {
|
||||
return mindmapIcon;
|
||||
|
Reference in New Issue
Block a user