KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfree > ui > Layer


1 /* ========================================================================
2  * JCommon : a free general purpose class library for the Java(tm) platform
3  * ========================================================================
4  *
5  * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
6  *
7  * Project Info: http://www.jfree.org/jcommon/index.html
8  *
9  * This library is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or
12  * (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17  * License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22  * USA.
23  *
24  * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
25  * in the United States and other countries.]
26  *
27  * ----------
28  * Layer.java
29  * ----------
30  * (C) Copyright 2003, 2004, by Object Refinery Limited.
31  *
32  * Original Author: David Gilbert (for Object Refinery Limited);
33  * Contributor(s): -;
34  *
35  * $Id: Layer.java,v 1.4 2005/10/18 13:18:34 mungady Exp $
36  *
37  * Changes:
38  * --------
39  * 17-Sep-2003 (DG);
40  *
41  */

42
43 package org.jfree.ui;
44
45 import java.io.ObjectStreamException JavaDoc;
46 import java.io.Serializable JavaDoc;
47
48 /**
49  * Used to indicate either the foreground or background layer.
50  *
51  * @author David Gilbert
52  */

53 public final class Layer implements Serializable JavaDoc {
54
55     /** For serialization. */
56     private static final long serialVersionUID = -1470104570733183430L;
57     
58     /** Foreground. */
59     public static final Layer FOREGROUND = new Layer("Layer.FOREGROUND");
60
61     /** Background. */
62     public static final Layer BACKGROUND = new Layer("Layer.BACKGROUND");
63
64     /** The name. */
65     private String JavaDoc name;
66
67     /**
68      * Private constructor.
69      *
70      * @param name the name.
71      */

72     private Layer(final String JavaDoc name) {
73         this.name = name;
74     }
75
76     /**
77      * Returns a string representing the object.
78      *
79      * @return The string.
80      */

81     public String JavaDoc toString() {
82         return this.name;
83     }
84
85     /**
86      * Returns <code>true</code> if this object is equal to the specified
87      * object, and <code>false</code> otherwise.
88      *
89      * @param o the other object.
90      *
91      * @return A boolean.
92      */

93     public boolean equals(final Object JavaDoc o) {
94
95         if (this == o) {
96             return true;
97         }
98         if (!(o instanceof Layer)) {
99             return false;
100         }
101
102         final Layer layer = (Layer) o;
103         if (!this.name.equals(layer.name)) {
104             return false;
105         }
106
107         return true;
108
109     }
110
111     /**
112      * Returns a hash code value for the object.
113      *
114      * @return the hashcode
115      */

116     public int hashCode() {
117         return this.name.hashCode();
118     }
119
120     /**
121      * Ensures that serialization returns the unique instances.
122      *
123      * @return The object.
124      *
125      * @throws ObjectStreamException if there is a problem.
126      */

127     private Object JavaDoc readResolve() throws ObjectStreamException JavaDoc {
128         Layer result = null;
129         if (this.equals(Layer.FOREGROUND)) {
130             result = Layer.FOREGROUND;
131         }
132         else if (this.equals(Layer.BACKGROUND)) {
133             result = Layer.BACKGROUND;
134         }
135         return result;
136     }
137     
138 }
139
140
Popular Tags