KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfree > chart > renderer > ItemLabelAnchor


1 /* ======================================
2  * JFreeChart : a free Java chart library
3  * ======================================
4  *
5  * Project Info: http://www.jfree.org/jfreechart/index.html
6  * Project Lead: David Gilbert (david.gilbert@object-refinery.com);
7  *
8  * (C) Copyright 2000-2003, by Object Refinery Limited and Contributors.
9  *
10  * This library is free software; you can redistribute it and/or modify it under the terms
11  * of the GNU Lesser General Public License as published by the Free Software Foundation;
12  * either version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License along with this
19  * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20  * Boston, MA 02111-1307, USA.
21  *
22  * --------------------
23  * ItemLabelAnchor.java
24  * --------------------
25  * (C) Copyright 2003 by Object Refinery Limited.
26  *
27  * Original Author: David Gilbert (for Object Refinery Limited);
28  * Contributor(s): -;
29  *
30  * $Id: ItemLabelAnchor.java,v 1.4 2003/10/28 16:42:52 mungady Exp $
31  *
32  * Changes
33  * -------
34  * 29-Apr-2003 : Version 1 (DG);
35  *
36  */

37 package org.jfree.chart.renderer;
38
39 import java.io.Serializable JavaDoc;
40
41 /**
42  * An enumeration of the positions that a value label can take, relative to an item
43  * in a {@link org.jfree.chart.plot.CategoryPlot}.
44  *
45  * @author David Gilbert
46  */

47 public class ItemLabelAnchor implements Serializable JavaDoc {
48
49     /** Center. */
50     public static final ItemLabelAnchor CENTER = new ItemLabelAnchor("ItemLabelAnchor.CENTER");
51
52     /** INSIDE1. */
53     public static final ItemLabelAnchor INSIDE1 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE1");
54
55     /** INSIDE2. */
56     public static final ItemLabelAnchor INSIDE2 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE2");
57
58     /** INSIDE3. */
59     public static final ItemLabelAnchor INSIDE3 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE3");
60
61     /** INSIDE4. */
62     public static final ItemLabelAnchor INSIDE4 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE4");
63
64     /** INSIDE5. */
65     public static final ItemLabelAnchor INSIDE5 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE5");
66
67     /** INSIDE6. */
68     public static final ItemLabelAnchor INSIDE6 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE6");
69
70     /** INSIDE7. */
71     public static final ItemLabelAnchor INSIDE7 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE7");
72
73     /** INSIDE8. */
74     public static final ItemLabelAnchor INSIDE8 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE8");
75
76     /** INSIDE9. */
77     public static final ItemLabelAnchor INSIDE9 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE9");
78
79     /** INSIDE10. */
80     public static final ItemLabelAnchor INSIDE10 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE10");
81
82     /** INSIDE11. */
83     public static final ItemLabelAnchor INSIDE11 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE11");
84
85     /** INSIDE12. */
86     public static final ItemLabelAnchor INSIDE12 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE12");
87
88     /** OUTSIDE1. */
89     public static final ItemLabelAnchor OUTSIDE1 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE1");
90
91     /** OUTSIDE2. */
92     public static final ItemLabelAnchor OUTSIDE2 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE2");
93
94     /** OUTSIDE3. */
95     public static final ItemLabelAnchor OUTSIDE3 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE3");
96
97     /** OUTSIDE4. */
98     public static final ItemLabelAnchor OUTSIDE4 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE4");
99
100     /** OUTSIDE5. */
101     public static final ItemLabelAnchor OUTSIDE5 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE5");
102
103     /** OUTSIDE6. */
104     public static final ItemLabelAnchor OUTSIDE6 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE6");
105
106     /** OUTSIDE7. */
107     public static final ItemLabelAnchor OUTSIDE7 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE7");
108
109     /** OUTSIDE8. */
110     public static final ItemLabelAnchor OUTSIDE8 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE8");
111
112     /** OUTSIDE9. */
113     public static final ItemLabelAnchor OUTSIDE9 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE9");
114
115     /** OUTSIDE10. */
116     public static final ItemLabelAnchor OUTSIDE10
117         = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE10");
118
119     /** OUTSIDE11. */
120     public static final ItemLabelAnchor OUTSIDE11
121         = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE11");
122
123     /** OUTSIDE12. */
124     public static final ItemLabelAnchor OUTSIDE12
125         = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE12");
126
127     /** The name. */
128     private String JavaDoc name;
129
130     /**
131      * Private constructor.
132      *
133      * @param name the name.
134      */

135     private ItemLabelAnchor(String JavaDoc name) {
136         this.name = name;
137     }
138
139     /**
140      * Returns a string representing the object.
141      *
142      * @return The string.
143      */

144     public String JavaDoc toString() {
145         return this.name;
146     }
147
148     /**
149      * Returns <code>true</code> if this object is equal to the specified object, and
150      * <code>false</code> otherwise.
151      *
152      * @param o the other object.
153      *
154      * @return A boolean.
155      */

156     public boolean equals(Object JavaDoc o) {
157
158         if (this == o) {
159             return true;
160         }
161         if (!(o instanceof ItemLabelAnchor)) {
162             return false;
163         }
164
165         final ItemLabelAnchor order = (ItemLabelAnchor) o;
166         if (!this.name.equals(order.toString())) {
167             return false;
168         }
169
170         return true;
171
172     }
173
174     /**
175      * Returns the anchor point that is horizontally opposite the given anchor point.
176      *
177      * @param anchor an anchor point.
178      *
179      * @return The opposite anchor point.
180      *
181      * @deprecated Renderer now has positive and negative item label anchors.
182      */

183     public static ItemLabelAnchor getHorizontalOpposite(ItemLabelAnchor anchor) {
184
185         if (anchor == ItemLabelAnchor.CENTER) {
186             return ItemLabelAnchor.CENTER;
187         }
188         else if (anchor == ItemLabelAnchor.INSIDE1) {
189             return ItemLabelAnchor.INSIDE11;
190         }
191         else if (anchor == ItemLabelAnchor.INSIDE2) {
192             return ItemLabelAnchor.INSIDE10;
193         }
194         else if (anchor == ItemLabelAnchor.INSIDE3) {
195             return ItemLabelAnchor.INSIDE9;
196         }
197         else if (anchor == ItemLabelAnchor.INSIDE4) {
198             return ItemLabelAnchor.INSIDE8;
199         }
200         else if (anchor == ItemLabelAnchor.INSIDE5) {
201             return ItemLabelAnchor.INSIDE7;
202         }
203         else if (anchor == ItemLabelAnchor.INSIDE6) {
204             return ItemLabelAnchor.INSIDE6;
205         }
206         else if (anchor == ItemLabelAnchor.INSIDE7) {
207             return ItemLabelAnchor.INSIDE5;
208         }
209         else if (anchor == ItemLabelAnchor.INSIDE8) {
210             return ItemLabelAnchor.INSIDE4;
211         }
212         else if (anchor == ItemLabelAnchor.INSIDE9) {
213             return ItemLabelAnchor.INSIDE3;
214         }
215         else if (anchor == ItemLabelAnchor.INSIDE10) {
216             return ItemLabelAnchor.INSIDE2;
217         }
218         else if (anchor == ItemLabelAnchor.INSIDE11) {
219             return ItemLabelAnchor.INSIDE1;
220         }
221         else if (anchor == ItemLabelAnchor.INSIDE12) {
222             return ItemLabelAnchor.INSIDE12;
223         }
224         else if (anchor == ItemLabelAnchor.OUTSIDE1) {
225             return ItemLabelAnchor.OUTSIDE11;
226         }
227         else if (anchor == ItemLabelAnchor.OUTSIDE2) {
228             return ItemLabelAnchor.OUTSIDE10;
229         }
230         else if (anchor == ItemLabelAnchor.OUTSIDE3) {
231             return ItemLabelAnchor.OUTSIDE9;
232         }
233         else if (anchor == ItemLabelAnchor.OUTSIDE4) {
234             return ItemLabelAnchor.OUTSIDE8;
235         }
236         else if (anchor == ItemLabelAnchor.OUTSIDE5) {
237             return ItemLabelAnchor.OUTSIDE7;
238         }
239         else if (anchor == ItemLabelAnchor.OUTSIDE6) {
240             return ItemLabelAnchor.OUTSIDE6;
241         }
242         else if (anchor == ItemLabelAnchor.OUTSIDE7) {
243             return ItemLabelAnchor.OUTSIDE5;
244         }
245         else if (anchor == ItemLabelAnchor.OUTSIDE8) {
246             return ItemLabelAnchor.OUTSIDE4;
247         }
248         else if (anchor == ItemLabelAnchor.OUTSIDE9) {
249             return ItemLabelAnchor.OUTSIDE3;
250         }
251         else if (anchor == ItemLabelAnchor.OUTSIDE10) {
252             return ItemLabelAnchor.OUTSIDE2;
253         }
254         else if (anchor == ItemLabelAnchor.OUTSIDE11) {
255             return ItemLabelAnchor.OUTSIDE1;
256         }
257         else if (anchor == ItemLabelAnchor.OUTSIDE12) {
258             return ItemLabelAnchor.OUTSIDE12;
259         }
260         return null;
261     }
262
263     /**
264      * Returns the anchor point that is vertically opposite the given anchor point.
265      *
266      * @param anchor an anchor point.
267      *
268      * @return The opposite anchor point.
269      *
270      * @deprecated Renderer now has positive and negative item label positions.
271      */

272     public static ItemLabelAnchor getVerticalOpposite(ItemLabelAnchor anchor) {
273
274         if (anchor == ItemLabelAnchor.CENTER) {
275             return ItemLabelAnchor.CENTER;
276         }
277         else if (anchor == ItemLabelAnchor.INSIDE1) {
278             return ItemLabelAnchor.INSIDE5;
279         }
280         else if (anchor == ItemLabelAnchor.INSIDE2) {
281             return ItemLabelAnchor.INSIDE4;
282         }
283         else if (anchor == ItemLabelAnchor.INSIDE3) {
284             return ItemLabelAnchor.INSIDE3;
285         }
286         else if (anchor == ItemLabelAnchor.INSIDE4) {
287             return ItemLabelAnchor.INSIDE2;
288         }
289         else if (anchor == ItemLabelAnchor.INSIDE5) {
290             return ItemLabelAnchor.INSIDE1;
291         }
292         else if (anchor == ItemLabelAnchor.INSIDE6) {
293             return ItemLabelAnchor.INSIDE12;
294         }
295         else if (anchor == ItemLabelAnchor.INSIDE7) {
296             return ItemLabelAnchor.INSIDE11;
297         }
298         else if (anchor == ItemLabelAnchor.INSIDE8) {
299             return ItemLabelAnchor.INSIDE10;
300         }
301         else if (anchor == ItemLabelAnchor.INSIDE9) {
302             return ItemLabelAnchor.INSIDE9;
303         }
304         else if (anchor == ItemLabelAnchor.INSIDE10) {
305             return ItemLabelAnchor.INSIDE8;
306         }
307         else if (anchor == ItemLabelAnchor.INSIDE11) {
308             return ItemLabelAnchor.INSIDE7;
309         }
310         else if (anchor == ItemLabelAnchor.INSIDE12) {
311             return ItemLabelAnchor.INSIDE6;
312         }
313         else if (anchor == ItemLabelAnchor.OUTSIDE1) {
314             return ItemLabelAnchor.OUTSIDE5;
315         }
316         else if (anchor == ItemLabelAnchor.OUTSIDE2) {
317             return ItemLabelAnchor.OUTSIDE4;
318         }
319         else if (anchor == ItemLabelAnchor.OUTSIDE3) {
320             return ItemLabelAnchor.OUTSIDE3;
321         }
322         else if (anchor == ItemLabelAnchor.OUTSIDE4) {
323             return ItemLabelAnchor.OUTSIDE2;
324         }
325         else if (anchor == ItemLabelAnchor.OUTSIDE5) {
326             return ItemLabelAnchor.OUTSIDE1;
327         }
328         else if (anchor == ItemLabelAnchor.OUTSIDE6) {
329             return ItemLabelAnchor.OUTSIDE12;
330         }
331         else if (anchor == ItemLabelAnchor.OUTSIDE7) {
332             return ItemLabelAnchor.OUTSIDE11;
333         }
334         else if (anchor == ItemLabelAnchor.OUTSIDE8) {
335             return ItemLabelAnchor.OUTSIDE10;
336         }
337         else if (anchor == ItemLabelAnchor.OUTSIDE9) {
338             return ItemLabelAnchor.OUTSIDE9;
339         }
340         else if (anchor == ItemLabelAnchor.OUTSIDE10) {
341             return ItemLabelAnchor.OUTSIDE8;
342         }
343         else if (anchor == ItemLabelAnchor.OUTSIDE11) {
344             return ItemLabelAnchor.OUTSIDE7;
345         }
346         else if (anchor == ItemLabelAnchor.OUTSIDE12) {
347             return ItemLabelAnchor.OUTSIDE6;
348         }
349         return null;
350     }
351
352 }
353
Popular Tags