Class CompositeImageDescriptor

  • Direct Known Subclasses:
    DecorationOverlayIcon

    public abstract class CompositeImageDescriptor
    extends ImageDescriptor
    Abstract base class for image descriptors that synthesize an image from other images in order to simulate the effect of custom drawing. For example, this could be used to superimpose a red bar dexter symbol across an image to indicate that something was disallowed.

    Subclasses must implement getSize() and drawImage(ImageDataProvider, int, int). Little or no work happens until the image descriptor's image is actually requested by a call to createImage (or to getImageData directly).

    See Also:
    DecorationOverlayIcon
    • Constructor Detail

      • CompositeImageDescriptor

        protected CompositeImageDescriptor()
        Constructs an uninitialized composite image.
    • Method Detail

      • getImageData

        @Deprecated
        public ImageData getImageData()
        Deprecated.
        Use getImageData(int) instead.
        Description copied from class: ImageDescriptor
        Creates and returns a new SWT ImageData object for this image descriptor. Note that each call returns a new SWT image data object.

        This framework method is declared public so that it is possible to request an image descriptor's image data without creating an SWT image object.

        Returns null if the image data could not be created.

        This method was abstract until 3.13. Clients should stop re-implementing this method and should re-implement ImageDescriptor.getImageData(int) instead.

        Overrides:
        getImageData in class ImageDescriptor
        Returns:
        a new image data or null
      • getImageData

        public ImageData getImageData​(int zoom)
        Description copied from class: ImageDescriptor
        Creates and returns a new SWT ImageData object for this image descriptor. Note that each call returns a new SWT image data object.

        This framework method is declared public so that it is possible to request an image descriptor's image data without creating an SWT image object.

        Returns null if the image data could not be created or if no image data is available for the given zoom level.

        Since 3.13, subclasses should re-implement this method and should not implement ImageDescriptor.getImageData() any more.

        Warning: This method does not implement ImageDataProvider.getImageData(int), since legal implementations of that method must return a non-null value for zoom == 100.

        Overrides:
        getImageData in class ImageDescriptor
        Parameters:
        zoom - The zoom level in % of the standard resolution (which is 1 physical monitor pixel / 1 SWT logical point). Typically 100, 150, or 200.
        Returns:
        a new image data or null
      • getTransparentPixel

        protected int getTransparentPixel()
        Return the transparent pixel for the receiver. NOTE This value is not currently in use in the default implementation.
        Returns:
        int
        Since:
        3.3
      • getSize

        protected abstract Point getSize()
        Return the size of this composite image.

        Subclasses must implement this framework method.

        Returns:
        the x and y size of the image expressed as a point object
      • setImageData

        @Deprecated
        protected void setImageData​(ImageData imageData)
        Deprecated.
        This method doesn't make sense and should never have been made API.
        Do not call this method! Behavior is unspecified.
        Parameters:
        imageData - unspecified
        Since:
        3.3
      • supportsZoomLevel

        protected boolean supportsZoomLevel​(int zoom)
        Returns whether the given zoom level is supported by this CompositeImageDescriptor.
        Parameters:
        zoom - the zoom level
        Returns:
        whether the given zoom level is supported. Must return true for zoom == 100.
        Since:
        3.13
      • getZoomLevel

        protected int getZoomLevel()
        Returns the current zoom level.

        Important: This method must only be called within the dynamic scope of a call to drawCompositeImage(int, int).

        Returns:
        The zoom level in % of the standard resolution (which is 1 physical monitor pixel == 1 SWT logical point). Typically 100, 150, or 200.
        Since:
        3.13
      • autoScaleDown

        protected int autoScaleDown​(int pixels)
        Converts a value in high-DPI pixels to the corresponding value in SWT points.

        This method must only be called within the dynamic scope of a call to drawCompositeImage(int, int).

        Parameters:
        pixels - a value in high-DPI pixels
        Returns:
        corresponding value in SWT points
        Since:
        3.13
      • autoScaleUp

        protected int autoScaleUp​(int points)
        Converts a value in SWT points to the corresponding value in high-DPI pixels.

        This method must only be called within the dynamic scope of a call to drawCompositeImage(int, int).

        Parameters:
        points - a value in SWT points
        Returns:
        corresponding value in high-DPI pixels
        Since:
        3.13