]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/undo/UndoCompress.java
Version 1, September 2006
[GpsPrune.git] / tim / prune / undo / UndoCompress.java
diff --git a/tim/prune/undo/UndoCompress.java b/tim/prune/undo/UndoCompress.java
new file mode 100644 (file)
index 0000000..843054d
--- /dev/null
@@ -0,0 +1,61 @@
+package tim.prune.undo;\r
+\r
+import tim.prune.I18nManager;\r
+import tim.prune.data.DataPoint;\r
+import tim.prune.data.Track;\r
+import tim.prune.data.TrackInfo;\r
+\r
+/**\r
+ * Operation to undo a track compression\r
+ */\r
+public class UndoCompress implements UndoOperation\r
+{\r
+       private DataPoint[] _contents = null;\r
+       protected int _numPointsDeleted = -1;\r
+\r
+\r
+       /**\r
+        * Constructor\r
+        * @param inTrack track contents to copy\r
+        */\r
+       public UndoCompress(Track inTrack)\r
+       {\r
+               _contents = inTrack.cloneContents();\r
+       }\r
+\r
+\r
+       /**\r
+        * Set the number of points deleted\r
+        * (only known after attempted compression)\r
+        * @param inNum number of points deleted\r
+        */\r
+       public void setNumPointsDeleted(int inNum)\r
+       {\r
+               _numPointsDeleted = inNum;\r
+       }\r
+\r
+\r
+       /**\r
+        * @return description of operation including parameters\r
+        */\r
+       public String getDescription()\r
+       {\r
+               String desc = I18nManager.getText("undo.compress");\r
+               if (_numPointsDeleted > 0)\r
+                       desc = desc + " (" + _numPointsDeleted + ")";\r
+               return desc;\r
+       }\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
+               // restore track to previous values\r
+               inTrackInfo.getTrack().replaceContents(_contents);\r
+               // clear selection\r
+               inTrackInfo.getSelection().clearAll();\r
+       }\r
+}
\ No newline at end of file