org.PingOO.DLAI.lib.util
Class ImageManager

java.lang.Object
  |
  +--org.PingOO.DLAI.lib.util.Manager
        |
        +--org.PingOO.DLAI.lib.util.ImageManager

public final class ImageManager
extends Manager

Manages the images for the DLAI

Since:
PingOO 2.0
Version:
2.0
Author:
Fabrice Bouyé (bouye@cur-archamps.fr)

Field Summary
private static java.lang.String DEFAULT_MODULE
          The default moduel of images.
private static java.util.Hashtable IMAGE_TABLE
          The cache of images.
 
Fields inherited from class org.PingOO.DLAI.lib.util.Manager
classLoader
 
Constructor Summary
private ImageManager()
          Hides the constructor from the outside.
 
Method Summary
static void clearCache()
          Clears the cache used in this manager.
private static java.util.Hashtable getCache(java.lang.String module, java.util.Hashtable parentTable)
          Return the correct cache.
static java.awt.Image getImage(javax.swing.Icon icon)
          Returns the image of the icon.
static java.awt.Image getImage(java.lang.String identifier)
          Returns an image from the default set.
static java.awt.Image getImage(java.lang.String module, java.lang.String identifier)
          Returns an icon from a different set.
private static void initialize()
          Initializes caches.
static java.awt.Image resizeImage(java.awt.Image oldImage, java.awt.Dimension dimension)
          Returns an image that have been resized to the correct dimension.
 
Methods inherited from class org.PingOO.DLAI.lib.util.Manager
findFile, findFile, findFile, findFile
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

IMAGE_TABLE

private static java.util.Hashtable IMAGE_TABLE
The cache of images.

DEFAULT_MODULE

private static final java.lang.String DEFAULT_MODULE
The default moduel of images.
Constructor Detail

ImageManager

private ImageManager()
Hides the constructor from the outside.
Method Detail

initialize

private static final void initialize()
Initializes caches.

getCache

private static final java.util.Hashtable getCache(java.lang.String module,
                                                  java.util.Hashtable parentTable)
Return the correct cache.
Parameters:
module - The module to use.
parentTable - The parent cache of the desired cache.
Returns:
The correct cache.

clearCache

public static void clearCache()
Clears the cache used in this manager.

getImage

public static final java.awt.Image getImage(java.lang.String identifier)
Returns an image from the default set.
In case the icon is not found the program will then try to retrieve it by removing the default extension.
By default the search occurs in the image directory, then if the file is still not found it will take place in the big icon and then in the mini icon directory.
Parameters:
identifier - The identifier need to get the image from its file. You do not need to provide the .gif extension.
Returns:
The expected icon, or null if the file was not found.

getImage

public static final java.awt.Image getImage(javax.swing.Icon icon)
Returns the image of the icon.
Returns:
The image of the icon, or null if the icon has no image.

getImage

public static final java.awt.Image getImage(java.lang.String module,
                                            java.lang.String identifier)
Returns an icon from a different set.
In case the icon is not found the program will then try to retrieve it by removing the default extension.
If the icon is still not found then the search will continue in the default set, using the same way as with the specific module.
By default the search occurs in the image directory, then if the file is still not found it will take place in the big icon and then in the mini icon directory.
Parameters:
module - The appli's name.
identifier - The identifier need to get the image from its file. You do not need to provide the .gif extension.
Returns:
The expected icon, or an image of the defautl icon instead if the file was not found.

resizeImage

public static final java.awt.Image resizeImage(java.awt.Image oldImage,
                                               java.awt.Dimension dimension)
Returns an image that have been resized to the correct dimension.
Provides a convienient way to resize images to their correct size.
Parameters:
oldImage - The original image that needs to be resized.
dimension - the new dimension to apply.
Returns:
An image with the correcte size, or the old image is the dimension is null or has a zero value, or null if the icon null.