1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package de.jaret.examples.timebars.millis.model;
21
22 import de.jaret.util.date.Interval;
23 import de.jaret.util.misc.PropertyObservableBase;
24 import de.jaret.util.ui.timebars.TimeBarIntervalFilter;
25 import de.jaret.util.ui.timebars.model.PPSInterval;
26 import de.jaret.util.ui.timebars.model.TimeBarRow;
27
28 /***
29 * Special interval filter removing all intervals that are completely inside a break in the timescale.
30 *
31 * @author kliem
32 * @version $Id: BreakIntervalFilter.java 836 2009-02-14 21:24:39Z kliem $
33 */
34 public class BreakIntervalFilter extends PropertyObservableBase implements TimeBarIntervalFilter {
35 /*** the row containing the ps intervals. */
36 private TimeBarRow _ppsScaleRow;
37
38 /***
39 * Construct the filter with a reference to the row that contains the pss intervals.
40 *
41 * @param ppsScaleRow the time bar row containing the pps intervals
42 */
43 public BreakIntervalFilter(TimeBarRow ppsScaleRow) {
44 _ppsScaleRow = ppsScaleRow;
45 }
46
47 /***
48 * {@inheritDoc} Intervals are in the result if they do not fall into a break.
49 */
50 public boolean isInResult(Interval interval) {
51 for (Interval i : _ppsScaleRow.getIntervals()) {
52 PPSInterval ppsInterval = (PPSInterval) i;
53 if (ppsInterval.isBreak() && ppsInterval.contains(interval)) {
54 return false;
55 }
56 }
57 return true;
58 }
59
60 }