aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org
diff options
context:
space:
mode:
authorGlen Mazza <gmazza@apache.org>2004-07-18 00:50:08 +0000
committerGlen Mazza <gmazza@apache.org>2004-07-18 00:50:08 +0000
commit3d598730fe1e84e080ebd43580a6a60cb75bcb7e (patch)
tree739e843860e75e06eceec477d3e4fe10dd9a31c7 /src/java/org
parentdb8e56a16f00fd1b43e60b39d164f3215ad3cc33 (diff)
downloadxmlgraphics-fop-3d598730fe1e84e080ebd43580a6a60cb75bcb7e.tar.gz
xmlgraphics-fop-3d598730fe1e84e080ebd43580a6a60cb75bcb7e.zip
1. New constructor for Driver created, takes FOUserAgent constructor.
Used for both CLI and AWTRenderer. (Thanks to Simon Pepping) 2. Removed Driver(AWTRenderer) constructor. 3. OutputStream validation moved to FOTreeBuilder. 4. Driver.reset() removed, not currently serving a purpose. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197797 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org')
-rw-r--r--src/java/org/apache/fop/apps/Driver.java38
-rw-r--r--src/java/org/apache/fop/apps/Fop.java5
-rw-r--r--src/java/org/apache/fop/fo/FOTreeBuilder.java9
-rw-r--r--src/java/org/apache/fop/render/awt/AWTRenderer.java7
-rw-r--r--src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java22
-rw-r--r--src/java/org/apache/fop/tools/TestConverter.java2
6 files changed, 32 insertions, 51 deletions
diff --git a/src/java/org/apache/fop/apps/Driver.java b/src/java/org/apache/fop/apps/Driver.java
index 41ae90469..f63581689 100644
--- a/src/java/org/apache/fop/apps/Driver.java
+++ b/src/java/org/apache/fop/apps/Driver.java
@@ -31,7 +31,6 @@ import org.xml.sax.XMLReader;
// FOP
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.FOTreeBuilder;
-import org.apache.fop.render.awt.AWTRenderer;
/**
* Primary class that drives the overall FOP process.
@@ -48,10 +47,6 @@ import org.apache.fop.render.awt.AWTRenderer;
* use and the OutputStream to use to output the results of the
* rendering (where applicable).
* <P>
- * Once the Driver is set up, the render method
- * is called. The invocation of the method is
- * render(Parser, InputSource).
- * <P>
* Here is an example use of Driver which outputs to AWT:
*
* <PRE>
@@ -70,7 +65,7 @@ public class Driver implements Constants {
/**
* the stream to use to output the results of the renderer
*/
- private OutputStream stream;
+ private OutputStream stream = null;
/**
* The system resources that FOP will use
@@ -82,17 +77,6 @@ public class Driver implements Constants {
*/
public Driver() {
foUserAgent = new FOUserAgent();
- stream = null;
- }
-
- /**
- * Constructor for AWTRenderer, which reuses the
- * same renderer instance for document reloading
- */
- public Driver(AWTRenderer render) {
- this();
- renderType = RENDER_AWT;
- foUserAgent = render.getUserAgent();
}
/**
@@ -105,12 +89,11 @@ public class Driver implements Constants {
}
/**
- * Resets the Driver so it can be reused. Property and element
- * mappings are reset to defaults.
- * The output stream is cleared. The renderer is cleared.
+ * Constructor with FOUserAgent
+ * Used by CLI, AWTRenderer
*/
- public synchronized void reset() {
- stream = null;
+ public Driver(FOUserAgent ua) {
+ foUserAgent = ua;
}
/**
@@ -139,12 +122,6 @@ public class Driver implements Constants {
this.stream = stream;
}
- private void validateOutputStream() {
- if (this.stream == null) {
- throw new IllegalStateException("OutputStream has not been set");
- }
- }
-
/**
* Method to set the rendering type desired. Must be one of
* <ul>
@@ -182,11 +159,6 @@ public class Driver implements Constants {
* @throws FOPException if setting up the ContentHandler fails
*/
public ContentHandler getContentHandler() throws FOPException {
-
- if (renderType != RENDER_PRINT && renderType != RENDER_AWT) {
- validateOutputStream();
- }
-
return new FOTreeBuilder(renderType, foUserAgent, stream);
}
diff --git a/src/java/org/apache/fop/apps/Fop.java b/src/java/org/apache/fop/apps/Fop.java
index 6db94af9e..d42424fa0 100644
--- a/src/java/org/apache/fop/apps/Fop.java
+++ b/src/java/org/apache/fop/apps/Fop.java
@@ -41,11 +41,10 @@ public class Fop {
BufferedOutputStream bos = null;
try {
- Driver driver = new Driver();
options = new CommandLineOptions(args);
-
foUserAgent = options.getFOUserAgent();
- driver.setUserAgent(foUserAgent);
+
+ Driver driver = new Driver(foUserAgent);
driver.setRenderer(options.getRenderer());
try {
diff --git a/src/java/org/apache/fop/fo/FOTreeBuilder.java b/src/java/org/apache/fop/fo/FOTreeBuilder.java
index c9f566c18..5f32eda89 100644
--- a/src/java/org/apache/fop/fo/FOTreeBuilder.java
+++ b/src/java/org/apache/fop/fo/FOTreeBuilder.java
@@ -96,6 +96,15 @@ public class FOTreeBuilder extends DefaultHandler {
*/
public FOTreeBuilder(int renderType, FOUserAgent foUserAgent,
OutputStream stream) throws FOPException {
+
+ if (renderType != Constants.RENDER_PRINT &&
+ renderType != Constants.RENDER_AWT) {
+ if (stream == null) {
+ throw new IllegalStateException(
+ "OutputStream has not been set");
+ }
+ }
+
if (renderType == Constants.RENDER_MIF) {
foInputHandler = new MIFHandler(foUserAgent, stream);
} else if (renderType == Constants.RENDER_RTF) {
diff --git a/src/java/org/apache/fop/render/awt/AWTRenderer.java b/src/java/org/apache/fop/render/awt/AWTRenderer.java
index 975f631f4..6fbb5402b 100644
--- a/src/java/org/apache/fop/render/awt/AWTRenderer.java
+++ b/src/java/org/apache/fop/render/awt/AWTRenderer.java
@@ -106,7 +106,8 @@ public class AWTRenderer extends AbstractRenderer implements Printable, Pageable
public void setUserAgent(FOUserAgent foUserAgent) {
super.setUserAgent(foUserAgent);
- createPreviewDialog(foUserAgent.getInputHandler());
+ userAgent.setRendererOverride(this); // for document regeneration
+ createPreviewDialog();
}
public FOUserAgent getUserAgent() {
@@ -180,8 +181,8 @@ public class AWTRenderer extends AbstractRenderer implements Printable, Pageable
return 0;
}
- private PreviewDialog createPreviewDialog(InputHandler handler) {
- frame = new PreviewDialog(this, handler);
+ private PreviewDialog createPreviewDialog() {
+ frame = new PreviewDialog(userAgent);
frame.addWindowListener(new WindowAdapter() {
public void windowClosed(WindowEvent we) {
System.exit(0);
diff --git a/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java b/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java
index 8a09828f1..ef565573b 100644
--- a/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java
+++ b/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java
@@ -49,8 +49,9 @@ import java.awt.print.PrinterException;
//FOP
import org.apache.fop.apps.Driver;
-import org.apache.fop.apps.InputHandler;
+import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.FOPException;
+import org.apache.fop.fo.Constants;
import org.apache.fop.render.awt.AWTRenderer;
/**
@@ -66,8 +67,8 @@ public class PreviewDialog extends JFrame {
protected Translator translator;
/** The AWT renderer */
protected AWTRenderer renderer;
- /** The InputHandler associated with this window */
- protected InputHandler inputHandler;
+ /** The FOUserAgent associated with this window */
+ protected FOUserAgent foUserAgent;
/** The Driver used for refreshing/reloading the view */
protected Driver driver;
@@ -83,9 +84,9 @@ public class PreviewDialog extends JFrame {
* Creates a new PreviewDialog that uses the given renderer.
* @param aRenderer the to use renderer
*/
- public PreviewDialog(AWTRenderer aRenderer, InputHandler handler) {
- renderer = aRenderer;
- inputHandler = handler;
+ public PreviewDialog(FOUserAgent foUserAgent) {
+ renderer = (AWTRenderer) foUserAgent.getRendererOverride();
+ this.foUserAgent = foUserAgent;
translator = renderer.getTranslator();
//Commands aka Actions
@@ -219,7 +220,7 @@ public class PreviewDialog extends JFrame {
}
});
// inputHandler must be set to allow reloading
- if (inputHandler != null) {
+ if (foUserAgent.getInputHandler() != null) {
menu.add(new Command(translator.getString("Menu.Reload")) {
public void doit() {
reload();
@@ -384,9 +385,8 @@ public class PreviewDialog extends JFrame {
private class Reloader extends Thread {
public void run() {
if (driver == null) {
- driver = new Driver(renderer);
- } else {
- driver.reset();
+ driver = new Driver(foUserAgent);
+ driver.setRenderer(Constants.RENDER_AWT);
}
pageLabel.setIcon(null);
@@ -395,7 +395,7 @@ public class PreviewDialog extends JFrame {
try {
setStatus(translator.getString("Status.Build.FO.tree"));
- driver.render(inputHandler);
+ driver.render(foUserAgent.getInputHandler());
setStatus(translator.getString("Status.Show"));
} catch (FOPException e) {
reportException(e);
diff --git a/src/java/org/apache/fop/tools/TestConverter.java b/src/java/org/apache/fop/tools/TestConverter.java
index a1ffe0f81..165de1cdb 100644
--- a/src/java/org/apache/fop/tools/TestConverter.java
+++ b/src/java/org/apache/fop/tools/TestConverter.java
@@ -302,7 +302,7 @@ public class TestConverter {
} else {
inputHandler = new XSLTInputHandler(xmlFile,
new File(baseDir + "/"
- + xsl), null);
+ + xsl));
}
Driver driver = new Driver();