]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/undo/UndoInterpolate.java
Moved source into separate src directory due to popular request
[GpsPrune.git] / tim / prune / undo / UndoInterpolate.java
diff --git a/tim/prune/undo/UndoInterpolate.java b/tim/prune/undo/UndoInterpolate.java
deleted file mode 100644 (file)
index 975a731..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-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