org.apache.batik.svggen

Class DOMGroupManager

public class DOMGroupManager extends Object implements SVGSyntax, ErrorConstants

This class is used by the Graphics2D SVG Generator to manage a group of Nodes that can later be added to the SVG DOM Tree managed by the DOMTreeManager. There are two rules that control how children nodes are added to the group managed by this class: + Children node are added to the group as long as there is no more than n graphic context overrides needed to describe the children style. A graphic context override happens when style attributes need to be added to a child node to reflect the state of the graphic context at the time the child was added. Note that the opacity is never reflected in a group node and therefore, is not accounted for in the number of overrides. The number of overrides can be configured and defaults to 2. + Children nodes are added to the current group as long as the associated GraphicContext's transform stack is valid. When children nodes can no longer be added, the group is considered complete and the associated DOMTreeManager is notified of the availability of a completed group. Then, a new group is started.
The DOMTreeManager is also notified every thime a new element is added to the current group. This is needed to let the DOMTreeManager handle group managers that would be used concurrently.
Field Summary
protected ElementcurrentGroup
Current group node
protected DOMTreeManagerdomTreeManager
DOMTreeManager that this group manager cooperates with
static shortDRAW
static shortFILL
protected GraphicContextgc
Reference to the GraphicContext this manager will use to reflect style attributes in the tree nodes.
protected SVGGraphicContextgroupGC
Current group's SVG GraphicContext state
Constructor Summary
DOMGroupManager(GraphicContext gc, DOMTreeManager domTreeManager)
Constructor
Method Summary
voidaddElement(Element element)
Adds a node to the current group, if possible
voidaddElement(Element element, short method)
Adds a node to the current group, if possible
protected intcountOverrides(SVGGraphicContext deltaGC)
Analyses the Map to define how many attributes constitute overrides.
protected voidsetTransform(Element element, TransformStackElement[] transformStack)
Processes the transform attribute value corresponding to a given transform stack
protected voidtrimContextForElement(SVGGraphicContext svgGC, Element element)
Removes properties that do not apply for a specific element

Field Detail

currentGroup

protected Element currentGroup
Current group node

domTreeManager

protected DOMTreeManager domTreeManager
DOMTreeManager that this group manager cooperates with

DRAW

public static final short DRAW

FILL

public static final short FILL

gc

protected GraphicContext gc
Reference to the GraphicContext this manager will use to reflect style attributes in the tree nodes.

groupGC

protected SVGGraphicContext groupGC
Current group's SVG GraphicContext state

Constructor Detail

DOMGroupManager

public DOMGroupManager(GraphicContext gc, DOMTreeManager domTreeManager)
Constructor

Parameters: gc graphic context whose state will be reflected in the element's style attributes. domTreeManager DOMTreeManager instance this group manager cooperates with.

Method Detail

addElement

public void addElement(Element element)
Adds a node to the current group, if possible

Parameters: element child Element to add to the group

addElement

public void addElement(Element element, short method)
Adds a node to the current group, if possible

Parameters: element child Element to add to the group

countOverrides

protected int countOverrides(SVGGraphicContext deltaGC)
Analyses the Map to define how many attributes constitute overrides. Only differences in the group context are considered overrides.

setTransform

protected void setTransform(Element element, TransformStackElement[] transformStack)
Processes the transform attribute value corresponding to a given transform stack

trimContextForElement

protected void trimContextForElement(SVGGraphicContext svgGC, Element element)
Removes properties that do not apply for a specific element
Copyright B) 2008 Apache Software Foundation. All Rights Reserved.