KickJava   Java API By Example, From Geeks To Geeks.

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


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: Position.java 426576 2006-07-28 15:44:37Z jeremias $ */
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     public void setIndex(int value) {
48         this.index = value;
49     }
50     
51     public int getIndex() {
52         return this.index;
53     }
54     
55     public String JavaDoc getShortLMName() {
56         if (getLM() != null) {
57             String JavaDoc lm = getLM().toString();
58             int idx = lm.lastIndexOf('.');
59             if (idx >= 0 && lm.indexOf('@') > 0) {
60                 return(lm.substring(idx + 1));
61             } else {
62                 return lm;
63             }
64         } else {
65             return "null";
66         }
67     }
68     
69     /** @see java.lang.Object#toString() */
70     public String JavaDoc toString() {
71         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
72         sb.append("Position:").append(getIndex()).append("(");
73         sb.append(getShortLMName());
74         sb.append(")");
75         return sb.toString();
76     }
77 }
78
79
Popular Tags