KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.io.Serializable JavaDoc;
32
33 /**
34  * A representation of a simple border.
35  */

36 public class Border
37 implements Serializable JavaDoc {
38     
39     /**
40      * A border style that causes no border to be rendered.
41      */

42     public static final int STYLE_NONE = 0;
43     
44     /**
45      * A border style that causes a single solid monochrome border around an
46      * object.
47      */

48     public static final int STYLE_SOLID = 1;
49     
50     /**
51      * A border style that causes a simulated 3D border to be rendered, such
52      * that an object appears recessed.
53      */

54     public static final int STYLE_INSET = 2;
55     
56     /**
57      * A border style that causes a simulated 3D border to be rendered, such
58      * that an object appears raised.
59      */

60     public static final int STYLE_OUTSET = 3;
61     
62     /**
63      * A border style that causes a simulated 3D border to be rendered, such
64      * that the border appears to have been carved out.
65      */

66     public static final int STYLE_GROOVE = 4;
67     
68     /**
69      * A border style that causes a simulated 3D border to be rendered, such
70      * that the border appears as a ridge around an object.
71      */

72     public static final int STYLE_RIDGE = 5;
73     
74     /**
75      * A border style that creates two solid monochrome borders around an
76      * object.
77      */

78     public static final int STYLE_DOUBLE = 6;
79     
80     /**
81      * A border style that appears as a series of dots.
82      */

83     public static final int STYLE_DOTTED = 7;
84     
85     /**
86      * A border style that appears as a series of short line segments.
87      */

88     public static final int STYLE_DASHED = 8;
89
90     private Extent size;
91     private Color color;
92     private int style;
93     
94     /**
95      * Creates a new <code>Border</code> with a pixel-based size.
96      *
97      * @param sizePx the size of the border, in pixels
98      * @param color the color of the border
99      * @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 JavaDoc 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 }
218
Popular Tags