JTP
Class ImageLoader

java.lang.Object
  extended by JTP.ImageLoader

public class ImageLoader
extends Object

This class is used to load the various image resources used by the game.

Author:
V.Termanis

Constructor Summary
ImageLoader()
           
 
Method Summary
static BufferedImage[][] getImages(Class cl, String imgPath, String imgPrefix, String imgExt, String[] imgPostfix, String[] imgNames, int requiredImagePostfixLimit)
          Loads a set of images.
static BufferedImage loadImage(URL imgLocation)
          Loads an image from the given location.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageLoader

public ImageLoader()
Method Detail

getImages

public static BufferedImage[][] getImages(Class cl,
                                          String imgPath,
                                          String imgPrefix,
                                          String imgExt,
                                          String[] imgPostfix,
                                          String[] imgNames,
                                          int requiredImagePostfixLimit)
                                   throws IndexOutOfBoundsException,
                                          NullPointerException,
                                          IOException
Loads a set of images. File names are combined as follows:
imgPrefix + imgName + imgPostfix + '.' + imgExt

Parameters:
cl - instance of Class which is needed to access image files via the getResource() method.
imgPath - relative or absolute path to the images
imgPrefix - prefix used by all image files
imgExt - the extension (without '.') used by all image files
imgPostfix - different endings used by each image group
imgNames - names of image groups to load
requiredImagePostfixLimit - minimum number of images that have to exist (if they do not then IOException will be thrown)
Returns:
An array of groups containing images with all different endings
Throws:
IndexOutOfBoundsException - if requiredImagePostfixLimit > imgPostfix.length
NullPointerException - if any of the parameters are null
IOException - if the image cannot be loaded

loadImage

public static BufferedImage loadImage(URL imgLocation)
                               throws IOException,
                                      NullPointerException
Loads an image from the given location.

Parameters:
imgLocation - full path or link to the image to load
Returns:
the loaded image
Throws:
IOException - if the image could not be read succesfully
NullPointerException - if imgLocation is null