diff options
author | Vincent Hennebert <vhennebert@apache.org> | 2014-07-18 13:48:43 +0000 |
---|---|---|
committer | Vincent Hennebert <vhennebert@apache.org> | 2014-07-18 13:48:43 +0000 |
commit | a1e5851e19b3b2f0b3224a4e9dd084515b280f72 (patch) | |
tree | 98eca0e2bcaf6b674c5543aefe77ad0e415a9451 /src/java/org/apache | |
parent | dc62d1034852b4e9102d4a9a200e85717323e5f4 (diff) | |
download | xmlgraphics-fop-a1e5851e19b3b2f0b3224a4e9dd084515b280f72.tar.gz xmlgraphics-fop-a1e5851e19b3b2f0b3224a4e9dd084515b280f72.zip |
Check bounds and encode
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP-2393_gradient-rendering@1611652 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache')
-rw-r--r-- | src/java/org/apache/fop/render/gradient/Function.java | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/java/org/apache/fop/render/gradient/Function.java b/src/java/org/apache/fop/render/gradient/Function.java index 2baa87820..e0dc210d0 100644 --- a/src/java/org/apache/fop/render/gradient/Function.java +++ b/src/java/org/apache/fop/render/gradient/Function.java @@ -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) { |