|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object graphics.AbstractGraphic graphics.AbstractColorableGraphic graphics.Polygon
public class Polygon
A polygon is a Graphic that can form many shapes. To use, first set the desired dimension of the polygon. Then add at least three points in order to correctly make a polygon. This will then play connect the dots in the order that the points were added. Then connects the last point back to the first, forming a polygon.
For example, to create a triangle:
Constructor Summary | |
---|---|
Polygon()
Creates a new instance of Polygon with no vertices |
Method Summary | |
---|---|
void |
actualPaint(Graphics2D gs,
Point location,
Dimension dimension)
This method uses the Graphics2D object to paint the Polygon onto the container. |
void |
addPoint(Point p)
Add a point to the polygon |
Shape |
getShape()
Gets a java.awt.shape that represents this shape |
void |
removePoint(Point p)
removes the first occurrence of point p from the polygon |
void |
setDimension(Dimension d)
Resizes the Polygon to a specified dimension. |
void |
setLocation(Point point)
Sets the upper left hand corner of the polygon's bounding box. |
Methods inherited from class graphics.AbstractColorableGraphic |
---|
getColor, paint, setColor |
Methods inherited from class graphics.AbstractGraphic |
---|
addMouseListener, addMouseMotionListener, contains, getBounds, getCenterLocation, getContainer, getDimension, getLocation, getMouseListeners, getMouseMotionListeners, getRotation, intersects, move, rotate, setCenterLocation, setContainer, setMovement, setRotation |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface graphics.IGraphic |
---|
addMouseListener, addMouseMotionListener, contains, getBounds, getContainer, getMouseListeners, getMouseMotionListeners, intersects, setContainer, setMovement |
Methods inherited from interface graphics.ISizeable |
---|
getDimension |
Methods inherited from interface graphics.CenterLocatable |
---|
getCenterLocation, setCenterLocation |
Methods inherited from interface graphics.ILocatable |
---|
getLocation, move |
Methods inherited from interface graphics.IRotatable |
---|
getRotation, rotate, setRotation |
Constructor Detail |
---|
public Polygon()
Method Detail |
---|
public void addPoint(Point p)
p
- the point to addpublic void removePoint(Point p)
p
- The Point to removepublic void actualPaint(Graphics2D gs, Point location, Dimension dimension)
gs
- The Graphics2D object to do the paintinglocation
- Does nothingdimension
- Does NothingIGraphic.actualPaint(java.awt.Graphics2D,
java.awt.Point, java.awt.Dimension)
public void setLocation(Point point)
setLocation
in interface ILocatable
setLocation
in class AbstractGraphic
point
- A java.awt.Point representing the new location of the PolygonILocatable.setLocation(java.awt.Point)
public void setDimension(Dimension d)
setDimension
in interface ISizeable
setDimension
in class AbstractGraphic
d
- The dimension which the polygon should haveISizeable.setDimension(java.awt.Dimension)
public Shape getShape()
IGraphic.getShape()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |