diff options
author | Mehdi Houshmand <mehdi@apache.org> | 2012-07-02 13:23:46 +0000 |
---|---|---|
committer | Mehdi Houshmand <mehdi@apache.org> | 2012-07-02 13:23:46 +0000 |
commit | ab426a49d46ec69b80e6accccd537522477df5b3 (patch) | |
tree | a4a4550b9d329c7a7eae6a8d00861f373911c081 /src/java/org/apache/fop/render/ps | |
parent | c9f6e74ddf229f879ea7df1b389d6018286ca1aa (diff) | |
parent | f5a033d38f700d70bbf679d87d535b37438c9ebb (diff) | |
download | xmlgraphics-fop-ab426a49d46ec69b80e6accccd537522477df5b3.tar.gz xmlgraphics-fop-ab426a49d46ec69b80e6accccd537522477df5b3.zip |
Merged in trunk@1356161
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_URI_Unification@1356212 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/render/ps')
-rw-r--r-- | src/java/org/apache/fop/render/ps/PSDocumentHandler.java | 9 | ||||
-rw-r--r-- | src/java/org/apache/fop/render/ps/PSPainter.java | 41 |
2 files changed, 17 insertions, 33 deletions
diff --git a/src/java/org/apache/fop/render/ps/PSDocumentHandler.java b/src/java/org/apache/fop/render/ps/PSDocumentHandler.java index 488abd559..d73beb759 100644 --- a/src/java/org/apache/fop/render/ps/PSDocumentHandler.java +++ b/src/java/org/apache/fop/render/ps/PSDocumentHandler.java @@ -56,6 +56,7 @@ import org.apache.fop.apps.MimeConstants; import org.apache.fop.apps.io.TempResourceURIGenerator; import org.apache.fop.render.intermediate.AbstractBinaryWritingIFDocumentHandler; import org.apache.fop.render.intermediate.IFContext; +import org.apache.fop.render.intermediate.IFDocumentHandler; import org.apache.fop.render.intermediate.IFDocumentHandlerConfigurator; import org.apache.fop.render.intermediate.IFException; import org.apache.fop.render.intermediate.IFPainter; @@ -80,10 +81,10 @@ public class PSDocumentHandler extends AbstractBinaryWritingIFDocumentHandler { * Utility class which enables all sorts of features that are not directly connected to the * normal rendering process. */ - protected PSRenderingUtil psUtil; + private PSRenderingUtil psUtil; /** The PostScript generator used to output the PostScript */ - protected PSGenerator gen; + PSGenerator gen; /** the temporary file in case of two-pass processing */ private URI tempURI; @@ -134,6 +135,10 @@ public class PSDocumentHandler extends AbstractBinaryWritingIFDocumentHandler { return MimeConstants.MIME_POSTSCRIPT; } + PSGenerator getGenerator() { + return gen; + } + /** {@inheritDoc} */ public IFDocumentHandlerConfigurator getConfigurator() { return new PSRendererConfigurator(getUserAgent(), new PSRendererConfigParser()); diff --git a/src/java/org/apache/fop/render/ps/PSPainter.java b/src/java/org/apache/fop/render/ps/PSPainter.java index c2288019a..63e947e55 100644 --- a/src/java/org/apache/fop/render/ps/PSPainter.java +++ b/src/java/org/apache/fop/render/ps/PSPainter.java @@ -41,7 +41,6 @@ import org.apache.xmlgraphics.ps.PSGenerator; import org.apache.xmlgraphics.ps.PSResource; import org.apache.fop.fonts.Font; -import org.apache.fop.fonts.FontInfo; import org.apache.fop.fonts.FontTriplet; import org.apache.fop.fonts.LazyFont; import org.apache.fop.fonts.MultiByteFont; @@ -49,7 +48,6 @@ import org.apache.fop.fonts.SingleByteFont; import org.apache.fop.fonts.Typeface; import org.apache.fop.render.RenderingContext; import org.apache.fop.render.intermediate.AbstractIFPainter; -import org.apache.fop.render.intermediate.IFContext; import org.apache.fop.render.intermediate.IFException; import org.apache.fop.render.intermediate.IFState; import org.apache.fop.render.intermediate.IFUtil; @@ -61,12 +59,11 @@ import org.apache.fop.util.HexEncoder; /** * IFPainter implementation that produces PostScript. */ -public class PSPainter extends AbstractIFPainter { +public class PSPainter extends AbstractIFPainter<PSDocumentHandler> { /** logging instance */ private static Log log = LogFactory.getLog(PSPainter.class); - private PSDocumentHandler documentHandler; private PSBorderPainter borderPainter; private boolean inTextMode = false; @@ -80,27 +77,13 @@ public class PSPainter extends AbstractIFPainter { } protected PSPainter(PSDocumentHandler documentHandler, IFState state) { - super(); - this.documentHandler = documentHandler; - this.borderPainter = new PSBorderPainter(documentHandler.gen); + super(documentHandler); + this.borderPainter = new PSBorderPainter(getGenerator()); this.state = state; } - /** {@inheritDoc} */ - protected IFContext getContext() { - return this.documentHandler.getContext(); - } - - PSRenderingUtil getPSUtil() { - return this.documentHandler.psUtil; - } - - FontInfo getFontInfo() { - return this.documentHandler.getFontInfo(); - } - private PSGenerator getGenerator() { - return this.documentHandler.gen; + return getDocumentHandler().getGenerator(); } /** {@inheritDoc} */ @@ -168,7 +151,7 @@ public class PSPainter extends AbstractIFPainter { /** {@inheritDoc} */ protected void drawImageUsingImageHandler(ImageInfo info, Rectangle rect) throws ImageException, IOException { - if (!getPSUtil().isOptimizeResources() + if (!getDocumentHandler().getPSUtil().isOptimizeResources() || PSImageUtils.isImageInlined(info, (PSRenderingContext)createRenderingContext())) { super.drawImageUsingImageHandler(info, rect); @@ -177,7 +160,7 @@ public class PSPainter extends AbstractIFPainter { log.debug("Image " + info + " is embedded as a form later"); } //Don't load image at this time, just put a form placeholder in the stream - PSResource form = documentHandler.getFormForImage(info.getOriginalURI()); + PSResource form = getDocumentHandler().getFormForImage(info.getOriginalURI()); PSImageUtils.drawForm(form, info, rect, getGenerator()); } } @@ -246,7 +229,7 @@ public class PSPainter extends AbstractIFPainter { if (top != null || bottom != null || left != null || right != null) { try { endTextObject(); - if (getPSUtil().getRenderingMode() == PSRenderingMode.SIZE + if (getDocumentHandler().getPSUtil().getRenderingMode() == PSRenderingMode.SIZE && hasOnlySolidBorders(top, bottom, left, right)) { super.drawBorderRect(rect, top, bottom, left, right); } else { @@ -273,7 +256,7 @@ public class PSPainter extends AbstractIFPainter { if (fontName == null) { throw new NullPointerException("fontName must not be null"); } - Typeface tf = (Typeface)getFontInfo().getFonts().get(fontName); + Typeface tf = getFontInfo().getFonts().get(fontName); if (tf instanceof LazyFont) { tf = ((LazyFont)tf).getRealFont(); } @@ -363,10 +346,7 @@ public class PSPainter extends AbstractIFPainter { state.getFontFamily(), state.getFontStyle(), state.getFontWeight()); //TODO Ignored: state.getFontVariant() //TODO Opportunity for font caching if font state is more heavily used - String fontKey = getFontInfo().getInternalFontKey(triplet); - if (fontKey == null) { - throw new IFException("Font not available: " + triplet, null); - } + String fontKey = getFontKey(triplet); int sizeMillipoints = state.getFontSize(); // This assumes that *all* CIDFonts use a /ToUnicode mapping @@ -529,10 +509,9 @@ public class PSPainter extends AbstractIFPainter { } private void useFont(String key, int size) throws IOException { - PSFontResource res = this.documentHandler.getPSResourceForFontKey(key); + PSFontResource res = getDocumentHandler().getPSResourceForFontKey(key); PSGenerator generator = getGenerator(); generator.useFont("/" + res.getName(), size / 1000f); res.notifyResourceUsageOnPage(generator.getResourceTracker()); } - } |