Eclipse Rich Ajax Platform
Release 1.3

org.eclipse.swt.graphics
Class Color

java.lang.Object
  extended byorg.eclipse.swt.graphics.Resource
      extended byorg.eclipse.swt.graphics.Color

public class Color
extends Resource

Instances of this class manage resources that implement SWT's RGB color model.

It is recommended to create a color by using one of the getColor methods in class Graphics and either specify the individual color components as integers in the range 0 to 255 or provide an instance of an RGB.

Since:
1.0
See Also:
RGB, Device.getSystemColor(int), Graphics.getColor(int, int, int), Graphics.getColor(RGB)

Constructor Summary
Color(Device device, int red, int green, int blue)
          Constructs a new instance of this class given a device and the desired red, green and blue values expressed as ints in the range 0 to 255 (where 0 is black and 255 is full brightness).
Color(Device device, RGB rgb)
          Constructs a new instance of this class given a device and an RGB describing the desired red, green and blue values.
 
Method Summary
 boolean equals(java.lang.Object object)
          Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.
 int getBlue()
          Returns the amount of blue in the color, from 0 to 255.
 int getGreen()
          Returns the amount of green in the color, from 0 to 255.
 int getRed()
          Returns the amount of red in the color, from 0 to 255.
 RGB getRGB()
          Returns an RGB representing the receiver.
 int hashCode()
          Returns an integer hash code for the receiver.
 java.lang.String toString()
          Returns a string containing a concise, human-readable description of the receiver.
 
Methods inherited from class org.eclipse.swt.graphics.Resource
dispose, getDevice, isDisposed
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Color

public Color(Device device,
             RGB rgb)
Constructs a new instance of this class given a device and an RGB describing the desired red, green and blue values. On limited color devices, the color instance created by this call may not have the same RGB values as the ones specified by the argument. The RGB values on the returned instance will be the color values of the operating system color.

You must dispose the color when it is no longer required.

Note, this constructor is provided for convenience when single-sourcing code with SWT. For RWT, the recommended way to create colors is to use one of the getColor methods in class Graphics.

Parameters:
device - the device on which to allocate the color
rgb - the RGB values of the desired color
Throws:
java.lang.IllegalArgumentException -
Since:
1.3
See Also:
Resource.dispose(), Graphics.getColor(int, int, int), Graphics.getColor(RGB)

Color

public Color(Device device,
             int red,
             int green,
             int blue)
Constructs a new instance of this class given a device and the desired red, green and blue values expressed as ints in the range 0 to 255 (where 0 is black and 255 is full brightness). On limited color devices, the color instance created by this call may not have the same RGB values as the ones specified by the arguments. The RGB values on the returned instance will be the color values of the operating system color.

You must dispose the color when it is no longer required.

Note, this constructor is provided for convenience when single-sourcing code with SWT. For RWT, the recommended way to create colors is to use one of the getColor methods in class Graphics.

Parameters:
device - the device on which to allocate the color
red - the amount of red in the color
green - the amount of green in the color
blue - the amount of blue in the color
Throws:
java.lang.IllegalArgumentException -
Since:
1.3
See Also:
Resource.dispose(), Graphics.getColor(int, int, int), Graphics.getColor(RGB)
Method Detail

getBlue

public int getBlue()
Returns the amount of blue in the color, from 0 to 255.

Returns:
the blue component of the color
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

getGreen

public int getGreen()
Returns the amount of green in the color, from 0 to 255.

Returns:
the green component of the color
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

getRed

public int getRed()
Returns the amount of red in the color, from 0 to 255.

Returns:
the red component of the color
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

getRGB

public RGB getRGB()
Returns an RGB representing the receiver.

Returns:
the RGB for the color
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

equals

public boolean equals(java.lang.Object object)
Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.

Parameters:
object - the object to compare with this object
Returns:
true if the object is the same as this object and false otherwise
See Also:
hashCode()

hashCode

public int hashCode()
Returns an integer hash code for the receiver. Any two objects that return true when passed to equals must return the same value for this method.

Returns:
the receiver's hash
See Also:
equals(java.lang.Object)

toString

public java.lang.String toString()
Returns a string containing a concise, human-readable description of the receiver.

Returns:
a string representation of the receiver

Eclipse Rich Ajax Platform
Release 1.3

Copyright (c) Innoopract Informationssysteme GmbH and others 2002, 2011. All rights reserved.