You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by vh...@apache.org on 2014/07/18 15:48:44 UTC

svn commit: r1611652 - in /xmlgraphics/fop/branches/FOP-2393_gradient-rendering: src/java/org/apache/fop/render/gradient/Function.java test/java/org/apache/fop/render/gradient/GradientTestCase.java

Author: vhennebert
Date: Fri Jul 18 13:48:43 2014
New Revision: 1611652

URL: http://svn.apache.org/r1611652
Log:
Check bounds and encode

Modified:
    xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/gradient/Function.java
    xmlgraphics/fop/branches/FOP-2393_gradient-rendering/test/java/org/apache/fop/render/gradient/GradientTestCase.java

Modified: xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/gradient/Function.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/gradient/Function.java?rev=1611652&r1=1611651&r2=1611652&view=diff
==============================================================================
--- xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/gradient/Function.java (original)
+++ xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/gradient/Function.java Fri Jul 18 13:48:43 2014
@@ -17,6 +17,7 @@
 
 package org.apache.fop.render.gradient;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
@@ -214,7 +215,20 @@ public class Function {
         this(3, domain, range);
         this.functions = functions;
         this.bounds = bounds;
-        this.encode = encode;
+        this.encode = makeEncode(encode);
+    }
+
+    private List<Double> makeEncode(List<Double> encode) {
+        if (encode != null) {
+            return encode;
+        } else {
+            encode = new ArrayList<Double>(functions.size() * 2);
+            for (int i = 0; i < functions.size(); i++) {
+                encode.add(0.0);
+                encode.add(1.0);
+            }
+            return encode;
+        }
     }
 
     private Function(int functionType, List<Double> domain, List<Double> range) {
@@ -432,18 +446,9 @@ public class Function {
     }
 
     private void outputEncode(StringBuilder out, DoubleFormatter doubleFormatter) {
-        if (encode != null) {
-            out.append("/Encode ");
-            GradientMaker.outputDoubles(out, doubleFormatter, encode);
-            out.append("\n");
-        } else {
-            out.append("/Encode [ ");
-            int size = functions.size();
-            for (int i = 0; i < size; i++) {
-                out.append("0 1 ");
-            }
-            out.append("]\n");
-        }
+        out.append("/Encode ");
+        GradientMaker.outputDoubles(out, doubleFormatter, encode);
+        out.append("\n");
     }
 
     private void outputDecode(StringBuilder out, DoubleFormatter doubleFormatter) {

Modified: xmlgraphics/fop/branches/FOP-2393_gradient-rendering/test/java/org/apache/fop/render/gradient/GradientTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/FOP-2393_gradient-rendering/test/java/org/apache/fop/render/gradient/GradientTestCase.java?rev=1611652&r1=1611651&r2=1611652&view=diff
==============================================================================
--- xmlgraphics/fop/branches/FOP-2393_gradient-rendering/test/java/org/apache/fop/render/gradient/GradientTestCase.java (original)
+++ xmlgraphics/fop/branches/FOP-2393_gradient-rendering/test/java/org/apache/fop/render/gradient/GradientTestCase.java Fri Jul 18 13:48:43 2014
@@ -100,6 +100,16 @@ public class GradientTestCase {
             return this;
         }
 
+        FunctionChecker bounds(Double... expectedBounds) {
+            assertArrayEquals(expectedBounds, function.getBounds().toArray());
+            return this;
+        }
+
+        FunctionChecker encode(Double... expectedEncode) {
+            assertArrayEquals(expectedEncode, function.getEncode().toArray());
+            return this;
+        }
+
         FunctionChecker cZero(float... expectedCZero) {
             assertArrayEquals(expectedCZero, function.getCZero(), 0f);
             return this;
@@ -137,6 +147,8 @@ public class GradientTestCase {
         FunctionChecker functionChecker = shadingChecker.function()
                 .functionType(3)
                 .domain(0.0, 1.0)
+                .bounds()
+                .encode(0.0, 1.0)
                 .functions(1);
         functionChecker.function(0)
                 .functionType(2)



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org