Class DOMTreeManager

  • All Implemented Interfaces:
    XMLConstants, ErrorConstants, SVGSyntax, CSSConstants, SVGConstants

    public class DOMTreeManager
    extends java.lang.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
    • Field Detail

      • groupManagers

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

        protected java.util.List genericDefSet
        Set of definitions that are to be placed at the top of the document tree
      • topLevelGroup

        protected org.w3c.dom.Element topLevelGroup
        Top level group
      • 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 java.util.List otherDefs
        Set of definitions which can be used by custom extensions
    • Constructor Detail

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

      • 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​(org.w3c.dom.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​(org.w3c.dom.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 org.w3c.dom.Element getRoot()
        Returns the root element with the generic definitions and the topLevelGroup.
      • getRoot

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

        public void applyDefaultRenderingStyle​(org.w3c.dom.Element element)
      • getGenericDefinitions

        public org.w3c.dom.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 java.util.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​(org.w3c.dom.Element definition)
        Lets custom implementations for various extensions add elements to the <defs> sections.
      • getTopLevelGroup

        public org.w3c.dom.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 org.w3c.dom.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