in src/java/org/apache/fop/render/pdf/pdfbox/PSPDFGraphics2D.java [120:178]
protected void applyPaint(Paint paint, boolean fill) {
preparePainting();
if (paint instanceof AxialShadingPaint || paint instanceof RadialShadingPaint) {
PaintContext paintContext = paint.createContext(null, new Rectangle(), null, new AffineTransform(),
getRenderingHints());
int deviceColorSpace = PDFDeviceColorSpace.DEVICE_RGB;
if (paintContext instanceof ShadingContext) {
PDColorSpace pdcs = getShadingColorSpace((ShadingContext) paintContext);
if (pdcs instanceof PDDeviceCMYK) {
deviceColorSpace = PDFDeviceColorSpace.DEVICE_CMYK;
} else if (pdcs instanceof PDDeviceGray) {
deviceColorSpace = PDFDeviceColorSpace.DEVICE_GRAY;
}
}
if (paint instanceof AxialShadingPaint) {
try {
AxialShadingContext asc = (AxialShadingContext) paintContext;
float[] fCoords = asc.getCoords();
transformCoords(fCoords, (ShadingPaint) paint, true);
PDFunction function = asc.getFunction();
Function targetFT = getFunction(function);
if (targetFT != null) {
if (targetFT.getFunctions().size() == 5
&& targetFT.getFunctions().get(0).getFunctionType() == 0) {
return;
}
List<Double> dCoords = floatArrayToDoubleList(fCoords);
PDFDeviceColorSpace colSpace = new PDFDeviceColorSpace(deviceColorSpace);
Shading shading = new Shading(2, colSpace, dCoords, targetFT);
Pattern pattern = new Pattern(2, shading, null);
gen.write(Gradient.outputPattern(pattern, doubleFormatter));
}
} catch (IOException ioe) {
handleIOException(ioe);
}
} else if (paint instanceof RadialShadingPaint) {
try {
RadialShadingContext rsc = (RadialShadingContext) paintContext;
float[] fCoords = rsc.getCoords();
transformCoords(fCoords, (ShadingPaint) paint, false);
PDFunction function = rsc.getFunction();
Function targetFT3 = getFunction(function);
List<Double> dCoords = floatArrayToDoubleList(fCoords);
PDFDeviceColorSpace colSpace = new PDFDeviceColorSpace(deviceColorSpace);
Shading shading = new Shading(3, colSpace, dCoords, targetFT3);
Pattern pattern = new Pattern(2, shading, null);
gen.write(Gradient.outputPattern(pattern, doubleFormatter));
} catch (IOException ioe) {
handleIOException(ioe);
}
}
} else if (paint.getClass().getSimpleName().equals("TilingPaint")) {
TexturePaint texturePaint = (TexturePaint) getField(paint, "paint");
Matrix matrix = (Matrix) getField(paint, "patternMatrix");
Rectangle2D rect = getTransformedRect(matrix, texturePaint.getAnchorRect());
texturePaint = new TexturePaint(texturePaint.getImage(), rect);
super.applyPaint(texturePaint, fill);
}
}