Class DefaultSvgProcessor

  • All Implemented Interfaces:
    ISvgProcessor

    public class DefaultSvgProcessor
    extends java.lang.Object
    implements ISvgProcessor
    Default implementation of ISvgProcessor. This implementation traverses the INode tree depth-first, using a stack to recreate a tree of ISvgNodeRenderer with the same structure.
    • Constructor Detail

      • DefaultSvgProcessor

        public DefaultSvgProcessor()
        Instantiates a DefaultSvgProcessor object.
    • Method Detail

      • performSetup

        void performSetup​(INode root,
                          ISvgConverterProperties converterProps)
        Load in configuration, set initial processorState and create/fill-in context of the processor
        Parameters:
        converterProps - that contains configuration properties and operations
      • executeDepthFirstTraversal

        void executeDepthFirstTraversal​(INode startingNode)
        Start the depth-first traversal of the INode tree, pushing the results on the stack
        Parameters:
        startingNode - node to start on
      • createResultAndClean

        private ISvgNodeRenderer createResultAndClean()
        Extract result from internal processorState and clean up afterwards
        Returns:
        Root renderer of the processed SVG
      • visit

        private void visit​(INode node)
        Recursive visit of the object tree, depth-first, processing the visited node and calling visit on its children. Visit responsibilities for element nodes: - Assign styles(CSS and attributes) to element - Create Renderer based on element - push and pop renderer to stack Visit responsibilities for text nodes - add text to parent object
        Parameters:
        node - INode to visit
      • processAsText

        private boolean processAsText​(INode node)
        Check if this node is a text node that needs to be processed by the parent
        Parameters:
        node - node to check
        Returns:
        true if the node should be processed as text, false otherwise
      • processText

        private void processText​(ITextNode textNode)
        Process the text contained in the text-node
        Parameters:
        textNode - node containing text to process
      • findFirstElement

        IElementNode findFirstElement​(INode node,
                                      java.lang.String tagName)
        Find the first element in the node-tree that corresponds with the passed tag-name. Search is performed depth-first
        Parameters:
        node - root-node to start with
        tagName - name of the tag that needs to be fonund
        Returns:
        IElementNode