1 package tim.prune.gui.profile;
3 import tim.prune.I18nManager;
4 import tim.prune.data.GradientCalculator;
5 import tim.prune.data.SpeedValue;
6 import tim.prune.data.Track;
7 import tim.prune.data.UnitSet;
10 * Class to provide a source of gradient data for the profile chart
11 * or for the point colourer
13 public class GradientData extends ProfileData
17 * @param inTrack track object
19 public GradientData(Track inTrack) {
24 * Get the data and populate the instance arrays
26 public void init(UnitSet inUnitSet)
28 setUnitSet(inUnitSet);
31 _minValue = _maxValue = 0.0;
32 SpeedValue speed = new SpeedValue();
35 for (int i=0; i<_track.getNumPoints(); i++)
37 // Get the gradient either from the speed values or from the distances and altitudes
38 GradientCalculator.calculateGradient(_track, i, speed);
41 double speedValue = speed.getValue();
42 _pointValues[i] = speedValue;
43 if (speedValue < _minValue || !_hasData) {_minValue = speedValue;}
44 if (speedValue > _maxValue || !_hasData) {_maxValue = speedValue;}
47 _pointHasData[i] = speed.isValid();
53 * @return text description
55 public String getLabel()
57 return I18nManager.getText("fieldname.gradient");
61 * @return key for message when no altitudes present
63 public String getNoDataKey() {
64 return "display.noaltitudes";