]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/undo/UndoAddTimeOffset.java
Version 19, May 2018
[GpsPrune.git] / tim / prune / undo / UndoAddTimeOffset.java
1 package tim.prune.undo;
2
3 import tim.prune.I18nManager;
4 import tim.prune.UpdateMessageBroker;
5 import tim.prune.data.TrackInfo;
6
7 /**
8  * Undo addition/subtraction of a time offset
9  */
10 public class UndoAddTimeOffset implements UndoOperation
11 {
12         /** Start and end indices of section */
13         private int _startIndex, _endIndex;
14         /** time offset in seconds */
15         private long _timeOffset;
16
17
18         /**
19          * Constructor
20          * @param inStart start index of section
21          * @param inEnd end index of section
22          * @param inOffset time offset in seconds
23          */
24         public UndoAddTimeOffset(int inStart, int inEnd, long inOffset)
25         {
26                 _startIndex = inStart;
27                 _endIndex = inEnd;
28                 _timeOffset = inOffset;
29         }
30
31
32         /**
33          * @return description of operation including number of points adjusted
34          */
35         public String getDescription()
36         {
37                 return I18nManager.getText("undo.addtimeoffset") + " (" + (_endIndex - _startIndex + 1) + ")";
38         }
39
40
41         /**
42          * Perform the undo operation on the given Track
43          * @param inTrackInfo TrackInfo object on which to perform the operation
44          */
45         public void performUndo(TrackInfo inTrackInfo) throws UndoException
46         {
47                 // Perform the inverse operation
48                 inTrackInfo.getTrack().addTimeOffsetSeconds(_startIndex, _endIndex, -_timeOffset, true);
49                 UpdateMessageBroker.informSubscribers();
50         }
51 }