JTP
Class ImageLoader
java.lang.Object
JTP.ImageLoader
public class ImageLoader
- extends Object
This class is used to load the various image resources used by the game.
- Author:
- V.Termanis
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ImageLoader
public ImageLoader()
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 imagesimgPrefix
- prefix used by all image filesimgExt
- the extension (without '.') used by all image filesimgPostfix
- different endings used by each image groupimgNames
- names of image groups to loadrequiredImagePostfixLimit
- 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