+++ /dev/null
-package tim.prune.undo;\r
-\r
-import tim.prune.I18nManager;\r
-import tim.prune.data.DataPoint;\r
-import tim.prune.data.TrackInfo;\r
-\r
-/**\r
- * Operation to undo an interpolation\r
- */\r
-public class UndoInterpolate implements UndoOperation\r
-{\r
- private int _startIndex = 0;\r
- private int _totalInserted = 0;\r
- private DataPoint[] _points = null;\r
-\r
-\r
- /**\r
- * Constructor\r
- * @param inTrackInfo track info object\r
- * @param inTotalInserted total number of points inserted\r
- */\r
- public UndoInterpolate(TrackInfo inTrackInfo, int inTotalInserted)\r
- {\r
- _startIndex = inTrackInfo.getSelection().getStart();\r
- _points = inTrackInfo.cloneSelectedRange();\r
- _totalInserted = inTotalInserted;\r
- }\r
-\r
-\r
- /**\r
- * @return description of operation including parameters\r
- */\r
- public String getDescription()\r
- {\r
- return I18nManager.getText("undo.insert") + " (" + _totalInserted + ")";\r
- }\r
-\r
-\r
- /**\r
- * Perform the undo operation on the given TrackInfo\r
- * @param inTrackInfo TrackInfo object on which to perform the operation\r
- */\r
- public void performUndo(TrackInfo inTrackInfo) throws UndoException\r
- {\r
- // Work out how many points were in the track before the interpolation\r
- final int newSize = inTrackInfo.getTrack().getNumPoints() - _totalInserted;\r
- DataPoint[] oldPoints = inTrackInfo.getTrack().cloneContents();\r
- DataPoint[] newPoints = new DataPoint[newSize];\r
-\r
- // Restore track to previous values\r
- System.arraycopy(oldPoints, 0, newPoints, 0, _startIndex);\r
- System.arraycopy(_points, 0, newPoints, _startIndex, _points.length);\r
- int endIndex = _startIndex + _points.length;\r
- System.arraycopy(oldPoints, endIndex + _totalInserted, newPoints, endIndex, newSize - endIndex);\r
-\r
- inTrackInfo.getTrack().replaceContents(newPoints);\r
- // reset selection\r
- inTrackInfo.getSelection().clearAll();\r
- }\r
-}\r