2 * JavaInspect - Utility to visualize java software
3 * Copyright (C) 2013-2015, 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 3 of the GNU Lesser General Public License
7 * or later as published by the Free Software Foundation.
10 package eu.svjatoslav.inspector.java.structure;
12 import java.util.ArrayList;
13 import java.util.List;
18 * retrieves colors from predefined palette
20 * @return next available dark color name
22 protected static String getNextDarkColor() {
23 lastChosenDarkColor++;
24 if (lastChosenDarkColor >= darkColors.size())
25 lastChosenDarkColor = 0;
27 return darkColors.get(lastChosenDarkColor);
31 * retrieves colors from predefined palette
33 * @return next available light color name
35 protected static String getNextLightColor() {
36 lastChosenLightColor++;
37 if (lastChosenLightColor >= lightColors.size())
38 lastChosenLightColor = 0;
40 return lightColors.get(lastChosenLightColor);
43 private static void initCommonObjectMethods() {
44 commonObjectMethods.add("wait");
45 commonObjectMethods.add("equals");
46 commonObjectMethods.add("toString");
47 commonObjectMethods.add("hashCode");
48 commonObjectMethods.add("notify");
49 commonObjectMethods.add("notifyAll");
50 commonObjectMethods.add("getClass");
53 protected static void initDarkColors() {
54 darkColors.add("antiquewhite4");
55 darkColors.add("blueviolet");
56 darkColors.add("brown4");
57 darkColors.add("chartreuse4");
58 darkColors.add("cyan4");
59 darkColors.add("deeppink1");
60 darkColors.add("deepskyblue3");
61 darkColors.add("firebrick1");
62 darkColors.add("goldenrod3");
63 darkColors.add("gray0");
66 private static void initEnumMethods() {
67 enumMethods.add("values");
68 enumMethods.add("valueOf");
69 enumMethods.add("name");
70 enumMethods.add("compareTo");
71 enumMethods.add("valueOf");
72 enumMethods.add("getDeclaringClass");
73 enumMethods.add("ordinal");
76 private static void initLightColors() {
77 lightColors.add("olivedrab2");
78 lightColors.add("peachpuff2");
79 lightColors.add("seagreen1");
80 lightColors.add("violet");
81 lightColors.add("aqua");
82 lightColors.add("orange");
85 private static void initSystemDataTypes() {
86 systemDataTypes.add("void");
87 systemDataTypes.add("int");
88 systemDataTypes.add("long");
89 systemDataTypes.add("float");
90 systemDataTypes.add("double");
91 systemDataTypes.add("boolean");
92 systemDataTypes.add("char");
93 systemDataTypes.add("short");
94 systemDataTypes.add("byte");
97 private static void initSystemPackages() {
98 systemPackages.add("java.");
99 systemPackages.add("javax.");
100 systemPackages.add("sun.");
103 protected static boolean isCommonObjectMethod(final String name) {
104 return commonObjectMethods.contains(name);
107 protected static boolean isEnumMethod(final String name) {
108 return enumMethods.contains(name);
111 protected static boolean isSystemDataType(final String name) {
112 return systemDataTypes.contains(name);
115 protected static boolean isSystemPackage(final String name) {
117 for (final String packagePrefix : systemPackages)
118 if (name.startsWith(packagePrefix))
124 private static final List<String> systemDataTypes = new ArrayList<String>();
126 private static final List<String> commonObjectMethods = new ArrayList<String>();
128 private static final List<String> systemPackages = new ArrayList<String>();
130 private static final List<String> darkColors = new ArrayList<String>();
132 private static final List<String> lightColors = new ArrayList<String>();
134 private static final List<String> enumMethods = new ArrayList<String>();
136 private static int lastChosenDarkColor = -1;
138 private static int lastChosenLightColor = -1;
142 initSystemDataTypes();
145 initCommonObjectMethods();
146 initSystemPackages();