Class WebColors
- All Implemented Interfaces:
Serializable, Cloneable, Map<String,int[]>
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final WebColorsHashMap containing all the names and corresponding color values.private static final doubleprivate static final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static floatgetAlphaChannelValue(String rgbChannel) static float[]getCMYKArray(String name) Gives an array of five floats that contain CMYK values and opacity, each value is between 0 and 1.private static floatgetCMYKChannelValue(String cmykChannel) static DeviceCmykgetCMYKColor(String name) Gives you a DeviceCmyk based on a name.static float[]getRGBAColor(String name) Gives an array of four floats that contain RGBA values, each value is between 0 and 1.private static floatgetRGBChannelValue(String rgbChannel) static DeviceRgbgetRGBColor(String name) Gives you a DeviceRgb based on a name.private static booleanmissingHashColorFormat(String colStr) A web color string without the leading # will be 3 or 6 characters long and all those characters will be hex digits.private static voidparseCMYKColors(float[] color, StringTokenizer tok) private static floatparsePercentValue(String rgbChannel) private static voidparseRGBColors(float[] color, StringTokenizer tok) Methods inherited from class HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, newHashMap, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuesMethods inherited from class AbstractMap
equals, hashCode, toString
-
Field Details
-
NAMES
HashMap containing all the names and corresponding color values. -
serialVersionUID
private static final long serialVersionUID- See Also:
-
RGB_MAX_VAL
private static final double RGB_MAX_VAL- See Also:
-
-
Constructor Details
-
WebColors
public WebColors()
-
-
Method Details
-
getRGBColor
-
getCMYKColor
Gives you a DeviceCmyk based on a name.- Parameters:
name- 'device-cmyk(c, m, y, k)' structure- Returns:
- the corresponding DeviceCmyk object. Never returns null.
-
getCMYKArray
Gives an array of five floats that contain CMYK values and opacity, each value is between 0 and 1.- Parameters:
name- 'device-cmyk(c, m, y, k)' structure- Returns:
- the corresponding array of five floats, or
nullif parsing failed.
-
getRGBAColor
Gives an array of four floats that contain RGBA values, each value is between 0 and 1.- Parameters:
name- a name such as black, violet, cornflowerblue or #RGB or #RRGGBB or RGB or RRGGBB or rgb(R,G,B) or rgb(R,G,B,A)- Returns:
- the corresponding array of four floats, or
nullif parsing failed.
-
parseRGBColors
-
parseCMYKColors
-
missingHashColorFormat
A web color string without the leading # will be 3 or 6 characters long and all those characters will be hex digits. NOTE: colStr must be all lower case or the current hex letter test will fail.- Parameters:
colStr- A non-null, lower case string that might describe an RGB color in hex.- Returns:
- Is this a web color hex string without the leading #?
-
getRGBChannelValue
-
getCMYKChannelValue
-
getAlphaChannelValue
-
parsePercentValue
-