javoids
Class Media

java.lang.Object
  extended by javoids.Media
All Implemented Interfaces:
java.io.Serializable

public final class Media
extends java.lang.Object
implements java.io.Serializable

A class to load the media files required for this game. The files include, the images, sounds, liscence, readme, and version information.

Author:
mallette
See Also:
Serialized Form

Field Summary
private static ImageMap imageMap
          an image map of all images
private static boolean isSoundEnabled
          is the sound enabled
private static ItemLoader item
          the item file's text
private static java.lang.String ITEM
          the item file name
private static TextLoader license
          the license file's text
private static java.lang.String LICENSE
          the license file name
private static TextLoader readme
          the readme file's text
private static java.lang.String README
          the readme file name
private static long serialVersionUID
          This is the version used for serializing/deserializing (storing/retrieving) this object
private static SoundMap soundMap
          an sound map of all sounds
private static TextLoader version
          the version file's text
private static java.lang.String VERSION
          the version file name
private static int volumePercent
          the volume level (0..100%)
 
Constructor Summary
Media()
           
 
Method Summary
static java.awt.Image getImage(ImageMap.Name name)
           
static javax.swing.ImageIcon getImageIcon(ImageMap.Name name)
           
static java.util.HashMap<ImageMap.Name,java.awt.Image> getImages()
           
static java.util.HashMap<Item.Type,Item> getItems()
           
static java.lang.String getLicense()
           
static int getNumberImages()
           
static int getNumberSounds()
           
static java.lang.String getReadme()
           
static java.awt.Image getScaledImage(ImageMap.Name name, int width, int height, int hints)
           
static java.util.HashMap<SoundMap.Sound,javax.sound.sampled.Clip> getSounds()
           
static java.lang.String getVersion()
           
static int getVolume()
           
static void play(SoundMap.Sound sound)
           
static void setImage(ImageMap.Name name, java.awt.Image image)
           
static void setIsSound(boolean _isSoundEnabled)
           
static void setVolume(javax.sound.sampled.Clip clip, int _volumePercent)
           
static void setVolume(int value)
           
static void stopAll()
          stop all sounds from playing
 java.lang.String toString()
          Provide a String representation of this object.
 
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

README

private static final java.lang.String README
the readme file name


VERSION

private static final java.lang.String VERSION
the version file name


LICENSE

private static final java.lang.String LICENSE
the license file name


ITEM

private static final java.lang.String ITEM
the item file name


imageMap

private static final ImageMap imageMap
an image map of all images


soundMap

private static final SoundMap soundMap
an sound map of all sounds


readme

private static final TextLoader readme
the readme file's text


version

private static final TextLoader version
the version file's text


license

private static final TextLoader license
the license file's text


item

private static final ItemLoader item
the item file's text


isSoundEnabled

private static boolean isSoundEnabled
is the sound enabled


volumePercent

private static int volumePercent
the volume level (0..100%)

Constructor Detail

Media

public Media()
Method Detail

getImages

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

getImage

public static java.awt.Image getImage(ImageMap.Name name)
Parameters:
name - the desired image's name
Returns:
the image associated with that image

getImageIcon

public static javax.swing.ImageIcon getImageIcon(ImageMap.Name name)
Parameters:
name - the desired icon's name
Returns:
the icon associated with that name

getScaledImage

public static java.awt.Image getScaledImage(ImageMap.Name name,
                                            int width,
                                            int height,
                                            int hints)
Parameters:
name - the name of the desired image
width - the width of the image
height - the height of the image
hints - rendering hints
Returns:
the scaled image

getNumberImages

public static int getNumberImages()
Returns:
the number of images that were loaded

getSounds

public static java.util.HashMap<SoundMap.Sound,javax.sound.sampled.Clip> getSounds()
Returns:
a mapping of a name to a sound clip

getItems

public static java.util.HashMap<Item.Type,Item> getItems()
Returns:
mapping of an item name to an item

getNumberSounds

public static int getNumberSounds()
Returns:
the number of sounds that were loaded

getReadme

public static java.lang.String getReadme()
Returns:
the text of the readme file

getVersion

public static java.lang.String getVersion()
Returns:
the text of the version file

getLicense

public static java.lang.String getLicense()
Returns:
the text of the license file

setIsSound

public static void setIsSound(boolean _isSoundEnabled)
Parameters:
_isSoundEnabled - set if the sound is enabled

setImage

public static void setImage(ImageMap.Name name,
                            java.awt.Image image)
Parameters:
name - the image name to set
image - the image to associate with the image name

play

public static void play(SoundMap.Sound sound)
Parameters:
sound - the name of the sound to play

setVolume

public static void setVolume(javax.sound.sampled.Clip clip,
                             int _volumePercent)
Parameters:
clip - the sound clip to set the volume for
_volumePercent - the volume level to set

getVolume

public static int getVolume()
Returns:
the volume level (0..100%)

setVolume

public static void setVolume(int value)
Parameters:
value - the percent value to set the volume level

stopAll

public static void stopAll()
stop all sounds from playing


toString

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

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