com.golden.gamedev.engine
Class BaseLoader

java.lang.Object
  |
  +--com.golden.gamedev.engine.BaseLoader

public class BaseLoader
extends Object

Class for loading and storing game images. Supported image type: png (*.png), gif (*.gif), and jpeg (*.jpg).

This class use BaseIO to get the external resources.


Constructor Summary
BaseLoader(BaseIO base, Color maskColor)
           
 
Method Summary
 BaseIO getBaseIO()
           
 BufferedImage getCacheImage(String key)
          Returns specified image key from cache.
 BufferedImage[] getCacheImages(String key)
          Returns specified image key from cache.
 BufferedImage getImage(String imagefile)
           
 BufferedImage getImage(String imagefile, boolean useMask)
          Loads and returns an image with specified file and masking color.
 BufferedImage[] getImages(String imagefile, int col, int row)
           
 BufferedImage[] getImages(String imagefile, int col, int row, boolean useMask)
          Loads and returns image strip with specified file and masking color.
 Color getMaskColor()
           
 void putImage(String key, BufferedImage image)
          Inserts specified image to cache.
 void putImages(String key, BufferedImage[] images)
          Inserts specified images to cache.
 boolean removeImage(BufferedImage image)
          Removes specified image from cache.
 BufferedImage removeImage(String imagefile)
          Removes image with specified file from cache.
 boolean removeImages(BufferedImage[] images)
          Removes specified images from cache.
 BufferedImage[] removeImages(String imagefile)
          Removes images with specified file from cache.
 void setBaseIO(BaseIO base)
           
 void setMaskColor(Color c)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BaseLoader

public BaseLoader(BaseIO base,
                  Color maskColor)
Method Detail

getBaseIO

public BaseIO getBaseIO()

setBaseIO

public void setBaseIO(BaseIO base)

getMaskColor

public Color getMaskColor()

setMaskColor

public void setMaskColor(Color c)

getImage

public BufferedImage getImage(String imagefile,
                              boolean useMask)
Loads and returns an image with specified file and masking color. Images that have been loaded before will return its cache immediately.

Parameters:
imagefile - the image file to be loaded
useMask - true, the image will use transparent color
Returns:
requested image

getImage

public BufferedImage getImage(String imagefile)

getImages

public BufferedImage[] getImages(String imagefile,
                                 int col,
                                 int row,
                                 boolean useMask)
Loads and returns image strip with specified file and masking color. Images that have been loaded before will return its cache immediately.

Parameters:
imagefile - the image file to be loaded
col - image strip column
row - image strip row
useMask - true, the image will use transparent color
Returns:
requested image

getImages

public BufferedImage[] getImages(String imagefile,
                                 int col,
                                 int row)

putImage

public void putImage(String key,
                     BufferedImage image)
Inserts specified image to cache.


putImages

public void putImages(String key,
                      BufferedImage[] images)
Inserts specified images to cache.


getCacheImage

public BufferedImage getCacheImage(String key)
Returns specified image key from cache.


getCacheImages

public BufferedImage[] getCacheImages(String key)
Returns specified image key from cache.


removeImage

public boolean removeImage(BufferedImage image)
Removes specified image from cache.


removeImages

public boolean removeImages(BufferedImage[] images)
Removes specified images from cache.


removeImage

public BufferedImage removeImage(String imagefile)
Removes image with specified file from cache.


removeImages

public BufferedImage[] removeImages(String imagefile)
Removes images with specified file from cache.


toString

public String toString()
Overrides:
toString in class Object