Class GRegPoly

All Implemented Interfaces:
Cloneable, Iterable<GPoint>

public class GRegPoly extends GPoly
Author:
Federico Vera <[email protected]>
  • 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
    • 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

      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
    • radRotate

      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