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 });
JavaFX 2.0
  • Constructor Details

    • Polygon

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

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

    • getPoints

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

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