KickJava   Java API By Example, From Geeks To Geeks.

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


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  * DateTickMarkPosition.java
28  * -------------------------
29  * (C) Copyright 2003-2005, by Object Refinery Limited.
30  *
31  * Original Author: David Gilbert (for Object Refinery Limited);
32  * Contributor(s): -;
33  *
34  * $Id: DateTickMarkPosition.java,v 1.4 2005/05/19 13:58:11 mungady Exp $
35  *
36  * Changes:
37  * --------
38  * 30-Apr-2003 : Version 1 (DG);
39  *
40  */

41
42 package org.jfree.chart.axis;
43
44 import java.io.ObjectStreamException JavaDoc;
45 import java.io.Serializable JavaDoc;
46
47 /**
48  * Used to indicate the required position of tick marks on a date axis relative
49  * to the underlying time period.
50  */

51 public final class DateTickMarkPosition implements Serializable JavaDoc {
52
53     /** For serialization. */
54     private static final long serialVersionUID = 2540750672764537240L;
55     
56     /** Start of period. */
57     public static final DateTickMarkPosition START
58         = new DateTickMarkPosition("DateTickMarkPosition.START");
59
60     /** Middle of period. */
61     public static final DateTickMarkPosition MIDDLE
62         = new DateTickMarkPosition("DateTickMarkPosition.MIDDLE");
63
64     /** End of period. */
65     public static final DateTickMarkPosition END
66         = new DateTickMarkPosition("DateTickMarkPosition.END");
67
68     /** The name. */
69     private String JavaDoc name;
70
71     /**
72      * Private constructor.
73      *
74      * @param name the name.
75      */

76     private DateTickMarkPosition(String JavaDoc name) {
77         this.name = name;
78     }
79
80     /**
81      * Returns a string representing the object.
82      *
83      * @return The string.
84      */

85     public String JavaDoc toString() {
86         return this.name;
87     }
88
89     /**
90      * Returns <code>true</code> if this object is equal to the specified
91      * object, and <code>false</code> otherwise.
92      *
93      * @param obj the other object.
94      *
95      * @return A boolean.
96      */

97     public boolean equals(Object JavaDoc obj) {
98
99         if (this == obj) {
100             return true;
101         }
102         if (!(obj instanceof DateTickMarkPosition)) {
103             return false;
104         }
105         DateTickMarkPosition position = (DateTickMarkPosition) obj;
106         if (!this.name.equals(position.toString())) {
107             return false;
108         }
109         return true;
110
111     }
112     
113     /**
114      * Ensures that serialization returns the unique instances.
115      *
116      * @return The object.
117      *
118      * @throws ObjectStreamException if there is a problem.
119      */

120     private Object JavaDoc readResolve() throws ObjectStreamException JavaDoc {
121         if (this.equals(DateTickMarkPosition.START)) {
122             return DateTickMarkPosition.START;
123         }
124         else if (this.equals(DateTickMarkPosition.MIDDLE)) {
125             return DateTickMarkPosition.MIDDLE;
126         }
127         else if (this.equals(DateTickMarkPosition.END)) {
128             return DateTickMarkPosition.END;
129         }
130         return null;
131     }
132
133
134 }
135
Popular Tags