15
15
* limitations under the License.
18
/* $Id: InlineArea.java 753327 2009-03-13 17:51:45Z adelmelle $ */
18
/* $Id: InlineArea.java 1293736 2012-02-26 02:29:01Z gadams $ */
20
20
package org.apache.fop.area.inline;
22
22
import java.io.Serializable;
23
import java.util.List;
24
25
import org.apache.fop.area.Area;
25
26
import org.apache.fop.area.LineArea;
26
27
import org.apache.fop.area.Trait;
28
import org.apache.fop.complexscripts.bidi.InlineRun;
33
35
public class InlineArea extends Area {
37
private static final long serialVersionUID = -8940066479810170980L;
36
40
* this class stores information about potential adjustments
37
41
* that can be used in order to re-compute adjustments when a
38
42
* page-number or a page-number-citation is resolved
40
44
protected class InlineAdjustingInfo implements Serializable {
46
private static final long serialVersionUID = -5601387735459712149L;
41
48
/** stretch of the inline area */
42
49
protected int availableStretch;
43
50
/** shrink of the inline area */
96
103
protected InlineAdjustingInfo adjustingInfo = null;
106
* Default constructor for inline area.
108
public InlineArea() {
113
* Instantiate inline area.
114
* @param blockProgressionOffset a block progression offset or zero
115
* @param bidiLevel a resolved bidi level or -1
117
protected InlineArea ( int blockProgressionOffset, int bidiLevel ) {
118
this.blockProgressionOffset = blockProgressionOffset;
119
setBidiLevel(bidiLevel);
99
123
* @return the adjustment information object
101
125
public InlineAdjustingInfo getAdjustingInfo() {
136
* Set the offset of this inline area.
160
* Set the block progression offset of this inline area.
137
161
* This is used to set the offset of the inline area
138
162
* which is relative to the before edge of the parent area.
140
* @param offset the offset
164
* @param blockProgressionOffset the offset
142
public void setOffset(int offset) {
143
this.offset = offset;
166
public void setBlockProgressionOffset(int blockProgressionOffset) {
167
this.blockProgressionOffset = blockProgressionOffset;
147
* Get the offset of this inline area.
171
* Get the block progression offset of this inline area.
148
172
* This returns the offset of the inline area
149
* which is relative to the before edge of the parent area.
173
* relative to the before edge of the parent area.
175
* @return the blockProgressionOffset
153
public int getOffset() {
177
public int getBlockProgressionOffset() {
178
return blockProgressionOffset;
245
* Apply IPD variation.
246
* @param ipdVariation the variation
221
248
public void handleIPDVariation(int ipdVariation) {
249
if (log.isTraceEnabled()) {
250
log.trace("Handling IPD variation for " + getClass().getSimpleName()
251
+ ": increase by " + ipdVariation + " mpt.");
222
254
increaseIPD(ipdVariation);
223
255
notifyIPDVariation(ipdVariation);
238
270
storedIPDVariation += ipdVariation;
275
* Returns the offset that this area would have if its offset and size were taking
276
* children areas into account. The bpd of an inline area is taken from its nominal
277
* font and doesn't depend on the bpds of its children elements. However, in the case
278
* of a basic-link element we want the active area to cover all of the children
281
* @return the offset that this area would have if the before-edge of its
282
* content-rectangle were coinciding with the <q>beforest</q> before-edge of its
283
* children allocation-rectangles.
284
* @see #getVirtualBPD()
287
int getVirtualOffset() {
288
return getBlockProgressionOffset();
292
* Returns the block-progression-dimension that this area would have if it were taking
293
* its children elements into account. See {@linkplain #getVirtualOffset()}.
297
int getVirtualBPD() {
302
* Collection bidi inline runs.
303
* @param runs current list of inline runs
304
* @return modified list of inline runs, having appended new run
306
public List collectInlineRuns ( List runs ) {
308
runs.add ( new InlineRun ( this, new int[] {getBidiLevel()}) );
313
* Determine if inline area IA is an ancestor inline area or same as this area.
314
* @param ia inline area to test
315
* @return true if specified inline area is an ancestor or same as this area
317
public boolean isAncestorOrSelf ( InlineArea ia ) {
318
return ( ia == this ) || isAncestor ( ia );
322
* Determine if inline area IA is an ancestor inline area of this area.
323
* @param ia inline area to test
324
* @return true if specified inline area is an ancestor of this area
326
public boolean isAncestor ( InlineArea ia ) {
327
for ( Area p = getParentArea(); p != null;) {
330
} else if ( p instanceof InlineArea ) {
331
p = ( (InlineArea) p ).getParentArea();