pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1648768 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/
Date Wed, 31 Dec 2014 19:24:19 GMT
Author: jahewson
Date: Wed Dec 31 19:24:18 2014
New Revision: 1648768

URL: http://svn.apache.org/r1648768
Log:
PDFBOX-1094: Rename "ctm" variables in shading patterns to "matrix" and update JavaDoc

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/AxialShadingContext.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/AxialShadingPaint.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/GouraudShadingContext.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShading.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType1.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType6.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType7.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PatchMeshesShadingContext.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/RadialShadingContext.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/RadialShadingPaint.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/ShadingContext.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/TriangleBasedShadingContext.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type1ShadingContext.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type1ShadingPaint.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type4ShadingContext.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type4ShadingPaint.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type5ShadingContext.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type5ShadingPaint.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type6ShadingContext.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type6ShadingPaint.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type7ShadingContext.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type7ShadingPaint.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/AxialShadingContext.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/AxialShadingContext.java?rev=1648768&r1=1648767&r2=1648768&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/AxialShadingContext.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/AxialShadingContext.java Wed Dec 31 19:24:18 2014
@@ -35,12 +35,10 @@ import org.apache.pdfbox.util.Matrix;
 /**
  * AWT PaintContext for axial shading.
  *
- * Performance improvement done as part of GSoC2014, Tilman Hausherr is the
- * mentor.
+ * Performance improvement done as part of GSoC2014, Tilman Hausherr is the mentor.
  *
  * @author Andreas Lehmkühler
  * @author Shaola Ren
- *
  */
 public class AxialShadingContext extends ShadingContext implements PaintContext
 {
@@ -67,13 +65,13 @@ public class AxialShadingContext extends
      * @param shading the shading type to be used
      * @param colorModel the color model to be used
      * @param xform transformation for user to device space
-     * @param ctm the transformation matrix
-     * @param dBounds device bounds
+     * @param matrix the pattern matrix concatenated with that of the parent content stream
+     * @param deviceBounds device bounds
      */
     public AxialShadingContext(PDShadingType2 shading, ColorModel colorModel, AffineTransform xform,
-            Matrix ctm, Rectangle dBounds) throws IOException
+                               Matrix matrix, Rectangle deviceBounds) throws IOException
     {
-        super(shading, colorModel, xform, ctm, dBounds);
+        super(shading, colorModel, xform, matrix, deviceBounds);
         this.axialShadingType = shading;
         coords = shading.getCoords().toFloatArray();
 
@@ -111,7 +109,7 @@ public class AxialShadingContext extends
         {
             // get inverse transform to be independent of current user / device space 
             // when handling actual pixels in getRaster()
-            rat = ctm.createAffineTransform().createInverse();
+            rat = matrix.createAffineTransform().createInverse();
             rat.concatenate(xform.createInverse());
         }
         catch (NoninvertibleTransformException ex)
@@ -120,8 +118,8 @@ public class AxialShadingContext extends
         }
 
         // transform the distance to actual pixel space
-        double maxX = Math.abs(ctm.getScalingFactorX() * xform.getScaleX() * longestDistance);
-        double maxY = Math.abs(ctm.getScalingFactorY() * xform.getScaleY() * longestDistance);
+        double maxX = Math.abs(matrix.getScalingFactorX() * xform.getScaleX() * longestDistance);
+        double maxY = Math.abs(matrix.getScalingFactorY() * xform.getScaleY() * longestDistance);
         factor = (int) Math.max(maxX, maxY);
         colorTable = calcColorTable();
     }
@@ -281,8 +279,6 @@ public class AxialShadingContext extends
 
     /**
      * Returns the coords values.
-     *
-     * @return the coords values as array
      */
     public float[] getCoords()
     {
@@ -291,8 +287,6 @@ public class AxialShadingContext extends
 
     /**
      * Returns the domain values.
-     *
-     * @return the domain values as array
      */
     public float[] getDomain()
     {
@@ -301,8 +295,6 @@ public class AxialShadingContext extends
 
     /**
      * Returns the extend values.
-     *
-     * @return the extend values as array
      */
     public boolean[] getExtend()
     {
@@ -311,9 +303,6 @@ public class AxialShadingContext extends
 
     /**
      * Returns the function.
-     *
-     * @return the function
-     * @throws IOException if something goes wrong
      */
     public PDFunction getFunction() throws IOException
     {

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/AxialShadingPaint.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/AxialShadingPaint.java?rev=1648768&r1=1648767&r2=1648768&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/AxialShadingPaint.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/AxialShadingPaint.java Wed Dec 31 19:24:18 2014
@@ -39,18 +39,18 @@ public class AxialShadingPaint implement
     private static final Log LOG = LogFactory.getLog(AxialShadingPaint.class);
 
     private final PDShadingType2 shading;
-    private final Matrix ctm;
+    private final Matrix matrix;
 
     /**
      * Constructor.
      *
      * @param shadingType2 the shading resources
-     * @param ctm current transformation matrix
+     * @param matrix the pattern matrix concatenated with that of the parent content stream
      */
-    AxialShadingPaint(PDShadingType2 shadingType2, Matrix ctm)
+    AxialShadingPaint(PDShadingType2 shadingType2, Matrix matrix)
     {
         shading = shadingType2;
-        this.ctm = ctm;
+        this.matrix = matrix;
     }
 
     @Override
@@ -60,13 +60,12 @@ public class AxialShadingPaint implement
     }
 
     @Override
-    public PaintContext createContext(ColorModel cm, Rectangle deviceBounds,
-            Rectangle2D userBounds, AffineTransform xform,
-            RenderingHints hints)
+    public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds,
+                                      AffineTransform xform, RenderingHints hints)
     {
         try
         {
-            return new AxialShadingContext(shading, cm, xform, ctm, deviceBounds);
+            return new AxialShadingContext(shading, cm, xform, matrix, deviceBounds);
         }
         catch (IOException ex)
         {

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/GouraudShadingContext.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/GouraudShadingContext.java?rev=1648768&r1=1648767&r2=1648768&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/GouraudShadingContext.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/GouraudShadingContext.java Wed Dec 31 19:24:18 2014
@@ -54,13 +54,13 @@ abstract class GouraudShadingContext ext
      * @param shading the shading type to be used
      * @param colorModel the color model to be used
      * @param xform transformation for user to device space
-     * @param ctm current transformation matrix
+     * @param matrix the pattern matrix concatenated with that of the parent content stream
      * @throws IOException if something went wrong
      */
     protected GouraudShadingContext(PDShading shading, ColorModel colorModel, AffineTransform xform,
-            Matrix ctm, Rectangle dBounds) throws IOException
+                                    Matrix matrix, Rectangle deviceBounds) throws IOException
     {
-        super(shading, colorModel, xform, ctm, dBounds);
+        super(shading, colorModel, xform, matrix, deviceBounds);
         triangleList = new ArrayList<ShadedTriangle>();
     }
 
@@ -68,18 +68,18 @@ abstract class GouraudShadingContext ext
      * Read a vertex from the bit input stream performs interpolations.
      *
      * @param input bit input stream
-     * @param flag the flag or any value if not relevant
      * @param maxSrcCoord max value for source coordinate (2^bits-1)
      * @param maxSrcColor max value for source color (2^bits-1)
      * @param rangeX dest range for X
      * @param rangeY dest range for Y
      * @param colRangeTab dest range array for colors
+     * @param matrix the pattern matrix concatenated with that of the parent content stream
      * @return a new vertex with the flag and the interpolated values
      * @throws IOException if something went wrong
      */
     protected Vertex readVertex(ImageInputStream input, long maxSrcCoord, long maxSrcColor,
-            PDRange rangeX, PDRange rangeY, PDRange[] colRangeTab, Matrix ctm,
-            AffineTransform xform) throws IOException
+                                PDRange rangeX, PDRange rangeY, PDRange[] colRangeTab,
+                                Matrix matrix, AffineTransform xform) throws IOException
     {
         float[] colorComponentTab = new float[numberOfColorComponents];
         long x = input.readBits(bitsPerCoordinate);
@@ -88,21 +88,20 @@ abstract class GouraudShadingContext ext
         double dstY = interpolate(y, maxSrcCoord, rangeY.getMin(), rangeY.getMax());
         LOG.debug("coord: " + String.format("[%06X,%06X] -> [%f,%f]", x, y, dstX, dstY));
         Point2D tmp = new Point2D.Double(dstX, dstY);
-        transformPoint(tmp, ctm, xform);
+        transformPoint(tmp, matrix, xform);
 
         for (int n = 0; n < numberOfColorComponents; ++n)
         {
             int color = (int) input.readBits(bitsPerColorComponent);
-            colorComponentTab[n] = (float) interpolate(color, maxSrcColor, colRangeTab[n].getMin(), colRangeTab[n].getMax());
+            colorComponentTab[n] = interpolate(color, maxSrcColor, colRangeTab[n].getMin(),
+                    colRangeTab[n].getMax());
             LOG.debug("color[" + n + "]: " + color + "/" + String.format("%02x", color)
                     + "-> color[" + n + "]: " + colorComponentTab[n]);
         }
         return new Vertex(tmp, colorComponentTab);
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    @Override
     protected Map<Point, Integer> calcPixelTable()
     {
         Map<Point, Integer> map = new HashMap<Point, Integer>();
@@ -110,9 +109,6 @@ abstract class GouraudShadingContext ext
         return map;
     }
 
-    /**
-     * {@inheritDoc}
-     */
     @Override
     public void dispose()
     {

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShading.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShading.java?rev=1648768&r1=1648767&r2=1648768&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShading.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShading.java Wed Dec 31 19:24:18 2014
@@ -32,7 +32,7 @@ import org.apache.pdfbox.util.Matrix;
 /**
  * A Shading Resource.
  *
- * @author Andreas Lehmkühler
+ * @author Andreas Lehmk�hler
  */
 public abstract class PDShading implements COSObjectable
 {
@@ -447,7 +447,8 @@ public abstract class PDShading implemen
     /**
      * Returns an AWT paint which corresponds to this shading
      *
-     * @param matrix the pattern matrix
+     * @param matrix the pattern matrix concatenated with that of the parent content stream,
+     *               this matrix which maps the pattern's internal coordinate system to user space
      * @return an AWT Paint instance
      */
     public abstract Paint toPaint(Matrix matrix);

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType1.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType1.java?rev=1648768&r1=1648767&r2=1648768&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType1.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType1.java Wed Dec 31 19:24:18 2014
@@ -55,14 +55,16 @@ public class PDShadingType1 extends PDSh
      */
     public Matrix getMatrix()
     {
-        Matrix matrix = null;
         COSArray array = (COSArray) getCOSDictionary().getDictionaryObject(COSName.MATRIX);
         if (array != null)
         {
-            matrix = new Matrix(array);
+            return new Matrix(array);
+        }
+        else
+        {
+            // identity matrix is the default
+            return new Matrix();
         }
-        // todo: else return identity matrix?
-        return matrix;
     }
 
     /**

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType6.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType6.java?rev=1648768&r1=1648767&r2=1648768&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType6.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType6.java Wed Dec 31 19:24:18 2014
@@ -26,7 +26,6 @@ import java.awt.Paint;
  */
 public class PDShadingType6 extends PDShadingType4
 {
-
     /**
      * Constructor using the given shading dictionary.
      *

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType7.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType7.java?rev=1648768&r1=1648767&r2=1648768&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType7.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PDShadingType7.java Wed Dec 31 19:24:18 2014
@@ -26,7 +26,6 @@ import java.awt.Paint;
  */
 public class PDShadingType7 extends PDShadingType6
 {
-
     /**
      * Constructor using the given shading dictionary.
      *

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PatchMeshesShadingContext.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PatchMeshesShadingContext.java?rev=1648768&r1=1648767&r2=1648768&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PatchMeshesShadingContext.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/PatchMeshesShadingContext.java Wed Dec 31 19:24:18 2014
@@ -46,52 +46,51 @@ abstract class PatchMeshesShadingContext
     private static final Log LOG = LogFactory.getLog(PatchMeshesShadingContext.class);
 
     protected final PDShading patchMeshesShadingType;
-
     protected List<Patch> patchList; // patch list
     protected int bitsPerFlag; // bits per flag
 
     /**
      * Constructor creates an instance to be used for fill operations.
-     * Constructor creates an instance to be used for fill operations.
      *
      * @param shading the shading type to be used
      * @param colorModel the color model to be used
      * @param xform transformation for user to device space
-     * @param ctm current transformation matrix
-     * @param dBounds device bounds
+     * @param matrix the pattern matrix concatenated with that of the parent content stream
+     * @param deviceBounds device bounds
      * @throws IOException if something went wrong
      */
-    protected PatchMeshesShadingContext(PDShading shading, ColorModel colorModel, AffineTransform xform,
-            Matrix ctm, Rectangle dBounds) throws IOException
+    protected PatchMeshesShadingContext(PDShading shading, ColorModel colorModel,
+                                        AffineTransform xform, Matrix matrix, Rectangle deviceBounds)
+                                        throws IOException
     {
-        super(shading, colorModel, xform, ctm, dBounds);
+        super(shading, colorModel, xform, matrix, deviceBounds);
         patchMeshesShadingType = shading;
         bitsPerFlag = ((PDShadingType6) shading).getBitsPerFlag();
         patchList = new ArrayList<Patch>();
     }
 
     /**
-     * Create a patch list from a data stream, the returned list contains all
-     * the patches contained in the data stream.
+     * Create a patch list from a data stream, the returned list contains all the patches contained
+     * in the data stream.
      *
      * @param xform transformation for user to device space
-     * @param ctm current transformation matrix
-     * @param cosDictionary dictionary object to give the image information
+     * @param matrix the pattern matrix concatenated with that of the parent content stream
+     * @param dict dictionary object to give the image information
      * @param rangeX range for coordinate x
      * @param rangeY range for coordinate y
      * @param colRange range for color
-     * @param numP number of control points, 12 for type 6 shading and 16 for
-     * type 7 shading
+     * @param numP number of control points, 12 for type 6 shading and 16 for type 7 shading
      * @return the obtained patch list
      * @throws IOException when something went wrong
      */
-    protected List<Patch> getPatchList(AffineTransform xform, Matrix ctm, COSDictionary cosDictionary,
-            PDRange rangeX, PDRange rangeY, PDRange[] colRange, int numP) throws IOException
+    protected List<Patch> getPatchList(AffineTransform xform, Matrix matrix, COSDictionary dict,
+                                       PDRange rangeX, PDRange rangeY, PDRange[] colRange, int numP)
+                                       throws IOException
     {
         List<Patch> list = new ArrayList<Patch>();
         long maxSrcCoord = (long) Math.pow(2, bitsPerCoordinate) - 1;
         long maxSrcColor = (long) Math.pow(2, bitsPerColorComponent) - 1;
-        COSStream cosStream = (COSStream) cosDictionary;
+        COSStream cosStream = (COSStream) dict;
 
         ImageInputStream mciis = new MemoryCacheImageInputStream(cosStream.getUnfilteredStream());
 
@@ -115,12 +114,12 @@ abstract class PatchMeshesShadingContext
             {
                 boolean isFree = (flag == 0);
                 Patch current = readPatch(mciis, isFree, implicitEdge, implicitCornerColor,
-                        maxSrcCoord, maxSrcColor, rangeX, rangeY, colRange, ctm, xform, numP);
+                        maxSrcCoord, maxSrcColor, rangeX, rangeY, colRange, matrix, xform, numP);
                 if (current == null)
                 {
                     break;
                 }
-                list.add((Patch) current);
+                list.add(current);
                 flag = (byte) (mciis.readBits(bitsPerFlag) & 3);
                 switch (flag)
                 {
@@ -153,32 +152,28 @@ abstract class PatchMeshesShadingContext
     }
 
     /**
-     * Read a single patch from a data stream, a patch contains information of
-     * its coordinates and color parameters.
+     * Read a single patch from a data stream, a patch contains information of its coordinates and
+     * color parameters.
      *
      * @param input the image source data stream
      * @param isFree whether this is a free patch
-     * @param implicitEdge implicit edge when a patch is not free, otherwise
-     * it's not used
-     * @param implicitCornerColor implicit colors when a patch is not free,
-     * otherwise it's not used
-     * @param maxSrcCoord the maximum coordinate value calculated from source
-     * data
+     * @param implicitEdge implicit edge when a patch is not free, otherwise it's not used
+     * @param implicitCornerColor implicit colors when a patch is not free, otherwise it's not used
+     * @param maxSrcCoord the maximum coordinate value calculated from source data
      * @param maxSrcColor the maximum color value calculated from source data
      * @param rangeX range for coordinate x
      * @param rangeY range for coordinate y
      * @param colRange range for color
-     * @param ctm current transformation matrix
+     * @param matrix the pattern matrix concatenated with that of the parent content stream
      * @param xform transformation for user to device space
-     * @param numP number of control points, 12 for type 6 shading and 16 for
-     * type 7 shading
+     * @param numP number of control points, 12 for type 6 shading and 16 for type 7 shading
      * @return a single patch
      * @throws IOException when something went wrong
      */
     protected Patch readPatch(ImageInputStream input, boolean isFree, Point2D[] implicitEdge,
-            float[][] implicitCornerColor, long maxSrcCoord, long maxSrcColor,
-            PDRange rangeX, PDRange rangeY, PDRange[] colRange,
-            Matrix ctm, AffineTransform xform, int numP) throws IOException
+                              float[][] implicitCornerColor, long maxSrcCoord, long maxSrcColor,
+                              PDRange rangeX, PDRange rangeY, PDRange[] colRange, Matrix matrix,
+                              AffineTransform xform, int numP) throws IOException
     {
         float[][] color = new float[4][numberOfColorComponents];
         Point2D[] points = new Point2D[numP];
@@ -211,7 +206,7 @@ abstract class PatchMeshesShadingContext
                 double px = interpolate(x, maxSrcCoord, rangeX.getMin(), rangeX.getMax());
                 double py = interpolate(y, maxSrcCoord, rangeY.getMin(), rangeY.getMax());
                 Point2D tmp = new Point2D.Double(px, py);
-                transformPoint(tmp, ctm, xform);
+                transformPoint(tmp, matrix, xform);
                 points[i] = tmp;
             }
             for (int i = cStart; i < 4; i++)
@@ -219,7 +214,8 @@ abstract class PatchMeshesShadingContext
                 for (int j = 0; j < numberOfColorComponents; j++)
                 {
                     long c = input.readBits(bitsPerColorComponent);
-                    color[i][j] = (float) interpolate(c, maxSrcColor, colRange[j].getMin(), colRange[j].getMax());
+                    color[i][j] = (float) interpolate(c, maxSrcColor, colRange[j].getMin(),
+                                                      colRange[j].getMax());
                 }
             }
         }
@@ -242,15 +238,14 @@ abstract class PatchMeshesShadingContext
      */
     abstract Patch generatePatch(Point2D[] points, float[][] color);
 
-    // get a point coordinate on a line by linear interpolation
+    /**
+     * Get a point coordinate on a line by linear interpolation.
+     */
     private double interpolate(double x, long maxValue, float rangeMin, float rangeMax)
     {
         return rangeMin + (x / maxValue) * (rangeMax - rangeMin);
     }
 
-    /**
-     * {@inheritDoc}
-     */
     @Override
     protected Map<Point, Integer> calcPixelTable()
     {
@@ -262,9 +257,6 @@ abstract class PatchMeshesShadingContext
         return map;
     }
 
-    /**
-     * {@inheritDoc}
-     */
     @Override
     public void dispose()
     {

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/RadialShadingContext.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/RadialShadingContext.java?rev=1648768&r1=1648767&r2=1648768&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/RadialShadingContext.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/RadialShadingContext.java Wed Dec 31 19:24:18 2014
@@ -69,14 +69,14 @@ public class RadialShadingContext extend
      * @param shading the shading type to be used
      * @param colorModel the color model to be used
      * @param xform transformation for user to device space
-     * @param ctm the transformation matrix
+     * @param matrix the pattern matrix concatenated with that of the parent content stream
      * @param deviceBounds device bounds
      */
     public RadialShadingContext(PDShadingType3 shading, ColorModel colorModel,
-                                AffineTransform xform, Matrix ctm, Rectangle deviceBounds)
+                                AffineTransform xform, Matrix matrix, Rectangle deviceBounds)
                                 throws IOException
     {
-        super(shading, colorModel, xform, ctm, deviceBounds);
+        super(shading, colorModel, xform, matrix, deviceBounds);
         this.radialShadingType = shading;
         coords = shading.getCoords().toFloatArray();
 
@@ -119,7 +119,7 @@ public class RadialShadingContext extend
         {
             // get inverse transform to be independent of current user / device space 
             // when handling actual pixels in getRaster()
-            rat = ctm.createAffineTransform().createInverse();
+            rat = matrix.createAffineTransform().createInverse();
             rat.concatenate(xform.createInverse());
         }
         catch (NoninvertibleTransformException ex)
@@ -128,8 +128,8 @@ public class RadialShadingContext extend
         }
 
         // transform the distance to actual pixel space
-        double maxX = Math.abs(ctm.getScalingFactorX() * xform.getScaleX() * longestDistance);
-        double maxY = Math.abs(ctm.getScalingFactorY() * xform.getScaleY() * longestDistance);
+        double maxX = Math.abs(matrix.getScalingFactorX() * xform.getScaleX() * longestDistance);
+        double maxY = Math.abs(matrix.getScalingFactorY() * xform.getScaleY() * longestDistance);
         factor = (int) Math.max(maxX, maxY);
         colorTable = calcColorTable();
     }
@@ -160,11 +160,10 @@ public class RadialShadingContext extend
     }
 
     /**
-     * Calculate the color on the line that connects two circles' centers and
-     * store the result in an array.
+     * Calculate the color on the line that connects two circles' centers and store the result in an
+     * array.
      *
-     * @return an array, index denotes the relative position, the corresponding
-     * value the color
+     * @return an array, index denotes the relative position, the corresponding value the color
      */
     private int[] calcColorTable()
     {
@@ -395,8 +394,6 @@ public class RadialShadingContext extend
 
     /**
      * Returns the coords values.
-     *
-     * @return the coords values as array
      */
     public float[] getCoords()
     {
@@ -405,8 +402,6 @@ public class RadialShadingContext extend
 
     /**
      * Returns the domain values.
-     *
-     * @return the domain values as array
      */
     public float[] getDomain()
     {
@@ -415,8 +410,6 @@ public class RadialShadingContext extend
 
     /**
      * Returns the extend values.
-     *
-     * @return the extend values as array
      */
     public boolean[] getExtend()
     {
@@ -425,9 +418,6 @@ public class RadialShadingContext extend
 
     /**
      * Returns the function.
-     *
-     * @return the function
-     * @throws IOException if something goes wrong
      */
     public PDFunction getFunction() throws IOException
     {

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/RadialShadingPaint.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/RadialShadingPaint.java?rev=1648768&r1=1648767&r2=1648768&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/RadialShadingPaint.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/RadialShadingPaint.java Wed Dec 31 19:24:18 2014
@@ -39,18 +39,18 @@ public class RadialShadingPaint implemen
     private static final Log LOG = LogFactory.getLog(RadialShadingPaint.class);
 
     private final PDShadingType3 shading;
-    private final Matrix ctm;
+    private final Matrix matrix;
 
     /**
      * Constructor.
      *
      * @param shading the shading resources
-     * @param ctm current transformation matrix
+     * @param matrix the pattern matrix concatenated with that of the parent content stream
      */
-    RadialShadingPaint(PDShadingType3 shading, Matrix ctm)
+    RadialShadingPaint(PDShadingType3 shading, Matrix matrix)
     {
         this.shading = shading;
-        this.ctm = ctm;
+        this.matrix = matrix;
     }
 
     @Override
@@ -61,11 +61,11 @@ public class RadialShadingPaint implemen
 
     @Override
     public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds,
-            AffineTransform xform, RenderingHints hints)
+                                      AffineTransform xform, RenderingHints hints)
     {
         try
         {
-            return new RadialShadingContext(shading, cm, xform, ctm, deviceBounds);
+            return new RadialShadingContext(shading, cm, xform, matrix, deviceBounds);
         }
         catch (IOException ex)
         {

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/ShadingContext.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/ShadingContext.java?rev=1648768&r1=1648767&r2=1648768&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/ShadingContext.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/ShadingContext.java Wed Dec 31 19:24:18 2014
@@ -49,11 +49,20 @@ public abstract class ShadingContext
     protected float[] background;
     protected int rgbBackground;
 
+    /**
+     * Constructor.
+     *
+     * @param shading the shading type to be used
+     * @param cm the color model to be used
+     * @param xform transformation for user to device space
+     * @param matrix the pattern matrix concatenated with that of the parent content stream
+     * @param deviceBounds device bounds
+     */
     public ShadingContext(PDShading shading, ColorModel cm, AffineTransform xform,
-            Matrix ctm, Rectangle dBounds) throws IOException
+                          Matrix matrix, Rectangle deviceBounds) throws IOException
     {
         this.shading = shading;
-        deviceBounds = dBounds;
+        this.deviceBounds = deviceBounds;
         shadingColorSpace = shading.getColorSpace();
 
         // create the output color model using RGB+alpha as color space
@@ -64,7 +73,7 @@ public abstract class ShadingContext
         bboxRect = shading.getBBox();
         if (bboxRect != null)
         {
-            transformBBox(ctm, xform);
+            transformBBox(matrix, xform);
         }
         
         // get background values if available
@@ -76,18 +85,17 @@ public abstract class ShadingContext
         }
     }
 
-    private void transformBBox(Matrix ctm, AffineTransform xform)
+    private void transformBBox(Matrix matrix, AffineTransform xform)
     {
         float[] bboxTab = new float[4];
         bboxTab[0] = bboxRect.getLowerLeftX();
         bboxTab[1] = bboxRect.getLowerLeftY();
         bboxTab[2] = bboxRect.getUpperRightX();
         bboxTab[3] = bboxRect.getUpperRightY();
-        if (ctm != null)
-        {
-            // transform the coords using the given matrix
-            ctm.createAffineTransform().transform(bboxTab, 0, bboxTab, 0, 2);
-        }
+
+        // transform the coords using the given matrix
+        matrix.createAffineTransform().transform(bboxTab, 0, bboxTab, 0, 2);
+
         xform.transform(bboxTab, 0, bboxTab, 0, 2);
         minBBoxX = Math.min(bboxTab[0], bboxTab[2]);
         minBBoxY = Math.min(bboxTab[1], bboxTab[3]);
@@ -115,8 +123,8 @@ public abstract class ShadingContext
         {
             rgbValues = shadingColorSpace.toRGB(values);
             normRGBValues = (int) (rgbValues[0] * 255);
-            normRGBValues |= (((int) (rgbValues[1] * 255)) << 8);
-            normRGBValues |= (((int) (rgbValues[2] * 255)) << 16);
+            normRGBValues |= (int) (rgbValues[1] * 255) << 8;
+            normRGBValues |= (int) (rgbValues[2] * 255) << 16;
         }
         catch (IOException exception)
         {
@@ -124,5 +132,4 @@ public abstract class ShadingContext
         }
         return normRGBValues;
     }
-
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/TriangleBasedShadingContext.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/TriangleBasedShadingContext.java?rev=1648768&r1=1648767&r2=1648768&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/TriangleBasedShadingContext.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/TriangleBasedShadingContext.java Wed Dec 31 19:24:18 2014
@@ -31,8 +31,8 @@ import org.apache.commons.logging.LogFac
 import org.apache.pdfbox.util.Matrix;
 
 /**
- * Intermediate class extended by the shading types 4,5,6 and 7 that contains
- * the common methods used by these classes.
+ * Intermediate class extended by the shading types 4,5,6 and 7 that contains the common methods
+ * used by these classes.
  *
  * @author Shaola Ren
  * @author Tilman Hausherr
@@ -41,33 +41,27 @@ abstract class TriangleBasedShadingConte
 {
     private static final Log LOG = LogFactory.getLog(TriangleBasedShadingContext.class);
 
-    /**
-     * bits per coordinate.
-     */
     protected int bitsPerCoordinate;
-
-    /**
-     * bits per color component
-     */
     protected int bitsPerColorComponent;
-
-    /**
-     * number of color components.
-     */
     protected int numberOfColorComponents;
+    protected final boolean hasFunction;
 
-    final protected boolean hasFunction;
+    // map of pixels within triangles to their RGB color
+    private Map<Point, Integer> pixelTable;
 
     /**
-     * Map of pixels within triangles to their RGB color.
+     * Constructor.
+     *
+     * @param shading the shading type to be used
+     * @param cm the color model to be used
+     * @param xform transformation for user to device space
+     * @param matrix the pattern matrix concatenated with that of the parent content stream
+     * @throws IOException if something went wrong
      */
-    private Map<Point, Integer> pixelTable;
-
-    public TriangleBasedShadingContext(PDShading shading, ColorModel cm,
-            AffineTransform xform, Matrix ctm, Rectangle dBounds)
-            throws IOException
+    public TriangleBasedShadingContext(PDShading shading, ColorModel cm, AffineTransform xform,
+                                       Matrix matrix, Rectangle deviceBounds) throws IOException
     {
-        super(shading, cm, xform, ctm, dBounds);
+        super(shading, cm, xform, matrix, deviceBounds);
         PDTriangleBasedShadingType triangleBasedShadingType = (PDTriangleBasedShadingType) shading;
         hasFunction = shading.getFunction() != null;
         bitsPerCoordinate = triangleBasedShadingType.getBitsPerCoordinate();
@@ -128,13 +122,15 @@ abstract class TriangleBasedShadingConte
         }
     }
 
-    // transform a point from source space to device space
-    protected void transformPoint(Point2D p, Matrix ctm, AffineTransform xform)
+    /**
+     * Transform a point from pattern space to device space.
+     * @param p point
+     * @param matrix the pattern matrix concatenated with that of the parent content stream
+     * @param xform transformation for user to device space
+     */
+    protected void transformPoint(Point2D p, Matrix matrix, AffineTransform xform)
     {
-        if (ctm != null)
-        {
-            ctm.createAffineTransform().transform(p, p);
-        }
+        matrix.createAffineTransform().transform(p, p);
         xform.transform(p, p);
     }
 
@@ -157,21 +153,17 @@ abstract class TriangleBasedShadingConte
         return convertToRGB(values);
     }
 
-    // true if the relevant list is empty
-    abstract boolean emptyList();
-    
     /**
-     * {@inheritDoc}
+     * True if the relevant list is empty.
      */
+    abstract boolean emptyList();
+
     @Override
     public final ColorModel getColorModel()
     {
         return outputColorModel;
     }
 
-    /**
-     * {@inheritDoc}
-     */
     @Override
     public void dispose()
     {
@@ -179,9 +171,6 @@ abstract class TriangleBasedShadingConte
         shadingColorSpace = null;
     }
 
-    /**
-     * {@inheritDoc}
-     */
     @Override
     public final Raster getRaster(int x, int y, int w, int h)
     {
@@ -230,5 +219,4 @@ abstract class TriangleBasedShadingConte
         raster.setPixels(0, 0, w, h, data);
         return raster;
     }
-
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type1ShadingContext.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type1ShadingContext.java?rev=1648768&r1=1648767&r2=1648768&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type1ShadingContext.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type1ShadingContext.java Wed Dec 31 19:24:18 2014
@@ -40,7 +40,7 @@ class Type1ShadingContext extends Shadin
     private PDShadingType1 type1ShadingType;
     private AffineTransform rat;
     private final float[] domain;
-    private Matrix matrix;
+    private Matrix patternMatrix;
 
     /**
      * Constructor creates an instance to be used for fill operations.
@@ -48,16 +48,15 @@ class Type1ShadingContext extends Shadin
      * @param shading the shading type to be used
      * @param colorModel the color model to be used
      * @param xform transformation for user to device space
-     * @param ctm current transformation matrix
-     * @param dBounds device bounds
+     * @param matrix the pattern matrix concatenated with that of the parent content stream
+     * @param deviceBounds device bounds
      */
     public Type1ShadingContext(PDShadingType1 shading, ColorModel colorModel, AffineTransform xform,
-            Matrix ctm, Rectangle dBounds) throws IOException
+                               Matrix matrix, Rectangle deviceBounds) throws IOException
     {
-        super(shading, colorModel, xform, ctm, dBounds);
+        super(shading, colorModel, xform, matrix, deviceBounds);
         this.type1ShadingType = shading;
 
-        // spec p.308
         // (Optional) An array of four numbers [ xmin xmax ymin ymax ] 
         // specifying the rectangular domain of coordinates over which the 
         // color function(s) are defined. Default value: [ 0.0 1.0 0.0 1.0 ].
@@ -70,19 +69,15 @@ class Type1ShadingContext extends Shadin
             domain = new float[] { 0, 1, 0, 1 };
         }
 
-        matrix = shading.getMatrix();
-        if (matrix == null)
-        {
-            matrix = new Matrix();
-        }
+        patternMatrix = shading.getMatrix();
 
         try
         {
             // get inverse transform to be independent of 
             // shading matrix and current user / device space 
             // when handling actual pixels in getRaster()
-            rat = matrix.createAffineTransform().createInverse();
-            rat.concatenate(ctm.createAffineTransform().createInverse());
+            rat = patternMatrix.createAffineTransform().createInverse();
+            rat.concatenate(matrix.createAffineTransform().createInverse());
             rat.concatenate(xform.createInverse());
         }
         catch (NoninvertibleTransformException ex)
@@ -128,7 +123,8 @@ class Type1ShadingContext extends Shadin
                 boolean useBackground = false;
                 float[] values = new float[] { x + i, y + j };
                 rat.transform(values, 0, values, 0, 1);
-                if (values[0] < domain[0] || values[0] > domain[1] || values[1] < domain[2] || values[1] > domain[3])
+                if (values[0] < domain[0] || values[0] > domain[1] ||
+                    values[1] < domain[2] || values[1] > domain[3])
                 {
                     if (background == null)
                     {

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type1ShadingPaint.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type1ShadingPaint.java?rev=1648768&r1=1648767&r2=1648768&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type1ShadingPaint.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type1ShadingPaint.java Wed Dec 31 19:24:18 2014
@@ -37,18 +37,18 @@ class Type1ShadingPaint implements Paint
     private static final Log LOG = LogFactory.getLog(Type1ShadingPaint.class);
 
     private PDShadingType1 shading;
-    private Matrix ctm;
+    private Matrix matrix;
 
     /**
      * Constructor.
      *
      * @param shading the shading resources
-     * @param ctm current transformation matrix
+     * @param matrix the pattern matrix concatenated with that of the parent content stream
      */
-    Type1ShadingPaint(PDShadingType1 shading, Matrix ctm)
+    Type1ShadingPaint(PDShadingType1 shading, Matrix matrix)
     {
         this.shading = shading;
-        this.ctm = ctm;
+        this.matrix = matrix;
     }
 
     @Override
@@ -59,11 +59,11 @@ class Type1ShadingPaint implements Paint
 
     @Override
     public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds,
-            AffineTransform xform, RenderingHints hints)
+                                      AffineTransform xform, RenderingHints hints)
     {
         try
         {
-            return new Type1ShadingContext(shading, cm, xform, ctm, deviceBounds);
+            return new Type1ShadingContext(shading, cm, xform, matrix, deviceBounds);
         }
         catch (IOException ex)
         {

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type4ShadingContext.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type4ShadingContext.java?rev=1648768&r1=1648767&r2=1648768&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type4ShadingContext.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type4ShadingContext.java Wed Dec 31 19:24:18 2014
@@ -50,24 +50,25 @@ class Type4ShadingContext extends Gourau
      * @param shading the shading type to be used
      * @param cm the color model to be used
      * @param xform transformation for user to device space
-     * @param ctm current transformation matrix
+     * @param matrix the pattern matrix concatenated with that of the parent content stream
      */
     public Type4ShadingContext(PDShadingType4 shading, ColorModel cm, AffineTransform xform,
-            Matrix ctm, Rectangle dBounds) throws IOException
+                               Matrix matrix, Rectangle deviceBounds) throws IOException
     {
-        super(shading, cm, xform, ctm, dBounds);
+        super(shading, cm, xform, matrix, deviceBounds);
         LOG.debug("Type4ShadingContext");
 
         bitsPerFlag = shading.getBitsPerFlag();
         LOG.debug("bitsPerFlag: " + bitsPerFlag); //TODO handle cases where bitperflag isn't 8
-        triangleList = getTriangleList(xform, ctm);
+        triangleList = getTriangleList(xform, matrix);
         createPixelTable();
     }
 
-    private List<ShadedTriangle> getTriangleList(AffineTransform xform, Matrix ctm) throws IOException
+    private List<ShadedTriangle> getTriangleList(AffineTransform xform, Matrix matrix)
+            throws IOException
     {
         PDShadingType4 freeTriangleShadingType = (PDShadingType4) shading;
-        COSDictionary cosDictionary = freeTriangleShadingType.getCOSDictionary();
+        COSDictionary dict = freeTriangleShadingType.getCOSDictionary();
         PDRange rangeX = freeTriangleShadingType.getDecodeForParameter(0);
         PDRange rangeY = freeTriangleShadingType.getDecodeForParameter(1);
         PDRange[] colRange = new PDRange[numberOfColorComponents];
@@ -78,11 +79,11 @@ class Type4ShadingContext extends Gourau
         List<ShadedTriangle> list = new ArrayList<ShadedTriangle>();
         long maxSrcCoord = (long) Math.pow(2, bitsPerCoordinate) - 1;
         long maxSrcColor = (long) Math.pow(2, bitsPerColorComponent) - 1;
-        COSStream cosStream = (COSStream) cosDictionary;
+        COSStream stream = (COSStream) dict;
 
-        ImageInputStream mciis = new MemoryCacheImageInputStream(cosStream.getUnfilteredStream());
-        byte flag = (byte) 0;
+        ImageInputStream mciis = new MemoryCacheImageInputStream(stream.getUnfilteredStream());
 
+        byte flag = (byte) 0;
         try
         {
             flag = (byte) (mciis.readBits(bitsPerFlag) & 3);
@@ -103,19 +104,22 @@ class Type4ShadingContext extends Gourau
                 switch (flag)
                 {
                     case 0:
-                        p0 = readVertex(mciis, maxSrcCoord, maxSrcColor, rangeX, rangeY, colRange, ctm, xform);
+                        p0 = readVertex(mciis, maxSrcCoord, maxSrcColor, rangeX, rangeY, colRange,
+                                        matrix, xform);
                         flag = (byte) (mciis.readBits(bitsPerFlag) & 3);
                         if (flag != 0)
                         {
                             LOG.error("bad triangle: " + flag);
                         }
-                        p1 = readVertex(mciis, maxSrcCoord, maxSrcColor, rangeX, rangeY, colRange, ctm, xform);
+                        p1 = readVertex(mciis, maxSrcCoord, maxSrcColor, rangeX, rangeY, colRange,
+                                        matrix, xform);
                         mciis.readBits(bitsPerFlag);
                         if (flag != 0)
                         {
                             LOG.error("bad triangle: " + flag);
                         }
-                        p2 = readVertex(mciis, maxSrcCoord, maxSrcColor, rangeX, rangeY, colRange, ctm, xform);
+                        p2 = readVertex(mciis, maxSrcCoord, maxSrcColor, rangeX, rangeY, colRange,
+                                        matrix, xform);
                         ps = new Point2D[] { p0.point, p1.point, p2.point };
                         cs = new float[][] { p0.color, p1.color, p2.color };
                         list.add(new ShadedTriangle(ps, cs));
@@ -131,7 +135,8 @@ class Type4ShadingContext extends Gourau
                         else
                         {
                             ShadedTriangle preTri = list.get(lastIndex);
-                            p2 = readVertex(mciis, maxSrcCoord, maxSrcColor, rangeX, rangeY, colRange, ctm, xform);
+                            p2 = readVertex(mciis, maxSrcCoord, maxSrcColor, rangeX, rangeY,
+                                            colRange, matrix, xform);
                             ps = new Point2D[] { flag == 1 ? preTri.corner[1] : preTri.corner[0],
                                                  preTri.corner[2],
                                                  p2.point };
@@ -155,5 +160,4 @@ class Type4ShadingContext extends Gourau
         mciis.close();
         return list;
     }
-
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type4ShadingPaint.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type4ShadingPaint.java?rev=1648768&r1=1648767&r2=1648768&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type4ShadingPaint.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type4ShadingPaint.java Wed Dec 31 19:24:18 2014
@@ -37,18 +37,18 @@ class Type4ShadingPaint implements Paint
     private static final Log LOG = LogFactory.getLog(Type4ShadingPaint.class);
 
     private PDShadingType4 shading;
-    private Matrix ctm;
+    private Matrix matrix;
 
     /**
      * Constructor.
      *
      * @param shading the shading resources
-     * @param ctm current transformation matrix
+     * @param matrix the pattern matrix concatenated with that of the parent content stream
      */
-    Type4ShadingPaint(PDShadingType4 shading, Matrix ctm)
+    Type4ShadingPaint(PDShadingType4 shading, Matrix matrix)
     {
         this.shading = shading;
-        this.ctm = ctm;
+        this.matrix = matrix;
     }
 
     @Override
@@ -59,11 +59,11 @@ class Type4ShadingPaint implements Paint
 
     @Override
     public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds,
-            AffineTransform xform, RenderingHints hints)
+                                      AffineTransform xform, RenderingHints hints)
     {
         try
         {
-            return new Type4ShadingContext(shading, cm, xform, ctm, deviceBounds);
+            return new Type4ShadingContext(shading, cm, xform, matrix, deviceBounds);
         }
         catch (IOException ex)
         {

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type5ShadingContext.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type5ShadingContext.java?rev=1648768&r1=1648767&r2=1648768&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type5ShadingContext.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type5ShadingContext.java Wed Dec 31 19:24:18 2014
@@ -49,21 +49,22 @@ class Type5ShadingContext extends Gourau
      * @param shading the shading type to be used
      * @param cm the color model to be used
      * @param xform transformation for user to device space
-     * @param ctm current transformation matrix
+     * @param matrix the pattern matrix concatenated with that of the parent content stream
      * @throws IOException if something went wrong
      */
     public Type5ShadingContext(PDShadingType5 shading, ColorModel cm, AffineTransform xform,
-            Matrix ctm, Rectangle dBounds) throws IOException
+                               Matrix matrix, Rectangle deviceBounds) throws IOException
     {
-        super(shading, cm, xform, ctm, dBounds);
+        super(shading, cm, xform, matrix, deviceBounds);
 
         LOG.debug("Type5ShadingContext");
 
-        triangleList = getTriangleList(xform, ctm);
+        triangleList = getTriangleList(xform, matrix);
         createPixelTable();
     }
 
-    private List<ShadedTriangle> getTriangleList(AffineTransform xform, Matrix ctm) throws IOException
+    private List<ShadedTriangle> getTriangleList(AffineTransform xform, Matrix matrix)
+            throws IOException
     {
         List<ShadedTriangle> list = new ArrayList<ShadedTriangle>();
         PDShadingType5 latticeTriangleShadingType = (PDShadingType5) shading;
@@ -87,7 +88,7 @@ class Type5ShadingContext extends Gourau
             Vertex p;
             try
             {
-                p = readVertex(mciis, maxSrcCoord, maxSrcColor, rangeX, rangeY, colRange, ctm, xform);
+                p = readVertex(mciis, maxSrcCoord, maxSrcColor, rangeX, rangeY, colRange, matrix, xform);
                 vlist.add(p);
             }
             catch (EOFException ex)

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type5ShadingPaint.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type5ShadingPaint.java?rev=1648768&r1=1648767&r2=1648768&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type5ShadingPaint.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type5ShadingPaint.java Wed Dec 31 19:24:18 2014
@@ -37,18 +37,18 @@ class Type5ShadingPaint implements Paint
     private static final Log LOG = LogFactory.getLog(Type5ShadingPaint.class);
 
     private PDShadingType5 shading;
-    private Matrix ctm;
+    private Matrix matrix;
 
     /**
      * Constructor.
      *
      * @param shading the shading resources
-     * @param ctm current transformation matrix
+     * @param matrix the pattern matrix concatenated with that of the parent content stream
      */
-    Type5ShadingPaint(PDShadingType5 shading, Matrix ctm)
+    Type5ShadingPaint(PDShadingType5 shading, Matrix matrix)
     {
         this.shading = shading;
-        this.ctm = ctm;
+        this.matrix = matrix;
     }
 
     @Override
@@ -59,11 +59,11 @@ class Type5ShadingPaint implements Paint
 
     @Override
     public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds,
-            AffineTransform xform, RenderingHints hints)
+                                      AffineTransform xform, RenderingHints hints)
     {
         try
         {
-            return new Type5ShadingContext(shading, cm, xform, ctm, deviceBounds);
+            return new Type5ShadingContext(shading, cm, xform, matrix, deviceBounds);
         }
         catch (IOException ex)
         {

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type6ShadingContext.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type6ShadingContext.java?rev=1648768&r1=1648767&r2=1648768&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type6ShadingContext.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type6ShadingContext.java Wed Dec 31 19:24:18 2014
@@ -33,30 +33,29 @@ import org.apache.pdfbox.util.Matrix;
  */
 class Type6ShadingContext extends PatchMeshesShadingContext
 {
-
     /**
      * Constructor creates an instance to be used for fill operations.
      *
      * @param shading the shading type to be used
      * @param colorModel the color model to be used
      * @param xform transformation for user to device space
-     * @param ctm current transformation matrix
+     * @param matrix the pattern matrix concatenated with that of the parent content stream
      * @param dBounds device bounds
      * @throws IOException if something went wrong
      */
     public Type6ShadingContext(PDShadingType6 shading, ColorModel colorModel, AffineTransform xform,
-            Matrix ctm, Rectangle dBounds) throws IOException
+                               Matrix matrix, Rectangle dBounds) throws IOException
     {
-        super(shading, colorModel, xform, ctm, dBounds);
-        patchList = getCoonsPatchList(xform, ctm);
+        super(shading, colorModel, xform, matrix, dBounds);
+        patchList = getCoonsPatchList(xform, matrix);
         createPixelTable();
     }
 
     // get the patch list which forms the type 6 shading image from data stream
-    private List<Patch> getCoonsPatchList(AffineTransform xform, Matrix ctm) throws IOException
+    private List<Patch> getCoonsPatchList(AffineTransform xform, Matrix matrix) throws IOException
     {
         PDShadingType6 coonsShadingType = (PDShadingType6) patchMeshesShadingType;
-        COSDictionary cosDictionary = coonsShadingType.getCOSDictionary();
+        COSDictionary dict = coonsShadingType.getCOSDictionary();
         PDRange rangeX = coonsShadingType.getDecodeForParameter(0);
         PDRange rangeY = coonsShadingType.getDecodeForParameter(1);
         PDRange[] colRange = new PDRange[numberOfColorComponents];
@@ -64,7 +63,7 @@ class Type6ShadingContext extends PatchM
         {
             colRange[i] = coonsShadingType.getDecodeForParameter(2 + i);
         }
-        return getPatchList(xform, ctm, cosDictionary, rangeX, rangeY, colRange, 12);
+        return getPatchList(xform, matrix, dict, rangeX, rangeY, colRange, 12);
     }
 
     @Override
@@ -72,5 +71,4 @@ class Type6ShadingContext extends PatchM
     {
         return new CoonsPatch(points, color);
     }
-
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type6ShadingPaint.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type6ShadingPaint.java?rev=1648768&r1=1648767&r2=1648768&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type6ShadingPaint.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type6ShadingPaint.java Wed Dec 31 19:24:18 2014
@@ -38,18 +38,18 @@ class Type6ShadingPaint implements Paint
     private static final Log LOG = LogFactory.getLog(Type6ShadingPaint.class);
 
     private final PDShadingType6 shading;
-    private final Matrix ctm;
+    private final Matrix matrix;
 
     /**
      * Constructor.
      *
      * @param shading the shading resources
-     * @param ctm current transformation matrix
+     * @param matrix the pattern matrix concatenated with that of the parent content stream
      */
-    public Type6ShadingPaint(PDShadingType6 shading, Matrix ctm)
+    public Type6ShadingPaint(PDShadingType6 shading, Matrix matrix)
     {
         this.shading = shading;
-        this.ctm = ctm;
+        this.matrix = matrix;
     }
 
     @Override
@@ -64,7 +64,7 @@ class Type6ShadingPaint implements Paint
     {
         try
         {
-            return new Type6ShadingContext(shading, cm, xform, ctm, deviceBounds);
+            return new Type6ShadingContext(shading, cm, xform, matrix, deviceBounds);
         }
         catch (IOException ex)
         {

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type7ShadingContext.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type7ShadingContext.java?rev=1648768&r1=1648767&r2=1648768&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type7ShadingContext.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type7ShadingContext.java Wed Dec 31 19:24:18 2014
@@ -33,30 +33,29 @@ import org.apache.pdfbox.util.Matrix;
  */
 class Type7ShadingContext extends PatchMeshesShadingContext
 {
-
     /**
      * Constructor creates an instance to be used for fill operations.
      *
      * @param shading the shading type to be used
      * @param colorModel the color model to be used
      * @param xform transformation for user to device space
-     * @param ctm current transformation matrix
-     * @param dBounds device bounds
+     * @param matrix the pattern matrix concatenated with that of the parent content stream
+     * @param deviceBounds device bounds
      * @throws IOException if something went wrong
      */
     public Type7ShadingContext(PDShadingType7 shading, ColorModel colorModel, AffineTransform xform,
-            Matrix ctm, Rectangle dBounds) throws IOException
+                               Matrix matrix, Rectangle deviceBounds) throws IOException
     {
-        super(shading, colorModel, xform, ctm, dBounds);
-        patchList = getTensorPatchList(xform, ctm);
+        super(shading, colorModel, xform, matrix, deviceBounds);
+        patchList = getTensorPatchList(xform, matrix);
         createPixelTable();
     }
 
     // get the patch list which forms the type 7 shading image from data stream
-    private List<Patch> getTensorPatchList(AffineTransform xform, Matrix ctm) throws IOException
+    private List<Patch> getTensorPatchList(AffineTransform xform, Matrix matrix) throws IOException
     {
         PDShadingType7 tensorShadingType = (PDShadingType7) patchMeshesShadingType;
-        COSDictionary cosDictionary = tensorShadingType.getCOSDictionary();
+        COSDictionary dict = tensorShadingType.getCOSDictionary();
         PDRange rangeX = tensorShadingType.getDecodeForParameter(0);
         PDRange rangeY = tensorShadingType.getDecodeForParameter(1);
         PDRange[] colRange = new PDRange[numberOfColorComponents];
@@ -64,7 +63,7 @@ class Type7ShadingContext extends PatchM
         {
             colRange[i] = tensorShadingType.getDecodeForParameter(2 + i);
         }
-        return getPatchList(xform, ctm, cosDictionary, rangeX, rangeY, colRange, 16);
+        return getPatchList(xform, matrix, dict, rangeX, rangeY, colRange, 16);
     }
 
     @Override
@@ -72,5 +71,4 @@ class Type7ShadingContext extends PatchM
     {
         return new TensorPatch(points, color);
     }
-
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type7ShadingPaint.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type7ShadingPaint.java?rev=1648768&r1=1648767&r2=1648768&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type7ShadingPaint.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Type7ShadingPaint.java Wed Dec 31 19:24:18 2014
@@ -38,18 +38,18 @@ class Type7ShadingPaint implements Paint
     private static final Log LOG = LogFactory.getLog(Type7ShadingPaint.class);
 
     private final PDShadingType7 shading;
-    private final Matrix ctm;
+    private final Matrix matrix;
 
     /**
      * Constructor.
      *
      * @param shading the shading resources
-     * @param ctm current transformation matrix
+     * @param matrix the pattern matrix concatenated with that of the parent content stream
      */
-    public Type7ShadingPaint(PDShadingType7 shading, Matrix ctm)
+    public Type7ShadingPaint(PDShadingType7 shading, Matrix matrix)
     {
         this.shading = shading;
-        this.ctm = ctm;
+        this.matrix = matrix;
     }
 
     @Override
@@ -64,7 +64,7 @@ class Type7ShadingPaint implements Paint
     {
         try
         {
-            return new Type7ShadingContext(shading, cm, xform, ctm, deviceBounds);
+            return new Type7ShadingContext(shading, cm, xform, matrix, deviceBounds);
         }
         catch (IOException ex)
         {



Mime
View raw message