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: Position.java 519975 2007-03-19 15:40:31Z vhennebert $ */
19:
20: package org.apache.fop.layoutmgr;
21:
22: public class Position {
23:
24: private LayoutManager layoutManager;
25: private int index = -1;
26:
27: public Position(LayoutManager lm) {
28: layoutManager = lm;
29: }
30:
31: public LayoutManager getLM() {
32: return layoutManager;
33: }
34:
35: /**
36: * Overridden by NonLeafPosition to return the Position of its
37: * child LM.
38: */
39: public Position getPosition() {
40: return null;
41: }
42:
43: public boolean generatesAreas() {
44: return false;
45: }
46:
47: /**
48: * Sets the index of this position in the sequence of Position elements.
49: *
50: * @param value this position's index
51: */
52: public void setIndex(int value) {
53: this .index = value;
54: }
55:
56: /**
57: * Returns the index of this position in the sequence of Position elements.
58: *
59: * @return the index of this position in the sequence of Position elements
60: */
61: public int getIndex() {
62: return this .index;
63: }
64:
65: public String getShortLMName() {
66: if (getLM() != null) {
67: String lm = getLM().toString();
68: int idx = lm.lastIndexOf('.');
69: if (idx >= 0 && lm.indexOf('@') > 0) {
70: return (lm.substring(idx + 1));
71: } else {
72: return lm;
73: }
74: } else {
75: return "null";
76: }
77: }
78:
79: /** @see java.lang.Object#toString() */
80: public String toString() {
81: StringBuffer sb = new StringBuffer();
82: sb.append("Position:").append(getIndex()).append("(");
83: sb.append(getShortLMName());
84: sb.append(")");
85: return sb.toString();
86: }
87: }
|