Class PdfBoxGraphics2DPaintApplier

    • Field Detail

      • EPSILON

        private static final double EPSILON
        Very small number, everything smaller than this is zero for us.
        See Also:
        Constant Field Values
      • BATIK_GRADIENT_NO_CYCLE

        private java.lang.Object BATIK_GRADIENT_NO_CYCLE
      • BATIK_GRADIENT_REFLECT

        private java.lang.Object BATIK_GRADIENT_REFLECT
      • BATIK_GRADIENT_REPEAT

        private java.lang.Object BATIK_GRADIENT_REPEAT
      • BATIK_COLORSPACE_SRGB

        private java.lang.Object BATIK_COLORSPACE_SRGB
      • BATIK_COLORSPACE_LINEAR_RGB

        private java.lang.Object BATIK_COLORSPACE_LINEAR_RGB
    • Constructor Detail

      • PdfBoxGraphics2DPaintApplier

        public PdfBoxGraphics2DPaintApplier()
    • Method Detail

      • applyPaint

        public org.apache.pdfbox.pdmodel.graphics.shading.PDShading applyPaint​(java.awt.Paint paint,
                                                                               org.apache.pdfbox.pdmodel.PDPageContentStream contentStream,
                                                                               java.awt.geom.AffineTransform tf,
                                                                               IPdfBoxGraphics2DPaintApplier.IPaintEnv env)
                                                                        throws java.io.IOException
        Description copied from interface: IPdfBoxGraphics2DPaintApplier
        Apply the paint on the ContentStream
        Specified by:
        applyPaint in interface IPdfBoxGraphics2DPaintApplier
        Parameters:
        paint - the paint which should be applied
        contentStream - the content stream to apply the paint on
        tf - the current transform of the Graphics2D relative to the contentStream default coordinate space. This is always a copy of the current transform, so we can modify it.
        env - Environment for mapping the paint.
        Returns:
        null or a PDShading which should be used to fill a shape.
        Throws:
        java.io.IOException - if its not possible to write the paint into the contentStream
      • applyPaint

        protected org.apache.pdfbox.pdmodel.graphics.shading.PDShading applyPaint​(java.awt.Paint paint,
                                                                                  PdfBoxGraphics2DPaintApplier.PaintApplierState state)
                                                                           throws java.io.IOException
        Apply paint and graphic state
        Throws:
        java.io.IOException
      • importPDFBoxShadingPaint

        private org.apache.pdfbox.pdmodel.graphics.shading.PDShading importPDFBoxShadingPaint​(org.apache.pdfbox.pdmodel.graphics.shading.ShadingPaint<?> paint,
                                                                                              PdfBoxGraphics2DPaintApplier.PaintApplierState state)
                                                                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • clonePoint

        private java.awt.geom.Point2D clonePoint​(java.awt.geom.Point2D point2D)
      • haveColorsTransparency

        static boolean haveColorsTransparency​(java.awt.Color[] colors)
      • buildLinearGradientShading

        private org.apache.pdfbox.pdmodel.graphics.shading.PDShading buildLinearGradientShading​(java.awt.Paint paint,
                                                                                                PdfBoxGraphics2DPaintApplier.PaintApplierState state)
                                                                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • linearGradientObjectBoundingBoxShading

        private org.apache.pdfbox.pdmodel.graphics.shading.PDShading linearGradientObjectBoundingBoxShading​(java.awt.Paint paint,
                                                                                                            PdfBoxGraphics2DPaintApplier.PaintApplierState state)
                                                                                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • setupShadingCoords

        private void setupShadingCoords​(org.apache.pdfbox.pdmodel.graphics.shading.PDShadingType3 shading,
                                        java.awt.geom.Point2D startPoint,
                                        java.awt.geom.Point2D endPoint)
      • linearGradientUserSpaceOnUseShading

        private org.apache.pdfbox.pdmodel.graphics.shading.PDShading linearGradientUserSpaceOnUseShading​(java.awt.Paint paint,
                                                                                                         PdfBoxGraphics2DPaintApplier.PaintApplierState state)
                                                                                                  throws java.io.IOException
        This is the default gradient mode for both SVG and java.awt gradients.
        Throws:
        java.io.IOException
      • setupBasicLinearShading

        private org.apache.pdfbox.pdmodel.graphics.shading.PDShadingType3 setupBasicLinearShading​(java.awt.Paint paint,
                                                                                                  PdfBoxGraphics2DPaintApplier.PaintApplierState state)
                                                                                           throws java.io.IOException
        Throws:
        java.io.IOException
      • mapFirstColorOfGradient

        private org.apache.pdfbox.pdmodel.graphics.color.PDColor mapFirstColorOfGradient​(PdfBoxGraphics2DPaintApplier.PaintApplierState state,
                                                                                         java.awt.Color[] colors)
                                                                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • setupExtends

        private org.apache.pdfbox.cos.COSArray setupExtends()
      • getCycleMethod

        private java.awt.MultipleGradientPaint.CycleMethod getCycleMethod​(java.awt.Paint paint)
        Map the cycleMethod of the GradientPaint to the java.awt.MultipleGradientPaint.CycleMethod enum.
        Parameters:
        paint - the paint to get the cycleMethod from (if not in any other way possible using reflection)
        Returns:
        the CycleMethod
      • getColorSpaceType

        private java.awt.MultipleGradientPaint.ColorSpaceType getColorSpaceType​(java.awt.Paint paint)
      • setupBatikReflectionAccess

        private void setupBatikReflectionAccess​(java.awt.Paint paint)
      • buildRadialGradientShading

        private org.apache.pdfbox.pdmodel.graphics.shading.PDShading buildRadialGradientShading​(java.awt.Paint paint,
                                                                                                PdfBoxGraphics2DPaintApplier.PaintApplierState state)
                                                                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • buildGradientShading

        private org.apache.pdfbox.pdmodel.graphics.shading.PDShading buildGradientShading​(java.awt.GradientPaint gradientPaint,
                                                                                          PdfBoxGraphics2DPaintApplier.PaintApplierState state)
                                                                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • buildType3Function

        private org.apache.pdfbox.pdmodel.common.function.PDFunctionType3 buildType3Function​(java.awt.Color[] colors,
                                                                                             float[] fractions,
                                                                                             PdfBoxGraphics2DPaintApplier.PaintApplierState state)
        Encode a color gradient as a type3 function
        Parameters:
        colors - The colors to encode
        fractions - the fractions for encoding
        state - our state, this is needed for color mapping
        Returns:
        the type3 function
      • needBoundsKeyFrameEntry

        private boolean needBoundsKeyFrameEntry​(float[] fractions)
      • buildType2Functions

        private org.apache.pdfbox.cos.COSArray buildType2Functions​(java.util.List<java.awt.Color> colors,
                                                                   org.apache.pdfbox.cos.COSArray domain,
                                                                   org.apache.pdfbox.cos.COSArray encode,
                                                                   PdfBoxGraphics2DPaintApplier.PaintApplierState state)
        Build a type2 function to interpolate between the given colors.
        Parameters:
        colors - the color to encode
        domain - the domain which should already been setuped. It will be used for the Type2 function
        encode - will get the domain information per color channel, i.e. colors.length x [0, 1]
        state - our internal state, this is needed for color mapping
        Returns:
        the Type2 function COSArray
      • getPropertyValue

        protected static <T> T getPropertyValue​(java.lang.Object obj,
                                                java.lang.String propertyGetter)
        Get a property value from an object using reflection
        Type Parameters:
        T - the type of the property you want to get.
        Parameters:
        obj - The object to get a property from.
        propertyGetter - method name of the getter, i.e. "getXY".
        Returns:
        the value read from the object