List of utility methods to do Color Create
Color | toColor(Node n) to Color if (!n.getNodeName().equals("color")) { throw new IllegalArgumentException(n.getNodeName()); NamedNodeMap map = n.getAttributes(); String s = map.getNamedItem("name").getNodeValue(); if (s.equals("white")) { return Color.WHITE; } else if (s.equals("green")) { ... |
Color | toColor(short rgb565) Return a Color based on a color in RGB565 format. if (rgb565 == 0) { return null; if (rgb565 == 0x20) { return Color.BLACK; return new Color(255 * ((rgb565 & 0xF800) >> 11) / 31, 255 * ((rgb565 & 0x07e0) >> 5) / 63, 255 * (rgb565 & 0x001f) / 31); ... |
Color | toColor(String background) Get the Color object matching with the given string. Color color = null; if (background != null) { background = background.trim(); color = Color.decode(background); return color; |
Color | toColor(String hexString) to Color int hexValue = 0; if (hexString != null && hexString.startsWith("#")) { hexString = hexString.substring(1); try { hexValue = Integer.parseInt(hexString, 16); } catch (NumberFormatException e) { hexValue = 0; ... |
Color | toColor(String pString) Parses a string to a Color. if (pString == null) { return null; if (pString.charAt(0) == '#') { int r = 0; int g = 0; int b = 0; int a = -1; ... |
Color | toColor(String str) Can be: (255, 0, 0) 255, 0, 0 #FF0000 #F00 red switch (str.charAt(0)) { case '(': int red, green, blue; int index; red = nextColorInt(str, 1); index = str.indexOf(','); green = nextColorInt(str, index + 1); index = str.indexOf(',', index + 1); ... |
Color[] | toColors(boolean hasAlpha, int... colors) Simply calls new Color(color, hasalpha) for each color in colors and returns all of them. Color[] result = new Color[colors.length]; for (int i = 0; i < colors.length; i++) { result[i] = new Color(colors[i], hasAlpha); return result; |