]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/function/AddAltitudeOffset.java
Version 14, October 2012
[GpsPrune.git] / tim / prune / function / AddAltitudeOffset.java
index 14adb8364189b949d580020bd7c51534e396d07f..85c52dee7f5291bc8293be3aa3b5038a0068a150 100644 (file)
@@ -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,6 +18,7 @@ import javax.swing.JTextField;
 import tim.prune.App;
 import tim.prune.GenericFunction;
 import tim.prune.I18nManager;
+import tim.prune.config.Config;
 import tim.prune.data.Altitude;
 import tim.prune.data.Field;
 
@@ -70,7 +70,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 +81,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,20 +149,11 @@ 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.FEET;
+               if (Config.getUnitSet().getAltitudeUnit().isStandard()) {
                        _altFormat = Altitude.Format.METRES;
                }
                final String unitKey = (_altFormat==Altitude.Format.METRES?"units.metres.short":"units.feet.short");