NGP
Interface Graphic

All Superinterfaces:
EventListener, MouseListener, MouseMotionListener, Reactor, Rotatable
All Known Implementing Classes:
Image, Shape, Text

public interface Graphic
extends Reactor, Rotatable

Indicates the basic methods that all graphical objects should implement. All Graphics have the ability to react when clicked on with the mouse. In addition they know how to paint themselves on the screen, hide themselves, show themselves, change their DrawingPanel, rotate, and determine if another Graphic intersects with them.

Author:
Matt Chotin (mhc)

Method Summary
 boolean contains(Point p)
          Determine whether this Graphic's bounding rectangle contains the passed in Point.
 Rectangle getBounds()
          Return a copy of this Graphic's bounding rectangle.
 Point getCenterLocation()
          Return a Point that represents the center of the Graphic.
 DrawingPanel getDrawingPanel()
          Get the DrawingPanel where this Graphic is being drawn.
 void hide()
          Set the Graphic so it does not paint.
 boolean intersects(Graphic g)
          Determine whether another Graphic's bounding rectangle intersects with this Graphic's bounding rectangle
 void paint(Graphics2D g)
          Normal users need not call this method!
 void setDrawingPanel(DrawingPanel dp)
          Set the DrawingPanel where this Graphic should be drawn.
 void show()
          Set the Graphic so it paints.
 
Methods inherited from interface NGP.Reactor
react
 
Methods inherited from interface java.awt.event.MouseListener
mouseClicked, mouseEntered, mouseExited, mousePressed, mouseReleased
 
Methods inherited from interface java.awt.event.MouseMotionListener
mouseDragged, mouseMoved
 
Methods inherited from interface NGP.Rotatable
getRotation, setRotation
 

Method Detail

paint

public void paint(Graphics2D g)
Normal users need not call this method!

Using the passed in Graphics2D paint this Graphic.

Parameters:
g - the Graphics2D to use when painting

hide

public void hide()
Set the Graphic so it does not paint.


show

public void show()
Set the Graphic so it paints.


setDrawingPanel

public void setDrawingPanel(DrawingPanel dp)
Set the DrawingPanel where this Graphic should be drawn.

Parameters:
dp - the DrawingPanel to use
See Also:
getDrawingPanel

getDrawingPanel

public DrawingPanel getDrawingPanel()
Get the DrawingPanel where this Graphic is being drawn.

Returns:
this Graphic's DrawingPanel
See Also:
setDrawingPanel

contains

public boolean contains(Point p)
Determine whether this Graphic's bounding rectangle contains the passed in Point. One use of his method is to determine if a Graphic should react.

Parameters:
p - the Point to check for containment
Returns:
true if the Point is contained, false otherwise

intersects

public boolean intersects(Graphic g)
Determine whether another Graphic's bounding rectangle intersects with this Graphic's bounding rectangle

Returns:
true if it does intersect, false if not
See Also:
getBounds

getBounds

public Rectangle getBounds()
Return a copy of this Graphic's bounding rectangle. Every Graphic uses has a bounding rectangle to help define its space.

Returns:
the java.awt.Rectangle which defines the bounds

getCenterLocation

public Point getCenterLocation()
Return a Point that represents the center of the Graphic. It's really done by getting the bounds and getting the center of that.

Returns:
the java.awt.Point that represents the center