public class ColorUtils extends Object
Modifier and Type | Method and Description |
---|---|
static Color |
decodeRGB(String colorString)
Decode a string with an RGB color into a Color object.
|
static Color |
decodeRGBSilently(String colorString)
Like
decodeRGB(String) but does not throw an exception if the color cannot be
parsed. |
static String |
encodeRGBHexString(Color color,
boolean withAlpha)
Create a string representation of the color in the format
#RRGGBB or
#RRGGBBAA if withAlpha is true. |
static String |
encodeRGBIntString(Color color,
boolean withAlpha)
Create a string of the integer values of the RGB components of the color.
|
public static Color decodeRGB(String colorString)
colorString
- the string to decode. Supported formats are hex and integer notations. The hex
notation has to have the format #RRGGBB
or #RRGGBBAA
with an alpha channel. The integer notation has to have the format
R,G,B
or R,G,B,A
with an alpha channel and values of the
components have to be in the range 0-255.public static Color decodeRGBSilently(String colorString)
decodeRGB(String)
but does not throw an exception if the color cannot be
parsed.colorString
- the string to decodepublic static String encodeRGBHexString(Color color, boolean withAlpha)
#RRGGBB
or
#RRGGBBAA
if withAlpha is true. The RR is the 2 byte hex value of the red
component of the color.color
- the color to encodewithAlpha
- whether to include the alpha value in the resultpublic static String encodeRGBIntString(Color color, boolean withAlpha)
color
- the color to encodewithAlpha
- whether the alpha value should be appendedCopyright © 2019 Communote team. All rights reserved.