Class LineElement

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

public class LineElement extends SvgGraphicsElement
A typed Java API for the SVG <line> element.

The <line> element is a basic SVG shape that draws a straight line connecting two points.

Note: A line element must have a stroke color specified to be visible, as lines have no fill.

Write-Only vs Read-Write Methods

This class provides two variants for each attribute setter:

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

    • LineElement

      public LineElement()
  • Method Details

    • x1

      public LineElement x1(double x1)
      Sets the x-axis coordinate of the line starting point.

      Uses write-only optimization. The value is NOT stored on the server. Use x1RW(double) if you need to read the value back.

      Parameters:
      x1 - the x coordinate of the start point in user units
      Returns:
      this element for method chaining
    • x1

      public LineElement x1(String x1)
      Sets the x-axis coordinate of the line starting point with a unit or percentage.

      Uses write-only optimization. The value is NOT stored on the server. Use x1RW(String) if you need to read the value back.

      Parameters:
      x1 - the x coordinate of the start point (e.g., "10", "10%", "10px")
      Returns:
      this element for method chaining
    • x1RW

      public LineElement x1RW(double x1)
      Sets the x-axis coordinate of the line starting point (read-write).

      Uses SvgElement.setAttribute(String, String) so the value can be retrieved via Element.getAttribute(String).

      Parameters:
      x1 - the x coordinate of the start point in user units
      Returns:
      this element for method chaining
    • x1RW

      public LineElement x1RW(String x1)
      Sets the x-axis coordinate of the line starting point with a unit or percentage (read-write).

      Uses SvgElement.setAttribute(String, String) so the value can be retrieved via Element.getAttribute(String).

      Parameters:
      x1 - the x coordinate of the start point (e.g., "10", "10%", "10px")
      Returns:
      this element for method chaining
    • y1

      public LineElement y1(double y1)
      Sets the y-axis coordinate of the line starting point.

      Uses write-only optimization. The value is NOT stored on the server. Use y1RW(double) if you need to read the value back.

      Parameters:
      y1 - the y coordinate of the start point in user units
      Returns:
      this element for method chaining
    • y1

      public LineElement y1(String y1)
      Sets the y-axis coordinate of the line starting point with a unit or percentage.

      Uses write-only optimization. The value is NOT stored on the server. Use y1RW(String) if you need to read the value back.

      Parameters:
      y1 - the y coordinate of the start point (e.g., "10", "10%", "10px")
      Returns:
      this element for method chaining
    • y1RW

      public LineElement y1RW(double y1)
      Sets the y-axis coordinate of the line starting point (read-write).

      Uses SvgElement.setAttribute(String, String) so the value can be retrieved via Element.getAttribute(String).

      Parameters:
      y1 - the y coordinate of the start point in user units
      Returns:
      this element for method chaining
    • y1RW

      public LineElement y1RW(String y1)
      Sets the y-axis coordinate of the line starting point with a unit or percentage (read-write).

      Uses SvgElement.setAttribute(String, String) so the value can be retrieved via Element.getAttribute(String).

      Parameters:
      y1 - the y coordinate of the start point (e.g., "10", "10%", "10px")
      Returns:
      this element for method chaining
    • x2

      public LineElement x2(double x2)
      Sets the x-axis coordinate of the line ending point.

      Uses write-only optimization. The value is NOT stored on the server. Use x2RW(double) if you need to read the value back.

      Parameters:
      x2 - the x coordinate of the end point in user units
      Returns:
      this element for method chaining
    • x2

      public LineElement x2(String x2)
      Sets the x-axis coordinate of the line ending point with a unit or percentage.

      Uses write-only optimization. The value is NOT stored on the server. Use x2RW(String) if you need to read the value back.

      Parameters:
      x2 - the x coordinate of the end point (e.g., "90", "90%", "90px")
      Returns:
      this element for method chaining
    • x2RW

      public LineElement x2RW(double x2)
      Sets the x-axis coordinate of the line ending point (read-write).

      Uses SvgElement.setAttribute(String, String) so the value can be retrieved via Element.getAttribute(String).

      Parameters:
      x2 - the x coordinate of the end point in user units
      Returns:
      this element for method chaining
    • x2RW

      public LineElement x2RW(String x2)
      Sets the x-axis coordinate of the line ending point with a unit or percentage (read-write).

      Uses SvgElement.setAttribute(String, String) so the value can be retrieved via Element.getAttribute(String).

      Parameters:
      x2 - the x coordinate of the end point (e.g., "90", "90%", "90px")
      Returns:
      this element for method chaining
    • y2

      public LineElement y2(double y2)
      Sets the y-axis coordinate of the line ending point.

      Uses write-only optimization. The value is NOT stored on the server. Use y2RW(double) if you need to read the value back.

      Parameters:
      y2 - the y coordinate of the end point in user units
      Returns:
      this element for method chaining
    • y2

      public LineElement y2(String y2)
      Sets the y-axis coordinate of the line ending point with a unit or percentage.

      Uses write-only optimization. The value is NOT stored on the server. Use y2RW(String) if you need to read the value back.

      Parameters:
      y2 - the y coordinate of the end point (e.g., "90", "90%", "90px")
      Returns:
      this element for method chaining
    • y2RW

      public LineElement y2RW(double y2)
      Sets the y-axis coordinate of the line ending point (read-write).

      Uses SvgElement.setAttribute(String, String) so the value can be retrieved via Element.getAttribute(String).

      Parameters:
      y2 - the y coordinate of the end point in user units
      Returns:
      this element for method chaining
    • y2RW

      public LineElement y2RW(String y2)
      Sets the y-axis coordinate of the line ending point with a unit or percentage (read-write).

      Uses SvgElement.setAttribute(String, String) so the value can be retrieved via Element.getAttribute(String).

      Parameters:
      y2 - the y coordinate of the end point (e.g., "90", "90%", "90px")
      Returns:
      this element for method chaining
    • pathLength

      public LineElement pathLength(double pathLength)
      Sets the total length for the line's path in user units.

      This value is used to calibrate the browser's distance calculations with those of the author, by scaling all distance computations using the ratio pathLength / (computed value of path length).

      Uses write-only optimization. The value is NOT stored on the server. Use pathLengthRW(double) if you need to read the value back.

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

      public LineElement pathLengthRW(double pathLength)
      Sets the total length for the line's path in user units (read-write).

      Uses SvgElement.setAttribute(String, String) so the value can be retrieved via Element.getAttribute(String).

      Parameters:
      pathLength - the total path length in user units
      Returns:
      this element for method chaining
    • from

      public LineElement from(double x1, double y1)
      Convenience method to set the starting point (x1, y1) at once.

      Uses write-only optimization. Use fromRW(double, double) if you need to read the values back.

      Parameters:
      x1 - the x coordinate of the start point in user units
      y1 - the y coordinate of the start point in user units
      Returns:
      this element for method chaining
    • from

      public LineElement from(String x1, String y1)
      Convenience method to set the starting point with strings (supports units/percentages).

      Uses write-only optimization. Use fromRW(String, String) if you need to read the values back.

      Parameters:
      x1 - the x coordinate of the start point (e.g., "10%")
      y1 - the y coordinate of the start point (e.g., "10%")
      Returns:
      this element for method chaining
    • fromRW

      public LineElement fromRW(double x1, double y1)
      Convenience method to set the starting point (x1, y1) at once (read-write).
      Parameters:
      x1 - the x coordinate of the start point in user units
      y1 - the y coordinate of the start point in user units
      Returns:
      this element for method chaining
    • fromRW

      public LineElement fromRW(String x1, String y1)
      Convenience method to set the starting point with strings (read-write).
      Parameters:
      x1 - the x coordinate of the start point (e.g., "10%")
      y1 - the y coordinate of the start point (e.g., "10%")
      Returns:
      this element for method chaining
    • to

      public LineElement to(double x2, double y2)
      Convenience method to set the ending point (x2, y2) at once.

      Uses write-only optimization. Use toRW(double, double) if you need to read the values back.

      Parameters:
      x2 - the x coordinate of the end point in user units
      y2 - the y coordinate of the end point in user units
      Returns:
      this element for method chaining
    • to

      public LineElement to(String x2, String y2)
      Convenience method to set the ending point with strings (supports units/percentages).

      Uses write-only optimization. Use toRW(String, String) if you need to read the values back.

      Parameters:
      x2 - the x coordinate of the end point (e.g., "90%")
      y2 - the y coordinate of the end point (e.g., "90%")
      Returns:
      this element for method chaining
    • toRW

      public LineElement toRW(double x2, double y2)
      Convenience method to set the ending point (x2, y2) at once (read-write).
      Parameters:
      x2 - the x coordinate of the end point in user units
      y2 - the y coordinate of the end point in user units
      Returns:
      this element for method chaining
    • toRW

      public LineElement toRW(String x2, String y2)
      Convenience method to set the ending point with strings (read-write).
      Parameters:
      x2 - the x coordinate of the end point (e.g., "90%")
      y2 - the y coordinate of the end point (e.g., "90%")
      Returns:
      this element for method chaining
    • points

      public LineElement points(double x1, double y1, double x2, double y2)
      Convenience method to set both start and end points at once.

      Uses write-only optimization. Use pointsRW(double, double, double, double) if you need to read the values back.

      Parameters:
      x1 - the x coordinate of the start point in user units
      y1 - the y coordinate of the start point in user units
      x2 - the x coordinate of the end point in user units
      y2 - the y coordinate of the end point in user units
      Returns:
      this element for method chaining
    • pointsRW

      public LineElement pointsRW(double x1, double y1, double x2, double y2)
      Convenience method to set both start and end points at once (read-write).
      Parameters:
      x1 - the x coordinate of the start point in user units
      y1 - the y coordinate of the start point in user units
      x2 - the x coordinate of the end point in user units
      y2 - the y coordinate of the end point in user units
      Returns:
      this element for method chaining