Package org.eclipse.jface.resource
Class ColorDescriptor
- java.lang.Object
-
- org.eclipse.jface.resource.DeviceResourceDescriptor
-
- org.eclipse.jface.resource.ColorDescriptor
-
public abstract class ColorDescriptor extends DeviceResourceDescriptor
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
Constructors Constructor Description ColorDescriptor()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract ColorcreateColor(Device device)Returns the Color described by this descriptor.static ColorDescriptorcreateFrom(Color toCreate)Creates a ColorDescriptor from an existing color.static ColorDescriptorcreateFrom(Color toCreate, Device originalDevice)Deprecated.static ColorDescriptorcreateFrom(RGB toCreate)Returns a color descriptor for the given RGB valuesObjectcreateResource(Device device)Creates the resource described by this descriptorabstract voiddestroyColor(Color toDestroy)Undoes whatever was done by createColor.voiddestroyResource(Object previouslyCreatedObject)Undoes everything that was done by a previous call to create(...), given the object that was returned by create(...).
-
-
-
Method Detail
-
createFrom
@Deprecated public static ColorDescriptor createFrom(Color toCreate, Device originalDevice)
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
public static ColorDescriptor createFrom(Color toCreate)
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
public static ColorDescriptor createFrom(RGB toCreate)
Returns a color descriptor for the given RGB values- Parameters:
toCreate- RGB values to create- Returns:
- a new ColorDescriptor
- Since:
- 3.1
-
createColor
public abstract Color createColor(Device device) throws DeviceResourceException
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
public abstract void destroyColor(Color toDestroy)
Undoes whatever was done by createColor.- Parameters:
toDestroy- a Color that was previously allocated by an equal ColorDescriptor- Since:
- 3.1
-
createResource
public final Object createResource(Device device) throws DeviceResourceException
Description copied from class:DeviceResourceDescriptorCreates the resource described by this descriptor- Specified by:
createResourcein classDeviceResourceDescriptor- 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
public final void destroyResource(Object previouslyCreatedObject)
Description copied from class:DeviceResourceDescriptorUndoes everything that was done by a previous call to create(...), given the object that was returned by create(...).- Specified by:
destroyResourcein classDeviceResourceDescriptor- Parameters:
previouslyCreatedObject- an object that was returned by an equal descriptor in a previous call to createResource(...).
-
-