aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKaren Lease <klease@apache.org>2001-11-09 22:21:28 +0000
committerKaren Lease <klease@apache.org>2001-11-09 22:21:28 +0000
commitf6ea69b56a30aaec6c0b1a040f91ab46b264dda5 (patch)
tree67c945dbf32e57f42641cff926847094cd9f8967 /src
parent20849fb6fb56e3bc008725ab4dd39f54e1fa4cca (diff)
downloadxmlgraphics-fop-f6ea69b56a30aaec6c0b1a040f91ab46b264dda5.tar.gz
xmlgraphics-fop-f6ea69b56a30aaec6c0b1a040f91ab46b264dda5.zip
PageMaster uses a PageViewport object
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194549 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/org/apache/fop/layout/PageMaster.java108
1 files changed, 58 insertions, 50 deletions
diff --git a/src/org/apache/fop/layout/PageMaster.java b/src/org/apache/fop/layout/PageMaster.java
index 7034bf238..3dd0443c3 100644
--- a/src/org/apache/fop/layout/PageMaster.java
+++ b/src/org/apache/fop/layout/PageMaster.java
@@ -7,69 +7,77 @@
package org.apache.fop.layout;
-public class PageMaster {
+import java.io.*;
- private int width;
- private int height;
+import org.apache.fop.area.PageViewport;
- private BodyRegionArea body;
- private RegionArea before;
- private RegionArea after;
- private RegionArea start;
- private RegionArea end;
+public class PageMaster {
- public PageMaster(int pageWidth, int pageHeight) {
- this.width = pageWidth;
- this.height = pageHeight;
- }
+ private PageViewport pageVP ;
- public void addAfter(RegionArea region) {
- this.after = region;
+ public PageMaster(PageViewport pageVP) {
+ this.pageVP = pageVP;
}
- public void addBefore(RegionArea region) {
- this.before = region;
- }
- public void addBody(BodyRegionArea region) {
- this.body = region;
- }
+ // Use serialization to make a clone of the master
+ public PageViewport makePage() {
+ try {
+ System.err.println("PageMaster.makePage");
+ PipedOutputStream outputStream = new PipedOutputStream();
+ PipedInputStream inputStream = new PipedInputStream(outputStream);
+ //System.err.println("PageMaster.makePage made piped streams");
- public void addEnd(RegionArea region) {
- this.end = region;
- }
+ ObjectOutputStream objOut =
+ new ObjectOutputStream(new BufferedOutputStream(outputStream));
+ /* ObjectInputStream objIn =
+ new ObjectInputStream(new BufferedInputStream(inputStream));*/
- public void addStart(RegionArea region) {
- this.start = region;
- }
+ //System.err.println("PageMaster.makePage: streams made");
+ PageViewport newPageVP = new PageViewport(pageVP.getPage(),
+ pageVP.getViewArea());
+ //System.err.println("PageMaster.makePage: newPageVP made");
+ Thread reader = new Thread(new PageReader(inputStream, newPageVP));
+ //System.err.println("Start serialize");
+ reader.start();
- public int getHeight() {
- return this.height;
- }
+ //System.err.println("Save page");
+ pageVP.savePage(objOut);
+ objOut.close();
+ //System.err.println("Save page done");
+ reader.join();
+ //System.err.println("join done");
- public int getWidth() {
- return this.width;
+ // objIn.close();
+ return newPageVP;
+ } catch (Exception e) {
+ System.err.println("PageMaster.makePage(): " + e.getMessage());
+ return null;
+ }
}
- public Page makePage(AreaTree areaTree) {
- Page p = new Page(areaTree, this.height, this.width);
- if (this.body != null) {
- p.addBody(body.makeBodyAreaContainer());
- }
- if (this.before != null) {
- p.addBefore(before.makeAreaContainer());
- }
- if (this.after != null) {
- p.addAfter(after.makeAreaContainer());
- }
- if (this.start != null) {
- p.addStart(start.makeAreaContainer());
- }
- if (this.end != null) {
- p.addEnd(end.makeAreaContainer());
- }
-
- return p;
+ static private class PageReader implements Runnable {
+ private InputStream is;
+ private PageViewport pvp;
+
+ PageReader(InputStream is, PageViewport pvp) {
+ //System.err.println("PageReader object made");
+ this.is = is;
+ this.pvp = pvp;
+ }
+
+ public void run() {
+ try {
+ //System.err.println("PageReader make ObjectInputStream");
+ ObjectInputStream ois = new ObjectInputStream(is);
+ //System.err.println("Load page");
+ pvp.loadPage(ois);
+ //System.err.println("Load page done");
+ } catch (Exception e) {
+ System.err.println("Error copying PageViewport: " +
+ e);
+ }
+ }
}
}