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 java.lang.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(java.awt.event.MouseListener ml)
          Adds a java.awt.event.MouseListener to this graphic
 void addMouseMotionListener(java.awt.event.MouseMotionListener mml)
          Adds a java.awt.event.MouseMotionListener to this graphic
 boolean contains(java.awt.Point p)
          Tests to see if the given point is contained within this shape
 java.awt.Rectangle getBounds()
          Returns the BoundingBox of this graphic
 java.awt.Point getCenterLocation()
          Gets the Center location of this graphic
 IContainer getContainer()
          Gets the Container of this graphic
 java.awt.Dimension getDimension()
          Gets the dimension of this graphic
 java.awt.Point getLocation()
          Gets the location of this graphic
 java.util.Collection<java.awt.event.MouseListener> getMouseListeners()
          Gets all the java.awt.event.MouseListeners of this graphic
 java.util.Collection<java.awt.event.MouseMotionListener> getMouseMotionListeners()
          Gets all the java.awt.event.MouseMotionListeners of this graphic
 IGraphicMovement getMovement()
          Gets the current movement of the graphic
 java.lang.Integer getRotation()
          Gets the current rotation of this graphic
 boolean intersects(IGraphic g)
          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(java.awt.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(java.lang.Integer degreesToRotate)
          Rotates the graphic by a specific number of degrees
 void setCenterLocation(java.awt.Point point)
          Changes the center location of this graphic
 void setContainer(IContainer container)
          Sets the Container of this Graphic.
 void setDimension(java.awt.Dimension d)
          Changes the Dimension of this Graphic
 void setLocation(java.awt.Point point)
          Changes the location of this graphic
 void setMovement(IGraphicMovement movement)
          Changes how the graphic moves
 void setRotation(java.lang.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(java.awt.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(java.awt.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 java.awt.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(java.awt.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 java.awt.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(java.awt.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 java.awt.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)
Changes how the graphic moves

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

getMovement

public IGraphicMovement getMovement()
Gets the current movement of the graphic

Specified by:
getMovement in interface IGraphic
Returns:
this graphics' IGraphicMovement
See Also:
IGraphic.getMovement()

setRotation

public void setRotation(java.lang.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 java.lang.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(java.lang.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(java.awt.event.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 java.util.Collection<java.awt.event.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(java.awt.event.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 java.util.Collection<java.awt.event.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 java.awt.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(java.awt.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)
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)