Class PatchMeshesShadingContext

  • All Implemented Interfaces:
    java.awt.PaintContext
    Direct Known Subclasses:
    Type6ShadingContext, Type7ShadingContext

    abstract class PatchMeshesShadingContext
    extends TriangleBasedShadingContext
    This class is extended in Type6ShadingContext and Type7ShadingContext. This was done as part of GSoC2014, Tilman Hausherr is the mentor.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected PatchMeshesShadingContext​(PDShadingType6 shading, java.awt.image.ColorModel colorModel, java.awt.geom.AffineTransform xform, Matrix matrix, java.awt.Rectangle deviceBounds, int controlPoints)
      Constructor creates an instance to be used for fill operations.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.util.Map<java.awt.Point,​java.lang.Integer> calcPixelTable​(java.awt.Rectangle deviceBounds)
      Calculate every point and its color and store them in a Hash table.
      (package private) java.util.List<Patch> collectPatches​(PDShadingType6 shadingType, java.awt.geom.AffineTransform xform, Matrix matrix, int controlPoints)
      Create a patch list from a data stream, the returned list contains all the patches contained in the data stream.
      void dispose()  
      (package private) abstract Patch generatePatch​(java.awt.geom.Point2D[] points, float[][] color)
      Create a patch using control points and 4 corner color values, in Type6ShadingContext, a CoonsPatch is returned; in Type6ShadingContext, a TensorPatch is returned.
      private float interpolate​(float x, long maxValue, float rangeMin, float rangeMax)
      Get a point coordinate on a line by linear interpolation.
      protected boolean isDataEmpty()
      Returns true if the shading has an empty data stream.
      protected Patch readPatch​(javax.imageio.stream.ImageInputStream input, boolean isFree, java.awt.geom.Point2D[] implicitEdge, float[][] implicitCornerColor, long maxSrcCoord, long maxSrcColor, PDRange rangeX, PDRange rangeY, PDRange[] colRange, Matrix matrix, java.awt.geom.AffineTransform xform, int controlPoints)
      Read a single patch from a data stream, a patch contains information of its coordinates and color parameters.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOG

        private static final org.apache.commons.logging.Log LOG
      • patchList

        private java.util.List<Patch> patchList
        patch list
    • Constructor Detail

      • PatchMeshesShadingContext

        protected PatchMeshesShadingContext​(PDShadingType6 shading,
                                            java.awt.image.ColorModel colorModel,
                                            java.awt.geom.AffineTransform xform,
                                            Matrix matrix,
                                            java.awt.Rectangle deviceBounds,
                                            int controlPoints)
                                     throws java.io.IOException
        Constructor creates an instance to be used for fill operations.
        Parameters:
        shading - the shading type to be used
        colorModel - the color model to be used
        xform - transformation for user to device space
        matrix - the pattern matrix concatenated with that of the parent content stream
        deviceBounds - device bounds
        controlPoints - number of control points, 12 for type 6 shading and 16 for type 7 shading
        Throws:
        java.io.IOException - if something went wrong
    • Method Detail

      • collectPatches

        final java.util.List<Patch> collectPatches​(PDShadingType6 shadingType,
                                                   java.awt.geom.AffineTransform xform,
                                                   Matrix matrix,
                                                   int controlPoints)
                                            throws java.io.IOException
        Create a patch list from a data stream, the returned list contains all the patches contained in the data stream.
        Parameters:
        shadingType - the shading type
        xform - transformation for user to device space
        matrix - the pattern matrix concatenated with that of the parent content stream
        controlPoints - number of control points, 12 for type 6 shading and 16 for type 7 shading
        Returns:
        the obtained patch list
        Throws:
        java.io.IOException - when something went wrong
      • readPatch

        protected Patch readPatch​(javax.imageio.stream.ImageInputStream input,
                                  boolean isFree,
                                  java.awt.geom.Point2D[] implicitEdge,
                                  float[][] implicitCornerColor,
                                  long maxSrcCoord,
                                  long maxSrcColor,
                                  PDRange rangeX,
                                  PDRange rangeY,
                                  PDRange[] colRange,
                                  Matrix matrix,
                                  java.awt.geom.AffineTransform xform,
                                  int controlPoints)
                           throws java.io.IOException
        Read a single patch from a data stream, a patch contains information of its coordinates and color parameters.
        Parameters:
        input - the image source data stream
        isFree - whether this is a free patch
        implicitEdge - implicit edge when a patch is not free, otherwise it's not used
        implicitCornerColor - implicit colors when a patch is not free, otherwise it's not used
        maxSrcCoord - the maximum coordinate value calculated from source data
        maxSrcColor - the maximum color value calculated from source data
        rangeX - range for coordinate x
        rangeY - range for coordinate y
        colRange - range for color
        matrix - the pattern matrix concatenated with that of the parent content stream
        xform - transformation for user to device space
        controlPoints - number of control points, 12 for type 6 shading and 16 for type 7 shading
        Returns:
        a single patch
        Throws:
        java.io.IOException - when something went wrong
      • generatePatch

        abstract Patch generatePatch​(java.awt.geom.Point2D[] points,
                                     float[][] color)
        Create a patch using control points and 4 corner color values, in Type6ShadingContext, a CoonsPatch is returned; in Type6ShadingContext, a TensorPatch is returned.
        Parameters:
        points - 12 or 16 control points
        color - 4 corner colors
        Returns:
        a patch instance
      • interpolate

        private float interpolate​(float x,
                                  long maxValue,
                                  float rangeMin,
                                  float rangeMax)
        Get a point coordinate on a line by linear interpolation.
      • calcPixelTable

        protected java.util.Map<java.awt.Point,​java.lang.Integer> calcPixelTable​(java.awt.Rectangle deviceBounds)
                                                                                throws java.io.IOException
        Description copied from class: TriangleBasedShadingContext
        Calculate every point and its color and store them in a Hash table.
        Specified by:
        calcPixelTable in class TriangleBasedShadingContext
        Returns:
        a Hash table which contains all the points' positions and colors of one image
        Throws:
        java.io.IOException