Class AbstractBranchSvgNodeRenderer

    • Field Detail

      • VIEWBOX_VALUES_NUMBER

        protected static final int VIEWBOX_VALUES_NUMBER
        The number of viewBox values.
        See Also:
        Constant Field Values
      • LOGGER

        private static final org.slf4j.Logger LOGGER
    • Constructor Detail

      • AbstractBranchSvgNodeRenderer

        public AbstractBranchSvgNodeRenderer()
    • Method Detail

      • doDraw

        protected void doDraw​(SvgDrawContext context)
        Method that will set properties to be inherited by this branch renderer's children and will iterate over all children in order to draw them.
        Specified by:
        doDraw in class AbstractSvgNodeRenderer
        Parameters:
        context - the object that knows the place to draw this element and maintains its state
      • addXObject

        static void addXObject​(PdfCanvas canvas,
                               PdfXObject xObject,
                               float x,
                               float y)
      • applyViewBox

        void applyViewBox​(SvgDrawContext context)
        Applies a transformation based on a viewBox for a given branch node.
        Parameters:
        context - current svg draw context
      • retrieveAlignAndMeet

        java.lang.String[] retrieveAlignAndMeet()
      • applyViewportClip

        private void applyViewportClip​(SvgDrawContext context)
        Applies a clipping operation based on the view port.
        Parameters:
        context - the svg draw context
      • applyViewportTranslationCorrection

        private void applyViewportTranslationCorrection​(SvgDrawContext context)
      • processAspectRatioPosition

        AffineTransform processAspectRatioPosition​(SvgDrawContext context,
                                                   float[] viewBoxValues,
                                                   java.lang.String align,
                                                   float scaleWidth,
                                                   float scaleHeight)
        If present, process the preserveAspectRatio position.
        Parameters:
        context - the svg draw context
        viewBoxValues - the four values depicting the viewbox [min-x min-y width height]
        align - alignment method to use
        scaleWidth - the multiplier for scaling width
        scaleHeight - the multiplier for scaling height
        Returns:
        the transformation based on the preserveAspectRatio value
      • cleanUp

        private void cleanUp​(SvgDrawContext context)
        Cleans up the SvgDrawContext by removing the current viewport and by popping the current canvas.
        Parameters:
        context - context to clean
      • calculateAndApplyViewBox

        void calculateAndApplyViewBox​(SvgDrawContext context,
                                      float[] values,
                                      Rectangle currentViewPort)
      • getViewBoxValues

        float[] getViewBoxValues()
      • scaleViewBoxValues

        private static float[] scaleViewBoxValues​(float[] values,
                                                  float scaleWidth,
                                                  float scaleHeight)
      • writeBBoxAccordingToVisibleOverflow

        private static void writeBBoxAccordingToVisibleOverflow​(SvgDrawContext context,
                                                                PdfStream stream)
        When in the svg element overflow is visible the corresponding formXObject should have a BBox (form XObject’s bounding box; see PDF 32000-1:2008 - 8.10.2 Form Dictionaries) that should cover the entire svg space (page in pdf) in order to be able to show parts of the element which are outside the current element viewPort. To do this, we get the inverse matrix of all the current transformation matrix changes and apply it to the root viewPort. This allows you to get the root rectangle in the final coordinate system.
        Parameters:
        context - current context to get canvases and view ports
        stream - stream to write a BBox