Class Polygon

  • All Implemented Interfaces:
    Styleable, EventTarget

    public class Polygon
    extends Shape
    Creates a polygon, defined by an array of x,y coordinates. The Polygon class is similar to the Polyline class, except that the Polyline class is not automatically closed.
    import javafx.scene.shape.*;
    
    Polygon polygon = new Polygon();
    polygon.getPoints().addAll(new Double[]{
        0.0, 0.0,
        20.0, 10.0,
        10.0, 20.0 });
    
    Since:
    JavaFX 2.0
    • Constructor Detail

      • Polygon

        public Polygon()
        Creates an empty instance of Polygon.
      • Polygon

        public Polygon​(double... points)
        Creates a new instance of Polygon.
        Parameters:
        points - the coordinates of the polygon vertices
    • Method Detail

      • getPoints

        public final ObservableList<Double> getPoints()
        Gets the coordinates of the Polygon vertices.
        Returns:
        An observable list of vertices of this Polygon
      • toString

        public String toString()
        Returns a string representation of this Polygon object.
        Overrides:
        toString in class Node
        Returns:
        a string representation of this Polygon object.