KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > layoutmgr > FootnoteBodyLayoutManager


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 /* $Id: FootnoteBodyLayoutManager.java 426576 2006-07-28 15:44:37Z jeremias $ */
19
20 package org.apache.fop.layoutmgr;
21
22 import org.apache.fop.area.Area;
23 import org.apache.fop.fo.flow.FootnoteBody;
24
25 import java.util.LinkedList JavaDoc;
26
27 /**
28  * Layout manager for footnote bodies.
29  */

30 public class FootnoteBodyLayoutManager extends BlockStackingLayoutManager {
31
32     /**
33      * Creates a new FootnoteBodyLayoutManager.
34      * @param body the footnote-body element
35      */

36     public FootnoteBodyLayoutManager(FootnoteBody body) {
37         super(body);
38     }
39
40     /** @see org.apache.fop.layoutmgr.LayoutManager */
41     public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) {
42         LayoutManager childLM = null;
43         LayoutManager lastLM = null;
44         LayoutContext lc = new LayoutContext(0);
45
46         // "unwrap" the NonLeafPositions stored in parentIter
47
// and put them in a new list;
48
LinkedList JavaDoc positionList = new LinkedList JavaDoc();
49         Position pos;
50         while (parentIter.hasNext()) {
51             pos = (Position) parentIter.next();
52             //log.trace("pos = " + pos.getClass().getName() + "; " + pos);
53
Position innerPosition = pos;
54             if (pos instanceof NonLeafPosition) {
55                 innerPosition = ((NonLeafPosition) pos).getPosition();
56                 if (innerPosition.getLM() == this) {
57                     // pos was created by this LM and was inside a penalty
58
// allowing or forbidding a page break
59
// nothing to do
60
//log.trace(" penalty");
61
} else {
62                     // innerPosition was created by another LM
63
positionList.add(innerPosition);
64                     lastLM = innerPosition.getLM();
65                     //log.trace(" " + innerPosition.getClass().getName());
66
}
67             }
68         }
69
70         // the Positions in positionList were inside the elements
71
// created by the LineLM
72
StackingIter childPosIter = new StackingIter(positionList.listIterator());
73
74         while ((childLM = childPosIter.getNextChildLM()) != null) {
75             // set last area flag
76
lc.setFlags(LayoutContext.LAST_AREA,
77                     (layoutContext.isLastArea() && childLM == lastLM));
78             // Add the line areas to Area
79
childLM.addAreas(childPosIter, lc);
80         }
81     }
82
83     /** @see org.apache.fop.layoutmgr.LayoutManager#addChildArea(org.apache.fop.area.Area) */
84     public void addChildArea(Area childArea) {
85         childArea.setAreaClass(Area.CLASS_FOOTNOTE);
86         parentLM.addChildArea(childArea);
87     }
88
89     /** @return the FootnoteBody node */
90     protected FootnoteBody getFootnodeBodyFO() {
91         return (FootnoteBody) fobj;
92     }
93
94 }
95
Popular Tags