Package app.media

Class PolygonShape

All Implemented Interfaces:
Serializable

public class PolygonShape extends GenericShape
An implementation of GenericShape representing a polygon

We assume the polygon is a regular shape, i.e. that each interior angle and each side length are the same.

See Also:
  • Constructor Details

    • PolygonShape

      public PolygonShape(javafx.geometry.Point2D p1, javafx.geometry.Point2D p2, String colour, double radius, double startAngle, int sideCount)
      Initializes a polygon with the following settings
      Parameters:
      p1 - The position of the polygon's center
      p2 - The position which determines the polygon's radius and starting angle
      colour - The shape's color
      radius - The shape's radius
      startAngle - The shape's starting angle
      sideCount - The number of sides the shape has
  • Method Details

    • getRadius

      public double getRadius()
      Returns the radius of the polygon

      Since the polygons are all regular shapes, this represents the distance from its center towards any vertex

      Returns:
      The radius of the polygon
    • getStartAngle

      public double getStartAngle()
      Returns the starting angle of the polygon

      More specifically, this is the angle the polygon is rotationally offset by

      Returns:
      The rotational offset of the polygon
    • getSideCount

      public int getSideCount()
      Returns the number of sides of the polygon
      Returns:
      the number of sides of the polygon
    • setRadius

      public void setRadius(double radius)
      Sets the radius of the polygon
      Parameters:
      radius - The desired new radius of the polygon
    • setStartAngle

      public void setStartAngle(double startAngle)
      Sets the starting angle of the polygon

      More specifically, this is the angle the Polygon is to be rotationally offset by

      Parameters:
      startAngle - The desired new rotational offset of the Polygon
    • setSideCount

      public void setSideCount(int sideCount)
      Sets the side count of the polygon
      Parameters:
      sideCount - The new number of sides the polygon should have
    • toString

      public String toString()
      Returns the shape's type, position, dimensions and color

      Additionally, returns the starting angular offset and side count (unique to polygon)

      Overrides:
      toString in class Media
      Returns:
      the shape's type, position, dimensions and color