KickJava   Java API By Example, From Geeks To Geeks.

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


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: UnresolvedListElementWithLength.java 426576 2006-07-28 15:44:37Z jeremias $ */
19
20 package org.apache.fop.layoutmgr;
21
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24 import org.apache.fop.traits.MinOptMax;
25
26 /**
27  * This class represents an unresolved list element element with a (conditional) length. This
28  * is the base class for spaces, borders and paddings.
29  */

30 public abstract class UnresolvedListElementWithLength extends UnresolvedListElement {
31
32     /** Logger instance */
33     protected static Log log = LogFactory.getLog(UnresolvedListElementWithLength.class);
34     
35     private MinOptMax length;
36     private boolean conditional;
37     private RelSide side;
38     private boolean isFirst;
39     private boolean isLast;
40     
41     /**
42      * Main constructor
43      * @param position the Position instance needed by the addAreas stage of the LMs.
44      * @param length the length of the element
45      * @param side the side to which this element applies
46      * @param conditional true if it's a conditional element (conditionality=discard)
47      * @param isFirst true if this is a space-before of the first area generated.
48      * @param isLast true if this is a space-after of the last area generated.
49      */

50     public UnresolvedListElementWithLength(Position position, MinOptMax length,
51             RelSide side,
52             boolean conditional, boolean isFirst, boolean isLast) {
53         super(position);
54         this.length = length;
55         this.side = side;
56         this.conditional = conditional;
57         this.isFirst = isFirst;
58         this.isLast = isLast;
59     }
60     
61     /** @see org.apache.fop.layoutmgr.UnresolvedListElement#isConditional() */
62     public boolean isConditional() {
63         return this.conditional;
64     }
65     
66     /** @return the space as resolved MinOptMax instance */
67     public MinOptMax getLength() {
68         return this.length;
69     }
70     
71     /** @return the side this element was generated for */
72     public RelSide getSide() {
73         return this.side;
74     }
75     
76     /** @return true if this is a space-before of the first area generated. */
77     public boolean isFirst() {
78         return this.isFirst;
79     }
80     
81     /** @return true if this is a space-after of the last area generated. */
82     public boolean isLast() {
83         return this.isLast;
84     }
85     
86     /**
87      * Called to notify the affected layout manager about the effective length after resolution.
88      * This method is called once before each call to the layout manager's addAreas() method.
89      * @param effectiveLength the effective length after resolution (may be null which equals to
90      * zero effective length)
91      */

92     public abstract void notifyLayoutManager(MinOptMax effectiveLength);
93     
94     /** @see java.lang.Object#toString() */
95     public String JavaDoc toString() {
96         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
97         sb.append(getSide().getName()).append(", ");
98         sb.append(this.length.toString());
99         if (isConditional()) {
100             sb.append("[discard]");
101         } else {
102             sb.append("[RETAIN]");
103         }
104         if (isFirst()) {
105             sb.append("[first]");
106         }
107         if (isLast()) {
108             sb.append("[last]");
109         }
110         return sb.toString();
111     }
112     
113 }
114
Popular Tags