pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1670743 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/
Date Wed, 01 Apr 2015 18:10:09 GMT
Author: tilman
Date: Wed Apr  1 18:10:08 2015
New Revision: 1670743

URL: http://svn.apache.org/r1670743
Log:
PDFBOX-2576: make fields final; remove uneeded casts; remove public modifier from methods
of non public class

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/CubicBezierCurve.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Line.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/Patch.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/ShadedTriangle.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/Type1ShadingPaint.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/Type5ShadingPaint.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/Type7ShadingPaint.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Vertex.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=1670743&r1=1670742&r2=1670743&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 Apr  1 18:10:08 2015
@@ -132,6 +132,7 @@ public class AxialShadingContext extends
      *
      * @return an array, index denotes the relative position, the corresponding
      * value is the color on the axial line
+     * @throws IOException if the color conversion fails.
      */
     private int[] calcColorTable() throws IOException
     {
@@ -145,7 +146,7 @@ public class AxialShadingContext extends
         {
             for (int i = 0; i <= factor; i++)
             {
-                float t = domain[0] + d1d0 * i / (float) factor;
+                float t = domain[0] + d1d0 * i / factor;
                 float[] values = axialShadingType.evalFunction(t);
                 map[i] = convertToRGB(values);
             }
@@ -292,6 +293,8 @@ public class AxialShadingContext extends
 
     /**
      * Returns the function.
+     *
+     * @throws java.io.IOException if we were not able to create the function.
      */
     public PDFunction getFunction() throws IOException
     {

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/CubicBezierCurve.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/CubicBezierCurve.java?rev=1670743&r1=1670742&r2=1670743&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/CubicBezierCurve.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/CubicBezierCurve.java
Wed Apr  1 18:10:08 2015
@@ -37,7 +37,7 @@ class CubicBezierCurve
      * into 2^0 = 1 segments, if l = n, one cubic Bezier curve is divided into
      * 2^n segments
      */
-    public CubicBezierCurve(Point2D[] ctrlPnts, int l)
+    CubicBezierCurve(Point2D[] ctrlPnts, int l)
     {
         controlPoints = ctrlPnts.clone();
         level = l;
@@ -49,7 +49,7 @@ class CubicBezierCurve
      *
      * @return level
      */
-    public int getLevel()
+    int getLevel()
     {
         return level;
     }
@@ -86,7 +86,7 @@ class CubicBezierCurve
      *
      * @return sampled points
      */
-    public Point2D[] getCubicBezierCurve()
+    Point2D[] getCubicBezierCurve()
     {
         return curve;
     }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Line.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Line.java?rev=1670743&r1=1670742&r2=1670743&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Line.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Line.java
Wed Apr  1 18:10:08 2015
@@ -42,7 +42,7 @@ class Line
      * @param c0 color of point p0
      * @param c1 color of point p1
      */
-    public Line(Point p0, Point p1, float[] c0, float[] c1)
+    Line(Point p0, Point p1, float[] c0, float[] c1)
     {
         point0 = p0;
         point1 = p1;
@@ -81,13 +81,13 @@ class Line
             int e2 = 2 * err;
             if (e2 > -dy)
             {
-                err = err - dy;
-                x0 = x0 + sx;
+                err -= dy;
+                x0 += sx;
             }
             if (e2 < dx)
             {
-                err = err + dx;
-                y0 = y0 + sy;
+                err += dx;
+                y0 += sy;
             }
         }
         return points;
@@ -113,7 +113,7 @@ class Line
             float l = point1.y - point0.y;
             for (int i = 0; i < numberOfColorComponents; i++)
             {
-                pc[i] = (float) (color0[i] * (point1.y - p.y) / l
+                pc[i] = (color0[i] * (point1.y - p.y) / l
                         + color1[i] * (p.y - point0.y) / l);
             }
         }
@@ -122,7 +122,7 @@ class Line
             float l = point1.x - point0.x;
             for (int i = 0; i < numberOfColorComponents; i++)
             {
-                pc[i] = (float) (color0[i] * (point1.x - p.x) / l
+                pc[i] = (color0[i] * (point1.x - p.x) / l
                         + color1[i] * (p.x - point0.x) / l);
             }
         }

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=1670743&r1=1670742&r2=1670743&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 Apr  1 18:10:08 2015
@@ -35,7 +35,7 @@ import org.apache.pdfbox.util.Matrix;
  */
 public abstract class PDShading implements COSObjectable
 {
-    private COSDictionary dictionary;
+    private final COSDictionary dictionary;
     private COSArray background = null;
     private PDRectangle bBox = null;
     private PDColorSpace colorSpace = null;
@@ -110,6 +110,7 @@ public abstract class PDShading implemen
      *
      * @return the cos object that matches this Java object
      */
+    @Override
     public COSBase getCOSObject()
     {
         return dictionary;
@@ -341,7 +342,7 @@ public abstract class PDShading implemen
      * This will return the function used to convert the color values.
      *
      * @return the function
-     * @exception IOException if we are unable to create the PDFunction object
+     * @throws java.io.IOException if we were not able to create the function.
      */
     public PDFunction getFunction() throws IOException
     {
@@ -409,7 +410,7 @@ public abstract class PDShading implemen
     {
         PDFunction[] functions = getFunctionsArray();
         int numberOfFunctions = functions.length;
-        float[] returnValues = null;
+        float[] returnValues;
         if (numberOfFunctions == 1)
         {
             returnValues = functions[0].eval(input);

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Patch.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Patch.java?rev=1670743&r1=1670742&r2=1670743&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Patch.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Patch.java
Wed Apr  1 18:10:08 2015
@@ -45,7 +45,7 @@ abstract class Patch
      * type 7 shading)
      * @param color 4 corner's colors
      */
-    public Patch(Point2D[] ctl, float[][] color)
+    Patch(Point2D[] ctl, float[][] color)
     {
         cornerColor = color.clone();
     }

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=1670743&r1=1670742&r2=1670743&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 Apr  1 18:10:08 2015
@@ -180,7 +180,7 @@ public class RadialShadingContext extend
         {
             for (int i = 0; i <= factor; i++)
             {
-                float t = domain[0] + d1d0 * i / (float) factor;
+                float t = domain[0] + d1d0 * i / factor;
                 float[] values = radialShadingType.evalFunction(t);
                 map[i] = convertToRGB(values);
             }
@@ -407,6 +407,8 @@ public class RadialShadingContext extend
 
     /**
      * Returns the function.
+     *
+     * @throws java.io.IOException if we were not able to create the function.
      */
     public PDFunction getFunction() throws IOException
     {

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/ShadedTriangle.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/ShadedTriangle.java?rev=1670743&r1=1670742&r2=1670743&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/ShadedTriangle.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/ShadedTriangle.java
Wed Apr  1 18:10:08 2015
@@ -55,7 +55,7 @@ class ShadedTriangle
      * @param p an array of the 3 vertices of a triangle
      * @param c an array of color corresponding the vertex array p
      */
-    public ShadedTriangle(Point2D[] p, float[][] c)
+    ShadedTriangle(Point2D[] p, float[][] c)
     {
         corner = p.clone();
         color = c.clone();

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=1670743&r1=1670742&r2=1670743&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 Apr  1 18:10:08 2015
@@ -120,10 +120,9 @@ public abstract class ShadingContext
      */
     protected final int convertToRGB(float[] values) throws IOException
     {
-        float[] rgbValues;
-        int normRGBValues = 0;
+        int normRGBValues;
 
-        rgbValues = shadingColorSpace.toRGB(values);
+        float[] rgbValues = shadingColorSpace.toRGB(values);
         normRGBValues = (int) (rgbValues[0] * 255);
         normRGBValues |= (int) (rgbValues[1] * 255) << 8;
         normRGBValues |= (int) (rgbValues[2] * 255) << 16;

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=1670743&r1=1670742&r2=1670743&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 Apr  1 18:10:08 2015
@@ -37,8 +37,8 @@ class Type1ShadingPaint implements Paint
 {
     private static final Log LOG = LogFactory.getLog(Type1ShadingPaint.class);
 
-    private PDShadingType1 shading;
-    private Matrix matrix;
+    private final PDShadingType1 shading;
+    private final Matrix matrix;
 
     /**
      * Constructor.

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=1670743&r1=1670742&r2=1670743&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 Apr  1 18:10:08 2015
@@ -37,8 +37,8 @@ class Type4ShadingPaint implements Paint
 {
     private static final Log LOG = LogFactory.getLog(Type4ShadingPaint.class);
 
-    private PDShadingType4 shading;
-    private Matrix matrix;
+    private final PDShadingType4 shading;
+    private final Matrix matrix;
 
     /**
      * Constructor.

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=1670743&r1=1670742&r2=1670743&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 Apr  1 18:10:08 2015
@@ -37,8 +37,8 @@ class Type5ShadingPaint implements Paint
 {
     private static final Log LOG = LogFactory.getLog(Type5ShadingPaint.class);
 
-    private PDShadingType5 shading;
-    private Matrix matrix;
+    private final PDShadingType5 shading;
+    private final Matrix matrix;
 
     /**
      * Constructor.

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=1670743&r1=1670742&r2=1670743&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 Apr  1 18:10:08 2015
@@ -47,7 +47,7 @@ class Type6ShadingPaint implements Paint
      * @param shading the shading resources
      * @param matrix the pattern matrix concatenated with that of the parent content stream
      */
-    public Type6ShadingPaint(PDShadingType6 shading, Matrix matrix)
+    Type6ShadingPaint(PDShadingType6 shading, Matrix matrix)
     {
         this.shading = shading;
         this.matrix = matrix;

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=1670743&r1=1670742&r2=1670743&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 Apr  1 18:10:08 2015
@@ -47,7 +47,7 @@ class Type7ShadingPaint implements Paint
      * @param shading the shading resources
      * @param matrix the pattern matrix concatenated with that of the parent content stream
      */
-    public Type7ShadingPaint(PDShadingType7 shading, Matrix matrix)
+    Type7ShadingPaint(PDShadingType7 shading, Matrix matrix)
     {
         this.shading = shading;
         this.matrix = matrix;

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Vertex.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Vertex.java?rev=1670743&r1=1670742&r2=1670743&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Vertex.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/Vertex.java
Wed Apr  1 18:10:08 2015
@@ -28,7 +28,7 @@ class Vertex
     public Point2D point;
     public float[] color;
 
-    public Vertex(Point2D p, float[] c)
+    Vertex(Point2D p, float[] c)
     {
         point = p;
         color = c.clone();



Mime
View raw message