cage.graphics
Class Clickable

java.lang.Object
  extended by cage.graphics.Clickable
Direct Known Subclasses:
HotSpot, Sprite

public abstract class Clickable
extends java.lang.Object

An abstract class which contains collision detection code with mouse input, for use with anything which has a rectangular hitbox and is intended to be clicked.

Author:
Seth Marinello

Field Summary
protected  java.lang.String actionName
          The name of the action to call when clicked.
protected  Point botRight
          The bottom right of the bounding box on this Clickable
protected  int height
          The height of this clickable's hit box
protected  java.lang.String name
          The name of the clickable item
protected  Point topLeft
          The top left of the bounding box on this Clickable
protected  int width
          The width of this clickable's hit box.
 
Constructor Summary
Clickable()
           
 
Method Summary
 Point getLocation()
          Gets the X,Y location of this Sprite.
 java.lang.String getName()
          Get the name of this Clickable.
 int getX()
          Get the X location of the upper left corner of this clickable.
 int getY()
          Get the Y location of the upper left corner of this clickable.
 boolean inputCollision(int x, int y)
          Checks to see if the given input coords are within the bounding box of this clickable.
 void performAction()
          Perform the action of this clickable, for use with inputCollision
 void setLocation(int x, int y)
          Set the location of this Clickable to the specified X,Y.
 void setLocation(Point coord)
          Set the location of this sprite to the specified point.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

topLeft

protected Point topLeft
The top left of the bounding box on this Clickable


botRight

protected Point botRight
The bottom right of the bounding box on this Clickable


width

protected int width
The width of this clickable's hit box.


height

protected int height
The height of this clickable's hit box


actionName

protected java.lang.String actionName
The name of the action to call when clicked.


name

protected java.lang.String name
The name of the clickable item

Constructor Detail

Clickable

public Clickable()
Method Detail

inputCollision

public boolean inputCollision(int x,
                              int y)
Checks to see if the given input coords are within the bounding box of this clickable.

Parameters:
x - the x value to test
y - the y value to test
Returns:
Returns true if the given coordinate is within this Clickables bound box.

getLocation

public Point getLocation()
Gets the X,Y location of this Sprite.

Returns:
the X,Y location as a Point

setLocation

public void setLocation(Point coord)
Set the location of this sprite to the specified point.

Parameters:
coord - the X,Y location of the sprite

setLocation

public void setLocation(int x,
                        int y)
Set the location of this Clickable to the specified X,Y.

Parameters:
x - the x coord
y - the y coord

getX

public int getX()
Get the X location of the upper left corner of this clickable.

Returns:
the top left x value.

getY

public int getY()
Get the Y location of the upper left corner of this clickable.

Returns:
the top left y value.

performAction

public void performAction()
Perform the action of this clickable, for use with inputCollision


getName

public java.lang.String getName()
Get the name of this Clickable.

Returns:
tbe name.