Class DOMGroupManager

java.lang.Object
org.apache.batik.svggen.DOMGroupManager
All Implemented Interfaces:
XMLConstants, ErrorConstants, SVGSyntax, CSSConstants, SVGConstants

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.
Version:
$Id: DOMGroupManager.java 1804130 2017-08-04 14:41:11Z ssteiner $
  • Field Details

    • DRAW

      public static final short DRAW
      See Also:
    • FILL

      public static final short FILL
      See Also:
    • gc

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

      protected DOMTreeManager domTreeManager
      DOMTreeManager that this group manager cooperates with
    • groupGC

      protected SVGGraphicContext groupGC
      Current group's SVG GraphicContext state
    • currentGroup

      protected Element currentGroup
      Current group node
  • Constructor Details

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

    • recycleCurrentGroup

      void recycleCurrentGroup()
      Reset the state of this object to handle a new currentGroup
    • 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.
    • trimContextForElement

      protected void trimContextForElement(SVGGraphicContext svgGC, Element element)
      Removes properties that do not apply for a specific element
    • setTransform

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

      static SVGGraphicContext processDeltaGC(SVGGraphicContext gc, SVGGraphicContext referenceGc)
      Processes the difference between two graphic contexts. The values in gc that are different from the values in referenceGc will be present in the delta. Other values will no.
    • processDeltaMap

      static Map processDeltaMap(Map map, Map referenceMap)
      Processes the difference between two Maps. The code assumes that the input Maps have the same key sets. Values in map that are different from values in referenceMap are place in the returned delta Map.