FontInfo fontInfo = new FontInfo();
FontSetup.setup(fontInfo, null, null);
PDFResources res = pdfDoc.getFactory().makeResources();
PDFResourceContext context = new PDFResourceContext(res);
PDFGraphics2D pattGraphic = new PDFGraphics2D(textAsShapes, fontInfo,
pdfDoc, context, pageRef,
"", 0);
pattGraphic.setGraphicContext(new GraphicContext());
pattGraphic.gc.validateTransformStack();
pattGraphic.setRenderingHints(this.getRenderingHints());
pattGraphic.setOutputStream(outputStream);
GraphicsNode gn = pp.getGraphicsNode();
Rectangle2D gnBBox = gn.getBounds();
Rectangle2D rect = pp.getPatternRect();
// if (!pp.getOverflow()) {
gn.paint(pattGraphic);
// } else {
// /* Commented out until SVN version of Batik is included */
// // For overflow we need to paint the content from
// // all the tiles who's overflow will intersect one
// // tile (left->right, top->bottom). Then we can
// // simply replicate that tile as normal.
// double gnMinX = gnBBox.getX();
// double gnMaxX = gnBBox.getX() + gnBBox.getWidth();
// double gnMinY = gnBBox.getY();
// double gnMaxY = gnBBox.getY() + gnBBox.getHeight();
// double patMaxX = rect.getX() + rect.getWidth();
// double patMaxY = rect.getY() + rect.getHeight();
// double stepX = rect.getWidth();
// double stepY = rect.getHeight();
//
// int startX = (int)((rect.getX() - gnMaxX)/stepX);
// int startY = (int)((rect.getY() - gnMaxY)/stepY);
//
// int endX = (int)((patMaxX - gnMinX)/stepX);
// int endY = (int)((patMaxY - gnMinY)/stepY);
//
// pattGraphic.translate(startX*stepX, startY*stepY);
// for (int yIdx=startY; yIdx<=endY; yIdx++) {
// for (int xIdx=startX; xIdx<=endX; xIdx++) {
// gn.paint(pattGraphic);
// pattGraphic.translate(stepX,0);
// }
// pattGraphic.translate(-(endX-startX+1)*stepX, stepY);
// }
// }
List bbox = new java.util.ArrayList();
bbox.add(new Double(rect.getX()));
bbox.add(new Double(rect.getHeight() + rect.getY()));
bbox.add(new Double(rect.getWidth() + rect.getX()));
bbox.add(new Double(rect.getY()));
AffineTransform transform;
transform = new AffineTransform(graphicsState.getTransform());
transform.concatenate(getTransform());
transform.concatenate(pp.getPatternTransform());
List theMatrix = new java.util.ArrayList();
double [] mat = new double[6];
transform.getMatrix(mat);
for (int idx = 0; idx < mat.length; idx++) {
theMatrix.add(new Double(mat[idx]));
}
/** @todo see if pdfDoc and res can be linked here,
(currently res <> PDFDocument's resources) so addFonts()
can be moved to PDFDocument class */
res.addFonts(pdfDoc, fontInfo);
PDFPattern myPat = pdfDoc.getFactory().makePattern(
resourceContext, 1, res, 1, 1, bbox,
rect.getWidth(), rect.getHeight(),
theMatrix, null,
pattGraphic.getBuffer());
currentStream.write(myPat.getColorSpaceOut(fill));
PDFAnnotList annots = context.getAnnotations();
if (annots != null) {
this.pdfDoc.addObject(annots);
}
if (outputStream != null) {