]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Bugzilla#52513: Moved FOUserAgent to the constructor of the Renderers
authorMehdi Houshmand <mehdi@apache.org>
Mon, 30 Jan 2012 09:49:22 +0000 (09:49 +0000)
committerMehdi Houshmand <mehdi@apache.org>
Mon, 30 Jan 2012 09:49:22 +0000 (09:49 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1237582 13f79535-47bb-0310-9956-ffa450edef68

30 files changed:
examples/embedding/java/embedding/ExampleFO2JPSPrint.java
examples/embedding/java/embedding/atxml/ExampleConcat.java
src/java/org/apache/fop/cli/CommandLineOptions.java
src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
src/java/org/apache/fop/render/AbstractRenderer.java
src/java/org/apache/fop/render/PrintRenderer.java
src/java/org/apache/fop/render/Renderer.java
src/java/org/apache/fop/render/RendererFactory.java
src/java/org/apache/fop/render/awt/AWTRenderer.java
src/java/org/apache/fop/render/awt/AWTRendererMaker.java
src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java
src/java/org/apache/fop/render/bitmap/PNGRenderer.java
src/java/org/apache/fop/render/bitmap/PNGRendererMaker.java
src/java/org/apache/fop/render/bitmap/TIFFRenderer.java
src/java/org/apache/fop/render/bitmap/TIFFRendererMaker.java
src/java/org/apache/fop/render/intermediate/IFRenderer.java
src/java/org/apache/fop/render/java2d/Java2DRenderer.java
src/java/org/apache/fop/render/print/PageableRenderer.java
src/java/org/apache/fop/render/print/PrintRenderer.java
src/java/org/apache/fop/render/print/PrintRendererMaker.java
src/java/org/apache/fop/render/txt/TXTRenderer.java
src/java/org/apache/fop/render/txt/TXTRendererMaker.java
src/java/org/apache/fop/render/xml/AbstractXMLRenderer.java
src/java/org/apache/fop/render/xml/XMLRenderer.java
src/java/org/apache/fop/render/xml/XMLRendererMaker.java
src/sandbox/org/apache/fop/render/svg/SVGRenderer.java
src/sandbox/org/apache/fop/render/svg/SVGRendererMaker.java
test/java/org/apache/fop/URIResolutionTestCase.java
test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java
test/java/org/apache/fop/layoutengine/LayoutEngineTestCase.java

index 4f18b71abd6797fc8ca0c0b673e5f6e413bbb213..1e0ec485333e6e03b8c03a3bdcc74dd3af5d7fbb 100644 (file)
@@ -85,8 +85,7 @@ public class ExampleFO2JPSPrint {
         //Set up a custom user agent so we can supply our own renderer instance
         FOUserAgent userAgent = fopFactory.newFOUserAgent();
 
-        PageableRenderer renderer = new PageableRenderer();
-        renderer.setUserAgent(userAgent);
+        PageableRenderer renderer = new PageableRenderer(userAgent);
         userAgent.setRendererOverride(renderer);
 
         // Construct FOP with desired output format
index adec1b08cb7dbd9ae0562afb0ff22a6f80df373c..289f7d0747ff23c039cc52b3d944c724e4e45142 100644 (file)
@@ -93,8 +93,7 @@ public class ExampleConcat {
                 userAgent, MimeConstants.MIME_PDF);
 
         //Create the XMLRenderer to create the area tree XML
-        XMLRenderer xmlRenderer = new XMLRenderer();
-        xmlRenderer.setUserAgent(userAgent);
+        XMLRenderer xmlRenderer = new XMLRenderer(userAgent);
 
         //Tell the XMLRenderer to mimic the target renderer
         xmlRenderer.mimicRenderer(targetRenderer);
index 0d4c3790c764a01bfa8290f39c56f60eef28ef22..845c11a0d78ab381572a650d0769401fb26e33b4 100644 (file)
@@ -203,17 +203,14 @@ public class CommandLineOptions {
                 System.err.println("Couldn't set system look & feel!");
             }
 
-            AWTRenderer renderer = new AWTRenderer(true);
-            renderer.setRenderable(inputHandler); //set before user agent!
-            renderer.setUserAgent(foUserAgent);
+            AWTRenderer renderer = new AWTRenderer(foUserAgent, inputHandler, true, true);
             foUserAgent.setRendererOverride(renderer);
         } else if (MimeConstants.MIME_FOP_AREA_TREE.equals(outputmode)
                && mimicRenderer != null) {
             // render from FO to Intermediate Format
             Renderer targetRenderer = foUserAgent.getRendererFactory().createRenderer(
                    foUserAgent, mimicRenderer);
-            XMLRenderer xmlRenderer = new XMLRenderer();
-            xmlRenderer.setUserAgent(foUserAgent);
+            XMLRenderer xmlRenderer = new XMLRenderer(foUserAgent);
 
             //Tell the XMLRenderer to mimic the target renderer
             xmlRenderer.mimicRenderer(targetRenderer);
index 45a02a9772eaad4fa1a881e36c2af60d5184847f..83d3d84a2554d86174d3a377aead15cd9e1d1c1c 100644 (file)
@@ -34,6 +34,7 @@ import org.apache.xmlgraphics.image.loader.ImageSize;
 import org.apache.xmlgraphics.util.QName;
 import org.apache.xmlgraphics.util.UnitConv;
 
+import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.area.Area;
 import org.apache.fop.area.Block;
 import org.apache.fop.area.BlockViewport;
@@ -56,6 +57,10 @@ import org.apache.fop.traits.BorderProps;
  */
 public abstract class AbstractPathOrientedRenderer extends PrintRenderer {
 
+    public AbstractPathOrientedRenderer(FOUserAgent userAgent) {
+        super(userAgent);
+    }
+
     /**
      * Handle block traits.
      * The block could be any sort of block with any positioning
index 7ff236d160867eefd8491a1919645e9de5b60715..659748df9ea67e96b833119d6c3f0ed25ba005d4 100644 (file)
@@ -61,11 +61,11 @@ import org.apache.fop.area.inline.Image;
 import org.apache.fop.area.inline.InlineArea;
 import org.apache.fop.area.inline.InlineBlockParent;
 import org.apache.fop.area.inline.InlineParent;
+import org.apache.fop.area.inline.InlineViewport;
 import org.apache.fop.area.inline.Leader;
 import org.apache.fop.area.inline.Space;
 import org.apache.fop.area.inline.SpaceArea;
 import org.apache.fop.area.inline.TextArea;
-import org.apache.fop.area.inline.InlineViewport;
 import org.apache.fop.area.inline.WordArea;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fonts.FontInfo;
@@ -116,16 +116,16 @@ public abstract class AbstractRenderer
     /** {@inheritDoc} */
     public abstract void setupFontInfo(FontInfo fontInfo) throws FOPException;
 
-    /** {@inheritDoc} */
-    public void setUserAgent(FOUserAgent agent) {
-        userAgent = agent;
+    /**
+     *
+     * @param userAgent the user agent that contains configuration details. This cannot be null.
+     */
+    public AbstractRenderer(FOUserAgent userAgent) {
+        this.userAgent = userAgent;
     }
 
     /** {@inheritDoc} */
     public FOUserAgent getUserAgent() {
-        if (userAgent == null) {
-            throw new IllegalStateException("FOUserAgent has not been set on Renderer");
-        }
         return userAgent;
     }
 
index be3ace0169f9bafb955dea2abeed008d274e6e4c..05e9cb7af6ab17a5aec35bf6e69390dd04f85769 100644 (file)
@@ -27,6 +27,7 @@ import java.util.Map;
 import org.w3c.dom.Document;
 
 import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.area.Area;
 import org.apache.fop.area.Trait;
 import org.apache.fop.fonts.CustomFontCollection;
@@ -42,6 +43,10 @@ import org.apache.fop.fonts.base14.Base14FontCollection;
 /** Abstract base class of "Print" type renderers.  */
 public abstract class PrintRenderer extends AbstractRenderer {
 
+    public PrintRenderer(FOUserAgent userAgent) {
+        super(userAgent);
+    }
+
     /** Font configuration */
     protected FontInfo fontInfo;
 
index 76f245251938dd8076518aeb7e63c56b1d71d3b2..5f5596dfb2722aa62f3524eb80c91037186b5441 100644 (file)
@@ -81,13 +81,6 @@ public interface Renderer {
     void stopRenderer()
         throws IOException;
 
-    /**
-     * Set the User Agent.
-     *
-     * @param agent  The User Agent
-     */
-    void setUserAgent(FOUserAgent agent);
-
     /**
      * Returns the associated user agent.
      * @return the user agent
index bc598450f40625862932c6586107d94e0b6ddd0b..3ceb27a8e4ed817329e6eebff80892bf20028502 100644 (file)
@@ -299,7 +299,6 @@ public class RendererFactory {
         AbstractRendererMaker maker = getRendererMaker(outputFormat);
         if (maker != null) {
             Renderer rend = maker.makeRenderer(userAgent);
-            rend.setUserAgent(userAgent);
             RendererConfigurator configurator = maker.getConfigurator(userAgent);
             if (configurator != null) {
                 configurator.configure(rend);
@@ -311,8 +310,7 @@ public class RendererFactory {
     }
 
     private Renderer createRendererForDocumentHandler(IFDocumentHandler documentHandler) {
-        IFRenderer rend = new IFRenderer();
-        rend.setUserAgent(documentHandler.getContext().getUserAgent());
+        IFRenderer rend = new IFRenderer(documentHandler.getContext().getUserAgent());
         rend.setDocumentHandler(documentHandler);
         return rend;
     }
index 99dece24a271d71cb5e71410551e6544679bffa1..c366552042f0cea985ed6d605c4e9b2dbce734d5 100644 (file)
@@ -64,18 +64,6 @@ public class AWTRenderer extends Java2DRenderer implements Pageable {
     /** flag for debugging */
     public boolean debug;                                       // CSOK: VisibilityModifier
 
-    /** If true, preview dialog is shown. */
-    public boolean dialogDisplay = true;                        // CSOK: VisibilityModifier
-
-    /** true if the preview dialog should be the main window of the application */
-    private boolean previewAsMainWindow;
-
-    /**
-     * Renderable instance that can be used to reload and re-render a document after
-     * modifications.
-     */
-    protected Renderable renderable;
-
     /**
      * Will be notified when rendering progresses
      */
@@ -84,47 +72,35 @@ public class AWTRenderer extends Java2DRenderer implements Pageable {
 
     /**
      * Creates a new AWTRenderer instance.
+     *
+     * @param userAgent the user agent that contains configuration data
      */
-    public AWTRenderer() {
-        this(false);
+    public AWTRenderer(FOUserAgent userAgent) {
+        this(userAgent, null, false, false);
     }
 
     /**
      * Creates a new AWTRenderer instance.
+     *
+     * @param userAgent the user agent that contains configuration data
+     * @param renderable a Renderable instance can be set so the Preview Dialog can enable the
+     * "Reload" button which causes the current document to be reprocessed and redisplayed.
      * @param previewAsMainWindow true if the preview dialog created by the renderer should be
-     *                            the main window of the application.
+     * the main window of the application.
+     * @param show sets whether the preview dialog should be created and displayed when the
+     * rendering has finished.
      */
-    public AWTRenderer(boolean previewAsMainWindow) {
-        this.previewAsMainWindow = previewAsMainWindow;
-    }
-
-    /** {@inheritDoc} */
-    public void setUserAgent(FOUserAgent foUserAgent) {
-        super.setUserAgent(foUserAgent);
-        if (dialogDisplay) {
-            setStatusListener(PreviewDialog.createPreviewDialog(userAgent, this.renderable,
-                    this.previewAsMainWindow));
+    public AWTRenderer(FOUserAgent userAgent, Renderable renderable, boolean previewAsMainWindow,
+            boolean show) {
+        super(userAgent);
+        if (show) {
+            // MH: Not sure about this??? If show is false, there's no way for this class
+            // to create a preview dialog... Previously a "setUserAgent" could be called.
+            setStatusListener(PreviewDialog.createPreviewDialog(userAgent, renderable,
+                    previewAsMainWindow));
         }
     }
 
-    /**
-     * A Renderable instance can be set so the Preview Dialog can enable the "Reload" button
-     * which causes the current document to be reprocessed and redisplayed.
-     * @param renderable the Renderable instance.
-     */
-    public void setRenderable(Renderable renderable) {
-        this.renderable = renderable;
-    }
-
-    /**
-     * Sets whether the preview dialog should be created and displayed when
-     * the rendering is finished.
-     * @param show If false, preview dialog is not shown. True by default
-     */
-    public void setPreviewDialogDisplayed(boolean show) {
-        dialogDisplay = show;
-    }
-
     /**
      * {@inheritDoc}
      */
index 983b42e0c8e4496fdcc6f2f6e96e691efdfc63e3..d65a550d43f613a928153fa96eb8ce64fa605626 100644 (file)
@@ -34,7 +34,7 @@ public class AWTRendererMaker extends AbstractRendererMaker {
 
     /** {@inheritDoc} */
     public Renderer makeRenderer(FOUserAgent ua) {
-        return new AWTRenderer();
+        return new AWTRenderer(ua);
     }
 
     /** {@inheritDoc} */
index 2303c0e8ee5dcb4b5f4949a6fbc72b687e0504f1..c850c35e7eef5d0870e2639e6b88ff6ff6be3d83 100644 (file)
@@ -67,12 +67,9 @@ import org.apache.fop.render.awt.AWTRenderer;
  * </p>
  * <pre>
  * FopFactory fopFactory = FopFactory.newInstance();
- * AWTRenderer renderer = new AWTRenderer();
  * FOUserAgent agent = fopFactory.newFOUserAgent();
+ * AWTRenderer renderer = new AWTRenderer(agent);
  * agent.setRendererOverride(renderer);
- * renderer.setPreviewDialogDisplayed(false);
- * renderer.setUserAgent(agent);
- * renderer.setUserAgent(agent);
  * previewPanel = new PreviewPanel(agent, null, renderer);
  * previewPanel = new PreviewPanel(ua);
  * myGui.add(previewPanel);
index 3733bf2f27462e7f168606053cdd1a765dc8887e..1c6f2e33df6ad0c3e81bd6cca4454142817daef0 100644 (file)
@@ -29,6 +29,7 @@ import org.apache.xmlgraphics.image.writer.ImageWriter;
 import org.apache.xmlgraphics.image.writer.ImageWriterParams;
 import org.apache.xmlgraphics.image.writer.ImageWriterRegistry;
 
+import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.MimeConstants;
 import org.apache.fop.area.PageViewport;
 import org.apache.fop.render.java2d.Java2DRenderer;
@@ -40,6 +41,10 @@ import org.apache.fop.render.java2d.Java2DRenderer;
  */
 public class PNGRenderer extends Java2DRenderer {
 
+    public PNGRenderer(FOUserAgent userAgent) {
+        super(userAgent);
+    }
+
     /** The MIME type for png-Rendering */
     public static final String MIME_TYPE = MimeConstants.MIME_PNG;
 
index 7d321791af5567fc39da7a72edc990e35efd4ed3..da19b29869f249a7da59395a37757f4f933994a9 100644 (file)
@@ -36,7 +36,7 @@ public class PNGRendererMaker extends AbstractRendererMaker {
 
     /** {@inheritDoc} */
     public Renderer makeRenderer(FOUserAgent ua) {
-        return new PNGRenderer();
+        return new PNGRenderer(ua);
     }
 
     /** {@inheritDoc} */
index 5a9cfa21b2cf126cf5c10ed8dd09ed13108f61e2..0e2364d35d36d46306ca68136a8550aa02a18ab7 100644 (file)
@@ -83,19 +83,11 @@ public class TIFFRenderer extends Java2DRenderer implements TIFFConstants {
     }
 
     /** Creates TIFF renderer. */
-    public TIFFRenderer() {
+    public TIFFRenderer(FOUserAgent userAgent) {
+        super(userAgent);
         writerParams = new ImageWriterParams();
         writerParams.setCompressionMethod(COMPRESSION_PACKBITS);
-    }
-
-    /**
-     * {@inheritDoc}
-     *          org.apache.fop.apps.FOUserAgent)
-     */
-    public void setUserAgent(FOUserAgent foUserAgent) {
-        super.setUserAgent(foUserAgent);
 
-        //Set target resolution
         int dpi = Math.round(userAgent.getTargetResolution());
         writerParams.setResolution(dpi);
     }
index e3c567995228af973166441a2eaa9066d2cbd322..852e6ba04565f7685a449986d896d5be546781bf 100644 (file)
@@ -34,7 +34,7 @@ public class TIFFRendererMaker extends AbstractRendererMaker {
 
     /** {@inheritDoc} */
     public Renderer makeRenderer(FOUserAgent userAgent) {
-        return new TIFFRenderer();
+        return new TIFFRenderer(userAgent);
     }
 
     /** {@inheritDoc} */
index 24a2e8a75809b11ec0888e0bd1579911160aa695..d5d5a154a99547cac2b0643f1344b54699912ea7 100644 (file)
@@ -51,6 +51,7 @@ import org.apache.xmlgraphics.xmp.schemas.XMPBasicSchema;
 
 import org.apache.fop.Version;
 import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.MimeConstants;
 import org.apache.fop.area.Area;
 import org.apache.fop.area.AreaTreeObject;
@@ -70,10 +71,10 @@ import org.apache.fop.area.inline.ForeignObject;
 import org.apache.fop.area.inline.Image;
 import org.apache.fop.area.inline.InlineArea;
 import org.apache.fop.area.inline.InlineParent;
+import org.apache.fop.area.inline.InlineViewport;
 import org.apache.fop.area.inline.Leader;
 import org.apache.fop.area.inline.SpaceArea;
 import org.apache.fop.area.inline.TextArea;
-import org.apache.fop.area.inline.InlineViewport;
 import org.apache.fop.area.inline.WordArea;
 import org.apache.fop.datatypes.URISpecification;
 import org.apache.fop.fo.extensions.ExtensionAttachment;
@@ -158,7 +159,8 @@ public class IFRenderer extends AbstractPathOrientedRenderer {
     /**
      * Main constructor
      */
-    public IFRenderer() {
+    public IFRenderer(FOUserAgent userAgent) {
+        super(userAgent);
     }
 
     /** {@inheritDoc} */
index 766aa081f8d273eafe0fd5012482549b901d5214..3c7006588cadf822104805e77b23acdf22999a98 100644 (file)
@@ -147,15 +147,13 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem
     private GeneralPath currentPath = null;
 
     /** Default constructor */
-    public Java2DRenderer() {
-    }
+    public Java2DRenderer(FOUserAgent userAgent) {
+        super(userAgent);
 
-    /** {@inheritDoc} */
-    public void setUserAgent(FOUserAgent foUserAgent) {
-        super.setUserAgent(foUserAgent);
+        // MH: necessary? the caller has access to FOUserAgent
         userAgent.setRendererOverride(this); // for document regeneration
 
-        String s = (String)userAgent.getRendererOptions().get(JAVA2D_TRANSPARENT_PAGE_BACKGROUND);
+        String s = (String) userAgent.getRendererOptions().get(JAVA2D_TRANSPARENT_PAGE_BACKGROUND);
         if (s != null) {
             this.transparentPageBackground = "true".equalsIgnoreCase(s);
         }
index 89ab980710969da3f47cdb61c9cc38cc14cfa445..08d5b0f041805bef23110a9b3d2f7deb93bfc43d 100644 (file)
@@ -73,7 +73,11 @@ public class PageableRenderer extends Java2DRenderer implements Pageable {
     /**
      * Creates a new PageableRenderer.
      */
-    public PageableRenderer() {
+    public PageableRenderer(FOUserAgent userAgent) {
+        super(userAgent);
+        Map rendererOptions = getUserAgent().getRendererOptions();
+        processOptions(rendererOptions);
+        this.pageFilter = new DefaultPageFilter();
     }
 
     /** {@inheritDoc} */
@@ -81,15 +85,6 @@ public class PageableRenderer extends Java2DRenderer implements Pageable {
         return MimeConstants.MIME_FOP_PRINT;
     }
 
-    /** {@inheritDoc} */
-    public void setUserAgent(FOUserAgent agent) {
-        super.setUserAgent(agent);
-
-        Map rendererOptions = agent.getRendererOptions();
-        processOptions(rendererOptions);
-        this.pageFilter = new DefaultPageFilter();
-    }
-
     private void processOptions(Map rendererOptions) {
         Object o = rendererOptions.get(PageableRenderer.PAGES_MODE);
         if (o != null) {
index 2eb2b07a2565d9d639d0514ac65134ca8655868a..ea68bc9b2aa939cbbdece771439911418443e7e4 100644 (file)
@@ -55,19 +55,9 @@ public class PrintRenderer extends PageableRenderer {
      * Creates a new PrintRenderer with the options set through the renderer options if a custom
      * PrinterJob is not given in FOUserAgent's renderer options.
      */
-    public PrintRenderer() {
-    }
-
-    /**
-     * Creates a new PrintRenderer and allows you to pass in a specific PrinterJob instance
-     * that this renderer should work with.
-     * @param printerJob the PrinterJob instance
-     * @deprecated Please use the rendering options on the user agent to pass in the PrinterJob!
-     */
-    public PrintRenderer(PrinterJob printerJob) {
-        this();
-        this.printerJob = printerJob;
-        printerJob.setPageable(this);
+    public PrintRenderer(FOUserAgent userAgent) {
+        super(userAgent);
+        setRendererOptions();
     }
 
     private void initializePrinterJob() {
@@ -85,11 +75,8 @@ public class PrintRenderer extends PageableRenderer {
         }
     }
 
-    /** {@inheritDoc} */
-    public void setUserAgent(FOUserAgent agent) {
-        super.setUserAgent(agent);
-
-        Map rendererOptions = agent.getRendererOptions();
+    private void setRendererOptions() {
+        Map rendererOptions = getUserAgent().getRendererOptions();
 
         Object printerJobO = rendererOptions.get(PrintRenderer.PRINTER_JOB);
         if (printerJobO != null) {
index 21eb4717a5548f73df933552cecc972f58953c01..63444a628447c608984f599e9a79ffcfdc221b63 100644 (file)
@@ -35,7 +35,7 @@ public class PrintRendererMaker extends AbstractRendererMaker {
 
     /**{@inheritDoc} */
     public Renderer makeRenderer(FOUserAgent userAgent) {
-        return new PrintRenderer();
+        return new PrintRenderer(userAgent);
     }
 
     /** {@inheritDoc} */
index 386f95838c56c8cd40edffc69d9274a11aa4f277..74c5b84a8b4547f00009c065a3a265aa19e70ce1 100644 (file)
@@ -32,6 +32,7 @@ import java.util.Map;
 import org.apache.xmlgraphics.util.UnitConv;
 
 import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.area.Area;
 import org.apache.fop.area.CTM;
 import org.apache.fop.area.PageViewport;
@@ -110,7 +111,8 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
     /**
      * Constructs a newly allocated <code>TXTRenderer</code> object.
      */
-    public TXTRenderer() {
+    public TXTRenderer(FOUserAgent userAgent) {
+        super(userAgent);
     }
 
     /** {@inheritDoc} */
index 0db369ef2102c703c070a2de646b0c78077a60d8..740866e0cbb889939fc35bc0e3051d5871121162 100644 (file)
@@ -34,7 +34,7 @@ public class TXTRendererMaker extends AbstractRendererMaker {
 
     /**{@inheritDoc} */
     public Renderer makeRenderer(FOUserAgent userAgent) {
-        return new TXTRenderer();
+        return new TXTRenderer(userAgent);
     }
 
     /**{@inheritDoc} */
index 497e3c04786330d5cfbc4d35e6e16333a68b0b86..9c938199f9819602aa439d8336269953af969e1f 100644 (file)
@@ -29,6 +29,15 @@ import javax.xml.transform.sax.SAXTransformerFactory;
 import javax.xml.transform.sax.TransformerHandler;
 import javax.xml.transform.stream.StreamResult;
 
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.ext.LexicalHandler;
+import org.xml.sax.helpers.AttributesImpl;
+
+import org.apache.xmlgraphics.util.QName;
+
+import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.area.BookmarkData;
 import org.apache.fop.area.OffDocumentExtensionAttachment;
 import org.apache.fop.area.OffDocumentItem;
@@ -36,16 +45,14 @@ import org.apache.fop.area.PageViewport;
 import org.apache.fop.fo.extensions.ExtensionAttachment;
 import org.apache.fop.render.PrintRenderer;
 import org.apache.fop.render.RendererContext;
-import org.apache.xmlgraphics.util.QName;
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.ext.LexicalHandler;
-import org.xml.sax.helpers.AttributesImpl;
 
 /** Abstract xml renderer base class. */
 public abstract class AbstractXMLRenderer extends PrintRenderer {
 
+    public AbstractXMLRenderer(FOUserAgent userAgent) {
+        super(userAgent);
+    }
+
     /** Main namespace in use. */
     public static final String NS = "";
 
index 21d28042dfce20708331bdbc4876b25a9ff7d2ca..3ae49b1214cdf2d9261e72c0bc71292da52e92ed 100644 (file)
@@ -37,7 +37,6 @@ import javax.xml.transform.stream.StreamResult;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
-
 import org.xml.sax.SAXException;
 
 import org.apache.xmlgraphics.util.QName;
@@ -75,11 +74,11 @@ import org.apache.fop.area.inline.Image;
 import org.apache.fop.area.inline.InlineArea;
 import org.apache.fop.area.inline.InlineBlockParent;
 import org.apache.fop.area.inline.InlineParent;
+import org.apache.fop.area.inline.InlineViewport;
 import org.apache.fop.area.inline.Leader;
 import org.apache.fop.area.inline.Space;
 import org.apache.fop.area.inline.SpaceArea;
 import org.apache.fop.area.inline.TextArea;
-import org.apache.fop.area.inline.InlineViewport;
 import org.apache.fop.area.inline.WordArea;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.extensions.ExtensionAttachment;
@@ -113,20 +112,9 @@ public class XMLRenderer extends AbstractXMLRenderer {
 
     private int pageSequenceIndex;
 
-    /**
-     * Creates a new XML renderer.
-     */
-    public XMLRenderer() {
+    public XMLRenderer(FOUserAgent userAgent) {
+        super(userAgent);
         context = new RendererContext(this, XML_MIME_TYPE);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void setUserAgent(FOUserAgent agent) {
-        super.setUserAgent(agent);
-
         XMLHandler xmlHandler = new XMLXMLHandler();
         userAgent.getXMLHandlerRegistry().addXMLHandler(xmlHandler);
         Boolean b = (Boolean)userAgent.getRendererOptions().get("compact-format");
index 8526daa2ab742c42c80856cf88783e71f0c16aca..f54c74b3243bdfa5f51d9b88d95cdae22209f47e 100644 (file)
@@ -35,7 +35,7 @@ public class XMLRendererMaker extends AbstractRendererMaker {
 
     /**{@inheritDoc} */
     public Renderer makeRenderer(FOUserAgent userAgent) {
-        return new XMLRenderer();
+        return new XMLRenderer(userAgent);
     }
 
     /**{@inheritDoc} */
index 63f486c07df2ceddf8db05aa1d62fee6e8239692..246062a3285ccbab7f2f65fc2d4bfd06256b8745 100644 (file)
@@ -26,19 +26,22 @@ import java.io.IOException;
 import java.io.OutputStream;
 import java.io.Writer;
 
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+
 import org.apache.batik.dom.GenericDOMImplementation;
 import org.apache.batik.svggen.SVGGeneratorContext;
 import org.apache.batik.svggen.SVGGraphics2D;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
+import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.MimeConstants;
 import org.apache.fop.area.PageViewport;
 import org.apache.fop.render.bitmap.MultiFileRenderingUtil;
 import org.apache.fop.render.java2d.Java2DGraphicsState;
 import org.apache.fop.render.java2d.Java2DRenderer;
-import org.w3c.dom.DOMImplementation;
-import org.w3c.dom.Document;
 
 /**
  * <p>
@@ -67,8 +70,8 @@ public class SVGRenderer extends Java2DRenderer {
     /** Helper class for generating multiple files */
     private MultiFileRenderingUtil multiFileUtil;
 
-    /** Default constructor. */
-    public SVGRenderer() {
+    public SVGRenderer(FOUserAgent userAgent) {
+        super(userAgent);
     }
 
     /** {@inheritDoc} */
index f0da974e6634ab45d7f11a2f14e9c809df8b03d3..892d017118190e9e9b645587d2b27d7cd3422833 100644 (file)
@@ -34,7 +34,7 @@ public class SVGRendererMaker extends AbstractRendererMaker {
 
     /** {@inheritDoc} */
     public Renderer makeRenderer(FOUserAgent ua) {
-        return new SVGRenderer();
+        return new SVGRenderer(ua);
     }
 
     /** {@inheritDoc} */
index 97d1c9c25afa521ed298c1c8b09ec101eca94b49..490486158bb8413bd2d7f31f2d1a2d471b5f1b6b 100644 (file)
@@ -39,19 +39,21 @@ import javax.xml.transform.sax.TransformerHandler;
 import javax.xml.transform.stream.StreamResult;
 import javax.xml.transform.stream.StreamSource;
 
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.w3c.dom.Document;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.io.output.ByteArrayOutputStream;
+import org.apache.xpath.XPathAPI;
+import org.apache.xpath.objects.XObject;
+
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.Fop;
 import org.apache.fop.apps.FopFactory;
 import org.apache.fop.apps.MimeConstants;
 import org.apache.fop.render.xml.XMLRenderer;
-import org.apache.xpath.XPathAPI;
-import org.apache.xpath.objects.XObject;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.w3c.dom.Document;
 
 /**
  * Tests URI resolution facilities.
@@ -160,8 +162,7 @@ public class URIResolutionTestCase extends AbstractFOPTest {
         TransformerHandler athandler = tfactory.newTransformerHandler();
         athandler.setResult(domres);
 
-        XMLRenderer atrenderer = new XMLRenderer();
-        atrenderer.setUserAgent(ua);
+        XMLRenderer atrenderer = new XMLRenderer(ua);
         atrenderer.setContentHandler(athandler);
         ua.setRendererOverride(atrenderer);
 
index a0de2e8abeb5681fd28fe6a4913ce71955cd9d34..1f8abb9befa2d5200729f50f749e61e168f51ad5 100644 (file)
@@ -97,10 +97,9 @@ public class AreaTreeParserTestCase extends AbstractIntermediateTest {
         Renderer targetRenderer = userAgent.getRendererFactory().createRenderer(
                 userAgent, getTargetMIME());
 
-        XMLRenderer renderer = new XMLRenderer();
+        XMLRenderer renderer = new XMLRenderer(userAgent);
         renderer.mimicRenderer(targetRenderer);
         renderer.setContentHandler(handler);
-        renderer.setUserAgent(userAgent);
 
         userAgent.setRendererOverride(renderer);
 
@@ -131,12 +130,10 @@ public class AreaTreeParserTestCase extends AbstractIntermediateTest {
         TransformerHandler handler = testAssistant.getTransformerFactory().newTransformerHandler();
         DOMResult domResult = new DOMResult();
         handler.setResult(domResult);
-        XMLRenderer renderer = new XMLRenderer();
-        renderer.setContentHandler(handler);
-
         FOUserAgent userAgent = createUserAgent();
+        XMLRenderer renderer = new XMLRenderer(userAgent);
         userAgent.setRendererOverride(renderer);
-        renderer.setUserAgent(userAgent);
+        renderer.setContentHandler(handler);
 
         FontInfo fontInfo = new FontInfo();
         AreaTreeModel treeModel = new RenderPagesModel(userAgent,
index 46908a4480bbe6b447b1b95d4d64eed3d743ce72..6a0d424e9a7b5d9e4f34f8c5818d4ca339f18ebf 100644 (file)
@@ -150,8 +150,7 @@ public class LayoutEngineTestCase {
             ua.getEventBroadcaster().addEventListener(
                     new ConsoleEventListenerForTests(testFile.getName(), EventSeverity.WARN));
 
-            XMLRenderer atrenderer = new XMLRenderer();
-            atrenderer.setUserAgent(ua);
+            XMLRenderer atrenderer = new XMLRenderer(ua);
             atrenderer.setContentHandler(athandler);
             ua.setRendererOverride(atrenderer);
             fop = effFactory.newFop(ua);
@@ -208,8 +207,7 @@ public class LayoutEngineTestCase {
             ua.getEventBroadcaster().addEventListener(
                     new ConsoleEventListenerForTests(testFile.getName(), EventSeverity.WARN));
 
-            IFRenderer ifRenderer = new IFRenderer();
-            ifRenderer.setUserAgent(ua);
+            IFRenderer ifRenderer = new IFRenderer(ua);
 
             IFSerializer serializer = new IFSerializer();
             serializer.setContext(new IFContext(ua));