Class DOMTreeManager

java.lang.Object
org.apache.batik.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
Version:
$Id: DOMTreeManager.java 1805408 2017-08-18 12:21:52Z ssteiner $
  • Field Details

    • maxGCOverrides

      int maxGCOverrides
      Maximum of Graphic Context attributes overrides in children of the current group.
    • groupManagers

      protected final List groupManagers
      Set of group managers that build groups for this manager. The synchronizedList is part of the fix for bug #40686
    • genericDefSet

      protected List genericDefSet
      Set of definitions that are to be placed at the top of the document tree
    • defaultGC

      Default SVG GraphicContext state
    • topLevelGroup

      protected Element topLevelGroup
      Top level group
    • gcConverter

      Used to convert the Java 2D API graphic context state into the SVG equivalent set of attributes and related definitions
    • generatorContext

      protected SVGGeneratorContext generatorContext
      The context that stores the domFactory, the imageHandler and the extensionHandler.
    • filterConverter

      protected SVGBufferedImageOp filterConverter
      Converters used bVy this object to translate graphic context attributes
    • otherDefs

      protected List otherDefs
      Set of definitions which can be used by custom extensions
  • 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.
    • setExtensionHandler

      void setExtensionHandler(ExtensionHandler extensionHandler)
      This will change the extension handler on the SVGGeneratorContext.
      Parameters:
      extensionHandler - new extension handler this object should use
    • getDefinitionSet

      public List 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()
    • getGeneratorContext

      SVGGeneratorContext getGeneratorContext()
    • getDOMFactory

      Document getDOMFactory()
    • getStyleHandler

      StyleHandler getStyleHandler()