Class RectElement

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

public class RectElement extends SvgGraphicsElement
A typed Java API for the SVG <rect> element.

The <rect> element is a basic SVG shape that draws rectangles, defined by their position, width, and height. The rectangles may have their corners rounded.

Write-Only vs Read-Write Methods

This class provides two variants for each attribute setter:

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

    • RectElement

      public RectElement()
  • Method Details

    • x

      public RectElement x(double x)
      Sets the x coordinate of the rectangle.

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

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

      public RectElement x(String x)
      Sets the x coordinate of the rectangle with a unit or percentage.

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

      Parameters:
      x - the x coordinate (e.g., "10", "50%", "10px")
      Returns:
      this element for method chaining
    • xRW

      public RectElement xRW(double x)
      Sets the x coordinate of the rectangle (read-write).
      Parameters:
      x - the x coordinate in user units
      Returns:
      this element for method chaining
    • xRW

      public RectElement xRW(String x)
      Sets the x coordinate of the rectangle with a unit or percentage (read-write).
      Parameters:
      x - the x coordinate (e.g., "10", "50%", "10px")
      Returns:
      this element for method chaining
    • y

      public RectElement y(double y)
      Sets the y coordinate of the rectangle.

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

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

      public RectElement y(String y)
      Sets the y coordinate of the rectangle with a unit or percentage.

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

      Parameters:
      y - the y coordinate (e.g., "10", "50%", "10px")
      Returns:
      this element for method chaining
    • yRW

      public RectElement yRW(double y)
      Sets the y coordinate of the rectangle (read-write).
      Parameters:
      y - the y coordinate in user units
      Returns:
      this element for method chaining
    • yRW

      public RectElement yRW(String y)
      Sets the y coordinate of the rectangle with a unit or percentage (read-write).
      Parameters:
      y - the y coordinate (e.g., "10", "50%", "10px")
      Returns:
      this element for method chaining
    • width

      public RectElement width(double width)
      Sets the width of the rectangle.

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

      Overrides:
      width in class SvgElement
      Parameters:
      width - the width in user units
      Returns:
      this element for method chaining
    • width

      public RectElement width(String width)
      Sets the width of the rectangle with a unit or percentage.

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

      Overrides:
      width in class SvgElement
      Parameters:
      width - the width (e.g., "100", "50%", "100px")
      Returns:
      this element for method chaining
    • widthRW

      public RectElement widthRW(double width)
      Sets the width of the rectangle (read-write).
      Parameters:
      width - the width in user units
      Returns:
      this element for method chaining
    • widthRW

      public RectElement widthRW(String width)
      Sets the width of the rectangle with a unit or percentage (read-write).
      Parameters:
      width - the width (e.g., "100", "50%", "100px")
      Returns:
      this element for method chaining
    • height

      public RectElement height(double height)
      Sets the height of the rectangle.

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

      Overrides:
      height in class SvgElement
      Parameters:
      height - the height in user units
      Returns:
      this element for method chaining
    • height

      public RectElement height(String height)
      Sets the height of the rectangle with a unit or percentage.

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

      Overrides:
      height in class SvgElement
      Parameters:
      height - the height (e.g., "100", "50%", "100px")
      Returns:
      this element for method chaining
    • heightRW

      public RectElement heightRW(double height)
      Sets the height of the rectangle (read-write).
      Parameters:
      height - the height in user units
      Returns:
      this element for method chaining
    • heightRW

      public RectElement heightRW(String height)
      Sets the height of the rectangle with a unit or percentage (read-write).
      Parameters:
      height - the height (e.g., "100", "50%", "100px")
      Returns:
      this element for method chaining
    • rx

      public RectElement rx(double rx)
      Sets the horizontal corner radius of the rectangle.

      If ry is not specified, it defaults to the value of rx.

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

      Parameters:
      rx - the horizontal corner radius in user units
      Returns:
      this element for method chaining
    • rx

      public RectElement rx(String rx)
      Sets the horizontal corner radius of the rectangle with a unit or percentage.

      If ry is not specified, it defaults to the value of rx.

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

      Parameters:
      rx - the horizontal corner radius (e.g., "10", "50%", "10px")
      Returns:
      this element for method chaining
    • rxRW

      public RectElement rxRW(double rx)
      Sets the horizontal corner radius of the rectangle (read-write).
      Parameters:
      rx - the horizontal corner radius in user units
      Returns:
      this element for method chaining
    • rxRW

      public RectElement rxRW(String rx)
      Sets the horizontal corner radius of the rectangle with a unit or percentage (read-write).
      Parameters:
      rx - the horizontal corner radius (e.g., "10", "50%", "10px")
      Returns:
      this element for method chaining
    • ry

      public RectElement ry(double ry)
      Sets the vertical corner radius of the rectangle.

      If rx is not specified, it defaults to the value of ry.

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

      Parameters:
      ry - the vertical corner radius in user units
      Returns:
      this element for method chaining
    • ry

      public RectElement ry(String ry)
      Sets the vertical corner radius of the rectangle with a unit or percentage.

      If rx is not specified, it defaults to the value of ry.

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

      Parameters:
      ry - the vertical corner radius (e.g., "10", "50%", "10px")
      Returns:
      this element for method chaining
    • ryRW

      public RectElement ryRW(double ry)
      Sets the vertical corner radius of the rectangle (read-write).
      Parameters:
      ry - the vertical corner radius in user units
      Returns:
      this element for method chaining
    • ryRW

      public RectElement ryRW(String ry)
      Sets the vertical corner radius of the rectangle with a unit or percentage (read-write).
      Parameters:
      ry - the vertical corner radius (e.g., "10", "50%", "10px")
      Returns:
      this element for method chaining
    • pathLength

      public RectElement pathLength(double pathLength)
      Sets the total length of the rectangle's perimeter 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 perimeter).

      Uses write-only optimization. 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 RectElement pathLengthRW(double pathLength)
      Sets the total length of the rectangle's perimeter in user units (read-write).
      Parameters:
      pathLength - the total path length in user units
      Returns:
      this element for method chaining
    • position

      public RectElement position(double x, double y)
      Convenience method to set position (x, y) at once.

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

      Parameters:
      x - the x coordinate in user units
      y - the y coordinate in user units
      Returns:
      this element for method chaining
    • positionRW

      public RectElement positionRW(double x, double y)
      Convenience method to set position (x, y) at once (read-write).
      Parameters:
      x - the x coordinate in user units
      y - the y coordinate in user units
      Returns:
      this element for method chaining
    • size

      public RectElement size(double width, double height)
      Convenience method to set size (width, height) at once.

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

      Overrides:
      size in class SvgElement
      Parameters:
      width - the width in user units
      height - the height in user units
      Returns:
      this element for method chaining
    • sizeRW

      public RectElement sizeRW(double width, double height)
      Convenience method to set size (width, height) at once (read-write).
      Parameters:
      width - the width in user units
      height - the height in user units
      Returns:
      this element for method chaining
    • bounds

      public RectElement bounds(double x, double y, double width, double height)
      Convenience method to set bounds (x, y, width, height) at once.

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

      Parameters:
      x - the x coordinate in user units
      y - the y coordinate in user units
      width - the width in user units
      height - the height in user units
      Returns:
      this element for method chaining
    • boundsRW

      public RectElement boundsRW(double x, double y, double width, double height)
      Convenience method to set bounds (x, y, width, height) at once (read-write).
      Parameters:
      x - the x coordinate in user units
      y - the y coordinate in user units
      width - the width in user units
      height - the height in user units
      Returns:
      this element for method chaining
    • cornerRadius

      public RectElement cornerRadius(double radius)
      Convenience method to set equal corner radius for both axes.

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

      Parameters:
      radius - the corner radius in user units
      Returns:
      this element for method chaining
    • cornerRadiusRW

      public RectElement cornerRadiusRW(double radius)
      Convenience method to set equal corner radius for both axes (read-write).
      Parameters:
      radius - the corner radius in user units
      Returns:
      this element for method chaining
    • cornerRadius

      public RectElement cornerRadius(double rx, double ry)
      Convenience method to set different corner radii for horizontal and vertical axes.

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

      Parameters:
      rx - the horizontal corner radius in user units
      ry - the vertical corner radius in user units
      Returns:
      this element for method chaining
    • cornerRadiusRW

      public RectElement cornerRadiusRW(double rx, double ry)
      Convenience method to set different corner radii for horizontal and vertical axes (read-write).
      Parameters:
      rx - the horizontal corner radius in user units
      ry - the vertical corner radius in user units
      Returns:
      this element for method chaining