| java.lang.Object org.awt.Color
Color | public class Color implements Transparency(Code) | | The Color class is used encapsulate colors in the default
sRGB color space or colors in arbitrary color spaces identified by a
ColorSpace . Every color has an implicit alpha value of 1.0 or
an explicit one provided in the constructor. The alpha value
defines the transparency of a color and can be represented by
a float value in the range 0.0 - 1.0 or 0 - 255.
An alpha value of 1.0 or 255 means that the color is completely
opaque and an alpha value of 0 or 0.0 means that the color is
completely transparent.
When constructing a Color with an explicit alpha or
getting the color/alpha components of a Color , the color
components are never premultiplied by the alpha component.
The default color space for the Java 2D(tm) API is sRGB, a proposed
standard RGB color space. For further information on sRGB,
see
http://www.w3.org/pub/WWW/Graphics/Color/sRGB.html
.
|
Constructor Summary | |
public | Color(int r, int g, int b) Creates an opaque sRGB color with the specified red, green,
and blue values in the range (0 - 255). | public | Color(int r, int g, int b, int a) Creates an sRGB color with the specified red, green, blue, and alpha
values in the range (0 - 255). | public | Color(int rgb) Creates an opaque sRGB 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. | public | Color(int rgba, boolean hasalpha) Creates an sRGB color with the specified combined RGBA value consisting
of the alpha component in bits 24-31, the red component in bits 16-23,
the green component in bits 8-15, and the blue component in bits 0-7. |
Method Summary | |
public static int | HSBtoRGB(float hue, float saturation, float brightness) Converts the components of a color, as specified by the HSB
model, to an equivalent set of values for the default RGB model. | public Color | brighter() Creates a new Color that is a brighter version of this
Color .
This method applies an arbitrary scale factor to each of the three RGB
components of this Color to create a brighter version
of this Color . | public Color | darker() Creates a new Color that is a darker version of this
Color .
This method applies an arbitrary scale factor to each of the three RGB
components of this Color to create a darker version of
this Color . | public static Color | decode(String nm) Converts a String to an integer and returns the
specified opaque Color . | public boolean | equals(Object obj) Determines whether another object is equal to this
Color .
The result is true if and only if the argument is not
null and is a Color object that has the same
red, green, blue, and alpha values as this object. | public int | getAlpha() Returns the alpha component in the range 0-255. | public int | getBlue() Returns the blue component in the range 0-255 in the default sRGB
space. | public static Color | getColor(String nm) Finds a color in the system properties. | public static Color | getColor(String nm, Color v) Finds a color in the system properties. | public static Color | getColor(String nm, int v) Finds a color in the system properties. | public int | getGreen() Returns the green component in the range 0-255 in the default sRGB
space. | public int | getRGB() Returns the RGB value representing the color in the default sRGB
ColorModel . | public int | getRed() Returns the red component in the range 0-255 in the default sRGB
space. | public int | getTransparency() Returns the transparency mode for this Color . | public int | hashCode() Computes the hash code for this Color . | public String | toString() Returns a string representation of this Color . |
black | final public static Color black(Code) | | The color black. In the default sRGB space.
|
blue | final public static Color blue(Code) | | The color blue. In the default sRGB space.
|
cyan | final public static Color cyan(Code) | | The color cyan. In the default sRGB space.
|
darkGray | final public static Color darkGray(Code) | | The color dark gray. In the default sRGB space.
|
gray | final public static Color gray(Code) | | The color gray. In the default sRGB space.
|
green | final public static Color green(Code) | | The color green. In the default sRGB space.
|
lightGray | final public static Color lightGray(Code) | | The color light gray. In the default sRGB space.
|
magenta | final public static Color magenta(Code) | | The color magenta. In the default sRGB space.
|
orange | final public static Color orange(Code) | | The color orange. In the default sRGB space.
|
pink | final public static Color pink(Code) | | The color pink. In the default sRGB space.
|
red | final public static Color red(Code) | | The color red. In the default sRGB space.
|
white | final public static Color white(Code) | | The color white. In the default sRGB space.
|
yellow | final public static Color yellow(Code) | | The color yellow. In the default sRGB space.
|
Color | public Color(int r, int g, int b)(Code) | | Creates an opaque sRGB color with the specified red, green,
and blue values in the range (0 - 255).
The actual color used in rendering depends
on finding the best match given the color space
available for a given output device.
Alpha is defaulted to 255.
Parameters: r - the red component Parameters: g - the green component Parameters: b - the blue component See Also: Color.getRed See Also: Color.getGreen See Also: Color.getBlue See Also: Color.getRGB |
Color | public Color(int r, int g, int b, int a)(Code) | | Creates an sRGB color with the specified red, green, blue, and alpha
values in the range (0 - 255).
Parameters: r - the red component Parameters: g - the green component Parameters: b - the blue component Parameters: a - the alpha component See Also: Color.getRed See Also: Color.getGreen See Also: Color.getBlue See Also: Color.getAlpha See Also: Color.getRGB |
Color | public Color(int rgb)(Code) | | Creates an opaque sRGB 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 depends on finding the best match given the
color space available for a particular output device. Alpha is
defaulted to 255.
Parameters: rgb - the combined RGB components See Also: java.awt.image.ColorModel.getRGBdefault See Also: Color.getRed See Also: Color.getGreen See Also: Color.getBlue See Also: Color.getRGB |
Color | public Color(int rgba, boolean hasalpha)(Code) | | Creates an sRGB color with the specified combined RGBA value consisting
of the alpha component in bits 24-31, the red component in bits 16-23,
the green component in bits 8-15, and the blue component in bits 0-7.
If the hasalpha argument is false , alpha
is defaulted to 255.
Parameters: rgba - the combined RGBA components Parameters: hasalpha - true if the alpha bits are valid;false otherwise See Also: java.awt.image.ColorModel.getRGBdefault See Also: Color.getRed See Also: Color.getGreen See Also: Color.getBlue See Also: Color.getAlpha See Also: Color.getRGB |
HSBtoRGB | public static int HSBtoRGB(float hue, float saturation, float brightness)(Code) | | Converts the components of a color, as specified by the HSB
model, to an equivalent set of values for the default RGB model.
The saturation and brightness components
should be floating-point values between zero and one
(numbers in the range 0.0-1.0). The hue component
can be any floating-point number. The floor of this number is
subtracted from it to create a fraction between 0 and 1. This
fractional number is then multiplied by 360 to produce the hue
angle in the HSB color model.
The integer that is returned by HSBtoRGB encodes the
value of a color in bits 0-23 of an integer value that is the same
format used by the method
Color.getRGB() getRGB .
This integer can be supplied as an argument to the
Color constructor that takes a single integer argument.
Parameters: hue - the hue component of the color Parameters: saturation - the saturation of the color Parameters: brightness - the brightness of the color the RGB value of the color with the indicated hue, saturation, and brightness. See Also: java.awt.Color.getRGB See Also: java.awt.Color.Color(int) See Also: java.awt.image.ColorModel.getRGBdefault since: JDK1.0 |
brighter | public Color brighter()(Code) | | Creates a new Color that is a brighter version of this
Color .
This method applies an arbitrary scale factor to each of the three RGB
components of this Color to create a brighter version
of this Color . Although brighter and
darker are inverse operations, the results of a
series of invocations of these two methods might be inconsistent
because of rounding errors.
a new Color object that is a brighter version of this Color . See Also: java.awt.Color.darker since: JDK1.0 |
darker | public Color darker()(Code) | | Creates a new Color that is a darker version of this
Color .
This method applies an arbitrary scale factor to each of the three RGB
components of this Color to create a darker version of
this Color . Although brighter and
darker are inverse operations, the results of a series
of invocations of these two methods might be inconsistent because
of rounding errors.
a new Color object that is a darker version of this Color . See Also: java.awt.Color.brighter since: JDK1.0 |
decode | public static Color decode(String nm) throws NumberFormatException(Code) | | Converts a String to an integer and returns the
specified opaque Color . This method handles string
formats that are used to represent octal and hexidecimal numbers.
Parameters: nm - a String that represents an opaque color as a 24-bit integer the new Color object. See Also: java.lang.Integer.decode exception: NumberFormatException - if the specified string cannotbe interpreted as a decimal, octal, or hexidecimal integer. since: JDK1.1 |
equals | public boolean equals(Object obj)(Code) | | Determines whether another object is equal to this
Color .
The result is true if and only if the argument is not
null and is a Color object that has the same
red, green, blue, and alpha values as this object.
Parameters: obj - the object to test for equality with thisColor true if the objects are the same; false otherwise. since: JDK1.0 |
getAlpha | public int getAlpha()(Code) | | Returns the alpha component in the range 0-255.
the alpha component. See Also: Color.getRGB |
getBlue | public int getBlue()(Code) | | Returns the blue component in the range 0-255 in the default sRGB
space.
the blue component. See Also: Color.getRGB |
getColor | public static Color getColor(String nm, Color v)(Code) | | Finds a color in the system properties.
The first argument is treated as the name of a system property to
be obtained. The string value of this property is then interpreted
as an integer which is then converted to a Color
object.
If the specified property is not found or cannot be parsed as
an integer then the Color specified by the second
argument is returned instead.
Parameters: nm - the name of the color property Parameters: v - the default Color the Color converted from the systemproperty, or the specified Color . See Also: java.lang.System.getProperty(java.lang.String) See Also: java.lang.Integer.getInteger(java.lang.String) See Also: java.awt.Color.Color(int) since: JDK1.0 |
getColor | public static Color getColor(String nm, int v)(Code) | | Finds a color in the system properties.
The first argument is treated as the name of a system property to
be obtained. The string value of this property is then interpreted
as an integer which is then converted to a Color
object.
If the specified property is not found or could not be parsed as
an integer then the integer value v is used instead,
and is converted to a Color object.
Parameters: nm - the name of the color property Parameters: v - the default color value, as an integer the Color converted from the systemproperty or the Color converted fromthe specified integer. See Also: java.lang.System.getProperty(java.lang.String) See Also: java.lang.Integer.getInteger(java.lang.String) See Also: java.awt.Color.Color(int) since: JDK1.0 |
getGreen | public int getGreen()(Code) | | Returns the green component in the range 0-255 in the default sRGB
space.
the green component. See Also: Color.getRGB |
getRed | public int getRed()(Code) | | Returns the red component in the range 0-255 in the default sRGB
space.
the red component. See Also: Color.getRGB |
getTransparency | public int getTransparency()(Code) | | Returns the transparency mode for this Color . This is
required to implement the Paint interface.
this Color object's transparency mode. See Also: Transparency See Also: Color.createContext |
hashCode | public int hashCode()(Code) | | Computes the hash code for this Color .
a hash code value for this object. since: JDK1.0 |
toString | public String toString()(Code) | | Returns a string representation of this Color . This
method is intended to be used only for debugging purposes. The
content and format of the returned string might vary between
implementations. The returned string might be empty but cannot
be null .
a string representation of this Color . |
|
|