Class 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 Detail

      • ColorDescriptor

        public ColorDescriptor()
    • 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

        @Deprecated
        public void destroyColor​(Color toDestroy)
        Deprecated.
        Colors do not need disposal anymore
        Undoes whatever was done by createColor.
        Parameters:
        toDestroy - a Color that was previously allocated by an equal ColorDescriptor
        Since:
        3.1
      • destroyResource

        public final void destroyResource​(Object previouslyCreatedObject)
        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 class DeviceResourceDescriptor
        Parameters:
        previouslyCreatedObject - an object that was returned by an equal descriptor in a previous call to createResource(...).