]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/undo/UndoAppendPoints.java
Version 19, May 2018
[GpsPrune.git] / tim / prune / undo / UndoAppendPoints.java
diff --git a/tim/prune/undo/UndoAppendPoints.java b/tim/prune/undo/UndoAppendPoints.java
new file mode 100644 (file)
index 0000000..14e147b
--- /dev/null
@@ -0,0 +1,51 @@
+package tim.prune.undo;\r
+\r
+import tim.prune.I18nManager;\r
+import tim.prune.data.TrackInfo;\r
+\r
+/**\r
+ * Operation to undo an operation (such as create marker waypoints)\r
+ * in which a number of points were appended to the track\r
+ */\r
+public class UndoAppendPoints implements UndoOperation\r
+{\r
+       private int _previousTrackLength = -1;\r
+       private int _numAppended = 0;\r
+\r
+\r
+       /**\r
+        * Constructor\r
+        */\r
+       public UndoAppendPoints(int inTrackLength)\r
+       {\r
+               _previousTrackLength = inTrackLength;\r
+       }\r
+\r
+       /**\r
+        * @param inNumPoints number of points appended to track\r
+        */\r
+       public void setNumPointsAppended(int inNumPoints)\r
+       {\r
+               _numAppended = inNumPoints;\r
+       }\r
+\r
+       /**\r
+        * @return description of operation including number of points loaded\r
+        */\r
+       public String getDescription()\r
+       {\r
+               return I18nManager.getText("undo.insert") + " (" + _numAppended + ")";\r
+       }\r
+\r
+       /**\r
+        * Perform the undo operation on the given Track\r
+        * @param inTrackInfo TrackInfo object on which to perform the operation\r
+        */\r
+       public void performUndo(TrackInfo inTrackInfo) throws UndoException\r
+       {\r
+               // crop track to previous size\r
+               inTrackInfo.getTrack().cropTo(_previousTrackLength);\r
+               // clear selection\r
+               inTrackInfo.getSelection().clearAll();\r
+       }\r
+}\r