KickJava   Java API By Example, From Geeks To Geeks.

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


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  * GradientPaintTransformType.java
29  * -------------------------------
30  * (C) Copyright 2003-2005, by Object Refinery Limited.
31  *
32  * Original Author: David Gilbert (for Object Refinery Limited);
33  * Contributor(s): -;
34  *
35  * $Id: GradientPaintTransformType.java,v 1.4 2005/10/18 13:18:34 mungady Exp $
36  *
37  * Changes:
38  * --------
39  * 21-Oct-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  * Represents a type of transform for a <code>GradientPaint</code>.
50  *
51  * @author David Gilbert
52  */

53 public final class GradientPaintTransformType implements Serializable JavaDoc {
54
55     /** For serialization. */
56     private static final long serialVersionUID = 8331561784933982450L;
57     
58     /** Vertical. */
59     public static final GradientPaintTransformType VERTICAL
60         = new GradientPaintTransformType("GradientPaintTransformType.VERTICAL");
61
62     /** Horizontal. */
63     public static final GradientPaintTransformType HORIZONTAL
64         = new GradientPaintTransformType(
65                 "GradientPaintTransformType.HORIZONTAL");
66
67     /** Center/vertical. */
68     public static final GradientPaintTransformType CENTER_VERTICAL
69         = new GradientPaintTransformType(
70                 "GradientPaintTransformType.CENTER_VERTICAL");
71
72     /** Center/horizontal. */
73     public static final GradientPaintTransformType CENTER_HORIZONTAL
74         = new GradientPaintTransformType(
75                 "GradientPaintTransformType.CENTER_HORIZONTAL");
76         
77     /** The name. */
78     private String JavaDoc name;
79
80     /**
81      * Private constructor.
82      *
83      * @param name the name.
84      */

85     private GradientPaintTransformType(final String JavaDoc name) {
86         this.name = name;
87     }
88
89     /**
90      * Returns a string representing the object.
91      *
92      * @return The string.
93      */

94     public String JavaDoc toString() {
95         return this.name;
96     }
97
98     /**
99      * Returns <code>true</code> if this object is equal to the specified
100      * object, and <code>false</code> otherwise.
101      *
102      * @param o the other object.
103      *
104      * @return A boolean.
105      */

106     public boolean equals(final Object JavaDoc o) {
107
108         if (this == o) {
109             return true;
110         }
111         if (!(o instanceof GradientPaintTransformType)) {
112             return false;
113         }
114
115         final GradientPaintTransformType t = (GradientPaintTransformType) o;
116         if (!this.name.equals(t.name)) {
117             return false;
118         }
119
120         return true;
121     }
122
123     /**
124      * Returns a hash code value for the object.
125      *
126      * @return the hashcode
127      */

128     public int hashCode() {
129         return this.name.hashCode();
130     }
131
132     /**
133      * Ensures that serialization returns the unique instances.
134      *
135      * @return The object.
136      *
137      * @throws ObjectStreamException if there is a problem.
138      */

139     private Object JavaDoc readResolve() throws ObjectStreamException JavaDoc {
140         GradientPaintTransformType result = null;
141         if (this.equals(GradientPaintTransformType.HORIZONTAL)) {
142             result = GradientPaintTransformType.HORIZONTAL;
143         }
144         else if (this.equals(GradientPaintTransformType.VERTICAL)) {
145             result = GradientPaintTransformType.VERTICAL;
146         }
147         else if (this.equals(GradientPaintTransformType.CENTER_HORIZONTAL)) {
148             result = GradientPaintTransformType.CENTER_HORIZONTAL;
149         }
150         else if (this.equals(GradientPaintTransformType.CENTER_VERTICAL)) {
151             result = GradientPaintTransformType.CENTER_VERTICAL;
152         }
153         return result;
154     }
155     
156 }
157
158
Popular Tags