com.vaadin.shared.ui.colorpicker
Class Color

java.lang.Object
  extended by com.vaadin.shared.ui.colorpicker.Color
All Implemented Interfaces:
java.io.Serializable

public class Color
extends java.lang.Object
implements java.io.Serializable

Default implementation for color.

Since:
7.0.0
See Also:
Serialized Form

Field Summary
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 Summary
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
 boolean equals(java.lang.Object obj)
           
 int getAlpha()
          Returns the alpha value of the color.
 int getBlue()
          Returns the blue value of the color.
 java.lang.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.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

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 value
green - the green value
blue - the blue value
alpha - the alpha value
Throws:
java.lang.IllegalArgumentException - if red, green, blue or alpha fall 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 value
green - the green value
blue - the blue value
Throws:
java.lang.IllegalArgumentException - if red, green or blue fall 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:
java.lang.IllegalArgumentException - if converted values of red, green, blue or alpha fall 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 java.lang.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.


hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

HSVtoRGB

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].

Parameters:
hue - the hue of the color
saturation - the saturation of the color
value - 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


Copyright © 2000-2014 Vaadin Ltd. All Rights Reserved.