Class Color
RGB or RGBA.
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.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionintthe handle to the OS color resource (Warning: This field is platform dependent) -
Constructor Summary
ConstructorsConstructorDescriptionConstructs 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).Constructs a new instance of this class given a device and the desired red, green, blue invalid input: '&' alpha values expressed as ints in the range 0 to 255 (where 0 is black and 255 is full brightness).Constructs a new instance of this class given a device and anRGBdescribing the desired red, green and blue values.Constructs a new instance of this class given a device and anRGBAdescribing the desired red, green, blue invalid input: '&' alpha values.Constructs a new instance of this class given a device, anRGBdescribing the desired red, green and blue values, alpha specifying the level of transparency. -
Method Summary
Modifier and TypeMethodDescriptionbooleanCompares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.intgetAlpha()Returns the amount of alpha in the color, from 0 (transparent) to 255 (opaque).intgetBlue()Returns the amount of blue in the color, from 0 to 255.intgetGreen()Returns the amount of green in the color, from 0 to 255.intgetRed()Returns the amount of red in the color, from 0 to 255.getRGB()Returns anRGBrepresenting the receiver.getRGBA()Returns anRGBArepresenting the receiver.inthashCode()Returns an integer hash code for the receiver.booleanReturnstrueif the color has been disposed, andfalseotherwise.toString()Returns a string containing a concise, human-readable description of the receiver.static ColorInvokes platform specific functionality to allocate a new color.static ColorInvokes platform specific functionality to allocate a new color.
-
Field Details
-
handle
public int handlethe handle to the OS color resource (Warning: This field is platform dependent)IMPORTANT: This field is not part of the SWT public API. 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 accessed from application code.
-
-
Constructor Details
-
Color
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.
- Parameters:
device- the device on which to allocate the colorred- the amount of red in the colorgreen- the amount of green in the colorblue- the amount of blue in the color- Throws:
IllegalArgumentException-- ERROR_NULL_ARGUMENT - if device is null and there is no current device
- ERROR_INVALID_ARGUMENT - if the red, green or blue argument is not between 0 and 255
- See Also:
-
Color
Constructs a new instance of this class given a device and the desired red, green, blue invalid input: '&' alpha 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.
- Parameters:
device- the device on which to allocate the colorred- the amount of red in the colorgreen- the amount of green in the colorblue- the amount of blue in the coloralpha- the amount of alpha in the color. Currently, SWT only honors extreme values for alpha i.e. 0 (transparent) or 255 (opaque).- Throws:
IllegalArgumentException-- ERROR_NULL_ARGUMENT - if device is null and there is no current device
- ERROR_INVALID_ARGUMENT - if the red, green, blue or alpha argument is not between 0 and 255
- Since:
- 3.104
- See Also:
-
Color
Constructs a new instance of this class given a device and anRGBdescribing 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.
- Parameters:
device- the device on which to allocate the colorrgb- the RGB values of the desired color- Throws:
IllegalArgumentException-- ERROR_NULL_ARGUMENT - if device is null and there is no current device
- ERROR_NULL_ARGUMENT - if the rgb argument is null
- ERROR_INVALID_ARGUMENT - if the red, green or blue components of the argument are not between 0 and 255
- See Also:
-
Color
Constructs a new instance of this class given a device and anRGBAdescribing the desired red, green, blue invalid input: '&' alpha values. On limited color devices, the color instance created by this call may not have the same RGBA values as the ones specified by the argument. The RGBA values on the returned instance will be the color values of the operating system color + alpha.You must dispose the color when it is no longer required.
- Parameters:
device- the device on which to allocate the colorrgba- the RGBA values of the desired color. Currently, SWT only honors extreme values for alpha i.e. 0 (transparent) or 255 (opaque).- Throws:
IllegalArgumentException-- ERROR_NULL_ARGUMENT - if device is null and there is no current device
- ERROR_NULL_ARGUMENT - if the rgba argument is null
- ERROR_INVALID_ARGUMENT - if the red, green, blue or alpha components of the argument are not between 0 and 255
- Since:
- 3.104
- See Also:
-
Color
Constructs a new instance of this class given a device, anRGBdescribing the desired red, green and blue values, alpha specifying the level of transparency. 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.
- Parameters:
device- the device on which to allocate the colorrgb- the RGB values of the desired coloralpha- the alpha value of the desired color. Currently, SWT only honors extreme values for alpha i.e. 0 (transparent) or 255 (opaque).- Throws:
IllegalArgumentException-- ERROR_NULL_ARGUMENT - if device is null and there is no current device
- ERROR_NULL_ARGUMENT - if the rgb argument is null
- ERROR_INVALID_ARGUMENT - if the red, green, blue or alpha components of the argument are not between 0 and 255
- Since:
- 3.104
- See Also:
-
-
Method Details
-
equals
Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison. -
getAlpha
public int getAlpha()Returns the amount of alpha in the color, from 0 (transparent) to 255 (opaque).- Returns:
- the alpha component of the color
- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.104
-
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
Returns anRGBrepresenting the receiver.- Returns:
- the RGB for the color
- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
getRGBA
Returns anRGBArepresenting the receiver.- Returns:
- the RGBA for the color
- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.104
-
hashCode
-
isDisposed
public boolean isDisposed()Returnstrueif the color has been disposed, andfalseotherwise.This method gets the dispose state for the color. When a color has been disposed, it is an error to invoke any other method (except
Resource.dispose()) using the color.- Specified by:
isDisposedin classResource- Returns:
truewhen the color is disposed andfalseotherwise
-
toString
-
win32_new
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.- Parameters:
device- the device on which to allocate the colorhandle- the handle for the color- Returns:
- a new color object containing the specified device and handle
-
win32_new
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.- Parameters:
device- the device on which to allocate the colorhandle- the handle for the coloralpha- the int for the alpha content in the color- Returns:
- a new color object containing the specified device and handle
-