public abstract class CompositeImageDescriptor extends ImageDescriptor
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).
DecorationOverlayIcon
Modifier and Type | Class and Description |
---|---|
protected class |
CompositeImageDescriptor.CachedImageDataProvider
An
ImageDataProvider that caches the most recently returned
ImageData object. |
DEFAULT_IMAGE_DATA
Modifier | Constructor and Description |
---|---|
protected |
CompositeImageDescriptor()
Constructs an uninitialized composite image.
|
Modifier and Type | Method and Description |
---|---|
protected 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.
|
protected CompositeImageDescriptor.CachedImageDataProvider |
createCachedImageDataProvider(Image image)
Creates a new
CompositeImageDescriptor.CachedImageDataProvider that is backed by the given
image. |
protected CompositeImageDescriptor.CachedImageDataProvider |
createCachedImageDataProvider(ImageDescriptor imageDescriptor)
Creates a new
CompositeImageDescriptor.CachedImageDataProvider that is backed by the given
image descriptor. |
protected abstract void |
drawCompositeImage(int width,
int height)
Draw the composite images.
|
protected void |
drawImage(ImageData src,
int ox,
int oy)
Deprecated.
Use
drawImage(ImageDataProvider, int, int) instead.
Replace the code that created the ImageData by calls to
createCachedImageDataProvider(Image) or
createCachedImageDataProvider(ImageDescriptor) and
then pass on that provider instead of ImageData objects.
Replace references to ImageData.width /height by calls
to CompositeImageDescriptor.CachedImageDataProvider.getWidth() /getHeight(). |
protected void |
drawImage(ImageDataProvider srcProvider,
int ox,
int oy)
Draws the given source image data into this composite image at the given
position.
|
ImageData |
getImageData()
Deprecated.
Use
getImageData(int) instead. |
ImageData |
getImageData(int zoom)
Creates and returns a new SWT
ImageData object for this
image descriptor. |
protected abstract Point |
getSize()
Return the size of this composite image.
|
protected int |
getTransparentPixel()
Return the transparent pixel for the receiver.
|
protected int |
getZoomLevel()
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.
|
createFromFile, createFromImage, createFromImage, createFromImageData, createFromImageDataProvider, createFromURL, createImage, createImage, createImage, createImage, createResource, createWithFlags, destroyResource, getMissingImageDescriptor
protected CompositeImageDescriptor()
protected abstract void drawCompositeImage(int width, int height)
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 a
CompositeImageDescriptor.CachedImageDataProvider
that can serve as
ImageDataProvider
. The CompositeImageDescriptor.CachedImageDataProvider
offers
other interesting methods like getWidth()
or
computeInPoints(...)
that can be useful to compute values in points,
based on the resolution-dependent ImageData
that is applicable
for the current drawing operation.
width
- the widthheight
- the heightdrawImage(ImageDataProvider, int, int)
,
createCachedImageDataProvider(Image)
,
createCachedImageDataProvider(ImageDescriptor)
@Deprecated protected final void drawImage(ImageData src, int ox, int oy)
drawImage(ImageDataProvider, int, int)
instead.
Replace the code that created the ImageData by calls to
createCachedImageDataProvider(Image)
or
createCachedImageDataProvider(ImageDescriptor)
and
then pass on that provider instead of ImageData objects.
Replace references to ImageData.width
/height by calls
to CompositeImageDescriptor.CachedImageDataProvider.getWidth()
/getHeight().Call this internal framework method to superimpose another image atop this composite image.
src
- the source image dataox
- the x positionoy
- the y positionprotected final void drawImage(ImageDataProvider srcProvider, int ox, int oy)
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)
or
createCachedImageDataProvider(ImageDescriptor)
to create an
ImageDataProvider
. To calculate the width and height of the image
that is about to be drawn, you can use
CompositeImageDescriptor.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.
srcProvider
- the source image data providerox
- the x positionoy
- the y position@Deprecated public ImageData getImageData()
getImageData(int)
instead.ImageDescriptor
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.
getImageData
in class ImageDescriptor
null
public ImageData getImageData(int zoom)
ImageDescriptor
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.
getImageData
in class ImageDescriptor
zoom
- The zoom level in % of the standard resolution (which is 1
physical monitor pixel / 1 SWT logical point). Typically 100,
150, or 200.null
protected int getTransparentPixel()
protected abstract Point getSize()
Subclasses must implement this framework method.
@Deprecated protected void setImageData(ImageData imageData)
imageData
- unspecifiedprotected boolean supportsZoomLevel(int zoom)
zoom
- the zoom levelzoom == 100
.protected int getZoomLevel()
Important: This method must only be called within the dynamic scope of a call to
drawCompositeImage(int, int)
.
protected int autoScaleDown(int pixels)
This method must only be called within the dynamic
scope of a call to drawCompositeImage(int, int)
.
pixels
- a value in high-DPI pixelsprotected int autoScaleUp(int points)
This method must only be called within the dynamic
scope of a call to drawCompositeImage(int, int)
.
points
- a value in SWT pointsprotected CompositeImageDescriptor.CachedImageDataProvider createCachedImageDataProvider(Image image)
CompositeImageDescriptor.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
to drawCompositeImage(int, int)
.image
- the image, must not be nullprotected CompositeImageDescriptor.CachedImageDataProvider createCachedImageDataProvider(ImageDescriptor imageDescriptor)
CompositeImageDescriptor.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
to drawCompositeImage(int, int)
.
The provider returns ImageDescriptor.getMissingImageDescriptor()
if the image descriptor unexpectedly provides a null image data at zoom
== 100.
imageDescriptor
- the image descriptor, must not be null
Copyright (c) 2000, 2018 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.