# Class GRegPoly

All Implemented Interfaces:
`Cloneable`, `Iterable<GPoint>`

public class GRegPoly extends GPoly
Author:
Federico Vera <[email protected]>
• ## Field Summary

### Fields inherited from class com.dkt.graphics.elements.GMultiPoint

`modCount, mutex, size, xs, ys`

### Fields inherited from class com.dkt.graphics.elements.GraphicE

`STROKE`
• ## Constructor Summary

Constructors
Constructor
Description
```GRegPoly(int x, int y, int r, int n, double a)```
Constructs a regular polygon contained in a circle
`GRegPoly(GRegPoly e)`
Copy constructor
• ## Method Summary

Modifier and Type
Method
Description
`double`
`area()`
Calculates the area of this polygon
`GRegPoly`
`clone()`

`boolean`
```contains(int xx, int yy)```
Tells if a point is contained in the polygon
`boolean`
`contains(GPoint p)`
Tells if a `GPoint` is contained in the polygon
`boolean`
`equals(Object obj)`

`int`
`getRadius()`
Returns the radius of the circle used to create
`int`
`getX()`
Retrieves the X coordinate of the center of the polygon
`int`
`getY()`
Retrieves the Y coordinate of the center of the polygon
`int`
`hashCode()`

`double`
`perimeter()`
Calculated the perimeter of this polygon
`void`
`radRotate(double angle)`
Rotates the current `GRegPoly` a given angle
`void`
`rotate(double angle)`
Rotates the current `GRegPoly` a given angle
`void`
```traslate(int x, int y)```
Traslates this element on X and Y

### Methods inherited from class com.dkt.graphics.elements.GPoly

`draw`

### Methods inherited from class com.dkt.graphics.elements.GMultiPoint

`append, append, appendNR, clear, ensureCapacity, getPointAt, getPoints, getShape, indexOf, indexOf, indexOf, indexOf, isEmpty, iterator, remove, remove, remove, size, sortByX, trimToSize`

### Methods inherited from class com.dkt.graphics.elements.GFillableE

`fill, getFillPaint, setFill, setFillPaint`

### Methods inherited from class com.dkt.graphics.elements.GraphicE

`getPaint, getStroke, setPaint, setStroke`

### Methods inherited from class java.lang.Object

`finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface java.lang.Iterable

`forEach, spliterator`
• ## Constructor Details

• ### GRegPoly

public GRegPoly(GRegPoly e)
Copy constructor
Parameters:
`e` - `GRegPoly` to copy
Throws:
`IllegalArgumentException` - if `e` is `null`
• ### GRegPoly

public GRegPoly(int x, int y, int r, int n, double a)
Constructs a regular polygon contained in a circle
Parameters:
`x` - X coordinate of the center of the circle
`y` - Y coordinate of the center of the circle
`r` - radius of the circle
`n` - number of sides
`a` - angle of the first point
• ## Method Details

• ### getX

public int getX()
Retrieves the X coordinate of the center of the polygon
Returns:
x coordinate of the center
• ### getY

public int getY()
Retrieves the Y coordinate of the center of the polygon
Returns:
y coordinate of the center

Returns the radius of the circle used to create
Returns:
• ### area

public double area()
Calculates the area of this polygon
Returns:
area of the polygon
• ### perimeter

public double perimeter()
Calculated the perimeter of this polygon
Returns:
perimeter
• ### contains

public boolean contains(GPoint p) throws IllegalArgumentException
Tells if a `GPoint` is contained in the polygon
Parameters:
`p` - `GPoint` to evaluate
Returns:
`true` if the point is contained and `false` otherwise
Throws:
`IllegalArgumentException` - if `p` is `null`
• ### contains

public boolean contains(int xx, int yy)
Tells if a point is contained in the polygon
Parameters:
`xx` - X coordinate of the point
`yy` - Y coordinate of the point
Returns:
`true` if the point is contained and `false` otherwise
• ### rotate

public void rotate(double angle)
Rotates the current `GRegPoly` a given angle
Parameters:
`angle` - angle in degrees

public void radRotate(double angle)
Rotates the current `GRegPoly` a given angle
Parameters:
`angle` - angle in radians
• ### traslate

public void traslate(int x, int y)
Description copied from class: `GraphicE`
Traslates this element on X and Y
Overrides:
`traslate` in class `GMultiPoint`
Parameters:
`x` - size in `px` of the horizontal translation
`y` - size in `px` of the vertical translation
• ### clone

public GRegPoly clone()
Overrides:
`clone` in class `GPoly`
• ### hashCode

public int hashCode()
Overrides:
`hashCode` in class `GMultiPoint`
• ### equals

public boolean equals(Object obj)
Overrides:
`equals` in class `GMultiPoint`