blob: 214e4110a0c44c1f6a4d63f33bb608772ba804b6 (
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
118
|
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* $Id$ */
package org.apache.fop.area.inline;
import java.util.List;
import java.util.ListIterator;
import java.util.ArrayList;
import java.util.Iterator;
/**
* Filled area.
* This inline area contains some inline areas.
* When the renderer gets the child areas to render
* the inline areas are repeated to fill the ipd of
* this inline parent.
* This extends InlineParent so that the renderer will render
* this as a normal inline parent.
*/
public class FilledArea extends InlineParent {
private int unitWidth;
/**
* Create a new filled area.
*/
public FilledArea() {
}
/**
* Set the offset of the descendant TextAreas,
* instead of the offset of the FilledArea itself.
*
* @param v the offset
*/
/*
public void setOffset(int v) {
setChildOffset(inlines.listIterator(), v);
}
*/
private void setChildOffset(ListIterator childrenIterator, int v) {
while (childrenIterator.hasNext()) {
InlineArea child = (InlineArea) childrenIterator.next();
if (child instanceof InlineParent) {
setChildOffset(((InlineParent) child).getChildAreas().listIterator(), v);
} else if (child instanceof org.apache.fop.area.inline.Viewport) {
// nothing
} else {
child.setOffset(v);
}
}
}
/**
* Set the unit width for the areas to fill the full width.
*
* @param w the unit width
*/
public void setUnitWidth(int w) {
unitWidth = w;
}
/**
* Return the unit width for the areas to fill the full width.
*
* @return the unit width
*/
public int getUnitWidth() {
return unitWidth;
}
/**
* @see org.apache.fop.area.Area#getBPD
*/
public int getBPD() {
int bpd = 0;
for (Iterator childAreaIt = getChildAreas().iterator(); childAreaIt.hasNext();) {
InlineArea area = (InlineArea)childAreaIt.next();
if (bpd < area.getBPD()) {
bpd = area.getBPD();
}
}
return bpd;
}
/**
* Get the child areas for this filled area.
* This copies the references of the inline areas so that
* it fills the total width of the area a whole number of times
* for the unit width.
*
* @return the list of child areas copied to fill the width
*/
public List getChildAreas() {
int units = (int)(getIPD() / unitWidth);
List newList = new ArrayList();
for (int count = 0; count < units; count++) {
newList.addAll(inlines);
}
return newList;
}
}
|