package org.apache.fop.render;
-import java.io.IOException;
import java.io.OutputStream;
-import java.util.Date;
+import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
// XML
import org.apache.fop.apps.Fop;
import org.apache.fop.configuration.FOUserAgent;
-import org.apache.avalon.framework.configuration.Configurable;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
-
/**
* Abstract base class for all renderers. The Abstract renderer does all the
* top level processing of the area tree and adds some abstract methods to
* handle viewports. This keeps track of the current block and inline position.
*/
public abstract class AbstractRenderer
- implements Renderer, Configurable {
+ implements Renderer {
- /**
- * user agent
- */
+ protected OutputStream output;
+ /** user agent */
protected FOUserAgent userAgent;
- /**
- * producer (usually "FOP")
- */
- protected String producer = "FOP";
-
- /**
- * creator of document
- */
- protected String creator = null;
-
- /**
- * creation time
- */
- protected Date creationDate = null;
-
- /**
- * renderer configuration
- */
- protected Map options;
-
- /**
- * block progression position
- */
- protected int currentBPPosition = 0;
-
- /**
- * inline progression position
- */
- protected int currentIPPosition = 0;
-
- /**
- * current inline progression position in block
- */
- protected int currentBlockIPPosition = 0;
+ /** renderer configuration */
+ protected Map options = new HashMap();
- /**
- * the block progression position of the containing block used for
- * absolutely positioned blocks
- */
- protected int containingBPPosition = 0;
-
- /**
- * the inline progression position of the containing block used for
- * absolutely positioned blocks
- */
- protected int containingIPPosition = 0;
+// /** block progression position */
+// protected int currentBPPosition = 0;
+//
+// /** inline progression position */
+// protected int currentIPPosition = 0;
+//
+// /** current inline progression position in block */
+// protected int currentBlockIPPosition = 0;
+//
+// /**
+// * the block progression position of the containing block used for
+// * absolutely positioned blocks
+// */
+// protected int containingBPPosition = 0;
+//
+// /**
+// * the inline progression position of the containing block used for
+// * absolutely positioned blocks
+// */
+// protected int containingIPPosition = 0;
protected Logger log = Logger.getLogger(Fop.fopPackage);
-
+
/**
- * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
+ * Implements Runnable.run() so that this thread can be started.
+ * Set up the fonts and perform other initialization.
+ * Respond to requests from layout thread for information
+ * Wait for requests from layout thread for layout.
*/
- public void configure(Configuration conf) throws ConfigurationException {
- }
-
- /** @see org.apache.fop.render.Renderer */
- public void setProducer(String inProducer) {
- producer = inProducer;
+ public void run() {
}
- /** @see org.apache.fop.render.Renderer */
- public void setCreator(String inCreator) {
- creator = inCreator;
+ public synchronized void setOutputStream(OutputStream output) {
+ this.output = output;
}
// /**
// */
// public abstract void setupFontInfo(FOTreeControl foTreeControl);
- /**
- * @see org.apache.fop.render.Renderer
- */
- public void setUserAgent(FOUserAgent agent) {
+ /** @see org.apache.fop.render.Renderer */
+ public synchronized void setUserAgent(FOUserAgent agent) {
userAgent = agent;
}
- /**
- * @param date
- */
- public void setCreationDate(Date date) {
- creationDate = date;
- }
-
- /** @see org.apache.fop.render.Renderer */
- public void setOptions(Map opt) {
- options = opt;
+ public synchronized void setOption(String key, Object value) {
+ options.put(key, value);
}
- /** @see org.apache.fop.render.Renderer */
- public void startRenderer(OutputStream outputStream)
- throws IOException { }
-
- /** @see org.apache.fop.render.Renderer */
- public void stopRenderer()
- throws IOException { }
-
/**
* Check if this renderer supports out of order rendering. If this renderer
* supports out of order rendering then it means that the pages that are
// Java
import java.io.OutputStream;
import java.io.IOException;
-import java.util.Date;
-import java.util.Map;
-
// FOP
import org.apache.fop.apps.FOPException;
import org.apache.fop.area.PageViewport;
* ({@link AbstractRenderer}, {@link PrintRenderer}) which already handle a lot
* of things letting you concentrate on the details of the output format.
*/
-public interface Renderer {
-
- /**
- * Role constant for Avalon.
- */
- String ROLE = Renderer.class.getName();
+public interface Renderer extends Runnable {
-
- /**
- * Initiates the rendering phase.
- * This must only be called once for a rendering. If
- * stopRenderer is called then this may be called again
- * for a new document rendering.
- *
- * @param outputStream The OutputStream to use for output
- * @exception IOException If an I/O error occurs
- */
- void startRenderer(OutputStream outputStream)
- throws IOException;
-
- /**
- * Signals the end of the rendering phase.
- * The renderer should reset to an initial state and dispose of
- * any resources for the completed rendering.
- *
- * @exception IOException If an I/O error occurs
- */
- void stopRenderer()
- throws IOException;
+ void setOutputStream(OutputStream outputStream);
/**
* Set the User Agent.
*/
void setUserAgent(FOUserAgent agent);
- /**
- * Set up renderer options.
- *
- * @param options The Configuration for the renderer
- */
- void setOptions(Map options);
-
- /**
- * Set the producer of the rendering. If this method isn't called the
- * renderer uses a default. Note: Not all renderers support this feature.
- *
- * @param producer The name of the producer (normally "FOP") to be
- * embedded in the generated file.
- */
- void setProducer(String producer);
-
- /**
- * Set the creator of the document to be rendered.
- * If this method isn't called the renderer uses a default.
- * Note: Not all renderers support this feature.
- *
- * @param creator The name of the document creator
- */
- void setCreator(String creator);
-
- /**
- * Set the creator date/timeof the document to be rendered.
- * If this method isn't called the renderer uses the current date/time
- * as default.
- * Note: Not all renderers support this feature.
- *
- * @param date The name of the document creator
- */
- void setCreationDate(Date date);
+ void setOption(String key, Object value);
/**
* Reports if out of order rendering is supported. <p>