X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=src%2Ftim%2Fprune%2Fdata%2FMidpointData.java;fp=src%2Ftim%2Fprune%2Fdata%2FMidpointData.java;h=3fdebb284ac1208d8352f2a35ea01419ed6b7bad;hp=0000000000000000000000000000000000000000;hb=ce6f2161b8596f7018d6a76bff79bc9e571f35fd;hpb=2d8cb72e84d5cc1089ce77baf1e34ea3ea2f8465 diff --git a/src/tim/prune/data/MidpointData.java b/src/tim/prune/data/MidpointData.java new file mode 100644 index 0000000..3fdebb2 --- /dev/null +++ b/src/tim/prune/data/MidpointData.java @@ -0,0 +1,98 @@ +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; + } +}