KickJava   Java API By Example, From Geeks To Geeks.

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


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: KnuthBlockBox.java 426576 2006-07-28 15:44:37Z jeremias $ */
19
20 package org.apache.fop.layoutmgr;
21
22 import org.apache.fop.traits.MinOptMax;
23
24 import java.util.LinkedList JavaDoc;
25
26 /**
27  * Knuth box used to represent a line in block-progression-dimension (i.e. the width is its height).
28  */

29 public class KnuthBlockBox extends KnuthBox {
30     
31     private MinOptMax ipdRange;
32     /**
33      * Natural width of the line represented by this box. In addition to ipdRange because
34      * it isn't possible to get the opt value stored in a MinOptMax object.
35      */

36     private int bpd;
37     private LinkedList JavaDoc footnoteList;
38     /** List of Knuth elements. This is a list of LinkedList elements. */
39     private LinkedList JavaDoc elementLists = null;
40
41     /**
42      * Creates a new box.
43      * @param w block progression dimension of this box
44      * @param range min, opt, max inline progression dimension of this box
45      * @param bpdim natural width of the line represented by this box.
46      * @param pos the Position stored in this box
47      * @param bAux is this box auxiliary?
48      */

49     public KnuthBlockBox(int w, MinOptMax range, int bpdim, Position pos, boolean bAux) {
50         super(w, pos, bAux);
51         ipdRange = (MinOptMax) range.clone();
52         bpd = bpdim;
53         footnoteList = new LinkedList JavaDoc();
54     }
55
56     /**
57      * Creates a new box.
58      * @param w block progression dimension of this box
59      * @param list footnotes cited by elements in this box. The list contains the
60      * corresponding FootnoteBodyLayoutManagers
61      * @param pos the Position stored in this box
62      * @param bAux is this box auxiliary?
63      */

64     public KnuthBlockBox(int w, LinkedList JavaDoc list, Position pos, boolean bAux) {
65         super(w, pos, bAux);
66         ipdRange = new MinOptMax(0);
67         bpd = 0;
68         footnoteList = new LinkedList JavaDoc(list);
69     }
70
71     /**
72      * @return the LMs for the footnotes cited in this box.
73      */

74     public LinkedList JavaDoc getFootnoteBodyLMs() {
75         return footnoteList;
76     }
77
78     /**
79      * @return true if this box contains footnote citations.
80      */

81     public boolean hasAnchors() {
82         return (footnoteList.size() > 0);
83     }
84
85     /**
86      * Adds the given list of Knuth elements to this box' list of elements.
87      * @param list elements corresponding to a footnote body
88      */

89     public void addElementList(LinkedList JavaDoc list) {
90         if (elementLists == null) {
91             elementLists = new LinkedList JavaDoc();
92         }
93         elementLists.add(list);
94     }
95
96     /**
97      * Returns the list of Knuth sequences registered by this box.
98      * @return a list of KnuthElement sequences corresponding to footnotes cited in this
99      * box
100      */

101     public LinkedList JavaDoc getElementLists() {
102         return elementLists;
103     }
104
105     /**
106      * @return the inline progression dimension of this box.
107      */

108     public MinOptMax getIPDRange() {
109         return (MinOptMax) ipdRange.clone();
110     }
111
112     /**
113      * Returns the natural width (without stretching nor shrinking) of the line
114      * represented by this box.
115      * @return the line width
116      */

117     public int getBPD() {
118         return bpd;
119     }
120 }
121
Popular Tags