KickJava   Java API By Example, From Geeks To Geeks.

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


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  * DateTick.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: DateTick.java,v 1.4 2005/04/10 06:21:47 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 java.util.Date JavaDoc;
46
47 import org.jfree.ui.TextAnchor;
48 import org.jfree.util.ObjectUtilities;
49
50 /**
51  * A tick used by the {@link DateAxis} class.
52  */

53 public class DateTick extends ValueTick {
54
55     /** The date. */
56     private Date JavaDoc date;
57     
58     /**
59      * Creates a new date tick.
60      *
61      * @param date the date.
62      * @param label the label.
63      * @param textAnchor the part of the label that is aligned to the anchor
64      * point.
65      * @param rotationAnchor defines the rotation point relative to the text.
66      * @param angle the rotation angle (in radians).
67      */

68     public DateTick(Date JavaDoc date, String JavaDoc label,
69                     TextAnchor textAnchor, TextAnchor rotationAnchor,
70                     double angle) {
71                         
72         super(date.getTime(), label, textAnchor, rotationAnchor, angle);
73         this.date = date;
74             
75     }
76     
77     /**
78      * Returns the date.
79      *
80      * @return The date.
81      */

82     public Date JavaDoc getDate() {
83         return this.date;
84     }
85
86     /**
87      * Tests this tick for equality with an arbitrary object.
88      *
89      * @param obj the object to test (<code>null</code> permitted).
90      *
91      * @return A boolean.
92      */

93     public boolean equals(Object JavaDoc obj) {
94         if (obj == this) {
95             return true;
96         }
97         if (obj instanceof DateTick && super.equals(obj)) {
98             DateTick dt = (DateTick) obj;
99             if (!ObjectUtilities.equal(this.date, dt.date)) {
100                 return false;
101             }
102             return true;
103         }
104         return false;
105     }
106     
107     /**
108      * Returns a hash code for this object.
109      *
110      * @return A hash code.
111      */

112     public int hashCode() {
113         return this.date.hashCode();
114     }
115     
116 }
117
Popular Tags