Changeset 3948 in josm


Ignore:
Timestamp:
2011-03-02T19:03:33+01:00 (14 years ago)
Author:
bastiK
Message:

fixed #5789 - Get rid of E-notation in offset fields

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/ImageryAdjustAction.java

    r3919 r3948  
    1111import java.awt.event.AWTEventListener;
    1212import java.awt.event.ActionEvent;
     13import java.awt.event.FocusEvent;
     14import java.awt.event.FocusListener;
    1315import java.awt.event.KeyEvent;
    1416import java.awt.event.MouseEvent;
    1517import java.awt.event.MouseListener;
    1618import java.awt.event.MouseMotionListener;
    17 import java.beans.PropertyChangeEvent;
    18 import java.beans.PropertyChangeListener;
    19 import java.text.DecimalFormat;
    20 
    21 import javax.swing.JFormattedTextField;
     19
    2220import javax.swing.JLabel;
    2321import javax.swing.JPanel;
     
    149147    }
    150148
    151     class ImageryOffsetDialog extends ExtendedDialog implements PropertyChangeListener {
    152         public final JFormattedTextField easting = new JFormattedTextField(new DecimalFormat("0.00000E0"));
    153         public final JFormattedTextField northing = new JFormattedTextField(new DecimalFormat("0.00000E0"));
     149    class ImageryOffsetDialog extends ExtendedDialog implements FocusListener {
     150        public final JTextField easting = new JTextField();
     151        public final JTextField northing = new JTextField();
    154152        JTextField tBookmarkName = new JTextField();
    155153        private boolean ignoreListener;
     
    173171            easting.setColumns(8);
    174172            northing.setColumns(8);
    175             easting.setValue(layer.getDx());
    176             northing.setValue(layer.getDy());
    177             easting.addPropertyChangeListener("value",this);
    178             northing.addPropertyChangeListener("value",this);
     173            easting.setText(String.valueOf(layer.getDx()));
     174            northing.setText(String.valueOf(layer.getDy()));
     175            easting.addFocusListener(this);
     176            northing.addFocusListener(this);
    179177            setContent(pnl);
    180178            setupDialog();
     
    182180
    183181        @Override
    184         public void propertyChange(PropertyChangeEvent evt) {
     182        public void focusGained(FocusEvent e) {
     183        }
     184
     185        @Override
     186        public void focusLost(FocusEvent e) {
    185187            if (ignoreListener) return;
    186             layer.setOffset(((Number)easting.getValue()).doubleValue(), ((Number)northing.getValue()).doubleValue());
     188            double dx = oldDx;
     189            try {
     190                dx = Double.parseDouble(easting.getText());
     191            } catch (NumberFormatException nfe) {
     192                easting.setText(String.valueOf(oldDx));
     193            }
     194            double dy = oldDy;
     195            try {
     196                dy = Double.parseDouble(northing.getText());
     197            } catch (NumberFormatException nfe) {
     198                northing.setText(String.valueOf(oldDy));
     199            }
     200            layer.setOffset(dx, dy);
    187201            Main.map.repaint();
    188202        }
     
    190204        public void updateOffset() {
    191205            ignoreListener = true;
    192             easting.setValue(layer.getDx());
    193             northing.setValue(layer.getDy());
     206            easting.setText(String.valueOf(layer.getDx()));
     207            northing.setText(String.valueOf(layer.getDy()));
    194208            ignoreListener = false;
    195209        }
Note: See TracChangeset for help on using the changeset viewer.