List of utility methods to do Color Decode
Color | decode(String color) decode long i = Long.parseLong(color, 16); int r = (int) (i & 0xff); int g = (int) ((i >> 8) & 0xff); int b = (int) ((i >> 16) & 0xff); int a = (int) ((i >> 24) & 0xff); return new Color(r, g, b, a); |
Color | decodeColor(final double v) Convert a double value to a color. if (Double.isInfinite(v) || Double.isNaN(v)) { return Color.BLACK; return new Color( isin(v, R_FREQ), isin(v, G_FREQ), isin(v, B_FREQ), isin(v, A_FREQ)); ... |
Color | decodeColor(final String value) Interprets a string as a color value. if (value == null) { throw new IllegalArgumentException("Cannot decode a null String."); String valueLowercase = value.toLowerCase(Locale.ENGLISH); Color color; if (valueLowercase.startsWith("0x")) { valueLowercase = valueLowercase.substring(2); if (valueLowercase.length() != 8) { ... |
Color | decodeColor(int color) decode Color return new Color(color, color > 0xFFFFFF); |
Color | decodeColor(int value) decode Color return new Color((int) (value & 0xFF0000) >> 16, (int) (value & 0xFF00) >> 8, (int) value & 0xFF, (int) (((long) value & 0xFF000000L) >> 24)); |
Color | decodeColor(String color, Color defaultColor) decode Color String colorVal = ""; if (color.length() > 0) { colorVal = color.trim(); if (colorVal.startsWith("#")) colorVal = colorVal.substring(1); try { colorVal = new Integer(Integer.parseInt(colorVal, 16)).toString(); return Color.decode(colorVal.toLowerCase()); ... |
Color | decodeColor(String string) decodes a String containing a 4 byte hex value as a color with an optional alpha (transparency) channel. if (string == null) return Color.BLACK; if (string.startsWith("java.awt.Color")) { Pattern pattern = Pattern.compile("java.awt.Color\\[r=(\\d+),\\s*g=(\\d+),\\s*b=(\\d+)\\s*\\]"); Matcher m = pattern.matcher(string); if (m.matches()) { int r = Integer.parseInt(m.group(1)); int g = Integer.parseInt(m.group(2)); ... |
Color | decodeColor(String value, Color dflt) This takes the given String and tries to convert it to a color. if (value == null) { return dflt; value = value.trim(); if (value.equals("null")) { return null; String s = value; ... |
Color | decodeHexColor(String hexString) decode Hex Color if (hexString.length() == 6 || hexString.length() == 8) { int r = parseHexColorComponent(hexString, 0); int g = parseHexColorComponent(hexString, 2); int b = parseHexColorComponent(hexString, 4); if (hexString.length() == 8) { int a = parseHexColorComponent(hexString, 6); return new Color(r, g, b, a); return new Color(r, g, b); } else { throw new IllegalArgumentException("Color is not a valid hex string: #" + hexString); |
Color | decodeHtmlColorString(String colourString) Decode an HTML color string like '#F567BA;' into a Color Color color; if (colourString.startsWith("#")) { colourString = colourString.substring(1); if (colourString.endsWith(";")) { colourString = colourString.substring(0, colourString.length() - 1); int red, green, blue; ... |