Changeset 6070 in josm for trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
- Timestamp:
- 2013-07-17T00:01:49+02:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r6065 r6070 64 64 void zoomChanged(); 65 65 } 66 66 67 67 /** 68 68 * Interface to notify listeners of the change of the system of measurement. … … 77 77 void systemOfMeasurementChanged(String oldSoM, String newSoM); 78 78 } 79 79 80 80 /** 81 81 * Simple data class that keeps map center and scale in one object. … … 150 150 /** 151 151 * Removes a SoM change listener 152 * 152 * 153 153 * @param listener the listener. Ignored if null or already absent 154 154 * @since 6056 … … 160 160 /** 161 161 * Adds a SoM change listener 162 * 162 * 163 163 * @param listener the listener. Ignored if null or already registered. 164 164 * @since 6056 … … 169 169 } 170 170 } 171 171 172 172 protected static void fireSoMChanged(String oldSoM, String newSoM) { 173 173 for (SoMChangeListener l : somChangeListeners) { … … 190 190 private Rectangle paintRect = null; 191 191 private Polygon paintPoly = null; 192 192 193 193 public NavigatableComponent() { 194 194 setLayout(null); … … 728 728 return getNearestNode(p, predicate, use_selected, null); 729 729 } 730 730 731 731 /** 732 732 * The *result* depends on the current map selection state IF use_selected is true … … 734 734 * If more than one node within node.snap-distance pixels is found, 735 735 * the nearest node selected is returned IF use_selected is true. 736 * 736 * 737 737 * If there are no selected nodes near that point, the node that is related to some of the preferredRefs 738 738 * … … 755 755 public final Node getNearestNode(Point p, Predicate<OsmPrimitive> predicate, 756 756 boolean use_selected, Collection<OsmPrimitive> preferredRefs) { 757 757 758 758 Map<Double, List<Node>> nlists = getNearestNodesImpl(p, predicate); 759 759 if (nlists.isEmpty()) return null; 760 760 761 761 if (preferredRefs != null && preferredRefs.isEmpty()) preferredRefs = null; 762 762 Node ntsel = null, ntnew = null, ntref = null; … … 793 793 794 794 // take nearest selected, nearest new or true nearest node to p, in that order 795 if (ntsel != null && useNtsel) 795 if (ntsel != null && useNtsel) 796 796 return ntsel; 797 if (ntref != null) 797 if (ntref != null) 798 798 return ntref; 799 if (ntnew != null) 799 if (ntnew != null) 800 800 return ntnew; 801 801 return nlists.values().iterator().next().get(0); … … 956 956 return (ntsel != null && use_selected) ? ntsel : wayseg; 957 957 } 958 958 959 959 /** 960 960 * The *result* depends on the current map selection state IF use_selected is true. … … 974 974 WaySegment wayseg = null, ntsel = null, ntref = null; 975 975 if (preferredRefs != null && preferredRefs.isEmpty()) preferredRefs = null; 976 976 977 977 searchLoop: for (List<WaySegment> wslist : getNearestWaySegmentsImpl(p, predicate).values()) { 978 978 for (WaySegment ws : wslist) { … … 1003 1003 } 1004 1004 } 1005 if (ntsel != null && use_selected) 1005 if (ntsel != null && use_selected) 1006 1006 return ntsel; 1007 1007 if (ntref != null) … … 1180 1180 */ 1181 1181 public final OsmPrimitive getNearestNodeOrWay(Point p, Predicate<OsmPrimitive> predicate, boolean use_selected) { 1182 Collection<OsmPrimitive> sel = 1182 Collection<OsmPrimitive> sel = 1183 1183 use_selected ? getCurrentDataSet().getSelected() : null; 1184 1184 OsmPrimitive osm = getNearestNode(p, predicate, use_selected, sel); … … 1295 1295 } 1296 1296 } 1297 1297 1298 1298 // add nearby nodes 1299 1299 for (List<Node> nlist : getNearestNodesImpl(p, predicate).values()) { 1300 1300 nearestList.addAll(nlist); 1301 1301 } 1302 1302 1303 1303 // add parent relations of nearby nodes and ways 1304 1304 Set<OsmPrimitive> parentRelations = new HashSet<OsmPrimitive>(); … … 1311 1311 } 1312 1312 nearestList.addAll(parentRelations); 1313 1313 1314 1314 if (ignore != null) { 1315 1315 nearestList.removeAll(ignore); … … 1392 1392 */ 1393 1393 public static class SystemOfMeasurement { 1394 1394 1395 1395 /** First value, in meters, used to translate unit according to above formula. */ 1396 1396 public final double aValue; … … 1404 1404 * @since 5870 */ 1405 1405 public final double areaCustomValue; 1406 /** Specific optional area unit. Set to {@code null} if not used. 1406 /** Specific optional area unit. Set to {@code null} if not used. 1407 1407 * @since 5870 */ 1408 1408 public final String areaCustomName; … … 1413 1413 * If a quantity x is given in m (x_m) and in unit a (x_a) then it translates as 1414 1414 * x_a == x_m / aValue 1415 * 1415 * 1416 1416 * @param aValue First value, in meters, used to translate unit according to above formula. 1417 1417 * @param aName First unit used to format text. … … 1422 1422 this(aValue, aName, bValue, bName, -1, null); 1423 1423 } 1424 1424 1425 1425 /** 1426 1426 * System of measurement. Currently covers only length (and area) units. … … 1428 1428 * If a quantity x is given in m (x_m) and in unit a (x_a) then it translates as 1429 1429 * x_a == x_m / aValue 1430 * 1430 * 1431 1431 * @param aValue First value, in meters, used to translate unit according to above formula. 1432 1432 * @param aName First unit used to format text. 1433 1433 * @param bValue Second value, in meters, used to translate unit according to above formula. 1434 1434 * @param bName Second unit used to format text. 1435 * @param areaCustomValue Specific optional area value, in squared meters, between {@code aValue*aValue} and {@code bValue*bValue}. 1435 * @param areaCustomValue Specific optional area value, in squared meters, between {@code aValue*aValue} and {@code bValue*bValue}. 1436 1436 * Set to {@code -1} if not used. 1437 1437 * @param areaCustomName Specific optional area unit. Set to {@code null} if not used. 1438 * 1438 * 1439 1439 * @since 5870 1440 1440 */ … … 1482 1482 return formatText(a, aName+"\u00b2"); 1483 1483 } 1484 1484 1485 1485 private static String formatText(double v, String unit) { 1486 1486 return String.format(Locale.US, "%." + (v<9.999999 ? 2 : 1) + "f %s", v, unit); … … 1493 1493 */ 1494 1494 public static final SystemOfMeasurement METRIC_SOM = new SystemOfMeasurement(1, "m", 1000, "km", 10000, "ha"); 1495 1495 1496 1496 /** 1497 1497 * Chinese system. … … 1499 1499 */ 1500 1500 public static final SystemOfMeasurement CHINESE_SOM = new SystemOfMeasurement(1.0/3.0, "\u5e02\u5c3a" /* chi */, 500, "\u5e02\u91cc" /* li */); 1501 1501 1502 1502 /** 1503 1503 * Imperial system (British Commonwealth and former British Empire). … … 1505 1505 */ 1506 1506 public static final SystemOfMeasurement IMPERIAL_SOM = new SystemOfMeasurement(0.3048, "ft", 1609.344, "mi", 4046.86, "ac"); 1507 1507 1508 1508 /** 1509 1509 * Nautical mile system (navigation, polar exploration). … … 1579 1579 Cursors = c; 1580 1580 } 1581 1581 1582 1582 @Override 1583 1583 public void paint(Graphics g) { … … 1613 1613 } 1614 1614 } 1615 1615 1616 1616 /** 1617 1617 * Requests to paint the given {@code Polygon} as a polyline (unclosed polygon). … … 1628 1628 } 1629 1629 } 1630 1630 1631 1631 /** 1632 1632 * Requests to clear the rectangled previously drawn.
Note:
See TracChangeset
for help on using the changeset viewer.