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: /**
23: * Represents a non-dividable part of a grid unit. Used by the table stepper.
24: */
25: class GridUnitPart {
26:
27: /** Primary grid unit */
28: protected PrimaryGridUnit pgu;
29: /** Index of the starting element of this part */
30: protected int start;
31: /** Index of the ending element of this part */
32: protected int end;
33:
34: /**
35: * Creates a new GridUnitPart.
36: * @param pgu Primary grid unit
37: * @param start starting element
38: * @param end ending element
39: */
40: protected GridUnitPart(PrimaryGridUnit pgu, int start, int end) {
41: this .pgu = pgu;
42: this .start = start;
43: this .end = end;
44: }
45:
46: /** @return true if this part is the first part of a cell */
47: public boolean isFirstPart() {
48: return (start == 0);
49: }
50:
51: /** @return true if this part is the last part of a cell */
52: public boolean isLastPart() {
53: return (end >= 0 && end == pgu.getElements().size() - 1);
54: }
55:
56: /** @see java.lang.Object#toString() */
57: public String toString() {
58: StringBuffer sb = new StringBuffer("Part: ");
59: sb.append(start).append("-").append(end);
60: sb.append(" [").append(isFirstPart() ? "F" : "-").append(
61: isLastPart() ? "L" : "-");
62: sb.append("] ").append(pgu);
63: return sb.toString();
64: }
65:
66: boolean mustKeepWithPrevious() {
67: return pgu.getFlag(GridUnit.KEEP_WITH_PREVIOUS_PENDING)
68: || (pgu.getRow() != null && pgu.getRow()
69: .mustKeepWithPrevious());
70: }
71:
72: }
|