Class ColorUtil
- java.lang.Object
-
- com.vaadin.ui.components.colorpicker.ColorUtil
-
public class ColorUtil extends java.lang.ObjectUtility class for matching and parsingColorobjects fromStringinput. Description of supported formats see http://www.w3schools.com/cssref/css_colors_legal.asp- Since:
- 8.4
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.regex.PatternHEX_PATTERNCase-insensitivePatternwith regular expression matching the default hexadecimal color presentation pattern:
'#' followed by six[\da-fA-F]characters.static java.util.regex.PatternHSL_PATTERNCase-insensitivePatternwith regular expression matching common HSL presentation patterns:
'hsl' followed by one [0-360] value and two [0-100] percentage value.static java.util.regex.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 java.util.regex.PatternRGB_PATTERNCase-insensitivePatternwith regular expression matching common RGB color presentation patterns:
'rgb' followed by three [0-255] number values.static java.util.regex.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 com.vaadin.shared.ui.colorpicker.ColorgetHexPatternColor(java.util.regex.Matcher matcher)ParsesColorfrom matched hexadecimalMatcher.static com.vaadin.shared.ui.colorpicker.ColorgetHSLAPatternColor(java.util.regex.Matcher matcher)ParsesColorfrom matched HSLAMatcher.static com.vaadin.shared.ui.colorpicker.ColorgetHSLPatternColor(java.util.regex.Matcher matcher)ParsesColorfrom matched HSLMatcher.static com.vaadin.shared.ui.colorpicker.ColorgetRGBAPatternColor(java.util.regex.Matcher matcher)ParsesColorfrom matched RGBAMatcher.static com.vaadin.shared.ui.colorpicker.ColorgetRGBPatternColor(java.util.regex.Matcher matcher)ParsesColorfrom matched RGBMatcher.static com.vaadin.shared.ui.colorpicker.ColorstringToColor(java.lang.String input)ParsesColorfrom any of the followingStringinputs:
- RGB hex (e.g.
-
-
-
Field Detail
-
HEX_PATTERN
public static final java.util.regex.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 java.util.regex.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 java.util.regex.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 java.util.regex.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 java.util.regex.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 com.vaadin.shared.ui.colorpicker.Color stringToColor(java.lang.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:
java.lang.NumberFormatException- Input does not match any recognized pattern
-
getHexPatternColor
public static com.vaadin.shared.ui.colorpicker.Color getHexPatternColor(java.util.regex.Matcher matcher)
ParsesColorfrom matched hexadecimalMatcher.- Parameters:
matcher-Matchermatching hexadecimal pattern with named regex groupsred,green, andblue- Returns:
Colorparsed fromMatcher
-
getRGBPatternColor
public static com.vaadin.shared.ui.colorpicker.Color getRGBPatternColor(java.util.regex.Matcher matcher)
ParsesColorfrom matched RGBMatcher.- Parameters:
matcher-Matchermatching RGB pattern with named regex groupsred,green, andblue- Returns:
Colorparsed fromMatcher
-
getRGBAPatternColor
public static com.vaadin.shared.ui.colorpicker.Color getRGBAPatternColor(java.util.regex.Matcher matcher)
ParsesColorfrom matched RGBAMatcher.- Parameters:
matcher-Matchermatching RGBA pattern with named regex groupsred,green,blue, andalpha- Returns:
Colorparsed fromMatcher
-
getHSLPatternColor
public static com.vaadin.shared.ui.colorpicker.Color getHSLPatternColor(java.util.regex.Matcher matcher)
ParsesColorfrom matched HSLMatcher.- Parameters:
matcher-Matchermatching HSL pattern with named regex groupshue,saturation, andlight- Returns:
Colorparsed fromMatcher
-
getHSLAPatternColor
public static com.vaadin.shared.ui.colorpicker.Color getHSLAPatternColor(java.util.regex.Matcher matcher)
ParsesColorfrom matched HSLAMatcher.- Parameters:
matcher-Matchermatching HSLA pattern with named regex groupshue,saturation,light, andalpha- Returns:
Colorparsed fromMatcher
-
-