1 package tim.prune.undo;
3 import tim.prune.I18nManager;
4 import tim.prune.UpdateMessageBroker;
5 import tim.prune.data.DataPoint;
6 import tim.prune.data.Field;
7 import tim.prune.data.Track;
8 import tim.prune.data.TrackInfo;
11 * Undo lookup of altitudes from SRTM data
13 public class UndoLookupSrtm implements UndoOperation
15 /** DataPoint objects which didn't have altitudes before */
16 private DataPoint[] _points;
21 * @param inTrackInfo track info object
23 public UndoLookupSrtm(TrackInfo inTrackInfo)
25 Track track = inTrackInfo.getTrack();
26 int numPoints = track.getNumPoints();
27 // Make array of points without altitudes
28 _points = new DataPoint[numPoints];
29 for (int i=0; i<numPoints; i++) {
30 DataPoint point = track.getPoint(i);
31 if (!point.hasAltitude()) {
39 * @return description of operation
41 public String getDescription()
43 return I18nManager.getText("undo.lookupsrtm");
48 * Perform the undo operation on the given Track
49 * @param inTrackInfo TrackInfo object on which to perform the operation
51 public void performUndo(TrackInfo inTrackInfo) throws UndoException
53 // Loop through points again, and reset altitudes if they have one
54 final int numPoints = _points.length;
55 for (int i=0; i<numPoints; i++) {
56 DataPoint point = _points[i];
57 if (point != null && point.hasAltitude()) {
58 point.setFieldValue(Field.ALTITUDE, null, true);
62 UpdateMessageBroker.informSubscribers();