Changeset 3948 in josm
- Timestamp:
- 2011-03-02T19:03:33+01:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/ImageryAdjustAction.java
r3919 r3948 11 11 import java.awt.event.AWTEventListener; 12 12 import java.awt.event.ActionEvent; 13 import java.awt.event.FocusEvent; 14 import java.awt.event.FocusListener; 13 15 import java.awt.event.KeyEvent; 14 16 import java.awt.event.MouseEvent; 15 17 import java.awt.event.MouseListener; 16 18 import 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 22 20 import javax.swing.JLabel; 23 21 import javax.swing.JPanel; … … 149 147 } 150 148 151 class ImageryOffsetDialog extends ExtendedDialog implements PropertyChangeListener {152 public final J FormattedTextField easting = new JFormattedTextField(new DecimalFormat("0.00000E0"));153 public final J FormattedTextField 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(); 154 152 JTextField tBookmarkName = new JTextField(); 155 153 private boolean ignoreListener; … … 173 171 easting.setColumns(8); 174 172 northing.setColumns(8); 175 easting.set Value(layer.getDx());176 northing.set Value(layer.getDy());177 easting.add PropertyChangeListener("value",this);178 northing.add PropertyChangeListener("value",this);173 easting.setText(String.valueOf(layer.getDx())); 174 northing.setText(String.valueOf(layer.getDy())); 175 easting.addFocusListener(this); 176 northing.addFocusListener(this); 179 177 setContent(pnl); 180 178 setupDialog(); … … 182 180 183 181 @Override 184 public void propertyChange(PropertyChangeEvent evt) { 182 public void focusGained(FocusEvent e) { 183 } 184 185 @Override 186 public void focusLost(FocusEvent e) { 185 187 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); 187 201 Main.map.repaint(); 188 202 } … … 190 204 public void updateOffset() { 191 205 ignoreListener = true; 192 easting.set Value(layer.getDx());193 northing.set Value(layer.getDy());206 easting.setText(String.valueOf(layer.getDx())); 207 northing.setText(String.valueOf(layer.getDy())); 194 208 ignoreListener = false; 195 209 }
Note:
See TracChangeset
for help on using the changeset viewer.