Package org.eclipse.jface.resource
Class ColorDescriptor
java.lang.Object
org.eclipse.jface.resource.DeviceResourceDescriptor<Color>
org.eclipse.jface.resource.ColorDescriptor
Lightweight descriptor for an SWT color. Each ColorDescriptor will create a particular SWT
Color on demand. This object will be compared so hashCode(...) and equals(...) must
return meaningful values.
- Since:
- 3.1
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract Color
createColor
(Device device) Returns the Color described by this descriptor.static ColorDescriptor
createFrom
(Color toCreate) Creates a ColorDescriptor from an existing color.static ColorDescriptor
createFrom
(Color toCreate, Device originalDevice) Deprecated.static ColorDescriptor
createFrom
(RGB toCreate) Returns a color descriptor for the given RGB valuesfinal Object
createResource
(Device device) Creates the resource described by this descriptorvoid
destroyColor
(Color toDestroy) Deprecated.Colors do not need disposal anymorefinal void
destroyResource
(Object previouslyCreatedObject) Undoes everything that was done by a previous call to create(...), given the object that was returned by create(...).
-
Constructor Details
-
ColorDescriptor
public ColorDescriptor()
-
-
Method Details
-
createFrom
Deprecated.Creates a ColorDescriptor from an existing Color, given the Device associated with the original Color. This is the usual way to convert a Color into a ColorDescriptor. Note that the returned ColorDescriptor depends on the original Color, and disposing the Color will invalidate the ColorDescriptor.- Parameters:
toCreate
- Color to convert into a ColorDescriptor.originalDevice
- this must be the same Device that was passed into the original Color's constructor.- Returns:
- a newly created ColorDescriptor that describes the given Color.
- Since:
- 3.1
-
createFrom
Creates a ColorDescriptor from an existing color. The returned ColorDescriptor depends on the original Color. Disposing the original colour while the color descriptor is still in use may cause SWT to throw a graphic disposed exception.- Parameters:
toCreate
- Color to generate a ColorDescriptor from- Returns:
- a newly created ColorDescriptor
- Since:
- 3.1
-
createFrom
Returns a color descriptor for the given RGB values- Parameters:
toCreate
- RGB values to create- Returns:
- a new ColorDescriptor
- Since:
- 3.1
-
createColor
Returns the Color described by this descriptor.- Parameters:
device
- SWT device on which to allocate the Color- Returns:
- a newly allocated SWT Color object (never null)
- Throws:
DeviceResourceException
- if unable to allocate the Color
-
destroyColor
Deprecated.Colors do not need disposal anymoreUndoes whatever was done by createColor.- Parameters:
toDestroy
- a Color that was previously allocated by an equal ColorDescriptor- Since:
- 3.1
-
createResource
Description copied from class:DeviceResourceDescriptor
Creates the resource described by this descriptor- Specified by:
createResource
in classDeviceResourceDescriptor<Color>
- Parameters:
device
- the Device on which to allocate the resource- Returns:
- the newly allocated resource (not null)
- Throws:
DeviceResourceException
- if unable to allocate the resource
-
destroyResource
Description copied from class:DeviceResourceDescriptor
Undoes everything that was done by a previous call to create(...), given the object that was returned by create(...).- Specified by:
destroyResource
in classDeviceResourceDescriptor<Color>
- Parameters:
previouslyCreatedObject
- an object that was returned by an equal descriptor in a previous call to createResource(...).
-
createFrom(Color)