kiwi.util
Class ResourceManager

java.lang.Object
  |
  +--kiwi.util.ResourceManager

public class ResourceManager
extends Object

This class provides base functionality for a resource manager; it includes support for the caching of images and sounds, and provides convenience methods for retrieving other types of resources. All resources are retrieved relative to an anchor class. The resource manager assumes that images will be within an "images" directory, textures within a "textures" directory, sounds within a "sounds" directory, URL-based references within an "html" directory, and properties within a "properties" directory.

Version:
1.1 (10/98)
Author:
Mark Lindner, PING Software Group
See Also:
ResourceLoader

Constructor Summary
ResourceManager(Class clazz)
          Construct a new ResourceManager.
 
Method Summary
 Icon getIcon(String name)
          Retrieve an internal Icon resource.
 Image getImage(String name)
          Retrieve an internal Image resource.
 Properties getProperties(String name)
          Get a reference to a Properties resource.
 AudioClip getSound(String name)
          Retrieve an internal AudioClip resource.
 Image getTexture(String name)
          Retrieve an internal texture resource.
 URL getURL(String name)
          Retrieve an internal URL resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceManager

public ResourceManager(Class clazz)
Construct a new ResourceManager.
Parameters:
clazz - The resource anchor class.
Method Detail

getIcon

public Icon getIcon(String name)
Retrieve an internal Icon resource. This is a convenience method that makes a call to getImage() and then wraps the result in a Swing ImageIcon object.
Returns:
An Icon for the specified image. If an icon for this image has previously been constructed, the cached copy is returned.
Throws:
ResourceNotFoundException - If the resource was not found.
See Also:
ImageIcon

getImage

public Image getImage(String name)
Retrieve an internal Image resource. If the named image has previously been loaded, a cached copy is returned.
Parameters:
name - The name of the resource.
Returns:
The Image object representing the resource.
Throws:
ResourceNotFoundException - If the resource was not found.

getTexture

public Image getTexture(String name)
Retrieve an internal texture resource. If the named texture has previously been loaded, a cached copy is returned.
Parameters:
name - The name of the resource.
Returns:
The Image object representing the resource.
Throws:
ResourceNotFoundException - If the resource was not found.

getURL

public URL getURL(String name)
Retrieve an internal URL resource.
Parameters:
The - name of the resource.
Returns:
A URL for the resource.
Throws:
ResourceNotFoundException - If the resource was not found.

getSound

public AudioClip getSound(String name)
Retrieve an internal AudioClip resource. If the named sound has previously been loaded, a cached copy is returned.
Parameters:
name - The name of the resource.
Returns:
The AudioClip object representing the resource.
Throws:
ResourceNotFoundException - If the resource was not found.

getProperties

public Properties getProperties(String name)
Get a reference to a Properties resource.
Parameters:
The - name of the resource.
Returns:
The Properties object representing the resource.
Throws:
ResourceNotFoundException - If the resource was not found.