summaryrefslogtreecommitdiffstats
path: root/fop-core
diff options
context:
space:
mode:
authorSimon Steiner <ssteiner@apache.org>2017-05-31 11:03:05 +0000
committerSimon Steiner <ssteiner@apache.org>2017-05-31 11:03:05 +0000
commit91f0e81f83b7783b8bb530bb3833606372bce7b4 (patch)
treec947c29ad0ecaf7f7d7cfb51ca91c30b75397e9c /fop-core
parentd907771bb89e90dbd1ef2c06fd83a2f3f699f472 (diff)
downloadxmlgraphics-fop-91f0e81f83b7783b8bb530bb3833606372bce7b4.tar.gz
xmlgraphics-fop-91f0e81f83b7783b8bb530bb3833606372bce7b4.zip
FOP-2710: SVG Gradient missing
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1797012 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'fop-core')
-rw-r--r--fop-core/src/main/java/org/apache/fop/render/gradient/GradientMaker.java8
-rw-r--r--fop-core/src/test/java/org/apache/fop/render/gradient/GradientTestCase.java14
2 files changed, 20 insertions, 2 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/render/gradient/GradientMaker.java b/fop-core/src/main/java/org/apache/fop/render/gradient/GradientMaker.java
index 0e3869868..8e17623ea 100644
--- a/fop-core/src/main/java/org/apache/fop/render/gradient/GradientMaker.java
+++ b/fop-core/src/main/java/org/apache/fop/render/gradient/GradientMaker.java
@@ -114,12 +114,16 @@ public final class GradientMaker {
private static List<Float> makeBounds(MultipleGradientPaint gradient) {
float[] fractions = gradient.getFractions();
- List<Float> bounds = new java.util.ArrayList<Float>(fractions.length);
+ List<Float> bounds = new ArrayList<Float>(fractions.length);
for (float offset : fractions) {
- if (0f < offset && offset < 1f) {
+ if (0f < offset) {
bounds.add(offset);
}
}
+ float last = bounds.get(bounds.size() - 1);
+ if (last == 1f) {
+ bounds.remove(bounds.size() - 1);
+ }
return bounds;
}
diff --git a/fop-core/src/test/java/org/apache/fop/render/gradient/GradientTestCase.java b/fop-core/src/test/java/org/apache/fop/render/gradient/GradientTestCase.java
index 51a9c6c37..165f1cc9d 100644
--- a/fop-core/src/test/java/org/apache/fop/render/gradient/GradientTestCase.java
+++ b/fop-core/src/test/java/org/apache/fop/render/gradient/GradientTestCase.java
@@ -288,4 +288,18 @@ public class GradientTestCase {
return colors;
}
+ @Test
+ public void testMakeBounds() {
+ RadialGradientPaint gradient = new RadialGradientPaint(0, 0, 100, 100, 100,
+ fractions(0f, 1f, 0.9f), colors(Color.WHITE, Color.RED, Color.GREEN));
+ Pattern pattern = GradientMaker.makeRadialGradient(gradient, new AffineTransform(), new AffineTransform());
+ ShadingChecker shadingChecker = new PatternChecker(pattern).shading()
+ .coords(70.7036, 70.7036, 0.0, 0.0, 0.0, 100.0);
+ shadingChecker.function()
+ .functionType(3)
+ .bounds(1f, 0.9f)
+ .encode(0.0, 1.0, 0.0, 1.0, 0.0, 1.0)
+ .functions(3);
+ }
+
}