diff options
author | Vincent Hennebert <vhennebert@apache.org> | 2014-07-10 18:21:59 +0000 |
---|---|---|
committer | Vincent Hennebert <vhennebert@apache.org> | 2014-07-10 18:21:59 +0000 |
commit | 2be89ddec6f3381d98cb3a9f9732245573b0ea88 (patch) | |
tree | 179a9539bce09cb29b7967b564e0298456d1072d | |
parent | 09781c3b8f0ff0f20fe10cb3c449c842d92a9581 (diff) | |
download | xmlgraphics-fop-2be89ddec6f3381d98cb3a9f9732245573b0ea88.tar.gz xmlgraphics-fop-2be89ddec6f3381d98cb3a9f9732245573b0ea88.zip |
Moved creation of colors into createFunctions
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP-2393_gradient-rendering@1609547 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | src/java/org/apache/fop/render/shading/GradientFactory.java | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/java/org/apache/fop/render/shading/GradientFactory.java b/src/java/org/apache/fop/render/shading/GradientFactory.java index ba76f3071..81467d88d 100644 --- a/src/java/org/apache/fop/render/shading/GradientFactory.java +++ b/src/java/org/apache/fop/render/shading/GradientFactory.java @@ -75,11 +75,10 @@ public abstract class GradientFactory<P extends Pattern> { private P createGradient(MultipleGradientPaint gradient, List<Double> coords, AffineTransform baseTransform, AffineTransform transform) { List<Double> matrix = createTransform(gradient, baseTransform, transform); - List<Color> colors = createColors(gradient); List<Double> bounds = createBounds(gradient); + List<Function> functions = createFunctions(gradient); //Gradients are currently restricted to sRGB PDFDeviceColorSpace colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB); - List<Function> functions = createFunctions(colors); Function function = makeFunction(3, null, null, functions, bounds, null); Shading shading = makeShading(gradient instanceof LinearGradientPaint ? 2 : 3, colSpace, null, null, false, coords, null, function, null); @@ -100,22 +99,6 @@ public abstract class GradientFactory<P extends Pattern> { return matrix; } - private List<Color> createColors(MultipleGradientPaint gradient) { - Color[] svgColors = gradient.getColors(); - List<Color> gradientColors = new ArrayList<Color>(svgColors.length + 2); - float[] fractions = gradient.getFractions(); - if (fractions[0] > 0f) { - gradientColors.add(getsRGBColor(svgColors[0])); - } - for (Color c : svgColors) { - gradientColors.add(getsRGBColor(c)); - } - if (fractions[fractions.length - 1] < 1f) { - gradientColors.add(getsRGBColor(svgColors[svgColors.length - 1])); - } - return gradientColors; - } - private Color getsRGBColor(Color c) { // Color space must be consistent, so convert to sRGB if necessary // TODO really? @@ -134,7 +117,8 @@ public abstract class GradientFactory<P extends Pattern> { return bounds; } - private List<Function> createFunctions(List<Color> colors) { + private List<Function> createFunctions(MultipleGradientPaint gradient) { + List<Color> colors = createColors(gradient); List<Function> functions = new ArrayList<Function>(); for (int currentPosition = 0, lastPosition = colors.size() - 1; currentPosition < lastPosition; @@ -149,6 +133,22 @@ public abstract class GradientFactory<P extends Pattern> { return functions; } + private List<Color> createColors(MultipleGradientPaint gradient) { + Color[] svgColors = gradient.getColors(); + List<Color> gradientColors = new ArrayList<Color>(svgColors.length + 2); + float[] fractions = gradient.getFractions(); + if (fractions[0] > 0f) { + gradientColors.add(getsRGBColor(svgColors[0])); + } + for (Color c : svgColors) { + gradientColors.add(getsRGBColor(c)); + } + if (fractions[fractions.length - 1] < 1f) { + gradientColors.add(getsRGBColor(svgColors[svgColors.length - 1])); + } + return gradientColors; + } + public abstract Function makeFunction(int functionType, List<Double> theDomain, List<Double> theRange, List<Function> theFunctions, List<Double> theBounds, List<Double> theEncode); |