git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1797012 13f79535-47bb-0310-9956-ffa450edef68tags/fop-2_3
private static List<Float> makeBounds(MultipleGradientPaint gradient) { | private static List<Float> makeBounds(MultipleGradientPaint gradient) { | ||||
float[] fractions = gradient.getFractions(); | 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) { | for (float offset : fractions) { | ||||
if (0f < offset && offset < 1f) { | |||||
if (0f < offset) { | |||||
bounds.add(offset); | bounds.add(offset); | ||||
} | } | ||||
} | } | ||||
float last = bounds.get(bounds.size() - 1); | |||||
if (last == 1f) { | |||||
bounds.remove(bounds.size() - 1); | |||||
} | |||||
return bounds; | return bounds; | ||||
} | } | ||||
return colors; | 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); | |||||
} | |||||
} | } |