Package com.vaadin.shared.ui.colorpicker
Class Color
- java.lang.Object
-
- com.vaadin.shared.ui.colorpicker.Color
-
- All Implemented Interfaces:
Serializable
public class Color extends Object implements Serializable
Default implementation for color.- Since:
- 7.0.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Color(int rgb)Creates a color based on an RGB value.Color(int red, int green, int blue)Creates a color that has the specified red, green, and blue values within the range [0 - 255].Color(int red, int green, int blue, int alpha)Creates a color that has the specified red, green, blue, and alpha values within the range [0 - 255].
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)intgetAlpha()Returns the alpha value of the color.intgetBlue()Returns the blue value of the color.StringgetCSS()Returns CSS representation of the Color, e.g.intgetGreen()Returns the green value of the color.float[]getHSV()Returns converted HSV components of the color.intgetRed()Returns the red value of the color.intgetRGB()Returns RGB value of the color.inthashCode()static intHSLtoRGB(int hue, int saturation, int lightness)Converts HSL's hue, saturation and lightness into an RGB value.static intHSVtoRGB(float hue, float saturation, float value)Converts HSV's hue, saturation and value into an RGB value.voidsetAlpha(int alpha)Sets the alpha value of the color.voidsetBlue(int blue)Sets the blue value of the color.voidsetGreen(int green)Sets the green value of the color.voidsetRed(int red)Sets the red value of the color.
-
-
-
Field Detail
-
WHITE
public static final Color WHITE
-
BLACK
public static final Color BLACK
-
RED
public static final Color RED
-
GREEN
public static final Color GREEN
-
BLUE
public static final Color BLUE
-
YELLOW
public static final Color YELLOW
-
MAGENTA
public static final Color MAGENTA
-
CYAN
public static final Color CYAN
-
-
Constructor Detail
-
Color
public Color(int red, int green, int blue, int alpha)Creates a color that has the specified red, green, blue, and alpha values within the range [0 - 255].- Parameters:
red- the red valuegreen- the green valueblue- the blue valuealpha- the alpha value- Throws:
IllegalArgumentException- ifred,green,blueoralphafall outside of the inclusive range from 0 to 255
-
Color
public Color(int red, int green, int blue)Creates a color that has the specified red, green, and blue values within the range [0 - 255]. Alpha gets the default value of 255.- Parameters:
red- the red valuegreen- the green valueblue- the blue value- Throws:
IllegalArgumentException- ifred,greenorbluefall outside of the inclusive range from 0 to 255
-
Color
public Color(int rgb)
Creates a color based on an RGB value.- Parameters:
rgb- the RGB value- Throws:
IllegalArgumentException- if converted values ofred,green,blueoralphafall outside of the inclusive range from 0 to 255
-
-
Method Detail
-
getRed
public int getRed()
Returns the red value of the color.
-
setRed
public void setRed(int red)
Sets the red value of the color. Value must be within the range [0, 255].- Parameters:
red- new red value
-
getGreen
public int getGreen()
Returns the green value of the color.
-
setGreen
public void setGreen(int green)
Sets the green value of the color. Value must be within the range [0, 255].- Parameters:
green- new green value
-
getBlue
public int getBlue()
Returns the blue value of the color.
-
setBlue
public void setBlue(int blue)
Sets the blue value of the color. Value must be within the range [0, 255].- Parameters:
blue- new blue value
-
getAlpha
public int getAlpha()
Returns the alpha value of the color.
-
setAlpha
public void setAlpha(int alpha)
Sets the alpha value of the color. Value must be within the range [0, 255].- Parameters:
alpha- new alpha value
-
getCSS
public String getCSS()
Returns CSS representation of the Color, e.g. #000000.
-
getRGB
public int getRGB()
Returns RGB value of the color.
-
getHSV
public float[] getHSV()
Returns converted HSV components of the color.
-
HSVtoRGB
public static int HSVtoRGB(float hue, float saturation, float value)Converts HSV's hue, saturation and value into an RGB value.
The
saturationandvaluecomponents should be floating-point values within the range [0.0-1.0].- Parameters:
hue- the hue of the colorsaturation- the saturation of the colorvalue- the value of the color- Returns:
- the RGB value of corresponding color
-
HSLtoRGB
public static int HSLtoRGB(int hue, int saturation, int lightness)Converts HSL's hue, saturation and lightness into an RGB value.
- Parameters:
hue- the hue of the color. The unit of the value is degrees and should be between 0-360.saturation- the saturation of the color. The unit of the value is percentages and should be between 0-100;lightness- the lightness of the color. The unit of the value is percentages and should be between 0-100;- Returns:
- the RGB value of corresponding color
-
-