Class PolylineElement

java.lang.Object
com.vaadin.flow.dom.Node<com.vaadin.flow.dom.Element>
com.vaadin.flow.dom.Element
All Implemented Interfaces:
Serializable

public class PolylineElement extends SvgGraphicsElement
A typed Java API for the SVG <polyline> element.

The <polyline> element defines a shape consisting of a set of connected straight line segments. Unlike a polygon, the last point is NOT automatically connected to the first point.

For a closed shape (where the last point connects to the first), use a polygon element instead.

Write-Only vs Read-Write Methods

This class provides two variants for attribute setters:

  • Default methods (e.g., points(), pathLength()) - Use an optimized write-only approach. Attribute values are NOT stored on the server and cannot be retrieved via getAttribute().
  • RW methods (e.g., pointsRW(), pathLengthRW()) - Use traditional setAttribute() which stores values on the server for later retrieval.
See Also:
  • Constructor Details

    • PolylineElement

      public PolylineElement()
  • Method Details

    • points

      public PolylineElement points(String points)
      Sets the points directly as a string.

      This replaces any points added using the fluent methods.

      Uses write-only optimization. Use pointsRW(String) if you need to read the value back.

      Parameters:
      points - the points string (e.g., "0,40 40,40 40,80 80,80 80,120")
      Returns:
      this element for method chaining
    • pointsRW

      public PolylineElement pointsRW(String points)
      Sets the points directly as a string (read-write).

      This replaces any points added using the fluent methods.

      Parameters:
      points - the points string (e.g., "0,40 40,40 40,80 80,80 80,120")
      Returns:
      this element for method chaining
    • points

      public PolylineElement points(double... coords)
      Sets the points from an array of coordinate pairs.

      Each pair of values represents an x,y coordinate.

      Parameters:
      coords - the coordinates as x1,y1,x2,y2,... sequence
      Returns:
      this element for method chaining
    • addPoint

      public PolylineElement addPoint(double x, double y)
      Adds a point to the polyline.
      Parameters:
      x - the x coordinate
      y - the y coordinate
      Returns:
      this element for method chaining
    • addPoints

      public PolylineElement addPoints(double... coords)
      Adds multiple points to the polyline.
      Parameters:
      coords - the coordinates as x1,y1,x2,y2,... sequence
      Returns:
      this element for method chaining
    • clearPoints

      public PolylineElement clearPoints()
      Clears all points from the polyline.
      Returns:
      this element for method chaining
    • pathLength

      public PolylineElement pathLength(double pathLength)
      Sets the total length for the polyline in user units.

      Uses write-only optimization. Use pathLengthRW(double) if you need to read the value back.

      Parameters:
      pathLength - the total path length
      Returns:
      this element for method chaining
    • pathLengthRW

      public PolylineElement pathLengthRW(double pathLength)
      Sets the total length for the polyline in user units (read-write).
      Parameters:
      pathLength - the total path length
      Returns:
      this element for method chaining