001 /* ===========================================================
002 * JFreeChart : a free chart library for the Java(tm) platform
003 * ===========================================================
004 *
005 * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
006 *
007 * Project Info: http://www.jfree.org/jfreechart/index.html
008 *
009 * This library is free software; you can redistribute it and/or modify it
010 * under the terms of the GNU Lesser General Public License as published by
011 * the Free Software Foundation; either version 2.1 of the License, or
012 * (at your option) any later version.
013 *
014 * This library is distributed in the hope that it will be useful, but
015 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
016 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
017 * License for more details.
018 *
019 * You should have received a copy of the GNU Lesser General Public
020 * License along with this library; if not, write to the Free Software
021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
022 * USA.
023 *
024 * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
025 * in the United States and other countries.]
026 *
027 * --------------------
028 * ItemLabelAnchor.java
029 * --------------------
030 * (C) Copyright 2003-2005, by Object Refinery Limited.
031 *
032 * Original Author: David Gilbert (for Object Refinery Limited);
033 * Contributor(s): -;
034 *
035 * $Id: ItemLabelAnchor.java,v 1.5.2.1 2005/10/25 20:49:02 mungady Exp $
036 *
037 * Changes
038 * -------
039 * 29-Apr-2003 : Version 1 (DG);
040 * 19-Feb-2004 : Moved to org.jfree.chart.labels package, added readResolve()
041 * method (DG);
042 * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0
043 * release (DG);
044 *
045 */
046
047 package org.jfree.chart.labels;
048
049 import java.io.ObjectStreamException;
050 import java.io.Serializable;
051
052 /**
053 * An enumeration of the positions that a value label can take, relative to an
054 * item in a {@link org.jfree.chart.plot.CategoryPlot}.
055 */
056 public final class ItemLabelAnchor implements Serializable {
057
058 /** For serialization. */
059 private static final long serialVersionUID = -1233101616128695658L;
060
061 /** CENTER. */
062 public static final ItemLabelAnchor CENTER
063 = new ItemLabelAnchor("ItemLabelAnchor.CENTER");
064
065 /** INSIDE1. */
066 public static final ItemLabelAnchor INSIDE1
067 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE1");
068
069 /** INSIDE2. */
070 public static final ItemLabelAnchor INSIDE2
071 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE2");
072
073 /** INSIDE3. */
074 public static final ItemLabelAnchor INSIDE3
075 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE3");
076
077 /** INSIDE4. */
078 public static final ItemLabelAnchor INSIDE4
079 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE4");
080
081 /** INSIDE5. */
082 public static final ItemLabelAnchor INSIDE5
083 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE5");
084
085 /** INSIDE6. */
086 public static final ItemLabelAnchor INSIDE6
087 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE6");
088
089 /** INSIDE7. */
090 public static final ItemLabelAnchor INSIDE7
091 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE7");
092
093 /** INSIDE8. */
094 public static final ItemLabelAnchor INSIDE8
095 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE8");
096
097 /** INSIDE9. */
098 public static final ItemLabelAnchor INSIDE9
099 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE9");
100
101 /** INSIDE10. */
102 public static final ItemLabelAnchor INSIDE10
103 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE10");
104
105 /** INSIDE11. */
106 public static final ItemLabelAnchor INSIDE11
107 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE11");
108
109 /** INSIDE12. */
110 public static final ItemLabelAnchor INSIDE12
111 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE12");
112
113 /** OUTSIDE1. */
114 public static final ItemLabelAnchor OUTSIDE1
115 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE1");
116
117 /** OUTSIDE2. */
118 public static final ItemLabelAnchor OUTSIDE2
119 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE2");
120
121 /** OUTSIDE3. */
122 public static final ItemLabelAnchor OUTSIDE3
123 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE3");
124
125 /** OUTSIDE4. */
126 public static final ItemLabelAnchor OUTSIDE4
127 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE4");
128
129 /** OUTSIDE5. */
130 public static final ItemLabelAnchor OUTSIDE5
131 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE5");
132
133 /** OUTSIDE6. */
134 public static final ItemLabelAnchor OUTSIDE6
135 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE6");
136
137 /** OUTSIDE7. */
138 public static final ItemLabelAnchor OUTSIDE7
139 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE7");
140
141 /** OUTSIDE8. */
142 public static final ItemLabelAnchor OUTSIDE8
143 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE8");
144
145 /** OUTSIDE9. */
146 public static final ItemLabelAnchor OUTSIDE9
147 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE9");
148
149 /** OUTSIDE10. */
150 public static final ItemLabelAnchor OUTSIDE10
151 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE10");
152
153 /** OUTSIDE11. */
154 public static final ItemLabelAnchor OUTSIDE11
155 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE11");
156
157 /** OUTSIDE12. */
158 public static final ItemLabelAnchor OUTSIDE12
159 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE12");
160
161 /** The name. */
162 private String name;
163
164 /**
165 * Private constructor.
166 *
167 * @param name the name.
168 */
169 private ItemLabelAnchor(String name) {
170 this.name = name;
171 }
172
173 /**
174 * Returns a string representing the object.
175 *
176 * @return The string.
177 */
178 public String toString() {
179 return this.name;
180 }
181
182 /**
183 * Returns <code>true</code> if this object is equal to the specified
184 * object, and <code>false</code> otherwise.
185 *
186 * @param o the other object.
187 *
188 * @return A boolean.
189 */
190 public boolean equals(Object o) {
191
192 if (this == o) {
193 return true;
194 }
195 if (!(o instanceof ItemLabelAnchor)) {
196 return false;
197 }
198
199 ItemLabelAnchor order = (ItemLabelAnchor) o;
200 if (!this.name.equals(order.toString())) {
201 return false;
202 }
203
204 return true;
205
206 }
207
208 /**
209 * Ensures that serialization returns the unique instances.
210 *
211 * @return The object.
212 *
213 * @throws ObjectStreamException if there is a problem.
214 */
215 private Object readResolve() throws ObjectStreamException {
216 ItemLabelAnchor result = null;
217 if (this.equals(ItemLabelAnchor.CENTER)) {
218 result = ItemLabelAnchor.CENTER;
219 }
220 else if (this.equals(ItemLabelAnchor.INSIDE1)) {
221 result = ItemLabelAnchor.INSIDE1;
222 }
223 else if (this.equals(ItemLabelAnchor.INSIDE2)) {
224 result = ItemLabelAnchor.INSIDE2;
225 }
226 else if (this.equals(ItemLabelAnchor.INSIDE3)) {
227 result = ItemLabelAnchor.INSIDE3;
228 }
229 else if (this.equals(ItemLabelAnchor.INSIDE4)) {
230 result = ItemLabelAnchor.INSIDE4;
231 }
232 else if (this.equals(ItemLabelAnchor.INSIDE5)) {
233 result = ItemLabelAnchor.INSIDE5;
234 }
235 else if (this.equals(ItemLabelAnchor.INSIDE6)) {
236 result = ItemLabelAnchor.INSIDE6;
237 }
238 else if (this.equals(ItemLabelAnchor.INSIDE7)) {
239 result = ItemLabelAnchor.INSIDE7;
240 }
241 else if (this.equals(ItemLabelAnchor.INSIDE8)) {
242 result = ItemLabelAnchor.INSIDE8;
243 }
244 else if (this.equals(ItemLabelAnchor.INSIDE9)) {
245 result = ItemLabelAnchor.INSIDE9;
246 }
247 else if (this.equals(ItemLabelAnchor.INSIDE10)) {
248 result = ItemLabelAnchor.INSIDE10;
249 }
250 else if (this.equals(ItemLabelAnchor.INSIDE11)) {
251 result = ItemLabelAnchor.INSIDE11;
252 }
253 else if (this.equals(ItemLabelAnchor.INSIDE12)) {
254 result = ItemLabelAnchor.INSIDE12;
255 }
256 else if (this.equals(ItemLabelAnchor.OUTSIDE1)) {
257 result = ItemLabelAnchor.OUTSIDE1;
258 }
259 else if (this.equals(ItemLabelAnchor.OUTSIDE2)) {
260 result = ItemLabelAnchor.OUTSIDE2;
261 }
262 else if (this.equals(ItemLabelAnchor.OUTSIDE3)) {
263 result = ItemLabelAnchor.OUTSIDE3;
264 }
265 else if (this.equals(ItemLabelAnchor.OUTSIDE4)) {
266 result = ItemLabelAnchor.OUTSIDE4;
267 }
268 else if (this.equals(ItemLabelAnchor.OUTSIDE5)) {
269 result = ItemLabelAnchor.OUTSIDE5;
270 }
271 else if (this.equals(ItemLabelAnchor.OUTSIDE6)) {
272 result = ItemLabelAnchor.OUTSIDE6;
273 }
274 else if (this.equals(ItemLabelAnchor.OUTSIDE7)) {
275 result = ItemLabelAnchor.OUTSIDE7;
276 }
277 else if (this.equals(ItemLabelAnchor.OUTSIDE8)) {
278 result = ItemLabelAnchor.OUTSIDE8;
279 }
280 else if (this.equals(ItemLabelAnchor.OUTSIDE9)) {
281 result = ItemLabelAnchor.OUTSIDE9;
282 }
283 else if (this.equals(ItemLabelAnchor.OUTSIDE10)) {
284 result = ItemLabelAnchor.OUTSIDE10;
285 }
286 else if (this.equals(ItemLabelAnchor.OUTSIDE11)) {
287 result = ItemLabelAnchor.OUTSIDE11;
288 }
289 else if (this.equals(ItemLabelAnchor.OUTSIDE12)) {
290 result = ItemLabelAnchor.OUTSIDE12;
291 }
292 return result;
293 }
294
295 }