Package drawit

Class RoundedPolygon

java.lang.Object
drawit.RoundedPolygon

public class RoundedPolygon
extends Object
The color of a rounded polygon is not null.
  • Constructor Details

    • RoundedPolygon

      public RoundedPolygon()
      Initializes this rounded polygon with the color yellow.
  • Method Details

    • getVertices

      public IntPoint[] getVertices()
    • getRadius

      public int getRadius()
    • getColor

      public Color getColor()
      Returns the color of this rounded polygon.
    • setVertices

      public void setVertices​(IntPoint[] newVertices)
    • setRadius

      public void setRadius​(int radius)
    • setColor

      public void setColor​(Color color)
      Sets the color of this rounded polygon to the given color.
    • insert

      public void insert​(int index, IntPoint point)
    • remove

      public void remove​(int index)
    • update

      public void update​(int index, IntPoint point)
    • contains

      public boolean contains​(IntPoint point)
    • getDrawingCommands

      public String 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, and fill. Each argument is a decimal representation of a floating-point number (or, in the case of fill, 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 angle Math.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 preceding line and arc operators with the color defined by the given R (red), G (green), and B (blue) components.

      Note: the line and arc commands serve only to define a shape to be filled; without a subsequent fill 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