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.inspector.java.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> commonObjectMethods = 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();
38 initCommonObjectMethods();
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("violet");
92 lightColors.add("aqua");
93 lightColors.add("orange");
96 public static void initSystemDataTypes() {
97 systemDataTypes.add("void");
98 systemDataTypes.add("int");
99 systemDataTypes.add("long");
100 systemDataTypes.add("float");
101 systemDataTypes.add("double");
102 systemDataTypes.add("boolean");
103 systemDataTypes.add("char");
104 systemDataTypes.add("short");
105 systemDataTypes.add("byte");
108 public static void initCommonObjectMethods() {
109 commonObjectMethods.add("wait");
110 commonObjectMethods.add("equals");
111 commonObjectMethods.add("toString");
112 commonObjectMethods.add("hashCode");
113 commonObjectMethods.add("notify");
114 commonObjectMethods.add("notifyAll");
115 commonObjectMethods.add("getClass");
118 public static void initSystemPackages() {
119 systemPackages.add("java.");
120 systemPackages.add("javax.");
121 systemPackages.add("sun.");
124 public static boolean isEnumMethod(final String name) {
125 return enumMethods.contains(name);
128 public static boolean isSystemDataType(final String name) {
129 return systemDataTypes.contains(name);
132 public static boolean isCommonObjectMethod(final String name) {
133 return commonObjectMethods.contains(name);
136 public static boolean isSystemPackage(final String name) {
138 for (final String packagePrefix : systemPackages)
139 if (name.startsWith(packagePrefix))