1 package tim.prune.gui.profile;
3 import tim.prune.I18nManager;
4 import tim.prune.data.Altitude;
5 import tim.prune.data.DataPoint;
6 import tim.prune.data.Track;
9 * Class to provide a source of altitude data for the profile chart
11 public class AltitudeData extends ProfileData
13 /** Altitude format for values */
14 private Altitude.Format _altitudeFormat = Altitude.Format.NO_FORMAT;
19 * @param inTrack track object
21 public AltitudeData(Track inTrack) {
26 * Get the data and populate the instance arrays
32 _altitudeFormat = Altitude.Format.NO_FORMAT;
34 for (int i=0; i<_track.getNumPoints(); i++)
36 DataPoint point = _track.getPoint(i);
37 if (point != null && point.hasAltitude())
39 // Point has an altitude - if it's the first one, use its format
40 if (_altitudeFormat == Altitude.Format.NO_FORMAT)
42 _altitudeFormat = point.getAltitude().getFormat();
43 _minValue = _maxValue = point.getAltitude().getValue();
45 // Store the value and maintain max and min values
46 double value = point.getAltitude().getValue(_altitudeFormat);
47 _pointValues[i] = value;
48 if (value < _minValue) {_minValue = value;}
49 if (value > _maxValue) {_maxValue = value;}
52 _pointHasData[i] = true;
54 else _pointHasData[i] = false;
60 * @return text description including units
62 public String getLabel()
64 return I18nManager.getText("fieldname.altitude") + " ("
65 + I18nManager.getText(_altitudeFormat==Altitude.Format.FEET?"units.feet.short":"units.metres.short")
70 * @return key for message when no altitudes present
72 public String getNoDataKey() {
73 return "display.noaltitudes";