Class CompositeImageDescriptor
- Direct Known Subclasses:
DecorationOverlayIcon
,DiffImageDescriptor
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:
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
AnImageDataProvider
that caches the most recently returnedImageData
object. -
Field Summary
Fields inherited from class org.eclipse.jface.resource.ImageDescriptor
DEFAULT_IMAGE_DATA
-
Constructor Summary
ModifierConstructorDescriptionprotected
Constructs an uninitialized composite image. -
Method Summary
Modifier and TypeMethodDescriptionprotected int
autoScaleDown
(int pixels) Converts a value in high-DPI pixels to the corresponding value in SWT points.protected int
autoScaleUp
(int points) Converts a value in SWT points to the corresponding value in high-DPI pixels.createCachedImageDataProvider
(ImageDescriptor imageDescriptor) Creates a newCompositeImageDescriptor.CachedImageDataProvider
that is backed by the given image descriptor.Creates a newCompositeImageDescriptor.CachedImageDataProvider
that is backed by the given image.protected abstract void
drawCompositeImage
(int width, int height) Draw the composite images.protected final void
Deprecated.protected final void
drawImage
(ImageDataProvider srcProvider, int ox, int oy) Draws the given source image data into this composite image at the given position.Deprecated.UsegetImageData(int)
instead.getImageData
(int zoom) Creates and returns a new SWTImageData
object for this image descriptor.protected abstract Point
getSize()
Return the size of this composite image.protected int
Return the transparent pixel for the receiver.protected int
Returns the current zoom level.protected void
setImageData
(ImageData imageData) Deprecated.This method doesn't make sense and should never have been made API.protected boolean
supportsZoomLevel
(int zoom) Returns whether the given zoom level is supported by this CompositeImageDescriptor.Methods inherited from class org.eclipse.jface.resource.ImageDescriptor
createFromFile, createFromImage, createFromImage, createFromImageData, createFromImageDataProvider, createFromURL, createFromURLSupplier, createImage, createImage, createImage, createImage, createResource, createWithFlags, destroyResource, getMissingImageDescriptor, imageDescriptorFromURI
-
Constructor Details
-
CompositeImageDescriptor
protected CompositeImageDescriptor()Constructs an uninitialized composite image.
-
-
Method Details
-
drawCompositeImage
protected abstract void drawCompositeImage(int width, int height) Draw the composite images.Subclasses must implement this framework method to paint images within the given bounds using one or more calls to the
drawImage(ImageDataProvider, int, int)
framework method.Implementers that need to perform computations based on the size of another image are advised to use one of the
createCachedImageDataProvider(org.eclipse.swt.graphics.Image)
methods to create aCompositeImageDescriptor.CachedImageDataProvider
that can serve asImageDataProvider
. TheCompositeImageDescriptor.CachedImageDataProvider
offers other interesting methods likegetWidth()
orcomputeInPoints(...)
that can be useful to compute values in points, based on the resolution-dependentImageData
that is applicable for the current drawing operation.- Parameters:
width
- the widthheight
- the height- See Also:
-
drawImage
Deprecated.UsedrawImage(ImageDataProvider, int, int)
instead. Replace the code that created the ImageData by calls tocreateCachedImageDataProvider(Image)
orcreateCachedImageDataProvider(ImageDescriptor)
and then pass on that provider instead of ImageData objects. Replace references toImageData.width
/height by calls toCompositeImageDescriptor.CachedImageDataProvider.getWidth()
/getHeight().Draws the given source image data into this composite image at the given position.Call this internal framework method to superimpose another image atop this composite image.
- Parameters:
src
- the source image dataox
- the x positionoy
- the y position
-
drawImage
Draws the given source image data into this composite image at the given position.Subclasses call this framework method to superimpose another image atop this composite image. This method must only be called within the dynamic scope of a call to
drawCompositeImage(int, int)
.Hint: Use
createCachedImageDataProvider(Image)
orcreateCachedImageDataProvider(ImageDescriptor)
to create anImageDataProvider
. To calculate the width and height of the image that is about to be drawn, you can useCompositeImageDescriptor.CachedImageDataProvider.getWidth()
/getHeight(). These methods already return values in SWT points, so that your code doesn't have to deal with device-dependent pixel coordinates.- Parameters:
srcProvider
- the source image data providerox
- the x positionoy
- the y position- Since:
- 3.13
-
getImageData
Deprecated.UsegetImageData(int)
instead.Description copied from class:ImageDescriptor
Creates and returns a new SWTImageData
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 classImageDescriptor
- Returns:
- a new image data or
null
-
getImageData
Description copied from class:ImageDescriptor
Creates and returns a new SWTImageData
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 classImageDescriptor
- 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
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.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
-
createCachedImageDataProvider
protected CompositeImageDescriptor.CachedImageDataProvider createCachedImageDataProvider(Image image) Creates a newCompositeImageDescriptor.CachedImageDataProvider
that is backed by the given image. This method and the resulting cached image data provider are only intended to be used within the dynamic scope of a call todrawCompositeImage(int, int)
.- Parameters:
image
- the image, must not be null- Returns:
- the new cached image provider
- Since:
- 3.13
-
createCachedImageDataProvider
protected CompositeImageDescriptor.CachedImageDataProvider createCachedImageDataProvider(ImageDescriptor imageDescriptor) Creates a newCompositeImageDescriptor.CachedImageDataProvider
that is backed by the given image descriptor. This method and the resulting cached image data provider are only intended to be used within the dynamic scope of a call todrawCompositeImage(int, int)
.The provider returns
ImageDescriptor.getMissingImageDescriptor()
if the image descriptor unexpectedly provides a null image data at zoom == 100.- Parameters:
imageDescriptor
- the image descriptor, must not be null- Returns:
- the new cached image provider
- Since:
- 3.13
-
drawImage(ImageDataProvider, int, int)
instead.