Class SymbolElement

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.SymbolElement
All Implemented Interfaces:
Serializable

public class SymbolElement extends SvgElement
A typed Java API for the SVG <symbol> element.

The <symbol> element is used to define graphical template objects that can be instantiated by a <use> element. Using <symbol> elements for graphics that are used multiple times adds structure and semantics.

Unlike <g>, a <symbol> element itself is not rendered. Only instances of a <symbol> element (i.e., a reference to it from a <use> element) are rendered.

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:
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.vaadin.firitin.element.svg.SvgElement

    SvgElement.PreserveAspectRatio
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    Creates a symbol with the given ID.
  • Method Summary

    Modifier and Type
    Method
    Description
    add(SvgElement... children)
    Adds child elements to this symbol.
    height(double height)
    Sets the height for this symbol.
    heightRW(double height)
    Sets the height for this symbol (read-write).
    Sets the preserveAspectRatio attribute.
    Sets the preserveAspectRatio attribute.
    Sets the preserveAspectRatio attribute (read-write).
    Sets the preserveAspectRatio attribute (read-write).
    viewBox(double minX, double minY, double width, double height)
    Sets the viewBox for this symbol.
    viewBoxRW(double minX, double minY, double width, double height)
    Sets the viewBox for this symbol (read-write).
    width(double width)
    Sets the width for this symbol.
    widthRW(double width)
    Sets the width for this symbol (read-write).
    x(double x)
    Sets the x coordinate for symbol positioning (when used in certain contexts).
    xRW(double x)
    Sets the x coordinate for symbol positioning (read-write).
    y(double y)
    Sets the y coordinate for symbol positioning (when used in certain contexts).
    yRW(double y)
    Sets the y coordinate for symbol positioning (read-write).

    Methods inherited from class com.vaadin.flow.dom.Element

    addAttachListener, addDetachListener, addEventListener, addPropertyChangeListener, addPropertyChangeListener, as, attachShadow, bindAttribute, bindProperty, bindText, callJsFunction, callJsFunction, createText, executeJs, executeJs, get, get, getAttribute, getAttributeNames, getChild, getChildCount, getChildren, getClassList, getComponent, getParent, getProperty, getProperty, getProperty, getProperty, getProperty, getPropertyBean, getPropertyBean, getPropertyNames, getPropertyRaw, getSelf, getShadowRoot, getTag, getText, getTextRecursively, getThemeList, hasAttribute, hasProperty, isEnabled, isTextNode, isVisible, removeAttribute, removeFromParent, removeFromTree, removeFromTree, removeProperty, scrollIntoView, scrollIntoView, setAttribute, setAttribute, setAttribute, setEnabled, setProperty, setProperty, setProperty, setPropertyBean, setPropertyJson, setPropertyList, setPropertyMap, setText, setVisible, toString

    Methods inherited from class com.vaadin.flow.dom.Node

    accept, appendChild, appendChild, appendVirtualChild, appendVirtualChild, ensureChildHasParent, equals, getNode, getParentNode, getStateProvider, hashCode, indexOfChild, insertChild, insertChild, isVirtualChild, removeAllChildren, removeChild, removeChild, removeChild, removeVirtualChild, removeVirtualChild, setChild

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SymbolElement

      public SymbolElement()
    • SymbolElement

      public SymbolElement(String id)
      Creates a symbol with the given ID.
      Parameters:
      id - the ID for this symbol (used by use element to reference it)
  • Method Details

    • viewBox

      public SymbolElement viewBox(double minX, double minY, double width, double height)
      Sets the viewBox for this symbol.

      The viewBox defines the coordinate system for the symbol's 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 of the viewBox
      height - the height of the viewBox
      Returns:
      this element for method chaining
    • viewBoxRW

      public SymbolElement viewBoxRW(double minX, double minY, double width, double height)
      Sets the viewBox for this symbol (read-write).

      The viewBox defines the coordinate system for the symbol's contents.

      Parameters:
      minX - the minimum x value
      minY - the minimum y value
      width - the width of the viewBox
      height - the height of the viewBox
      Returns:
      this element for method chaining
    • preserveAspectRatio

      public SymbolElement 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 (e.g., "xMidYMid meet")
      Returns:
      this element for method chaining
    • preserveAspectRatioRW

      public SymbolElement preserveAspectRatioRW(String value)
      Sets the preserveAspectRatio attribute (read-write).
      Parameters:
      value - the preserveAspectRatio value (e.g., "xMidYMid meet")
      Returns:
      this element for method chaining
    • preserveAspectRatio

      public SymbolElement 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 SymbolElement preserveAspectRatioRW(SvgElement.PreserveAspectRatio ratio)
      Sets the preserveAspectRatio attribute (read-write).
      Parameters:
      ratio - the preserveAspectRatio setting
      Returns:
      this element for method chaining
    • x

      public SymbolElement x(double x)
      Sets the x coordinate for symbol positioning (when used in certain contexts).

      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 SymbolElement xRW(double x)
      Sets the x coordinate for symbol positioning (read-write).
      Parameters:
      x - the x coordinate
      Returns:
      this element for method chaining
    • y

      public SymbolElement y(double y)
      Sets the y coordinate for symbol positioning (when used in certain contexts).

      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 SymbolElement yRW(double y)
      Sets the y coordinate for symbol positioning (read-write).
      Parameters:
      y - the y coordinate
      Returns:
      this element for method chaining
    • width

      public SymbolElement width(double width)
      Sets the width for this symbol.

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

      public SymbolElement widthRW(double width)
      Sets the width for this symbol (read-write).
      Parameters:
      width - the width
      Returns:
      this element for method chaining
    • height

      public SymbolElement height(double height)
      Sets the height for this symbol.

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

      public SymbolElement heightRW(double height)
      Sets the height for this symbol (read-write).
      Parameters:
      height - the height
      Returns:
      this element for method chaining
    • add

      public SymbolElement add(SvgElement... children)
      Adds child elements to this symbol.
      Parameters:
      children - the elements to add
      Returns:
      this element for method chaining