X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Finspector%2Fjava%2Fstructure%2FUtils.java;h=de74c1341fbd825049cc2269fa1f6ec969621b39;hb=c508bf97e017675b49df989b7f5a64cbd31d9aa3;hp=5feae60b4220b8bbc840c8170e8c041ee25346a7;hpb=f124664cffca475ecbfafd5d9bb33be033bf4e7d;p=javainspect.git diff --git a/src/main/java/eu/svjatoslav/inspector/java/structure/Utils.java b/src/main/java/eu/svjatoslav/inspector/java/structure/Utils.java old mode 100644 new mode 100755 index 5feae60..de74c13 --- a/src/main/java/eu/svjatoslav/inspector/java/structure/Utils.java +++ b/src/main/java/eu/svjatoslav/inspector/java/structure/Utils.java @@ -1,10 +1,10 @@ /* * JavaInspect - Utility to visualize java software - * Copyright (C) 2013, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * + * Copyright (C) 2013-2015, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu + * * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public License - * as published by the Free Software Foundation. + * modify it under the terms of version 3 of the GNU Lesser General Public License + * or later as published by the Free Software Foundation. */ package eu.svjatoslav.inspector.java.structure; @@ -14,35 +14,10 @@ import java.util.List; public class Utils { - private static final List systemDataTypes = new ArrayList(); - - private static final List systemMethods = new ArrayList(); - - private static final List systemPackages = new ArrayList(); - - private static final List darkColors = new ArrayList(); - - private static final List lightColors = new ArrayList(); - - private static final List enumMethods = new ArrayList(); - - public static int lastChosenDarkColor = -1; - - public static int lastChosenLightColor = -1; - - static { - initEnumMethods(); - initSystemDataTypes(); - initDarkColors(); - initLightColors(); - initSystemMethods(); - initSystemPackages(); - } - /** * retrieves colors from predefined palette */ - public static String getNextDarkColor() { + protected static String getNextDarkColor() { lastChosenDarkColor++; if (lastChosenDarkColor >= darkColors.size()) lastChosenDarkColor = 0; @@ -53,7 +28,7 @@ public class Utils { /** * retrieves colors from predefined palette */ - public static String getNextLightColor() { + protected static String getNextLightColor() { lastChosenLightColor++; if (lastChosenLightColor >= lightColors.size()) lastChosenLightColor = 0; @@ -61,7 +36,17 @@ public class Utils { return lightColors.get(lastChosenLightColor); } - public static void initDarkColors() { + private static void initCommonObjectMethods() { + commonObjectMethods.add("wait"); + commonObjectMethods.add("equals"); + commonObjectMethods.add("toString"); + commonObjectMethods.add("hashCode"); + commonObjectMethods.add("notify"); + commonObjectMethods.add("notifyAll"); + commonObjectMethods.add("getClass"); + } + + protected static void initDarkColors() { darkColors.add("antiquewhite4"); darkColors.add("blueviolet"); darkColors.add("brown4"); @@ -74,7 +59,7 @@ public class Utils { darkColors.add("gray0"); } - public static void initEnumMethods() { + private static void initEnumMethods() { enumMethods.add("values"); enumMethods.add("valueOf"); enumMethods.add("name"); @@ -84,7 +69,7 @@ public class Utils { enumMethods.add("ordinal"); } - public static void initLightColors() { + private static void initLightColors() { lightColors.add("olivedrab2"); lightColors.add("peachpuff2"); lightColors.add("seagreen1"); @@ -93,7 +78,7 @@ public class Utils { lightColors.add("orange"); } - public static void initSystemDataTypes() { + private static void initSystemDataTypes() { systemDataTypes.add("void"); systemDataTypes.add("int"); systemDataTypes.add("long"); @@ -105,35 +90,25 @@ public class Utils { systemDataTypes.add("byte"); } - public static void initSystemMethods() { - systemMethods.add("wait"); - systemMethods.add("equals"); - systemMethods.add("toString"); - systemMethods.add("hashCode"); - systemMethods.add("notify"); - systemMethods.add("notifyAll"); - systemMethods.add("getClass"); - } - - public static void initSystemPackages() { + private static void initSystemPackages() { systemPackages.add("java."); systemPackages.add("javax."); systemPackages.add("sun."); } - public static boolean isEnumMethod(final String name) { - return enumMethods.contains(name); + protected static boolean isCommonObjectMethod(final String name) { + return commonObjectMethods.contains(name); } - public static boolean isSystemDataType(final String name) { - return systemDataTypes.contains(name); + protected static boolean isEnumMethod(final String name) { + return enumMethods.contains(name); } - public static boolean isSystemMethod(final String name) { - return systemMethods.contains(name); + protected static boolean isSystemDataType(final String name) { + return systemDataTypes.contains(name); } - public static boolean isSystemPackage(final String name) { + protected static boolean isSystemPackage(final String name) { for (final String packagePrefix : systemPackages) if (name.startsWith(packagePrefix)) @@ -142,4 +117,29 @@ public class Utils { return false; } + private static final List systemDataTypes = new ArrayList(); + + private static final List commonObjectMethods = new ArrayList(); + + private static final List systemPackages = new ArrayList(); + + private static final List darkColors = new ArrayList(); + + private static final List lightColors = new ArrayList(); + + private static final List enumMethods = new ArrayList(); + + private static int lastChosenDarkColor = -1; + + private static int lastChosenLightColor = -1; + + static { + initEnumMethods(); + initSystemDataTypes(); + initDarkColors(); + initLightColors(); + initCommonObjectMethods(); + initSystemPackages(); + } + }