From 06adde0ea4c267e1f15a65dbd6794938bb17f54c Mon Sep 17 00:00:00 2001 From: Vincent Hennebert Date: Fri, 11 Jul 2014 17:41:49 +0000 Subject: [PATCH] Simplified makeShading and makePattern methods git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP-2393_gradient-rendering@1609754 13f79535-47bb-0310-9956-ffa450edef68 --- .../fop/render/shading/GradientFactory.java | 19 +++++++---------- .../render/shading/PDFGradientFactory.java | 21 +++++++------------ .../fop/render/shading/PSGradientFactory.java | 15 +++++-------- 3 files changed, 21 insertions(+), 34 deletions(-) diff --git a/src/java/org/apache/fop/render/shading/GradientFactory.java b/src/java/org/apache/fop/render/shading/GradientFactory.java index 666bc0a77..94fe21ae9 100644 --- a/src/java/org/apache/fop/render/shading/GradientFactory.java +++ b/src/java/org/apache/fop/render/shading/GradientFactory.java @@ -77,12 +77,12 @@ public abstract class GradientFactory

{ List matrix = createTransform(gradient, baseTransform, transform); List bounds = createBounds(gradient); List functions = createFunctions(gradient); - //Gradients are currently restricted to sRGB - PDFDeviceColorSpace colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB); + // Gradients are currently restricted to sRGB + PDFDeviceColorSpace colorSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB); Function function = new Function(3, null, null, functions, bounds, null); - Shading shading = makeShading(gradient instanceof LinearGradientPaint ? 2 : 3, - colSpace, null, null, false, coords, null, function, null); - return makePattern(2, shading, null, null, matrix); + Shading shading = makeShading(gradient instanceof LinearGradientPaint ? 2 : 3, colorSpace, + coords, function); + return makePattern(2, shading, matrix); } private List createTransform(MultipleGradientPaint gradient, @@ -149,11 +149,8 @@ public abstract class GradientFactory

{ return gradientColors; } - public abstract Shading makeShading(int shadingType, - PDFDeviceColorSpace colorSpace, List background, List bbox, - boolean antiAlias, List coords, List domain, - Function function, List extend); + protected abstract Shading makeShading(int shadingType, PDFDeviceColorSpace colorSpace, + List coords, Function function); - public abstract P makePattern(int patternType, Shading shading, List xuid, - StringBuffer extGState, List matrix); + protected abstract P makePattern(int patternType, Shading shading, List matrix); } diff --git a/src/java/org/apache/fop/render/shading/PDFGradientFactory.java b/src/java/org/apache/fop/render/shading/PDFGradientFactory.java index 4cab73a80..576ae3649 100644 --- a/src/java/org/apache/fop/render/shading/PDFGradientFactory.java +++ b/src/java/org/apache/fop/render/shading/PDFGradientFactory.java @@ -35,27 +35,22 @@ public class PDFGradientFactory extends GradientFactory { } @Override - public Shading makeShading(int shadingType, - PDFDeviceColorSpace colorSpace, List background, List bbox, - boolean antiAlias, List coords, List domain, - Function function, List extend) { + protected Shading makeShading(int shadingType, PDFDeviceColorSpace colorSpace, + List coords, Function function) { List pdfFunctions = new ArrayList(function.getFunctions().size()); for (Function f : function.getFunctions()) { pdfFunctions.add(graphics2D.registerFunction(new PDFFunction(f))); } PDFFunction pdfFunction = graphics2D.registerFunction(new PDFFunction(function, pdfFunctions)); - PDFShading newShading = new PDFShading(shadingType, colorSpace, background, - bbox, antiAlias, coords, domain, pdfFunction, extend); - newShading = graphics2D.registerShading(newShading); - return newShading; + PDFShading shading = new PDFShading(shadingType, colorSpace, null, null, false, + coords, null, pdfFunction, null); + return graphics2D.registerShading(shading); } @Override - public PDFPattern makePattern(int patternType, Shading shading, List xuid, - StringBuffer extGState, List matrix) { - PDFPattern newPattern = new PDFPattern(patternType, shading, xuid, extGState, matrix); - newPattern = graphics2D.registerPattern(newPattern); - return newPattern; + protected PDFPattern makePattern(int patternType, Shading shading, List matrix) { + PDFPattern pattern = new PDFPattern(patternType, shading, null, null, matrix); + return graphics2D.registerPattern(pattern); } } diff --git a/src/java/org/apache/fop/render/shading/PSGradientFactory.java b/src/java/org/apache/fop/render/shading/PSGradientFactory.java index 7bd7ba245..0efdc3192 100644 --- a/src/java/org/apache/fop/render/shading/PSGradientFactory.java +++ b/src/java/org/apache/fop/render/shading/PSGradientFactory.java @@ -26,18 +26,13 @@ import org.apache.fop.render.ps.svg.PSShading; public class PSGradientFactory extends GradientFactory { @Override - public Shading makeShading(int shadingType, - PDFDeviceColorSpace colorSpace, List background, List bbox, - boolean antiAlias, List coords, List domain, - Function function, List extend) { - Shading newShading = new PSShading(shadingType, colorSpace, background, bbox, - antiAlias, coords, domain, function, extend); - return newShading; + protected Shading makeShading(int shadingType, + PDFDeviceColorSpace colorSpace, List coords, Function function) { + return new PSShading(shadingType, colorSpace, null, null, false, coords, null, function, null); } @Override - public PSPattern makePattern(int patternType, Shading shading, List xuid, - StringBuffer extGState, List matrix) { - return new PSPattern(patternType, shading, xuid, extGState, matrix); + protected PSPattern makePattern(int patternType, Shading shading, List matrix) { + return new PSPattern(patternType, shading, null, null, matrix); } } -- 2.39.5