graphics
Class AbstractGraphic

java.lang.Object
  extended by graphics.AbstractGraphic
All Implemented Interfaces:
CenterLocatable, IGraphic, ILocatable, IRotatable, ISizeable
Direct Known Subclasses:
AbstractColorableGraphic, CompoundGraphic, Image

public abstract class AbstractGraphic
extends Object
implements IGraphic

An abstract class that is the superclass for most graphics. Defines most capabilities that are shared among all Graphic shapes

Author:
Michael Kozelsky Created on: Jul 28, 2006 AbstractGraphic.java

Constructor Summary
AbstractGraphic()
          Creates a new instance of AbstractGraphic with a default size (0,0); location (0,0); and rotation (0)
 
Method Summary
 void addMouseListener(MouseListener ml)
          Adds a java.awt.event.MouseListener to this graphic
 void addMouseMotionListener(MouseMotionListener mml)
          Adds a java.awt.event.MouseMotionListener to this graphic
 boolean contains(Point p)
          Tests to see if the given point is contained within this shape
 Rectangle getBounds()
          Returns the BoundingBox of this graphic
 Point getCenterLocation()
          Gets the Center location of this graphic
 IContainer getContainer()
          Gets the Container of this graphic
 Dimension getDimension()
          Gets the dimension of this graphic
 Point getLocation()
          Gets the location of this graphic
 Collection<MouseListener> getMouseListeners()
          Gets all the java.awt.event.MouseListeners of this graphic
 Collection<MouseMotionListener> getMouseMotionListeners()
          Gets all the java.awt.event.MouseMotionListeners of this graphic
 Integer getRotation()
          Gets the current rotation of this graphic
 boolean intersects(IGraphic g)
          In Beta Testing Tests to see if two Graphics intersect with each other.
 Vector move(Vector v)
          Moves the Graphic by a certain vector, according to it's current MovementBehavior
 void paint(Graphics2D gs)
          This gets the concrete subclasses ready to do the actual painting - it figures out a rotation, then delegates the drawing to the specific subclass
 void rotate(Integer degreesToRotate)
          Rotates the graphic by a specific number of degrees
 void setCenterLocation(Point point)
          Changes the center location of this graphic
 void setContainer(IContainer container)
          Sets the Container of this Graphic.
 void setDimension(Dimension d)
          Changes the Dimension of this Graphic
 void setLocation(Point point)
          Changes the location of this graphic
 void setMovement(IGraphicMovement movement)
          Sets the movement of the Graphic.
 void setRotation(Integer degree)
          Changes the rotation of this graphic.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface graphics.IGraphic
actualPaint, getShape
 

Constructor Detail

AbstractGraphic

public AbstractGraphic()
Creates a new instance of AbstractGraphic with a default size (0,0); location (0,0); and rotation (0)

Method Detail

getContainer

public IContainer getContainer()
Gets the Container of this graphic

Specified by:
getContainer in interface IGraphic
Returns:
the IContainer that this graphic is contained in. Returns null if this does not have an IContainer
See Also:
setContainer(IContainer container)

setContainer

public void setContainer(IContainer container)
Sets the Container of this Graphic. Should be automatically called inside the addGraphic method of the IContainer that contains this graphic

Specified by:
setContainer in interface IGraphic
Parameters:
container -

paint

public void paint(Graphics2D gs)
This gets the concrete subclasses ready to do the actual painting - it figures out a rotation, then delegates the drawing to the specific subclass

Specified by:
paint in interface IGraphic
Parameters:
gs - The Graphics2D object that draws the shapes on the IContainer
See Also:
IGraphic.paint(java.awt.Graphics2D)

setDimension

public void setDimension(Dimension d)
Changes the Dimension of this Graphic

Specified by:
setDimension in interface ISizeable
Parameters:
d - the new Dimension
See Also:
ISizeable.setDimension(java.awt.Dimension), getDimension()

getDimension

public Dimension getDimension()
Gets the dimension of this graphic

Specified by:
getDimension in interface ISizeable
Returns:
the Dimension of this graphic
See Also:
ISizeable.getDimension(), setDimension(java.awt.Dimension)

setLocation

public void setLocation(Point point)
Changes the location of this graphic

Specified by:
setLocation in interface ILocatable
Parameters:
point - The new location to put the graphic
See Also:
ILocatable.setLocation(java.awt.Point)

getLocation

public Point getLocation()
Gets the location of this graphic

Specified by:
getLocation in interface ILocatable
Returns:
The current location
See Also:
ILocatable.getLocation()

setCenterLocation

public void setCenterLocation(Point point)
Changes the center location of this graphic

Specified by:
setCenterLocation in interface CenterLocatable
Parameters:
point - the location to place the center of this graphic at
See Also:
CenterLocatable.setCenterLocation(java.awt.Point)

getCenterLocation

public Point getCenterLocation()
Gets the Center location of this graphic

Specified by:
getCenterLocation in interface CenterLocatable
Returns:
a Point representing the location at the center of this graphic
See Also:
CenterLocatable.getCenterLocation()

move

public Vector move(Vector v)
Moves the Graphic by a certain vector, according to it's current MovementBehavior

Specified by:
move in interface ILocatable
Parameters:
v - The vector containing the amount to move
See Also:
ILocatable.move(utilities.Vector)

setMovement

public void setMovement(IGraphicMovement movement)
Description copied from interface: IGraphic
Sets the movement of the Graphic. A movement should be a definition of how this will react to the move() method.

Specified by:
setMovement in interface IGraphic
Parameters:
movement -
See Also:
IGraphic.setMovement(graphics.movement.IGraphicMovement)

setRotation

public void setRotation(Integer degree)
Changes the rotation of this graphic. Should rotate about its center

Specified by:
setRotation in interface IRotatable
Parameters:
degree - The number of degrees to set the rotation at
See Also:
IRotatable.setRotation(java.lang.Integer)

getRotation

public Integer getRotation()
Gets the current rotation of this graphic

Specified by:
getRotation in interface IRotatable
Returns:
an Integer (0 through 359) representing the rotation of this graphic
See Also:
IRotatable.getRotation()

rotate

public void rotate(Integer degreesToRotate)
Rotates the graphic by a specific number of degrees

Specified by:
rotate in interface IRotatable
Parameters:
degreesToRotate - The number of degrees to rotate this graphic
See Also:
IRotatable.rotate(java.lang.Integer)

addMouseListener

public void addMouseListener(MouseListener ml)
Adds a java.awt.event.MouseListener to this graphic

Specified by:
addMouseListener in interface IGraphic
Parameters:
ml -
See Also:
IGraphic.addMouseListener(java.awt.event.MouseListener)

getMouseListeners

public Collection<MouseListener> getMouseListeners()
Gets all the java.awt.event.MouseListeners of this graphic

Specified by:
getMouseListeners in interface IGraphic
Returns:
a Collection of MouseListeners
See Also:
IGraphic.getMouseListeners()

addMouseMotionListener

public void addMouseMotionListener(MouseMotionListener mml)
Adds a java.awt.event.MouseMotionListener to this graphic

Specified by:
addMouseMotionListener in interface IGraphic
Parameters:
mml - The java.awt.event.MouseMotionListener to add to the
See Also:
IGraphic.addMouseMotionListener(java.awt.event.MouseMotionListener)

getMouseMotionListeners

public Collection<MouseMotionListener> getMouseMotionListeners()
Gets all the java.awt.event.MouseMotionListeners of this graphic

Specified by:
getMouseMotionListeners in interface IGraphic
Returns:
A collection of all the MouseMotionListeners of this graphic
See Also:
IGraphic.getMouseMotionListeners()

getBounds

public Rectangle getBounds()
Returns the BoundingBox of this graphic

Specified by:
getBounds in interface IGraphic
Returns:
A java.awt.Rectangle representing the bounding box of this graphic
See Also:
IGraphic.getBounds()

contains

public boolean contains(Point p)
Tests to see if the given point is contained within this shape

Specified by:
contains in interface IGraphic
Parameters:
p - The point to test for containment
Returns:
true if the point is contained in the ellipse, false otherwise
See Also:
IGraphic.contains(java.awt.Point)

intersects

public boolean intersects(IGraphic g)
In Beta Testing Tests to see if two Graphics intersect with each other.

Specified by:
intersects in interface IGraphic
Parameters:
g - the graphic to test for intersection
Returns:
true if this graphic intersects with g
See Also:
IGraphic.intersects(graphics.IGraphic)