aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarved <arved@unknown>2000-12-18 04:07:47 +0000
committerarved <arved@unknown>2000-12-18 04:07:47 +0000
commit4a6ecf1f795b0a10437543f65155655d2790acb9 (patch)
tree9f9761614a5426b249e52be36a394eb096b6da9a
parentfcc4bef8d45118da37da4b1808bb9f3290340d5b (diff)
downloadxmlgraphics-fop-4a6ecf1f795b0a10437543f65155655d2790acb9.tar.gz
xmlgraphics-fop-4a6ecf1f795b0a10437543f65155655d2790acb9.zip
Support for rendering complex body regions
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193902 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/org/apache/fop/render/Renderer.java10
-rw-r--r--src/org/apache/fop/render/awt/AWTRenderer.java13
-rw-r--r--src/org/apache/fop/render/pdf/PDFRenderer.java33
-rw-r--r--src/org/apache/fop/render/xml/XMLRenderer.java40
4 files changed, 80 insertions, 16 deletions
diff --git a/src/org/apache/fop/render/Renderer.java b/src/org/apache/fop/render/Renderer.java
index b78ca0d7a..5c4d53007 100644
--- a/src/org/apache/fop/render/Renderer.java
+++ b/src/org/apache/fop/render/Renderer.java
@@ -57,7 +57,7 @@ import org.apache.fop.apps.FOPException;
import org.apache.fop.layout.*;
// Java
-import java.io.OutputStream;
+import java.io.PrintWriter;
import java.io.IOException;
/**
@@ -75,11 +75,17 @@ public interface Renderer {
public void setProducer(String producer);
/** render the given area tree to the given writer */
- public void render(AreaTree areaTree, OutputStream stream) throws IOException, FOPException;
+ public void render(AreaTree areaTree, PrintWriter writer) throws IOException, FOPException;
/** render the given area container */
public void renderAreaContainer(AreaContainer area);
+ /** render the given area container */
+ public void renderBodyAreaContainer(BodyAreaContainer area);
+
+ /** render the given span area */
+ public void renderSpanArea(SpanArea area);
+
/** render the given block area */
public void renderBlockArea(BlockArea area);
diff --git a/src/org/apache/fop/render/awt/AWTRenderer.java b/src/org/apache/fop/render/awt/AWTRenderer.java
index a6803c243..7f367b194 100644
--- a/src/org/apache/fop/render/awt/AWTRenderer.java
+++ b/src/org/apache/fop/render/awt/AWTRenderer.java
@@ -258,7 +258,7 @@ public class AWTRenderer implements Renderer, Printable, Pageable {
}
public void render(AreaTree areaTree,
- OutputStream stream) throws IOException {
+ PrintWriter writer) throws IOException {
tree = areaTree;
render(areaTree, 0);
}
@@ -286,7 +286,8 @@ public class AWTRenderer implements Renderer, Printable, Pageable {
}
public void renderPage(Page page) {
- AreaContainer body, before, after;
+ BodyAreaContainer body;
+ AreaContainer before, after;
body = page.getBody();
before = page.getBefore();
@@ -295,7 +296,7 @@ public class AWTRenderer implements Renderer, Printable, Pageable {
this.currentFontName = "";
this.currentFontSize = 0;
- renderAreaContainer(body);
+ renderBodyAreaContainer(body);
if (before != null) {
renderAreaContainer(before);
@@ -356,6 +357,12 @@ public class AWTRenderer implements Renderer, Printable, Pageable {
}
}
+ // empty for now
+ public void renderBodyAreaContainer(BodyAreaContainer area) {}
+
+ // empty for now
+ public void renderSpanArea(SpanArea area) {}
+
private void doFrame(org.apache.fop.layout.Area area) {
int w, h;
int rx = this.currentAreaContainerXPosition;
diff --git a/src/org/apache/fop/render/pdf/PDFRenderer.java b/src/org/apache/fop/render/pdf/PDFRenderer.java
index ebf79ba88..6a17e782f 100644
--- a/src/org/apache/fop/render/pdf/PDFRenderer.java
+++ b/src/org/apache/fop/render/pdf/PDFRenderer.java
@@ -78,7 +78,7 @@ import org.apache.fop.dom.svg.SVGArea;
// Java
import java.io.IOException;
-import java.io.OutputStream;
+import java.io.PrintWriter;
import java.util.Enumeration;
import java.awt.Rectangle;
import java.util.Vector;
@@ -160,10 +160,10 @@ public class PDFRenderer implements Renderer {
* render the areas into PDF
*
* @param areaTree the laid-out area tree
- * @param stream the OutputStream to write the PDF to
+ * @param writer the PrintWriter to write the PDF with
*/
public void render(AreaTree areaTree,
- OutputStream stream) throws IOException, FOPException {
+ PrintWriter writer) throws IOException, FOPException {
MessageHandler.logln("rendering areas to PDF");
idReferences = areaTree.getIDReferences();
this.pdfResources = this.pdfDoc.getResources();
@@ -181,7 +181,7 @@ public class PDFRenderer implements Renderer {
}
MessageHandler.logln("writing out PDF");
- this.pdfDoc.output(stream);
+ this.pdfDoc.output(writer);
}
/**
@@ -300,6 +300,26 @@ public class PDFRenderer implements Renderer {
this.currentYPosition -= area.getHeight();
}
+ public void renderBodyAreaContainer(BodyAreaContainer area) {
+ renderAreaContainer(area.getBeforeFloatReferenceArea());
+ renderAreaContainer(area.getFootnoteReferenceArea());
+
+ // main reference area
+ Enumeration e = area.getMainReferenceArea().getChildren().elements();
+ while (e.hasMoreElements()) {
+ Box b = (Box) e.nextElement();
+ b.render(this); // span areas
+ }
+ }
+
+ public void renderSpanArea(SpanArea area) {
+ Enumeration e = area.getChildren().elements();
+ while (e.hasMoreElements()) {
+ Box b = (Box) e.nextElement();
+ b.render(this); // column areas
+ }
+ }
+
private void doFrame(Area area) {
int w, h;
int rx = this.currentAreaContainerXPosition;
@@ -628,7 +648,8 @@ public class PDFRenderer implements Renderer {
* @param page page to render
*/
public void renderPage(Page page) {
- AreaContainer body, before, after;
+ BodyAreaContainer body;
+ AreaContainer before, after;
currentStream = this.pdfDoc.makeStream();
body = page.getBody();
@@ -640,7 +661,7 @@ public class PDFRenderer implements Renderer {
currentStream.add("BT\n");
- renderAreaContainer(body);
+ renderBodyAreaContainer(body);
if (before != null) {
renderAreaContainer(before);
diff --git a/src/org/apache/fop/render/xml/XMLRenderer.java b/src/org/apache/fop/render/xml/XMLRenderer.java
index 6330db0fc..9b17daad5 100644
--- a/src/org/apache/fop/render/xml/XMLRenderer.java
+++ b/src/org/apache/fop/render/xml/XMLRenderer.java
@@ -64,7 +64,6 @@ import org.apache.fop.fo.properties.LeaderPattern;
// Java
import java.io.IOException;
import java.io.PrintWriter;
-import java.io.OutputStream;
import java.util.Enumeration;
/**
@@ -96,10 +95,10 @@ public class XMLRenderer implements Renderer {
* @param areaTree the laid-out area tree
* @param writer the PrintWriter to give the XML to
*/
- public void render(AreaTree areaTree, OutputStream stream)
+ public void render(AreaTree areaTree, PrintWriter writer)
throws IOException {
MessageHandler.logln("rendering areas to XML");
- this.writer = new PrintWriter(stream);
+ this.writer = writer;
this.writer.write("<?xml version=\"1.0\"?>\n<!-- produced by "
+ this.producer + " -->\n");
writeStartTag("<AreaTree>");
@@ -192,6 +191,36 @@ public class XMLRenderer implements Renderer {
}
/**
+ * render a body area container to XML
+ *
+ * @param area the body area container to render
+ */
+ public void renderBodyAreaContainer(BodyAreaContainer area) {
+ writeStartTag("<BodyAreaContainer>");
+ Enumeration e = area.getChildren().elements();
+ while (e.hasMoreElements()) {
+ Box b = (Box) e.nextElement();
+ b.render(this);
+ }
+ writeEndTag("</BodyAreaContainer>");
+ }
+
+ /**
+ * render a span area to XML
+ *
+ * @param area the span area to render
+ */
+ public void renderSpanArea(SpanArea area) {
+ writeStartTag("<SpanArea>");
+ Enumeration e = area.getChildren().elements();
+ while (e.hasMoreElements()) {
+ Box b = (Box) e.nextElement();
+ b.render(this);
+ }
+ writeEndTag("</SpanArea>");
+ }
+
+ /**
* render a block area to XML
*
* @param area the block area to render
@@ -303,7 +332,8 @@ public class XMLRenderer implements Renderer {
* @param page the page to render
*/
public void renderPage(Page page) {
- AreaContainer body, before, after;
+ BodyAreaContainer body;
+ AreaContainer before, after;
writeStartTag("<Page>");
body = page.getBody();
before = page.getBefore();
@@ -311,7 +341,7 @@ public class XMLRenderer implements Renderer {
if (before != null) {
renderAreaContainer(before);
}
- renderAreaContainer(body);
+ renderBodyAreaContainer(body);
if (after != null) {
renderAreaContainer(after);
}