Package app.media
Class PolygonShape
java.lang.Object
app.media.Media
app.media.GenericShape
app.media.PolygonShape
- All Implemented Interfaces:
Serializable
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:
-
Property Summary
-
Field Summary
-
Constructor Summary
ConstructorDescriptionPolygonShape
(javafx.geometry.Point2D p1, javafx.geometry.Point2D p2, String colour, double radius, double startAngle, int sideCount) Initializes a polygon with the following settings -
Method Summary
Modifier and TypeMethodDescriptiondouble
Returns the radius of the polygonint
Returns the number of sides of the polygondouble
Returns the starting angle of the polygonvoid
setRadius
(double radius) Sets the radius of the polygonvoid
setSideCount
(int sideCount) Sets the side count of the polygonvoid
setStartAngle
(double startAngle) Sets the starting angle of the polygontoString()
Returns the shape's type, position, dimensions and colorMethods inherited from class app.media.GenericShape
getColour, getP1, getP2, setColour, setP1, setP2
Methods inherited from class app.media.Media
angleProperty, getAngle, getHeight, getID, getName, getTags, getWidth, getX, getY, getZindex, heightProperty, isWithin, nameProperty, setAngle, setHeight, setID, setName, setTags, setWidth, setX, setY, setZindex, widthProperty, xProperty, yProperty, zIndexProperty
-
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 centerp2
- The position which determines the polygon's radius and starting anglecolour
- The shape's colorradius
- The shape's radiusstartAngle
- The shape's starting anglesideCount
- The number of sides the shape has
-
-
Method Details
-
getRadius
public double getRadius()Returns the radius of the polygonSince 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 polygonMore 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 polygonMore 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
Returns the shape's type, position, dimensions and colorAdditionally, returns the starting angular offset and side count (unique to polygon)
-