gameutil
Class ImageLoader

java.lang.Object
  extended by gameutil.ImageLoader

public class ImageLoader
extends java.lang.Object

The purpose of the ImageLoader is to be able to obtain multipul instances of an object without using extra RAM space.


Field Summary
 java.util.ArrayList<java.awt.Image> images
           
 java.util.ArrayList<java.lang.String> names
           
 
Constructor Summary
ImageLoader()
          Constructs an ImageLoader.
 
Method Summary
 boolean alreadyLoaded(java.lang.String fileName)
          Tests to see if an image from a defined file name is already loaded.
 java.awt.Image getImage(int i)
          Retrieves a loaded image at index i.
 java.awt.Image getImage(java.lang.String fileName)
          Loads an image from a given file name if it is not already loaded, and returns the image.
 java.util.ArrayList<java.awt.Image> getImages()
          Retrieves all of the loaded images.
 java.util.ArrayList<java.awt.Image> getImages(java.util.ArrayList<java.lang.String> fileNames)
          Retrieves a group of images.
 java.util.ArrayList<java.awt.Image> getImages(int start, int finish)
          Retrieves a subset of all the previously loaded images.
 void load(java.lang.String fileName)
          Loads an image from a given file name.
 void load(java.net.URL url)
          Loads an image from a given URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

images

public java.util.ArrayList<java.awt.Image> images

names

public java.util.ArrayList<java.lang.String> names
Constructor Detail

ImageLoader

public ImageLoader()
Constructs an ImageLoader.

Method Detail

load

public void load(java.net.URL url)
Loads an image from a given URL.

Parameters:
url - The URL of an image.

load

public void load(java.lang.String fileName)
Loads an image from a given file name.

Parameters:
fileName - The file name of an image.

alreadyLoaded

public boolean alreadyLoaded(java.lang.String fileName)
Tests to see if an image from a defined file name is already loaded.

Parameters:
fileName - The fileName of an image.
Returns:
true if the image is already loaded.

getImage

public java.awt.Image getImage(java.lang.String fileName)
Loads an image from a given file name if it is not already loaded, and returns the image.

Parameters:
fileName - The file name of an image.
Returns:
returns the image of file name "fileName"

getImages

public java.util.ArrayList<java.awt.Image> getImages()
Retrieves all of the loaded images.

Returns:
All of the previously loaded Image.

getImage

public java.awt.Image getImage(int i)
Retrieves a loaded image at index i.

Parameters:
i - The index of an Image.
Returns:
A the previously loaded Image.

getImages

public java.util.ArrayList<java.awt.Image> getImages(int start,
                                                     int finish)
Retrieves a subset of all the previously loaded images.

Parameters:
start - The starting index of all images.
finish - The ending index.
Returns:
A subset of all the previously loaded images.

getImages

public java.util.ArrayList<java.awt.Image> getImages(java.util.ArrayList<java.lang.String> fileNames)
Retrieves a group of images. (Loads the images if they are not preloaded)

Parameters:
fileNames - An ArrayList of image file names.
Returns:
A group of images.