1 package tim.prune.function;
4 import tim.prune.data.Track;
7 * Class to provide the function to crop the track
8 * to the current selection
10 public class CropToSelection extends DeleteBitOfTrackFunction
14 * @param inApp application object for callback
16 public CropToSelection(App inApp)
21 /** Get the name key */
22 public String getNameKey() {
23 return "function.croptrack";
27 * @return name key for undo operation
29 protected String getUndoNameKey() {
30 return "undo.croptrack";
39 Track track = _app.getTrackInfo().getTrack();
40 if (track == null || track.getNumPoints() <= 0) return;
42 final int selStart = _app.getTrackInfo().getSelection().getStart();
43 final int selEnd = _app.getTrackInfo().getSelection().getEnd();
44 if (selStart < 0 || selEnd < 0 || selEnd <= selStart) return;
45 // check for all selected
46 if (selStart == 0 && selEnd == (track.getNumPoints() - 1)) return;
48 // Pass indexes to parent class
49 deleteTwoSections(0, selStart-1, selEnd+1, track.getNumPoints()-1);