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 protected static String getNextDarkColor() {
21 lastChosenDarkColor++;
22 if (lastChosenDarkColor >= darkColors.size())
23 lastChosenDarkColor = 0;
25 return darkColors.get(lastChosenDarkColor);
29 * retrieves colors from predefined palette
31 protected static String getNextLightColor() {
32 lastChosenLightColor++;
33 if (lastChosenLightColor >= lightColors.size())
34 lastChosenLightColor = 0;
36 return lightColors.get(lastChosenLightColor);
39 private static void initCommonObjectMethods() {
40 commonObjectMethods.add("wait");
41 commonObjectMethods.add("equals");
42 commonObjectMethods.add("toString");
43 commonObjectMethods.add("hashCode");
44 commonObjectMethods.add("notify");
45 commonObjectMethods.add("notifyAll");
46 commonObjectMethods.add("getClass");
49 protected static void initDarkColors() {
50 darkColors.add("antiquewhite4");
51 darkColors.add("blueviolet");
52 darkColors.add("brown4");
53 darkColors.add("chartreuse4");
54 darkColors.add("cyan4");
55 darkColors.add("deeppink1");
56 darkColors.add("deepskyblue3");
57 darkColors.add("firebrick1");
58 darkColors.add("goldenrod3");
59 darkColors.add("gray0");
62 private static void initEnumMethods() {
63 enumMethods.add("values");
64 enumMethods.add("valueOf");
65 enumMethods.add("name");
66 enumMethods.add("compareTo");
67 enumMethods.add("valueOf");
68 enumMethods.add("getDeclaringClass");
69 enumMethods.add("ordinal");
72 private static void initLightColors() {
73 lightColors.add("olivedrab2");
74 lightColors.add("peachpuff2");
75 lightColors.add("seagreen1");
76 lightColors.add("violet");
77 lightColors.add("aqua");
78 lightColors.add("orange");
81 private static void initSystemDataTypes() {
82 systemDataTypes.add("void");
83 systemDataTypes.add("int");
84 systemDataTypes.add("long");
85 systemDataTypes.add("float");
86 systemDataTypes.add("double");
87 systemDataTypes.add("boolean");
88 systemDataTypes.add("char");
89 systemDataTypes.add("short");
90 systemDataTypes.add("byte");
93 private static void initSystemPackages() {
94 systemPackages.add("java.");
95 systemPackages.add("javax.");
96 systemPackages.add("sun.");
99 protected static boolean isCommonObjectMethod(final String name) {
100 return commonObjectMethods.contains(name);
103 protected static boolean isEnumMethod(final String name) {
104 return enumMethods.contains(name);
107 protected static boolean isSystemDataType(final String name) {
108 return systemDataTypes.contains(name);
111 protected static boolean isSystemPackage(final String name) {
113 for (final String packagePrefix : systemPackages)
114 if (name.startsWith(packagePrefix))
120 private static final List<String> systemDataTypes = new ArrayList<String>();
122 private static final List<String> commonObjectMethods = new ArrayList<String>();
124 private static final List<String> systemPackages = new ArrayList<String>();
126 private static final List<String> darkColors = new ArrayList<String>();
128 private static final List<String> lightColors = new ArrayList<String>();
130 private static final List<String> enumMethods = new ArrayList<String>();
132 private static int lastChosenDarkColor = -1;
134 private static int lastChosenLightColor = -1;
138 initSystemDataTypes();
141 initCommonObjectMethods();
142 initSystemPackages();