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
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoublearea()Calculates the area of this polygonclone()booleancontains(int xx, int yy) Tells if a point is contained in the polygonbooleanTells if aGPointis contained in the polygonbooleanintReturns the radius of the circle used to createintgetX()Retrieves the X coordinate of the center of the polygonintgetY()Retrieves the Y coordinate of the center of the polygoninthashCode()doubleCalculated the perimeter of this polygonvoidradRotate(double angle) Rotates the currentGRegPolya given anglevoidrotate(double angle) Rotates the currentGRegPolya given anglevoidtraslate(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, trimToSizeMethods inherited from class com.dkt.graphics.elements.GFillableE
fill, getFillPaint, setFill, setFillPaintMethods inherited from class com.dkt.graphics.elements.GraphicE
getPaint, getStroke, setPaint, setStrokeMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
GRegPoly
Copy constructor- Parameters:
e-GRegPolyto copy- Throws:
IllegalArgumentException- ifeisnull
-
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 aGPointis contained in the polygon- Parameters:
p-GPointto evaluate- Returns:
trueif the point is contained andfalseotherwise- Throws:
IllegalArgumentException- ifpisnull
-
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:
trueif the point is contained andfalseotherwise
-
rotate
public void rotate(double angle) Rotates the currentGRegPolya given angle- Parameters:
angle- angle in degrees
-
radRotate
public void radRotate(double angle) Rotates the currentGRegPolya given angle- Parameters:
angle- angle in radians
-
traslate
public void traslate(int x, int y) Description copied from class:GraphicETraslates this element on X and Y- Overrides:
traslatein classGMultiPoint- Parameters:
x- size inpxof the horizontal translationy- size inpxof the vertical translation
-
clone
-
hashCode
public int hashCode()- Overrides:
hashCodein classGMultiPoint
-
equals
- Overrides:
equalsin classGMultiPoint
-