| 
 | JSR 217 (Maintenance Release) | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.awt.Color
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 .
ColorSpace, 
AlphaComposite, 
Serialized Form| Field Summary | |
| static Color | blackAn object of type Colorrepresenting
 the color black. | 
| static Color | BLACKAn object of type Colorrepresenting
 the color black. | 
| static Color | blueAn object of type Colorrepresenting
 the color blue. | 
| static Color | BLUEAn object of type Colorrepresenting
 the color blue. | 
| static Color | cyanAn object of type Colorrepresenting
 the color cyan. | 
| static Color | CYANAn object of type Colorrepresenting
 the color cyan. | 
| static Color | DARK_GRAYAn object of type Colorrepresenting
 the color dark gray. | 
| static Color | darkGrayAn object of type Colorrepresenting
 the color dark gray. | 
| static Color | grayAn object of type Colorrepresenting
 the color gray. | 
| static Color | GRAYAn object of type Colorrepresenting
 the color gray. | 
| static Color | greenAn object of type Colorrepresenting
 the color green. | 
| static Color | GREENAn object of type Colorrepresenting
 the color green. | 
| static Color | LIGHT_GRAYAn object of type Colorrepresenting
 the color light gray. | 
| static Color | lightGrayAn object of type Colorrepresenting
 the color light gray. | 
| static Color | magentaAn object of type Colorrepresenting
 the color magenta. | 
| static Color | MAGENTAAn object of type Colorrepresenting
 the color magenta. | 
| static Color | orangeAn object of type Colorrepresenting
 the color orange. | 
| static Color | ORANGEAn object of type Colorrepresenting
 the color orange. | 
| static Color | pinkAn object of type Colorrepresenting
 the color pink. | 
| static Color | PINKAn object of type Colorrepresenting
 the color pink. | 
| static Color | redAn object of type Colorrepresenting
 the color red. | 
| static Color | REDAn object of type Colorrepresenting
 the color red. | 
| static Color | whiteAn object of type Colorrepresenting
 the color white. | 
| static Color | WHITEAn object of type Colorrepresenting
 the color white. | 
| static Color | yellowAn object of type Colorrepresenting
 the color yellow. | 
| static Color | YELLOWAn object of type Colorrepresenting
 the color yellow. | 
| Fields inherited from interface java.awt.Transparency | 
| BITMASK, OPAQUE, TRANSLUCENT | 
| Constructor Summary | |
| Color(float r,
      float g,
      float b)Creates an opaque sRGB color with the specified red, green, and blue values in the range (0.0 - 1.0). | |
| Color(float r,
      float g,
      float b,
      float a)Creates an sRGB color with the specified red, green, blue, and alpha values in the range (0.0 - 1.0). | |
| 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. | |
| 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. | |
| 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). | |
| 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). | |
| Method Summary | |
|  Color | brighter()Creates a new Colorthat is a brighter version of thisColor. | 
|  Color | darker()Creates a new Colorthat is a darker version of thisColor. | 
| static Color | decode(String nm)Converts a Stringto an integer and returns the 
 specified opaqueColor. | 
|  boolean | equals(Object obj)Determines whether another object is equal to this Color. | 
|  int | getAlpha()Returns the alpha component in the range 0-255. | 
|  int | getBlue()Returns the blue component in the range 0-255 in the default sRGB space. | 
| static Color | getColor(String nm)Finds a color in the system properties. | 
| static Color | getColor(String nm,
         Color v)Finds a color in the system properties. | 
| static Color | getColor(String nm,
         int v)Finds a color in the system properties. | 
|  float[] | getColorComponents(float[] compArray)Returns a floatarray containing only the color
 components of theColor, in theColorSpaceof theColor. | 
|  ColorSpace | getColorSpace()Returns the ColorSpaceof thisColor. | 
|  float[] | getComponents(float[] compArray)Returns a floatarray containing the color and alpha
 components of theColor, in theColorSpaceof theColor. | 
|  int | getGreen()Returns the green component in the range 0-255 in the default sRGB space. | 
| static Color | getHSBColor(float h,
            float s,
            float b)Creates a Colorobject based on the specified values 
 for the HSB color model. | 
|  int | getRed()Returns the red component in the range 0-255 in the default sRGB space. | 
|  int | getRGB()Returns the RGB value representing the color in the default sRGB ColorModel. | 
|  float[] | getRGBColorComponents(float[] compArray)Returns a floatarray containing only the color
 components of theColor, in the default sRGB color
 space. | 
|  float[] | getRGBComponents(float[] compArray)Returns a floatarray containing the color and alpha
 components of theColor, as represented in the default
 sRGB color space. | 
|  int | getTransparency()Returns the transparency mode for this Color. | 
|  int | hashCode()Computes the hash code for this Color. | 
| 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. | 
| static float[] | RGBtoHSB(int r,
         int g,
         int b,
         float[] hsbvals)Converts the components of a color, as specified by the default RGB model, to an equivalent set of values for hue, saturation, and brightness that are the three components of the HSB model. | 
|  String | toString()Returns a string representation of this Color. | 
| Methods inherited from class java.lang.Object | 
| clone, finalize, getClass, notify, notifyAll, wait, wait, wait | 
| Field Detail | 
public static final Color white
Color representing
 the color white.  In the default sRGB space.
public static final Color WHITE
Color representing
 the color white.  In the default sRGB space.
public static final Color lightGray
Color representing
 the color light gray.  In the default sRGB space.
public static final Color LIGHT_GRAY
Color representing
 the color light gray.  In the default sRGB space.
public static final Color gray
Color representing
 the color gray.  In the default sRGB space.
public static final Color GRAY
Color representing
 the color gray.  In the default sRGB space.
public static final Color darkGray
Color representing
 the color dark gray.  In the default sRGB space.
public static final Color DARK_GRAY
Color representing
 the color dark gray.  In the default sRGB space.
public static final Color black
Color representing
 the color black.  In the default sRGB space.
public static final Color BLACK
Color representing
 the color black.  In the default sRGB space.
public static final Color red
Color representing
 the color red.  In the default sRGB space.
public static final Color RED
Color representing
 the color red.  In the default sRGB space.
public static final Color pink
Color representing
 the color pink.  In the default sRGB space.
public static final Color PINK
Color representing
 the color pink.  In the default sRGB space.
public static final Color orange
Color representing
 the color orange.  In the default sRGB space.
public static final Color ORANGE
Color representing
 the color orange.  In the default sRGB space.
public static final Color yellow
Color representing
 the color yellow.  In the default sRGB space.
public static final Color YELLOW
Color representing
 the color yellow.  In the default sRGB space.
public static final Color green
Color representing
 the color green.  In the default sRGB space.
public static final Color GREEN
Color representing
 the color green.  In the default sRGB space.
public static final Color magenta
Color representing
 the color magenta.  In the default sRGB space.
public static final Color MAGENTA
Color representing
 the color magenta.  In the default sRGB space.
public static final Color cyan
Color representing
 the color cyan.  In the default sRGB space.
public static final Color CYAN
Color representing
 the color cyan.  In the default sRGB space.
public static final Color blue
Color representing
 the color blue.  In the default sRGB space.
public static final Color BLUE
Color representing
 the color blue.  In the default sRGB space.
| Constructor Detail | 
public Color(int r,
             int g,
             int b)
r - the red componentg - the green componentb - the blue componentgetRed(), 
getGreen(), 
getBlue(), 
getRGB()
public Color(int r,
             int g,
             int b,
             int a)
r - the red componentg - the green componentb - the blue componenta - the alpha componentgetRed(), 
getGreen(), 
getBlue(), 
getAlpha(), 
getRGB()public Color(int rgb)
rgb - the combined RGB componentsColorModel.getRGBdefault(), 
getRed(), 
getGreen(), 
getBlue(), 
getRGB()
public Color(int rgba,
             boolean hasalpha)
hasalpha argument is false, alpha
 is defaulted to 255.
rgba - the combined RGBA componentshasalpha - true if the alpha bits are valid;
 false otherwiseColorModel.getRGBdefault(), 
getRed(), 
getGreen(), 
getBlue(), 
getAlpha(), 
getRGB()
public Color(float r,
             float g,
             float b)
r - the red componentg - the green componentb - the blue componentgetRed(), 
getGreen(), 
getBlue(), 
getRGB()
public Color(float r,
             float g,
             float b,
             float a)
r - the red componentg - the green componentb - the blue componenta - the alpha componentgetRed(), 
getGreen(), 
getBlue(), 
getAlpha(), 
getRGB()| Method Detail | 
public int getRed()
getRGB()public int getGreen()
getRGB()public int getBlue()
getRGB()public int getAlpha()
getRGB()public int getRGB()
ColorModel.
 (Bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are
 blue).
ColorModel.ColorModel.getRGBdefault(), 
getRed(), 
getGreen(), 
getBlue()public Color brighter()
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.
Color object that is  
                 a brighter version of this Color.darker()public Color darker()
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.
Color object that is 
                    a darker version of this Color.brighter()public int hashCode()
Color.
hashCode in class ObjectObject.equals(java.lang.Object), 
Hashtablepublic boolean equals(Object obj)
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.
equals in class Objectobj - the object to test for equality with this
				Color
true if the objects are the same; 
                             false otherwise.Object.hashCode(), 
Hashtablepublic String toString()
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.
toString in class ObjectColor.
public static Color decode(String nm)
                    throws NumberFormatException
String to an integer and returns the 
 specified opaque Color. This method handles string
 formats that are used to represent octal and hexidecimal numbers.
nm - a String that represents 
                            an opaque color as a 24-bit integer
Color object.
NumberFormatException - if the specified string cannot
                      be interpreted as a decimal, 
                      octal, or hexidecimal integer.Integer.decode(java.lang.String)public static Color getColor(String nm)
 The 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 null is returned.
nm - the name of the color property
Color converted from the system 
 		property.System.getProperty(java.lang.String), 
Integer.getInteger(java.lang.String), 
Color(int)
public static Color getColor(String nm,
                             Color v)
 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.
nm - the name of the color propertyv - the default Color
Color converted from the system
		property, or the specified Color.System.getProperty(java.lang.String), 
Integer.getInteger(java.lang.String), 
Color(int)
public static Color getColor(String nm,
                             int v)
 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.
nm - the name of the color propertyv - the default color value, as an integer
Color converted from the system
		property or the Color converted from
		the specified integer.System.getProperty(java.lang.String), 
Integer.getInteger(java.lang.String), 
Color(int)
public static int HSBtoRGB(float hue,
                           float saturation,
                           float brightness)
 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 getRGBColor constructor that takes a single integer argument.
hue - the hue component of the colorsaturation - the saturation of the colorbrightness - the brightness of the color
getRGB(), 
Color(int), 
ColorModel.getRGBdefault()
public static float[] RGBtoHSB(int r,
                               int g,
                               int b,
                               float[] hsbvals)
 If the hsbvals argument is null, then a 
 new array is allocated to return the result. Otherwise, the method 
 returns the array hsbvals, with the values put into 
 that array.
r - the red component of the colorg - the green component of the colorb - the blue component of the colorhsbvals - the array used to return the 
                     three HSB values, or null
getRGB(), 
Color(int), 
ColorModel.getRGBdefault()
public static Color getHSBColor(float h,
                                float s,
                                float b)
Color object based on the specified values 
 for the HSB color model. 
 
 The s and b components should be
 floating-point values between zero and one 
 (numbers in the range 0.0-1.0).  The h 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.
h - the hue components - the saturation of the colorb - the brightness of the color
Color object with the specified hue, 
                                 saturation, and brightness.public float[] getRGBComponents(float[] compArray)
float array containing the color and alpha
 components of the Color, as represented in the default
 sRGB color space.
 If compArray is null, an array of length
 4 is created for the return value.  Otherwise, 
 compArray must have length 4 or greater,
 and it is filled in with the components and returned.
compArray - an array that this method fills with 
			color and alpha components and returns
float array.public float[] getRGBColorComponents(float[] compArray)
float array containing only the color
 components of the Color, in the default sRGB color
 space.  If compArray is null, an array of
 length 3 is created for the return value.  Otherwise,
 compArray must have length 3 or greater, and it is
 filled in with the components and returned.
compArray - an array that this method fills with color 
		components and returns
float array.public float[] getComponents(float[] compArray)
float array containing the color and alpha
 components of the Color, in the
 ColorSpace of the Color.
 If compArray is null, an array with
 length equal to the number of components in the associated
 ColorSpace plus one is created for
 the return value.  Otherwise, compArray must have at
 least this length and it is filled in with the components and
 returned.
compArray - an array that this method fills with the color and
		alpha components of this Color in its
		ColorSpace and returns
float 
 		array.public float[] getColorComponents(float[] compArray)
float array containing only the color
 components of the Color, in the
 ColorSpace of the Color.
 If compArray is null, an array with
 length equal to the number of components in the associated
 ColorSpace is created for
 the return value.  Otherwise, compArray must have at
 least this length and it is filled in with the components and
 returned.
compArray - an array that this method fills with the color
		components of this Color in its
		ColorSpace and returns
float array.public ColorSpace getColorSpace()
ColorSpace of this Color.
Color object's ColorSpace.public int getTransparency()
Color.
getTransparency in interface TransparencyColor object's transparency mode.Transparency| 
 | JSR 217 (Maintenance Release) | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
ing HTML relocated from here.-->