You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by kl...@apache.org on 2001/11/09 23:21:28 UTC
cvs commit: xml-fop/src/org/apache/fop/layout PageMaster.java
klease 01/11/09 14:21:28
Modified: src/org/apache/fop/layout PageMaster.java
Log:
PageMaster uses a PageViewport object
Revision Changes Path
1.12 +65 -57 xml-fop/src/org/apache/fop/layout/PageMaster.java
Index: PageMaster.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/layout/PageMaster.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- PageMaster.java 2001/07/30 20:29:27 1.11
+++ PageMaster.java 2001/11/09 22:21:28 1.12
@@ -1,5 +1,5 @@
/*
- * $Id: PageMaster.java,v 1.11 2001/07/30 20:29:27 tore Exp $
+ * $Id: PageMaster.java,v 1.12 2001/11/09 22:21:28 klease 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.
@@ -7,69 +7,77 @@
package org.apache.fop.layout;
-public class PageMaster {
-
- private int width;
- private int height;
-
- private BodyRegionArea body;
- private RegionArea before;
- private RegionArea after;
- private RegionArea start;
- private RegionArea end;
-
- public PageMaster(int pageWidth, int pageHeight) {
- this.width = pageWidth;
- this.height = pageHeight;
- }
-
- public void addAfter(RegionArea region) {
- this.after = region;
- }
-
- public void addBefore(RegionArea region) {
- this.before = region;
- }
-
- public void addBody(BodyRegionArea region) {
- this.body = region;
- }
+import java.io.*;
- public void addEnd(RegionArea region) {
- this.end = region;
- }
+import org.apache.fop.area.PageViewport;
- public void addStart(RegionArea region) {
- this.start = region;
- }
+public class PageMaster {
- public int getHeight() {
- return this.height;
- }
+ private PageViewport pageVP ;
- public int getWidth() {
- return this.width;
+ public PageMaster(PageViewport pageVP) {
+ this.pageVP = pageVP;
}
- 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;
+ // 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");
+
+ ObjectOutputStream objOut =
+ new ObjectOutputStream(new BufferedOutputStream(outputStream));
+ /* ObjectInputStream objIn =
+ new ObjectInputStream(new BufferedInputStream(inputStream));*/
+
+ //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();
+
+ //System.err.println("Save page");
+ pageVP.savePage(objOut);
+ objOut.close();
+ //System.err.println("Save page done");
+ reader.join();
+ //System.err.println("join done");
+
+ // objIn.close();
+ return newPageVP;
+ } catch (Exception e) {
+ System.err.println("PageMaster.makePage(): " + e.getMessage());
+ return null;
+ }
+ }
+
+ 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);
+ }
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org