Ticket #1730: ticket1730.patch
| File ticket1730.patch, 7.6 KB (added by , 17 years ago) |
|---|
-
home/mli/workspace/JOSM/src/org/openstreetmap/josm/gui/preferences/ProjectionPreference.java
13 13 14 14 import org.openstreetmap.josm.Main; 15 15 import org.openstreetmap.josm.data.projection.Projection; 16 import org.openstreetmap.josm.data.projection.Projection.CoordinateDisplay; 16 17 import org.openstreetmap.josm.tools.GBC; 17 18 18 19 public class ProjectionPreference implements PreferenceSetting { … … 21 22 * Combobox with all projections available 22 23 */ 23 24 private JComboBox projectionCombo = new JComboBox(Projection.allProjections); 25 private JComboBox coordinatesCombo = new JComboBox(CoordinateDisplay.values()); 24 26 25 27 public void addGui(PreferenceDialog gui) { 26 for (int i = 0; i < projectionCombo.getItemCount(); ++i) { 27 if (projectionCombo.getItemAt(i).getClass().getName().equals(Main.pref.get("projection"))) { 28 projectionCombo.setSelectedIndex(i); 29 break; 30 } 31 } 28 29 for (int i = 0; i < projectionCombo.getItemCount(); ++i) { 30 if (projectionCombo.getItemAt(i).getClass().getName().equals(Main.pref.get("projection"))) { 31 projectionCombo.setSelectedIndex(i); 32 break; 33 } 34 } 35 36 for (int i = 0; i < coordinatesCombo.getItemCount(); ++i) { 37 if (coordinatesCombo.getItemAt(i).toString().equals(Main.pref.get("coordinates"))) { 38 coordinatesCombo.setSelectedIndex(i); 39 break; 40 } 41 } 42 32 43 projectionCombo.addActionListener(gui.requireRestartAction); 44 coordinatesCombo.addActionListener(gui.requireRestartAction); 33 45 34 46 JPanel projPanel = new JPanel(); 35 47 projPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.gray), tr("Map Projection"))); … … 37 49 projPanel.add(new JLabel(tr("Projection method")), GBC.std().insets(5,5,0,5)); 38 50 projPanel.add(GBC.glue(5,0), GBC.std().fill(GBC.HORIZONTAL)); 39 51 projPanel.add(projectionCombo, GBC.eop().fill(GBC.HORIZONTAL).insets(0,5,5,5)); 52 projPanel.add(new JLabel(tr("Display coordinates as")), GBC.std().insets(5,5,0,5)); 53 projPanel.add(GBC.glue(5,0), GBC.std().fill(GBC.HORIZONTAL)); 54 projPanel.add(coordinatesCombo, GBC.eop().fill(GBC.HORIZONTAL).insets(0,5,5,5)); 40 55 gui.map.add(projPanel, GBC.eol().insets(0,0,0,10).fill(GBC.HORIZONTAL)); 41 56 } 42 57 43 58 public void ok() { 44 59 Main.pref.put("projection", projectionCombo.getSelectedItem().getClass().getName()); 60 Main.pref.put("coordinates", coordinatesCombo.getSelectedItem().toString()); 45 61 } 46 62 } -
home/mli/workspace/JOSM/src/org/openstreetmap/josm/gui/MapStatus.java
88 88 } 89 89 } 90 90 91 String mCord; 91 92 DecimalFormat latlon = new DecimalFormat("###0.0000"); 92 ImageLabel lonText = new ImageLabel("lon", tr("The geographic longitude at the mouse pointer."), 8);93 ImageLabel lonText = new ImageLabel("lon", tr("The geographic longitude at the mouse pointer."), 10); 93 94 ImageLabel nameText = new ImageLabel("name", tr("The name of the object at the mouse pointer."), 20); 94 95 JTextField helpText = new JTextField(); 95 ImageLabel latText = new ImageLabel("lat", tr("The geographic latitude at the mouse pointer."), 7);96 ImageLabel latText = new ImageLabel("lat", tr("The geographic latitude at the mouse pointer."), 10); 96 97 ImageLabel angleText = new ImageLabel("angle", tr("The angle between the previous and the current way segment."), 6); 97 98 ImageLabel headingText = new ImageLabel("heading", tr("The (compass) heading of the line segment being drawn."), 6); 98 99 ImageLabel distText = new ImageLabel("dist", tr("The length of the new way segment being drawn."), 8); … … 253 254 */ 254 255 public MapStatus(final MapFrame mapFrame) { 255 256 this.mv = mapFrame.mapView; 256 257 258 mCord = Main.pref.get("coordinates"); 259 257 260 // Listen for mouse movements and set the position text field 258 261 mv.addMouseMotionListener(new MouseMotionListener(){ 259 262 public void mouseDragged(MouseEvent e) { … … 265 268 // Do not update the view, if ctrl is pressed. 266 269 if ((e.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) == 0) { 267 270 LatLon p = mv.getLatLon(e.getX(),e.getY()); 268 latText.setText( latlon.format(p.lat()));269 lonText.setText( latlon.format(p.lon()));271 latText.setText(p.lat(mCord, latlon)); 272 lonText.setText(p.lon(mCord, latlon)); 270 273 } 271 274 } 272 275 }); -
home/mli/workspace/JOSM/src/org/openstreetmap/josm/data/coor/LatLon.java
1 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others 2 2 package org.openstreetmap.josm.data.coor; 3 3 4 import java.text.DecimalFormat; 5 import java.text.NumberFormat; 6 4 7 import org.openstreetmap.josm.data.Bounds; 5 8 import org.openstreetmap.josm.data.projection.Projection; 6 import java.text.NumberFormat;9 import org.openstreetmap.josm.data.projection.Projection.CoordinateDisplay; 7 10 8 11 /** 9 12 * LatLon are unprojected latitude / longitude coordinates. … … 13 16 * @author Imi 14 17 */ 15 18 public class LatLon extends Coordinate { 19 20 private static DecimalFormat mFormatter = new DecimalFormat("00.00"); 21 22 public static String convertDDToDMS(double pCordinate) { 23 24 int tDegree = (int) pCordinate; 25 double tTmpMinutes = (pCordinate - tDegree) * 60; 26 int tMinutes = (int) tTmpMinutes; 27 double tSeconds = (tTmpMinutes - tMinutes) * 60; 28 29 return tDegree + "\u00B0" + tMinutes + "\'" + mFormatter.format(tSeconds) + "\""; 30 } 16 31 17 32 public LatLon(double lat, double lon) { 18 33 super(lon, lat); … … 21 36 public double lat() { 22 37 return y; 23 38 } 39 40 public String lat(String pCord, DecimalFormat pFormat) { 41 42 if (pCord.equals(CoordinateDisplay.DD.toString())) { 43 return pFormat.format(y); 44 } 45 else { 46 return convertDDToDMS(y); 47 } 48 } 24 49 25 50 public double lon() { 26 51 return x; 27 52 } 53 54 public String lon(String pCord, DecimalFormat pFormat) { 55 56 if (pCord.equals(CoordinateDisplay.DD.toString())) { 57 return pFormat.format(x); 58 } 59 else { 60 return convertDDToDMS(x); 61 } 62 } 28 63 29 64 /** 30 65 * @return <code>true</code> if the other point has almost the same lat/lon -
home/mli/workspace/JOSM/src/org/openstreetmap/josm/data/projection/Projection.java
37 37 }; 38 38 39 39 /** 40 * Possible ways to display coordinates 41 */ 42 public enum CoordinateDisplay { 43 DD {public String toString() {return "Decimal Degrees";}}, 44 DMS {public String toString() {return "Degree Minute Second";}}; 45 } 46 47 /** 40 48 * Convert from lat/lon to northing/easting. 41 49 * 42 50 * @param p The geo point to convert. x/y members of the point are filled.
