1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
package tim.prune.gui.profile;
import tim.prune.data.Track;
/**
* Abstract class for all sources of profile data,
* including altitudes and speeds
*/
public abstract class ProfileData
{
/** Track object */
protected final Track _track;
/** Flag for availability of any data */
protected boolean _hasData = false;
/** Array of booleans for data per point */
protected boolean[] _pointHasData = null;
/** Array of values per point */
protected double[] _pointValues = null;
/** Minimum value for track */
protected double _minValue = 0.0;
/** Maximum value for track */
protected double _maxValue = 0.0;
/**
* Constructor giving track object
* @param inTrack track object
*/
public ProfileData(Track inTrack)
{
_track = inTrack;
}
/**
* @return true if this source has any data at all
*/
public boolean hasData() {
return _hasData;
}
/**
* @param inPointNum index of point
* @return true if that point has data
*/
public boolean hasData(int inPointNum)
{
return (_hasData && _pointHasData != null && inPointNum >= 0
&& inPointNum < _pointHasData.length && _pointHasData[inPointNum]);
}
/**
* @param inPointNum index of point
* @return value corresponding to that point
*/
public double getData(int inPointNum)
{
if (!hasData(inPointNum)) {return 0.0;}
return _pointValues[inPointNum];
}
/**
* @return minimum value
*/
public double getMinValue() {
return _minValue;
}
/**
* @return maximum value
*/
public double getMaxValue() {
return _maxValue;
}
/**
* Get the data from the track and populate the value arrays
*/
public abstract void init();
/**
* @return text for label including units
*/
public abstract String getLabel();
/**
* @return key for message when no data available
*/
public abstract String getNoDataKey();
/**
* Initialise the data arrays
*/
protected void initArrays()
{
int numTrackPoints = _track.getNumPoints();
if (_pointHasData == null || _pointHasData.length != numTrackPoints)
{
_pointHasData = new boolean[numTrackPoints];
_pointValues = new double[numTrackPoints];
}
}
}
|