vooga.gameEngine.item
Class BoundedItem

java.lang.Object
  extended by vooga.gameEngine.game.GameRelatedObject
      extended by vooga.gameEngine.item.GameItem
          extended by vooga.gameEngine.item.BoundedItem
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Renderable>, java.util.EventListener, Renderable, Tangible, PositionChangeListener, RotationChangeListener, SizeChangeListener, TangibleListener
Direct Known Subclasses:
Alien, Bomb, EnemyShip, Ship, UFO

public class BoundedItem
extends GameItem
implements TangibleListener

Represents an item that is always updated to know the current boundaries of of a given Tangible item.

Author:
Justin C. Klaassen
See Also:
Serialized Form

Constructor Summary
BoundedItem(Texture t, Tangible b)
          Constructor for creating a BoundedItem.
 
Method Summary
protected  java.awt.geom.Rectangle2D getRectangularBoundaries()
          Method for getting the current rectangular boundaries associated with the BoundedItem.
protected  java.awt.Shape getShapeBoundaries()
          Method for getting the current boundaries associated with the BoundedItem.
 void positionChanged(PositionChangedEvent e)
          This is called whenever a Tangible object updates its position.
 void rotationChanged(RotationChangedEvent e)
          This is called whenever a Tangible object changes its rotation.
 void sizeChanged(SizeChangedEvent e)
          This is called whenever a Tangible object updates its position.
 
Methods inherited from class vooga.gameEngine.item.GameItem
compareTo, getPosition, getRotation, getShape, getSize, getTexture, isVisible, move, resize, rotate, setPosition, setRotation, setSize, setVisibility
 
Methods inherited from class vooga.gameEngine.game.GameRelatedObject
addEventListener, clearListeners, equals, fire, fire, fire, getEventListeners, getID, getListenerCount, removeEventListener
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BoundedItem

public BoundedItem(Texture t,
                   Tangible b)
Constructor for creating a BoundedItem. Automatically adds this item as a listener to the supplied Tangible item if it is a GameRelatedObject.

Parameters:
t - is the Texture to represent this item on screen
b - is the Tangible item that this object will know the bounds of
Method Detail

getRectangularBoundaries

protected java.awt.geom.Rectangle2D getRectangularBoundaries()
Method for getting the current rectangular boundaries associated with the BoundedItem. This is equivalent of calling getShape().getBounds2D().

Returns:
a Rectangle2D representing the boundaries of what is bounding this item in terms of the game's coordinate system

getShapeBoundaries

protected java.awt.Shape getShapeBoundaries()
Method for getting the current boundaries associated with the BoundedItem. These boundaries are very precise and represent the exact Shape associated with the object bounding this one.

Returns:
a Shape representing the boundaries of what is bounding this item in terms of the game's coordinate system

positionChanged

public void positionChanged(PositionChangedEvent e)
Description copied from interface: PositionChangeListener
This is called whenever a Tangible object updates its position.

Specified by:
positionChanged in interface PositionChangeListener
Parameters:
e - the PositionChangedEvent

rotationChanged

public void rotationChanged(RotationChangedEvent e)
Description copied from interface: RotationChangeListener
This is called whenever a Tangible object changes its rotation.

Specified by:
rotationChanged in interface RotationChangeListener
Parameters:
e - the RotationChangedEvent

sizeChanged

public void sizeChanged(SizeChangedEvent e)
Description copied from interface: SizeChangeListener
This is called whenever a Tangible object updates its position.

Specified by:
sizeChanged in interface SizeChangeListener
Parameters:
e - the PositionChangedEvent