/** * Returns a hex representation for the given color. * * @param color * Color to return the hex string for. * @return Returns a hex string for the given color. */ public static String getHexColorString(Color color) { return mxHtmlColor.getHexColorString(color); }
/** * */ public static String hexString(Color color) { return mxHtmlColor.hexString(color); }
/** * Shortcut for parseColor with no transparency. */ public static Color parseColor(String str) throws NumberFormatException { return parseColor(str, 1); };
protected static Color parseRgb(String rgbString) { String[] values = rgbString.split("[,()]"); String red = values[1].trim(); String green = values[2].trim(); String blue = values[3].trim(); String alpha = "1.0"; if (values.length >= 5) { alpha = values[4].trim(); } return new Color(parseValue(red, 255), parseValue(green, 255), parseValue(blue, 255), parseAlpha(alpha)); }
protected static float parseValue(String val, int max) { if (val.endsWith("%")) { return (float) (parsePercent(val) * max / max); } return (float) (Integer.parseInt(val) / max); }
return parseRgb(str);
protected static Color parseRgb(String rgbString) { String[] values = rgbString.split("[,()]"); String red = values[1].trim(); String green = values[2].trim(); String blue = values[3].trim(); String alpha = "1.0"; if (values.length >= 5) { alpha = values[4].trim(); } return new Color(parseValue(red, 255), parseValue(green, 255), parseValue(blue, 255), parseAlpha(alpha)); }
protected static float parseValue(String val, int max) { if (val.endsWith("%")) { return (float) (parsePercent(val) * max / max); } return (float) (Integer.parseInt(val) / max); }
return parseRgb(str);
/** * Shortcut for parseColor with no transparency. */ public static Color parseColor(String colorString) throws NumberFormatException { return mxHtmlColor.parseColor(colorString); }
/** * Returns a hex representation for the given color. * * @param color * Color to return the hex string for. * @return Returns a hex string for the given color. */ public static String getHexColorString(Color color) { return mxHtmlColor.getHexColorString(color); }
/** * */ public static String hexString(Color color) { return mxHtmlColor.hexString(color); }
/** * Convert a string representing a 24/32bit hex color value into a Color * object. The following color names are also supported: white, black, red, * green, blue, orange, yellow, pink, turquoise, gray and none (null). * Examples of possible hex color values are: #C3D9FF, #6482B9 and #774400, * but note that you do not include the "#" in the string passed in * * @param colorString * the 24/32bit hex string value (ARGB) * @return java.awt.Color (24bit RGB on JDK 1.1, 24/32bit ARGB on JDK1.2) * @exception NumberFormatException * if the specified string cannot be interpreted as a * hexidecimal integer */ public static Color parseColor(String colorString) throws NumberFormatException { return mxHtmlColor.parseColor(colorString); }
/** * Convert a string representing a 24/32bit hex color value into a Color * object. The following color names are also supported: white, black, red, * green, blue, orange, yellow, pink, turquoise, gray and none (null). * Examples of possible hex color values are: #C3D9FF, #6482B9 and #774400, * but note that you do not include the "#" in the string passed in * * @param colorString * the 24/32bit hex string value (ARGB) * @return java.awt.Color (24bit RGB on JDK 1.1, 24/32bit ARGB on JDK1.2) * @exception NumberFormatException * if the specified string cannot be interpreted as a * hexidecimal integer */ public static Color parseColor(String colorString, double alpha) throws NumberFormatException { return mxHtmlColor.parseColor(colorString, alpha); };