Class java.awt.Color
All Packages Class Hierarchy This Package Previous Next Index
Class java.awt.Color
java.lang.Object
|
+----java.awt.Color
- public final class Color
- extends Object
A class to encapsulate RGB Colors.
-
black
- The color black.
-
blue
- The color blue.
-
cyan
- The color cyan.
-
darkGray
- The color dark gray.
-
gray
- The color gray.
-
green
- The color green.
-
lightGray
- The color light gray.
-
magenta
- The color magneta.
-
orange
- The color orange.
-
pink
- The color pink.
-
red
- The color red.
-
white
- The color white.
-
yellow
- The color yellow.
-
Color(float, float, float)
- Creates a color with the specified red, green, and blue values in the
range (0.0 - 1.0).
-
Color(int)
- Creates a color with the specified combined RGB value consisting of
the red component in bits 16-23, the green component in bits 8-15,
and the blue component in bits 0-7.
-
Color(int, int, int)
- Creates a color with the specified red, green, and blue values in
the range (0 - 255).
-
brighter()
- Returns a brighter version of this color.
-
darker()
- Returns a darker version of this color.
-
equals(Object)
- Compares this object against the specified object.
-
getBlue()
- Gets the blue component.
-
getColor(String)
- Gets the specified Color property.
-
getColor(String, Color)
- Gets the specified Color property of the specified Color.
-
getColor(String, int)
- Gets the specified Color property of the color value.
-
getGreen()
- Gets the green component.
-
getHSBColor(float, float, float)
- A static Color factory for generating a Color object from HSB
values.
-
getRed()
- Gets the red component.
-
getRGB()
- Gets the RGB value representing the color in the default RGB ColorModel.
-
hashCode()
- Computes the hash code.
-
HSBtoRGB(float, float, float)
- Returns the RGB value defined by the default RGB ColorModel, of
the color corresponding to the given HSB color components.
-
RGBtoHSB(int, int, int, float[])
- Returns the HSB values corresponding to the color defined by the
red, green, and blue components.
-
toString()
- Returns the String representation of this Color's values.
white
public final static Color white
- The color white.
lightGray
public final static Color lightGray
- The color light gray.
gray
public final static Color gray
- The color gray.
darkGray
public final static Color darkGray
- The color dark gray.
black
public final static Color black
- The color black.
red
public final static Color red
- The color red.
pink
public final static Color pink
- The color pink.
orange
public final static Color orange
- The color orange.
yellow
public final static Color yellow
- The color yellow.
green
public final static Color green
- The color green.
magenta
public final static Color magenta
- The color magneta.
cyan
public final static Color cyan
- The color cyan.
blue
public final static Color blue
- The color blue.
Color
public Color(int r,
int g,
int b)
- Creates a color with the specified red, green, and blue values in
the range (0 - 255). The actual color used in rendering will depend
on finding the best match given the color space available for a
given output device.
- Parameters:
- r - the red component
- g - the green component
- b - the blue component
- See Also:
- getRed, getGreen, getBlue, getRGB
Color
public Color(int rgb)
- Creates a color with the specified combined RGB value consisting of
the red component in bits 16-23, the green component in bits 8-15,
and the blue component in bits 0-7. The actual color used in
rendering will depend on finding the best match given the color space
available for a given output device.
- Parameters:
- rgb - the combined RGB components
- See Also:
- getRGBdefault, getRed, getGreen, getBlue, getRGB
Color
public Color(float r,
float g,
float b)
- Creates a color with the specified red, green, and blue values in the
range (0.0 - 1.0). The actual color
used in rendering will depend on finding the best match given the
color space available for a given output device.
- Parameters:
- r - the red component
- g - the red component
- b - the red component
- See Also:
- getRed, getGreen, getBlue, getRGB
getRed
public int getRed()
- Gets the red component.
- See Also:
- getRGB
getGreen
public int getGreen()
- Gets the green component.
- See Also:
- getRGB
getBlue
public int getBlue()
- Gets the blue component.
- See Also:
- getRGB
getRGB
public int getRGB()
- Gets the RGB value representing the color in the default RGB ColorModel.
(Bits 24-31 are 0xff, 16-23 are red, 8-15 are green, 0-7 are blue).
- See Also:
- getRGBdefault, getRed, getGreen, getBlue
brighter
public Color brighter()
- Returns a brighter version of this color.
darker
public Color darker()
- Returns a darker version of this color.
hashCode
public int hashCode()
- Computes the hash code.
- Overrides:
- hashCode in class Object
equals
public boolean equals(Object obj)
- Compares this object against the specified object.
- Parameters:
- obj - the object to compare with.
- Returns:
- true if the objects are the same; false otherwise.
- Overrides:
- equals in class Object
toString
public String toString()
- Returns the String representation of this Color's values.
- Overrides:
- toString in class Object
getColor
public static Color getColor(String nm)
- Gets the specified Color property.
- Parameters:
- nm - the name of the color property
getColor
public static Color getColor(String nm,
Color v)
- Gets the specified Color property of the specified Color.
- Parameters:
- nm - the name of the color property
- v - the specified color
- Returns:
- the new color.
getColor
public static Color getColor(String nm,
int v)
- Gets the specified Color property of the color value.
- Parameters:
- nm - the name of the color property
- v - the color value
- Returns:
- the new color.
HSBtoRGB
public static int HSBtoRGB(float hue,
float saturation,
float brightness)
- Returns the RGB value defined by the default RGB ColorModel, of
the color corresponding to the given HSB color components.
- Parameters:
- hue - the hue component of the color
- saturation - the saturation of the color
- brightness - the brightness of the color
- See Also:
- getRGBdefault, getRGB
RGBtoHSB
public static float[] RGBtoHSB(int r,
int g,
int b,
float hsbvals[])
- Returns the HSB values corresponding to the color defined by the
red, green, and blue components.
- Parameters:
- r - the red component of the color
- g - the green component of the color
- b - the blue component of the color
- hsbvals - the array to be used to return the 3 HSB values, or null
- Returns:
- the array used to store the results [hue, saturation, brightness]
- See Also:
- getRGBdefault, getRGB
getHSBColor
public static Color getHSBColor(float h,
float s,
float b)
- A static Color factory for generating a Color object from HSB
values.
- Parameters:
- h - the hue component
- s - the saturation of the color
- b - the brightness of the color
- Returns:
- the Color object for the corresponding RGB color
All Packages Class Hierarchy This Package Previous Next Index