List of usage examples for java.awt Paint createContext
public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds,
AffineTransform xform, RenderingHints hints);
From source file:org.apache.fop.render.pdf.pdfbox.PSPDFGraphics2D.java
protected void applyPaint(Paint paint, boolean fill) { preparePainting();/*from w w w . j av a2 s . c o m*/ if (paint instanceof AxialShadingPaint || paint instanceof RadialShadingPaint) { PaintContext paintContext = paint.createContext(null, new Rectangle(), null, new AffineTransform(), getRenderingHints()); int deviceColorSpace = PDFDeviceColorSpace.DEVICE_RGB; if (paint instanceof AxialShadingPaint) { try { AxialShadingContext asc = (AxialShadingContext) paintContext; float[] fCoords = asc.getCoords(); transformCoords(fCoords, 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, 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); } } } }