KickJava   Java API By Example, From Geeks To Geeks.

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


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: KnuthElement.java 426576 2006-07-28 15:44:37Z jeremias $ */
19
20 package org.apache.fop.layoutmgr;
21
22 /**
23  * This is the super class for KnuthBox, KnuthGlue and KnuthPenalty.
24  *
25  * It stores information common to all sub classes, and the methods to get it:
26  * the width, a Position and a boolean marking KnuthElements used for some
27  * special feature (for example, the additional elements used to represent
28  * a space when text alignment is right, left or center).
29  */

30 public abstract class KnuthElement extends ListElement {
31
32     /** The value used as an infinite indicator. */
33     public static final int INFINITE = 1000;
34
35     private int width;
36     private boolean bIsAuxiliary;
37
38     /**
39      * Create a new KnuthElement.
40      * This class being abstract, this can be called only by subclasses.
41      *
42      * @param w the width of this element
43      * @param pos the Position stored in this element
44      * @param bAux is this an auxiliary element?
45      */

46     protected KnuthElement(int w, Position pos, boolean bAux) {
47         super(pos);
48         width = w;
49         bIsAuxiliary = bAux;
50     }
51
52     /** @return true if this element is an auxiliary one. */
53     public boolean isAuxiliary() {
54         return bIsAuxiliary;
55     }
56
57     /** @return the width of this element. */
58     public int getW() {
59         return width;
60     }
61
62     /** @return the penalty value of this element, if applicable. */
63     public int getP() {
64         throw new RuntimeException JavaDoc("Element is not a penalty");
65     }
66
67     /** @return the stretch value of this element, if applicable. */
68     public int getY() {
69         throw new RuntimeException JavaDoc("Element is not a glue");
70     }
71
72     /** @return the shrink value of this element, if applicable. */
73     public int getZ() {
74         throw new RuntimeException JavaDoc("Element is not a glue");
75     }
76     
77     /** @see org.apache.fop.layoutmgr.ListElement#isUnresolvedElement() */
78     public boolean isUnresolvedElement() {
79         return false;
80     }
81
82 }
83
Popular Tags