001    /* ===========================================================
002     * JFreeChart : a free chart library for the Java(tm) platform
003     * ===========================================================
004     *
005     * (C) Copyright 2000-2008, 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-2008, by Object Refinery Limited.
031     *
032     * Original Author:  David Gilbert (for Object Refinery Limited);
033     * Contributor(s):   -;
034     *
035     * Changes
036     * -------
037     * 29-Apr-2003 : Version 1 (DG);
038     * 19-Feb-2004 : Moved to org.jfree.chart.labels package, added readResolve()
039     *               method (DG);
040     * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0
041     *               release (DG);
042     *
043     */
044    
045    package org.jfree.chart.labels;
046    
047    import java.io.ObjectStreamException;
048    import java.io.Serializable;
049    
050    /**
051     * An enumeration of the positions that a value label can take, relative to an
052     * item in a {@link org.jfree.chart.plot.CategoryPlot}.
053     */
054    public final class ItemLabelAnchor implements Serializable {
055    
056        /** For serialization. */
057        private static final long serialVersionUID = -1233101616128695658L;
058    
059        /** CENTER. */
060        public static final ItemLabelAnchor CENTER
061            = new ItemLabelAnchor("ItemLabelAnchor.CENTER");
062    
063        /** INSIDE1. */
064        public static final ItemLabelAnchor INSIDE1
065            = new ItemLabelAnchor("ItemLabelAnchor.INSIDE1");
066    
067        /** INSIDE2. */
068        public static final ItemLabelAnchor INSIDE2
069            = new ItemLabelAnchor("ItemLabelAnchor.INSIDE2");
070    
071        /** INSIDE3. */
072        public static final ItemLabelAnchor INSIDE3
073            = new ItemLabelAnchor("ItemLabelAnchor.INSIDE3");
074    
075        /** INSIDE4. */
076        public static final ItemLabelAnchor INSIDE4
077            = new ItemLabelAnchor("ItemLabelAnchor.INSIDE4");
078    
079        /** INSIDE5. */
080        public static final ItemLabelAnchor INSIDE5
081            = new ItemLabelAnchor("ItemLabelAnchor.INSIDE5");
082    
083        /** INSIDE6. */
084        public static final ItemLabelAnchor INSIDE6
085            = new ItemLabelAnchor("ItemLabelAnchor.INSIDE6");
086    
087        /** INSIDE7. */
088        public static final ItemLabelAnchor INSIDE7
089            = new ItemLabelAnchor("ItemLabelAnchor.INSIDE7");
090    
091        /** INSIDE8. */
092        public static final ItemLabelAnchor INSIDE8
093            = new ItemLabelAnchor("ItemLabelAnchor.INSIDE8");
094    
095        /** INSIDE9. */
096        public static final ItemLabelAnchor INSIDE9
097            = new ItemLabelAnchor("ItemLabelAnchor.INSIDE9");
098    
099        /** INSIDE10. */
100        public static final ItemLabelAnchor INSIDE10
101            = new ItemLabelAnchor("ItemLabelAnchor.INSIDE10");
102    
103        /** INSIDE11. */
104        public static final ItemLabelAnchor INSIDE11
105            = new ItemLabelAnchor("ItemLabelAnchor.INSIDE11");
106    
107        /** INSIDE12. */
108        public static final ItemLabelAnchor INSIDE12
109            = new ItemLabelAnchor("ItemLabelAnchor.INSIDE12");
110    
111        /** OUTSIDE1. */
112        public static final ItemLabelAnchor OUTSIDE1
113            = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE1");
114    
115        /** OUTSIDE2. */
116        public static final ItemLabelAnchor OUTSIDE2
117            = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE2");
118    
119        /** OUTSIDE3. */
120        public static final ItemLabelAnchor OUTSIDE3
121            = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE3");
122    
123        /** OUTSIDE4. */
124        public static final ItemLabelAnchor OUTSIDE4
125            = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE4");
126    
127        /** OUTSIDE5. */
128        public static final ItemLabelAnchor OUTSIDE5
129            = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE5");
130    
131        /** OUTSIDE6. */
132        public static final ItemLabelAnchor OUTSIDE6
133            = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE6");
134    
135        /** OUTSIDE7. */
136        public static final ItemLabelAnchor OUTSIDE7
137            = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE7");
138    
139        /** OUTSIDE8. */
140        public static final ItemLabelAnchor OUTSIDE8
141            = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE8");
142    
143        /** OUTSIDE9. */
144        public static final ItemLabelAnchor OUTSIDE9
145            = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE9");
146    
147        /** OUTSIDE10. */
148        public static final ItemLabelAnchor OUTSIDE10
149            = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE10");
150    
151        /** OUTSIDE11. */
152        public static final ItemLabelAnchor OUTSIDE11
153            = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE11");
154    
155        /** OUTSIDE12. */
156        public static final ItemLabelAnchor OUTSIDE12
157            = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE12");
158    
159        /** The name. */
160        private String name;
161    
162        /**
163         * Private constructor.
164         *
165         * @param name  the name.
166         */
167        private ItemLabelAnchor(String name) {
168            this.name = name;
169        }
170    
171        /**
172         * Returns a string representing the object.
173         *
174         * @return The string.
175         */
176        public String toString() {
177            return this.name;
178        }
179    
180        /**
181         * Returns <code>true</code> if this object is equal to the specified
182         * object, and <code>false</code> otherwise.
183         *
184         * @param o  the other object.
185         *
186         * @return A boolean.
187         */
188        public boolean equals(Object o) {
189    
190            if (this == o) {
191                return true;
192            }
193            if (!(o instanceof ItemLabelAnchor)) {
194                return false;
195            }
196    
197            ItemLabelAnchor order = (ItemLabelAnchor) o;
198            if (!this.name.equals(order.toString())) {
199                return false;
200            }
201    
202            return true;
203    
204        }
205    
206        /**
207         * Ensures that serialization returns the unique instances.
208         *
209         * @return The object.
210         *
211         * @throws ObjectStreamException if there is a problem.
212         */
213        private Object readResolve() throws ObjectStreamException {
214            ItemLabelAnchor result = null;
215            if (this.equals(ItemLabelAnchor.CENTER)) {
216                result = ItemLabelAnchor.CENTER;
217            }
218            else if (this.equals(ItemLabelAnchor.INSIDE1)) {
219                result = ItemLabelAnchor.INSIDE1;
220            }
221            else if (this.equals(ItemLabelAnchor.INSIDE2)) {
222                result = ItemLabelAnchor.INSIDE2;
223            }
224            else if (this.equals(ItemLabelAnchor.INSIDE3)) {
225                result = ItemLabelAnchor.INSIDE3;
226            }
227            else if (this.equals(ItemLabelAnchor.INSIDE4)) {
228                result = ItemLabelAnchor.INSIDE4;
229            }
230            else if (this.equals(ItemLabelAnchor.INSIDE5)) {
231                result = ItemLabelAnchor.INSIDE5;
232            }
233            else if (this.equals(ItemLabelAnchor.INSIDE6)) {
234                result = ItemLabelAnchor.INSIDE6;
235            }
236            else if (this.equals(ItemLabelAnchor.INSIDE7)) {
237                result = ItemLabelAnchor.INSIDE7;
238            }
239            else if (this.equals(ItemLabelAnchor.INSIDE8)) {
240                result = ItemLabelAnchor.INSIDE8;
241            }
242            else if (this.equals(ItemLabelAnchor.INSIDE9)) {
243                result = ItemLabelAnchor.INSIDE9;
244            }
245            else if (this.equals(ItemLabelAnchor.INSIDE10)) {
246                result = ItemLabelAnchor.INSIDE10;
247            }
248            else if (this.equals(ItemLabelAnchor.INSIDE11)) {
249                result = ItemLabelAnchor.INSIDE11;
250            }
251            else if (this.equals(ItemLabelAnchor.INSIDE12)) {
252                result = ItemLabelAnchor.INSIDE12;
253            }
254            else if (this.equals(ItemLabelAnchor.OUTSIDE1)) {
255                result = ItemLabelAnchor.OUTSIDE1;
256            }
257            else if (this.equals(ItemLabelAnchor.OUTSIDE2)) {
258                result = ItemLabelAnchor.OUTSIDE2;
259            }
260            else if (this.equals(ItemLabelAnchor.OUTSIDE3)) {
261                result = ItemLabelAnchor.OUTSIDE3;
262            }
263            else if (this.equals(ItemLabelAnchor.OUTSIDE4)) {
264                result = ItemLabelAnchor.OUTSIDE4;
265            }
266            else if (this.equals(ItemLabelAnchor.OUTSIDE5)) {
267                result = ItemLabelAnchor.OUTSIDE5;
268            }
269            else if (this.equals(ItemLabelAnchor.OUTSIDE6)) {
270                result = ItemLabelAnchor.OUTSIDE6;
271            }
272            else if (this.equals(ItemLabelAnchor.OUTSIDE7)) {
273                result = ItemLabelAnchor.OUTSIDE7;
274            }
275            else if (this.equals(ItemLabelAnchor.OUTSIDE8)) {
276                result = ItemLabelAnchor.OUTSIDE8;
277            }
278            else if (this.equals(ItemLabelAnchor.OUTSIDE9)) {
279                result = ItemLabelAnchor.OUTSIDE9;
280            }
281            else if (this.equals(ItemLabelAnchor.OUTSIDE10)) {
282                result = ItemLabelAnchor.OUTSIDE10;
283            }
284            else if (this.equals(ItemLabelAnchor.OUTSIDE11)) {
285                result = ItemLabelAnchor.OUTSIDE11;
286            }
287            else if (this.equals(ItemLabelAnchor.OUTSIDE12)) {
288                result = ItemLabelAnchor.OUTSIDE12;
289            }
290            return result;
291        }
292    
293    }