git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1797012 13f79535-47bb-0310-9956-ffa450edef68pull/5/head
@@ -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; | |||
} | |||
@@ -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); | |||
} | |||
} |