001: /*
002: * This file is part of the Echo Web Application Framework (hereinafter "Echo").
003: * Copyright (C) 2002-2005 NextApp, Inc.
004: *
005: * Version: MPL 1.1/GPL 2.0/LGPL 2.1
006: *
007: * The contents of this file are subject to the Mozilla Public License Version
008: * 1.1 (the "License"); you may not use this file except in compliance with
009: * the License. You may obtain a copy of the License at
010: * http://www.mozilla.org/MPL/
011: *
012: * Software distributed under the License is distributed on an "AS IS" basis,
013: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
014: * for the specific language governing rights and limitations under the
015: * License.
016: *
017: * Alternatively, the contents of this file may be used under the terms of
018: * either the GNU General Public License Version 2 or later (the "GPL"), or
019: * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
020: * in which case the provisions of the GPL or the LGPL are applicable instead
021: * of those above. If you wish to allow use of your version of this file only
022: * under the terms of either the GPL or the LGPL, and not to allow others to
023: * use your version of this file under the terms of the MPL, indicate your
024: * decision by deleting the provisions above and replace them with the notice
025: * and other provisions required by the GPL or the LGPL. If you do not delete
026: * the provisions above, a recipient may use your version of this file under
027: * the terms of any one of the MPL, the GPL or the LGPL.
028: */
029:
030: package nextapp.echo2.app;
031:
032: import java.io.Serializable;
033:
034: /**
035: * A property object which describes the alignment or positioning of a
036: * particular item relative to others.
037: */
038: public class Alignment implements Serializable {
039:
040: /**
041: * A predefined alignment instance specifying left horizontal alignment and default vertical alignment.
042: */
043: public static final Alignment ALIGN_LEFT = new Alignment(
044: Alignment.LEFT, Alignment.DEFAULT);
045:
046: /**
047: * A predefined alignment instance specifying center horizontal alignment and default vertical alignment.
048: */
049: public static final Alignment ALIGN_CENTER = new Alignment(
050: Alignment.CENTER, Alignment.DEFAULT);
051:
052: /**
053: * A predefined alignment instance specifying right horizontal alignment and default vertical alignment.
054: */
055: public static final Alignment ALIGN_RIGHT = new Alignment(
056: Alignment.RIGHT, Alignment.DEFAULT);
057:
058: /**
059: * A predefined alignment instance specifying default horizontal alignment and top vertical alignment.
060: */
061: public static final Alignment ALIGN_TOP = new Alignment(
062: Alignment.DEFAULT, Alignment.TOP);
063:
064: /**
065: * A predefined alignment instance specifying default horizontal alignment and bottom vertical alignment.
066: */
067: public static final Alignment ALIGN_BOTTOM = new Alignment(
068: Alignment.DEFAULT, Alignment.BOTTOM);
069:
070: /**
071: * Specifies default alignment.
072: */
073: public static final int DEFAULT = 0;
074:
075: /**
076: * Specifies leading alignment (left in LTR languages, right in RTL languages).
077: */
078: public static final int LEADING = 1;
079:
080: /**
081: * Specifies trailing alignment (right in LTR languages, left in RTL languages).
082: */
083: public static final int TRAILING = 2;
084:
085: /**
086: * Specifies left alignment.
087: */
088: public static final int LEFT = 3;
089:
090: /**
091: * Specifies center alignment.
092: */
093: public static final int CENTER = 4;
094:
095: /**
096: * Specifies right alignment.
097: */
098: public static final int RIGHT = 5;
099:
100: /**
101: * Specifies top alignment.
102: */
103: public static final int TOP = 6;
104:
105: /**
106: * Specifies bottom alignment.
107: */
108: public static final int BOTTOM = 7;
109:
110: private int horizontal;
111: private int vertical;
112:
113: /**
114: * Creates a new <code>Alignment</code>.
115: *
116: * @param horizontal The horizontal alignment setting, one of the
117: * following values:
118: * <ul>
119: * <li><code>DEFAULT</code></li>
120: * <li><code>LEADING</code></li>
121: * <li><code>TRAILING</code></li>
122: * <li><code>LEFT</code></li>
123: * <li><code>CENTER</code></li>
124: * <li><code>RIGHT</code></li>
125: * </ul>
126: * @param vertical The vertical alignment setting, one of the
127: * following values:
128: * <ul>
129: * <li><code>DEFAULT</code></li>
130: * <li><code>TOP</code></li>
131: * <li><code>CENTER</code></li>
132: * <li><code>BOTTOM</code></li>
133: * </ul>
134: */
135: public Alignment(int horizontal, int vertical) {
136: super ();
137: this .horizontal = horizontal;
138: this .vertical = vertical;
139: }
140:
141: /**
142: * @see java.lang.Object#equals(java.lang.Object)
143: */
144: public boolean equals(Object o) {
145: if (!(o instanceof Alignment)) {
146: return false;
147: }
148: Alignment that = (Alignment) o;
149: return this .horizontal == that.horizontal
150: && this .vertical == that.vertical;
151: }
152:
153: /**
154: * Returns the horizontal setting of this <code>Alignment</code>.
155: *
156: * @return the horizontal setting of this <code>Alignment</code>,
157: * one of the following values:
158: * <ul>
159: * <li><code>DEFAULT</code></li>
160: * <li><code>LEADING</code></li>
161: * <li><code>TRAILING</code></li>
162: * <li><code>LEFT</code></li>
163: * <li><code>CENTER</code></li>
164: * <li><code>RIGHT</code></li>
165: * </ul>
166: */
167: public int getHorizontal() {
168: return horizontal;
169: }
170:
171: /**
172: * Returns the vertical setting of this <code>Alignment</code>.
173: *
174: * @return the vertical setting of this <code>Alignment</code>,
175: * one of the following values:
176: * <ul>
177: * <li><code>DEFAULT</code></li>
178: * <li><code>TOP</code></li>
179: * <li><code>CENTER</code></li>
180: * <li><code>BOTTOM</code></li>
181: * </ul>
182: */
183: public int getVertical() {
184: return vertical;
185: }
186: }
|