diff options
author | Vincent Hennebert <vhennebert@apache.org> | 2014-07-18 13:44:56 +0000 |
---|---|---|
committer | Vincent Hennebert <vhennebert@apache.org> | 2014-07-18 13:44:56 +0000 |
commit | 0a505d2b84aff8ae2be8b7aaa28ef7054794edf3 (patch) | |
tree | e35694f75acc8415015e072f3e939b68abaf19f1 /src/java/org/apache | |
parent | b49267763c60c4d9f68a0c7cf762262d159c6c2b (diff) | |
download | xmlgraphics-fop-0a505d2b84aff8ae2be8b7aaa28ef7054794edf3.tar.gz xmlgraphics-fop-0a505d2b84aff8ae2be8b7aaa28ef7054794edf3.zip |
Added test case for the gradient package
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP-2393_gradient-rendering@1611649 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache')
-rw-r--r-- | src/java/org/apache/fop/render/gradient/Function.java | 28 | ||||
-rw-r--r-- | src/java/org/apache/fop/render/gradient/Shading.java | 39 |
2 files changed, 25 insertions, 42 deletions
diff --git a/src/java/org/apache/fop/render/gradient/Function.java b/src/java/org/apache/fop/render/gradient/Function.java index f5e1e6ef8..2ac095819 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.Arrays; import java.util.Collections; import java.util.List; @@ -171,15 +172,10 @@ public class Function { */ public Function(int functionType, List<Double> domain, List<Double> range, float[] cZero, float[] cOne, double interpolationExponentN) { - this.functionType = 2; // dang well better be 2; - + this(2, domain, range); this.cZero = cZero; this.cOne = cOne; this.interpolationExponentN = interpolationExponentN; - - this.domain = domain; - this.range = range; - } /** @@ -219,14 +215,16 @@ public class Function { public Function(int functionType, List<Double> domain, List<Double> range, List<Function> functions, List<Double> bounds, List<Double> encode) { - this.functionType = 3; // dang well better be 3; - + this(3, domain, range); this.functions = functions; this.bounds = bounds; this.encode = encode; - this.domain = domain; - this.range = range; + } + private Function(int functionType, List<Double> domain, List<Double> range) { + this.functionType = functionType; + this.domain = (domain == null) ? Arrays.asList(0.0, 1.0) : domain; + this.range = range; } /** @@ -406,13 +404,9 @@ public class Function { } private void outputDomain(StringBuilder p, DoubleFormatter doubleFormatter) { - if (domain != null) { - p.append("/Domain "); - GradientMaker.outputDoubles(p, doubleFormatter, domain); - p.append("\n"); - } else { - p.append("/Domain [ 0 1 ]\n"); - } + p.append("/Domain "); + GradientMaker.outputDoubles(p, doubleFormatter, domain); + p.append("\n"); } private void outputSize(StringBuilder out, DoubleFormatter doubleFormatter) { diff --git a/src/java/org/apache/fop/render/gradient/Shading.java b/src/java/org/apache/fop/render/gradient/Shading.java index 5b17db270..a9c9b1072 100644 --- a/src/java/org/apache/fop/render/gradient/Shading.java +++ b/src/java/org/apache/fop/render/gradient/Shading.java @@ -17,6 +17,7 @@ package org.apache.fop.render.gradient; +import java.util.Arrays; import java.util.List; import org.apache.fop.pdf.PDFDeviceColorSpace; @@ -141,9 +142,9 @@ public class Shading { this.bbox = null; this.antiAlias = false; this.coords = coords; - this.domain = null; + this.domain = Arrays.asList(0.0, 1.0); this.function = function; - this.extend = null; + this.extend = Arrays.asList(true, true); this.matrix = null; this.decode = null; this.bitsPerCoordinate = 0; @@ -257,13 +258,9 @@ public class Shading { private void outputShadingType1(StringBuilder out, DoubleFormatter doubleFormatter, Shading.FunctionRenderer functionRenderer) { - if (domain != null) { - out.append("/Domain "); - GradientMaker.outputDoubles(out, doubleFormatter, domain); - out.append("\n"); - } else { - out.append("/Domain [ 0 1 ] \n"); - } + out.append("/Domain "); + GradientMaker.outputDoubles(out, doubleFormatter, domain); + out.append("\n"); if (matrix != null) { out.append("/Matrix "); @@ -281,24 +278,16 @@ public class Shading { out.append("\n"); } - if (domain != null) { - out.append("/Domain "); - GradientMaker.outputDoubles(out, doubleFormatter, domain); - out.append("\n"); - } else { - out.append("/Domain [ 0 1 ] \n"); - } + out.append("/Domain "); + GradientMaker.outputDoubles(out, doubleFormatter, domain); + out.append("\n"); - if (extend != null) { - out.append("/Extend ["); - for (Boolean b : extend) { - out.append(b); - out.append(" "); - } - out.append("\n"); - } else { - out.append("/Extend [ true true ] \n"); + out.append("/Extend [ "); + for (Boolean b : extend) { + out.append(b); + out.append(" "); } + out.append("]\n"); outputFunction(out, functionRenderer); } |