package tim.prune.data; /** * Class to hold information about the mid-points between * adjacent track points. Used by the MapCanvas for creating * points by dragging. */ public class MidpointData { // track object private Track _track = null; // Scaled x, y values private double[] _xValues = null; private double[] _yValues = null; // Validity flags private boolean[] _valids = null; // Flag to set data stale private boolean _needRefresh = true; /** * Flag the data as needing to be updated * @param inTrack track object from which to get the data */ public void updateData(Track inTrack) { _track = inTrack; _needRefresh = true; } /** * Update the arrays of data from the track */ private synchronized void updateData() { _needRefresh = false; if (_track == null) return; // Make arrays the right size final int numPoints = _track.getNumPoints(); if (_xValues == null || _xValues.length != numPoints) { _xValues = new double[numPoints]; _yValues = new double[numPoints]; _valids = new boolean[numPoints]; } if (numPoints <= 0) return; _valids[0] = false; // Loop over the points in the track for (int i=1; i inMaxDist && inMaxDist > 0.0) { return -1; } return nearestPoint; } }