aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/svg
diff options
context:
space:
mode:
authorVincent Hennebert <vhennebert@apache.org>2014-07-10 17:37:30 +0000
committerVincent Hennebert <vhennebert@apache.org>2014-07-10 17:37:30 +0000
commitcf24cc5673fd2a5ad71347a091abff749e6d124f (patch)
tree865736f20eb8ca67158c945238cefb49afde0257 /src/java/org/apache/fop/svg
parentea7fa816d2fa119cdb8eabe87ff70ee3abf862a6 (diff)
downloadxmlgraphics-fop-cf24cc5673fd2a5ad71347a091abff749e6d124f.tar.gz
xmlgraphics-fop-cf24cc5673fd2a5ad71347a091abff749e6d124f.zip
Factorized creation of gradient bounds
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP-2393_gradient-rendering@1609518 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/svg')
-rw-r--r--src/java/org/apache/fop/svg/PDFGraphics2D.java34
1 files changed, 16 insertions, 18 deletions
diff --git a/src/java/org/apache/fop/svg/PDFGraphics2D.java b/src/java/org/apache/fop/svg/PDFGraphics2D.java
index 06dd1f575..0403fa465 100644
--- a/src/java/org/apache/fop/svg/PDFGraphics2D.java
+++ b/src/java/org/apache/fop/svg/PDFGraphics2D.java
@@ -880,19 +880,12 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand
List<Color> colors = createGradientColors(gp);
- float[] fractions = gp.getFractions();
- List<Double> theBounds = new java.util.ArrayList<Double>();
- for (int count = 0; count < fractions.length; count++) {
- float offset = fractions[count];
- if (0f < offset && offset < 1f) {
- theBounds.add(new Double(offset));
- }
- }
+ List<Double> bounds = createGradientBounds(gp);
//Gradients are currently restricted to sRGB
PDFDeviceColorSpace colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB);
PDFGradientFactory gradientFactory = new PDFGradientFactory(this);
- PDFPattern myPat = gradientFactory.createGradient(false, colSpace, colors, theBounds,
+ PDFPattern myPat = gradientFactory.createGradient(false, colSpace, colors, bounds,
theCoords, matrix);
currentStream.write(myPat.getColorSpaceOut(fill));
@@ -941,19 +934,12 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand
List<Color> colors = createGradientColors(gp);
- float[] fractions = gp.getFractions();
- List<Double> theBounds = new java.util.ArrayList<Double>();
- for (int count = 0; count < fractions.length; count++) {
- float offset = fractions[count];
- if (0f < offset && offset < 1f) {
- theBounds.add(new Double(offset));
- }
- }
+ List<Double> bounds = createGradientBounds(gp);
//Gradients are currently restricted to sRGB
PDFDeviceColorSpace colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB);
PDFGradientFactory gradientFactory = new PDFGradientFactory(this);
- PDFPattern myPat = gradientFactory.createGradient(true, colSpace, colors, theBounds,
+ PDFPattern myPat = gradientFactory.createGradient(true, colSpace, colors, bounds,
theCoords, matrix);
currentStream.write(myPat.getColorSpaceOut(fill));
@@ -991,6 +977,18 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand
return gradientColors;
}
+ private List<Double> createGradientBounds(MultipleGradientPaint gradient) {
+ // TODO is the conversion to double necessary?
+ float[] fractions = gradient.getFractions();
+ List<Double> bounds = new java.util.ArrayList<Double>(fractions.length);
+ for (float offset : fractions) {
+ if (0f < offset && offset < 1f) {
+ bounds.add(Double.valueOf(offset));
+ }
+ }
+ return bounds;
+ }
+
private boolean createPattern(PatternPaint pp, boolean fill) {
preparePainting();