Author: vhennebert
Date: Thu Jul 10 17:48:11 2014
New Revision: 1609524

URL: http://svn.apache.org/r1609524
Log:
Factorized creation of gradient bounds

Modified:
    
xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java

Modified: 
xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java?rev=1609524&r1=1609523&r2=1609524&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java
 (original)
+++ 
xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java
 Thu Jul 10 17:48:11 2014
@@ -112,20 +112,13 @@ public class PSSVGGraphics2D extends PSG
 
         List<Color> colors = createGradientColors(gp);
 
-        float[] fractions = gp.getFractions();
-        List<Double> theBounds = new java.util.ArrayList<Double>();
-        for (int count = 0; count < fractions.length; count++) {
-            float offset = fractions[count];
-            if (0f < offset && offset < 1f) {
-                theBounds.add(new Double(offset));
-            }
-        }
+        List<Double> bounds = createGradientBounds(gp);
         PDFDeviceColorSpace colSpace;
         colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB);
 
         PSGradientFactory gradientFactory = new PSGradientFactory();
         PSPattern myPattern = gradientFactory.createGradient(false, colSpace,
-                colors, theBounds, theCoords, matrix);
+                colors, bounds, theCoords, matrix);
 
         gen.write(myPattern.toString());
 
@@ -163,20 +156,13 @@ public class PSSVGGraphics2D extends PSG
 
         List<Color> colors = createGradientColors(gp);
 
-        float[] fractions = gp.getFractions();
-        List<Double> theBounds = new java.util.ArrayList<Double>();
-        for (int count = 0; count < fractions.length; count++) {
-            float offset = fractions[count];
-            if (0f < offset && offset < 1f) {
-                theBounds.add(new Double(offset));
-            }
-        }
+        List<Double> bounds = createGradientBounds(gp);
         PDFDeviceColorSpace colSpace;
         colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB);
 
         PSGradientFactory gradientFactory = new PSGradientFactory();
         PSPattern myPattern = gradientFactory.createGradient(true, colSpace,
-                colors, theBounds, theCoords, matrix);
+                colors, bounds, theCoords, matrix);
 
         gen.write(myPattern.toString());
     }
@@ -210,6 +196,18 @@ public class PSSVGGraphics2D extends PSG
         return gradientColors;
     }
 
+    private List<Double> createGradientBounds(MultipleGradientPaint gradient) {
+        // TODO is the conversion to double necessary?
+        float[] fractions = gradient.getFractions();
+        List<Double> bounds = new 
java.util.ArrayList<Double>(fractions.length);
+        for (float offset : fractions) {
+            if (0f < offset && offset < 1f) {
+                bounds.add(Double.valueOf(offset));
+            }
+        }
+        return bounds;
+    }
+
     private AffineTransform applyTransform(AffineTransform base, double posX, 
double posY) {
         AffineTransform result = AffineTransform.getTranslateInstance(posX, 
posY);
         AffineTransform orig = base;



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to