org.apache.batik.svggen

Class DOMTreeManager

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
Field Summary
protected SVGBufferedImageOpfilterConverter
Converters used bVy this object to translate graphic context attributes
protected SVGGeneratorContextgeneratorContext
The context that stores the domFactory, the imageHandler and the extensionHandler.
protected ListgenericDefSet
Set of definitions that are to be placed at the top of the document tree
protected ListgroupManagers
Set of group managers that build groups for this manager.
protected ListotherDefs
Set of definitions which can be used by custom extensions
protected ElementtopLevelGroup
Top level group
Constructor Summary
DOMTreeManager(GraphicContext gc, SVGGeneratorContext generatorContext, int maxGCOverrides)
Constructor
Method Summary
voidaddGroupManager(DOMGroupManager groupManager)
voidaddOtherDef(Element definition)
Lets custom implementations for various extensions add elements to the sections.
voidappendGroup(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.
voidapplyDefaultRenderingStyle(Element element)
ListgetDefinitionSet()
Invoking this method will return a set of definition element that contain all the definitions referenced by the attributes generated by the various converters.
ExtensionHandlergetExtensionHandler()
SVGBufferedImageOpgetFilterConverter()
ElementgetGenericDefinitions()
SVGGraphicContextConvertergetGraphicContextConverter()
ElementgetRoot()
Returns the root element with the generic definitions and the topLevelGroup.
ElementgetRoot(Element svgElement)
Returns the root element with the generic definitions and the topLevelGroup.
ElementgetTopLevelGroup()
Invoking this method will return a reference to the topLevelGroup Element managed by this object.
ElementgetTopLevelGroup(boolean includeDefinitionSet)
Invoking this method will return a reference to the topLevelGroup Element managed by this object.
protected voidrecycleTopLevelGroup()
Reset the state of this object to handler a new topLevelGroup
protected voidrecycleTopLevelGroup(boolean recycleConverters)
Reset the state of this object to handler a new topLevelGroup
voidremoveGroupManager(DOMGroupManager groupManager)
voidsetTopLevelGroup(Element topLevelGroup)
Sets the topLevelGroup to the input element.

Field Detail

filterConverter

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

generatorContext

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

genericDefSet

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

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

otherDefs

protected List otherDefs
Set of definitions which can be used by custom extensions

topLevelGroup

protected Element topLevelGroup
Top level group

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.

addOtherDef

public void addOtherDef(Element definition)
Lets custom implementations for various extensions add elements to the sections.

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.

applyDefaultRenderingStyle

public void applyDefaultRenderingStyle(Element element)

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.

getExtensionHandler

public ExtensionHandler getExtensionHandler()

Returns: the extension handler used by the DOMTreeManager.

getFilterConverter

public SVGBufferedImageOp getFilterConverter()

getGenericDefinitions

public Element getGenericDefinitions()

Returns: a defs element that contains all the generic definitions

getGraphicContextConverter

public SVGGraphicContextConverter getGraphicContextConverter()

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.

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

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

removeGroupManager

public void removeGroupManager(DOMGroupManager groupManager)

Parameters: groupManager DOMGroupManager to remove from the list of managers that collaborate with this tree manager

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.
Copyright B) 2008 Apache Software Foundation. All Rights Reserved.