Class DOMTreeManager

java.lang.Object
io.sf.carte.echosvg.svggen.DOMTreeManager
All Implemented Interfaces:
XMLConstants, ErrorConstants, SVGSyntax, CSSConstants, SVGConstants

public class DOMTreeManager extends Object implements SVGSyntax, ErrorConstants
This class is used by the SVGGraphics2D SVG Generator to manage addition of new Nodes to the SVG DOM Tree. This class handles a set of DOMGroupManager objects that can all append to the top level group managed by this class. This allows multiple SVGGraphics2D instances, created from the same SVGGraphics2D through the various create methods, to append to the same SVG document and keep the rendering order correct. The root node managed by this DOMTreeManager contains two children: a top level group node and a top level defs node. The top level defs node contains the definition of common SVG entities such as the various AlphaComposite rules. Note that other defs can also be created under the top level group, for example to represent gradient or pattern paints.
[svg] | +-- [defs] Contain generic definitions +-- [g] Top level group | +-- [defs] Contains definitions specific to rendering +-- [g] Group 1 +-- ... +-- [g] Group n
  • Constructor Details

    • DOMTreeManager

      public DOMTreeManager(GraphicContext gc, SVGGeneratorContext generatorContext, int maxGCOverrides)
      Constructor
      Parameters:
      gc - default graphic context state
      generatorContext - the SVG generator context
      maxGCOverrides - defines how many overrides are allowed in children nodes of the current group.
  • Method Details

    • addGroupManager

      public void addGroupManager(DOMGroupManager groupManager)
      Parameters:
      groupManager - new DOMGroupManager to add to the list of managers that collaborate with this tree manager.
    • removeGroupManager

      public void removeGroupManager(DOMGroupManager groupManager)
      Parameters:
      groupManager - DOMGroupManager to remove from the list of managers that collaborate with this tree manager
    • appendGroup

      public void appendGroup(Element group, DOMGroupManager groupManager)
      When a group is appended to the tree by this call, all the other group managers are requested to start new groups, in order to preserve the Z-order.
      Parameters:
      group - new group to be appended to the topLevelGroup
      groupManager - DOMTreeManager that produced the group.
    • recycleTopLevelGroup

      protected void recycleTopLevelGroup()
      Reset the state of this object to handler a new topLevelGroup
    • recycleTopLevelGroup

      protected void recycleTopLevelGroup(boolean recycleConverters)
      Reset the state of this object to handler a new topLevelGroup
    • setTopLevelGroup

      public void setTopLevelGroup(Element topLevelGroup)
      Sets the topLevelGroup to the input element. This will throw an exception if the input element is not of type 'g' or if it is null.
    • getRoot

      public Element getRoot()
      Returns the root element with the generic definitions and the topLevelGroup.
    • getRoot

      public Element getRoot(Element svgElement)
      Returns the root element with the generic definitions and the topLevelGroup.
    • applyDefaultRenderingStyle

      public void applyDefaultRenderingStyle(Element element)
    • getGenericDefinitions

      public Element getGenericDefinitions()
      Returns:
      a defs element that contains all the generic definitions
    • getExtensionHandler

      public ExtensionHandler getExtensionHandler()
      Returns:
      the extension handler used by the DOMTreeManager.
    • getDefinitionSet

      public List<Element> getDefinitionSet()
      Invoking this method will return a set of definition element that contain all the definitions referenced by the attributes generated by the various converters. This also resets the converters.
    • addOtherDef

      public void addOtherDef(Element definition)
      Lets custom implementations for various extensions add elements to the <defs> sections.
    • getTopLevelGroup

      public Element getTopLevelGroup()
      Invoking this method will return a reference to the topLevelGroup Element managed by this object. It will also cause this object to start working with a new topLevelGroup.
      Returns:
      top level group
    • getTopLevelGroup

      public Element getTopLevelGroup(boolean includeDefinitionSet)
      Invoking this method will return a reference to the topLevelGroup Element managed by this object. It will also cause this object to start working with a new topLevelGroup.
      Parameters:
      includeDefinitionSet - if true, the definition set is included and the converters are reset (i.e., they start with an empty set of definitions).
      Returns:
      top level group
    • getFilterConverter

      public SVGBufferedImageOp getFilterConverter()
    • getGraphicContextConverter

      public SVGGraphicContextConverter getGraphicContextConverter()