Changeset 6992 in josm
- Timestamp:
- 2014-04-22T01:06:55+02:00 (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r6990 r6992 58 58 import org.openstreetmap.josm.data.ServerSidePreferences; 59 59 import org.openstreetmap.josm.data.UndoRedoHandler; 60 import org.openstreetmap.josm.data.ViewportData; 60 61 import org.openstreetmap.josm.data.coor.CoordinateFormat; 61 62 import org.openstreetmap.josm.data.coor.LatLon; … … 72 73 import org.openstreetmap.josm.gui.MapFrameListener; 73 74 import org.openstreetmap.josm.gui.MapView; 74 import org.openstreetmap.josm.gui.NavigatableComponent.ViewportData;75 75 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 76 76 import org.openstreetmap.josm.gui.help.HelpUtil; -
trunk/src/org/openstreetmap/josm/actions/SessionLoadAction.java
r6643 r6992 19 19 20 20 import org.openstreetmap.josm.Main; 21 import org.openstreetmap.josm.data.ViewportData; 21 22 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 22 import org.openstreetmap.josm.gui.NavigatableComponent.ViewportData;23 23 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 24 24 import org.openstreetmap.josm.gui.layer.Layer; -
trunk/src/org/openstreetmap/josm/actions/mapmode/ParallelWayAction.java
r6792 r6992 25 25 import org.openstreetmap.josm.Main; 26 26 import org.openstreetmap.josm.data.Bounds; 27 import org.openstreetmap.josm.data.SystemOfMeasurement; 27 28 import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent; 28 29 import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener; … … 36 37 import org.openstreetmap.josm.gui.MapView; 37 38 import org.openstreetmap.josm.gui.NavigatableComponent; 38 import org.openstreetmap.josm.gui.NavigatableComponent.SystemOfMeasurement;39 39 import org.openstreetmap.josm.gui.layer.Layer; 40 40 import org.openstreetmap.josm.gui.layer.MapViewPaintable; … … 429 429 double snapDistance; 430 430 SystemOfMeasurement som = NavigatableComponent.getSystemOfMeasurement(); 431 if (som.equals( NavigatableComponent.CHINESE_SOM)) {432 snapDistance = snapDistanceChinese * NavigatableComponent.CHINESE_SOM.aValue;433 } else if (som.equals( NavigatableComponent.IMPERIAL_SOM)) {434 snapDistance = snapDistanceImperial * NavigatableComponent.IMPERIAL_SOM.aValue;435 } else if (som.equals( NavigatableComponent.NAUTICAL_MILE_SOM)) {436 snapDistance = snapDistanceNautical * NavigatableComponent.NAUTICAL_MILE_SOM.aValue;431 if (som.equals(SystemOfMeasurement.CHINESE)) { 432 snapDistance = snapDistanceChinese * SystemOfMeasurement.CHINESE.aValue; 433 } else if (som.equals(SystemOfMeasurement.IMPERIAL)) { 434 snapDistance = snapDistanceImperial * SystemOfMeasurement.IMPERIAL.aValue; 435 } else if (som.equals(SystemOfMeasurement.NAUTICAL_MILE)) { 436 snapDistance = snapDistanceNautical * SystemOfMeasurement.NAUTICAL_MILE.aValue; 437 437 } else { 438 438 snapDistance = snapDistanceMetric; // Metric system by default -
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r6957 r6992 48 48 import org.openstreetmap.josm.gui.MapFrame; 49 49 import org.openstreetmap.josm.gui.MapView; 50 import org.openstreetmap.josm.gui.NavigatableComponent;51 50 import org.openstreetmap.josm.gui.SelectionManager; 52 51 import org.openstreetmap.josm.gui.SelectionManager.SelectionEnded; … … 248 247 */ 249 248 private boolean giveUserFeedback(MouseEvent e, int modifiers) { 250 Collection<OsmPrimitive> c = MapView.asColl(249 Collection<OsmPrimitive> c = asColl( 251 250 mv.getNearestNodeOrWay(e.getPoint(), OsmPrimitive.isSelectablePredicate, true)); 252 251 … … 431 430 // if nothing was selected, select primitive under cursor for scaling or rotating 432 431 if (getCurrentDataSet().getSelected().isEmpty()) { 433 getCurrentDataSet().setSelected( MapView.asColl(nearestPrimitive));432 getCurrentDataSet().setSelected(asColl(nearestPrimitive)); 434 433 } 435 434 … … 446 445 } 447 446 OsmPrimitive toSelect = cycleManager.cycleSetup(nearestPrimitive, e.getPoint()); 448 selectPrims( NavigatableComponent.asColl(toSelect), false, false);447 selectPrims(asColl(toSelect), false, false); 449 448 useLastMoveCommandIfPossible(); 450 449 // Schedule a timer to update status line "initialMoveDelay+1" ms in the future … … 522 521 needsRepaint = true; 523 522 } 524 mv.setNewCursor(getCursor( MapView.asColl(p)), this);523 mv.setNewCursor(getCursor(asColl(p)), this); 525 524 // also update the stored mouse event, so we can display the correct cursor 526 525 // when dragging a node onto another one and then press CTRL to merge … … 953 952 if (!(alt || multipleMatchesParameter)) { 954 953 // no real cycling, just one element in cycle list 955 cycleList = MapView.asColl(osm);954 cycleList = asColl(osm); 956 955 957 956 if (waitForMouseUpParameter) { … … 1060 1059 } 1061 1060 // return one-element collection with one element to be selected (or added to selection) 1062 return MapView.asColl(nxt);1061 return asColl(nxt); 1063 1062 } 1064 1063 } … … 1162 1161 } 1163 1162 } 1163 1164 /** 1165 * @return o as collection of o's type. 1166 */ 1167 protected static <T> Collection<T> asColl(T o) { 1168 if (o == null) 1169 return Collections.emptySet(); 1170 return Collections.singleton(o); 1171 } 1164 1172 } -
trunk/src/org/openstreetmap/josm/data/imagery/WmsCache.java
r6643 r6992 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.data.imagery; 3 4 3 5 4 import java.awt.Graphics2D; … … 35 34 import org.openstreetmap.josm.Main; 36 35 import org.openstreetmap.josm.data.ProjectionBounds; 36 import org.openstreetmap.josm.data.SystemOfMeasurement; 37 37 import org.openstreetmap.josm.data.coor.EastNorth; 38 38 import org.openstreetmap.josm.data.coor.LatLon; … … 42 42 import org.openstreetmap.josm.data.preferences.StringProperty; 43 43 import org.openstreetmap.josm.data.projection.Projection; 44 import org.openstreetmap.josm.gui.NavigatableComponent;45 44 import org.openstreetmap.josm.tools.Utils; 46 47 48 45 49 46 public class WmsCache { … … 454 451 int precisionLon = Math.max(0, -(int)Math.ceil(Math.log10(deltaLon)) + 1); 455 452 456 String zoom = NavigatableComponent.METRIC_SOM.getDistText(ll1.greatCircleDistance(ll2));453 String zoom = SystemOfMeasurement.METRIC.getDistText(ll1.greatCircleDistance(ll2)); 457 454 String extension; 458 455 if ("image/jpeg".equals(mimeType) || "image/jpg".equals(mimeType)) { -
trunk/src/org/openstreetmap/josm/gui/MapFrame.java
r6454 r6992 53 53 import org.openstreetmap.josm.actions.mapmode.ZoomAction; 54 54 import org.openstreetmap.josm.data.Preferences; 55 import org.openstreetmap.josm.data.ViewportData; 55 56 import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent; 56 57 import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener; 57 58 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 58 import org.openstreetmap.josm.gui.NavigatableComponent.ViewportData;59 59 import org.openstreetmap.josm.gui.dialogs.ChangesetDialog; 60 60 import org.openstreetmap.josm.gui.dialogs.CommandStackDialog; -
trunk/src/org/openstreetmap/josm/gui/MapStatus.java
r6977 r6992 50 50 51 51 import org.openstreetmap.josm.Main; 52 import org.openstreetmap.josm.data.SystemOfMeasurement; 52 53 import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent; 53 54 import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener; … … 732 733 733 734 public MapStatusPopupMenu() { 734 for (final String key : new TreeSet<String>( NavigatableComponent.SYSTEMS_OF_MEASUREMENT.keySet())) {735 for (final String key : new TreeSet<String>(SystemOfMeasurement.ALL_SYSTEMS.keySet())) { 735 736 JCheckBoxMenuItem item = new JCheckBoxMenuItem(new AbstractAction(key) { 736 737 @Override … … 829 830 if (Main.pref.getBoolean("statusbar.change-system-of-measurement-on-click", true)) { 830 831 distText.addMouseListener(new MouseAdapter() { 831 private final List<String> soms = new ArrayList<String>(new TreeSet<String>( NavigatableComponent.SYSTEMS_OF_MEASUREMENT.keySet()));832 private final List<String> soms = new ArrayList<String>(new TreeSet<String>(SystemOfMeasurement.ALL_SYSTEMS.keySet())); 832 833 833 834 @Override -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r6883 r6992 40 40 import org.openstreetmap.josm.actions.mapmode.MapMode; 41 41 import org.openstreetmap.josm.data.Bounds; 42 import org.openstreetmap.josm.data.ViewportData; 42 43 import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent; 43 44 import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener; -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r6873 r6992 1 1 // License: GPL. See LICENSE file for details. 2 2 package org.openstreetmap.josm.gui; 3 4 import static org.openstreetmap.josm.tools.I18n.marktr;5 3 6 4 import java.awt.Cursor; … … 11 9 import java.awt.geom.AffineTransform; 12 10 import java.awt.geom.Point2D; 13 import java.text.NumberFormat;14 11 import java.util.ArrayList; 15 12 import java.util.Collection; … … 17 14 import java.util.Date; 18 15 import java.util.HashSet; 19 import java.util.LinkedHashMap;20 16 import java.util.LinkedList; 21 17 import java.util.List; 22 import java.util.Locale;23 18 import java.util.Map; 24 19 import java.util.Map.Entry; … … 33 28 import org.openstreetmap.josm.data.Bounds; 34 29 import org.openstreetmap.josm.data.ProjectionBounds; 30 import org.openstreetmap.josm.data.SystemOfMeasurement; 35 31 import org.openstreetmap.josm.data.coor.CachedLatLon; 36 32 import org.openstreetmap.josm.data.coor.EastNorth; … … 54 50 55 51 /** 56 * A n component that can be navigated by a mapmover. Used as map view and for the52 * A component that can be navigated by a {@link MapMover}. Used as map view and for the 57 53 * zoomer in the download dialog. 58 54 * 59 55 * @author imi 56 * @since 41 60 57 */ 61 58 public class NavigatableComponent extends JComponent implements Helpful { … … 65 62 */ 66 63 public interface ZoomChangeListener { 64 /** 65 * Method called when the zoom area has changed. 66 */ 67 67 void zoomChanged(); 68 68 } … … 81 81 } 82 82 83 /**84 * Simple data class that keeps map center and scale in one object.85 */86 public static class ViewportData {87 private EastNorth center;88 private Double scale;89 90 public ViewportData(EastNorth center, Double scale) {91 this.center = center;92 this.scale = scale;93 }94 95 /**96 * Return the projected coordinates of the map center97 * @return the center98 */99 public EastNorth getCenter() {100 return center;101 }102 103 /**104 * Return the scale factor in east-/north-units per pixel.105 * @return the scale106 */107 public Double getScale() {108 return scale;109 }110 }111 112 83 public static final IntegerProperty PROP_SNAP_DISTANCE = new IntegerProperty("mappaint.node.snap-distance", 10); 113 84 … … 146 117 } 147 118 148 /**149 * the SoM listeners150 */151 119 private static final CopyOnWriteArrayList<SoMChangeListener> somChangeListeners = new CopyOnWriteArrayList<SoMChangeListener>(); 152 120 … … 185 153 */ 186 154 private double scale = Main.getProjection().getDefaultZoomInPPD(); 155 187 156 /** 188 157 * Center n/e coordinate of the desired screen center. … … 233 202 } 234 203 235 public String getDist100PixelText() 236 { 204 public String getDist100PixelText() { 237 205 return getDistText(getDist100Pixel()); 238 206 } 239 207 240 public double getDist100Pixel() 241 { 208 public double getDist100Pixel() { 242 209 int w = getWidth()/2; 243 210 int h = getHeight()/2; … … 263 230 * @param y Y-Pixelposition to get coordinate from 264 231 * 265 * @return Geographic coordinates from a specific pixel coordination 266 * on the screen. 232 * @return Geographic coordinates from a specific pixel coordination on the screen. 267 233 */ 268 234 public EastNorth getEastNorth(int x, int y) { … … 549 515 550 516 private class ZoomData { 551 LatLon center;552 double scale;517 final LatLon center; 518 final double scale; 553 519 554 520 public ZoomData(EastNorth center, double scale) { … … 731 697 * give the nearest node that is tagged. 732 698 */ 733 public final Node getNearestNode(Point p, Predicate<OsmPrimitive> predicate, boolean use _selected) {734 return getNearestNode(p, predicate, use _selected, null);699 public final Node getNearestNode(Point p, Predicate<OsmPrimitive> predicate, boolean useSelected) { 700 return getNearestNode(p, predicate, useSelected, null); 735 701 } 736 702 … … 811 777 /** 812 778 * Convenience method to {@link #getNearestNode(Point, Predicate, boolean)}. 779 * @param p the screen point 780 * @param predicate this parameter imposes a condition on the returned object, e.g. 781 * give the nearest node that is tagged. 813 782 * 814 783 * @return The nearest node to point p. … … 940 909 * @param p the point for which to search the nearest segment. 941 910 * @param predicate the returned object has to fulfill certain properties. 942 * @param use _selected whether selected way segments should be preferred.943 */ 944 public final WaySegment getNearestWaySegment(Point p, Predicate<OsmPrimitive> predicate, boolean use _selected) {911 * @param useSelected whether selected way segments should be preferred. 912 */ 913 public final WaySegment getNearestWaySegment(Point p, Predicate<OsmPrimitive> predicate, boolean useSelected) { 945 914 WaySegment wayseg = null, ntsel = null; 946 915 … … 959 928 } 960 929 961 return (ntsel != null && use _selected) ? ntsel : wayseg;930 return (ntsel != null && useSelected) ? ntsel : wayseg; 962 931 } 963 932 … … 1017 986 /** 1018 987 * Convenience method to {@link #getNearestWaySegment(Point, Predicate, boolean)}. 988 * @param p the point for which to search the nearest segment. 989 * @param predicate the returned object has to fulfill certain properties. 1019 990 * 1020 991 * @return The nearest way segment to point p. … … 1177 1148 * that is chosen by the algorithm described. 1178 1149 * @see #getNearestNode(Point, Predicate) 1179 * @see #getNearestNodesImpl(Point, Predicate)1180 1150 * @see #getNearestWay(Point, Predicate) 1181 1151 * … … 1223 1193 } 1224 1194 1225 /**1226 * @return o as collection of o's type.1227 */1228 public static <T> Collection<T> asColl(T o) {1229 if (o == null)1230 return Collections.emptySet();1231 return Collections.singleton(o);1232 }1233 1234 1195 public static double perDist(Point2D pt, Point2D a, Point2D b) { 1235 1196 if (pt != null && a != null && b != null) { … … 1360 1321 /** 1361 1322 * Return a ID which is unique as long as viewport dimensions are the same 1323 * @return A unique ID, as long as viewport dimensions are the same 1362 1324 */ 1363 1325 public int getViewID() { … … 1375 1337 */ 1376 1338 public static SystemOfMeasurement getSystemOfMeasurement() { 1377 SystemOfMeasurement som = S YSTEMS_OF_MEASUREMENT.get(ProjectionPreference.PROP_SYSTEM_OF_MEASUREMENT.get());1339 SystemOfMeasurement som = SystemOfMeasurement.ALL_SYSTEMS.get(ProjectionPreference.PROP_SYSTEM_OF_MEASUREMENT.get()); 1378 1340 if (som == null) 1379 return METRIC_SOM;1341 return SystemOfMeasurement.METRIC; 1380 1342 return som; 1381 1343 } … … 1383 1345 /** 1384 1346 * Sets the current system of measurement. 1385 * @param somKey The system of measurement key. Must be defined in {@link NavigatableComponent#SYSTEMS_OF_MEASUREMENT}.1347 * @param somKey The system of measurement key. Must be defined in {@link SystemOfMeasurement#ALL_SYSTEMS}. 1386 1348 * @since 6056 1387 1349 * @throws IllegalArgumentException if {@code somKey} is not known 1388 1350 */ 1389 1351 public static void setSystemOfMeasurement(String somKey) { 1390 if (!S YSTEMS_OF_MEASUREMENT.containsKey(somKey)) {1352 if (!SystemOfMeasurement.ALL_SYSTEMS.containsKey(somKey)) { 1391 1353 throw new IllegalArgumentException("Invalid system of measurement: "+somKey); 1392 1354 } … … 1397 1359 } 1398 1360 1399 /**1400 * A system of units used to express length and area measurements.1401 * @since 34061402 */1403 public static class SystemOfMeasurement {1404 1405 /** First value, in meters, used to translate unit according to above formula. */1406 public final double aValue;1407 /** Second value, in meters, used to translate unit according to above formula. */1408 public final double bValue;1409 /** First unit used to format text. */1410 public final String aName;1411 /** Second unit used to format text. */1412 public final String bName;1413 /** Specific optional area value, in squared meters, between {@code aValue*aValue} and {@code bValue*bValue}. Set to {@code -1} if not used.1414 * @since 5870 */1415 public final double areaCustomValue;1416 /** Specific optional area unit. Set to {@code null} if not used.1417 * @since 5870 */1418 public final String areaCustomName;1419 1420 /**1421 * System of measurement. Currently covers only length (and area) units.1422 *1423 * If a quantity x is given in m (x_m) and in unit a (x_a) then it translates as1424 * x_a == x_m / aValue1425 *1426 * @param aValue First value, in meters, used to translate unit according to above formula.1427 * @param aName First unit used to format text.1428 * @param bValue Second value, in meters, used to translate unit according to above formula.1429 * @param bName Second unit used to format text.1430 */1431 public SystemOfMeasurement(double aValue, String aName, double bValue, String bName) {1432 this(aValue, aName, bValue, bName, -1, null);1433 }1434 1435 /**1436 * System of measurement. Currently covers only length (and area) units.1437 *1438 * If a quantity x is given in m (x_m) and in unit a (x_a) then it translates as1439 * x_a == x_m / aValue1440 *1441 * @param aValue First value, in meters, used to translate unit according to above formula.1442 * @param aName First unit used to format text.1443 * @param bValue Second value, in meters, used to translate unit according to above formula.1444 * @param bName Second unit used to format text.1445 * @param areaCustomValue Specific optional area value, in squared meters, between {@code aValue*aValue} and {@code bValue*bValue}.1446 * Set to {@code -1} if not used.1447 * @param areaCustomName Specific optional area unit. Set to {@code null} if not used.1448 *1449 * @since 58701450 */1451 public SystemOfMeasurement(double aValue, String aName, double bValue, String bName, double areaCustomValue, String areaCustomName) {1452 this.aValue = aValue;1453 this.aName = aName;1454 this.bValue = bValue;1455 this.bName = bName;1456 this.areaCustomValue = areaCustomValue;1457 this.areaCustomName = areaCustomName;1458 }1459 1460 /**1461 * Returns the text describing the given distance in this system of measurement.1462 * @param dist The distance in metres1463 * @return The text describing the given distance in this system of measurement.1464 */1465 public String getDistText(double dist) {1466 return getDistText(dist, null, 0.01);1467 }1468 1469 /**1470 * Returns the text describing the given distance in this system of measurement.1471 * @param dist The distance in metres1472 * @param format A {@link NumberFormat} to format the area value1473 * @param threshold Values lower than this {@code threshold} are displayed as {@code "< [threshold]"}1474 * @return The text describing the given distance in this system of measurement.1475 * @since 64221476 */1477 public String getDistText(final double dist, final NumberFormat format, final double threshold) {1478 double a = dist / aValue;1479 if (!Main.pref.getBoolean("system_of_measurement.use_only_lower_unit", false) && a > bValue / aValue)1480 return formatText(dist / bValue, bName, format);1481 else if (a < threshold)1482 return "< " + formatText(threshold, aName, format);1483 else1484 return formatText(a, aName, format);1485 }1486 1487 /**1488 * Returns the text describing the given area in this system of measurement.1489 * @param area The area in square metres1490 * @return The text describing the given area in this system of measurement.1491 * @since 55601492 */1493 public String getAreaText(double area) {1494 return getAreaText(area, null, 0.01);1495 }1496 1497 /**1498 * Returns the text describing the given area in this system of measurement.1499 * @param area The area in square metres1500 * @param format A {@link NumberFormat} to format the area value1501 * @param threshold Values lower than this {@code threshold} are displayed as {@code "< [threshold]"}1502 * @return The text describing the given area in this system of measurement.1503 * @since 64221504 */1505 public String getAreaText(final double area, final NumberFormat format, final double threshold) {1506 double a = area / (aValue*aValue);1507 boolean lowerOnly = Main.pref.getBoolean("system_of_measurement.use_only_lower_unit", false);1508 boolean customAreaOnly = Main.pref.getBoolean("system_of_measurement.use_only_custom_area_unit", false);1509 if ((!lowerOnly && areaCustomValue > 0 && a > areaCustomValue / (aValue*aValue) && a < (bValue*bValue) / (aValue*aValue)) || customAreaOnly)1510 return formatText(area / areaCustomValue, areaCustomName, format);1511 else if (!lowerOnly && a >= (bValue*bValue) / (aValue*aValue))1512 return formatText(area / (bValue * bValue), bName + "\u00b2", format);1513 else if (a < threshold)1514 return "< " + formatText(threshold, aName + "\u00b2", format);1515 else1516 return formatText(a, aName + "\u00b2", format);1517 }1518 1519 private static String formatText(double v, String unit, NumberFormat format) {1520 if (format != null) {1521 return format.format(v) + " " + unit;1522 }1523 return String.format(Locale.US, "%." + (v<9.999999 ? 2 : 1) + "f %s", v, unit);1524 }1525 }1526 1527 /**1528 * Metric system (international standard).1529 * @since 34061530 */1531 public static final SystemOfMeasurement METRIC_SOM = new SystemOfMeasurement(1, "m", 1000, "km", 10000, "ha");1532 1533 /**1534 * Chinese system.1535 * @since 34061536 */1537 public static final SystemOfMeasurement CHINESE_SOM = new SystemOfMeasurement(1.0/3.0, "\u5e02\u5c3a" /* chi */, 500, "\u5e02\u91cc" /* li */);1538 1539 /**1540 * Imperial system (British Commonwealth and former British Empire).1541 * @since 34061542 */1543 public static final SystemOfMeasurement IMPERIAL_SOM = new SystemOfMeasurement(0.3048, "ft", 1609.344, "mi", 4046.86, "ac");1544 1545 /**1546 * Nautical mile system (navigation, polar exploration).1547 * @since 55491548 */1549 public static final SystemOfMeasurement NAUTICAL_MILE_SOM = new SystemOfMeasurement(185.2, "kbl", 1852, "NM");1550 1551 /**1552 * Known systems of measurement.1553 * @since 34061554 */1555 public static final Map<String, SystemOfMeasurement> SYSTEMS_OF_MEASUREMENT;1556 static {1557 SYSTEMS_OF_MEASUREMENT = new LinkedHashMap<String, SystemOfMeasurement>();1558 SYSTEMS_OF_MEASUREMENT.put(marktr("Metric"), METRIC_SOM);1559 SYSTEMS_OF_MEASUREMENT.put(marktr("Chinese"), CHINESE_SOM);1560 SYSTEMS_OF_MEASUREMENT.put(marktr("Imperial"), IMPERIAL_SOM);1561 SYSTEMS_OF_MEASUREMENT.put(marktr("Nautical Mile"), NAUTICAL_MILE_SOM);1562 }1563 1564 1361 private static class CursorInfo { 1565 publicCursor cursor;1566 publicObject object;1362 final Cursor cursor; 1363 final Object object; 1567 1364 public CursorInfo(Cursor c, Object o) { 1568 1365 cursor = c; -
trunk/src/org/openstreetmap/josm/gui/preferences/projection/ProjectionPreference.java
r6920 r6992 24 24 import org.openstreetmap.josm.Main; 25 25 import org.openstreetmap.josm.data.Bounds; 26 import org.openstreetmap.josm.data.SystemOfMeasurement; 26 27 import org.openstreetmap.josm.data.coor.CoordinateFormat; 27 28 import org.openstreetmap.josm.data.preferences.CollectionProperty; … … 246 247 private static final CollectionProperty PROP_SUB_PROJECTION = new CollectionProperty("projection.sub", null); 247 248 public static final StringProperty PROP_SYSTEM_OF_MEASUREMENT = new StringProperty("system_of_measurement", "Metric"); 248 private static final String[] unitsValues = (new ArrayList<String>( NavigatableComponent.SYSTEMS_OF_MEASUREMENT.keySet())).toArray(new String[0]);249 private static final String[] unitsValues = (new ArrayList<String>(SystemOfMeasurement.ALL_SYSTEMS.keySet())).toArray(new String[0]); 249 250 private static final String[] unitsValuesTr = new String[unitsValues.length]; 250 251 static { -
trunk/src/org/openstreetmap/josm/io/session/SessionReader.java
r6792 r6992 33 33 34 34 import org.openstreetmap.josm.Main; 35 import org.openstreetmap.josm.data.ViewportData; 35 36 import org.openstreetmap.josm.data.coor.EastNorth; 36 37 import org.openstreetmap.josm.data.coor.LatLon; … … 38 39 import org.openstreetmap.josm.data.projection.Projections; 39 40 import org.openstreetmap.josm.gui.ExtendedDialog; 40 import org.openstreetmap.josm.gui.NavigatableComponent.ViewportData;41 41 import org.openstreetmap.josm.gui.layer.Layer; 42 42 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; -
trunk/test/unit/org/openstreetmap/josm/gui/SystemOfMeasurementTest.java
r6881 r6992 10 10 import org.junit.Test; 11 11 import org.openstreetmap.josm.Main; 12 import org.openstreetmap.josm. gui.NavigatableComponent.SystemOfMeasurement;12 import org.openstreetmap.josm.data.SystemOfMeasurement; 13 13 14 14 /** … … 31 31 public void testGetDistText() { 32 32 33 assertEquals("< 0.01 m", NavigatableComponent.METRIC_SOM.getDistText(-1));34 assertEquals("< 0.01 m", NavigatableComponent.METRIC_SOM.getDistText(-0.99));35 assertEquals("< 0.01 m", NavigatableComponent.METRIC_SOM.getDistText(-0));36 assertEquals("< 0.01 m", NavigatableComponent.METRIC_SOM.getDistText(0));33 assertEquals("< 0.01 m", SystemOfMeasurement.METRIC.getDistText(-1)); 34 assertEquals("< 0.01 m", SystemOfMeasurement.METRIC.getDistText(-0.99)); 35 assertEquals("< 0.01 m", SystemOfMeasurement.METRIC.getDistText(-0)); 36 assertEquals("< 0.01 m", SystemOfMeasurement.METRIC.getDistText(0)); 37 37 38 assertEquals("0.01 m", NavigatableComponent.METRIC_SOM.getDistText(0.01));38 assertEquals("0.01 m", SystemOfMeasurement.METRIC.getDistText(0.01)); 39 39 40 assertEquals("0.99 m", NavigatableComponent.METRIC_SOM.getDistText(0.99));41 assertEquals("1.00 m", NavigatableComponent.METRIC_SOM.getDistText(1.0));42 assertEquals("1.01 m", NavigatableComponent.METRIC_SOM.getDistText(1.01));40 assertEquals("0.99 m", SystemOfMeasurement.METRIC.getDistText(0.99)); 41 assertEquals("1.00 m", SystemOfMeasurement.METRIC.getDistText(1.0)); 42 assertEquals("1.01 m", SystemOfMeasurement.METRIC.getDistText(1.01)); 43 43 44 assertEquals("9.99 m", NavigatableComponent.METRIC_SOM.getDistText(9.99));45 assertEquals("10.0 m", NavigatableComponent.METRIC_SOM.getDistText(10.0));46 assertEquals("10.0 m", NavigatableComponent.METRIC_SOM.getDistText(10.01));47 assertEquals("10.0 m", NavigatableComponent.METRIC_SOM.getDistText(10.049));48 assertEquals("10.1 m", NavigatableComponent.METRIC_SOM.getDistText(10.050));49 assertEquals("10.1 m", NavigatableComponent.METRIC_SOM.getDistText(10.051));44 assertEquals("9.99 m", SystemOfMeasurement.METRIC.getDistText(9.99)); 45 assertEquals("10.0 m", SystemOfMeasurement.METRIC.getDistText(10.0)); 46 assertEquals("10.0 m", SystemOfMeasurement.METRIC.getDistText(10.01)); 47 assertEquals("10.0 m", SystemOfMeasurement.METRIC.getDistText(10.049)); 48 assertEquals("10.1 m", SystemOfMeasurement.METRIC.getDistText(10.050)); 49 assertEquals("10.1 m", SystemOfMeasurement.METRIC.getDistText(10.051)); 50 50 51 assertEquals("100.0 m", NavigatableComponent.METRIC_SOM.getDistText(99.99));52 assertEquals("100.0 m", NavigatableComponent.METRIC_SOM.getDistText(100.0));53 assertEquals("100.0 m", NavigatableComponent.METRIC_SOM.getDistText(100.01));51 assertEquals("100.0 m", SystemOfMeasurement.METRIC.getDistText(99.99)); 52 assertEquals("100.0 m", SystemOfMeasurement.METRIC.getDistText(100.0)); 53 assertEquals("100.0 m", SystemOfMeasurement.METRIC.getDistText(100.01)); 54 54 55 assertEquals("1000.0 m", NavigatableComponent.METRIC_SOM.getDistText(999.99)); // TODO ? 1.00 km should be better56 assertEquals("1000.0 m", NavigatableComponent.METRIC_SOM.getDistText(1000.0)); // TODO ? 1.00 km should be better57 assertEquals("1.00 km", NavigatableComponent.METRIC_SOM.getDistText(1000.01));55 assertEquals("1000.0 m", SystemOfMeasurement.METRIC.getDistText(999.99)); // TODO ? 1.00 km should be better 56 assertEquals("1000.0 m", SystemOfMeasurement.METRIC.getDistText(1000.0)); // TODO ? 1.00 km should be better 57 assertEquals("1.00 km", SystemOfMeasurement.METRIC.getDistText(1000.01)); 58 58 59 assertEquals("10.00 km", NavigatableComponent.METRIC_SOM.getDistText(9999.99)); // TODO ? 10.0 km should be better60 assertEquals("10.0 km", NavigatableComponent.METRIC_SOM.getDistText(10000.0));61 assertEquals("10.0 km", NavigatableComponent.METRIC_SOM.getDistText(10000.01));59 assertEquals("10.00 km", SystemOfMeasurement.METRIC.getDistText(9999.99)); // TODO ? 10.0 km should be better 60 assertEquals("10.0 km", SystemOfMeasurement.METRIC.getDistText(10000.0)); 61 assertEquals("10.0 km", SystemOfMeasurement.METRIC.getDistText(10000.01)); 62 62 63 assertEquals("100.0 km", NavigatableComponent.METRIC_SOM.getDistText(99999.99));64 assertEquals("100.0 km", NavigatableComponent.METRIC_SOM.getDistText(100000.0));65 assertEquals("100.0 km", NavigatableComponent.METRIC_SOM.getDistText(100000.01));63 assertEquals("100.0 km", SystemOfMeasurement.METRIC.getDistText(99999.99)); 64 assertEquals("100.0 km", SystemOfMeasurement.METRIC.getDistText(100000.0)); 65 assertEquals("100.0 km", SystemOfMeasurement.METRIC.getDistText(100000.01)); 66 66 } 67 67 … … 72 72 public void testGetDistTextLocalized() { 73 73 final DecimalFormat format = new DecimalFormat("0.000", DecimalFormatSymbols.getInstance(Locale.GERMAN)); 74 assertEquals("0,001 m", NavigatableComponent.METRIC_SOM.getDistText(0.001, format, 1e-6));75 assertEquals("< 0,010 m", NavigatableComponent.METRIC_SOM.getDistText(0.001, format, 0.01));76 assertEquals("10,051 m", NavigatableComponent.METRIC_SOM.getDistText(10.0514, format, 0.01));77 assertEquals("10,052 m", NavigatableComponent.METRIC_SOM.getDistText(10.0515, format, 0.01));78 assertEquals("100,000 km", NavigatableComponent.METRIC_SOM.getDistText(100000.0, format, 0.01));74 assertEquals("0,001 m", SystemOfMeasurement.METRIC.getDistText(0.001, format, 1e-6)); 75 assertEquals("< 0,010 m", SystemOfMeasurement.METRIC.getDistText(0.001, format, 0.01)); 76 assertEquals("10,051 m", SystemOfMeasurement.METRIC.getDistText(10.0514, format, 0.01)); 77 assertEquals("10,052 m", SystemOfMeasurement.METRIC.getDistText(10.0515, format, 0.01)); 78 assertEquals("100,000 km", SystemOfMeasurement.METRIC.getDistText(100000.0, format, 0.01)); 79 79 } 80 80 … … 84 84 @Test 85 85 public void testGetAreaText() { 86 assertEquals("< 0.01 m²", NavigatableComponent.METRIC_SOM.getAreaText(-1));87 assertEquals("< 0.01 m²", NavigatableComponent.METRIC_SOM.getAreaText(-0.99));88 assertEquals("< 0.01 m²", NavigatableComponent.METRIC_SOM.getAreaText(-0));89 assertEquals("< 0.01 m²", NavigatableComponent.METRIC_SOM.getAreaText(0));86 assertEquals("< 0.01 m²", SystemOfMeasurement.METRIC.getAreaText(-1)); 87 assertEquals("< 0.01 m²", SystemOfMeasurement.METRIC.getAreaText(-0.99)); 88 assertEquals("< 0.01 m²", SystemOfMeasurement.METRIC.getAreaText(-0)); 89 assertEquals("< 0.01 m²", SystemOfMeasurement.METRIC.getAreaText(0)); 90 90 91 assertEquals("0.01 m²", NavigatableComponent.METRIC_SOM.getAreaText(0.01));91 assertEquals("0.01 m²", SystemOfMeasurement.METRIC.getAreaText(0.01)); 92 92 93 assertEquals("0.99 m²", NavigatableComponent.METRIC_SOM.getAreaText(0.99));94 assertEquals("1.00 m²", NavigatableComponent.METRIC_SOM.getAreaText(1.0));95 assertEquals("1.01 m²", NavigatableComponent.METRIC_SOM.getAreaText(1.01));93 assertEquals("0.99 m²", SystemOfMeasurement.METRIC.getAreaText(0.99)); 94 assertEquals("1.00 m²", SystemOfMeasurement.METRIC.getAreaText(1.0)); 95 assertEquals("1.01 m²", SystemOfMeasurement.METRIC.getAreaText(1.01)); 96 96 97 assertEquals("9.99 m²", NavigatableComponent.METRIC_SOM.getAreaText(9.99));98 assertEquals("10.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(10.0));99 assertEquals("10.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(10.01));100 assertEquals("10.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(10.049));101 assertEquals("10.1 m²", NavigatableComponent.METRIC_SOM.getAreaText(10.050));102 assertEquals("10.1 m²", NavigatableComponent.METRIC_SOM.getAreaText(10.051));97 assertEquals("9.99 m²", SystemOfMeasurement.METRIC.getAreaText(9.99)); 98 assertEquals("10.0 m²", SystemOfMeasurement.METRIC.getAreaText(10.0)); 99 assertEquals("10.0 m²", SystemOfMeasurement.METRIC.getAreaText(10.01)); 100 assertEquals("10.0 m²", SystemOfMeasurement.METRIC.getAreaText(10.049)); 101 assertEquals("10.1 m²", SystemOfMeasurement.METRIC.getAreaText(10.050)); 102 assertEquals("10.1 m²", SystemOfMeasurement.METRIC.getAreaText(10.051)); 103 103 104 assertEquals("100.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(99.99));105 assertEquals("100.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(100.0));106 assertEquals("100.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(100.01));104 assertEquals("100.0 m²", SystemOfMeasurement.METRIC.getAreaText(99.99)); 105 assertEquals("100.0 m²", SystemOfMeasurement.METRIC.getAreaText(100.0)); 106 assertEquals("100.0 m²", SystemOfMeasurement.METRIC.getAreaText(100.01)); 107 107 108 assertEquals("1000.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(999.99));109 assertEquals("1000.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(1000.0));110 assertEquals("1000.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(1000.01));108 assertEquals("1000.0 m²", SystemOfMeasurement.METRIC.getAreaText(999.99)); 109 assertEquals("1000.0 m²", SystemOfMeasurement.METRIC.getAreaText(1000.0)); 110 assertEquals("1000.0 m²", SystemOfMeasurement.METRIC.getAreaText(1000.01)); 111 111 112 assertEquals("10000.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(9999.99)); // TODO ? 1.00 ha should be better113 assertEquals("10000.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(10000.0)); // TODO ? 1.00 ha should be better114 assertEquals("1.00 ha", NavigatableComponent.METRIC_SOM.getAreaText(10000.01));112 assertEquals("10000.0 m²", SystemOfMeasurement.METRIC.getAreaText(9999.99)); // TODO ? 1.00 ha should be better 113 assertEquals("10000.0 m²", SystemOfMeasurement.METRIC.getAreaText(10000.0)); // TODO ? 1.00 ha should be better 114 assertEquals("1.00 ha", SystemOfMeasurement.METRIC.getAreaText(10000.01)); 115 115 116 assertEquals("10.0 ha", NavigatableComponent.METRIC_SOM.getAreaText(99999.99));117 assertEquals("10.0 ha", NavigatableComponent.METRIC_SOM.getAreaText(100000.0));118 assertEquals("10.0 ha", NavigatableComponent.METRIC_SOM.getAreaText(100000.01));116 assertEquals("10.0 ha", SystemOfMeasurement.METRIC.getAreaText(99999.99)); 117 assertEquals("10.0 ha", SystemOfMeasurement.METRIC.getAreaText(100000.0)); 118 assertEquals("10.0 ha", SystemOfMeasurement.METRIC.getAreaText(100000.01)); 119 119 120 assertEquals("100.0 ha", NavigatableComponent.METRIC_SOM.getAreaText(999999.99)); // TODO ? 1.00 km² should be better121 assertEquals("1.00 km²", NavigatableComponent.METRIC_SOM.getAreaText(1000000.0));122 assertEquals("1.00 km²", NavigatableComponent.METRIC_SOM.getAreaText(1000000.01));120 assertEquals("100.0 ha", SystemOfMeasurement.METRIC.getAreaText(999999.99)); // TODO ? 1.00 km² should be better 121 assertEquals("1.00 km²", SystemOfMeasurement.METRIC.getAreaText(1000000.0)); 122 assertEquals("1.00 km²", SystemOfMeasurement.METRIC.getAreaText(1000000.01)); 123 123 124 assertEquals("10.0 km²", NavigatableComponent.METRIC_SOM.getAreaText(9999999.99));125 assertEquals("10.0 km²", NavigatableComponent.METRIC_SOM.getAreaText(10000000.0));126 assertEquals("10.0 km²", NavigatableComponent.METRIC_SOM.getAreaText(10000000.01));124 assertEquals("10.0 km²", SystemOfMeasurement.METRIC.getAreaText(9999999.99)); 125 assertEquals("10.0 km²", SystemOfMeasurement.METRIC.getAreaText(10000000.0)); 126 assertEquals("10.0 km²", SystemOfMeasurement.METRIC.getAreaText(10000000.01)); 127 127 } 128 128 }
Note:
See TracChangeset
for help on using the changeset viewer.