org.eclipse.corona.ui.tools
Class ImageCache

java.lang.Object
  extended by org.eclipse.corona.ui.tools.ImageCache
Direct Known Subclasses:
ImageCache, ImageCache

public class ImageCache
extends java.lang.Object

The base class which is intedned to be extended by a bundle and then used. Class have two maps:

  • k=String(fileName) v=ImageDescriptor
  • k=ImageDescriptor v=Image

    Author:
    Marcin Okraszewski, Piotr Jaworowski

    Constructor Summary
    protected ImageCache(org.osgi.framework.Bundle bundle)
              The image cache constructor.
     
    Method Summary
     void dispose()
              Method disposes all the images kept in the imageMap and imageMapByName.
     org.eclipse.swt.graphics.Image getImage(org.eclipse.jface.resource.ImageDescriptor imageDescriptor)
              Returns the image that is represented by an image descriptor.
     org.eclipse.swt.graphics.Image getImage(java.lang.String imageName)
              Returns the image that is represented by a given name.
     org.eclipse.jface.resource.ImageDescriptor getImageDescriptor(java.lang.String imagePath)
              Returns image descriptor for given image source.
     boolean isMissingImageDescriptor(org.eclipse.jface.resource.ImageDescriptor image)
              Mechod checks whether given imageDescriptoris equal to ImageDescriptor.getMissingImageDescriptor() image descriptor.
     void putImageDescriptor(java.lang.String imageName, org.eclipse.jface.resource.ImageDescriptor img)
              Method puts image created/retrieved into the imageMapByName, with custom image name.
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    ImageCache

    protected ImageCache(org.osgi.framework.Bundle bundle)
    The image cache constructor. Is available only by extending.

    Method Detail

    getImage

    public org.eclipse.swt.graphics.Image getImage(org.eclipse.jface.resource.ImageDescriptor imageDescriptor)
    Returns the image that is represented by an image descriptor. getImage(String) method is easier to use.

    Parameters:
    imageDescriptor - ImageDescriptor for which Image should be returned.
    Returns:
    created Image, or null if Image cannot be created.

    getImage

    public org.eclipse.swt.graphics.Image getImage(java.lang.String imageName)
    Returns the image that is represented by a given name. Two source are used: workbench shared images and file system.

    Parameters:
    imageName - image name to be found in imageMapByName, if it's not found it will be created based on name.
    Returns:
    created Image, or null if Image cannot be created.

    putImageDescriptor

    public void putImageDescriptor(java.lang.String imageName,
                                   org.eclipse.jface.resource.ImageDescriptor img)
    Method puts image created/retrieved into the imageMapByName, with custom image name.
    NOTE: ImageDescriptor will not be added into the map if it's MissingImageDescriptor.

    Parameters:
    imageName - custom image name under which the image should be kept.
    img - imageDescriptor to be stored in imageDescriptorMap.

    getImageDescriptor

    public org.eclipse.jface.resource.ImageDescriptor getImageDescriptor(java.lang.String imagePath)
    Returns image descriptor for given image source.

    Parameters:
    imagePath - Path to image, where root is root of current plugin.
    Returns:
    Descriptor of the image, or null if image cannot be created.

    dispose

    public void dispose()
    Method disposes all the images kept in the imageMap and imageMapByName.


    isMissingImageDescriptor

    public boolean isMissingImageDescriptor(org.eclipse.jface.resource.ImageDescriptor image)
    Mechod checks whether given imageDescriptoris equal to ImageDescriptor.getMissingImageDescriptor() image descriptor.

    Parameters:
    image - to check against the MissingImageDescriptor.
    Returns:
    true if it was created beased on missing image descriptor.

    Copyright 2006 IBM Corporation and others.
    All Rights Reserved.