import tim.prune.App;
import tim.prune.GenericFunction;
import tim.prune.I18nManager;
-import tim.prune.data.Altitude;
+import tim.prune.config.Config;
import tim.prune.data.Field;
+import tim.prune.data.Unit;
+import tim.prune.data.UnitSetLibrary;
/**
* Class to provide the function to add an altitude offset to a track range
private JLabel _descLabel = null;
private JTextField _editField = null;
private JButton _okButton = null;
- private Altitude.Format _altFormat = Altitude.Format.NO_FORMAT;
+ private Unit _altUnit = null;
/**
_dialog.pack();
}
// Set label according to altitude units
- setLabelText(selStart, selEnd);
+ setLabelText();
// Select the contents of the edit field
_editField.selectAll();
_dialog.setVisible(true);
/**
* Set the label text according to the current units
- * @param inStart start index of selection
- * @param inEnd end index of selection
*/
- private void setLabelText(int inStart, int inEnd)
+ private void setLabelText()
{
- _altFormat = Altitude.Format.NO_FORMAT;
- for (int i=inStart; i<=inEnd && _altFormat==Altitude.Format.NO_FORMAT; i++)
- {
- Altitude alt = _app.getTrackInfo().getTrack().getPoint(i).getAltitude();
- if (alt != null) {
- _altFormat = alt.getFormat();
- }
- }
- if (_altFormat==Altitude.Format.NO_FORMAT) {
- _altFormat = Altitude.Format.METRES;
+ _altUnit = UnitSetLibrary.UNITS_FEET;
+ if (Config.getUnitSet().getAltitudeUnit().isStandard()) {
+ _altUnit = UnitSetLibrary.UNITS_METRES;
}
- final String unitKey = (_altFormat==Altitude.Format.METRES?"units.metres.short":"units.feet.short");
+ final String unitKey = _altUnit.getShortnameKey();
_descLabel.setText(I18nManager.getText("dialog.addaltitude.desc") + " (" + I18nManager.getText(unitKey) + ")");
}
private void finish()
{
// Pass information back to App to complete function
- _app.finishAddAltitudeOffset(_editField.getText(), _altFormat);
+ _app.finishAddAltitudeOffset(_editField.getText(), _altUnit);
_dialog.dispose();
}
}