+ /**
+ * Get the next track point starting from the given index
+ * @param inStartIndex index to start looking from
+ * @return next track point, or null if end of data reached
+ */
+ public DataPoint getNextTrackPoint(int inStartIndex)
+ {
+ return getNextTrackPoint(inStartIndex, 1);
+ }
+
+ /**
+ * Get the previous track point starting from the given index
+ * @param inStartIndex index to start looking from
+ * @return next track point, or null if end of data reached
+ */
+ public DataPoint getPreviousTrackPoint(int inStartIndex)
+ {
+ return getNextTrackPoint(inStartIndex, -1);
+ }
+
+ /**
+ * Get the next track point starting from the given index
+ * @param inStartIndex index to start looking from
+ * @param inIncrement increment to add to point index, +1 for next, -1 for previous
+ * @return next track point, or null if end of data reached
+ */
+ private DataPoint getNextTrackPoint(int inStartIndex, int inIncrement)
+ {
+ // Loop forever over points
+ for (int i=inStartIndex; ; i+=inIncrement)
+ {
+ DataPoint point = getPoint(i);
+ // Exit if end of data reached - there wasn't a track point
+ if (point == null) {return null;}
+ if (point.isValid() && !point.isWaypoint()) {
+ // next track point found
+ return point;
+ }
+ }
+ }
+
+ /**
+ * Shift all the segment start flags in the given range by 1
+ * Method used by reverse range and its undo
+ * @param inStartIndex start of range, inclusive
+ * @param inEndIndex end of range, inclusive
+ */
+ public void shiftSegmentStarts(int inStartIndex, int inEndIndex)
+ {
+ boolean prevFlag = true;
+ boolean currFlag = true;
+ for (int i=inStartIndex; i<= inEndIndex; i++)
+ {
+ DataPoint point = getPoint(i);
+ if (point != null && !point.isWaypoint())
+ {
+ // remember flag
+ currFlag = point.getSegmentStart();
+ // shift flag by 1
+ point.setSegmentStart(prevFlag);
+ prevFlag = currFlag;
+ }
+ }
+ }
+