blob: 3dd0443c3423a6f4df9f33d0134c53f02a177e2e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
/*
* $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.
*/
package org.apache.fop.layout;
import java.io.*;
import org.apache.fop.area.PageViewport;
public class PageMaster {
private PageViewport pageVP ;
public PageMaster(PageViewport pageVP) {
this.pageVP = pageVP;
}
// 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);
}
}
}
}
|