Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.eclipse.swt.graphics
Class Color  view Color download Color.java

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

public final class Color
extends java.lang.Object

Instances of this class manage the operating system resources that implement SWT's RGB color model. To create a color you can either specify the individual color components as integers in the range 0 to 255 or provide an instance of an RGB.

Application code must explicitly invoke the Color.dispose() method to release the operating system resources managed by each instance when those instances are no longer required.


Field Summary
(package private)  Device device
          The device where this color was created.
 org.eclipse.swt.internal.gtk.GdkColor handle
          the handle to the OS color resource (Warning: This field is platform dependent)
 
Constructor Summary
(package private) Color()
           
  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
 void dispose()
          Disposes of the operating system resources associated with the color.
 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.
static Color gtk_new(Device device, org.eclipse.swt.internal.gtk.GdkColor gdkColor)
          Invokes platform specific functionality to allocate a new color.
 int hashCode()
          Returns an integer hash code for the receiver.
(package private)  void init(Device device, int red, int green, int blue)
           
 boolean isDisposed()
          Returns true if the color has been disposed, and false otherwise.
 java.lang.String toString()
          Returns a string containing a concise, human-readable description of the receiver.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

handle

public org.eclipse.swt.internal.gtk.GdkColor handle
the handle to the OS color resource (Warning: This field is platform dependent)


device

Device device
The device where this color was created.

Constructor Detail

Color

Color()

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.


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.

Method Detail

dispose

public void dispose()
Disposes of the operating system resources associated with the color. Applications must dispose of all colors which they allocate.


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.


getBlue

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


getGreen

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


getRed

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


hashCode

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


getRGB

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


gtk_new

public static Color gtk_new(Device device,
                            org.eclipse.swt.internal.gtk.GdkColor gdkColor)
Invokes platform specific functionality to allocate a new color.

IMPORTANT: This method is not part of the public API for Color. It is marked public only so that it can be shared within the packages provided by SWT. It is not available on all platforms, and should never be called from application code.


init

void init(Device device,
          int red,
          int green,
          int blue)

isDisposed

public boolean isDisposed()
Returns true if the color has been disposed, and false otherwise.

This method gets the dispose state for the color. When a color has been disposed, it is an error to invoke any other method using the color.


toString

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