diff options
author | Vincent Hennebert <vhennebert@apache.org> | 2014-07-18 13:49:05 +0000 |
---|---|---|
committer | Vincent Hennebert <vhennebert@apache.org> | 2014-07-18 13:49:05 +0000 |
commit | f8dd309bf637ecd62762fdfd889be1e7b210b755 (patch) | |
tree | ff643bc8e7dd521f21c5b7b6eb4b533ab9f9c29b /src/java/org/apache | |
parent | a1e5851e19b3b2f0b3224a4e9dd084515b280f72 (diff) | |
download | xmlgraphics-fop-f8dd309bf637ecd62762fdfd889be1e7b210b755.tar.gz xmlgraphics-fop-f8dd309bf637ecd62762fdfd889be1e7b210b755.zip |
Added more complete tests
Keep floats for bounds instead of converting them to doubles
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP-2393_gradient-rendering@1611653 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache')
-rw-r--r-- | src/java/org/apache/fop/render/gradient/Function.java | 6 | ||||
-rw-r--r-- | src/java/org/apache/fop/render/gradient/GradientMaker.java | 16 |
2 files changed, 11 insertions, 11 deletions
diff --git a/src/java/org/apache/fop/render/gradient/Function.java b/src/java/org/apache/fop/render/gradient/Function.java index e0dc210d0..38aec8064 100644 --- a/src/java/org/apache/fop/render/gradient/Function.java +++ b/src/java/org/apache/fop/render/gradient/Function.java @@ -143,7 +143,7 @@ public class Function { * This makes each function responsible for an equal amount of the stitching function. * It makes the gradient even. */ - private List<Double> bounds; + private List<Float> bounds; /** * create an complete Function object of Type 2, an Exponential Interpolation function. @@ -211,7 +211,7 @@ public class Function { * See page 270 in the PDF 1.3 spec. */ public Function(List<Double> domain, List<Double> range, List<Function> functions, - List<Double> bounds, List<Double> encode) { + List<Float> bounds, List<Double> encode) { this(3, domain, range); this.functions = functions; this.bounds = bounds; @@ -247,7 +247,7 @@ public class Function { /** * Gets the function bounds */ - public List<Double> getBounds() { + public List<Float> getBounds() { return bounds; } diff --git a/src/java/org/apache/fop/render/gradient/GradientMaker.java b/src/java/org/apache/fop/render/gradient/GradientMaker.java index d8307c300..4c8734d9f 100644 --- a/src/java/org/apache/fop/render/gradient/GradientMaker.java +++ b/src/java/org/apache/fop/render/gradient/GradientMaker.java @@ -82,7 +82,7 @@ public final class GradientMaker { private static Pattern makeGradient(MultipleGradientPaint gradient, List<Double> coords, AffineTransform baseTransform, AffineTransform transform) { List<Double> matrix = makeTransform(gradient, baseTransform, transform); - List<Double> bounds = makeBounds(gradient); + List<Float> bounds = makeBounds(gradient); List<Function> functions = makeFunctions(gradient); // Gradients are currently restricted to sRGB PDFDeviceColorSpace colorSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB); @@ -112,13 +112,12 @@ public final class GradientMaker { return c.getColorSpace().isCS_sRGB() ? c : ColorUtil.toSRGBColor(c); } - private static List<Double> makeBounds(MultipleGradientPaint gradient) { - // TODO is the conversion to double necessary? + private static List<Float> makeBounds(MultipleGradientPaint gradient) { float[] fractions = gradient.getFractions(); - List<Double> bounds = new java.util.ArrayList<Double>(fractions.length); + List<Float> bounds = new java.util.ArrayList<Float>(fractions.length); for (float offset : fractions) { if (0f < offset && offset < 1f) { - bounds.add(Double.valueOf(offset)); + bounds.add(offset); } } return bounds; @@ -156,10 +155,11 @@ public final class GradientMaker { return gradientColors; } - static void outputDoubles(StringBuilder out, DoubleFormatter doubleFormatter, List<Double> doubles) { + static void outputDoubles(StringBuilder out, DoubleFormatter doubleFormatter, + List<? extends Number> numbers) { out.append("[ "); - for (Double d : doubles) { - out.append(doubleFormatter.formatDouble(d)); + for (Number n : numbers) { + out.append(doubleFormatter.formatDouble(n.doubleValue())); out.append(" "); } out.append("]"); |