Class SvgContainerElement<T extends SvgContainerElement<T>>

Direct Known Subclasses:
Svg, SvgAnchor, SvgClipPath, SvgDefs, SvgDesc, SvgFeComponentTransfer, SvgFeDiffuseLighting, SvgFeMerge, SvgFeSpecularLighting, SvgFilter, SvgForeignObject, SvgGroup, SvgLinearGradient, SvgMarker, SvgMask, SvgMetadata, SvgPattern, SvgRadialGradient, SvgSwitch, SvgSymbol, SvgText, SvgTextPath, SvgTitle, SvgTspan

public abstract class SvgContainerElement<T extends SvgContainerElement<T>> extends SvgElement<T>
Abstract base class for SVG container elements that accept child SVG elements.

SVG container elements like <svg>, <g>, <defs>, and <symbol> can contain other SVG elements as children. This class provides type-safe child management that restricts children to SvgElement types, preventing invalid mixing of HTML and SVG content.

In addition to the type-safe Element.addElement(SvgElement) method, this class implements

invalid reference
ContainerIntf
to provide the full set of container operations.

Since:
2026
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • SvgContainerElement

      protected SvgContainerElement(String tagName)
      Constructs an SVG container element with the specified tag name.
      Parameters:
      tagName - the SVG tag name (e.g., "svg", "g", "defs")
  • Method Details

    • removeAllElements

      public void removeAllElements()
      Removes all child elements from this element.

      Each child is unlinked and registered for DOM removal if the element is attached to a page.

      Overrides:
      removeAllElements in class Element<T extends SvgContainerElement<T>>
    • removeElement

      public void removeElement(SvgElement child)
    • removeElement

      public void removeElement(String id)
      Removes a child element by its ID.
      Overrides:
      removeElement in class Element<T extends SvgContainerElement<T>>
      Parameters:
      id - The ID of the child element to remove.
    • setText

      public void setText(String text)
      Sets the text content of this element, replacing any existing content.
      Overrides:
      setText in class Element<T extends SvgContainerElement<T>>
      Parameters:
      text - The text content to set.
    • addText

      public void addText(String text)
      Appends text content to this element.
      Overrides:
      addText in class Element<T extends SvgContainerElement<T>>
      Parameters:
      text - The text content to append.