diff options
Diffstat (limited to 'src/java/org/apache/fop/svg/PDFBridgeContext.java')
-rw-r--r-- | src/java/org/apache/fop/svg/PDFBridgeContext.java | 104 |
1 files changed, 30 insertions, 74 deletions
diff --git a/src/java/org/apache/fop/svg/PDFBridgeContext.java b/src/java/org/apache/fop/svg/PDFBridgeContext.java index 6aa29cfa1..364c7a6f3 100644 --- a/src/java/org/apache/fop/svg/PDFBridgeContext.java +++ b/src/java/org/apache/fop/svg/PDFBridgeContext.java @@ -20,30 +20,20 @@ package org.apache.fop.svg; import java.awt.geom.AffineTransform; -import java.lang.reflect.Constructor; -import org.apache.batik.bridge.Bridge; import org.apache.batik.bridge.BridgeContext; import org.apache.batik.bridge.DocumentLoader; +import org.apache.batik.bridge.SVGTextElementBridge; import org.apache.batik.bridge.UserAgent; +import org.apache.batik.gvt.TextPainter; import org.apache.fop.fonts.FontInfo; - import org.apache.xmlgraphics.image.loader.ImageManager; import org.apache.xmlgraphics.image.loader.ImageSessionContext; - /** * BridgeContext which registers the custom bridges for PDF output. */ -public class PDFBridgeContext extends BridgeContext { - - /** The font list. */ - private final FontInfo fontInfo; - - private final ImageManager imageManager; - private final ImageSessionContext imageSessionContext; - - private AffineTransform linkTransform; +public class PDFBridgeContext extends AbstractFOPBridgeContext { /** * Constructs a new bridge context. @@ -53,18 +43,16 @@ public class PDFBridgeContext extends BridgeContext { * in which case text is painted as shapes * @param linkTransform AffineTransform to properly place links, * may be null + * @param imageManager an image manager + * @param imageSessionContext an image session context + * @param linkTransform AffineTransform to properly place links, + * may be null */ - public PDFBridgeContext(UserAgent userAgent, - DocumentLoader loader, - FontInfo fontInfo, - ImageManager imageManager, - ImageSessionContext imageSessionContext, - AffineTransform linkTransform) { - super(userAgent, loader); - this.fontInfo = fontInfo; - this.imageManager = imageManager; - this.imageSessionContext = imageSessionContext; - this.linkTransform = linkTransform; + public PDFBridgeContext(UserAgent userAgent, DocumentLoader documentLoader, + FontInfo fontInfo, ImageManager imageManager, + ImageSessionContext imageSessionContext, + AffineTransform linkTransform) { + super(userAgent, documentLoader, fontInfo, imageManager, imageSessionContext, linkTransform); } /** @@ -72,19 +60,12 @@ public class PDFBridgeContext extends BridgeContext { * @param userAgent the user agent * @param fontInfo the font list for the text painter, may be null * in which case text is painted as shapes - * @param linkTransform AffineTransform to properly place links, - * may be null + * @param imageManager an image manager + * @param imageSessionContext an image session context */ - public PDFBridgeContext(UserAgent userAgent, - FontInfo fontInfo, - ImageManager imageManager, - ImageSessionContext imageSessionContext, - AffineTransform linkTransform) { - super(userAgent); - this.fontInfo = fontInfo; - this.imageManager = imageManager; - this.imageSessionContext = imageSessionContext; - this.linkTransform = linkTransform; + public PDFBridgeContext(UserAgent userAgent, FontInfo fontInfo, + ImageManager imageManager, ImageSessionContext imageSessionContext) { + super(userAgent, fontInfo, imageManager, imageSessionContext); } /** @@ -92,41 +73,15 @@ public class PDFBridgeContext extends BridgeContext { * @param userAgent the user agent * @param fontInfo the font list for the text painter, may be null * in which case text is painted as shapes + * @param imageManager an image manager + * @param imageSessionContext an image session context + * @param linkTransform AffineTransform to properly place links, + * may be null */ - public PDFBridgeContext(UserAgent userAgent, - FontInfo fontInfo, - ImageManager imageManager, - ImageSessionContext imageSessionContext) { - this(userAgent, fontInfo, imageManager, imageSessionContext, null); - } - - /** - * Returns the ImageManager to be used by the ImageElementBridge. - * @return the image manager - */ - public ImageManager getImageManager() { - return this.imageManager; - } - - /** - * Returns the ImageSessionContext to be used by the ImageElementBridge. - * @return the image session context - */ - public ImageSessionContext getImageSessionContext() { - return this.imageSessionContext; - } - - private void putPDFElementBridgeConditional(String className, String testFor) { - try { - Class.forName(testFor); - //if we get here the test class is available - - Class clazz = Class.forName(className); - Constructor constructor = clazz.getConstructor(new Class[] {FontInfo.class}); - putBridge((Bridge)constructor.newInstance(new Object[] {fontInfo})); - } catch (Throwable t) { - //simply ignore (bridges instantiated over this method are optional) - } + public PDFBridgeContext(SVGUserAgent userAgent, FontInfo fontInfo, + ImageManager imageManager, ImageSessionContext imageSessionContext, + AffineTransform linkTransform) { + super(userAgent, fontInfo, imageManager, imageSessionContext, linkTransform); } /** {@inheritDoc} */ @@ -134,23 +89,24 @@ public class PDFBridgeContext extends BridgeContext { super.registerSVGBridges(); if (fontInfo != null) { - PDFTextElementBridge textElementBridge = new PDFTextElementBridge(fontInfo); + TextPainter textPainter = new PDFTextPainter(fontInfo); + SVGTextElementBridge textElementBridge = new PDFTextElementBridge(textPainter); putBridge(textElementBridge); //Batik flow text extension (may not always be available) //putBridge(new PDFBatikFlowTextElementBridge(fontInfo); - putPDFElementBridgeConditional( + putElementBridgeConditional( "org.apache.fop.svg.PDFBatikFlowTextElementBridge", "org.apache.batik.extension.svg.BatikFlowTextElementBridge"); //SVG 1.2 flow text support //putBridge(new PDFSVG12TextElementBridge(fontInfo)); //-->Batik 1.7 - putPDFElementBridgeConditional( + putElementBridgeConditional( "org.apache.fop.svg.PDFSVG12TextElementBridge", "org.apache.batik.bridge.svg12.SVG12TextElementBridge"); //putBridge(new PDFSVGFlowRootElementBridge(fontInfo)); - putPDFElementBridgeConditional( + putElementBridgeConditional( "org.apache.fop.svg.PDFSVGFlowRootElementBridge", "org.apache.batik.bridge.svg12.SVGFlowRootElementBridge"); } |