1 /*
2 * File: IntervalModificator.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.mod;
21
22 import de.jaret.util.date.Interval;
23 import de.jaret.util.date.JaretDate;
24 import de.jaret.util.ui.timebars.model.TimeBarRow;
25
26 /**
27 * Interface for deciding about interval modifications through the time bar viewer (visual editing).
28 *
29 * @author Peter Kliem
30 * @version $Id: IntervalModificator.java 800 2008-12-27 22:27:33Z kliem $
31 */
32 public interface IntervalModificator {
33
34 /**
35 * Decides whether the interval modificator is responsible for a given interval in a row.
36 *
37 * @param row row of the interval
38 * @param interval interval in question
39 * @return true if this modificator should be questioned
40 */
41 boolean isApplicable(TimeBarRow row, Interval interval);
42
43 /**
44 * Decide whether a given interval in a row is allowed to be sized.
45 *
46 * @param row row of the interval
47 * @param interval interval in question
48 * @return true if the interval may be sized
49 */
50 boolean isSizingAllowed(TimeBarRow row, Interval interval);
51
52 /**
53 * Decide whether a given interval in a given row can change the begin date.
54 *
55 * @param row row of the interval
56 * @param interval interval to be modified
57 * @param newBegin new begin date
58 * @return true if the modification is allowed
59 */
60 boolean newBeginAllowed(TimeBarRow row, Interval interval, JaretDate newBegin);
61
62 /**
63 * Decide whether a given interval in a given row can change the end date.
64 *
65 * @param row row of the interval
66 * @param interval interval to be modified
67 * @param newEnd new end date
68 * @return true if the modification is allowed
69 */
70 boolean newEndAllowed(TimeBarRow row, Interval interval, JaretDate newEnd);
71
72 /**
73 * Decide whether a given interval in a row is allowed to be shifted.
74 *
75 * @param row row of the interval
76 * @param interval interval in question
77 * @return true if the interval may be shifted
78 */
79 boolean isShiftingAllowed(TimeBarRow row, Interval interval);
80
81 /**
82 * Decide whether an interval may be shifted in time to a new begin date.
83 *
84 * @param row row of the interval
85 * @param interval interval to be modified
86 * @param newBegin new begin date
87 * @return true if the modification is allowed
88 */
89 boolean shiftAllowed(TimeBarRow row, Interval interval, JaretDate newBegin);
90
91 /**
92 * If this method returns a positive value this is used as the modification interval. The value is given in seconds.
93 *
94 * @return the positive grid snap or a negative value indicating no grid snap
95 */
96 double getSecondGridSnap();
97 }