GTGE API

com.golden.gamedev.engine
Class BaseLoader

java.lang.Object
  extended by com.golden.gamedev.engine.BaseLoader

public class BaseLoader
extends Object

Class for loading and masking images, and also behave as storage of the loaded images.

Supported image format: png (*.png), gif (*.gif), and jpeg (*.jpg).

BaseLoader class is using functions from ImageUtil class for loading and masking images in convenient way.

This class is using BaseIO to get the external resources.

See Also:
ImageUtil

Constructor Summary
BaseLoader(BaseIO base, Color maskColor)
          Constructs new BaseLoader with specified I/O loader, and masking color.
 
Method Summary
 BaseIO getBaseIO()
          Returns BaseIO associated with this image loader.
 BufferedImage getImage(String imagefile)
          Loads and returns an image with specified file using masking color.
 BufferedImage getImage(String imagefile, boolean useMask)
          Loads and returns an image with specified file and whether using masking color or not.
 BufferedImage[] getImages(String imagefile, int col, int row)
          Loads and returns image strip with specified file using masking color.
 BufferedImage[] getImages(String imagefile, int col, int row, boolean useMask)
          Loads and returns image strip with specified file and whether using masking color or not.
 Color getMaskColor()
          Returns image loader masking color.
 BufferedImage getStoredImage(String key)
          Returns cache image with specified key.
 BufferedImage[] getStoredImages(String key)
          Returns cache images with specified key.
 boolean removeImage(BufferedImage image)
          Removes specified image from cache.
 BufferedImage removeImage(String imagefile)
          Removes image with specified image filename from cache.
 boolean removeImages(BufferedImage[] images)
          Removes specified images from cache.
 BufferedImage[] removeImages(String imagefile)
          Removes images with specified image filename from cache.
 void setBaseIO(BaseIO base)
          Sets BaseIO where the image resources is loaded from.
 void setMaskColor(Color c)
          Sets image loader masking color.
 void storeImage(String key, BufferedImage image)
          Stores image into cache with specified key.
 void storeImages(String key, BufferedImage[] images)
          Stores images into cache with specified key.
 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)
Constructs new BaseLoader with specified I/O loader, and masking color.

Masking color is the color of the images that will be converted to transparent.

Parameters:
base - I/O resource loader
maskColor - the mask color
Method Detail

getImage

public BufferedImage getImage(String imagefile,
                              boolean useMask)
Loads and returns an image with specified file and whether using masking color or not. Image that have been loaded before will return immediately from cache.

Parameters:
imagefile - the image filename to be loaded
useMask - true, the image is using transparent color
Returns:
Requested image.

getImage

public BufferedImage getImage(String imagefile)
Loads and returns an image with specified file using masking color. Image that have been loaded before will return immediately from cache.

Parameters:
imagefile - the image filename to be loaded
Returns:
Requested image.
See Also:
getImage(String, boolean)

getImages

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

Parameters:
imagefile - the image filename to be loaded
col - image strip column
row - image strip row
useMask - true, the image is using transparent color
Returns:
Requested image.

getImages

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

Parameters:
imagefile - the image filename to be loaded
col - image strip column
row - image strip row
Returns:
Requested image.
See Also:
getImages(String, int, int, boolean)

storeImage

public void storeImage(String key,
                       BufferedImage image)
Stores image into cache with specified key.


storeImages

public void storeImages(String key,
                        BufferedImage[] images)
Stores images into cache with specified key.


getStoredImage

public BufferedImage getStoredImage(String key)
Returns cache image with specified key.


getStoredImages

public BufferedImage[] getStoredImages(String key)
Returns cache images with specified key.


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 image filename from cache.


removeImages

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


getBaseIO

public BaseIO getBaseIO()
Returns BaseIO associated with this image loader.

See Also:
setBaseIO(BaseIO)

setBaseIO

public void setBaseIO(BaseIO base)
Sets BaseIO where the image resources is loaded from.


getMaskColor

public Color getMaskColor()
Returns image loader masking color.

See Also:
setMaskColor(Color)

setMaskColor

public void setMaskColor(Color c)
Sets image loader masking color.

Masking color is the color of the images that will be converted to transparent.

See Also:
getMaskColor()

toString

public String toString()
Overrides:
toString in class Object

GTGE API

Copyright © 2003-2005 Golden T Studios. All rights reserved. Use is subject to license terms.
GoldenStudios.or.id