pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1616959 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/
Date Sat, 09 Aug 2014 14:43:32 GMT
Author: tilman
Date: Sat Aug  9 14:43:32 2014
New Revision: 1616959

URL: http://svn.apache.org/r1616959
Log:
PDFBOX-1915: more refactoring, pulled up convertToRGB and transformPoint

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/GouraudShadingContext.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/ShadingContext.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/TriangleBasedShadingContext.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=1616959&r1=1616958&r2=1616959&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
Sat Aug  9 14:43:32 2014
@@ -163,25 +163,6 @@ public class AxialShadingContext extends
         return map;
     }
     
-    // convert color to RGB color values
-    private int convertToRGB(float[] values)
-    {
-        float[] rgbValues;
-        int normRGBValues = 0;
-        try
-        {
-            rgbValues = shadingColorSpace.toRGB(values);
-            normRGBValues = (int) (rgbValues[0] * 255);
-            normRGBValues |= (((int) (rgbValues[1] * 255)) << 8);
-            normRGBValues |= (((int) (rgbValues[2] * 255)) << 16);
-        }
-        catch (IOException exception)
-        {
-            LOG.error("error processing color space", exception);
-        }
-        return normRGBValues;
-    }
-
     @Override
     public void dispose() 
     {

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=1616959&r1=1616958&r2=1616959&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
Sat Aug  9 14:43:32 2014
@@ -116,16 +116,6 @@ abstract class GouraudShadingContext ext
         return new Vertex(tmp, colorComponentTab);
     }
     
-    // transform a point from source space to device space
-    private void transformPoint(Point2D p, Matrix ctm, AffineTransform xform)
-    {
-        if (ctm != null)
-        {
-            ctm.createAffineTransform().transform(p, p);
-        }
-        xform.transform(p, p);
-    }
-    
     protected HashMap<Point, Integer> calcPixelTable()
     {
         HashMap<Point, Integer> map = new HashMap<Point, Integer>();

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=1616959&r1=1616958&r2=1616959&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
Sat Aug  9 14:43:32 2014
@@ -84,16 +84,6 @@ abstract class PatchMeshesShadingContext
         }
     }
     
-    // transform a point from source space to device space
-    private void transformPoint(Point2D p, Matrix ctm, AffineTransform xform)
-    {
-        if (ctm != null)
-        {
-            ctm.createAffineTransform().transform(p, p);
-        }
-        xform.transform(p, p);
-    }
-    
     /**
      * Create a patch list from a data stream, the returned list contains all the patches

      * contained in the data stream.

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=1616959&r1=1616958&r2=1616959&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
Sat Aug  9 14:43:32 2014
@@ -203,25 +203,6 @@ public class RadialShadingContext extend
         return map;
     }
     
-    // convert color to RGB color values
-    private int convertToRGB(float[] values)
-    {
-        float[] rgbValues;
-        int normRGBValues = 0;
-        try
-        {
-            rgbValues = shadingColorSpace.toRGB(values);
-            normRGBValues = (int) (rgbValues[0] * 255);
-            normRGBValues |= (((int) (rgbValues[1] * 255)) << 8);
-            normRGBValues |= (((int) (rgbValues[2] * 255)) << 16);
-        }
-        catch (IOException exception)
-        {
-            LOG.error("error processing color space", exception);
-        }
-        return normRGBValues;
-    }
-
     @Override
     public void dispose() 
     {

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=1616959&r1=1616958&r2=1616959&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
Sat Aug  9 14:43:32 2014
@@ -89,4 +89,23 @@ public abstract class ShadingContext
         }
     }
 
+    // convert color to RGB color values encoded into an integer.
+    protected int convertToRGB(float[] values)
+    {
+        float[] rgbValues;
+        int normRGBValues = 0;
+        try
+        {
+            rgbValues = shadingColorSpace.toRGB(values);
+            normRGBValues = (int) (rgbValues[0] * 255);
+            normRGBValues |= (((int) (rgbValues[1] * 255)) << 8);
+            normRGBValues |= (((int) (rgbValues[2] * 255)) << 16);
+        }
+        catch (IOException exception)
+        {
+            LOG.error("error processing color space", exception);
+        }
+        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=1616959&r1=1616958&r2=1616959&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
Sat Aug  9 14:43:32 2014
@@ -19,6 +19,7 @@ package org.apache.pdfbox.pdmodel.graphi
 import java.awt.Point;
 import java.awt.Rectangle;
 import java.awt.geom.AffineTransform;
+import java.awt.geom.Point2D;
 import java.awt.image.ColorModel;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -39,14 +40,14 @@ abstract class TriangleBasedShadingConte
 {
     private static final Log LOG = LogFactory.getLog(TriangleBasedShadingContext.class);
     
-    protected final boolean hasFunction;
-
     /** bits per coordinate. */
     protected int bitsPerCoordinate;
     
     /** bits per color component */
     protected int bitsPerColorComponent; 
 
+    final protected boolean hasFunction;
+    
     public TriangleBasedShadingContext(PDShading shading, ColorModel cm, 
             AffineTransform xform, Matrix ctm, int pageHeight, Rectangle dBounds) 
             throws IOException
@@ -59,47 +60,6 @@ abstract class TriangleBasedShadingConte
         bitsPerColorComponent = triangleBasedShadingType.getBitsPerComponent();
         LOG.debug("bitsPerColorComponent: " + bitsPerColorComponent);
     }
-
-    // convert color to RGB color value, using function if required, 
-    // then convert from the shading colorspace to an RGB value,
-    // which is encoded into an integer.
-    protected int convertToRGB(float[] values)
-    {
-        float[] nValues = null;
-        int normRGBValues = 0;
-        if (hasFunction)
-        {
-            try
-            {
-                nValues = shading.evalFunction(values);
-            }
-            catch (IOException exception)
-            {
-                LOG.error("error while processing a function", exception);
-            }
-        }
-
-        try
-        {
-            float[] rgbValues;
-            if (nValues == null)
-            {
-                rgbValues = shadingColorSpace.toRGB(values);
-            }
-            else
-            {
-                rgbValues = shadingColorSpace.toRGB(nValues);
-            }
-            normRGBValues = (int) (rgbValues[0] * 255);
-            normRGBValues |= (((int) (rgbValues[1] * 255)) << 8);
-            normRGBValues |= (((int) (rgbValues[2] * 255)) << 16);
-        }
-        catch (IOException exception)
-        {
-            LOG.error("error processing color space", exception);
-        }
-        return normRGBValues;
-    }
     
     // get the points from the triangles, calculate their color and add 
     // point-color mappings to the map
@@ -139,4 +99,34 @@ abstract class TriangleBasedShadingConte
         }
     }
     
+    // transform a point from source space to device space
+    protected void transformPoint(Point2D p, Matrix ctm, AffineTransform xform)
+    {
+        if (ctm != null)
+        {
+            ctm.createAffineTransform().transform(p, p);
+        }
+        xform.transform(p, p);
+    }
+    
+    // convert color to RGB color value, using function if required,
+    // then convert from the shading colorspace to an RGB value,
+    // which is encoded into an integer.
+    @Override
+    protected int convertToRGB(float[] values)
+    {
+        if (hasFunction)
+        {
+            try
+            {
+                values = shading.evalFunction(values);
+            }
+            catch (IOException exception)
+            {
+                LOG.error("error while processing a function", exception);
+            }
+        }
+        return super.convertToRGB(values);
+    }
+
 }



Mime
View raw message