javoids
Class SoundMap

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

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

A class to provide mappings of sound names to sound clips and other functions to support their loading and use.

Author:
mallette
See Also:
Serialized Form

Nested Class Summary
static class SoundMap.Sound
          A list of sound names for the game.
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
private static java.util.HashMap<SoundMap.Sound,java.lang.String> fileNames
          a map of sound names to their file names
private static long serialVersionUID
          This is the version used for serializing/deserializing (storing/retrieving) this object
private static java.util.HashMap<SoundMap.Sound,javax.sound.sampled.Clip> sounds
          a map of sound names to the sound clips (the loaded sound files)
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
SoundMap()
           
 
Method Summary
 javax.sound.sampled.Clip getSound(SoundMap.Sound sound)
           
 java.lang.String getSoundName(SoundMap.Sound sound)
           
 java.util.HashMap<SoundMap.Sound,javax.sound.sampled.Clip> getSounds()
           
 void run()
          Run a separate thread to load the sounds.
 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

fileNames

private static java.util.HashMap<SoundMap.Sound,java.lang.String> fileNames
a map of sound names to their file names


sounds

private static java.util.HashMap<SoundMap.Sound,javax.sound.sampled.Clip> sounds
a map of sound names to the sound clips (the loaded sound files)

Constructor Detail

SoundMap

public SoundMap()
Method Detail

run

public void run()
Run a separate thread to load the sounds.

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

size

public int size()
Returns:
the number of sounds loaded

getSound

public javax.sound.sampled.Clip getSound(SoundMap.Sound sound)
Parameters:
sound - the sound name
Returns:
the sound clip associated with the name

getSounds

public java.util.HashMap<SoundMap.Sound,javax.sound.sampled.Clip> getSounds()
Returns:
the mapping of sound names to sound clips

getSoundName

public java.lang.String getSoundName(SoundMap.Sound sound)
Parameters:
sound - the sound name
Returns:
the text representation of the sound 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.