public class ImageRegistry extends Object
An image registry owns all of the image objects registered with it, and automatically disposes of them when the SWT Display that creates the images is disposed. Because of this, clients do not need to (indeed, must not attempt to) dispose of these images themselves.
Clients may instantiate this class (it was not designed to be subclassed).
Unlike the FontRegistry, it is an error to replace images. As a result there are no events that fire when values are changed in the registry
Constructor and Description |
---|
ImageRegistry()
Creates an empty image registry.
|
ImageRegistry(Display display)
Creates an empty image registry.
|
ImageRegistry(ResourceManager manager)
Creates an empty image registry using the given resource manager to allocate images.
|
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Disposes this image registry, disposing any images
that were allocated for it, and clearing its entries.
|
Image |
get(String key)
Returns the image associated with the given key in this registry,
or
null if none. |
ImageDescriptor |
getDescriptor(String key)
Returns the descriptor associated with the given key in this registry,
or
null if none. |
void |
put(String key,
Image image)
Adds an image to this registry.
|
void |
put(String key,
ImageDescriptor descriptor)
Adds (or replaces) an image descriptor to this registry.
|
void |
remove(String key)
Removes an image from this registry.
|
public ImageRegistry()
There must be an SWT Display created in the current thread before calling this method.
public ImageRegistry(ResourceManager manager)
manager
- the resource manager used to allocate imagespublic ImageRegistry(Display display)
display
- this Display
must not be
null
and must not be disposed in order
to use this registrypublic Image get(String key)
null
if none.key
- the keynull
if nonepublic ImageDescriptor getDescriptor(String key)
null
if none.key
- the keynull
if nonepublic void put(String key, ImageDescriptor descriptor)
key
- the keydescriptor
- the ImageDescriptorIllegalArgumentException
- if the key already existspublic void put(String key, Image image)
Note that an image registry owns all of the image objects registered with it, and automatically disposes of them when the SWT Display is disposed. Because of this, clients must not register an image object that is managed by another object.
key
- the keyimage
- the image, should not be null
IllegalArgumentException
- if the key already existspublic void remove(String key)
key
- the keypublic void dispose()
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.