You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2005/08/23 16:06:48 UTC
svn commit: r239409 - in /xmlgraphics/fop/trunk: ./
src/java/org/apache/fop/apps/ src/java/org/apache/fop/cli/
src/java/org/apache/fop/render/awt/
src/java/org/apache/fop/render/awt/viewer/ src/java/org/apache/fop/tools/
src/java/org/apache/fop/tools/a...
Author: jeremias
Date: Tue Aug 23 07:06:25 2005
New Revision: 239409
URL: http://svn.apache.org/viewcvs?rev=239409&view=rev
Log:
Moved CLI to its own package. New main class is org.apache.fop.cli.Main.
InputHandler is not passed through the FOUserAgent anymore. IMO it doesn't belong there. Instead I defined an interface "Renderable" in the AWT preview that InputHandler implements. This is used exclusively for reloading the document inside the preview dialog.
Added:
xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/
xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/CommandLineOptions.java
- copied, changed from r239253, xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/CommandLineOptions.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/InputHandler.java
- copied, changed from r239253, xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/InputHandler.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/Main.java (with props)
xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/package.html
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/awt/viewer/Renderable.java (with props)
Removed:
xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/CommandLineOptions.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/InputHandler.java
Modified:
xmlgraphics/fop/trunk/build.xml
xmlgraphics/fop/trunk/fop.bat
xmlgraphics/fop/trunk/fop.sh
xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FOUserAgent.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/Fop.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/package.html
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/awt/AWTRenderer.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/tools/TestConverter.java (contents, props changed)
xmlgraphics/fop/trunk/src/java/org/apache/fop/tools/anttasks/Fop.java (contents, props changed)
xmlgraphics/fop/trunk/test/java/org/apache/fop/BasicDriverTestCase.java
Modified: xmlgraphics/fop/trunk/build.xml
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/build.xml?rev=239409&r1=239408&r2=239409&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/build.xml (original)
+++ xmlgraphics/fop/trunk/build.xml Tue Aug 23 07:06:25 2005
@@ -428,7 +428,7 @@
<jar jarfile="${build.dir}/fop.jar" basedir="${build.classes.dir}" includes="org/**">
<manifest>
- <attribute name="Main-Class" value="org.apache.fop.apps.Fop"/>
+ <attribute name="Main-Class" value="org.apache.fop.cli.Main"/>
<!--attribute name="Class-Path" value="${manifest-classpath}"/-->
<attribute name="Implementation-Title" value="${Name}"/>
<attribute name="Implementation-Version" value="${version}"/>
Modified: xmlgraphics/fop/trunk/fop.bat
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/fop.bat?rev=239409&r1=239408&r2=239409&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/fop.bat (original)
+++ xmlgraphics/fop/trunk/fop.bat Tue Aug 23 07:06:25 2005
@@ -54,5 +54,5 @@
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\fop-hyph.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%FOP_HYPHENATION_PATH%
-java %LOGCHOICE% %LOGLEVEL% -cp "%LOCALCLASSPATH%" org.apache.fop.apps.Fop %FOP_CMD_LINE_ARGS%
+java %LOGCHOICE% %LOGLEVEL% -cp "%LOCALCLASSPATH%" org.apache.fop.cli.Main %FOP_CMD_LINE_ARGS%
Modified: xmlgraphics/fop/trunk/fop.sh
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/fop.sh?rev=239409&r1=239408&r2=239409&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/fop.sh (original)
+++ xmlgraphics/fop/trunk/fop.sh Tue Aug 23 07:06:25 2005
@@ -122,5 +122,5 @@
# Possible SimpleLog values: "trace", "debug", "info" (default), "warn", "error", or "fatal".
# LOGLEVEL=-Dorg.apache.commons.logging.simplelog.defaultlog=INFO
-$JAVACMD $LOGCHOICE $LOGLEVEL -classpath "$LOCALCLASSPATH" $FOP_OPTS org.apache.fop.apps.Fop "$@"
+$JAVACMD $LOGCHOICE $LOGLEVEL -classpath "$LOCALCLASSPATH" $FOP_OPTS org.apache.fop.cli.Main "$@"
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FOUserAgent.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FOUserAgent.java?rev=239409&r1=239408&r2=239409&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FOUserAgent.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FOUserAgent.java Tue Aug 23 07:06:25 2005
@@ -81,7 +81,6 @@
private PDFEncryptionParams pdfEncryptionParams;
private float px2mm = DEFAULT_PX2MM;
private Map rendererOptions = new java.util.HashMap();
- private InputHandler inputHandler = null;
private File outputFile = null;
private Renderer rendererOverride = null;
private FOEventHandler foEventHandlerOverride = null;
@@ -122,23 +121,6 @@
/** Set of keywords applicable to this document. */
protected String keywords = null;
- /**
- * Sets the InputHandler object for this process
- * @param inputHandler holding input file name information
- */
- public void setInputHandler(InputHandler inputHandler) {
- this.inputHandler = inputHandler;
- }
-
- /**
- * Returns the apps.InputHandler object created during command-line
- * processing
- * @return InputHandler object
- */
- public InputHandler getInputHandler() {
- return inputHandler;
- }
-
/**
* Add the element mapping with the given class name.
* @param elementMapping the class name representing the element mapping.
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/Fop.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/Fop.java?rev=239409&r1=239408&r2=239409&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/Fop.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/Fop.java Tue Aug 23 07:06:25 2005
@@ -19,15 +19,7 @@
package org.apache.fop.apps;
// Java
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileOutputStream;
import java.io.OutputStream;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.List;
// XML
import org.xml.sax.helpers.DefaultHandler;
@@ -37,8 +29,7 @@
import org.apache.fop.fo.FOTreeBuilder;
/**
- * Primary class that activates the FOP process for both command line
- * and embedded usage.
+ * Primary class that activates the FOP process for embedded usage.
* <P>
* JAXP is the standard method of embedding FOP in Java programs.
* Please check our embedding page (http://xml.apache.org/fop/embedding.html)
@@ -159,161 +150,6 @@
return foTreeBuilder.getResults();
}
}
-
- /**
- * @return the list of URLs to all libraries.
- * @throws MalformedURLException In case there is a problem converting java.io.File
- * instances to URLs.
- */
- public static URL[] getJARList() throws MalformedURLException {
- File baseDir = new File(".").getAbsoluteFile().getParentFile();
- File buildDir;
- if ("build".equals(baseDir.getName())) {
- buildDir = baseDir;
- baseDir = baseDir.getParentFile();
- } else {
- buildDir = new File(baseDir, "build");
- }
- File fopJar = new File(buildDir, "fop.jar");
- if (!fopJar.exists()) {
- fopJar = new File(baseDir, "fop.jar");
- }
- if (!fopJar.exists()) {
- throw new RuntimeException("fop.jar not found in directory: "
- + baseDir.getAbsolutePath() + " (or below)");
- }
- List jars = new java.util.ArrayList();
- jars.add(fopJar.toURL());
- File[] files;
- FileFilter filter = new FileFilter() {
- public boolean accept(File pathname) {
- return pathname.getName().endsWith(".jar");
- }
- };
- File libDir = new File(baseDir, "lib");
- if (!libDir.exists()) {
- libDir = baseDir;
- }
- files = libDir.listFiles(filter);
- if (files != null) {
- for (int i = 0, size = files.length; i < size; i++) {
- jars.add(files[i].toURL());
- }
- }
- String optionalLib = System.getProperty("fop.optional.lib");
- if (optionalLib != null) {
- files = new File(optionalLib).listFiles(filter);
- if (files != null) {
- for (int i = 0, size = files.length; i < size; i++) {
- jars.add(files[i].toURL());
- }
- }
- }
- URL[] urls = (URL[])jars.toArray(new URL[jars.size()]);
- /*
- for (int i = 0, c = urls.length; i < c; i++) {
- System.out.println(urls[i]);
- }*/
- return urls;
- }
-
- /**
- * @return true if FOP's dependecies are available in the current ClassLoader setup.
- */
- public static boolean checkDependencies() {
- try {
- //System.out.println(Thread.currentThread().getContextClassLoader());
- Class clazz = Class.forName("org.apache.batik.Version");
- if (clazz != null) {
- clazz = Class.forName("org.apache.avalon.framework.configuration.Configuration");
- }
- return (clazz != null);
- } catch (Exception e) {
- return false;
- }
- }
-
- /**
- * Dynamically builds a ClassLoader and executes FOP.
- * @param args command-line arguments
- */
- public static void startFOPWithDynamicClasspath(String[] args) {
- try {
- URL[] urls = getJARList();
- //System.out.println("CCL: "
- // + Thread.currentThread().getContextClassLoader().toString());
- ClassLoader loader = new java.net.URLClassLoader(urls, null);
- Thread.currentThread().setContextClassLoader(loader);
- Class clazz = Class.forName("org.apache.fop.apps.Fop", true, loader);
- //System.out.println("CL: " + clazz.getClassLoader().toString());
- Method mainMethod = clazz.getMethod("startFOP", new Class[] {String[].class});
- mainMethod.invoke(null, new Object[] {args});
- } catch (Exception e) {
- System.err.println("Unable to start FOP:");
- e.printStackTrace();
- System.exit(-1);
- }
- }
-
- /**
- * Executes FOP with the given ClassLoader setup.
- * @param args command-line arguments
- */
- public static void startFOP(String[] args) {
- //System.out.println("static CCL: "
- // + Thread.currentThread().getContextClassLoader().toString());
- //System.out.println("static CL: " + Fop.class.getClassLoader().toString());
- CommandLineOptions options = null;
- FOUserAgent foUserAgent = null;
- BufferedOutputStream bos = null;
-
- try {
- options = new CommandLineOptions();
- options.parse(args);
- foUserAgent = options.getFOUserAgent();
-
- Fop fop = new Fop(options.getRenderer(), foUserAgent);
-
- try {
- if (options.getOutputFile() != null) {
- bos = new BufferedOutputStream(new FileOutputStream(
- options.getOutputFile()));
- fop.setOutputStream(bos);
- foUserAgent.setOutputFile(options.getOutputFile());
- }
- foUserAgent.getInputHandler().render(fop);
- } finally {
- if (bos != null) {
- bos.close();
- }
- }
-
- // System.exit(0) called to close AWT/SVG-created threads, if any.
- // AWTRenderer closes with window shutdown, so exit() should not
- // be called here
- if (options.getOutputMode() != CommandLineOptions.RENDER_AWT) {
- System.exit(0);
- }
- } catch (Exception e) {
- if (options != null) {
- options.getLogger().error("Exception", e);
- }
- System.exit(1);
- }
- }
-
- /**
- * The main routine for the command line interface
- * @param args the command line parameters
- */
- public static void main(String[] args) {
- if (checkDependencies()) {
- startFOP(args);
- } else {
- startFOPWithDynamicClasspath(args);
- }
- }
-
/**
* Get the version of FOP
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/package.html
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/package.html?rev=239409&r1=239408&r2=239409&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/package.html (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/package.html Tue Aug 23 07:06:25 2005
@@ -1,7 +1,6 @@
<HTML>
<TITLE>org.apache.fop.apps Package</TITLE>
<BODY>
-<P>Application classes used for running FOP both on the command line and
-embedded in other applications.</P>
+<P>Application classes used for running FOP embedded in other applications.</P>
</BODY>
</HTML>
Copied: xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/CommandLineOptions.java (from r239253, xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/CommandLineOptions.java)
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/CommandLineOptions.java?p2=xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/CommandLineOptions.java&p1=xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/CommandLineOptions.java&r1=239253&r2=239409&rev=239409&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/CommandLineOptions.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/CommandLineOptions.java Tue Aug 23 07:06:25 2005
@@ -16,7 +16,7 @@
/* $Id$ */
-package org.apache.fop.apps;
+package org.apache.fop.cli;
// java
import java.io.File;
@@ -25,7 +25,11 @@
import java.util.Locale;
import java.util.Vector;
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.Fop;
import org.apache.fop.fo.Constants;
+import org.apache.fop.render.awt.AWTRenderer;
import org.apache.fop.util.CommandLineLogger;
// commons logging
@@ -68,6 +72,8 @@
private FOUserAgent foUserAgent;
+ private InputHandler inputHandler;
+
private Log log;
private Vector xsltParams = null;
@@ -119,9 +125,23 @@
throw e;
}
- foUserAgent.setInputHandler(createInputHandler());
+ inputHandler = createInputHandler();
+
+ if (outputmode == RENDER_AWT) {
+ AWTRenderer renderer = new AWTRenderer();
+ renderer.setRenderable(inputHandler); //set before user agent!
+ renderer.setUserAgent(foUserAgent);
+ foUserAgent.setRendererOverride(renderer);
+ }
}
+ /**
+ * @return the InputHandler instance defined by the command-line options.
+ */
+ public InputHandler getInputHandler() {
+ return inputHandler;
+ }
+
/**
* Get the logger.
* @return the logger
Copied: xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/InputHandler.java (from r239253, xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/InputHandler.java)
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/InputHandler.java?p2=xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/InputHandler.java&p1=xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/InputHandler.java&r1=239253&r2=239409&rev=239409&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/InputHandler.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/InputHandler.java Tue Aug 23 07:06:25 2005
@@ -16,7 +16,7 @@
/* $Id$ */
-package org.apache.fop.apps;
+package org.apache.fop.cli;
// Imported java.io classes
import java.io.File;
@@ -34,13 +34,17 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.Fop;
+import org.apache.fop.render.awt.viewer.Renderable;
/**
* Class for handling files input from command line
* either with XML and XSLT files (and optionally xsl
* parameters) or FO File input alone
*/
-public class InputHandler implements ErrorListener {
+public class InputHandler implements ErrorListener, Renderable {
+
private File sourcefile = null; // either FO or XML/XSLT usage
private File stylesheet = null; // for XML/XSLT usage
private Vector xsltParams = null; // for XML/XSLT usage
@@ -80,8 +84,7 @@
String baseURL = null;
try {
- baseURL =
- new File(sourcefile.getAbsolutePath()).
+ baseURL = new File(sourcefile.getAbsolutePath()).
getParentFile().toURL().toExternalForm();
} catch (Exception e) {
baseURL = "";
@@ -124,22 +127,24 @@
}
}
+ // --- Implementation of the ErrorListener interface ---
+
/**
- * Implementation of the ErrorListener interface.
+ * @see javax.xml.transform.ErrorListener#warning(javax.xml.transform.TransformerException)
*/
public void warning(TransformerException exc) {
log.warn(exc.toString());
}
/**
- * Implementation of the ErrorListener interface.
+ * @see javax.xml.transform.ErrorListener#error(javax.xml.transform.TransformerException)
*/
public void error(TransformerException exc) {
log.error(exc.toString());
}
/**
- * Implementation of the ErrorListener interface.
+ * @see javax.xml.transform.ErrorListener#fatalError(javax.xml.transform.TransformerException)
*/
public void fatalError(TransformerException exc)
throws TransformerException {
Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/Main.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/Main.java?rev=239409&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/Main.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/Main.java Tue Aug 23 07:06:25 2005
@@ -0,0 +1,192 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.cli;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileOutputStream;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.Fop;
+
+/**
+ * Main command-line class for Apache FOP.
+ */
+public class Main {
+
+ /**
+ * @return the list of URLs to all libraries.
+ * @throws MalformedURLException In case there is a problem converting java.io.File
+ * instances to URLs.
+ */
+ public static URL[] getJARList() throws MalformedURLException {
+ File baseDir = new File(".").getAbsoluteFile().getParentFile();
+ File buildDir;
+ if ("build".equals(baseDir.getName())) {
+ buildDir = baseDir;
+ baseDir = baseDir.getParentFile();
+ } else {
+ buildDir = new File(baseDir, "build");
+ }
+ File fopJar = new File(buildDir, "fop.jar");
+ if (!fopJar.exists()) {
+ fopJar = new File(baseDir, "fop.jar");
+ }
+ if (!fopJar.exists()) {
+ throw new RuntimeException("fop.jar not found in directory: "
+ + baseDir.getAbsolutePath() + " (or below)");
+ }
+ List jars = new java.util.ArrayList();
+ jars.add(fopJar.toURL());
+ File[] files;
+ FileFilter filter = new FileFilter() {
+ public boolean accept(File pathname) {
+ return pathname.getName().endsWith(".jar");
+ }
+ };
+ File libDir = new File(baseDir, "lib");
+ if (!libDir.exists()) {
+ libDir = baseDir;
+ }
+ files = libDir.listFiles(filter);
+ if (files != null) {
+ for (int i = 0, size = files.length; i < size; i++) {
+ jars.add(files[i].toURL());
+ }
+ }
+ String optionalLib = System.getProperty("fop.optional.lib");
+ if (optionalLib != null) {
+ files = new File(optionalLib).listFiles(filter);
+ if (files != null) {
+ for (int i = 0, size = files.length; i < size; i++) {
+ jars.add(files[i].toURL());
+ }
+ }
+ }
+ URL[] urls = (URL[])jars.toArray(new URL[jars.size()]);
+ /*
+ for (int i = 0, c = urls.length; i < c; i++) {
+ System.out.println(urls[i]);
+ }*/
+ return urls;
+ }
+
+ /**
+ * @return true if FOP's dependecies are available in the current ClassLoader setup.
+ */
+ public static boolean checkDependencies() {
+ try {
+ //System.out.println(Thread.currentThread().getContextClassLoader());
+ Class clazz = Class.forName("org.apache.batik.Version");
+ if (clazz != null) {
+ clazz = Class.forName("org.apache.avalon.framework.configuration.Configuration");
+ }
+ return (clazz != null);
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ /**
+ * Dynamically builds a ClassLoader and executes FOP.
+ * @param args command-line arguments
+ */
+ public static void startFOPWithDynamicClasspath(String[] args) {
+ try {
+ URL[] urls = getJARList();
+ //System.out.println("CCL: "
+ // + Thread.currentThread().getContextClassLoader().toString());
+ ClassLoader loader = new java.net.URLClassLoader(urls, null);
+ Thread.currentThread().setContextClassLoader(loader);
+ Class clazz = Class.forName("org.apache.fop.cli.Main", true, loader);
+ //System.out.println("CL: " + clazz.getClassLoader().toString());
+ Method mainMethod = clazz.getMethod("startFOP", new Class[] {String[].class});
+ mainMethod.invoke(null, new Object[] {args});
+ } catch (Exception e) {
+ System.err.println("Unable to start FOP:");
+ e.printStackTrace();
+ System.exit(-1);
+ }
+ }
+
+ /**
+ * Executes FOP with the given ClassLoader setup.
+ * @param args command-line arguments
+ */
+ public static void startFOP(String[] args) {
+ //System.out.println("static CCL: "
+ // + Thread.currentThread().getContextClassLoader().toString());
+ //System.out.println("static CL: " + Fop.class.getClassLoader().toString());
+ CommandLineOptions options = null;
+ FOUserAgent foUserAgent = null;
+ BufferedOutputStream bos = null;
+
+ try {
+ options = new CommandLineOptions();
+ options.parse(args);
+ foUserAgent = options.getFOUserAgent();
+
+ Fop fop = new Fop(options.getRenderer(), foUserAgent);
+
+ try {
+ if (options.getOutputFile() != null) {
+ bos = new BufferedOutputStream(new FileOutputStream(
+ options.getOutputFile()));
+ fop.setOutputStream(bos);
+ foUserAgent.setOutputFile(options.getOutputFile());
+ }
+ options.getInputHandler().render(fop);
+ } finally {
+ if (bos != null) {
+ bos.close();
+ }
+ }
+
+ // System.exit(0) called to close AWT/SVG-created threads, if any.
+ // AWTRenderer closes with window shutdown, so exit() should not
+ // be called here
+ if (options.getOutputMode() != CommandLineOptions.RENDER_AWT) {
+ System.exit(0);
+ }
+ } catch (Exception e) {
+ if (options != null) {
+ options.getLogger().error("Exception", e);
+ }
+ System.exit(1);
+ }
+ }
+
+ /**
+ * The main routine for the command line interface
+ * @param args the command line parameters
+ */
+ public static void main(String[] args) {
+ if (checkDependencies()) {
+ startFOP(args);
+ } else {
+ startFOPWithDynamicClasspath(args);
+ }
+ }
+
+}
Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/Main.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/Main.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/package.html
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/package.html?rev=239409&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/package.html (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/package.html Tue Aug 23 07:06:25 2005
@@ -0,0 +1,6 @@
+<HTML>
+<TITLE>org.apache.fop.cli Package</TITLE>
+<BODY>
+<P>This package contains the command-line client for Apache FOP.</P>
+</BODY>
+</HTML>
\ No newline at end of file
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/awt/AWTRenderer.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/awt/AWTRenderer.java?rev=239409&r1=239408&r2=239409&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/awt/AWTRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/awt/AWTRenderer.java Tue Aug 23 07:06:25 2005
@@ -44,6 +44,7 @@
import org.apache.fop.datatypes.ColorType;
import org.apache.fop.fo.properties.ColorTypeProperty;
import org.apache.fop.render.awt.viewer.PreviewDialog;
+import org.apache.fop.render.awt.viewer.Renderable;
import org.apache.fop.render.awt.viewer.Translator;
import org.apache.fop.render.java2d.Java2DRenderer;
@@ -73,6 +74,12 @@
protected PreviewDialog frame;
/**
+ * Renderable instance that can be used to reload and re-render a document after
+ * modifications.
+ */
+ protected Renderable renderable;
+
+ /**
* Creates a new AWTRenderer instance.
*/
public AWTRenderer() {
@@ -88,6 +95,15 @@
}
/**
+ * 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
@@ -135,7 +151,7 @@
/** Creates and initialize the AWT Viewer main window */
private PreviewDialog createPreviewDialog() {
- frame = new PreviewDialog(userAgent);
+ frame = new PreviewDialog(userAgent, this.renderable);
frame.addWindowListener(new WindowAdapter() {
public void windowClosed(WindowEvent we) {
System.exit(0);
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java?rev=239409&r1=239408&r2=239409&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java Tue Aug 23 07:06:25 2005
@@ -68,6 +68,11 @@
protected AWTRenderer renderer;
/** The FOUserAgent associated with this window */
protected FOUserAgent foUserAgent;
+ /**
+ * Renderable instance that can be used to reload and re-render a document after
+ * modifications.
+ */
+ protected Renderable renderable;
/** The JCombobox to rescale the rendered page view */
private JComboBox scale;
@@ -87,10 +92,13 @@
/**
* Creates a new PreviewDialog that uses the given renderer.
* @param foUserAgent the user agent
+ * @param renderable the Renderable instance that is used to reload/re-render a document
+ * after modifications.
*/
- public PreviewDialog(FOUserAgent foUserAgent) {
+ public PreviewDialog(FOUserAgent foUserAgent, Renderable renderable) {
renderer = (AWTRenderer) foUserAgent.getRendererOverride();
this.foUserAgent = foUserAgent;
+ this.renderable = renderable;
translator = renderer.getTranslator();
//Commands aka Actions
@@ -156,7 +164,7 @@
setSize(screen.width * 61 / 100, screen.height * 9 / 10);
//Page view stuff
- previewPanel = new PreviewPanel(foUserAgent, renderer);
+ previewPanel = new PreviewPanel(foUserAgent, renderable, renderer);
getContentPane().add(previewPanel, BorderLayout.CENTER);
//Scaling combobox
@@ -232,6 +240,14 @@
}
/**
+ * Creates a new PreviewDialog that uses the given renderer.
+ * @param foUserAgent the user agent
+ */
+ public PreviewDialog(FOUserAgent foUserAgent) {
+ this(foUserAgent, null);
+ }
+
+ /**
* Creates a new menubar to be shown in this window.
* @return the newly created menubar
*/
@@ -246,7 +262,7 @@
}
});
// inputHandler must be set to allow reloading
- if (foUserAgent.getInputHandler() != null) {
+ if (renderable != null) {
menu.add(new Command(translator.getString("Menu.Reload"), KeyEvent.VK_R) {
public void doit() {
reload();
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java?rev=239409&r1=239408&r2=239409&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java Tue Aug 23 07:06:25 2005
@@ -13,6 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+/* $Id$ */
+
package org.apache.fop.render.awt.viewer;
import java.awt.Color;
@@ -100,6 +103,11 @@
/** The FOUserAgent associated with this panel - often shared with PreviewDialog */
protected FOUserAgent foUserAgent;
+ /**
+ * Renderable instance that can be used to reload and re-render a document after
+ * modifications.
+ */
+ protected Renderable renderable;
/** The number of the page which is currently selected */
private int currentPage = 0;
@@ -136,10 +144,13 @@
/**
* Creates a new PreviewPanel instance.
* @param foUserAgent the user agent
+ * @param renderable the Renderable instance that is used to reload/re-render a document
+ * after modifications.
* @param renderer the AWT Renderer instance to paint with
*/
- public PreviewPanel(FOUserAgent foUserAgent, AWTRenderer renderer) {
+ public PreviewPanel(FOUserAgent foUserAgent, Renderable renderable, AWTRenderer renderer) {
super(new GridLayout(1, 1));
+ this.renderable = renderable;
this.renderer = renderer;
this.foUserAgent = foUserAgent;
@@ -284,7 +295,7 @@
// do not allow the reloading while FOP is still rendering
JOptionPane.showMessageDialog(previewArea,
"Cannot perform the requested operation until "
- + "all page are rendererd. Please wait",
+ + "all page are rendered. Please wait",
"Please wait ", 1 /* INFORMATION_MESSAGE */);
return;
}
@@ -325,9 +336,9 @@
}
try {
- if (foUserAgent.getInputHandler() != null) {
+ if (renderable != null) {
renderer.clearViewportList();
- foUserAgent.getInputHandler().render(fop);
+ renderable.render(fop);
}
} catch (FOPException e) {
e.printStackTrace();
Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/awt/viewer/Renderable.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/awt/viewer/Renderable.java?rev=239409&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/awt/viewer/Renderable.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/awt/viewer/Renderable.java Tue Aug 23 07:06:25 2005
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.awt.viewer;
+
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.Fop;
+
+/**
+ * The interface is used by the AWT preview dialog to reload a document.
+ */
+public interface Renderable {
+
+ /**
+ * Renders the pre-setup document.
+ * @param fop the Fop instance to do the FO processing with
+ * @exception FOPException if the FO processing fails
+ */
+ void render(Fop fop) throws FOPException;
+
+}
Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/awt/viewer/Renderable.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/awt/viewer/Renderable.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/tools/TestConverter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/tools/TestConverter.java?rev=239409&r1=239408&r2=239409&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/tools/TestConverter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/tools/TestConverter.java Tue Aug 23 07:06:25 2005
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.apps.InputHandler;
+import org.apache.fop.cli.InputHandler;
import org.apache.fop.tools.anttasks.FileCompare;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/tools/TestConverter.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/tools/anttasks/Fop.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/tools/anttasks/Fop.java?rev=239409&r1=239408&r2=239409&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/tools/anttasks/Fop.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/tools/anttasks/Fop.java Tue Aug 23 07:06:25 2005
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,10 +34,10 @@
import java.util.List;
// FOP
-import org.apache.fop.apps.InputHandler;
import org.apache.fop.fo.Constants;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.cli.InputHandler;
import org.apache.commons.logging.impl.SimpleLog;
import org.apache.commons.logging.Log;
Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/tools/anttasks/Fop.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/BasicDriverTestCase.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/test/java/org/apache/fop/BasicDriverTestCase.java?rev=239409&r1=239408&r2=239409&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/BasicDriverTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/BasicDriverTestCase.java Tue Aug 23 07:06:25 2005
@@ -29,7 +29,7 @@
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.fop.apps.Fop;
-import org.apache.fop.apps.InputHandler;
+import org.apache.fop.cli.InputHandler;
/**
* Basic runtime test for the old Fop class. It is used to verify that
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org