X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Ffunction%2FAddAltitudeOffset.java;h=c98ab3e17843a27db638d74ffac802c5400bea36;hb=92dad5df664287acb51728e9ea599f150765d34a;hp=14adb8364189b949d580020bd7c51534e396d07f;hpb=112bb0c9b46894adca9a33ed8c99ea712b253185;p=GpsPrune.git diff --git a/tim/prune/function/AddAltitudeOffset.java b/tim/prune/function/AddAltitudeOffset.java index 14adb83..c98ab3e 100644 --- a/tim/prune/function/AddAltitudeOffset.java +++ b/tim/prune/function/AddAltitudeOffset.java @@ -1,7 +1,6 @@ package tim.prune.function; import java.awt.BorderLayout; -import java.awt.Component; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -19,8 +18,10 @@ import javax.swing.JTextField; 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 @@ -31,7 +32,7 @@ public class AddAltitudeOffset extends GenericFunction private JLabel _descLabel = null; private JTextField _editField = null; private JButton _okButton = null; - private Altitude.Format _altFormat = Altitude.Format.NO_FORMAT; + private Unit _altUnit = null; /** @@ -70,7 +71,7 @@ public class AddAltitudeOffset extends GenericFunction _dialog.pack(); } // Set label according to altitude units - setLabelText(selStart, selEnd); + setLabelText(); // Select the contents of the edit field _editField.selectAll(); _dialog.setVisible(true); @@ -81,7 +82,7 @@ public class AddAltitudeOffset extends GenericFunction * Create dialog components * @return Panel containing all gui elements in dialog */ - private Component makeDialogComponents() + private JPanel makeDialogComponents() { JPanel dialogPanel = new JPanel(); dialogPanel.setLayout(new BorderLayout()); @@ -149,23 +150,14 @@ public class AddAltitudeOffset extends GenericFunction /** * 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) + ")"); } @@ -175,7 +167,7 @@ public class AddAltitudeOffset extends GenericFunction private void finish() { // Pass information back to App to complete function - _app.finishAddAltitudeOffset(_editField.getText(), _altFormat); + _app.finishAddAltitudeOffset(_editField.getText(), _altUnit); _dialog.dispose(); } }