~ubuntu-branches/ubuntu/saucy/fop/saucy-proposed

« back to all changes in this revision

Viewing changes to src/java/org/apache/fop/area/inline/InlineArea.java

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-05-21 12:21:26 UTC
  • mfrom: (15.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20130521122126-3c9r5fo6ountjg6r
Tags: 1:1.1.dfsg-2ubuntu1
* Merge from Debian unstable.  Remaining changes:
  -  Transition libservlet2.5-java -> libservlet3.0-java.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 * limitations under the License.
16
16
 */
17
17
 
18
 
/* $Id: InlineArea.java 753327 2009-03-13 17:51:45Z adelmelle $ */
 
18
/* $Id: InlineArea.java 1293736 2012-02-26 02:29:01Z gadams $ */
19
19
 
20
20
package org.apache.fop.area.inline;
21
21
 
22
22
import java.io.Serializable;
 
23
import java.util.List;
23
24
 
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;
27
29
 
28
30
/**
29
31
 * Inline Area
32
34
 */
33
35
public class InlineArea extends Area {
34
36
 
 
37
    private static final long serialVersionUID = -8940066479810170980L;
 
38
 
35
39
    /**
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
39
43
     */
40
44
    protected class InlineAdjustingInfo implements Serializable {
 
45
 
 
46
        private static final long serialVersionUID = -5601387735459712149L;
 
47
 
41
48
        /** stretch of the inline area */
42
49
        protected int availableStretch;
43
50
        /** shrink of the inline area */
74
81
    /**
75
82
     * offset position from before edge of parent area
76
83
     */
77
 
    protected int offset = 0;
 
84
    protected int blockProgressionOffset = 0;
78
85
 
79
86
    /**
80
87
     * parent area
96
103
    protected InlineAdjustingInfo adjustingInfo = null;
97
104
 
98
105
    /**
 
106
     * Default constructor for inline area.
 
107
     */
 
108
    public InlineArea() {
 
109
        this (  0, -1 );
 
110
    }
 
111
 
 
112
    /**
 
113
     * Instantiate inline area.
 
114
     * @param blockProgressionOffset a block progression offset or zero
 
115
     * @param bidiLevel a resolved bidi level or -1
 
116
     */
 
117
    protected InlineArea ( int blockProgressionOffset, int bidiLevel ) {
 
118
        this.blockProgressionOffset = blockProgressionOffset;
 
119
        setBidiLevel(bidiLevel);
 
120
    }
 
121
 
 
122
    /**
99
123
     * @return the adjustment information object
100
124
     */
101
125
    public InlineAdjustingInfo getAdjustingInfo() {
133
157
    }
134
158
 
135
159
    /**
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.
139
163
     *
140
 
     * @param offset the offset
 
164
     * @param blockProgressionOffset the offset
141
165
     */
142
 
    public void setOffset(int offset) {
143
 
        this.offset = offset;
 
166
    public void setBlockProgressionOffset(int blockProgressionOffset) {
 
167
        this.blockProgressionOffset = blockProgressionOffset;
144
168
    }
145
169
 
146
170
    /**
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.
150
174
     *
151
 
     * @return the offset
 
175
     * @return the blockProgressionOffset
152
176
     */
153
 
    public int getOffset() {
154
 
        return offset;
 
177
    public int getBlockProgressionOffset() {
 
178
        return blockProgressionOffset;
155
179
    }
156
180
 
157
181
    /**
173
197
     *
174
198
     * {@inheritDoc}
175
199
     */
 
200
    @Override
176
201
    public void addChildArea(Area childArea) {
177
202
        super.addChildArea(childArea);
178
203
        if (childArea instanceof InlineArea) {
180
205
        }
181
206
    }
182
207
 
183
 
    /**
184
 
     *@return true if the inline area is underlined.
185
 
     */
 
208
    /** @return true if the inline area is underlined. */
186
209
    public boolean hasUnderline() {
187
210
        return getTraitAsBoolean(Trait.UNDERLINE);
188
211
    }
218
241
        return false;
219
242
    }
220
243
 
 
244
    /**
 
245
     * Apply IPD variation.
 
246
     * @param ipdVariation the variation
 
247
     */
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.");
 
252
        }
 
253
 
222
254
        increaseIPD(ipdVariation);
223
255
        notifyIPDVariation(ipdVariation);
224
256
    }
238
270
            storedIPDVariation += ipdVariation;
239
271
        }
240
272
    }
 
273
 
 
274
    /**
 
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
 
279
     * elements.
 
280
     *
 
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()
 
285
     * @see BasicLinkArea
 
286
     */
 
287
    int getVirtualOffset() {
 
288
        return getBlockProgressionOffset();
 
289
    }
 
290
 
 
291
    /**
 
292
     * Returns the block-progression-dimension that this area would have if it were taking
 
293
     * its children elements into account. See {@linkplain #getVirtualOffset()}.
 
294
     *
 
295
     * @return the bpd
 
296
     */
 
297
    int getVirtualBPD() {
 
298
        return getBPD();
 
299
    }
 
300
 
 
301
    /**
 
302
     * Collection bidi inline runs.
 
303
     * @param runs current list of inline runs
 
304
     * @return modified list of inline runs, having appended new run
 
305
     */
 
306
    public List collectInlineRuns ( List runs ) {
 
307
        assert runs != null;
 
308
        runs.add ( new InlineRun ( this, new int[] {getBidiLevel()}) );
 
309
        return runs;
 
310
    }
 
311
 
 
312
    /**
 
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
 
316
     */
 
317
    public boolean isAncestorOrSelf ( InlineArea ia ) {
 
318
        return ( ia == this ) || isAncestor ( ia );
 
319
    }
 
320
 
 
321
    /**
 
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
 
325
     */
 
326
    public boolean isAncestor ( InlineArea ia ) {
 
327
        for ( Area p = getParentArea(); p != null;) {
 
328
            if ( p == ia ) {
 
329
                return true;
 
330
            } else if ( p instanceof InlineArea ) {
 
331
                p = ( (InlineArea) p ).getParentArea();
 
332
            } else {
 
333
                p = null;
 
334
            }
 
335
        }
 
336
        return false;
 
337
    }
 
338
 
241
339
}
242