Package com.dkt.graphics.elements
Class GRegPoly
java.lang.Object
com.dkt.graphics.elements.GraphicE
com.dkt.graphics.elements.GFillableE
com.dkt.graphics.elements.GMultiPoint
com.dkt.graphics.elements.GPoly
com.dkt.graphics.elements.GRegPoly
- Author:
- Federico Vera <[email protected]>
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondouble
area()
Calculates the area of this polygonclone()
boolean
contains
(int xx, int yy) Tells if a point is contained in the polygonboolean
Tells if aGPoint
is contained in the polygonboolean
int
Returns the radius of the circle used to createint
getX()
Retrieves the X coordinate of the center of the polygonint
getY()
Retrieves the Y coordinate of the center of the polygonint
hashCode()
double
Calculated the perimeter of this polygonvoid
radRotate
(double angle) Rotates the currentGRegPoly
a given anglevoid
rotate
(double angle) Rotates the currentGRegPoly
a given anglevoid
traslate
(int x, int y) Traslates this element on X and YMethods 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
Copy constructor- Parameters:
e
-GRegPoly
to copy- Throws:
IllegalArgumentException
- ife
isnull
-
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 circley
- Y coordinate of the center of the circler
- radius of the circlen
- number of sidesa
- 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
-
getRadius
public int getRadius()Returns the radius of the circle used to create- Returns:
- radius
-
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
Tells if aGPoint
is contained in the polygon- Parameters:
p
-GPoint
to evaluate- Returns:
true
if the point is contained andfalse
otherwise- Throws:
IllegalArgumentException
- ifp
isnull
-
contains
public boolean contains(int xx, int yy) Tells if a point is contained in the polygon- Parameters:
xx
- X coordinate of the pointyy
- Y coordinate of the point- Returns:
true
if the point is contained andfalse
otherwise
-
rotate
public void rotate(double angle) Rotates the currentGRegPoly
a given angle- Parameters:
angle
- angle in degrees
-
radRotate
public void radRotate(double angle) Rotates the currentGRegPoly
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 classGMultiPoint
- Parameters:
x
- size inpx
of the horizontal translationy
- size inpx
of the vertical translation
-
clone
-
hashCode
public int hashCode()- Overrides:
hashCode
in classGMultiPoint
-
equals
- Overrides:
equals
in classGMultiPoint
-