diff options
author | Jeremias Maerki <jeremias@apache.org> | 2005-11-11 13:44:40 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2005-11-11 13:44:40 +0000 |
commit | 82b916bf0d5dff2475e7b591e6ada7d45fa1b2b9 (patch) | |
tree | 299bd11ae1cb5d1f812fdf912ffc775bfafdb600 /src/java/org/apache/fop/render/txt | |
parent | 97581a9081ec184b9755bdc07ce049df9419ca06 (diff) | |
download | xmlgraphics-fop-82b916bf0d5dff2475e7b591e6ada7d45fa1b2b9.tar.gz xmlgraphics-fop-82b916bf0d5dff2475e7b591e6ada7d45fa1b2b9.zip |
Fop.java gets two new constructors: Fop(String) and Fop(String, FOUserAgent) where the String is the MIME type for the desired output format.
MimeConstants provides a comprehensive list of MIME types used in Fop.java.
Non-standard, FOP-specific MIME types changed to a uniform pattern: application/X-fop-awt-preview, application/X-fop-print and application/X-fop-areatree.
RendererFactory now supports manual registration and dynamic discovery of Renderers and FOEventHandlers by their MIME types. Instantitation is done using MIME types everywhere.
The RENDER_* constants are mapped to MIME types in Fop.java.
RendererFactory is now an instantiable class whose reference is held by FOUserAgent just like it is done for the XLMHandlers.
Renderers and FOEventHandlers now each have a *Maker class which is a kind of factory class which is used to register a Renderer/FOEventHandler and additionally serves to provide additional information about the thing, such as the MIME types it supports and if the implementation requires an OutputStream.
The command-line gets a new option: -out application/pdf myfile.pdf is the generic way to create an output file. If someone created a WordML output handler and provided the right service resource file he could specify "-out text/xml+msword out.xml". ".out list" lists all MIME types that are available for output.
Renderers can now potionally expose a Graphics2DAdapter which in concert with Graphics2DImagePainter can be used by FOP extensions to paint their content directly using a Graphics2D instance. That makes it possible to avoid a detour via SVG/Batik in certain cases.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@332549 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/render/txt')
3 files changed, 103 insertions, 1 deletions
diff --git a/src/java/org/apache/fop/render/txt/TXTFOEventHandlerMaker.java b/src/java/org/apache/fop/render/txt/TXTFOEventHandlerMaker.java new file mode 100644 index 000000000..ddc981a40 --- /dev/null +++ b/src/java/org/apache/fop/render/txt/TXTFOEventHandlerMaker.java @@ -0,0 +1,52 @@ +/*
+ * 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.txt;
+
+import java.io.OutputStream;
+
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.MimeConstants;
+import org.apache.fop.fo.FOEventHandler;
+import org.apache.fop.render.AbstractFOEventHandlerMaker;
+
+/**
+ * Maker class for the special FOEventHandler for TXT support.
+ */
+public class TXTFOEventHandlerMaker extends AbstractFOEventHandlerMaker {
+
+ private static final String[] MIMES = new String[] {
+ MimeConstants.MIME_PLAIN_TEXT};
+
+ /** @see org.apache.fop.render.AbstractFOEventHandlerMaker */
+ public FOEventHandler makeFOEventHandler(FOUserAgent ua, OutputStream out) throws FOPException {
+ return new TXTHandler(ua, out);
+ }
+
+ /** @see org.apache.fop.render.AbstractFOEventHandlerMaker#needsOutputStream() */
+ public boolean needsOutputStream() {
+ return true;
+ }
+
+ /** @see org.apache.fop.render.AbstractFOEventHandlerMaker#getSupportedMimeTypes() */
+ public String[] getSupportedMimeTypes() {
+ return MIMES;
+ }
+
+}
diff --git a/src/java/org/apache/fop/render/txt/TXTHandler.java b/src/java/org/apache/fop/render/txt/TXTHandler.java index d75e65f50..87e6defee 100644 --- a/src/java/org/apache/fop/render/txt/TXTHandler.java +++ b/src/java/org/apache/fop/render/txt/TXTHandler.java @@ -25,6 +25,7 @@ import java.util.List; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.apps.MimeConstants; import org.apache.fop.area.AreaTreeHandler; import org.apache.fop.datatypes.CompoundDatatype; import org.apache.fop.datatypes.Length; @@ -94,7 +95,7 @@ public class TXTHandler extends AreaTreeHandler { */ public TXTHandler(FOUserAgent userAgent, OutputStream stream) throws FOPException { - super(userAgent, Constants.RENDER_TXT, stream); + super(userAgent, MimeConstants.MIME_PLAIN_TEXT, stream); } /** diff --git a/src/java/org/apache/fop/render/txt/TXTRendererMaker.java b/src/java/org/apache/fop/render/txt/TXTRendererMaker.java new file mode 100644 index 000000000..026c7996c --- /dev/null +++ b/src/java/org/apache/fop/render/txt/TXTRendererMaker.java @@ -0,0 +1,49 @@ +/*
+ * 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.txt;
+
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.MimeConstants;
+import org.apache.fop.render.AbstractRendererMaker;
+import org.apache.fop.render.Renderer;
+
+/**
+ * RendererMaker for the Plain Text Renderer.
+ */
+public class TXTRendererMaker extends AbstractRendererMaker {
+
+ private static final String[] MIMES = new String[] {MimeConstants.MIME_PLAIN_TEXT};
+
+
+ /**@see org.apache.fop.render.AbstractRendererMaker */
+ public Renderer makeRenderer(FOUserAgent ua) {
+ return new TXTRenderer();
+ }
+
+ /** @see org.apache.fop.render.AbstractRendererMaker#needsOutputStream() */
+ public boolean needsOutputStream() {
+ return true;
+ }
+
+ /** @see org.apache.fop.render.AbstractRendererMaker#getSupportedMimeTypes() */
+ public String[] getSupportedMimeTypes() {
+ return MIMES;
+ }
+
+}
|