All Packages  Class Hierarchy  This Package  Previous  Next  Index
Class java.awt.Color 
java.lang.Object
|
   +----java.awt.Color
- public class Color - extends Object - implements Serializable 
This class encapsulates colors using the RGB format. In RGB format, the red, blue, and green components of a color are each represented by an integer in the range 0-255. The value 0 indicates no contribution from this primary color. The value 255 indicates the maximum intensity of this color component.Although the Color class is based on the three-component RGB model, the class provides a set of convenience methods for converting between RGB and HSB colors. For a definition of the RGB and HSB color models, see Foley, van Dam, Feiner, and Hughes, Computer Graphics: Principles and Practice. 
 
 
 black black
- The color black. 
 blue blue
- The color blue. 
 cyan cyan
- The color cyan. 
 darkGray darkGray
- The color dark gray. 
 gray gray
- The color gray. 
 green green
- The color green. 
 lightGray lightGray
- The color light gray. 
 magenta magenta
- The color magenta. 
 orange orange
- The color orange. 
 pink pink
- The color pink. 
 red red
- The color red. 
 white white
- The color white. 
 yellow yellow
- The color yellow. 
 
 
 Color(float, float, float) Color(float, float, float)
- Creates a color with the specified red, green, and blue values, where each of the values is in the range 0.0-1.0. 
 Color(int) Color(int)
- Creates a color with the specified RGB value, where the red component is in bits 16-23 of the argument, the green component is in bits 8-15 of the argument, and the blue component is in bits 0-7. 
 Color(int, int, int) Color(int, int, int)
- Creates a color with the specified red, green, and blue components. 
 
 
 brighter() brighter()
- Creates a brighter version of this color. 
 darker() darker()
- Creates a darker version of this color. 
 decode(String) decode(String)
- Converts a string to an integer and returns the specified color. 
 equals(Object) equals(Object)
- Determines whether another object is equal to this color. 
 getBlue() getBlue()
- Gets the blue component of this color. 
 getColor(String) getColor(String)
- Finds a color in the system properties. 
 getColor(String, Color) getColor(String, Color)
- Finds a color in the system properties. 
 getColor(String, int) getColor(String, int)
- Finds a color in the system properties. 
 getGreen() getGreen()
- Gets the green component of this color. 
 getHSBColor(float, float, float) getHSBColor(float, float, float)
- Creates a Colorobject based on values supplied for the HSB color model.
 getRed() getRed()
- Gets the red component of this color. 
 getRGB() getRGB()
- Gets the RGB value representing the color in the default RGB ColorModel. 
 hashCode() hashCode()
- Computes the hash code for this color. 
 HSBtoRGB(float, float, float) HSBtoRGB(float, float, float)
- Converts the components of a color, as specified by the HSB model, to an equivalent set of values for the RGB model. 
 RGBtoHSB(int, int, int, float[]) RGBtoHSB(int, int, int, float[])
- Converts the components of a color, as specified by the RGB model, to an equivalent set of values for hue, saturation, and brightness, the three components of the HSB model. 
 toString() toString()
- Creates a string that represents this color and indicates the values of its RGB components. 
 
 
 white
 white 
public static final Color white
- The color white.
 lightGray
 lightGray 
public static final Color lightGray
- The color light gray.
 gray
 gray 
public static final Color gray
- The color gray.
 darkGray
 darkGray 
public static final Color darkGray
- The color dark gray.
 black
 black 
public static final Color black
- The color black.
 red
 red 
public static final Color red
- The color red.
 pink
 pink 
public static final Color pink
- The color pink.
 orange
 orange 
public static final Color orange
- The color orange.
 yellow
 yellow 
public static final Color yellow
- The color yellow.
 green
 green 
public static final Color green
- The color green.
 magenta
 magenta 
public static final Color magenta
- The color magenta.
 cyan
 cyan 
public static final Color cyan
- The color cyan.
 blue
 blue 
public static final Color blue
- The color blue.
 
 
 Color
 Color 
public Color(int r,
              int g,
              int b)
- Creates a color with the specified red, green, and blue components. The three arguments must each be 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.  
- Parameters: 
- r - the red component. - g - the green component. - b - the blue component. 
- See Also: 
- getRed., getGreen., getBlue., getRGB. 
 
 Color
 Color 
public Color(int rgb)
- Creates a color with the specified RGB value, where the red component is in bits 16-23 of the argument, the green component is in bits 8-15 of the argument, and the blue component is in bits 0-7. The value zero indicates no contribution from the primary color component. The actual color used in rendering depends on finding the best match given the color space available for a given output device.  
- Parameters: 
- rgb - an integer giving the red, green, and blue components. 
- See Also: 
- getRGBdefault, getRed., getGreen., getBlue., getRGB. 
 
 Color
 Color 
public Color(float r,
              float g,
              float b)
- Creates a color with the specified red, green, and blue values, where each of the values is in the range 0.0-1.0. The value 0.0 indicates no contribution from the primary color component. The value 1.0 indicates the maximum intensity of the primary color component. The actual color used in rendering depends 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
 getRed 
public int getRed()
- Gets the red component of this color. The result is an integer in the range 0 to 255. - Returns: 
- the red component of this color. 
- See Also: 
- getRGB 
 
 getGreen
 getGreen 
public int getGreen()
- Gets the green component of this color. The result is an integer in the range 0 to 255. - Returns: 
- the green component of this color. 
- See Also: 
- getRGB 
 
 getBlue
 getBlue 
public int getBlue()
- Gets the blue component of this color. The result is an integer in the range 0 to 255. - Returns: 
- the blue component of this color. 
- See Also: 
- getRGB 
 
 getRGB
 getRGB 
public int getRGB()
- Gets the RGB value representing the color in the default RGB ColorModel. The red, green, and blue components of the color are each scaled to be a value between 0 (abscence of the color) and 255 (complete saturation). Bits 24-31 of the returned integer are 0xff, bits 16-23 are the red value, bit 8-15 are the green value, and bits 0-7 are the blue value. - See Also: 
- getRGBdefault, getRed, getGreen, getBlue 
 
 brighter
 brighter 
public Color brighter()
- Creates a brighter version of this color. This method applies an arbitrary scale factor to each of the three RGB components of the color to create a brighter version of the same color. Although brighteranddarkerare inverse operations, the results of a series of invocations of these two methods may be inconsistent because of rounding errors.
 
- Returns: 
- a new Colorobject, a brighter version of this color.
- See Also: 
- darker 
 
 darker
 darker 
public Color darker()
- Creates a darker version of this color. This method applies an arbitrary scale factor to each of the three RGB components of the color to create a darker version of the same color. Although brighteranddarkerare inverse operations, the results of a series of invocations of these two methods may be inconsistent because of rounding errors.
 
- Returns: 
- a new Colorobject, a darker version of this color.
- See Also: 
- brighter 
 
 hashCode
 hashCode 
public int hashCode()
- Computes the hash code for this color. - Returns: 
- a hash code value for this object. 
- Overrides: 
- hashCode in class Object 
 
 equals
 equals 
public boolean equals(Object obj)
- Determines whether another object is equal to this color. The result is trueif and only if the argument is notnulland is aColorobject that has the same red, green, and blue values as this object.
 
- Parameters: 
- obj - the object to compare with. 
- Returns: 
- trueif the objects are the same;- falseotherwise.
- Overrides: 
- equals in class Object 
 
 toString
 toString 
public String toString()
- Creates a string that represents this color and indicates the values of its RGB components. - Returns: 
- a representation of this color as a Stringobject.
- Overrides: 
- toString in class Object 
 
 decode
 decode 
public static Color decode(String nm) throws NumberFormatException
- Converts a string to an integer and returns the specified color. This method handles string formats that are used to represent octal and hexidecimal numbers. - Parameters: 
- nm - a string that represents a color as a 24-bit integer. 
- Returns: 
- the new color 
- Throws: NumberFormatException 
- if the specified string cannot be interpreted as a decimal, octal, or hexidecimal integer. 
- See Also: 
- decode 
 
 getColor
 getColor 
public static Color getColor(String nm)
- Finds a color in the system properties. 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.  If the specified property is not found, or could not be parsed as an integer, then nullis returned.
 
- Parameters: 
- nm - the name of the color property 
- Returns: 
- the color value of the property. 
- See Also: 
- getProperty, getInteger, Color 
 
 getColor
 getColor 
public static Color getColor(String nm,
Color v)
- 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.  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 - v - the default color value. 
- Returns: 
- the color value of the property. 
- See Also: 
- getProperty, getInteger, Color 
 
 getColor
 getColor 
public static Color getColor(String nm,
                              int v)
- 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.  If the specified property is not found, or could not be parsed as an integer, then the integer value vis used instead, and is converted to a color.
 
- Parameters: 
- nm - the name of the color property. - v - the default color value, as an integer. 
- Returns: 
- the color value of the property. 
- See Also: 
- getProperty, getInteger, Color 
 
 HSBtoRGB
 HSBtoRGB 
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 RGB model. The integer that is returned by HSBtoRGBencodes the value of a color in bits 0&endash;23 of an integer value, the same format used by the methodgetRGB. This integer can be supplied as an argument to theColorconstructor that takes a single integer argument.
 
- Parameters: 
- hue - the hue component of the color. - saturation - the saturation of the color. - brightness - the brightness of the color. 
- Returns: 
- the RGB value of the color with the indicated hue, saturation, and brightness. 
- See Also: 
- getRGB, Color 
 
 RGBtoHSB
 RGBtoHSB 
public static float[] RGBtoHSB(int r,
                                int g,
                                int b,
                                float hsbvals[])
- Converts the components of a color, as specified by the RGB model, to an equivalent set of values for hue, saturation, and brightness, the three components of the HSB model. If the hsbvalsargument isnull, then a new array is allocated to return the result. Otherwise, the method returns the arrayhsbvals, with the values put into that array.
 
- 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 three HSB values, or null.
- Returns: 
- an array of three elements containing the hue, saturation, and brightness (in that order), of the color with the indicated red, green, and blue components. 
- See Also: 
- getRGB, Color 
 
 getHSBColor
 getHSBColor 
public static Color getHSBColor(float h,
                                 float s,
                                 float b)
- Creates a Colorobject based on values supplied for the HSB color model.Each of the three components should be a floating-point value between zero and one (a number in the range 0.0≤h,s,b≤1.0). 
 
- Parameters: 
- h - the hue component. - s - the saturation of the color. - b - the brightness of the color. 
- Returns: 
- a Colorobject with the specified hue, saturation, and brightness.
 
All Packages  Class Hierarchy  This Package  Previous  Next  Index
Submit a bug or feature - Version 1.1.8 of Java Platform API Specification
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1995-1999 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.