Class TextPathElement

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

public class TextPathElement extends SvgGraphicsElement
A typed Java API for the SVG <textPath> element.

The <textPath> element renders text along the shape of a path. The text is enclosed within a <text> element and references a <path> element using the href attribute.

Write-Only vs Read-Write Methods

This class provides two variants for each attribute setter:

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

    • TextPathElement

      public TextPathElement()
    • TextPathElement

      public TextPathElement(PathElement path)
      Creates a textPath element referencing the given path. An ID is automatically generated for the path if not already set.
      Parameters:
      path - the path element to follow
    • TextPathElement

      public TextPathElement(PathElement path, String text)
      Creates a textPath element with path reference and text. An ID is automatically generated for the path if not already set.
      Parameters:
      path - the path element to follow
      text - the text content
  • Method Details

    • text

      public TextPathElement text(String text)
      Sets the text content.
      Parameters:
      text - the text content
      Returns:
      this element for method chaining
    • path

      public TextPathElement path(PathElement path)
      Sets the path element for the text to follow. An ID is automatically generated for the path if not already set.

      Note: This method uses read-write approach to ensure ID is properly set.

      Parameters:
      path - the path element
      Returns:
      this element for method chaining
    • href

      public TextPathElement href(String href)
      Sets the href to reference a path element by ID.

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

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

      public TextPathElement hrefRW(String href)
      Sets the href to reference a path element by ID (read-write).
      Parameters:
      href - the reference URL (e.g., "#myPath")
      Returns:
      this element for method chaining
    • startOffset

      public TextPathElement startOffset(double offset)
      Sets the offset along the path where text rendering starts.

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

      Parameters:
      offset - the start offset
      Returns:
      this element for method chaining
    • startOffset

      public TextPathElement startOffset(String offset)
      Sets the offset along the path with a unit.

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

      Parameters:
      offset - the start offset (e.g., "50%", "100px")
      Returns:
      this element for method chaining
    • startOffsetRW

      public TextPathElement startOffsetRW(double offset)
      Sets the offset along the path where text rendering starts (read-write).
      Parameters:
      offset - the start offset
      Returns:
      this element for method chaining
    • startOffsetRW

      public TextPathElement startOffsetRW(String offset)
      Sets the offset along the path with a unit (read-write).
      Parameters:
      offset - the start offset (e.g., "50%", "100px")
      Returns:
      this element for method chaining
    • method

      public TextPathElement method(TextPathElement.Method method)
      Sets the method used to render individual glyphs along the path.

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

      Parameters:
      method - the rendering method
      Returns:
      this element for method chaining
    • methodRW

      public TextPathElement methodRW(TextPathElement.Method method)
      Sets the method used to render individual glyphs along the path (read-write).
      Parameters:
      method - the rendering method
      Returns:
      this element for method chaining
    • spacing

      public TextPathElement spacing(TextPathElement.Spacing spacing)
      Sets the spacing between glyphs.

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

      Parameters:
      spacing - the spacing mode
      Returns:
      this element for method chaining
    • spacingRW

      public TextPathElement spacingRW(TextPathElement.Spacing spacing)
      Sets the spacing between glyphs (read-write).
      Parameters:
      spacing - the spacing mode
      Returns:
      this element for method chaining
    • side

      Sets which side of the path the text is rendered on.

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

      Parameters:
      side - the side
      Returns:
      this element for method chaining
    • sideRW

      public TextPathElement sideRW(TextPathElement.Side side)
      Sets which side of the path the text is rendered on (read-write).
      Parameters:
      side - the side
      Returns:
      this element for method chaining
    • textLength

      public TextPathElement textLength(double length)
      Sets the total length of the text.

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

      Parameters:
      length - the text length
      Returns:
      this element for method chaining
    • textLengthRW

      public TextPathElement textLengthRW(double length)
      Sets the total length of the text (read-write).
      Parameters:
      length - the text length
      Returns:
      this element for method chaining
    • fontFamily

      public TextPathElement fontFamily(String fontFamily)
      Sets the font family.

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

      Parameters:
      fontFamily - the font family
      Returns:
      this element for method chaining
    • fontFamilyRW

      public TextPathElement fontFamilyRW(String fontFamily)
      Sets the font family (read-write).
      Parameters:
      fontFamily - the font family
      Returns:
      this element for method chaining
    • fontSize

      public TextPathElement fontSize(double size)
      Sets the font size.

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

      Parameters:
      size - the font size
      Returns:
      this element for method chaining
    • fontSize

      public TextPathElement fontSize(String size)
      Sets the font size with a unit.

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

      Parameters:
      size - the font size (e.g., "12px", "1em")
      Returns:
      this element for method chaining
    • fontSizeRW

      public TextPathElement fontSizeRW(double size)
      Sets the font size (read-write).
      Parameters:
      size - the font size
      Returns:
      this element for method chaining
    • fontSizeRW

      public TextPathElement fontSizeRW(String size)
      Sets the font size with a unit (read-write).
      Parameters:
      size - the font size (e.g., "12px", "1em")
      Returns:
      this element for method chaining
    • fontWeight

      public TextPathElement fontWeight(TextElement.FontWeight weight)
      Sets the font weight.

      Uses write-only optimization. Use fontWeightRW(TextElement.FontWeight) if you need to read the value back.

      Parameters:
      weight - the font weight
      Returns:
      this element for method chaining
    • fontWeightRW

      public TextPathElement fontWeightRW(TextElement.FontWeight weight)
      Sets the font weight (read-write).
      Parameters:
      weight - the font weight
      Returns:
      this element for method chaining