KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Timeline.java
28  * -------------
29  * (C) Copyright 2000-2004, by Object Refinery Limited and Contributors.
30  *
31  * Original Author: Bill Kelemen;
32  * Contributor(s): David Gilbert (for Object Refinery Limited);
33  *
34  * $Id: Timeline.java,v 1.2 2005/02/28 11:45:17 mungady Exp $
35  *
36  * Changes
37  * -------
38  * 23-May-2003 : Version 1 (BK);
39  * 09-Sep-2003 : Changed some method and parameter names (DG);
40  *
41  */

42
43 package org.jfree.chart.axis;
44
45 import java.util.Date JavaDoc;
46
47 /**
48  * An interface that defines the contract for a Timeline.
49  * <P>
50  * A Timeline will present a series of values to be used for an axis. Each
51  * Timeline must provide transformation methods between domain values and
52  * timeline values. In theory many transformations are possible. This interface
53  * has been implemented completely in
54  * {@link org.jfree.chart.axis.SegmentedTimeline}.
55  * <P>
56  * A timeline can be used as parameter to a
57  * {@link org.jfree.chart.axis.DateAxis} to define the values that this axis
58  * supports. As an example, the {@link org.jfree.chart.axis.SegmentedTimeline}
59  * implements a timeline formed by segments of equal length (ex. days, hours,
60  * minutes) where some segments can be included in the timeline and others
61  * excluded. Therefore timelines like "working days" or "working hours" can be
62  * created where non-working days or non-working hours respectively can be
63  * removed from the timeline, and therefore from the axis. This creates a smooth
64  * plot with equal separation between all included segments.
65  * <P>
66  * Because Timelines were created mainly for Date related axis, values are
67  * represented as longs instead of doubles. In this case, the domain value is
68  * just the number of milliseconds since January 1, 1970, 00:00:00 GMT as
69  * defined by the getTime() method of {@link java.util.Date}.
70  *
71  * @see org.jfree.chart.axis.SegmentedTimeline
72  * @see org.jfree.chart.axis.DateAxis
73  *
74  * @author Bill Kelemen
75  */

76 public interface Timeline {
77
78     /**
79      * Translates a millisecond (as defined by java.util.Date) into an index
80      * along this timeline.
81      *
82      * @param millisecond the millisecond.
83      *
84      * @return A timeline value.
85      */

86     long toTimelineValue(long millisecond);
87
88     /**
89      * Translates a date into a value on this timeline.
90      *
91      * @param date the date.
92      *
93      * @return A timeline value
94      */

95     long toTimelineValue(Date JavaDoc date);
96
97     /**
98      * Translates a value relative to this timeline into a domain value. The
99      * domain value obtained by this method is not always the same domain value
100      * that could have been supplied to
101      * translateDomainValueToTimelineValue(domainValue).
102      * This is because the original tranformation may not be complete
103      * reversable.
104      *
105      * @see org.jfree.chart.axis.SegmentedTimeline
106      *
107      * @param timelineValue a timeline value.
108      *
109      * @return A domain value.
110      */

111     long toMillisecond(long timelineValue);
112
113     /**
114      * Returns <code>true</code> if a value is contained in the timeline values.
115      *
116      * @param millisecond the millisecond.
117      *
118      * @return <code>true</code> if value is contained in the timeline and
119      * <code>false</code> otherwise.
120      */

121     boolean containsDomainValue(long millisecond);
122
123     /**
124      * Returns <code>true</code> if a date is contained in the timeline values.
125      *
126      * @param date the date to verify.
127      *
128      * @return <code>true</code> if value is contained in the timeline and
129      * <code>false</code> otherwise.
130      */

131     boolean containsDomainValue(Date JavaDoc date);
132
133     /**
134      * Returns <code>true</code> if a range of values are contained in the
135      * timeline.
136      *
137      * @param fromMillisecond the start of the range to verify.
138      * @param toMillisecond the end of the range to verify.
139      *
140      * @return <code>true</code> if the range is contained in the timeline or
141      * <code>false</code> otherwise
142      */

143     boolean containsDomainRange(long fromMillisecond, long toMillisecond);
144
145     /**
146      * Returns <code>true</code> if a range of dates are contained in the
147      * timeline.
148      *
149      * @param fromDate the start of the range to verify.
150      * @param toDate the end of the range to verify.
151      *
152      * @return <code>true</code> if the range is contained in the timeline or
153      * <code>false</code> otherwise
154      */

155     boolean containsDomainRange(Date JavaDoc fromDate, Date JavaDoc toDate);
156
157 }
158
Popular Tags