1 /*
2 * File: IOverlapStrategy.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.strategy;
21
22 import java.util.Map;
23
24 import de.jaret.util.date.Interval;
25 import de.jaret.util.ui.timebars.model.TimeBarRow;
26
27 /**
28 * Interface describing the strategy to calculate overlap information for a time bar viewer.
29 *
30 * @author kliem
31 * @version $Id: $
32 */
33 public interface IOverlapStrategy {
34
35 /**
36 * Retrieve the information about overlapping intervals and drawing position for a given interval.
37 *
38 * @param row row of the interval
39 * @param interval interval
40 * @return the overlap information
41 */
42 OverlapInfo getOverlapInfo(TimeBarRow row, Interval interval);
43
44 /**
45 * Retrieve tha maximal count of overlapping intervals in a row.
46 *
47 * @param row row to check
48 * @return count of maximum overlapping intervals in the row
49 */
50 int getMaxOverlapCount(TimeBarRow row);
51
52 /**
53 * Calculate the number of overlapping intervals and determine the positions to draw them on. May Assume sorted
54 * Intervals - check the strategy implementation!
55 *
56 * @param row row to update the cache for
57 * @return a map containing overlap infos for every interval in the row
58 */
59 Map<Interval, OverlapInfo> updateOICache(TimeBarRow row);
60
61 /**
62 * Clear all cached data. This method is to be called on model changes that invalidate cleared data.
63 */
64 void clearCachedData();
65
66 /**
67 * Called when a strategy is no loner used. May be useful to help garbage collecting or disconnect listeners.
68 */
69 void dispose();
70
71 }