+++ /dev/null
-package tim.prune.undo;\r
-\r
-import tim.prune.I18nManager;\r
-import tim.prune.data.DataPoint;\r
-import tim.prune.data.Track;\r
-import tim.prune.data.TrackInfo;\r
-\r
-/**\r
- * Operation to undo a track compression\r
- */\r
-public class UndoCompress implements UndoOperation\r
-{\r
- private DataPoint[] _contents = null;\r
- protected int _numPointsDeleted = -1;\r
- private boolean[] _segmentStarts = null;\r
-\r
-\r
- /**\r
- * Constructor\r
- * @param inTrack track contents to copy\r
- */\r
- public UndoCompress(Track inTrack)\r
- {\r
- _contents = inTrack.cloneContents();\r
- // Copy boolean segment start flags\r
- _segmentStarts = new boolean[inTrack.getNumPoints()];\r
- for (int i=0; i<inTrack.getNumPoints(); i++) {\r
- _segmentStarts[i] = inTrack.getPoint(i).getSegmentStart();\r
- }\r
- }\r
-\r
-\r
- /**\r
- * Set the number of points deleted\r
- * (only known after attempted compression)\r
- * @param inNum number of points deleted\r
- */\r
- public void setNumPointsDeleted(int inNum)\r
- {\r
- _numPointsDeleted = inNum;\r
- }\r
-\r
-\r
- /**\r
- * @return description of operation including parameters\r
- */\r
- public String getDescription()\r
- {\r
- String desc = I18nManager.getText("undo.compress");\r
- if (_numPointsDeleted > 0)\r
- desc = desc + " (" + _numPointsDeleted + ")";\r
- return desc;\r
- }\r
-\r
-\r
- /**\r
- * Perform the undo operation on the given Track\r
- * @param inTrackInfo TrackInfo object on which to perform the operation\r
- */\r
- public void performUndo(TrackInfo inTrackInfo) throws UndoException\r
- {\r
- // restore track to previous values\r
- inTrackInfo.getTrack().replaceContents(_contents);\r
- // Copy boolean segment start flags\r
- Track track = inTrackInfo.getTrack();\r
- if (_segmentStarts.length != track.getNumPoints())\r
- throw new UndoException("Cannot undo compress - track length no longer matches");\r
- for (int i=0; i<_segmentStarts.length; i++) {\r
- track.getPoint(i).setSegmentStart(_segmentStarts[i]);\r
- }\r
- // clear selection\r
- inTrackInfo.getSelection().clearAll();\r
- }\r
-}
\ No newline at end of file