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 representation of a simple border.
036: */
037: public class Border implements Serializable {
038:
039: /**
040: * A border style that causes no border to be rendered.
041: */
042: public static final int STYLE_NONE = 0;
043:
044: /**
045: * A border style that causes a single solid monochrome border around an
046: * object.
047: */
048: public static final int STYLE_SOLID = 1;
049:
050: /**
051: * A border style that causes a simulated 3D border to be rendered, such
052: * that an object appears recessed.
053: */
054: public static final int STYLE_INSET = 2;
055:
056: /**
057: * A border style that causes a simulated 3D border to be rendered, such
058: * that an object appears raised.
059: */
060: public static final int STYLE_OUTSET = 3;
061:
062: /**
063: * A border style that causes a simulated 3D border to be rendered, such
064: * that the border appears to have been carved out.
065: */
066: public static final int STYLE_GROOVE = 4;
067:
068: /**
069: * A border style that causes a simulated 3D border to be rendered, such
070: * that the border appears as a ridge around an object.
071: */
072: public static final int STYLE_RIDGE = 5;
073:
074: /**
075: * A border style that creates two solid monochrome borders around an
076: * object.
077: */
078: public static final int STYLE_DOUBLE = 6;
079:
080: /**
081: * A border style that appears as a series of dots.
082: */
083: public static final int STYLE_DOTTED = 7;
084:
085: /**
086: * A border style that appears as a series of short line segments.
087: */
088: public static final int STYLE_DASHED = 8;
089:
090: private Extent size;
091: private Color color;
092: private int style;
093:
094: /**
095: * Creates a new <code>Border</code> with a pixel-based size.
096: *
097: * @param sizePx the size of the border, in pixels
098: * @param color the color of the border
099: * @param style the style of the border, one of the following constant values:
100: * <ul>
101: * <li><code>STYLE_NONE</code></li>
102: * <li><code>STYLE_SOLID</code></li>
103: * <li><code>STYLE_INSET</code></li>
104: * <li><code>STYLE_OUTSET</code></li>
105: * <li><code>STYLE_GROOVE</code></li>
106: * <li><code>STYLE_RIDGE</code></li>
107: * <li><code>STYLE_DOUBLE</code></li>
108: * <li><code>STYLE_DOTTED</code></li>
109: * <li><code>STYLE_DASHED</code></li>
110: * </ul>
111: */
112: public Border(int sizePx, Color color, int style) {
113: this (new Extent(sizePx), color, style);
114: }
115:
116: /**
117: * Creates a new <code>Border</code>.
118: *
119: * @param size the size of the border (this property only supports
120: * <code>Extent</code>s with fixed (i.e., not percent) units)
121: * @param color the color of the border
122: * @param style the style of the border, one of the following constant
123: * values:
124: * <ul>
125: * <li><code>STYLE_NONE</code></li>
126: * <li><code>STYLE_SOLID</code></li>
127: * <li><code>STYLE_INSET</code></li>
128: * <li><code>STYLE_OUTSET</code></li>
129: * <li><code>STYLE_GROOVE</code></li>
130: * <li><code>STYLE_RIDGE</code></li>
131: * <li><code>STYLE_DOUBLE</code></li>
132: * <li><code>STYLE_DOTTED</code></li>
133: * <li><code>STYLE_DASHED</code></li>
134: * </ul>
135: */
136: public Border(Extent size, Color color, int style) {
137: super ();
138: this .size = size;
139: this .color = color;
140: this .style = style;
141: }
142:
143: /**
144: * @see java.lang.Object#equals(java.lang.Object)
145: */
146: public boolean equals(Object o) {
147: if (this == o) {
148: return true;
149: }
150: if (!(o instanceof Border)) {
151: return false;
152: }
153: Border that = (Border) o;
154: if (this .style != that.style) {
155: return false;
156: }
157: if (color == null) {
158: if (that.color != null) {
159: return false;
160: }
161: } else {
162: if (!this .color.equals(that.color)) {
163: return false;
164: }
165: }
166: if (size == null) {
167: if (that.size != null) {
168: return false;
169: }
170: } else {
171: if (!this .size.equals(that.size)) {
172: return false;
173: }
174: }
175: return true;
176: }
177:
178: /**
179: * Returns the border color.
180: *
181: * @return the color
182: */
183: public Color getColor() {
184: return color;
185: }
186:
187: /**
188: * Returns the border size.
189: * This property only supports <code>Extent</code>s with
190: * fixed (i.e., not percent) units.
191: *
192: * @return the size
193: */
194: public Extent getSize() {
195: return size;
196: }
197:
198: /**
199: * Returns the border style.
200: *
201: * @return the style, one of the following values:
202: * <ul>
203: * <li><code>STYLE_NONE</code></li>
204: * <li><code>STYLE_SOLID</code></li>
205: * <li><code>STYLE_INSET</code></li>
206: * <li><code>STYLE_OUTSET</code></li>
207: * <li><code>STYLE_GROOVE</code></li>
208: * <li><code>STYLE_RIDGE</code></li>
209: * <li><code>STYLE_DOUBLE</code></li>
210: * <li><code>STYLE_DOTTED</code></li>
211: * <li><code>STYLE_DASHED</code></li>
212: * </ul>
213: */
214: public int getStyle() {
215: return style;
216: }
217: }
|