Class ColorUtil
- java.lang.Object
-
- com.vaadin.ui.components.colorpicker.ColorUtil
-
-
Field Summary
Fields Modifier and Type Field Description static PatternHEX_PATTERNCase-insensitivePatternwith regular expression matching the default hexadecimal color presentation pattern:
'#' followed by six[\da-fA-F]characters.static PatternHSL_PATTERNCase-insensitivePatternwith regular expression matching common HSL presentation patterns:
'hsl' followed by one [0-360] value and two [0-100] percentage value.static PatternHSLA_PATTERNCase-insensitivePatternwith regular expression matching common HSLA presentation patterns:
'hsla' followed by one [0-360] value, two [0-100] percentage values, and one [0.0-1.0] value.static PatternRGB_PATTERNCase-insensitivePatternwith regular expression matching common RGB color presentation patterns:
'rgb' followed by three [0-255] number values.static PatternRGBA_PATTERNCase-insensitivePatternwith regular expression matching common RGBA presentation patterns:
'rgba' followed by three [0-255] values and one [0.0-1.0] value.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ColorgetHexPatternColor(Matcher matcher)static ColorgetHSLAPatternColor(Matcher matcher)static ColorgetHSLPatternColor(Matcher matcher)static ColorgetRGBAPatternColor(Matcher matcher)static ColorgetRGBPatternColor(Matcher matcher)static ColorstringToColor(String input)
-
-
-
Field Detail
-
HEX_PATTERN
public static final Pattern HEX_PATTERN
Case-insensitivePatternwith regular expression matching the default hexadecimal color presentation pattern:
'#' followed by six[\da-fA-F]characters.Pattern contains named groups
red,green, andblue, which represent the individual values.
-
RGB_PATTERN
public static final Pattern RGB_PATTERN
Case-insensitivePatternwith regular expression matching common RGB color presentation patterns:
'rgb' followed by three [0-255] number values. Values can be separated with either comma or whitespace.Pattern contains named groups
red,green, andblue, which represent the individual values.
-
RGBA_PATTERN
public static final Pattern RGBA_PATTERN
Case-insensitivePatternwith regular expression matching common RGBA presentation patterns:
'rgba' followed by three [0-255] values and one [0.0-1.0] value. Values can be separated with either comma or whitespace. The only accepted decimal marker is point ('.').Pattern contains named groups
red,green,blue, andalpha, which represent the individual values.
-
HSL_PATTERN
public static final Pattern HSL_PATTERN
Case-insensitivePatternwith regular expression matching common HSL presentation patterns:
'hsl' followed by one [0-360] value and two [0-100] percentage value. Values can be separated with either comma or whitespace. The percent sign ('%') is optional.Pattern contains named groups
hue,saturation, andlight, which represent the individual values.
-
HSLA_PATTERN
public static final Pattern HSLA_PATTERN
Case-insensitivePatternwith regular expression matching common HSLA presentation patterns:
'hsla' followed by one [0-360] value, two [0-100] percentage values, and one [0.0-1.0] value. Values can be separated with either comma or whitespace. The percent sign ('%') is optional. The only accepted decimal marker is point ('.').Pattern contains named groups
hue,saturation,light, andalpha, which represent the individual values.
-
-
Method Detail
-
stringToColor
public static Color stringToColor(String input)
ParsesColorfrom any of the followingStringinputs:
- RGB hex (e.g. "#FFAA00"),HEX_PATTERN
- RGB "function" (e.g. "rgb(128,0,255)"),RGB_PATTERN
- RGBA "function" (e.g. "rgba(50,50,50,0.2)"),RGBA_PATTERN
- HSL "function" (e.g. "hsl(50,50,50)"),HSL_PATTERN
- HSLA "function" (e.g. "hsl(50,50,50,0.2)"),HSLA_PATTERNParsing is case-insensitive.
- Parameters:
input- String input- Returns:
Colorparsed from input- Throws:
NumberFormatException- Input does not match any recognized pattern
-
-