cse115.graphics
Interface Graphic

All Superinterfaces:
CenterLocatable, Locatable, Rotatable, Sizeable
All Known Subinterfaces:
ColorableGraphic, MovingBody, Shape
All Known Implementing Classes:
AbstractColorableGraphic, AbstractGraphic, BouncingBall, BouncingSquare, BouncingTriangle, CompoundGraphic, Ellipse, Eye, Fish, Fish, FramedEllipse, FramedRectangle, Image, Mouth, MovingBodyAdapter, Oval, Painter, Polygon, Rectangle, Rectangle, Rectangle3D, Triangle

public interface Graphic
extends Sizeable, CenterLocatable, Rotatable

The interface that defines the capabilites for an object that is a Graphic

Author:
Michael Kozelsky Created on: Jul 27, 2006 Graphic.java

Method Summary
 void actualPaint(Graphics2D gs, Point location, Dimension dimension)
          This method uses the Graphics2D object to paint the actual shape onto the Container.
 void addMouseListener(MouseListener ml)
          Adds a java.awt.event.MouseListener onto this graphic TODO: remove mouse listener?
 void addMouseMotionListener(MouseMotionListener mml)
          Adds a java.awt.event.MouseMotionListener onto this graphic TODO: remove listener?
 boolean contains(Point p)
          Checks whether a given point is contained within this graphic
 Rectangle getBounds()
          Returns the bounding box of this graphic
 Collection<MouseListener> getMouseListeners()
          Returns all the java.awt.event.MouseListeners of this graphic
 Collection<MouseMotionListener> getMouseMotionListeners()
          Returns all the java.awt.event.MouseMotionListeners of this graphic
 Shape getShape()
          Should return a java.awt.Shape representation of this graphic.
 boolean intersects(Graphic shape)
          In Beta Testing Tests to see if two Graphics intersect with each other.
 void paint(Graphics2D gs)
          This method uses the Graphics2D object to paint itself onto its container
 void setContainer(IContainer container)
          This sets the container of this graphic
 
Methods inherited from interface cse115.graphics.Sizeable
getDimension, setDimension
 
Methods inherited from interface cse115.graphics.CenterLocatable
getCenterLocation, setCenterLocation
 
Methods inherited from interface cse115.graphics.Locatable
getLocation, move, setLocation
 
Methods inherited from interface cse115.graphics.Rotatable
getRotation, rotate, setRotation
 

Method Detail

setContainer

void setContainer(IContainer container)
This sets the container of this graphic

Parameters:
container - the container which will contain this graphic

getBounds

Rectangle getBounds()
Returns the bounding box of this graphic

Returns:
a java.awt.Rectangle representing the bounds

contains

boolean contains(Point p)
Checks whether a given point is contained within this graphic

Parameters:
p - The point to check
Returns:
true if this graphic contains p false if not

getShape

Shape getShape()
Should return a java.awt.Shape representation of this graphic. The shape is used as a delegate for the methods: contains, intersects, etc.

Returns:
a java.awt.Shape

paint

void paint(Graphics2D gs)
This method uses the Graphics2D object to paint itself onto its container

Parameters:
gs - The Graphics2D object used to do the painting

actualPaint

void actualPaint(Graphics2D gs,
                 Point location,
                 Dimension dimension)
This method uses the Graphics2D object to paint the actual shape onto the Container.

Parameters:
gs - The Graphics2D object used to do the painting
location - The offset at which to paint this graphic
dimension - The dimension this graphic

addMouseListener

void addMouseListener(MouseListener ml)
Adds a java.awt.event.MouseListener onto this graphic TODO: remove mouse listener?

Parameters:
ml - The java.awt.event.MouseListener to listen on this graphic

getMouseListeners

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

Returns:
Returns a collection containing all the java.awt.event.MouseListeners of this graphic

addMouseMotionListener

void addMouseMotionListener(MouseMotionListener mml)
Adds a java.awt.event.MouseMotionListener onto this graphic TODO: remove listener?

Parameters:
mml - The java.awt.event.MouseMotionListener to listen on this graphic

getMouseMotionListeners

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

Returns:
Returns a collection containing all the java.awt.event.MouseMotionListeners of this graphic

intersects

boolean intersects(Graphic shape)
In Beta Testing Tests to see if two Graphics intersect with each other.

Parameters:
shape - the graphic to test for intersection
Returns:
true if this graphic intersects with g