KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfree > chart > axis > CategoryTick


1 /* ===========================================================
2  * JFreeChart : a free chart 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/jfreechart/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 License
20  * along with this library; if not, write to the Free Software Foundation,
21  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
22  *
23  * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
24  * in the United States and other countries.]
25  *
26  * -----------------
27  * CategoryTick.java
28  * -----------------
29  * (C) Copyright 2003, 2004, by Object Refinery Limited.
30  *
31  * Original Author: David Gilbert (for Object Refinery Limited);
32  * Contributor(s): -;
33  *
34  * $Id: CategoryTick.java,v 1.4 2005/04/10 06:20:19 mungady Exp $
35  *
36  * Changes
37  * -------
38  * 07-Nov-2003 : Version 1 (DG);
39  * 13-May-2004 : Added equals() method (DG);
40  *
41  */

42
43 package org.jfree.chart.axis;
44
45 import org.jfree.text.TextBlock;
46 import org.jfree.text.TextBlockAnchor;
47 import org.jfree.ui.TextAnchor;
48 import org.jfree.util.ObjectUtilities;
49
50 /**
51  * A tick for a {@link CategoryAxis}.
52  */

53 public class CategoryTick extends Tick {
54
55     /** The category. */
56     private Comparable JavaDoc category;
57     
58     /** The label. */
59     private TextBlock label;
60     
61     /** The label anchor. */
62     private TextBlockAnchor labelAnchor;
63     
64     /**
65      * Creates a new tick.
66      *
67      * @param category the category.
68      * @param label the label.
69      * @param labelAnchor the label anchor.
70      * @param rotationAnchor the rotation anchor.
71      * @param angle the rotation angle (in radians).
72      */

73     public CategoryTick(Comparable JavaDoc category,
74                         TextBlock label,
75                         TextBlockAnchor labelAnchor,
76                         TextAnchor rotationAnchor,
77                         double angle) {
78                             
79         super("", TextAnchor.CENTER, rotationAnchor, angle);
80         this.category = category;
81         this.label = label;
82         this.labelAnchor = labelAnchor;
83         
84     }
85     
86     /**
87      * Returns the category.
88      *
89      * @return The category.
90      */

91     public Comparable JavaDoc getCategory() {
92         return this.category;
93     }
94     
95     /**
96      * Returns the label.
97      *
98      * @return The label.
99      */

100     public TextBlock getLabel() {
101         return this.label;
102     }
103     
104     /**
105      * Returns the label anchor.
106      *
107      * @return The label anchor.
108      */

109     public TextBlockAnchor getLabelAnchor() {
110         return this.labelAnchor;
111     }
112     
113     /**
114      * Tests this category tick for equality with an arbitrary object.
115      *
116      * @param obj the object (<code>null</code> permitted).
117      *
118      * @return A boolean.
119      */

120     public boolean equals(Object JavaDoc obj) {
121         if (this == obj) {
122             return true;
123         }
124         if (obj instanceof CategoryTick && super.equals(obj)) {
125             CategoryTick that = (CategoryTick) obj;
126             if (!ObjectUtilities.equal(this.category, that.category)) {
127                 return false;
128             }
129             if (!ObjectUtilities.equal(this.label, that.label)) {
130                 return false;
131             }
132             if (!ObjectUtilities.equal(this.labelAnchor, that.labelAnchor)) {
133                 return false;
134            }
135             return true;
136         }
137         return false;
138     }
139     
140     /**
141      * Returns a hash code for this object.
142      *
143      * @return A hash code.
144      */

145     public int hashCode() {
146         int result = 41;
147         result = 37 * result + this.category.hashCode();
148         result = 37 * result + this.label.hashCode();
149         result = 37 * result + this.labelAnchor.hashCode();
150         return result;
151     }
152 }
153
Popular Tags