erland.util
Class SubImageHandler

java.lang.Object
  extended by erland.util.SubImageHandler

public class SubImageHandler
extends Object

Implements a image handler which makes it easier to extract and drag sub images from a large image

Author:
Erland Isaksson

Constructor Summary
SubImageHandler(Image image, int width, int height, int noOfX, int noOfY)
          Creates a image handler which makes it possible to extract sub images from a main image
SubImageHandler(Image image, int width, int height, int noOfX, int noOfY, int drawOffsetX, int drawOffsetY)
          Creates a image handler which makes it possible to extract sub images from a main image.
 
Method Summary
 void drawImage(Graphics g, int subimage, int x, int y)
          Draw a specific subimage
 Graphics getGraphics(int subimage)
          Get a Graphics object for the specified sub image
 Image getImage()
          Get the main image which contains all sub images
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SubImageHandler

public SubImageHandler(Image image,
                       int width,
                       int height,
                       int noOfX,
                       int noOfY)
Creates a image handler which makes it possible to extract sub images from a main image

Parameters:
image - The main image to extract sub images from
width - The width of each subimage
height - The height of each subimage
noOfX - Number of sub images on each row
noOfY - Number of rows with sub images

SubImageHandler

public SubImageHandler(Image image,
                       int width,
                       int height,
                       int noOfX,
                       int noOfY,
                       int drawOffsetX,
                       int drawOffsetY)
Creates a image handler which makes it possible to extract sub images from a main image. It is also possible to select an offset which should be added before drawing the image.

Parameters:
image - The main image to extract sub images from
width - The width of each subimage
height - The height of each subimage
noOfX - Number of sub images on each row
noOfY - Number of rows with sub images
drawOffsetX - Number of pixels to add to x coordinate before drawing
drawOffsetY - Number of pixels to add to y coordinate before drawing
Method Detail

drawImage

public void drawImage(Graphics g,
                      int subimage,
                      int x,
                      int y)
Draw a specific subimage

Parameters:
g - The Graphics object to draw on
subimage - The number of the sub image to draw
x - The x position to draw sub image on
y - The y position to draw sub image on

getImage

public Image getImage()
Get the main image which contains all sub images

Returns:
The main image

getGraphics

public Graphics getGraphics(int subimage)
Get a Graphics object for the specified sub image

Parameters:
subimage - The sub image to get a Graphics object for
Returns:
A Graphics object for the subimage


Copyright © 2003-2005 Erland Isaksson. All Rights Reserved.