keiron 01/09/17 04:04:50
Modified: src/org/apache/fop/render AbstractRenderer.java
PrintRenderer.java
src/org/apache/fop/render/awt AWTRenderer.java
src/org/apache/fop/render/pdf PDFRenderer.java
Log:
put a few common methods in the abstract renderer
Revision Changes Path
1.2 +80 -4 xml-fop/src/org/apache/fop/render/AbstractRenderer.java
Index: AbstractRenderer.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/AbstractRenderer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractRenderer.java 2001/08/21 06:18:55 1.1
+++ AbstractRenderer.java 2001/09/17 11:04:49 1.2
@@ -1,8 +1,8 @@
/*
- * $Id: AbstractRenderer.java,v 1.1 2001/08/21 06:18:55 keiron Exp $
+ * $Id: AbstractRenderer.java,v 1.2 2001/09/17 11:04:49 keiron Exp $
* 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.datatypes.*;
import org.apache.fop.render.pdf.FontSetup;
-import org.apache.fop.svg.SVGArea;
-
import org.apache.log.Logger;
// Java
@@ -34,8 +32,86 @@
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;
+ }
}
1.12 +16 -63 xml-fop/src/org/apache/fop/render/PrintRenderer.java
Index: PrintRenderer.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/PrintRenderer.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- PrintRenderer.java 2001/08/21 06:18:55 1.11
+++ PrintRenderer.java 2001/09/17 11:04:49 1.12
@@ -1,5 +1,5 @@
/*
- * $Id: PrintRenderer.java,v 1.11 2001/08/21 06:18:55 keiron Exp $
+ * $Id: PrintRenderer.java,v 1.12 2001/09/17 11:04:49 keiron Exp $
* 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."
@@ -14,15 +14,11 @@
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 @@
// 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 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 @@
* 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 @@
this.currentYPosition -= (area.getPaddingBottom()
+ area.getBorderBottomWidth());
}
+*/
/**
* render display space
@@ -495,38 +468,6 @@
}
/**
- * 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 void startRenderer(OutputStream outputStream)
throws IOException {}
+
/**
Default stop renderer method. This would
normally be overridden. ([EMAIL PROTECTED]).
*/
+ 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;
}
}
1.33 +2 -83 xml-fop/src/org/apache/fop/render/awt/AWTRenderer.java
Index: AWTRenderer.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/awt/AWTRenderer.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- AWTRenderer.java 2001/08/21 06:18:55 1.32
+++ AWTRenderer.java 2001/09/17 11:04:49 1.33
@@ -1,5 +1,5 @@
/*
- * $Id: AWTRenderer.java,v 1.32 2001/08/21 06:18:55 keiron Exp $
+ * $Id: AWTRenderer.java,v 1.33 2001/09/17 11:04:49 keiron Exp $
* 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.
@@ -106,21 +106,6 @@
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 @@
}
}
- // empty for now
public void renderBodyAreaContainer(BodyAreaContainer area) {
renderAreaContainer(area.getBeforeFloatReferenceArea());
renderAreaContainer(area.getFootnoteReferenceArea());
@@ -465,18 +449,7 @@
}
- // 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 @@
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 =
@@ -749,34 +696,6 @@
public void renderInlineSpace(InlineSpace space) {
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;
}
/**
1.88 +2 -1 xml-fop/src/org/apache/fop/render/pdf/PDFRenderer.java
Index: PDFRenderer.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/pdf/PDFRenderer.java,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -r1.87 -r1.88
--- PDFRenderer.java 2001/08/30 10:09:02 1.87
+++ PDFRenderer.java 2001/09/17 11:04:50 1.88
@@ -1,5 +1,5 @@
/*
- * $Id: PDFRenderer.java,v 1.87 2001/08/30 10:09:02 keiron Exp $
+ * $Id: PDFRenderer.java,v 1.88 2001/09/17 11:04:50 keiron Exp $
* 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.
@@ -166,6 +166,7 @@
currentAnnotList = null;
currentPage = null;
currentColor = null;
+ super.stopRenderer(stream);
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]