Java Doc for Color.java in  » 6.0-JDK-Modules » j2me » java » awt » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » j2me » java.awt 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.awt.Color

All known Subclasses:   java.awt.SystemColor,
Color
public class Color implements java.io.Serializable,Transparency(Code)
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.
version:
   1.46, 08/19/02
author:
   Sami Shaio
author:
   Arthur van Hoff
since:
   JDK1.0



Field Summary
final public static  ColorBLACK
     The color black.
final public static  ColorBLUE
     The color blue.
final public static  ColorCYAN
     The color cyan.
final public static  ColorDARK_GRAY
     The color dark gray.
final public static  ColorGRAY
     The color gray.
final public static  ColorGREEN
     The color green.
final public static  ColorLIGHT_GRAY
     The color light gray.
final public static  ColorMAGENTA
     The color magenta.
final public static  ColorORANGE
     The color orange.
final public static  ColorPINK
     The color pink.
final public static  ColorRED
     The color red.
final public static  ColorWHITE
     The color white.
final public static  ColorYELLOW
     The color yellow.
final public static  Colorblack
     The color black.
final public static  Colorblue
     The color blue.
final public static  Colorcyan
     The color cyan.
final public static  ColordarkGray
     The color dark gray.
final public static  Colorgray
     The color gray.
final public static  Colorgreen
     The color green.
final public static  ColorlightGray
     The color light gray.
final public static  Colormagenta
     The color magenta.
final public static  Colororange
     The color orange.
final public static  Colorpink
     The color pink.
final public static  Colorred
     The color red.
 intvalue
     The color value.
final public static  Colorwhite
     The color white.
final public static  Coloryellow
     The color yellow.

Constructor Summary
public  Color(int r, int g, int b)
     Creates a color with the specified red, green, and blue components.
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 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.
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.
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.
public  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).

Method Summary
public static  intHSBtoRGB(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 HSBtoRGB encodes the value of a color in bits 0&endash;23 of an integer value, the same format used by the method getRGB.

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 hsbvals argument is null, then a new array is allocated to return the result.

public  Colorbrighter()
     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.

public  Colordarker()
     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.

public static  Colordecode(String nm)
     Converts a string to an integer and returns the specified color.
public  booleanequals(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, and blue values as this object.
Parameters:
  obj - the object to compare with.

public  intgetAlpha()
     Returns the alpha component in the range 0-255.
public  intgetBlue()
     Gets the blue component of this color.
public static  ColorgetColor(String nm)
     Finds a color in the system properties.

The argument is treated as the name of a system property to be obtained.

public static  ColorgetColor(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.

public static  ColorgetColor(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.

public  float[]getColorComponents(float[] compArray)
     Returns a 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.
public  ColorSpacegetColorSpace()
     Returns the ColorSpace of this Color.
public  float[]getComponents(float[] compArray)
     Returns a 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.
public  intgetGreen()
     Gets the green component of this color.
public static  ColorgetHSBColor(float h, float s, float b)
     Creates a Color object 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).

public  intgetRGB()
     Gets the RGB value representing the color in the default RGB ColorModel.
public  float[]getRGBColorComponents(float[] compArray)
     Returns a float array containing only the color components of the Color, in the default sRGB color space.
public  float[]getRGBComponents(float[] compArray)
     Returns a 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.
public  intgetRed()
     Gets the red component of this color.
public  intgetTransparency()
     Returns the transparency mode for this Color.
public  inthashCode()
     Computes the hash code for this color.
public  StringtoString()
     Creates a string that represents this color and indicates the values of its RGB components.

Field Detail
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.



DARK_GRAY
final public static Color DARK_GRAY(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.



LIGHT_GRAY
final public static Color LIGHT_GRAY(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.



black
final public static Color black(Code)
The color black.



blue
final public static Color blue(Code)
The color blue.



cyan
final public static Color cyan(Code)
The color cyan.



darkGray
final public static Color darkGray(Code)
The color dark gray.



gray
final public static Color gray(Code)
The color gray.



green
final public static Color green(Code)
The color green.



lightGray
final public static Color lightGray(Code)
The color light gray.



magenta
final public static Color magenta(Code)
The color magenta.



orange
final public static Color orange(Code)
The color orange.



pink
final public static Color pink(Code)
The color pink.



red
final public static Color red(Code)
The color red.



value
int value(Code)
The color value.



white
final public static Color white(Code)
The color white.



yellow
final public static Color yellow(Code)
The color yellow.




Constructor Detail
Color
public Color(int r, int g, int b)(Code)
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.
Parameters:
  g - the green component.
Parameters:
  b - the blue component.
See Also:   java.awt.Color.getRed
See Also:   java.awt.Color.getGreen
See Also:   java.awt.Color.getBlue
See Also:   java.awt.Color.getRGB
since:
   JDK1.0




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 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:   java.awt.image.ColorModel.getRGBdefault
See Also:   java.awt.Color.getRed
See Also:   java.awt.Color.getGreen
See Also:   java.awt.Color.getBlue
See Also:   java.awt.Color.getRGB
since:
   JDK1.0




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



Color
public Color(float r, float g, float b)(Code)
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
Parameters:
  g - the red component
Parameters:
  b - the red component
See Also:   java.awt.Color.getRed
See Also:   java.awt.Color.getGreen
See Also:   java.awt.Color.getBlue
See Also:   java.awt.Color.getRGB
since:
   JDK1.0




Color
public Color(float r, float g, float b, float a)(Code)
Creates an sRGB color with the specified red, green, blue, and alpha values in the range (0.0 - 1.0). The actual color used in rendering depends on finding the best match given the color space available for a particular output device.
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




Method Detail
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 RGB model.

The integer that is returned by HSBtoRGB encodes the value of a color in bits 0&endash;23 of an integer value, the same format used by the method 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)
since:
   JDK1.0




RGBtoHSB
public static float[] RGBtoHSB(int r, int g, int b, float[] hsbvals)(Code)
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 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.
Parameters:
  r - the red component of the color.
Parameters:
  g - the green component of the color.
Parameters:
  b - the blue component of the color.
Parameters:
  hsbvals - the array to be used to return thethree HSB values, or null. an array of three elements containing the hue, saturation,and brightness (in that order), of the color withthe indicated red, green, and blue components.
See Also:   java.awt.Color.getRGB
See Also:   java.awt.Color.Color(int)
since:
   JDK1.0




brighter
public Color brighter()(Code)
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 brighter and darker are inverse operations, the results of a series of invocations of these two methods may be inconsistent because of rounding errors. a new Color object,a brighter version of this color.
See Also:   java.awt.Color.darker
since:
   JDK1.0




darker
public Color darker()(Code)
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 brighter and darker are inverse operations, the results of a series of invocations of these two methods may be inconsistent because of rounding errors. a new Color object,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 color. This method handles string formats that are used to represent octal and hexidecimal numbers.
Parameters:
  nm - a string that representsa color as a 24-bit integer. the new color
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, and blue values as this object.
Parameters:
  obj - the object to compare with. 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)
Gets the blue component of this color. The result is an integer in the range 0 to 255. the blue component of this color.
See Also:   java.awt.Color.getRGB
since:
   JDK1.0



getColor
public static Color getColor(String nm)(Code)
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 null is returned.
Parameters:
  nm - the name of the color property the color value of the property.
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, 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.

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 value. the color value of the property.
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.

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.
Parameters:
  nm - the name of the color property.
Parameters:
  v - the default color value, as an integer. the color value of the property.
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




getColorComponents
public float[] getColorComponents(float[] compArray)(Code)
Returns a 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.
Parameters:
  compArray - an array that this method fills with the colorcomponents of this Color in itsColorSpace and returns the color components in a float array.



getColorSpace
public ColorSpace getColorSpace()(Code)
Returns the ColorSpace of this Color. this Color object's ColorSpace.



getComponents
public float[] getComponents(float[] compArray)(Code)
Returns a 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.
Parameters:
  compArray - an array that this method fills with the color andalpha components of this Color in itsColorSpace and returns the color and alpha components in a floatarray.



getGreen
public int getGreen()(Code)
Gets the green component of this color. The result is an integer in the range 0 to 255. the green component of this color.
See Also:   java.awt.Color.getRGB
since:
   JDK1.0



getHSBColor
public static Color getHSBColor(float h, float s, float b)(Code)
Creates a Color object 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.
Parameters:
  s - the saturation of the color.
Parameters:
  b - the brightness of the color. a Color object with the specified hue,saturation, and brightness.
since:
   JDK1.0




getRGB
public int getRGB()(Code)
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:   java.awt.image.ColorModel.getRGBdefault
See Also:   Color.getRed
See Also:   Color.getGreen
See Also:   Color.getBlue
since:
   JDK1.0



getRGBColorComponents
public float[] getRGBColorComponents(float[] compArray)(Code)
Returns a 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.
Parameters:
  compArray - an array that this method fills with colorcomponents and returns the RGB components in a float array.



getRGBComponents
public float[] getRGBComponents(float[] compArray)(Code)
Returns a 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.
Parameters:
  compArray - an array that this method fills withcolor and alpha components and returns the RGBA components in a float array.



getRed
public int getRed()(Code)
Gets the red component of this color. The result is an integer in the range 0 to 255. the red component of this color.
See Also:   java.awt.Color.getRGB
since:
   JDK1.0



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:   Paint
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)
Creates a string that represents this color and indicates the values of its RGB components. a representation of this color as aString object.
since:
   JDK1.0



Methods inherited from java.lang.Object
public boolean equals(Object obj)(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.