2 * JavaInspect - Utility to visualize java software
3 * Copyright (C) 2013-2018, 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;
17 private static final List<String> systemDataTypes = new ArrayList<>();
18 private static final List<String> commonObjectMethods = new ArrayList<>();
19 private static final List<String> systemPackages = new ArrayList<>();
20 private static final List<String> darkColors = new ArrayList<>();
21 private static final List<String> lightColors = new ArrayList<>();
22 private static final List<String> enumMethods = new ArrayList<>();
23 private static int lastChosenDarkColor = -1;
24 private static int lastChosenLightColor = -1;
28 initSystemDataTypes();
31 initCommonObjectMethods();
36 * retrieves colors from predefined palette
38 * @return next available dark color name
40 protected static String getNextDarkColor() {
41 lastChosenDarkColor++;
42 if (lastChosenDarkColor >= darkColors.size())
43 lastChosenDarkColor = 0;
45 return darkColors.get(lastChosenDarkColor);
49 * retrieves colors from predefined palette
51 * @return next available light color name
53 protected static String getNextLightColor() {
54 lastChosenLightColor++;
55 if (lastChosenLightColor >= lightColors.size())
56 lastChosenLightColor = 0;
58 return lightColors.get(lastChosenLightColor);
61 private static void initCommonObjectMethods() {
62 commonObjectMethods.add("wait");
63 commonObjectMethods.add("equals");
64 commonObjectMethods.add("toString");
65 commonObjectMethods.add("hashCode");
66 commonObjectMethods.add("notify");
67 commonObjectMethods.add("notifyAll");
68 commonObjectMethods.add("getClass");
71 protected static void initDarkColors() {
72 darkColors.add("antiquewhite4");
73 darkColors.add("blueviolet");
74 darkColors.add("brown4");
75 darkColors.add("chartreuse4");
76 darkColors.add("cyan4");
77 darkColors.add("deeppink1");
78 darkColors.add("deepskyblue3");
79 darkColors.add("firebrick1");
80 darkColors.add("goldenrod3");
81 darkColors.add("gray0");
84 private static void initEnumMethods() {
85 enumMethods.add("values");
86 enumMethods.add("valueOf");
87 enumMethods.add("name");
88 enumMethods.add("compareTo");
89 enumMethods.add("valueOf");
90 enumMethods.add("getDeclaringClass");
91 enumMethods.add("ordinal");
94 private static void initLightColors() {
95 lightColors.add("olivedrab2");
96 lightColors.add("peachpuff2");
97 lightColors.add("seagreen1");
98 lightColors.add("violet");
99 lightColors.add("cyan");
100 lightColors.add("orange");
103 private static void initSystemDataTypes() {
104 systemDataTypes.add("void");
105 systemDataTypes.add("int");
106 systemDataTypes.add("long");
107 systemDataTypes.add("float");
108 systemDataTypes.add("double");
109 systemDataTypes.add("boolean");
110 systemDataTypes.add("char");
111 systemDataTypes.add("short");
112 systemDataTypes.add("byte");
115 private static void initSystemPackages() {
116 systemPackages.add("java.");
117 systemPackages.add("javax.");
118 systemPackages.add("sun.");
121 protected static boolean isCommonObjectMethod(final String name) {
122 return commonObjectMethods.contains(name);
125 protected static boolean isEnumMethod(final String name) {
126 return enumMethods.contains(name);
129 protected static boolean isSystemDataType(final String name) {
130 return systemDataTypes.contains(name);
133 protected static boolean isSystemPackage(final String name) {
135 for (final String packagePrefix : systemPackages)
136 if (name.startsWith(packagePrefix))