Class PathSvgNodeRenderer

    • Field Detail

      • INVALID_REGEX_PATTERN

        private static final java.util.regex.Pattern INVALID_REGEX_PATTERN
      • SPLIT_PATTERN

        private static final java.util.regex.Pattern SPLIT_PATTERN
        The regular expression to split the PathData attribute of the <path> element

        Since containsInvalidAttributes(String) is called before the use of this expression in parsePathOperations() the attribute to be split is valid.

        SVG defines 6 types of path commands, for a total of 20 commands:

        MoveTo: M, m LineTo: L, l, H, h, V, v Cubic Bezier Curve: C, c, S, s Quadratic Bezier Curve: Q, q, T, t Elliptical Arc Curve: A, a ClosePath: Z, z

      • zOperator

        private ClosePath zOperator
        The ClosePath shape keeping track of the initial point set by a MoveTo operation. The original value is null, and must be set via a MoveTo operation before it may be drawn.
    • Constructor Detail

      • PathSvgNodeRenderer

        public PathSvgNodeRenderer()
    • Method Detail

      • doDraw

        public void doDraw​(SvgDrawContext context)
        Description copied from class: AbstractSvgNodeRenderer
        Draws this element to a canvas-like object maintained in the context.
        Specified by:
        doDraw in class AbstractSvgNodeRenderer
        Parameters:
        context - the object that knows the place to draw this element and maintains its state
      • getObjectBoundingBox

        public Rectangle getObjectBoundingBox​(SvgDrawContext context)
        Description copied from interface: ISvgNodeRenderer
        Calculates the current object bounding box.
        Specified by:
        getObjectBoundingBox in interface ISvgNodeRenderer
        Parameters:
        context - the current context, for instance it contains current viewport and available font data
        Returns:
        the Rectangle representing the current object's bounding box, or null if bounding box is undefined
      • processPathOperator

        private java.util.List<IPathShape> processPathOperator​(java.lang.String[] pathProperties,
                                                               IPathShape previousShape)
        Processes an individual pathing operator and all of its arguments, converting into one or more IPathShape objects.
        Parameters:
        pathProperties - The property operator and all arguments as an array of Strings
        previousShape - The previous shape which can affect the positioning of the current shape. If no previous shape exists null is passed.
        Returns:
        a List of each IPathShape that should be drawn to represent the operator.
      • addMoveToShapes

        private java.util.List<IPathShape> addMoveToShapes​(IPathShape pathShape,
                                                           java.lang.String[] pathProperties,
                                                           IPathShape beforeMoveShape)
      • concatenate

        private static java.lang.String[] concatenate​(java.lang.String[] first,
                                                      java.lang.String[] second)
      • containsInvalidAttributes

        boolean containsInvalidAttributes​(java.lang.String attributes)
      • parsePathOperations

        java.util.Collection<java.lang.String> parsePathOperations()
      • separateDecimalPoints

        java.lang.String separateDecimalPoints​(java.lang.String input)
        Iterate over the input string and separate numbers from each other with space chars
      • splitPathStringIntoOperators

        static java.lang.String[] splitPathStringIntoOperators​(java.lang.String path)
        Gets an array of strings representing operators with their arguments, e.g. {"M 100 100", "L 300 100", "L200, 300", "z"}
      • endsWithNonWhitespace

        private static boolean endsWithNonWhitespace​(java.lang.StringBuilder sb)
      • drawMarker

        public void drawMarker​(SvgDrawContext context,
                               MarkerVertexType markerVertexType)
        Description copied from interface: IMarkerCapable
        Draws a marker in the specified context. The marker is drawn on the vertices defined according to the given marker type.
        Specified by:
        drawMarker in interface IMarkerCapable
        Parameters:
        context - the object that knows the place to draw this element and maintains its state
        markerVertexType - type of marker that determine on which vertices of the given element marker should be drawn
      • getAutoOrientAngle

        public double getAutoOrientAngle​(MarkerSvgNodeRenderer marker,
                                         boolean reverse)
        Description copied from interface: IMarkerCapable
        Calculates marker orientation angle if orient attribute is set to auto
        Specified by:
        getAutoOrientAngle in interface IMarkerCapable
        Parameters:
        marker - marker for which the rotation angle should be calculated
        reverse - indicates that the resulting angle should be rotated 180 degrees
        Returns:
        marker orientation angle so that its positive x-axis is pointing in the direction of the path at the point it is placed
      • getCurrentPoint

        private static Point getCurrentPoint​(IPathShape previousShape)