]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/undo/UndoCompress.java
843054dc90fd3195b01a3733da099feb0a40c58e
[GpsPrune.git] / tim / prune / undo / UndoCompress.java
1 package tim.prune.undo;\r
2 \r
3 import tim.prune.I18nManager;\r
4 import tim.prune.data.DataPoint;\r
5 import tim.prune.data.Track;\r
6 import tim.prune.data.TrackInfo;\r
7 \r
8 /**\r
9  * Operation to undo a track compression\r
10  */\r
11 public class UndoCompress implements UndoOperation\r
12 {\r
13         private DataPoint[] _contents = null;\r
14         protected int _numPointsDeleted = -1;\r
15 \r
16 \r
17         /**\r
18          * Constructor\r
19          * @param inTrack track contents to copy\r
20          */\r
21         public UndoCompress(Track inTrack)\r
22         {\r
23                 _contents = inTrack.cloneContents();\r
24         }\r
25 \r
26 \r
27         /**\r
28          * Set the number of points deleted\r
29          * (only known after attempted compression)\r
30          * @param inNum number of points deleted\r
31          */\r
32         public void setNumPointsDeleted(int inNum)\r
33         {\r
34                 _numPointsDeleted = inNum;\r
35         }\r
36 \r
37 \r
38         /**\r
39          * @return description of operation including parameters\r
40          */\r
41         public String getDescription()\r
42         {\r
43                 String desc = I18nManager.getText("undo.compress");\r
44                 if (_numPointsDeleted > 0)\r
45                         desc = desc + " (" + _numPointsDeleted + ")";\r
46                 return desc;\r
47         }\r
48 \r
49 \r
50         /**\r
51          * Perform the undo operation on the given Track\r
52          * @param inTrackInfo TrackInfo object on which to perform the operation\r
53          */\r
54         public void performUndo(TrackInfo inTrackInfo) throws UndoException\r
55         {\r
56                 // restore track to previous values\r
57                 inTrackInfo.getTrack().replaceContents(_contents);\r
58                 // clear selection\r
59                 inTrackInfo.getSelection().clearAll();\r
60         }\r
61 }