2 * JavaInspect - Utility to visualize java software
3 * Copyright (C) 2013, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 2 of the GNU General Public License
7 * as published by the Free Software Foundation.
10 package eu.svjatoslav.javainspect.structure;
12 import java.util.ArrayList;
13 import java.util.List;
17 private static final List<String> systemDataTypes = new ArrayList<String>();
19 private static final List<String> systemMethods = new ArrayList<String>();
21 private static final List<String> systemPackages = new ArrayList<String>();
23 private static final List<String> darkColors = new ArrayList<String>();
25 private static final List<String> lightColors = new ArrayList<String>();
27 private static final List<String> enumMethods = new ArrayList<String>();
29 public static int lastChosenDarkColor = -1;
31 public static int lastChosenLightColor = -1;
35 initSystemDataTypes();
43 * retrieves colors from predefined palette
45 public static String getNextDarkColor() {
46 lastChosenDarkColor++;
47 if (lastChosenDarkColor >= darkColors.size())
48 lastChosenDarkColor = 0;
50 return darkColors.get(lastChosenDarkColor);
54 * retrieves colors from predefined palette
56 public static String getNextLightColor() {
57 lastChosenLightColor++;
58 if (lastChosenLightColor >= lightColors.size())
59 lastChosenLightColor = 0;
61 return lightColors.get(lastChosenLightColor);
64 public static void initDarkColors() {
65 darkColors.add("antiquewhite4");
66 darkColors.add("blueviolet");
67 darkColors.add("brown4");
68 darkColors.add("chartreuse4");
69 darkColors.add("cyan4");
70 darkColors.add("deeppink1");
71 darkColors.add("deepskyblue3");
72 darkColors.add("firebrick1");
73 darkColors.add("goldenrod3");
74 darkColors.add("gray0");
77 public static void initEnumMethods() {
78 enumMethods.add("values");
79 enumMethods.add("valueOf");
80 enumMethods.add("name");
81 enumMethods.add("compareTo");
82 enumMethods.add("valueOf");
83 enumMethods.add("getDeclaringClass");
84 enumMethods.add("ordinal");
87 public static void initLightColors() {
88 lightColors.add("olivedrab2");
89 lightColors.add("peachpuff2");
90 lightColors.add("seagreen1");
91 lightColors.add("yellow");
92 lightColors.add("violet");
95 public static void initSystemDataTypes() {
96 systemDataTypes.add("void");
97 systemDataTypes.add("int");
98 systemDataTypes.add("long");
99 systemDataTypes.add("float");
100 systemDataTypes.add("double");
101 systemDataTypes.add("boolean");
102 systemDataTypes.add("char");
103 systemDataTypes.add("short");
104 systemDataTypes.add("byte");
107 public static void initSystemMethods() {
108 systemMethods.add("wait");
109 systemMethods.add("equals");
110 systemMethods.add("toString");
111 systemMethods.add("hashCode");
112 systemMethods.add("notify");
113 systemMethods.add("notifyAll");
114 systemMethods.add("getClass");
117 public static void initSystemPackages() {
118 systemPackages.add("java.");
119 systemPackages.add("javax.");
120 systemPackages.add("sun.");
123 public static boolean isEnumMethod(final String name) {
124 return enumMethods.contains(name);
127 public static boolean isSystemDataType(final String name) {
128 return systemDataTypes.contains(name);
131 public static boolean isSystemMethod(final String name) {
132 return systemMethods.contains(name);
135 public static boolean isSystemPackage(final String name) {
137 for (final String packagePrefix : systemPackages)
138 if (name.startsWith(packagePrefix))