cs015.SketchySupport
Class PolygonShape

java.lang.Object
  extended byNGP.Graphics.Shape
      extended bycs015.SketchySupport.PolygonShape
All Implemented Interfaces:
Colorable, java.util.EventListener, Graphic, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, Reactor, Rotatable, Sizeable
Direct Known Subclasses:
FilledPolygonShape, FramedPolygonShape

public abstract class PolygonShape
extends Shape
implements Sizeable

Used for defining non-rectangular geometric shapes.

Author:
Brent Shields (bshields)

Field Summary
 
Fields inherited from class NGP.Graphics.Shape
_awtShape, _dpanel
 
Fields inherited from interface NGP.Colorable
DEFAULT_GRAY
 
Constructor Summary
PolygonShape(DrawingPanel dp, java.awt.Polygon p)
          Create a PolygonShape in the specified drawing panel with the given polygon
 
Method Summary
 java.awt.Point getCenterLocation()
          Get the location of this PolygonShape.
 java.awt.Dimension getDimension()
          Get the dimensions of this PolygonShape.
 void setCenterLocation(java.awt.Point p)
          Set the location of this PolygonShape.
 void setDimension(java.awt.Dimension d)
          Set the dimensions of this PolygonShape.
 void show()
          Make the shape appear
 
Methods inherited from class NGP.Graphics.Shape
actualPaint, contains, drag, getBounds, getColor, getDrawingPanel, getRotation, hide, intersects, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, paint, react, setColor, setDrawingPanel, setRotation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PolygonShape

public PolygonShape(DrawingPanel dp,
                    java.awt.Polygon p)
Create a PolygonShape in the specified drawing panel with the given polygon

Parameters:
dp - the DrawingPanel for this Shape
p - the Polygon that describes this Shape
Method Detail

show

public void show()
Make the shape appear

Specified by:
show in interface Graphic

getDimension

public java.awt.Dimension getDimension()
Get the dimensions of this PolygonShape.

Specified by:
getDimension in interface Sizeable
Returns:
the Dimension of this PolygonShape

setDimension

public void setDimension(java.awt.Dimension d)
Set the dimensions of this PolygonShape.

Specified by:
setDimension in interface Sizeable
Parameters:
d - the new Dimension of this PolygonShape

getCenterLocation

public java.awt.Point getCenterLocation()
Get the location of this PolygonShape. The position of PolygonShapes are determined by the center of their bounding rectangle. Therefore, this point will be in the center of the polygon, not the upper left hand corner of it.

Specified by:
getCenterLocation in interface Graphic
Returns:
the Point of this PolygonShape

setCenterLocation

public void setCenterLocation(java.awt.Point p)
Set the location of this PolygonShape. The position of PolygonShapes are determined by the center of their bounding rectangle. Therefore, this point will be in the center of the polygon, not the upper left hand corner of it.

Parameters:
p - the new Point for this PolygonShape