KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > area > Block


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: Block.java 426576 2006-07-28 15:44:37Z jeremias $ */
19  
20 package org.apache.fop.area;
21
22 import java.util.ArrayList JavaDoc;
23
24 // block areas hold either more block areas or line
25
// areas can also be used as a block spacer
26
// a block area may have children positioned by stacking
27
// or by relative to the parent for floats, tables and lists
28
// cacheable object
29
// has id information
30

31 /**
32  * This is the block area class.
33  * It holds child block areas such as other blocks or lines.
34  */

35 public class Block extends BlockParent {
36     /**
37      * Normally stacked with other blocks.
38      */

39     public static final int STACK = 0;
40
41     /**
42      * Placed relative to the flow position.
43      * This effects the flow placement of stacking normally.
44      */

45     public static final int RELATIVE = 1;
46
47     /**
48      * Relative to the block parent but not effecting the stacking
49      * Used for block-container, tables and lists.
50      */

51     public static final int ABSOLUTE = 2;
52
53     /**
54      * Relative to a viewport/page but not effecting the stacking
55      * Used for block-container.
56      */

57     public static final int FIXED = 3;
58
59     private int stacking = TB;
60     private int positioning = STACK;
61
62     // a block with may contain the dominant styling info in
63
// terms of most lines or blocks with info
64

65     /**
66      * Add the block to this block area.
67      *
68      * @param block the block area to add
69      */

70     public void addBlock(Block block) {
71         addBlock(block, true);
72     }
73
74     /**
75      * Add the block to this block area.
76      *
77      * @param block the block area to add
78      * @param autoHeight increase the height of the block.
79      */

80     public void addBlock(Block block, boolean autoHeight) {
81         if (autoHeight) {
82             bpd += block.getAllocBPD();
83         }
84         addChildArea(block);
85     }
86
87     /**
88      * Add the line area to this block area.
89      *
90      * @param line the line area to add
91      */

92     public void addLineArea(LineArea line) {
93         bpd += line.getAllocBPD();
94         addChildArea(line);
95     }
96
97     /**
98      * Set the positioning of this area.
99      *
100      * @param pos the positioning to use when rendering this area
101      */

102     public void setPositioning(int pos) {
103         positioning = pos;
104     }
105
106     /**
107      * Get the positioning of this area.
108      *
109      * @return the positioning to use when rendering this area
110      */

111     public int getPositioning() {
112         return positioning;
113     }
114
115     /**
116      * @return the start-indent trait
117      */

118     public int getStartIndent() {
119         Integer JavaDoc startIndent = (Integer JavaDoc)getTrait(Trait.START_INDENT);
120         return (startIndent != null ? startIndent.intValue() : 0);
121     }
122     
123 }
124
125
Popular Tags