X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=tim%2Fprune%2Fundo%2FUndoAddTimeOffset.java;fp=tim%2Fprune%2Fundo%2FUndoAddTimeOffset.java;h=329d09a3a6b3f059eeea9f0ca6c17b1180370f81;hp=0000000000000000000000000000000000000000;hb=52bf9e8686c916be37a26a0b75340393d4478b05;hpb=ca9bdb3916f9c39adbbf95d06ac95c21dafbb4e6 diff --git a/tim/prune/undo/UndoAddTimeOffset.java b/tim/prune/undo/UndoAddTimeOffset.java new file mode 100644 index 0000000..329d09a --- /dev/null +++ b/tim/prune/undo/UndoAddTimeOffset.java @@ -0,0 +1,51 @@ +package tim.prune.undo; + +import tim.prune.I18nManager; +import tim.prune.UpdateMessageBroker; +import tim.prune.data.TrackInfo; + +/** + * Undo addition/subtraction of a time offset + */ +public class UndoAddTimeOffset implements UndoOperation +{ + /** Start and end indices of section */ + private int _startIndex, _endIndex; + /** time offset */ + private long _timeOffset; + + + /** + * Constructor + * @param inStart start index of section + * @param inEnd end index of section + * @param inOffset time offset + */ + public UndoAddTimeOffset(int inStart, int inEnd, long inOffset) + { + _startIndex = inStart; + _endIndex = inEnd; + _timeOffset = inOffset; + } + + + /** + * @return description of operation including number of points adjusted + */ + public String getDescription() + { + return I18nManager.getText("undo.addtimeoffset") + " (" + (_endIndex - _startIndex + 1) + ")"; + } + + + /** + * Perform the undo operation on the given Track + * @param inTrackInfo TrackInfo object on which to perform the operation + */ + public void performUndo(TrackInfo inTrackInfo) throws UndoException + { + // Perform the inverse operation + inTrackInfo.getTrack().addTimeOffset(_startIndex, _endIndex, -_timeOffset); + UpdateMessageBroker.informSubscribers(); + } +}