Class TSpanElement

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

public class TSpanElement extends SvgGraphicsElement
A typed Java API for the SVG <tspan> element.

The <tspan> element defines a subtext within a <text> element or another <tspan> element. It allows for adjustment of the style and/or position of that subtext as needed.

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

    • TSpanElement

      public TSpanElement()
    • TSpanElement

      public TSpanElement(String text)
      Creates a tspan element with the given text content.
      Parameters:
      text - the text content
  • Method Details

    • text

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

      public TSpanElement x(double x)
      Sets the absolute x coordinate for this tspan.

      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
    • x

      public TSpanElement x(String x)
      Sets the absolute x coordinate with a unit.

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

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

      public TSpanElement xRW(double x)
      Sets the absolute x coordinate for this tspan (read-write).
      Parameters:
      x - the x coordinate
      Returns:
      this element for method chaining
    • xRW

      public TSpanElement xRW(String x)
      Sets the absolute x coordinate with a unit (read-write).
      Parameters:
      x - the x coordinate (e.g., "50%")
      Returns:
      this element for method chaining
    • y

      public TSpanElement y(double y)
      Sets the absolute y coordinate for this tspan.

      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
    • y

      public TSpanElement y(String y)
      Sets the absolute y coordinate with a unit.

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

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

      public TSpanElement yRW(double y)
      Sets the absolute y coordinate for this tspan (read-write).
      Parameters:
      y - the y coordinate
      Returns:
      this element for method chaining
    • yRW

      public TSpanElement yRW(String y)
      Sets the absolute y coordinate with a unit (read-write).
      Parameters:
      y - the y coordinate (e.g., "50%")
      Returns:
      this element for method chaining
    • dx

      public TSpanElement dx(double dx)
      Sets the horizontal shift from the previous text position.

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

      Parameters:
      dx - the horizontal offset
      Returns:
      this element for method chaining
    • dx

      public TSpanElement dx(String dx)
      Sets the horizontal shift with a unit.

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

      Parameters:
      dx - the horizontal offset (e.g., "1em")
      Returns:
      this element for method chaining
    • dxRW

      public TSpanElement dxRW(double dx)
      Sets the horizontal shift from the previous text position (read-write).
      Parameters:
      dx - the horizontal offset
      Returns:
      this element for method chaining
    • dxRW

      public TSpanElement dxRW(String dx)
      Sets the horizontal shift with a unit (read-write).
      Parameters:
      dx - the horizontal offset (e.g., "1em")
      Returns:
      this element for method chaining
    • dy

      public TSpanElement dy(double dy)
      Sets the vertical shift from the previous text position.

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

      Parameters:
      dy - the vertical offset
      Returns:
      this element for method chaining
    • dy

      public TSpanElement dy(String dy)
      Sets the vertical shift with a unit.

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

      Parameters:
      dy - the vertical offset (e.g., "1em")
      Returns:
      this element for method chaining
    • dyRW

      public TSpanElement dyRW(double dy)
      Sets the vertical shift from the previous text position (read-write).
      Parameters:
      dy - the vertical offset
      Returns:
      this element for method chaining
    • dyRW

      public TSpanElement dyRW(String dy)
      Sets the vertical shift with a unit (read-write).
      Parameters:
      dy - the vertical offset (e.g., "1em")
      Returns:
      this element for method chaining
    • rotate

      public TSpanElement rotate(String rotate)
      Sets the rotation for each character.

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

      Parameters:
      rotate - the rotation angle(s) in degrees
      Returns:
      this element for method chaining
    • rotateRW

      public TSpanElement rotateRW(String rotate)
      Sets the rotation for each character (read-write).
      Parameters:
      rotate - the rotation angle(s) in degrees
      Returns:
      this element for method chaining
    • textLength

      public TSpanElement textLength(double length)
      Sets the total length of the text in this tspan.

      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 TSpanElement textLengthRW(double length)
      Sets the total length of the text in this tspan (read-write).
      Parameters:
      length - the text length
      Returns:
      this element for method chaining
    • fontFamily

      public TSpanElement 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 TSpanElement fontFamilyRW(String fontFamily)
      Sets the font family (read-write).
      Parameters:
      fontFamily - the font family
      Returns:
      this element for method chaining
    • fontSize

      public TSpanElement 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 TSpanElement 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 TSpanElement fontSizeRW(double size)
      Sets the font size (read-write).
      Parameters:
      size - the font size
      Returns:
      this element for method chaining
    • fontSizeRW

      public TSpanElement 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 TSpanElement 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 TSpanElement fontWeightRW(TextElement.FontWeight weight)
      Sets the font weight (read-write).
      Parameters:
      weight - the font weight
      Returns:
      this element for method chaining
    • fontStyle

      public TSpanElement fontStyle(TextElement.FontStyle style)
      Sets the font style.

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

      Parameters:
      style - the font style
      Returns:
      this element for method chaining
    • fontStyleRW

      public TSpanElement fontStyleRW(TextElement.FontStyle style)
      Sets the font style (read-write).
      Parameters:
      style - the font style
      Returns:
      this element for method chaining
    • textDecoration

      public TSpanElement textDecoration(TextElement.TextDecoration decoration)
      Sets the text decoration.

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

      Parameters:
      decoration - the text decoration
      Returns:
      this element for method chaining
    • textDecorationRW

      public TSpanElement textDecorationRW(TextElement.TextDecoration decoration)
      Sets the text decoration (read-write).
      Parameters:
      decoration - the text decoration
      Returns:
      this element for method chaining
    • baselineShift

      public TSpanElement baselineShift(TSpanElement.BaselineShift shift)
      Sets the baseline shift (for subscript/superscript).

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

      Parameters:
      shift - the baseline shift
      Returns:
      this element for method chaining
    • baselineShiftRW

      public TSpanElement baselineShiftRW(TSpanElement.BaselineShift shift)
      Sets the baseline shift (for subscript/superscript) (read-write).
      Parameters:
      shift - the baseline shift
      Returns:
      this element for method chaining
    • baselineShift

      public TSpanElement baselineShift(String shift)
      Sets the baseline shift with a custom value.

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

      Parameters:
      shift - the baseline shift (e.g., "30%", "-5px")
      Returns:
      this element for method chaining
    • baselineShiftRW

      public TSpanElement baselineShiftRW(String shift)
      Sets the baseline shift with a custom value (read-write).
      Parameters:
      shift - the baseline shift (e.g., "30%", "-5px")
      Returns:
      this element for method chaining