wheelsunh.users
Class AbstractShape

java.lang.Object
  extended by wheelsunh.etc.AbstractGraphic
      extended by wheelsunh.users.AbstractShape
All Implemented Interfaces:
CustomGraphic, Locatable, Rotatable
Direct Known Subclasses:
Image, Shape, ShapeGroup

public abstract class AbstractShape
extends AbstractGraphic
implements Locatable, Rotatable

AbstractShape: an abstract superclass for Shape and ShapeGroup. Mostly for proper design hierarchy; it also means that a ShapeGroup can contain ShapeGroups. unh addition


Field Summary
protected  double _rot
           
 
Constructor Summary
AbstractShape()
          Default constructor - does nothing but check that a Frame has been created! UNH addition: 11/14/09 rdb
 
Method Summary
 boolean boundsIntersects(AbstractShape s)
          Intersect the bounds of this object with the argument.
protected  java.awt.Point center()
          convenience method to get the center of Shape
protected static double distance(java.awt.Point p1, java.awt.Point p2)
          convenience static method to compute distance between 2 points
abstract  java.awt.Rectangle getBounds()
           
 java.awt.Point getCenter()
          Returns the center of this Shape.
 int getCenterX()
          Returns the X-coordinate of this Shape's center.
 int getCenterY()
          Returns the Y-coordinate of this Shape's center.
abstract  int getHeight()
           
protected  java.awt.Point getIntersection(java.awt.Point start, double angle, AbstractShape s)
          getIntersection: get the intersection of the line starting at start with angle ( radians ) with the AbstractShape s Return the Point of intersection with the "wall" of the Frame if not found, or the point of intersection with the bounding box of s if found intersection() exploits this for shape-specific distances
abstract  java.awt.Point getLocation()
          Returns the object's location.
abstract  int getRotation()
          Returns the object's rotation in degrees.
abstract  int getWidth()
           
abstract  int getXLocation()
          Returns the object's x location.
abstract  int getYLocation()
          Returns the object's y location.
 int intersects(AbstractShape s)
          Generic AbstractShape handler Same as rectangle; exists for weird things that aren't the standard Shapes and for use in ShapeGroup's handler
 int intersects(ShapeGroup s)
          ShapeGroup intersection handler Calls intersects() for each AbstractShape in the group and returns the closest.
 void setCenter(java.awt.Point p)
          Moves this Shape so that its center is at p.
 void setLocation(int x, int y)
          Set object's location to given coordinates.
abstract  void setLocation(java.awt.Point p)
          Set object's location to given point.
abstract  void setRotation(int d)
          Sets the object's rotation in degrees.
 
Methods inherited from class wheelsunh.etc.AbstractGraphic
mouseClicked, mouseDragged, mousePressed, mouseReleased
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface wheelsunh.etc.CustomGraphic
contains, paint
 

Field Detail

_rot

protected double _rot
Constructor Detail

AbstractShape

public AbstractShape()
Default constructor - does nothing but check that a Frame has been created! UNH addition: 11/14/09 rdb

Method Detail

setLocation

public void setLocation(int x,
                        int y)
Set object's location to given coordinates.

Specified by:
setLocation in interface Locatable

setLocation

public abstract void setLocation(java.awt.Point p)
Description copied from interface: Locatable
Set object's location to given point.

Specified by:
setLocation in interface Locatable

getBounds

public abstract java.awt.Rectangle getBounds()

getXLocation

public abstract int getXLocation()
Description copied from interface: Locatable
Returns the object's x location.

Specified by:
getXLocation in interface Locatable

getYLocation

public abstract int getYLocation()
Description copied from interface: Locatable
Returns the object's y location.

Specified by:
getYLocation in interface Locatable

getWidth

public abstract int getWidth()

getHeight

public abstract int getHeight()

getLocation

public abstract java.awt.Point getLocation()
Description copied from interface: Locatable
Returns the object's location.

Specified by:
getLocation in interface Locatable

setRotation

public abstract void setRotation(int d)
Description copied from interface: Rotatable
Sets the object's rotation in degrees.

Specified by:
setRotation in interface Rotatable

getRotation

public abstract int getRotation()
Description copied from interface: Rotatable
Returns the object's rotation in degrees.

Specified by:
getRotation in interface Rotatable

getCenter

public java.awt.Point getCenter()
Returns the center of this Shape. unh addition


setCenter

public void setCenter(java.awt.Point p)
Moves this Shape so that its center is at p. unh addition


getCenterX

public int getCenterX()
Returns the X-coordinate of this Shape's center.


getCenterY

public int getCenterY()
Returns the Y-coordinate of this Shape's center.


boundsIntersects

public boolean boundsIntersects(AbstractShape s)
Intersect the bounds of this object with the argument. Returns true if there is overlap. The intersects method should do this, except for Line. unh addition 11/02/08 rdb: created


intersects

public int intersects(AbstractShape s)
Generic AbstractShape handler Same as rectangle; exists for weird things that aren't the standard Shapes and for use in ShapeGroup's handler


intersects

public int intersects(ShapeGroup s)
ShapeGroup intersection handler Calls intersects() for each AbstractShape in the group and returns the closest.


getIntersection

protected java.awt.Point getIntersection(java.awt.Point start,
                                         double angle,
                                         AbstractShape s)
getIntersection: get the intersection of the line starting at start with angle ( radians ) with the AbstractShape s Return the Point of intersection with the "wall" of the Frame if not found, or the point of intersection with the bounding box of s if found intersection() exploits this for shape-specific distances


distance

protected static final double distance(java.awt.Point p1,
                                       java.awt.Point p2)
convenience static method to compute distance between 2 points


center

protected final java.awt.Point center()
convenience method to get the center of Shape