Class PatternElement

java.lang.Object
com.vaadin.flow.dom.Node<com.vaadin.flow.dom.Element>
com.vaadin.flow.dom.Element
org.vaadin.firitin.element.svg.SvgElement
org.vaadin.firitin.element.svg.PatternElement
All Implemented Interfaces:
Serializable

public class PatternElement extends SvgElement
A typed Java API for the SVG <pattern> element.

The <pattern> element defines a repeating pattern that can be used as a fill or stroke for other SVG elements. The pattern is defined by its contents and is tiled to fill the target area.

Patterns must be placed inside a <defs> element and referenced by ID (e.g., fill="url(#myPattern)").

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

    • PatternElement

      public PatternElement()
    • PatternElement

      public PatternElement(String id)
      Creates a pattern with the given ID.
      Parameters:
      id - the ID for referencing this pattern
  • Method Details

    • x

      public PatternElement x(double x)
      Sets the x coordinate of the pattern tile.

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

      Parameters:
      x - the x coordinate
      Returns:
      this element for method chaining
    • xRW

      public PatternElement xRW(double x)
      Sets the x coordinate of the pattern tile (read-write).
      Parameters:
      x - the x coordinate
      Returns:
      this element for method chaining
    • y

      public PatternElement y(double y)
      Sets the y coordinate of the pattern tile.

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

      Parameters:
      y - the y coordinate
      Returns:
      this element for method chaining
    • yRW

      public PatternElement yRW(double y)
      Sets the y coordinate of the pattern tile (read-write).
      Parameters:
      y - the y coordinate
      Returns:
      this element for method chaining
    • width

      public PatternElement width(double width)
      Sets the width of the pattern tile.

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

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

      public PatternElement width(String width)
      Sets the width with a unit.

      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., "10%", "20px")
      Returns:
      this element for method chaining
    • widthRW

      public PatternElement widthRW(double width)
      Sets the width of the pattern tile (read-write).
      Parameters:
      width - the width
      Returns:
      this element for method chaining
    • widthRW

      public PatternElement widthRW(String width)
      Sets the width with a unit (read-write).
      Parameters:
      width - the width (e.g., "10%", "20px")
      Returns:
      this element for method chaining
    • height

      public PatternElement height(double height)
      Sets the height of the pattern tile.

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

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

      public PatternElement height(String height)
      Sets the height with a unit.

      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., "10%", "20px")
      Returns:
      this element for method chaining
    • heightRW

      public PatternElement heightRW(double height)
      Sets the height of the pattern tile (read-write).
      Parameters:
      height - the height
      Returns:
      this element for method chaining
    • heightRW

      public PatternElement heightRW(String height)
      Sets the height with a unit (read-write).
      Parameters:
      height - the height (e.g., "10%", "20px")
      Returns:
      this element for method chaining
    • size

      public PatternElement size(double width, double height)
      Sets the size of the pattern tile.

      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
      height - the height
      Returns:
      this element for method chaining
    • sizeRW

      public PatternElement sizeRW(double width, double height)
      Sets the size of the pattern tile (read-write).
      Parameters:
      width - the width
      height - the height
      Returns:
      this element for method chaining
    • viewBox

      public PatternElement viewBox(double minX, double minY, double width, double height)
      Sets the viewBox for the pattern contents.

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

      Overrides:
      viewBox in class SvgElement
      Parameters:
      minX - the minimum x value
      minY - the minimum y value
      width - the width
      height - the height
      Returns:
      this element for method chaining
    • viewBoxRW

      public PatternElement viewBoxRW(double minX, double minY, double width, double height)
      Sets the viewBox for the pattern contents (read-write).
      Parameters:
      minX - the minimum x value
      minY - the minimum y value
      width - the width
      height - the height
      Returns:
      this element for method chaining
    • patternUnits

      public PatternElement patternUnits(PatternElement.PatternUnits units)
      Sets the coordinate system for x, y, width, height attributes.

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

      Parameters:
      units - the pattern units
      Returns:
      this element for method chaining
    • patternUnitsRW

      public PatternElement patternUnitsRW(PatternElement.PatternUnits units)
      Sets the coordinate system for x, y, width, height attributes (read-write).
      Parameters:
      units - the pattern units
      Returns:
      this element for method chaining
    • patternContentUnits

      public PatternElement patternContentUnits(PatternElement.PatternUnits units)
      Sets the coordinate system for the pattern contents.

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

      Parameters:
      units - the pattern content units
      Returns:
      this element for method chaining
    • patternContentUnitsRW

      public PatternElement patternContentUnitsRW(PatternElement.PatternUnits units)
      Sets the coordinate system for the pattern contents (read-write).
      Parameters:
      units - the pattern content units
      Returns:
      this element for method chaining
    • patternTransform

      public PatternElement patternTransform(String transform)
      Sets a transform on the pattern.

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

      Parameters:
      transform - the transform string
      Returns:
      this element for method chaining
    • patternTransformRW

      public PatternElement patternTransformRW(String transform)
      Sets a transform on the pattern (read-write).
      Parameters:
      transform - the transform string
      Returns:
      this element for method chaining
    • href

      public PatternElement href(String href)
      References another pattern to inherit attributes from.

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

      Parameters:
      href - the reference (e.g., "#otherPattern")
      Returns:
      this element for method chaining
    • hrefRW

      public PatternElement hrefRW(String href)
      References another pattern to inherit attributes from (read-write).
      Parameters:
      href - the reference (e.g., "#otherPattern")
      Returns:
      this element for method chaining
    • preserveAspectRatio

      public PatternElement preserveAspectRatio(String value)
      Sets the preserveAspectRatio attribute.

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

      Overrides:
      preserveAspectRatio in class SvgElement
      Parameters:
      value - the preserveAspectRatio value
      Returns:
      this element for method chaining
    • preserveAspectRatioRW

      public PatternElement preserveAspectRatioRW(String value)
      Sets the preserveAspectRatio attribute (read-write).
      Parameters:
      value - the preserveAspectRatio value
      Returns:
      this element for method chaining
    • preserveAspectRatio

      public PatternElement preserveAspectRatio(SvgElement.PreserveAspectRatio ratio)
      Sets the preserveAspectRatio attribute.

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

      Overrides:
      preserveAspectRatio in class SvgElement
      Parameters:
      ratio - the preserveAspectRatio setting
      Returns:
      this element for method chaining
    • preserveAspectRatioRW

      public PatternElement preserveAspectRatioRW(SvgElement.PreserveAspectRatio ratio)
      Sets the preserveAspectRatio attribute (read-write).
      Parameters:
      ratio - the preserveAspectRatio setting
      Returns:
      this element for method chaining
    • add

      public PatternElement add(SvgElement... elements)
      Adds content elements to this pattern.
      Parameters:
      elements - the elements that define the pattern
      Returns:
      this element for method chaining