KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > nextapp > echo2 > app > Alignment


1 /*
2  * This file is part of the Echo Web Application Framework (hereinafter "Echo").
3  * Copyright (C) 2002-2005 NextApp, Inc.
4  *
5  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6  *
7  * The contents of this file are subject to the Mozilla Public License Version
8  * 1.1 (the "License"); you may not use this file except in compliance with
9  * the License. You may obtain a copy of the License at
10  * http://www.mozilla.org/MPL/
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * Alternatively, the contents of this file may be used under the terms of
18  * either the GNU General Public License Version 2 or later (the "GPL"), or
19  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20  * in which case the provisions of the GPL or the LGPL are applicable instead
21  * of those above. If you wish to allow use of your version of this file only
22  * under the terms of either the GPL or the LGPL, and not to allow others to
23  * use your version of this file under the terms of the MPL, indicate your
24  * decision by deleting the provisions above and replace them with the notice
25  * and other provisions required by the GPL or the LGPL. If you do not delete
26  * the provisions above, a recipient may use your version of this file under
27  * the terms of any one of the MPL, the GPL or the LGPL.
28  */

29
30 package nextapp.echo2.app;
31
32 import java.io.Serializable JavaDoc;
33
34 /**
35  * A property object which describes the alignment or positioning of a
36  * particular item relative to others.
37  */

38 public class Alignment
39 implements Serializable JavaDoc {
40     
41     /**
42      * A predefined alignment instance specifying left horizontal alignment and default vertical alignment.
43      */

44     public static final Alignment ALIGN_LEFT = new Alignment(Alignment.LEFT, Alignment.DEFAULT);
45     
46     /**
47      * A predefined alignment instance specifying center horizontal alignment and default vertical alignment.
48      */

49     public static final Alignment ALIGN_CENTER = new Alignment(Alignment.CENTER, Alignment.DEFAULT);
50
51     /**
52      * A predefined alignment instance specifying right horizontal alignment and default vertical alignment.
53      */

54     public static final Alignment ALIGN_RIGHT = new Alignment(Alignment.RIGHT, Alignment.DEFAULT);
55     
56     /**
57      * A predefined alignment instance specifying default horizontal alignment and top vertical alignment.
58      */

59     public static final Alignment ALIGN_TOP = new Alignment(Alignment.DEFAULT, Alignment.TOP);
60     
61     /**
62      * A predefined alignment instance specifying default horizontal alignment and bottom vertical alignment.
63      */

64     public static final Alignment ALIGN_BOTTOM = new Alignment(Alignment.DEFAULT, Alignment.BOTTOM);
65     
66     /**
67      * Specifies default alignment.
68      */

69     public static final int DEFAULT = 0;
70     
71     /**
72      * Specifies leading alignment (left in LTR languages, right in RTL languages).
73      */

74     public static final int LEADING = 1;
75
76     /**
77      * Specifies trailing alignment (right in LTR languages, left in RTL languages).
78      */

79     public static final int TRAILING = 2;
80     
81     /**
82      * Specifies left alignment.
83      */

84     public static final int LEFT = 3;
85
86     /**
87      * Specifies center alignment.
88      */

89     public static final int CENTER = 4;
90
91     /**
92      * Specifies right alignment.
93      */

94     public static final int RIGHT = 5;
95     
96     /**
97      * Specifies top alignment.
98      */

99     public static final int TOP = 6;
100
101     /**
102      * Specifies bottom alignment.
103      */

104     public static final int BOTTOM = 7;
105     
106     private int horizontal;
107     private int vertical;
108     
109     /**
110      * Creates a new <code>Alignment</code>.
111      *
112      * @param horizontal The horizontal alignment setting, one of the
113      * following values:
114      * <ul>
115      * <li><code>DEFAULT</code></li>
116      * <li><code>LEADING</code></li>
117      * <li><code>TRAILING</code></li>
118      * <li><code>LEFT</code></li>
119      * <li><code>CENTER</code></li>
120      * <li><code>RIGHT</code></li>
121      * </ul>
122      * @param vertical The vertical alignment setting, one of the
123      * following values:
124      * <ul>
125      * <li><code>DEFAULT</code></li>
126      * <li><code>TOP</code></li>
127      * <li><code>CENTER</code></li>
128      * <li><code>BOTTOM</code></li>
129      * </ul>
130      */

131     public Alignment (int horizontal, int vertical) {
132         super();
133         this.horizontal = horizontal;
134         this.vertical = vertical;
135     }
136     
137     /**
138      * @see java.lang.Object#equals(java.lang.Object)
139      */

140     public boolean equals(Object JavaDoc o) {
141         if (!(o instanceof Alignment)) {
142             return false;
143         }
144         Alignment that = (Alignment) o;
145         return this.horizontal == that.horizontal && this.vertical == that.vertical;
146     }
147     
148     /**
149      * Returns the horizontal setting of this <code>Alignment</code>.
150      *
151      * @return the horizontal setting of this <code>Alignment</code>,
152      * one of the following values:
153      * <ul>
154      * <li><code>DEFAULT</code></li>
155      * <li><code>LEADING</code></li>
156      * <li><code>TRAILING</code></li>
157      * <li><code>LEFT</code></li>
158      * <li><code>CENTER</code></li>
159      * <li><code>RIGHT</code></li>
160      * </ul>
161      */

162     public int getHorizontal() {
163         return horizontal;
164     }
165     
166     /**
167      * Returns the vertical setting of this <code>Alignment</code>.
168      *
169      * @return the vertical setting of this <code>Alignment</code>,
170      * one of the following values:
171      * <ul>
172      * <li><code>DEFAULT</code></li>
173      * <li><code>TOP</code></li>
174      * <li><code>CENTER</code></li>
175      * <li><code>BOTTOM</code></li>
176      * </ul>
177      */

178     public int getVertical() {
179         return vertical;
180     }
181 }
182
Popular Tags