Class DOMGroupManager

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

    public class DOMGroupManager
    extends java.lang.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 Detail

      • 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 org.w3c.dom.Element currentGroup
        Current group node
    • 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​(org.w3c.dom.Element element)
        Adds a node to the current group, if possible
        Parameters:
        element - child Element to add to the group
      • addElement

        public void addElement​(org.w3c.dom.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,
                                             org.w3c.dom.Element element)
        Removes properties that do not apply for a specific element
      • setTransform

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