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;
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 initCommonObjectMethods() {
65 commonObjectMethods.add("wait");
66 commonObjectMethods.add("equals");
67 commonObjectMethods.add("toString");
68 commonObjectMethods.add("hashCode");
69 commonObjectMethods.add("notify");
70 commonObjectMethods.add("notifyAll");
71 commonObjectMethods.add("getClass");
74 public static void initDarkColors() {
75 darkColors.add("antiquewhite4");
76 darkColors.add("blueviolet");
77 darkColors.add("brown4");
78 darkColors.add("chartreuse4");
79 darkColors.add("cyan4");
80 darkColors.add("deeppink1");
81 darkColors.add("deepskyblue3");
82 darkColors.add("firebrick1");
83 darkColors.add("goldenrod3");
84 darkColors.add("gray0");
87 public static void initEnumMethods() {
88 enumMethods.add("values");
89 enumMethods.add("valueOf");
90 enumMethods.add("name");
91 enumMethods.add("compareTo");
92 enumMethods.add("valueOf");
93 enumMethods.add("getDeclaringClass");
94 enumMethods.add("ordinal");
97 public static void initLightColors() {
98 lightColors.add("olivedrab2");
99 lightColors.add("peachpuff2");
100 lightColors.add("seagreen1");
101 lightColors.add("violet");
102 lightColors.add("aqua");
103 lightColors.add("orange");
106 public static void initSystemDataTypes() {
107 systemDataTypes.add("void");
108 systemDataTypes.add("int");
109 systemDataTypes.add("long");
110 systemDataTypes.add("float");
111 systemDataTypes.add("double");
112 systemDataTypes.add("boolean");
113 systemDataTypes.add("char");
114 systemDataTypes.add("short");
115 systemDataTypes.add("byte");
118 public static void initSystemPackages() {
119 systemPackages.add("java.");
120 systemPackages.add("javax.");
121 systemPackages.add("sun.");
124 public static boolean isCommonObjectMethod(final String name) {
125 return commonObjectMethods.contains(name);
128 public static boolean isEnumMethod(final String name) {
129 return enumMethods.contains(name);
132 public static boolean isSystemDataType(final String name) {
133 return systemDataTypes.contains(name);
136 public static boolean isSystemPackage(final String name) {
138 for (final String packagePrefix : systemPackages)
139 if (name.startsWith(packagePrefix))