Package drawit
Class RoundedPolygon
java.lang.Object
drawit.RoundedPolygon
public class RoundedPolygon extends Object
The color of a rounded polygon is not null.
-
Constructor Summary
Constructors Constructor Description RoundedPolygon()
Initializes this rounded polygon with the color yellow. -
Method Summary
Modifier and Type Method Description boolean
contains(IntPoint point)
Color
getColor()
Returns the color of this rounded polygon.String
getDrawingCommands()
Returns a textual representation of a set of drawing commands for drawing this rounded polygon.int
getRadius()
IntPoint[]
getVertices()
void
insert(int index, IntPoint point)
void
remove(int index)
void
setColor(Color color)
Sets the color of this rounded polygon to the given color.void
setRadius(int radius)
void
setVertices(IntPoint[] newVertices)
void
update(int index, IntPoint point)
-
Constructor Details
-
RoundedPolygon
public RoundedPolygon()Initializes this rounded polygon with the color yellow.
-
-
Method Details
-
getVertices
-
getRadius
public int getRadius() -
getColor
Returns the color of this rounded polygon. -
setVertices
-
setRadius
public void setRadius(int radius) -
setColor
Sets the color of this rounded polygon to the given color. -
insert
-
remove
public void remove(int index) -
update
-
contains
-
getDrawingCommands
Returns a textual representation of a set of drawing commands for drawing this rounded polygon.The returned text consists of a sequence of drawing operators and arguments, separated by spaces. The drawing operators are
line
,arc
, andfill
. Each argument is a decimal representation of a floating-point number (or, in the case offill
, an integer).- Operator
line
takes four arguments: X1 Y1 X2 Y2; it draws a line between (X1, Y1) and (X2, Y2). arc
takes five: X Y R S E. It draws a part of a circle. The circle is defined by its center (X, Y) and its radius R. The part to draw is defined by the start angle S and angle extent E, both in radians. Positive X is angle zero; positive Y is angleMath.PI / 2
; negative Y is angle-Math.PI / 2
.- Operator
fill
takes three integer arguments: R G B. R, G, and B are integers between 0 and 255. The operator fills the shape defined by the precedingline
andarc
operators with the color defined by the given R (red), G (green), and B (blue) components.
Note: the
line
andarc
commands serve only to define a shape to be filled; without a subsequentfill
command, they have no visual effect.For example, the following commands fill a rounded square with corner radius 10 with color red:
line 1 0 9 0 arc 9 1 1 -1.5707963267948966 1.5707963267948966 line 10 1 10 9 arc 9 9 1 0 1.5707963267948966 line 9 10 1 10 arc 1 9 1 1.5707963267948966 1.5707963267948966 line 0 9 0 1 arc 1 1 1 3.141592653589793 1.5707963267948966 fill 255 0 0
- Operator
-