git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP-2393_gradient-rendering@1609511 13f79535-47bb-0310-9956-ffa450edef68tags/fop-2_0
@@ -40,7 +40,6 @@ import org.apache.xmlgraphics.ps.PSGenerator; | |||
import org.apache.fop.pdf.PDFDeviceColorSpace; | |||
import org.apache.fop.render.shading.Function; | |||
import org.apache.fop.render.shading.GradientFactory; | |||
import org.apache.fop.render.shading.GradientRegistrar; | |||
import org.apache.fop.render.shading.PSGradientFactory; | |||
import org.apache.fop.render.shading.Pattern; | |||
@@ -148,7 +147,7 @@ public class PSSVGGraphics2D extends PSGraphics2D implements GradientRegistrar { | |||
PDFDeviceColorSpace colSpace; | |||
colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB); | |||
PSGradientFactory gradientFactory = (PSGradientFactory)GradientFactory.newInstance(this); | |||
PSGradientFactory gradientFactory = new PSGradientFactory(); | |||
PSPattern myPattern = gradientFactory.createGradient(false, colSpace, | |||
someColors, theBounds, theCoords, theMatrix); | |||
@@ -235,7 +234,7 @@ public class PSSVGGraphics2D extends PSGraphics2D implements GradientRegistrar { | |||
PDFDeviceColorSpace colSpace; | |||
colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB); | |||
PSGradientFactory gradientFactory = (PSGradientFactory)GradientFactory.newInstance(this); | |||
PSGradientFactory gradientFactory = new PSGradientFactory(); | |||
PSPattern myPattern = gradientFactory.createGradient(true, colSpace, | |||
someColors, theBounds, theCoords, theMatrix); | |||
@@ -26,26 +26,9 @@ import java.util.List; | |||
import org.apache.xmlgraphics.java2d.color.ColorUtil; | |||
import org.apache.fop.pdf.PDFDeviceColorSpace; | |||
import org.apache.fop.render.ps.svg.PSSVGGraphics2D; | |||
public abstract class GradientFactory { | |||
static GradientRegistrar registrar; | |||
/** | |||
* Constructor | |||
* @param registrar The object used to register new embedded objects in the | |||
* output format. | |||
*/ | |||
public static GradientFactory newInstance(GradientRegistrar theRegistrar) { | |||
registrar = theRegistrar; | |||
if (registrar instanceof PSSVGGraphics2D) { | |||
return new PSGradientFactory(); | |||
} else { | |||
return new PDFGradientFactory(); | |||
} | |||
} | |||
/** | |||
* Creates a new gradient | |||
* @param radial Determines whether the gradient is radial |
@@ -24,9 +24,16 @@ import org.apache.fop.pdf.PDFDeviceColorSpace; | |||
import org.apache.fop.pdf.PDFFunction; | |||
import org.apache.fop.pdf.PDFPattern; | |||
import org.apache.fop.pdf.PDFShading; | |||
import org.apache.fop.svg.PDFGraphics2D; | |||
public class PDFGradientFactory extends GradientFactory { | |||
private final GradientRegistrar registrar; | |||
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) { |
@@ -97,7 +97,6 @@ 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.GradientFactory; | |||
import org.apache.fop.render.shading.GradientRegistrar; | |||
import org.apache.fop.render.shading.PDFGradientFactory; | |||
import org.apache.fop.render.shading.Pattern; | |||
@@ -897,7 +896,7 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand | |||
//Gradients are currently restricted to sRGB | |||
PDFDeviceColorSpace colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB); | |||
PDFGradientFactory gradientFactory = (PDFGradientFactory)GradientFactory.newInstance(this); | |||
PDFGradientFactory gradientFactory = new PDFGradientFactory(this); | |||
PDFPattern myPat = gradientFactory.createGradient(false, colSpace, someColors, theBounds, | |||
theCoords, theMatrix); | |||
currentStream.write(myPat.getColorSpaceOut(fill)); | |||
@@ -980,7 +979,7 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand | |||
} | |||
} | |||
PDFDeviceColorSpace colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB); | |||
PDFGradientFactory gradientFactory = (PDFGradientFactory) GradientFactory.newInstance(this); | |||
PDFGradientFactory gradientFactory = new PDFGradientFactory(this); | |||
PDFPattern myPat = gradientFactory.createGradient(true, colSpace, someColors, theBounds, | |||
theCoords, theMatrix); | |||
currentStream.write(myPat.getColorSpaceOut(fill)); |