View Javadoc

1   /*
2    *  File: TimeBarRow.java 
3    *  Copyright (c) 2004-2007  Peter Kliem (Peter.Kliem@jaret.de)
4    *  A commercial license is available, see http://www.jaret.de.
5    *
6    *  This program is free software; you can redistribute it and/or modify
7    *  it under the terms of the GNU General Public License as published by
8    *  the Free Software Foundation; either version 2 of the License, or
9    *  (at your option) any later version.
10   *
11   *  This program is distributed in the hope that it will be useful,
12   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   *  GNU General Public License for more details.
15   *
16   *  You should have received a copy of the GNU General Public License
17   *  along with this program; if not, write to the Free Software
18   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19   */
20  package de.jaret.util.ui.timebars.model;
21  
22  import java.util.List;
23  
24  import de.jaret.util.date.Interval;
25  import de.jaret.util.date.JaretDate;
26  
27  /**
28   * Model for a single row of intervals. When implementing the interface care should be taken to think about a performant
29   * implementation of the by-date-selecting mehtods for interval retrieval.
30   * 
31   * @author Peter Kliem
32   * @version $Id: TimeBarRow.java 800 2008-12-27 22:27:33Z kliem $
33   */
34  public interface TimeBarRow {
35      /**
36       * Provide the full ordered list of intervals.
37       * 
38       * @return an ordered List of Intervals
39       */
40      List<Interval> getIntervals();
41  
42      /**
43       * Provide the intervals in beetween a given interval. An interval should be selected as inside the given bounds if
44       * it is in between the bounds or one of the bounds is in the interval in question.
45       * 
46       * @param beginDate first date
47       * @param endDate last date
48       * @return ordered List of Intervals between the given dates
49       */
50      List<Interval> getIntervals(JaretDate beginDate, JaretDate endDate);
51  
52      /**
53       * Returns all intervals containing the given date.
54       * 
55       * @param date the date to be included in the intervals
56       * @return List of intervals containing the given date
57       */
58      List<Interval> getIntervals(JaretDate date);
59  
60      /**
61       * Return the row header.
62       * 
63       * @return row header
64       */
65      TimeBarRowHeader getRowHeader();
66  
67      /**
68       * Return the beginning date of the earliest interval in the row. A row may return <code>null</code> if it contains
69       * no intervals. If a row supplies a min date it must always supply a max value.
70       * 
71       * @return earliest date in the row or <code>null</code> if the row contains no intervals.
72       */
73      JaretDate getMinDate();
74  
75      /**
76       * Return the ending date of the latest interval in the row. A row may return <code>null</code> if it contains no
77       * intervals. If a row supplies a max date it must always supply a min date.
78       * 
79       * @return latest date in the row or <code>null</code> if the row contains no intervals.
80       */
81      JaretDate getMaxDate();
82  
83      /**
84       * Register a <code>TimeBarRowListener</code> for listening to changes in the row.
85       * 
86       * @param tbrl TimeBarRowListener to be added
87       */
88      void addTimeBarRowListener(TimeBarRowListener tbrl);
89  
90      /**
91       * Remove a previously added TimeBarRowListener.
92       * 
93       * @param tbrl TimeBarRowListener to be removed
94       */
95      void remTimeBarRowListener(TimeBarRowListener tbrl);
96  
97  }