]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Factorized outputDoubles into GradientMaker
authorVincent Hennebert <vhennebert@apache.org>
Mon, 14 Jul 2014 21:25:13 +0000 (21:25 +0000)
committerVincent Hennebert <vhennebert@apache.org>
Mon, 14 Jul 2014 21:25:13 +0000 (21:25 +0000)
Removed conversion to Double when unnecessary

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP-2393_gradient-rendering@1610538 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/render/gradient/Function.java
src/java/org/apache/fop/render/gradient/GradientMaker.java
src/java/org/apache/fop/render/gradient/Shading.java

index 220c5f79107d3299f05f273c51b19d5dcb6f5ca2..ca87d509db09cca952ccde1c99bca839b136dcee 100644 (file)
@@ -375,14 +375,14 @@ public class Function {
             outputEncode(out);
             out.append("/Bounds ");
             if (bounds != null) {
-                outputDoubles(out, bounds);
+                GradientMaker.outputDoubles(out, bounds);
             } else if (!functions.isEmpty()) {
                 // if there are n functions,
                 // there must be n-1 bounds.
                 // so let each function handle an equal portion
                 // of the whole. e.g. if there are 4, then [ 0.25 0.25 0.25 ]
                 int numberOfFunctions = functions.size();
-                String functionsFraction = PDFNumber.doubleOut(Double.valueOf(1.0 / (numberOfFunctions)));
+                String functionsFraction = PDFNumber.doubleOut(1.0 / numberOfFunctions);
                 out.append("[ ");
                 for (int i = 0; i + 1 < numberOfFunctions; i++) {
                     out.append(functionsFraction);
@@ -407,7 +407,7 @@ public class Function {
     private void outputDomain(StringBuilder p) {
         if (domain != null) {
             p.append("/Domain ");
-            outputDoubles(p, domain);
+            GradientMaker.outputDoubles(p, domain);
             p.append("\n");
         } else {
             p.append("/Domain [ 0 1 ]\n");
@@ -417,7 +417,7 @@ public class Function {
     private void outputSize(StringBuilder out) {
         if (size != null) {
             out.append("/Size ");
-            outputDoubles(out, size);
+            GradientMaker.outputDoubles(out, size);
             out.append("\n");
         }
     }
@@ -435,7 +435,7 @@ public class Function {
     private void outputRange(StringBuilder out) {
         if (range != null) {
             out.append("/Range ");
-            outputDoubles(out, range);
+            GradientMaker.outputDoubles(out, range);
             out.append("\n");
         }
     }
@@ -443,7 +443,7 @@ public class Function {
     private void outputEncode(StringBuilder out) {
         if (encode != null) {
             out.append("/Encode ");
-            outputDoubles(out, encode);
+            GradientMaker.outputDoubles(out, encode);
             out.append("\n");
         } else {
             out.append("/Encode [ ");
@@ -458,7 +458,7 @@ public class Function {
     private void outputDecode(StringBuilder out) {
         if (decode != null) {
             out.append("/Decode ");
-            outputDoubles(out, decode);
+            GradientMaker.outputDoubles(out, decode);
             out.append("\n");
         }
     }
@@ -503,17 +503,8 @@ public class Function {
 
     private void outputInterpolationExponentN(StringBuilder out) {
         out.append("/N ");
-        out.append(PDFNumber.doubleOut(Double.valueOf(interpolationExponentN)));
+        out.append(PDFNumber.doubleOut(interpolationExponentN));
         out.append("\n");
     }
 
-    private void outputDoubles(StringBuilder out, List<Double> doubles) {
-        out.append("[ ");
-        for (Double d : doubles) {
-            out.append(PDFNumber.doubleOut(d));
-            out.append(" ");
-        }
-        out.append("]");
-    }
-
 }
index 02db2c5fea43d5ff364d39543db97ffb44aad2a8..1f378e465fb312e0b7c1452aad1cb0613cb20049 100644 (file)
@@ -32,6 +32,7 @@ import org.apache.batik.ext.awt.RadialGradientPaint;
 import org.apache.xmlgraphics.java2d.color.ColorUtil;
 
 import org.apache.fop.pdf.PDFDeviceColorSpace;
+import org.apache.fop.pdf.PDFNumber;
 
 public final class GradientMaker {
 
@@ -151,4 +152,13 @@ public final class GradientMaker {
         return gradientColors;
     }
 
+    static void outputDoubles(StringBuilder out, List<Double> doubles) {
+        out.append("[ ");
+        for (Double d : doubles) {
+            out.append(PDFNumber.doubleOut(d));
+            out.append(" ");
+        }
+        out.append("]");
+    }
+
 }
index 61f933cdd9478ced945821909c69bff3ded7c9b0..593a22dd22c74ba298705172bd76cd6c89859465 100644 (file)
@@ -20,7 +20,6 @@ package org.apache.fop.render.gradient;
 import java.util.List;
 
 import org.apache.fop.pdf.PDFDeviceColorSpace;
-import org.apache.fop.pdf.PDFNumber;
 
 
 public class Shading {
@@ -220,13 +219,13 @@ public class Shading {
 
         if (background != null) {
             out.append("/Background ");
-            outputDoubles(out, background);
+            GradientMaker.outputDoubles(out, background);
             out.append("\n");
         }
 
         if (bbox != null) {
             out.append("/BBox");
-            outputDoubles(out, bbox);
+            GradientMaker.outputDoubles(out, bbox);
             out.append("\n");
         }
 
@@ -255,19 +254,10 @@ public class Shading {
         out.append(">>");
     }
 
-    private void outputDoubles(StringBuilder out, List<Double> doubles) {
-        out.append("[ ");
-        for (Double d : doubles) {
-            out.append(PDFNumber.doubleOut(d));
-            out.append(" ");
-        }
-        out.append("]");
-    }
-
     private void outputShadingType1(StringBuilder out, Shading.FunctionRenderer functionRenderer) {
         if (domain != null) {
             out.append("/Domain ");
-            outputDoubles(out, domain);
+            GradientMaker.outputDoubles(out, domain);
             out.append("\n");
         } else {
             out.append("/Domain [ 0 1 ] \n");
@@ -275,7 +265,7 @@ public class Shading {
 
         if (matrix != null) {
             out.append("/Matrix ");
-            outputDoubles(out, matrix);
+            GradientMaker.outputDoubles(out, matrix);
             out.append("\n");
         }
         outputFunction(out, functionRenderer);
@@ -284,13 +274,13 @@ public class Shading {
     private void outputShadingType2or3(StringBuilder out, Shading.FunctionRenderer functionRenderer) {
         if (coords != null) {
             out.append("/Coords ");
-            outputDoubles(out, coords);
+            GradientMaker.outputDoubles(out, coords);
             out.append("\n");
         }
 
         if (domain != null) {
             out.append("/Domain ");
-            outputDoubles(out, domain);
+            GradientMaker.outputDoubles(out, domain);
             out.append("\n");
         } else {
             out.append("/Domain [ 0 1 ] \n");
@@ -331,7 +321,7 @@ public class Shading {
 
         if (decode != null) {
             out.append("/Decode ");
-            outputDoubles(out, decode);
+            GradientMaker.outputDoubles(out, decode);
             out.append("\n");
         }
 
@@ -353,7 +343,7 @@ public class Shading {
 
         if (decode != null) {
             out.append("/Decode ");
-            outputDoubles(out, decode);
+            GradientMaker.outputDoubles(out, decode);
             out.append("\n");
         }