ColorHelper { public static boolean isColorDefinition(String color) { boolean ret = false; if (color == null) { return false; } if (color.startsWith("#")) { color = color.substring(1); try { Integer.parseInt(color, 16); ret = true; } catch (NumberFormatException e) { } } else if (color.startsWith("0x") || color.startsWith("0X")) { color = color.substring(2); try { Integer.parseInt(color, 16); ret = true; } catch (NumberFormatException e) { } } return ret; } private  ColorHelper(); static int getAlpha(final int color); static int increaseAlpha(final int color, final double amount); static boolean isColorDefinition(String color); static boolean isOpaque(int color); static boolean isTransparent(int color); @Deprecated static int makeColor(float red, float green, float blue); @Deprecated static int makeColor(float red, float green, float blue,
                                float alpha); static int colorFromFloatComponents(float red, float green, float blue,
                                Float alpha); static int makeColor(int red, int green, int blue); static int makeColor(int red, int green, int blue, int alpha); static int colorFromComponents(int red, int green, int blue, Integer alpha); static int makeColor(final int red, final int green, final int blue, 
                                final int alpha, final int top); static int makeColor(String color); @Deprecated static int[] makeComponents(final int color); static int[] colorToComponents(final int color); static float[] colorToFloatComponents(int rgba); static int colorFromFloatComponents(float[] rgba); static Map<String, Integer> colorToComponents(final int color,
            Map<String, Integer> out); static int makeOpaque(int value); static int makeVisible(int value); static int makeVisible(int value, int threshold); static Integer makeVisible(int value, int threshold, Integer white,
            Integer black); static int neverTransparent(int color); static int setAlpha(final int color, final int alpha); static Map<String, Float> colorToHSV(int rgba, Map<String, Float> out); @Deprecated static float[] ColorToHSV(int rgba); static float[] colorToHSV(int rgba); static int shiftHue(int rgba, float shift); static int scaleSV(int rgba, float scaleS, float scaleV); static int colorFromHSV(float hue, float saturation, float value, Float alpha); static int colorFromHSV(Map<String, Float> hsva); @Deprecated static int ColorFromHSV(float[] hsva); static int colorFromHSV(float[] hsva); static int saturate(int rgba, float satStep); static void saturatePalette(ColorPalette pal, int startIdx, int endIdx, float satStep); static void repeatForPalette(ColorPalette pal, int startIdx, ColorTransformer transformer, Integer length); static void repeatForPalette(ColorPalette pal, int startIdx, int endIdx, ColorTransformer transformer); static int multiply(int rgba1, int rgba2); static int multiply(int rgba1, float value); static int add(int rgba1, int rgba2); static int subtract(int rgba1, int rgba2); static int lerp(int rgba1, int rgba2, float weight); static int lerp(int rgba1, int rgba2); static int lerp(int rgba1, int rgba2, float[] weight); @Deprecated static int lerp(int rgba1, int rgba2, int weight); static int colorFromComponents(Map<String, Integer> components); static int colorFromComponents(int[] components); static List<Integer> createGradient(int colors, Integer... rgbaColors); static List<Integer> lookup(ColorPalette in, String... namesOrColorDefs); static List<Integer> lookup(ColorPalette in, Integer... indexesOrColors); static List<Integer> extendGradient(List<Integer> out, int colors, List<Integer> colorValues); static List<Integer> extendGradient(List<Integer> out, int colors, int colorValue); static List<Integer> createGradient(List<Integer> out, int colors,
            List<Integer> rgbaColors); static int guessBlack(ColorPalette palette); static int guessWhite(ColorPalette palette); static Set<Integer> findChangedColors(ColorPalette newPalette, ColorPalette oldPalette); static final String HUE; static final String SATURATION; static final String VALUE; static final String ALPHA; static final String RED; static final String GREEN; static final String BLUE; }
@Test @Covers("public static boolean isColorDefinition(String)") public void isColorDefinition() { assertFalse(ColorHelper.isColorDefinition("#pickle")); assertTrue(ColorHelper.isColorDefinition("#00FF00")); assertTrue(ColorHelper.isColorDefinition("#0f0")); assertTrue(ColorHelper.isColorDefinition("0xFF007f")); assertTrue(ColorHelper.isColorDefinition("0XFF007f")); assertFalse(ColorHelper.isColorDefinition("0xOXENFART")); assertFalse(ColorHelper.isColorDefinition("White")); assertFalse(ColorHelper.isColorDefinition("0")); }