javoids
Class ImageMap

java.lang.Object
  extended by java.lang.Thread
      extended by javoids.ImageMap
All Implemented Interfaces:
java.io.Serializable, java.lang.Runnable

public class ImageMap
extends java.lang.Thread
implements java.io.Serializable

A class to load images mapped to an enum name for the items in this game.

Author:
mallette
See Also:
Serialized Form

Nested Class Summary
static class ImageMap.Name
          An enum for each item name.
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
private static java.util.HashMap<ImageMap.Name,javax.swing.ImageIcon> imageIcons
          a mapping of image names to the created icons based on the loaded images
private static java.util.HashMap<ImageMap.Name,java.lang.String> imageNames
          a mapping of image names to image file names
private static java.util.HashMap<ImageMap.Name,java.awt.Image> images
          a mapping of image names to the loaded images
private static long serialVersionUID
          This is the version used for serializing/deserializing (storing/retrieving) this object
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ImageMap()
           
 
Method Summary
 java.awt.Image getImage(ImageMap.Name name)
           
 javax.swing.ImageIcon getImageIcon(ImageMap.Name name)
           
 java.util.HashMap<ImageMap.Name,java.awt.Image> getImages()
           
 java.awt.Image getScaledImage(ImageMap.Name name, int width, int height, int hints)
          Scale an image from the list
 void putImage(ImageMap.Name name, java.awt.Image image)
           
 void run()
          Load the images in a separate thread.
 int size()
           
 java.lang.String toString()
          Provide a String representation of this object.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
This is the version used for serializing/deserializing (storing/retrieving) this object

See Also:
Constant Field Values

imageNames

private static java.util.HashMap<ImageMap.Name,java.lang.String> imageNames
a mapping of image names to image file names


images

private static java.util.HashMap<ImageMap.Name,java.awt.Image> images
a mapping of image names to the loaded images


imageIcons

private static java.util.HashMap<ImageMap.Name,javax.swing.ImageIcon> imageIcons
a mapping of image names to the created icons based on the loaded images

Constructor Detail

ImageMap

public ImageMap()
Method Detail

run

public void run()
Load the images in a separate thread.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

size

public int size()
Returns:
the number of images

getImage

public java.awt.Image getImage(ImageMap.Name name)
Parameters:
name - the name (enum) of the item
Returns:
the image for the provided name

getImageIcon

public javax.swing.ImageIcon getImageIcon(ImageMap.Name name)
Parameters:
name - the name (enum) of the item
Returns:
the icon for the provided name

getScaledImage

public java.awt.Image getScaledImage(ImageMap.Name name,
                                     int width,
                                     int height,
                                     int hints)
Scale an image from the list

Parameters:
name - the name (enum) of the item
width - the desired width of the images
height - the desired height of the image
hints - image rendering hints (see sun constants)
Returns:
the scaled image

getImages

public java.util.HashMap<ImageMap.Name,java.awt.Image> getImages()
Returns:
a mapping of image names to images

putImage

public void putImage(ImageMap.Name name,
                     java.awt.Image image)
Parameters:
name - the name (enum) of the item
image - the image to associate with the provided name

toString

public java.lang.String toString()
Provide a String representation of this object.

Overrides:
toString in class java.lang.Thread
Returns:
String A representation of the object for debugging.