Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.eclipse.jface.resource
Class ImageRegistry  view ImageRegistry download ImageRegistry.java

java.lang.Object
  extended byorg.eclipse.jface.resource.ImageRegistry

public class ImageRegistry
extends java.lang.Object

An image registry maintains a mapping between symbolic image names and SWT image objects or special image descriptor objects which defer the creation of SWT image objects until they are needed.

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


Nested Class Summary
private static class ImageRegistry.Entry
          Contains the data for an entry in the registry.
 
Field Summary
private  org.eclipse.swt.widgets.Display display
          display used when getting images
private  java.util.Map table
          Table of known images keyed by symbolic image name (key type: String, value type: org.eclipse.swt.graphics.Image or ImageDescriptor).
 
Constructor Summary
ImageRegistry()
          Creates an empty image registry.
ImageRegistry(org.eclipse.swt.widgets.Display display)
          Creates an empty image registry.
 
Method Summary
 org.eclipse.swt.graphics.Image get(java.lang.String key)
          Returns the image associated with the given key in this registry, or null if none.
 ImageDescriptor getDescriptor(java.lang.String key)
          Returns the descriptor associated with the given key in this registry, or null if none.
private  ImageRegistry.Entry getEntry(java.lang.String key)
           
private  java.util.Map getTable()
           
(package private)  void handleDisplayDispose()
          Shut downs this resource registry and disposes of all registered images.
private  void hookDisplayDispose(org.eclipse.swt.widgets.Display display)
          Hook a dispose listener on the SWT display.
 void put(java.lang.String key, org.eclipse.swt.graphics.Image image)
          Adds an image to this registry.
 void put(java.lang.String key, ImageDescriptor descriptor)
          Adds (or replaces) an image descriptor to this registry.
private  void putEntry(java.lang.String key, ImageRegistry.Entry entry)
           
 void remove(java.lang.String key)
          Removes an image from this registry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

table

private java.util.Map table
Table of known images keyed by symbolic image name (key type: String, value type: org.eclipse.swt.graphics.Image or ImageDescriptor).


display

private org.eclipse.swt.widgets.Display display
display used when getting images

Constructor Detail

ImageRegistry

public ImageRegistry()
Creates an empty image registry.

There must be an SWT Display created in the current thread before calling this method.


ImageRegistry

public ImageRegistry(org.eclipse.swt.widgets.Display display)
Creates an empty image registry.

Method Detail

get

public org.eclipse.swt.graphics.Image get(java.lang.String key)
Returns the image associated with the given key in this registry, or null if none.


getDescriptor

public ImageDescriptor getDescriptor(java.lang.String key)
Returns the descriptor associated with the given key in this registry, or null if none.

Since:
2.1

handleDisplayDispose

void handleDisplayDispose()
Shut downs this resource registry and disposes of all registered images.


hookDisplayDispose

private void hookDisplayDispose(org.eclipse.swt.widgets.Display display)
Hook a dispose listener on the SWT display.


put

public void put(java.lang.String key,
                ImageDescriptor descriptor)
Adds (or replaces) an image descriptor to this registry. The first time this new entry is retrieved, the image descriptor's image will be computed (via ImageDescriptor.createImage) and remembered. This method replaces an existing image descriptor associated with the given key, but fails if there is a real image associated with it.


put

public void put(java.lang.String key,
                org.eclipse.swt.graphics.Image image)
Adds an image to this registry. This method fails if there is already an image or descriptor for the given key.

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.


remove

public void remove(java.lang.String key)
Removes an image from this registry. If an SWT image was allocated, it is disposed. This method has no effect if there is no image or descriptor for the given key.


getEntry

private ImageRegistry.Entry getEntry(java.lang.String key)

putEntry

private void putEntry(java.lang.String key,
                      ImageRegistry.Entry entry)

getTable

private java.util.Map getTable()