]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/undo/UndoLoadPhotos.java
bb6a21176c48673f3a293115a97e6969fd98255e
[GpsPrune.git] / tim / prune / undo / UndoLoadPhotos.java
1 package tim.prune.undo;\r
2 \r
3 import tim.prune.I18nManager;\r
4 import tim.prune.data.TrackInfo;\r
5 \r
6 /**\r
7  * Operation to undo a load photos operation\r
8  */\r
9 public class UndoLoadPhotos implements UndoOperation\r
10 {\r
11         private int _numPhotos = -1;\r
12         private int _numPoints = -1;\r
13 \r
14 \r
15         /**\r
16          * Constructor\r
17          * @param inNumPhotos number of photos loaded\r
18          * @param inNumPoints number of points loaded\r
19          */\r
20         public UndoLoadPhotos(int inNumPhotos, int inNumPoints)\r
21         {\r
22                 _numPhotos = inNumPhotos;\r
23                 _numPoints = inNumPoints;\r
24         }\r
25 \r
26 \r
27         /**\r
28          * @return description of operation including number of photos loaded\r
29          */\r
30         public String getDescription()\r
31         {\r
32                 String desc = I18nManager.getText("undo.loadphotos");\r
33                 if (_numPhotos > 0)\r
34                         desc = desc + " (" + _numPhotos + ")";\r
35                 return desc;\r
36         }\r
37 \r
38 \r
39         /**\r
40          * Perform the undo operation on the given Track\r
41          * Delete both track points and Photo objects\r
42          * @param inTrackInfo TrackInfo object on which to perform the operation\r
43          */\r
44         public void performUndo(TrackInfo inTrackInfo) throws UndoException\r
45         {\r
46                 int cropIndex;\r
47                 // crop track to previous size\r
48                 if (_numPoints > 0)\r
49                 {\r
50                         cropIndex = inTrackInfo.getTrack().getNumPoints() - _numPoints;\r
51                         inTrackInfo.getTrack().cropTo(cropIndex);\r
52                 }\r
53                 // crop photo list to previous size\r
54                 cropIndex = inTrackInfo.getPhotoList().getNumPhotos() - _numPhotos;\r
55                 inTrackInfo.getPhotoList().cropTo(cropIndex);\r
56                 // clear selection\r
57                 inTrackInfo.getSelection().clearAll();\r
58         }\r
59 }