01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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$ */
19:
20: package org.apache.fop.layoutmgr.table;
21:
22: import java.util.List;
23:
24: import org.apache.fop.layoutmgr.LayoutManager;
25: import org.apache.fop.layoutmgr.Position;
26:
27: /**
28: * This class represents a Position specific to TableContentLayoutManager. Used for normal
29: * content cases.
30: */
31: class TableContentPosition extends Position {
32:
33: /** The position is the first of the row group. */
34: public static final int FIRST_IN_ROWGROUP = 1;
35: /** The position is the last of the row group. */
36: public static final int LAST_IN_ROWGROUP = 2;
37:
38: /** the list of GridUnitParts making up this position */
39: protected List gridUnitParts;
40: /** effective row this position belongs to */
41: protected EffRow row;
42: /** flags for the position */
43: protected int flags;
44:
45: /**
46: * Creates a new TableContentPosition.
47: * @param lm applicable layout manager
48: * @param gridUnitParts the list of GridUnitPart instances
49: * @param row effective row this position belongs to
50: */
51: protected TableContentPosition(LayoutManager lm,
52: List gridUnitParts, EffRow row) {
53: super (lm);
54: this .gridUnitParts = gridUnitParts;
55: this .row = row;
56: }
57:
58: /**
59: * Returns a flag for this GridUnit.
60: * @param which the requested flag
61: * @return the value of the flag
62: */
63: public boolean getFlag(int which) {
64: return (flags & (1 << which)) != 0;
65: }
66:
67: /**
68: * Sets a flag on a GridUnit.
69: * @param which the flag to set
70: * @param value the new value for the flag
71: */
72: public void setFlag(int which, boolean value) {
73: if (value) {
74: flags |= (1 << which); //set flag
75: } else {
76: flags &= ~(1 << which); //clear flag
77: }
78: }
79:
80: public boolean generatesAreas() {
81: return true;
82: }
83:
84: public String toString() {
85: StringBuffer sb = new StringBuffer("TableContentPosition:");
86: sb.append(getIndex());
87: sb.append("[");
88: sb.append(row.getIndex()).append("/");
89: sb.append(getFlag(FIRST_IN_ROWGROUP) ? "F" : "-");
90: sb.append(getFlag(LAST_IN_ROWGROUP) ? "L" : "-").append("]");
91: sb.append("(");
92: sb.append(gridUnitParts);
93: sb.append(")");
94: return sb.toString();
95: }
96: }
|