DESY ACOP Beans Home

com.cosylab.gui.components.util
Class ImageHelper

java.lang.Object
  extended by com.cosylab.gui.components.util.ImageHelper

public class ImageHelper
extends java.lang.Object

ImageHelper acts as an interface to the all images currently in classpath. ImageHelper is a singleton class that maintains internal cache to all accessed images. This class may be used to minimize the memory consumption where application uses static images. If images are changed independently, this class should not be used.

Version:
$id$
Author:
Jernej Kamenik

Method Summary
static java.awt.Image createImage(java.lang.String name)
          Returns instance of the image.
static java.awt.Image createimage(java.lang.String name, java.lang.ClassLoader cl)
          Returns instance of the image by loading it using the ClassLoader instance provided.
static java.awt.Image loadResource(java.lang.String resourceName, java.lang.ClassLoader c)
          This is a utility method to help in loading image images.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createimage

public static java.awt.Image createimage(java.lang.String name,
                                         java.lang.ClassLoader cl)
Returns instance of the image by loading it using the ClassLoader instance provided. images are cached. If an image with the same name is requested several times, createImage will return the same instance each time. If images will be manipulated individually, do not use this method to load images. If image is not found in the classpath, return value will be null.

Parameters:
name - String
cl - ClassLoader Instance of class loader to use
Returns:
image Instance of image or null if image could not be found.

createImage

public static java.awt.Image createImage(java.lang.String name)
Returns instance of the image. images are cached. If an image with the same name is requested several times, createImage will return the same instance each time. If images will be manipulated individually, do not use this method to load images. If image is not found in the classpath, return value will be null.

Parameters:
name - String
Returns:
image Instance of image or null if image could not be found.

loadResource

public static java.awt.Image loadResource(java.lang.String resourceName,
                                          java.lang.ClassLoader c)
This is a utility method to help in loading image images. It takes the name of a resource file and loads an image object from that file. Typically images will be GIFs.

Parameters:
resourceName - A pathname relative to the directory holding the class loader specified. For example, "wombat.gif".
c - ClassLoader.
Returns:
an image object. May be null if the load failed.


Copyright © 2010. All Rights Reserved.