KickJava   Java API By Example, From Geeks To Geeks.

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


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  * ItemLabelPosition.java
24  * ----------------------
25  * (C) Copyright 2003 by Object Refinery Limited and Contributors.
26  *
27  * Original Author: David Gilbert (for Object Refinery Limited);
28  * Contributor(s): -;
29  *
30  * $Id: ItemLabelPosition.java,v 1.2 2003/10/30 10:44:37 mungady Exp $
31  *
32  * Changes
33  * -------
34  * 27-Oct-2003 : Version 1 (DG);
35  *
36  */

37
38 package org.jfree.chart.renderer;
39
40 import java.io.Serializable JavaDoc;
41
42 import org.jfree.ui.TextAnchor;
43
44 /**
45  * The attributes that control the position of the label for each data item on a chart.
46  *
47  * @author David Gilbert
48  */

49 public class ItemLabelPosition implements Serializable JavaDoc {
50
51     /** The item label anchor point. */
52     private ItemLabelAnchor itemLabelAnchor;
53     
54     /** The text anchor. */
55     private TextAnchor textAnchor;
56     
57     /** The rotation anchor. */
58     private TextAnchor rotationAnchor;
59
60     /** The rotation angle. */
61     private double angle;
62     
63     /**
64      * Creates a new position record with default settings.
65      */

66     public ItemLabelPosition() {
67         this(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER, TextAnchor.CENTER, 0.0);
68     }
69     
70     /**
71      * Creates a new position record. The item label anchor is a point relative to the
72      * data item (dot, bar or other visual item) on a chart. The item label is aligned
73      * by aligning the text anchor with the item label anchor.
74      *
75      * @param itemLabelAnchor the item label anchor.
76      * @param textAnchor the text anchor.
77      * @param rotationAnchor the rotation anchor.
78      * @param angle the rotation angle.
79      */

80     public ItemLabelPosition(ItemLabelAnchor itemLabelAnchor,
81                              TextAnchor textAnchor,
82                              TextAnchor rotationAnchor,
83                              double angle) {
84                                  
85         this.itemLabelAnchor = itemLabelAnchor;
86         this.textAnchor = textAnchor;
87         this.rotationAnchor = rotationAnchor;
88         this.angle = angle;
89     
90     }
91     
92     /**
93      * Returns the item label anchor.
94      *
95      * @return The item label anchor.
96      */

97     public ItemLabelAnchor getItemLabelAnchor() {
98         return this.itemLabelAnchor;
99     }
100     
101     /**
102      * Returns the text anchor.
103      *
104      * @return The text anchor.
105      */

106     public TextAnchor getTextAnchor() {
107         return this.textAnchor;
108     }
109     
110     /**
111      * Returns the rotation anchor point.
112      *
113      * @return The rotation anchor point.
114      */

115     public TextAnchor getRotationAnchor() {
116         return this.rotationAnchor;
117     }
118     
119     /**
120      * Returns the angle of rotation for the label.
121      *
122      * @return The angle.
123      */

124     public double getAngle() {
125         return this.angle;
126     }
127     
128     /**
129      * Tests an object for equality with this instance.
130      *
131      * @param object the object.
132      *
133      * @return A boolean.
134      */

135     public boolean equals(Object JavaDoc object) {
136         
137         if (object == null) {
138             return false;
139         }
140         
141         if (object == this) {
142             return true;
143         }
144         
145         if (object instanceof ItemLabelPosition) {
146
147             ItemLabelPosition p = (ItemLabelPosition) object;
148             boolean b0 = (this.itemLabelAnchor.equals(p.itemLabelAnchor));
149             boolean b1 = (this.textAnchor.equals(p.textAnchor));
150             boolean b2 = (this.rotationAnchor.equals(p.rotationAnchor));
151             boolean b3 = (this.angle == p.angle);
152             return b0 && b1 && b2 && b3;
153         }
154         
155         return false;
156         
157     }
158
159 }
160
Popular Tags