1 package tim.prune.function;
4 import tim.prune.GenericFunction;
5 import tim.prune.data.Checker;
6 import tim.prune.data.DataPoint;
9 * Function to allow the selection of which tracks to load from the file / stream
11 public class SelectSegmentFunction extends GenericFunction
16 * @param inApp app object to use for load
18 public SelectSegmentFunction(App inApp)
28 // If no point selected, or a waypoint is selected, then do nothing
29 DataPoint currPoint = _app.getTrackInfo().getCurrentPoint();
30 if (currPoint != null && !currPoint.isWaypoint())
32 // Find indexes of segment start and end
33 final int currIndex = _app.getTrackInfo().getSelection().getCurrentPointIndex();
34 final int startIndex = Checker.getPreviousSegmentStart(_app.getTrackInfo().getTrack(), currIndex+1);
35 final int endIndex = Checker.getNextSegmentEnd(_app.getTrackInfo().getTrack(), currIndex);
36 // Select this range if there is one
37 if (endIndex > startIndex) {
38 _app.getTrackInfo().getSelection().selectRange(startIndex, endIndex);
43 /** @return name key */
44 public String getNameKey() {
45 return "function.selectsegment";