diff options
Diffstat (limited to 'src/java')
6 files changed, 23 insertions, 130 deletions
diff --git a/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java b/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java index 7e0dcb496..8e7315801 100644 --- a/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java +++ b/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java @@ -33,14 +33,11 @@ import org.apache.batik.ext.awt.RadialGradientPaint; import org.apache.xmlgraphics.java2d.ps.PSGraphics2D; import org.apache.xmlgraphics.ps.PSGenerator; -import org.apache.fop.render.shading.Function; -import org.apache.fop.render.shading.GradientRegistrar; import org.apache.fop.render.shading.PSGradientFactory; import org.apache.fop.render.shading.Pattern; -import org.apache.fop.render.shading.Shading; -public class PSSVGGraphics2D extends PSGraphics2D implements GradientRegistrar { +public class PSSVGGraphics2D extends PSGraphics2D { private static final Log LOG = LogFactory.getLog(PSSVGGraphics2D.class); @@ -109,36 +106,4 @@ public class PSSVGGraphics2D extends PSGraphics2D implements GradientRegistrar { return new PSSVGGraphics2D(this); } - /** - * Registers a function object against the output format document - * @param function The function object to register - * @return Returns either the function which has already been registered - * or the current new registered object. - */ - public Function registerFunction(Function function) { - //Objects aren't needed to be registered in Postscript - return function; - } - - /** - * Registers a shading object against the otuput format document - * @param shading The shading object to register - * @return Returs either the shading which has already been registered - * or the current new registered object - */ - public Shading registerShading(Shading shading) { - //Objects aren't needed to be registered in Postscript - return shading; - } - - /** - * Registers a pattern object against the output format document - * @param pattern The pattern object to register - * @return Returns either the pattern which has already been registered - * or the current new registered object - */ - public Pattern registerPattern(Pattern pattern) { - // TODO Auto-generated method stub - return pattern; - } } diff --git a/src/java/org/apache/fop/render/shading/GradientFactory.java b/src/java/org/apache/fop/render/shading/GradientFactory.java index 9a68cdf7d..3ec03d60f 100644 --- a/src/java/org/apache/fop/render/shading/GradientFactory.java +++ b/src/java/org/apache/fop/render/shading/GradientFactory.java @@ -79,7 +79,7 @@ public abstract class GradientFactory<P extends Pattern> { List<Double> bounds = createBounds(gradient); //Gradients are currently restricted to sRGB PDFDeviceColorSpace colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB); - return createGradient(gradient instanceof RadialGradientPaint, colSpace, colors, bounds, coords, matrix); + return makeGradient(gradient instanceof RadialGradientPaint, colSpace, colors, bounds, coords, matrix); } private List<Double> createTransform(MultipleGradientPaint gradient, @@ -134,11 +134,7 @@ public abstract class GradientFactory<P extends Pattern> { * @param theMatrix The matrix for any transformations * @return Returns the Pattern object of the gradient */ - public abstract P createGradient(boolean radial, - PDFDeviceColorSpace theColorspace, List<Color> theColors, List<Double> theBounds, - List<Double> theCoords, List<Double> theMatrix); - - protected Pattern makeGradient(boolean radial, PDFDeviceColorSpace theColorspace, + protected P makeGradient(boolean radial, PDFDeviceColorSpace theColorspace, List<Color> theColors, List<Double> theBounds, List<Double> theCoords, List<Double> theMatrix) { Shading myShad; @@ -226,7 +222,7 @@ public abstract class GradientFactory<P extends Pattern> { boolean theAntiAlias, List<Double> theCoords, List<Double> theDomain, Function theFunction, List<Integer> theExtend); - public abstract Pattern makePattern(int thePatternType, Shading theShading, List theXUID, + public abstract P makePattern(int thePatternType, Shading theShading, List theXUID, StringBuffer theExtGState, List<Double> theMatrix); private List<Double> toColorVector(Color nextColor) { diff --git a/src/java/org/apache/fop/render/shading/GradientRegistrar.java b/src/java/org/apache/fop/render/shading/GradientRegistrar.java deleted file mode 100644 index 617fcd4fb..000000000 --- a/src/java/org/apache/fop/render/shading/GradientRegistrar.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.fop.render.shading; - -public interface GradientRegistrar { - - /** - * Registers a function object against the output format document - * @param function The function object to register - * @return Returns either the function which has already been registered - * or the current new registered object. - */ - Function registerFunction(Function function); - - /** - * Registers a shading object against the output format document - * @param shading The shading object to register - * @return Returns either the shading which has already been registered - * or the current new registered object - */ - Shading registerShading(Shading shading); - - /** - * Registers a pattern object against the output format document - * @param pattern The pattern object to register - * @return Returns either the pattern which has already been registered - * or the current new registered object - */ - Pattern registerPattern(Pattern pattern); -} diff --git a/src/java/org/apache/fop/render/shading/PDFGradientFactory.java b/src/java/org/apache/fop/render/shading/PDFGradientFactory.java index 7254b1669..e12fa82e5 100644 --- a/src/java/org/apache/fop/render/shading/PDFGradientFactory.java +++ b/src/java/org/apache/fop/render/shading/PDFGradientFactory.java @@ -17,7 +17,6 @@ package org.apache.fop.render.shading; -import java.awt.Color; import java.util.List; import org.apache.fop.pdf.PDFDeviceColorSpace; @@ -28,35 +27,28 @@ import org.apache.fop.svg.PDFGraphics2D; public class PDFGradientFactory extends GradientFactory<PDFPattern> { - private final GradientRegistrar registrar; + private final PDFGraphics2D graphics2D; public PDFGradientFactory(PDFGraphics2D pdfGraphics2D) { - this.registrar = pdfGraphics2D; - } - - @Override - public PDFPattern createGradient(boolean radial, PDFDeviceColorSpace theColorspace, List<Color> theColors, - List<Double> theBounds, List<Double> theCoords, List<Double> theMatrix) { - return (PDFPattern)makeGradient(radial, theColorspace, theColors, theBounds, - theCoords, theMatrix); + this.graphics2D = pdfGraphics2D; } @Override public Function makeFunction(int functionType, List<Double> theDomain, List<Double> theRange, List<Function> theFunctions, List<Double> theBounds, List<Double> theEncode) { - Function newFunction = new PDFFunction(functionType, theDomain, theRange, theFunctions, + PDFFunction newFunction = new PDFFunction(functionType, theDomain, theRange, theFunctions, theBounds, theEncode); - newFunction = registrar.registerFunction(newFunction); + newFunction = graphics2D.registerFunction(newFunction); return newFunction; } public Function makeFunction(int functionType, List<Double> theDomain, List<Double> theRange, List<Double> theCZero, List<Double> theCOne, double theInterpolationExponentN) { - Function newFunction = new PDFFunction(functionType, theDomain, theRange, theCZero, + PDFFunction newFunction = new PDFFunction(functionType, theDomain, theRange, theCZero, theCOne, theInterpolationExponentN); - newFunction = registrar.registerFunction(newFunction); + newFunction = graphics2D.registerFunction(newFunction); return newFunction; } @@ -65,18 +57,18 @@ public class PDFGradientFactory extends GradientFactory<PDFPattern> { PDFDeviceColorSpace theColorSpace, List<Double> theBackground, List<Double> theBBox, boolean theAntiAlias, List<Double> theCoords, List<Double> theDomain, Function theFunction, List<Integer> theExtend) { - Shading newShading = new PDFShading(theShadingType, theColorSpace, theBackground, + PDFShading newShading = new PDFShading(theShadingType, theColorSpace, theBackground, theBBox, theAntiAlias, theCoords, theDomain, theFunction, theExtend); - newShading = registrar.registerShading(newShading); + newShading = graphics2D.registerShading(newShading); return newShading; } @Override - public Pattern makePattern(int thePatternType, Shading theShading, List theXUID, + public PDFPattern makePattern(int thePatternType, Shading theShading, List theXUID, StringBuffer theExtGState, List<Double> theMatrix) { - Pattern newPattern = new PDFPattern(thePatternType, theShading, theXUID, theExtGState, + PDFPattern newPattern = new PDFPattern(thePatternType, theShading, theXUID, theExtGState, theMatrix); - newPattern = registrar.registerPattern(newPattern); + newPattern = graphics2D.registerPattern(newPattern); return newPattern; } diff --git a/src/java/org/apache/fop/render/shading/PSGradientFactory.java b/src/java/org/apache/fop/render/shading/PSGradientFactory.java index 156ace52a..afd23ad75 100644 --- a/src/java/org/apache/fop/render/shading/PSGradientFactory.java +++ b/src/java/org/apache/fop/render/shading/PSGradientFactory.java @@ -17,7 +17,6 @@ package org.apache.fop.render.shading; -import java.awt.Color; import java.util.List; import org.apache.fop.pdf.PDFDeviceColorSpace; @@ -27,14 +26,6 @@ import org.apache.fop.render.ps.svg.PSShading; public class PSGradientFactory extends GradientFactory<PSPattern> { - @Override - public PSPattern createGradient(boolean radial, PDFDeviceColorSpace theColorspace, - List<Color> theColors, List<Double> theBounds, List<Double> theCoords, - List<Double> theMatrix) { - return (PSPattern)makeGradient(radial, theColorspace, theColors, theBounds, - theCoords, theMatrix); - } - public Function makeFunction(int functionType, List<Double> theDomain, List<Double> theRange, List<Function> theFunctions, List<Double> theBounds, List<Double> theEncode) { @@ -63,7 +54,7 @@ public class PSGradientFactory extends GradientFactory<PSPattern> { } @Override - public Pattern makePattern(int thePatternType, Shading theShading, List theXUID, + public PSPattern makePattern(int thePatternType, Shading theShading, List theXUID, StringBuffer theExtGState, List<Double> theMatrix) { return new PSPattern(thePatternType, theShading, theXUID, theExtGState, theMatrix); } diff --git a/src/java/org/apache/fop/svg/PDFGraphics2D.java b/src/java/org/apache/fop/svg/PDFGraphics2D.java index 01d416767..8a5615cc6 100644 --- a/src/java/org/apache/fop/svg/PDFGraphics2D.java +++ b/src/java/org/apache/fop/svg/PDFGraphics2D.java @@ -95,11 +95,7 @@ import org.apache.fop.pdf.PDFXObject; import org.apache.fop.render.pdf.ImageRawCCITTFaxAdapter; import org.apache.fop.render.pdf.ImageRawJPEGAdapter; import org.apache.fop.render.pdf.ImageRenderedAdapter; -import org.apache.fop.render.shading.Function; -import org.apache.fop.render.shading.GradientRegistrar; import org.apache.fop.render.shading.PDFGradientFactory; -import org.apache.fop.render.shading.Pattern; -import org.apache.fop.render.shading.Shading; /** * <p>PDF Graphics 2D. @@ -110,7 +106,7 @@ import org.apache.fop.render.shading.Shading; * * @see org.apache.batik.ext.awt.g2d.AbstractGraphics2D */ -public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHandler, GradientRegistrar { +public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHandler { private static final AffineTransform IDENTITY_TRANSFORM = new AffineTransform(); /** The number of decimal places. */ @@ -1764,8 +1760,8 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand * @return Returns either the function which has already been registered * or the current new registered object. */ - public Function registerFunction(Function function) { - return pdfDoc.getFactory().registerFunction((PDFFunction)function); + public PDFFunction registerFunction(PDFFunction function) { + return pdfDoc.getFactory().registerFunction(function); } /** @@ -1774,9 +1770,8 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand * @return Returs either the shading which has already been registered * or the current new registered object */ - public Shading registerShading(Shading shading) { - assert shading instanceof PDFShading; - return pdfDoc.getFactory().registerShading(resourceContext, (PDFShading)shading); + public PDFShading registerShading(PDFShading shading) { + return pdfDoc.getFactory().registerShading(resourceContext, shading); } /** @@ -1785,9 +1780,8 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand * @return Returns either the pattern which has already been registered * or the current new registered object */ - public Pattern registerPattern(Pattern pattern) { - assert pattern instanceof PDFPattern; - return pdfDoc.getFactory().registerPattern(resourceContext, (PDFPattern)pattern); + public PDFPattern registerPattern(PDFPattern pattern) { + return pdfDoc.getFactory().registerPattern(resourceContext, pattern); } } |