From 1750419a2fcec90c11bcd2e7e21ed45d581193d1 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Sun, 10 Oct 2004 12:19:19 +0000 Subject: [PATCH] Set Batik rendering hints to improve output quality. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198025 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/fop/render/ps/PSGraphics2D.java | 7 +++ .../org/apache/fop/svg/PDFGraphics2D.java | 51 +++++++++++-------- 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/src/java/org/apache/fop/render/ps/PSGraphics2D.java b/src/java/org/apache/fop/render/ps/PSGraphics2D.java index 4da7cc5c3..eea3c47cf 100644 --- a/src/java/org/apache/fop/render/ps/PSGraphics2D.java +++ b/src/java/org/apache/fop/render/ps/PSGraphics2D.java @@ -53,6 +53,7 @@ import java.awt.image.renderable.RenderableImage; import java.io.IOException; //Batik +import org.apache.batik.ext.awt.RenderingHintsKeyExt; import org.apache.batik.ext.awt.g2d.AbstractGraphics2D; import org.apache.batik.ext.awt.g2d.GraphicContext; import org.apache.commons.logging.Log; @@ -147,6 +148,12 @@ public class PSGraphics2D extends AbstractGraphics2D { */ public void setGraphicContext(GraphicContext c) { gc = c; + setPrivateHints(); + } + + private void setPrivateHints() { + setRenderingHint(RenderingHintsKeyExt.KEY_AVOID_TILE_PAINTING, + RenderingHintsKeyExt.VALUE_AVOID_TILE_PAINTING_ON); } /** diff --git a/src/java/org/apache/fop/svg/PDFGraphics2D.java b/src/java/org/apache/fop/svg/PDFGraphics2D.java index e8bddd53b..c675fe494 100644 --- a/src/java/org/apache/fop/svg/PDFGraphics2D.java +++ b/src/java/org/apache/fop/svg/PDFGraphics2D.java @@ -43,9 +43,9 @@ import org.apache.fop.render.pdf.FopPDFImage; import org.apache.batik.ext.awt.g2d.AbstractGraphics2D; import org.apache.batik.ext.awt.g2d.GraphicContext; -//import org.apache.batik.ext.awt.MultipleGradientPaint; import org.apache.batik.ext.awt.RadialGradientPaint; import org.apache.batik.ext.awt.LinearGradientPaint; +import org.apache.batik.ext.awt.RenderingHintsKeyExt; import org.apache.batik.gvt.PatternPaint; import org.apache.batik.gvt.GraphicsNode; @@ -174,7 +174,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { */ public PDFGraphics2D(boolean textAsShapes, FontInfo fi, PDFDocument doc, PDFResourceContext page, String pref, String font, float size) { - super(textAsShapes); + this(textAsShapes); pdfDoc = doc; resourceContext = page; currentFontName = font; @@ -193,6 +193,26 @@ public class PDFGraphics2D extends AbstractGraphics2D { super(textAsShapes); } + /** + * This constructor supports the create method. + * This is not implemented properly. + * + * @param g the PDF graphics to make a copy of + */ + public PDFGraphics2D(PDFGraphics2D g) { + super(g); + } + + /** + * Creates a new Graphics object that is + * a copy of this Graphics object. + * @return a new graphics context that is a copy of + * this graphics context. + */ + public Graphics create() { + return new PDFGraphics2D(this); + } + /** * Set the PDF state to use when starting to draw * into the PDF graphics. @@ -231,8 +251,14 @@ public class PDFGraphics2D extends AbstractGraphics2D { */ public void setGraphicContext(GraphicContext c) { gc = c; + setPrivateHints(); } + private void setPrivateHints() { + setRenderingHint(RenderingHintsKeyExt.KEY_AVOID_TILE_PAINTING, + RenderingHintsKeyExt.VALUE_AVOID_TILE_PAINTING_ON); + } + /** * Set the override font state for drawing text. * This is used by the PDF text painter so that it can temporarily @@ -245,26 +271,6 @@ public class PDFGraphics2D extends AbstractGraphics2D { ovFontState = infont; } - /** - * This constructor supports the create method. - * This is not implemented properly. - * - * @param g the PDF graphics to make a copy of - */ - public PDFGraphics2D(PDFGraphics2D g) { - super(g); - } - - /** - * Creates a new Graphics object that is - * a copy of this Graphics object. - * @return a new graphics context that is a copy of - * this graphics context. - */ - public Graphics create() { - return new PDFGraphics2D(this); - } - /** * Restore the PDF graphics state to the starting state level. */ @@ -429,6 +435,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { */ public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer) { + System.out.println("drawImage x=" + x + " y=" + y + " width=" + width + " height=" + height + " image=" + img.toString()); // first we look to see if we've already added this image to // the pdf document. If so, we just reuse the reference; // otherwise we have to build a FopImage and add it to the pdf -- 2.39.5