]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/function/PasteCoordinates.java
Version 16, February 2014
[GpsPrune.git] / tim / prune / function / PasteCoordinates.java
index 23fe8d285afd8af965a47e62f3fcdc0827a12603..c9b2ad1c7ff3f74da6e8162fbb84d8fa886c1e42 100644 (file)
@@ -29,6 +29,8 @@ import tim.prune.data.DataPoint;
 import tim.prune.data.Field;
 import tim.prune.data.Latitude;
 import tim.prune.data.Longitude;
+import tim.prune.data.Unit;
+import tim.prune.data.UnitSetLibrary;
 import tim.prune.gui.GuiGridLayout;
 
 /**
@@ -41,7 +43,7 @@ public class PasteCoordinates extends GenericFunction
        private JTextField _nameField = null;
        private JTextField _coordField = null;
        private JButton _okButton = null;
-       private JComboBox _altUnitsDropDown;
+       private JComboBox<String> _altUnitsDropDown;
 
 
        /**
@@ -75,8 +77,8 @@ public class PasteCoordinates extends GenericFunction
                // MAYBE: Paste clipboard into the edit field
                _coordField.setText("");
                _nameField.setText("");
-               boolean metric = Config.getConfigBoolean(Config.KEY_METRIC_UNITS);
-               _altUnitsDropDown.setSelectedIndex(metric?0:1);
+               boolean useMetres = (Config.getUnitSet().getAltitudeUnit() == UnitSetLibrary.UNITS_METRES);
+               _altUnitsDropDown.setSelectedIndex(useMetres?0:1);
                enableOK();
                _dialog.setVisible(true);
        }
@@ -120,7 +122,7 @@ public class PasteCoordinates extends GenericFunction
                formatLabel.setHorizontalAlignment(SwingConstants.RIGHT);
                grid.add(formatLabel);
                final String[] altunits = {I18nManager.getText("units.metres"), I18nManager.getText("units.feet")};
-               _altUnitsDropDown = new JComboBox(altunits);
+               _altUnitsDropDown = new JComboBox<String>(altunits);
                grid.add(_altUnitsDropDown);
                // Waypoint name
                JLabel nameLabel = new JLabel(I18nManager.getText("dialog.pointnameedit.name"));
@@ -236,9 +238,9 @@ public class PasteCoordinates extends GenericFunction
                if (inValue3 != null)
                {
                        // Look at altitude units dropdown
-                       final Altitude.Format altFormat = (_altUnitsDropDown.getSelectedIndex()==0?
-                               Altitude.Format.METRES:Altitude.Format.FEET);
-                       alt = new Altitude(inValue3, altFormat);
+                       final Unit altUnit = (_altUnitsDropDown.getSelectedIndex()==0?
+                               UnitSetLibrary.UNITS_METRES : UnitSetLibrary.UNITS_FEET);
+                       alt = new Altitude(inValue3, altUnit);
                        if (!alt.isValid()) {alt = null;}
                }
                // See if value1 can be lat and value2 lon: