vooga.gameEngine.graphics
Class ImageTexture

java.lang.Object
  extended by vooga.gameEngine.graphics.Texture
      extended by vooga.gameEngine.graphics.ImageTexture
All Implemented Interfaces:
java.io.Serializable

public class ImageTexture
extends Texture

Class ImageTexture creates a Texture from a URL linking to an image file. The images used must be a .png, .gif, or .jpg. The image should contain a continuous opaque area that represents the object and the rest of the image should be transparent. The image will automatically be cropped to its minimal visible size such that in every row and column there is at least one non-transparent pixel.

Author:
Justin C. Klaassen, Jacob Harer
See Also:
Serialized Form

Constructor Summary
ImageTexture(java.net.URL url, Dimension d, Position p)
          Creates a new ImageTexture from a url, dimension, and position.
 
Method Summary
protected  java.awt.Shape makeShape()
          Method for a Texture subclass to supply a Shape representing their bounding box.
 void setImage(java.net.URL url)
          Loads an image from a url and uses it to represent this Texture on screen.
 void setShape(java.awt.Shape s)
          sets the shape of the image by cutting our the image to fit the shape
 
Methods inherited from class vooga.gameEngine.graphics.Texture
getArea, getIndex, getPosition, getRotation, getShape, getSize, paintComponent, setImage, setIndex, setPosition, setRotation, setSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageTexture

public ImageTexture(java.net.URL url,
                    Dimension d,
                    Position p)
Creates a new ImageTexture from a url, dimension, and position. The image when loaded will automatically be cropped to its minimal visible size.

Parameters:
url - is the link to the image file to be used
d - is the dimension of the object in the game's coordinate system
p - is the position of the top left corner of the created Texture in the game's coordinate system
Method Detail

setImage

public void setImage(java.net.URL url)
Loads an image from a url and uses it to represent this Texture on screen. The image is automatically cropped to its minimal visible size.

Parameters:
url - is the link to the image file to be used

setShape

public void setShape(java.awt.Shape s)
sets the shape of the image by cutting our the image to fit the shape

Parameters:
s -

makeShape

protected java.awt.Shape makeShape()
Description copied from class: Texture
Method for a Texture subclass to supply a Shape representing their bounding box. For efficiency, an object should cache their Shape if possible.

Specified by:
makeShape in class Texture
Returns:
a Shape representing the boundaries of the object