blob: b8544878c3a81bb70dd308e4f672dccd6f58a336 (
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
/*
* $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.area;
import java.util.ArrayList;
/**
* Area tree for formatting objects.
*
* Concepts:
* The area tree is to be as small as possible. With minimal classes
* and data to fully represent an area tree for formatting objects.
* The area tree needs to be simple to render and follow the spec
* closely.
* This area tree has the concept of page sequences.
* Where ever possible information is discarded or optimised to
* keep memory use low. The data is also organised to make it
* possible for renderers to minimise their output.
* A page can be saved if not fully resolved and once rendered
* a page contains only size and id reference information.
* The area tree pages are organised in a model that depends on the
* type of renderer.
*/
public class AreaTree {
// allows for different models to deal with adding/rendering
// in different situations
AreaTreeModel model;
public void createRenderPageModel(PageRenderListener listener) {
}
public static StorePagesModel createStorePagesModel() {
return new StorePagesModel();
}
public void setTreeModel(AreaTreeModel m) {
model = m;
}
public void startPageSequence(Area title) {
model.startPageSequence(title);
}
public void addPage(PageViewport page) {
model.addPage(page);
}
// this is the model for the area tree object
public static abstract class AreaTreeModel {
public abstract void startPageSequence(Area title);
public abstract void addPage(PageViewport page);
}
// this class stores all the pages in the document
// for interactive agents
public static class StorePagesModel extends AreaTreeModel {
ArrayList pageSequence = null;
ArrayList titles = new ArrayList();
ArrayList currSequence;
public StorePagesModel() {}
public void startPageSequence(Area title) {
titles.add(title);
if (pageSequence == null) {
pageSequence = new ArrayList();
}
currSequence = new ArrayList();
pageSequence.add(currSequence);
}
public void addPage(PageViewport page) {
currSequence.add(page);
}
public int getPageSequenceCount() {
return pageSequence.size();
}
public Title getTitle(int count) {
return (Title) titles.get(count);
}
public int getPageCount(int seq) {
ArrayList sequence = (ArrayList) pageSequence.get(seq);
return sequence.size();
}
public PageViewport getPage(int seq, int count) {
ArrayList sequence = (ArrayList) pageSequence.get(seq);
return (PageViewport) sequence.get(count);
}
}
// this queues pages and will call the render listener
// when the page is ready to be rendered
// if the render supports out of order rendering
// then a ready page is rendered immediately
public static class RenderPagesModel extends StorePagesModel {
public void startPageSequence(Area title) {}
public void addPage(PageViewport page) {}
}
public static abstract class PageRenderListener {
public abstract void renderPage(RenderPagesModel model,
int pageseq, int count);
}
}
|