Class GuiSvgDocument

java.lang.Object
com.render.api.gui.GuiSvgDocument

public final class GuiSvgDocument extends Object
Retained mutable SVG element tree with stable node identities and versioned asynchronous rasterization.

DOM and style mutations increment generation(). The shared asset manager keeps the last valid texture visible while a newer generation rasterizes. Each mutable document owns a distinct asset identity, even when several documents are parsed from the same markup.

  • Method Details

    • parse

      public static GuiSvgDocument parse(String svg)
    • builder

      public static GuiSvgDocument builder(GuiSvgBuilder builder)
    • root

      public GuiSvgDocument.Node root()
    • nodes

      public List<GuiSvgDocument.Node> nodes()
    • byId

      public Optional<GuiSvgDocument.Node> byId(String id)
    • select

      public List<GuiSvgDocument.Node> select(GuiSvgSelector selector)
    • edit

      public GuiSvgDocument edit(Consumer<GuiSvgDocument> edits)
      Applies a group of DOM/style edits with one cascade refresh and one publication generation. Nested edits share the outer transaction. An exception still publishes mutations already performed.
      Parameters:
      edits - mutations of this retained document
      Returns:
      this document
    • rule

      public GuiSvgDocument rule(GuiSvgSelector selector, Consumer<GuiStyleBuilder> declarations)
      Adds a retained typed presentation rule and applies all rules in source order.
      Returns:
      this document
    • append

      public GuiSvgDocument.Node append(GuiSvgDocument.Node parent, String tag)
    • remove

      public void remove(GuiSvgDocument.Node node)
    • hitTest

      public Optional<GuiSvgDocument.Node> hitTest(float x, float y)
      Performs transformed retained hit testing for SVG viewport, shape, path, line, polyline, polygon, image, and text geometry. Visibility and pointer-event suppression are honored; nodes later in paint order win.
    • hitTestLimitations

      public List<String> hitTestLimitations()
      Reports painted features whose exact hit geometry is unavailable. Masked/filtered/CSS-painted nodes are conservatively excluded from hit testing rather than returned using an unrelated bounding box.
      Returns:
      deduplicated unsupported hit features present in the document
    • markup

      public String markup()
    • sampleAnimations

      public boolean sampleAnimations(double animationTimeSeconds)
      Samples every retained SVG attribute animation against a view animation clock.

      The document generation changes only if at least one serialized attribute value changes. RenderLib invokes this automatically when the document is painted; it is public so a caller can drive a detached document with another retained clock.

      Parameters:
      animationTimeSeconds - clock time in seconds
      Returns:
      whether the sampled SVG markup changed
    • cacheKey

      public String cacheKey()
    • generation

      public long generation()
    • hintWidth

      public float hintWidth()
    • hintHeight

      public float hintHeight()
    • load

      public com.render.api.gui.GuiLoadedAsset load() throws Exception
      Throws:
      Exception
    • snapshotForLoad

      public com.render.api.gui.GuiAssetSource.LoadSnapshot snapshotForLoad()
    • rasterVariant

      public com.render.api.gui.GuiAssetSource rasterVariant(float physicalWidth, float physicalHeight)