net.shredzone.ifish.pool
Class ImgPool

java.lang.Object
  extended by net.shredzone.ifish.pool.ImgPool

public final class ImgPool
extends Object

Serves images from a common image pool. You just need to pass the name of the picture, and get the Image as result.

The ImgPool implements a weak caching mechanism. If you need several instances of the same image, you can just call get() multiple times and always get the same instance. The image is internally cached until the last reference has been discarded.

Version:
$Id: ImgPool.java 291 2009-04-28 21:29:27Z shred $

Constructor Summary
ImgPool()
           
 
Method Summary
static ImageIcon get(String name)
          Get an ImageIcon by its name.
static ImageIcon getScaled(String name, int width, int height)
          Get an ImageIcon by its name, and scales it to the given dimensions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImgPool

public ImgPool()
Method Detail

get

public static ImageIcon get(String name)
Get an ImageIcon by its name.

Parameters:
name - Image name
Returns:
ImageIcon or null if not found

getScaled

public static ImageIcon getScaled(String name,
                                  int width,
                                  int height)
Get an ImageIcon by its name, and scales it to the given dimensions. Note that scaled images will not be cached.

Parameters:
name - Image name
width - Image width
height - Image height
Returns:
ImageIcon or null if not found


Copyright © 2007-2011 shredzone.org. All Rights Reserved.