public class Polygon extends java.lang.Object implements GraphicalPrimitive
Modifier and Type | Field and Description |
---|---|
java.awt.Color |
drawColor
The drawing color of the shape
|
java.awt.Color |
fillColor
The fill color of the shape.
|
Constructor and Description |
---|
Polygon()
Initializes an empty polygon (with no point at the beginning) with default drawing color (strong gray, half opacity)
and default fill color (gray, half opacity).
|
Polygon(java.awt.Color drawColor,
java.awt.Color fillColor)
Initializes an empty polygon (with no point at the beginning).
|
Modifier and Type | Method and Description |
---|---|
void |
addPoint(Point point)
Adds a point to the polygon (at the end of the current sequence).
|
void |
draw(java.awt.Graphics2D g2d,
CoordinateConverter converter)
The function that draws the primitive
|
BoundingBox |
getBoundingBox()
Computes the bounding box of the graphical primitive.
|
public java.awt.Color fillColor
public java.awt.Color drawColor
public Polygon(java.awt.Color drawColor, java.awt.Color fillColor)
drawColor
- the drawing color.fillColor
- the fill color.public Polygon()
public void draw(java.awt.Graphics2D g2d, CoordinateConverter converter)
GraphicalPrimitive
draw
in interface GraphicalPrimitive
g2d
- the Graphics2D object on which the shape must be drawn.converter
- the coordinate converter used to convert the primitive's coordinates into the screen (hence Graphics2D) coordinates.public BoundingBox getBoundingBox()
GraphicalPrimitive
getBoundingBox
in interface GraphicalPrimitive
public void addPoint(Point point)
point
- the point to be added.