public class Polygon extends Figure
Constructor and Description |
---|
Polygon(Coordinate p1,
Coordinate p2,
Coordinate... ps)
Constructor
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(double x,
double y,
DrawContext ctx)
Returns true if the polygon contains the given x and y coordinates within the given draw context.
|
void |
draw(java.awt.Graphics2D gc,
DrawContext ctx)
Draws the polygon (this is called by the study framework).
|
java.awt.Color |
getFillColor()
Gets the color for drawing the fill (null for no fill).
|
java.awt.Color |
getLineColor()
Gets the color for drawing the outline.
|
java.awt.Stroke |
getStroke()
Gets the stroke for displaying the outline.
|
boolean |
isShowFill()
Gets the show fill attribute
|
boolean |
isShowOutline()
Gets the show outline attribute
|
boolean |
isVisible(DrawContext ctx)
Returns true if the polygon is currently visible within the given draw context.
|
void |
layout(DrawContext ctx)
Lays out the polygon by converting the start and end coordinates to x,y
coordinates on the graph.
|
void |
setFillColor(java.awt.Color color)
Sets the color for drawing the fill (null for no fill).
|
void |
setLineColor(java.awt.Color color)
Sets the color of the line used to draw the outline.
|
void |
setShowFill(boolean b)
Sets the display of the fill.
|
void |
setShowOutline(boolean b)
Sets the display of the outline.
|
void |
setStroke(java.awt.Stroke stroke)
Sets the stroke for displaying the outline.
|
public Polygon(Coordinate p1, Coordinate p2, Coordinate... ps)
p1
- first point in the polygonp2
- second point in the polygonps
- remaining points in the polygonpublic void setShowOutline(boolean b)
b
- true if the outline of the polygon should be displayedpublic boolean isShowOutline()
public void setShowFill(boolean b)
b
- true if the fill color should be displayedpublic boolean isShowFill()
public java.awt.Color getLineColor()
public void setLineColor(java.awt.Color color)
color
- outline colorpublic java.awt.Color getFillColor()
public void setFillColor(java.awt.Color color)
color
- fill colorpublic void setStroke(java.awt.Stroke stroke)
stroke
- public java.awt.Stroke getStroke()
public boolean isVisible(DrawContext ctx)
public boolean contains(double x, double y, DrawContext ctx)
public void layout(DrawContext ctx)
public void draw(java.awt.Graphics2D gc, DrawContext ctx)