public class Color extends Object implements Serializable
| Modifier and Type | Field and Description |
|---|---|
static Color |
BLACK |
static Color |
BLUE |
static Color |
CYAN |
static Color |
GREEN |
static Color |
MAGENTA |
static Color |
RED |
static Color |
WHITE |
static Color |
YELLOW |
| Constructor and 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].
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
int |
getAlpha()
Returns the alpha value of the color.
|
int |
getBlue()
Returns the blue value of the color.
|
String |
getCSS()
Returns CSS representation of the Color, e.g.
|
int |
getGreen()
Returns the green value of the color.
|
float[] |
getHSV()
Returns converted HSV components of the color.
|
int |
getRed()
Returns the red value of the color.
|
int |
getRGB()
Returns RGB value of the color.
|
int |
hashCode() |
static int |
HSLtoRGB(int hue,
int saturation,
int lightness)
Converts HSL's hue, saturation and lightness into an RGB value.
|
static int |
HSVtoRGB(float hue,
float saturation,
float value)
Converts HSV's hue, saturation and value into an RGB value.
|
void |
setAlpha(int alpha)
Sets the alpha value of the color.
|
void |
setBlue(int blue)
Sets the blue value of the color.
|
void |
setGreen(int green)
Sets the green value of the color.
|
void |
setRed(int red)
Sets the red value of the color.
|
public static final Color WHITE
public static final Color BLACK
public static final Color RED
public static final Color GREEN
public static final Color BLUE
public static final Color YELLOW
public static final Color MAGENTA
public static final Color CYAN
public Color(int red,
int green,
int blue,
int alpha)
red - the red valuegreen - the green valueblue - the blue valuealpha - the alpha valueIllegalArgumentException - if red, green, blue or
alpha fall outside of the inclusive range from 0
to 255public Color(int red,
int green,
int blue)
red - the red valuegreen - the green valueblue - the blue valueIllegalArgumentException - if red, green or blue
fall outside of the inclusive range from 0 to 255public Color(int rgb)
rgb - the RGB valueIllegalArgumentException - if converted values of red, green,
blue or alpha fall outside of the
inclusive range from 0 to 255public int getRed()
public void setRed(int red)
red - new red valuepublic int getGreen()
public void setGreen(int green)
green - new green valuepublic int getBlue()
public void setBlue(int blue)
blue - new blue valuepublic int getAlpha()
public void setAlpha(int alpha)
alpha - new alpha valuepublic String getCSS()
public int getRGB()
public float[] getHSV()
public static int HSVtoRGB(float hue,
float saturation,
float value)
Converts HSV's hue, saturation and value into an RGB value.
The saturation and value components should be
floating-point values within the range [0.0-1.0].
hue - the hue of the colorsaturation - the saturation of the colorvalue - the value of the colorpublic static int HSLtoRGB(int hue,
int saturation,
int lightness)
Converts HSL's hue, saturation and lightness into an RGB value.
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;Copyright © 2021 Vaadin Ltd. All rights reserved.