aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache
diff options
context:
space:
mode:
authorKeiron Liddle <keiron@apache.org>2001-09-17 11:04:50 +0000
committerKeiron Liddle <keiron@apache.org>2001-09-17 11:04:50 +0000
commitf3c3996b7b0e01ac0420b4dec2aeef74e1c56236 (patch)
tree9dc6ea2c2bdb6cd2d8020ea51cc6afb252d2dda9 /src/org/apache
parent10c4757319cb7d6d798d9ec6ed13e6d5136d329f (diff)
downloadxmlgraphics-fop-f3c3996b7b0e01ac0420b4dec2aeef74e1c56236.tar.gz
xmlgraphics-fop-f3c3996b7b0e01ac0420b4dec2aeef74e1c56236.zip
put a few common methods in the abstract renderer
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194465 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache')
-rw-r--r--src/org/apache/fop/render/AbstractRenderer.java82
-rw-r--r--src/org/apache/fop/render/PrintRenderer.java77
-rw-r--r--src/org/apache/fop/render/awt/AWTRenderer.java83
-rw-r--r--src/org/apache/fop/render/pdf/PDFRenderer.java1
4 files changed, 96 insertions, 147 deletions
diff --git a/src/org/apache/fop/render/AbstractRenderer.java b/src/org/apache/fop/render/AbstractRenderer.java
index b7222229b..677018200 100644
--- a/src/org/apache/fop/render/AbstractRenderer.java
+++ b/src/org/apache/fop/render/AbstractRenderer.java
@@ -2,7 +2,7 @@
* $Id$
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
- * LICENSE file included with these sources."
+ * LICENSE file included with these sources.
*/
package org.apache.fop.render;
@@ -18,8 +18,6 @@ import org.apache.fop.layout.inline.*;
import org.apache.fop.datatypes.*;
import org.apache.fop.render.pdf.FontSetup;
-import org.apache.fop.svg.SVGArea;
-
import org.apache.log.Logger;
// Java
@@ -34,8 +32,86 @@ import java.util.Enumeration;
public abstract class AbstractRenderer implements Renderer {
protected Logger log;
+ /**
+ * the current vertical position in millipoints from bottom
+ */
+ protected int currentYPosition = 0;
+
+ /**
+ * the current horizontal position in millipoints from left
+ */
+ protected int currentXPosition = 0;
+
+ /**
+ * the horizontal position of the current area container
+ */
+ protected int currentAreaContainerXPosition = 0;
+
public void setLogger(Logger logger) {
log = logger;
}
+ public void renderSpanArea(SpanArea area) {
+ Enumeration e = area.getChildren().elements();
+ while (e.hasMoreElements()) {
+ org.apache.fop.layout.Box b =
+ (org.apache.fop.layout.Box)e.nextElement();
+ b.render(this); // column areas
+ }
+
+ }
+
+ protected abstract void doFrame(Area area);
+
+ /**
+ * render block area
+ *
+ * @param area the block area to render
+ */
+ public void renderBlockArea(BlockArea area) {
+ // KLease: Temporary test to fix block positioning
+ // Offset ypos by padding and border widths
+ this.currentYPosition -= (area.getPaddingTop()
+ + area.getBorderTopWidth());
+ doFrame(area);
+ Enumeration e = area.getChildren().elements();
+ while (e.hasMoreElements()) {
+ Box b = (Box)e.nextElement();
+ b.render(this);
+ }
+ this.currentYPosition -= (area.getPaddingBottom()
+ + area.getBorderBottomWidth());
+ }
+
+ /**
+ * render line area
+ *
+ * @param area area to render
+ */
+ public void renderLineArea(LineArea area) {
+ int rx = this.currentAreaContainerXPosition + area.getStartIndent();
+ int ry = this.currentYPosition;
+ int w = area.getContentWidth();
+ int h = area.getHeight();
+
+ this.currentYPosition -= area.getPlacementOffset();
+ this.currentXPosition = rx;
+
+ int bl = this.currentYPosition;
+
+ Enumeration e = area.getChildren().elements();
+ while (e.hasMoreElements()) {
+ Box b = (Box)e.nextElement();
+ if (b instanceof InlineArea) {
+ InlineArea ia = (InlineArea)b;
+ this.currentYPosition = ry - ia.getYOffset();
+ } else {
+ this.currentYPosition = ry - area.getPlacementOffset();
+ }
+ b.render(this);
+ }
+
+ this.currentYPosition = ry - h;
+ this.currentXPosition = rx;
+ }
}
diff --git a/src/org/apache/fop/render/PrintRenderer.java b/src/org/apache/fop/render/PrintRenderer.java
index 2213c6296..3a6e355b4 100644
--- a/src/org/apache/fop/render/PrintRenderer.java
+++ b/src/org/apache/fop/render/PrintRenderer.java
@@ -14,15 +14,11 @@ package org.apache.fop.render;
import org.apache.fop.pdf.PDFPathPaint;
import org.apache.fop.pdf.PDFColor;
import org.apache.fop.image.ImageArea;
-// import org.apache.fop.image.FopImage;
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.*;
import org.apache.fop.layout.inline.*;
import org.apache.fop.datatypes.*;
-// import org.apache.fop.configuration.Configuration;
-// import org.apache.fop.extensions.*;
-// import org.apache.fop.datatypes.IDReferences;
import org.apache.fop.render.pdf.FontSetup;
import org.apache.fop.svg.SVGArea;
@@ -81,21 +77,6 @@ public abstract class PrintRenderer extends AbstractRenderer {
// protected float currentBlue = 0;
// ^^^
- /**
- * the current vertical position in millipoints from bottom
- */
- protected int currentYPosition = 0;
-
- /**
- * the current horizontal position in millipoints from left
- */
- protected int currentXPosition = 0;
-
- /**
- * the horizontal position of the current area container
- */
- protected int currentAreaContainerXPosition = 0;
-
// previous values used for text-decoration drawing
protected int prevUnderlineXEndPos;
protected int prevUnderlineYEndPos;
@@ -295,16 +276,7 @@ public abstract class PrintRenderer extends AbstractRenderer {
}
- 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) {
+ protected void doFrame(Area area) {
int w, h;
int rx = this.currentAreaContainerXPosition;
w = area.getContentWidth();
@@ -375,7 +347,7 @@ public abstract class PrintRenderer extends AbstractRenderer {
* render block area
*
* @param area the block area to render
- */
+ *
public void renderBlockArea(BlockArea area) {
// KLease: Temporary test to fix block positioning
// Offset ypos by padding and border widths
@@ -390,6 +362,7 @@ public abstract class PrintRenderer extends AbstractRenderer {
this.currentYPosition -= (area.getPaddingBottom()
+ area.getBorderBottomWidth());
}
+*/
/**
* render display space
@@ -495,38 +468,6 @@ public abstract class PrintRenderer extends AbstractRenderer {
}
/**
- * render line area
- *
- * @param area area to render
- */
- public void renderLineArea(LineArea area) {
- int rx = this.currentAreaContainerXPosition + area.getStartIndent();
- int ry = this.currentYPosition;
- int w = area.getContentWidth();
- int h = area.getHeight();
-
- this.currentYPosition -= area.getPlacementOffset();
- this.currentXPosition = rx;
-
- int bl = this.currentYPosition;
-
- Enumeration e = area.getChildren().elements();
- while (e.hasMoreElements()) {
- Box b = (Box)e.nextElement();
- if (b instanceof InlineArea) {
- InlineArea ia = (InlineArea)b;
- this.currentYPosition = ry - ia.getYOffset();
- } else {
- this.currentYPosition = ry - area.getPlacementOffset();
- }
- b.render(this);
- }
-
- this.currentYPosition = ry - h;
- this.currentXPosition = rx;
- }
-
- /**
* render page
*
* @param page page to render
@@ -599,11 +540,23 @@ public abstract class PrintRenderer extends AbstractRenderer {
*/
public void startRenderer(OutputStream outputStream)
throws IOException {}
+
/**
Default stop renderer method. This would
normally be overridden. (mark-fop@inomial.com).
*/
+ public void stopRenderer(OutputStream outputStream)
+ throws IOException
{
+ this.idReferences = null;
+ currentFontName = "";
+ currentStroke = null;
+ currentFill = null;
+ prevUnderlineColor = null;
+ prevOverlineColor = null;
+ prevLineThroughColor = null;
+ fontInfo = null;
+ this.idReferences = null;
}
}
diff --git a/src/org/apache/fop/render/awt/AWTRenderer.java b/src/org/apache/fop/render/awt/AWTRenderer.java
index d88a30c12..e65eef64e 100644
--- a/src/org/apache/fop/render/awt/AWTRenderer.java
+++ b/src/org/apache/fop/render/awt/AWTRenderer.java
@@ -106,21 +106,6 @@ public class AWTRenderer extends AbstractRenderer implements Printable, Pageable
protected Component parent;
/**
- * The current vertical position in millipoints from bottom
- */
- protected int currentYPosition = 0;
-
- /**
- * The current horizontal position in millipoints from left
- */
- protected int currentXPosition = 0;
-
- /**
- * The horizontal position of the current area container
- */
- private int currentAreaContainerXPosition = 0;
-
- /**
* options
*/
protected Hashtable options;
@@ -450,7 +435,6 @@ public class AWTRenderer extends AbstractRenderer implements Printable, Pageable
}
}
- // empty for now
public void renderBodyAreaContainer(BodyAreaContainer area) {
renderAreaContainer(area.getBeforeFloatReferenceArea());
renderAreaContainer(area.getFootnoteReferenceArea());
@@ -465,18 +449,7 @@ public class AWTRenderer extends AbstractRenderer implements Printable, Pageable
}
- // empty for now
- public void renderSpanArea(SpanArea area) {
- Enumeration e = area.getChildren().elements();
- while (e.hasMoreElements()) {
- org.apache.fop.layout.Box b =
- (org.apache.fop.layout.Box)e.nextElement();
- b.render(this); // column areas
- }
-
- }
-
- private void doFrame(org.apache.fop.layout.Area area) {
+ protected void doFrame(org.apache.fop.layout.Area area) {
int w, h;
int rx = this.currentAreaContainerXPosition;
w = area.getContentWidth();
@@ -549,32 +522,6 @@ public class AWTRenderer extends AbstractRenderer implements Printable, Pageable
a.getAllocationWidth(), a.getHeight());
}
- /*
- * public void renderBlockArea(BlockArea area) {
- * doFrame(area);
- * Enumeration e = area.getChildren().elements();
- * while (e.hasMoreElements()) {
- * org.apache.fop.layout.Box b =
- * (org.apache.fop.layout.Box) e.nextElement();
- * b.render(this);
- * }
- * }
- */
- public void renderBlockArea(BlockArea area) {
- this.currentYPosition -= (area.getPaddingTop()
- + area.getBorderTopWidth());
- doFrame(area);
- Enumeration e = area.getChildren().elements();
- while (e.hasMoreElements()) {
- org.apache.fop.layout.Box b =
- (org.apache.fop.layout.Box)e.nextElement();
- b.render(this);
- }
- this.currentYPosition -= (area.getPaddingBottom()
- + area.getBorderBottomWidth());
- }
-
-
public void setupFontInfo(FontInfo fontInfo) {
// create a temp Image to test font metrics on
BufferedImage fontImage =
@@ -751,34 +698,6 @@ public class AWTRenderer extends AbstractRenderer implements Printable, Pageable
this.currentXPosition += space.getSize();
}
- public void renderLineArea(LineArea area) {
-
- int rx = this.currentAreaContainerXPosition + area.getStartIndent();
- int ry = this.currentYPosition;
- int w = area.getContentWidth();
- int h = area.getHeight();
-
- this.currentYPosition -= area.getPlacementOffset();
- this.currentXPosition = rx;
-
- int bl = this.currentYPosition;
-
- Enumeration e = area.getChildren().elements();
- while (e.hasMoreElements()) {
- org.apache.fop.layout.Box b =
- (org.apache.fop.layout.Box)e.nextElement();
- if (b instanceof InlineArea) {
- InlineArea ia = (InlineArea)b;
- this.currentYPosition = ry - ia.getYOffset();
- } else {
- this.currentYPosition = ry - area.getPlacementOffset();
- }
- b.render(this);
- }
-
- this.currentYPosition = ry - h;
- }
-
/**
* render leader area into AWT
*
diff --git a/src/org/apache/fop/render/pdf/PDFRenderer.java b/src/org/apache/fop/render/pdf/PDFRenderer.java
index e4ae8f056..4c87184a7 100644
--- a/src/org/apache/fop/render/pdf/PDFRenderer.java
+++ b/src/org/apache/fop/render/pdf/PDFRenderer.java
@@ -166,6 +166,7 @@ public class PDFRenderer extends PrintRenderer {
currentAnnotList = null;
currentPage = null;
currentColor = null;
+ super.stopRenderer(stream);
}
/**