Changeset 3600 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2010-10-11T21:58:03+02:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r3594 r3600 36 36 import org.openstreetmap.josm.data.osm.Way; 37 37 import org.openstreetmap.josm.data.osm.WaySegment; 38 import org.openstreetmap.josm.data.preferences.IntegerProperty; 38 39 import org.openstreetmap.josm.data.projection.Projection; 39 40 import org.openstreetmap.josm.gui.help.Helpful; … … 55 56 void zoomChanged(); 56 57 } 58 59 public static final IntegerProperty PROP_SNAP_DISTANCE = new IntegerProperty("mappaint.node.snap-distance", 10); 57 60 58 61 /** … … 461 464 * neither does the result *order*. 462 465 * It solely depends on the distance to point p. 463 * 466 * 464 467 * @return a sorted map with the keys representing the distance of 465 468 * their associated nodes to point p. … … 471 474 472 475 if (ds != null) { 473 double dist, snapDistanceSq = Main.pref.getInteger("mappaint.node.snap-distance", 10);476 double dist, snapDistanceSq = PROP_SNAP_DISTANCE.get(); 474 477 snapDistanceSq *= snapDistanceSq; 475 478 476 for (Node n : ds.searchNodes(getBBox(p, Main.pref.getInteger("mappaint.node.snap-distance", 10)))) {479 for (Node n : ds.searchNodes(getBBox(p, PROP_SNAP_DISTANCE.get()))) { 477 480 if (predicate.evaluate(n) 478 481 && (dist = getPoint2D(n).distanceSq(p)) < snapDistanceSq) … … 497 500 * neither does the result *order*. 498 501 * It solely depends on the distance to point p. 499 * 502 * 500 503 * @return All nodes nearest to point p that are in a belt from 501 504 * dist(nearest) to dist(nearest)+4px around p and … … 544 547 * neither does the result *order*. 545 548 * It solely depends on the distance to point p. 546 * 549 * 547 550 * @return All nodes nearest to point p that are in a belt from 548 551 * dist(nearest) to dist(nearest)+4px around p. 549 552 * @see #getNearestNodes(Point, Collection, Predicate) 550 * 553 * 551 554 * @param p the point for which to search the nearest segment. 552 555 * @param predicate the returned objects have to fulfill certain properties. … … 558 561 /** 559 562 * The *result* depends on the current map selection state. 560 * 563 * 561 564 * If more than one node within node.snap-distance pixels is found, 562 565 * the nearest node selected is returned. 563 * 566 * 564 567 * If no such node is found, the nearest new/id=0 node within 565 568 * about the same distance as the true nearest node is returned. 566 * 569 * 567 570 * If no such node is found either, the true nearest 568 571 * node to p is returned. 569 * 572 * 570 573 * Finally, if a node is not found at all, return null. 571 * 574 * 572 575 * @return A node within snap-distance to point p, 573 576 * that is chosen by the algorithm described. 574 * 577 * 575 578 * @param p the screen point 576 579 * @param predicate this parameter imposes a condition on the returned object, e.g. … … 616 619 * neither does the result *order*. 617 620 * It solely depends on the distance to point p. 618 * 621 * 619 622 * @return a sorted map with the keys representing the perpendicular 620 623 * distance of their associated way segments to point p. … … 685 688 * Segments within 10px of p are searched and sorted by their distance to @param p, 686 689 * then, within groups of equally distant segments, prefer those that are selected. 687 * 690 * 688 691 * @return all segments within 10px of p that are not in ignore, 689 692 * sorted by their perpendicular distance. 690 * 693 * 691 694 * @param p the point for which to search the nearest segments. 692 695 * @param ignore a collection of segments which are not to be returned. … … 716 719 /** 717 720 * The result *order* depends on the current map selection state. 718 * 721 * 719 722 * @return all segments within 10px of p, sorted by their perpendicular distance. 720 723 * @see #getNearestWaySegments(Point, Collection, Predicate) … … 729 732 /** 730 733 * The *result* depends on the current map selection state. 731 * 734 * 732 735 * @return The nearest way segment to point p, 733 736 * prefer a nearest, selected way segment, if found. … … 761 764 * neither does the result *order*. 762 765 * It solely depends on the perpendicular distance to point p. 763 * 766 * 764 767 * @return all nearest ways to the screen point given that are not in ignore. 765 768 * @see #getNearestWaySegments(Point, Collection, Predicate) 766 * 769 * 767 770 * @param p the point for which to search the nearest ways. 768 771 * @param ignore a collection of ways which are not to be returned. … … 792 795 * neither does the result *order*. 793 796 * It solely depends on the perpendicular distance to point p. 794 * 797 * 795 798 * @return all nearest ways to the screen point given. 796 799 * @see #getNearestWays(Point, Collection, Predicate) 797 * 800 * 798 801 * @param p the point for which to search the nearest ways. 799 802 * @param predicate the returned object has to fulfill certain properties. … … 827 830 * neither does the result *order*. 828 831 * It solely depends on the distance to point p. 829 * 832 * 830 833 * First, nodes will be searched. If there are nodes within BBox found, 831 834 * return a collection of those nodes only. 832 * 835 * 833 836 * If no nodes are found, search for nearest ways. If there are ways 834 837 * within BBox found, return a collection of those ways only. 835 * 838 * 836 839 * If nothing is found, return an empty collection. 837 * 840 * 838 841 * @return Primitives nearest to the given screen point that are not in ignore. 839 842 * @see #getNearestNodes(Point, Collection, Predicate) 840 843 * @see #getNearestWays(Point, Collection, Predicate) 841 * 844 * 842 845 * @param p The point on screen. 843 846 * @param ignore a collection of ways which are not to be returned. … … 867 870 * neither does the result *order*. 868 871 * It solely depends on the distance to point p. 869 * 872 * 870 873 * @return Primitives nearest to the given screen point. 871 874 * @see #getNearests(Point, Collection, Predicate) 872 * 875 * 873 876 * @param p The point on screen. 874 877 * @param predicate the returned object has to fulfill certain properties. … … 880 883 /** 881 884 * This is used as a helper routine to {@link #getNearestNodeOrWay(Point, Predicate, boolean)} 882 * 885 * 883 886 * @return true, if the node fulfills certain properties wrt p and use_sel 884 * 887 * 885 888 * @param osm node to check 886 889 * @param p point clicked … … 903 906 /** 904 907 * The *result* depends on the current map selection state IF use_selected is true. 905 * 908 * 906 909 * IF use_selected is true, use {@link #getNearestNode(Point, Predicate)} to find 907 910 * the nearest, selected node. If not found, try {@link #getNearestWaySegment(Point, Predicate)} 908 911 * to find the nearest selected way. 909 * 912 * 910 913 * IF use_selected is false, or if no selected primitive was found, do the following. 911 * 914 * 912 915 * If the nearest node found is within 4px of p, simply take it. 913 916 * Else, find the nearest way segment. Then, if p is closer to its 914 917 * middle than to the node, take the way segment, else take the node. 915 * 918 * 916 919 * Finally, if no nearest primitive is found at all, return null. 917 920 * … … 974 977 osm = ws.way; 975 978 } else { 976 int maxWaySegLenSq = 3* Main.pref.getInteger("mappaint.node.snap-distance", 10);979 int maxWaySegLenSq = 3*PROP_SNAP_DISTANCE.get(); 977 980 maxWaySegLenSq *= maxWaySegLenSq; 978 981 … … 996 999 /** 997 1000 * Convenience method to {@link #getNearestNodeOrWay(Point, Predicate, boolean)}. 998 * 1001 * 999 1002 * @return The nearest primitive to point p. 1000 1003 */ … … 1033 1036 1034 1037 /** 1035 * 1038 * 1036 1039 * @param pt point to project onto (ab) 1037 1040 * @param a root of vector … … 1054 1057 * if r = 0 returns a, if r=1 returns b, 1055 1058 * if r = 0.5 returns center between a and b, etc.. 1056 * 1059 * 1057 1060 * @param r scale value 1058 1061 * @param a root of vector … … 1074 1077 * neither does the result *order*. 1075 1078 * It solely depends on the distance to point p. 1076 * 1079 * 1077 1080 * @return a list of all objects that are nearest to point p and 1078 1081 * not in ignore or an empty list if nothing was found. 1079 * 1082 * 1080 1083 * @param p The point on screen. 1081 1084 * @param ignore a collection of ways which are not to be returned. … … 1108 1111 * neither does the result *order*. 1109 1112 * It solely depends on the distance to point p. 1110 * 1113 * 1111 1114 * @return a list of all objects that are nearest to point p 1112 1115 * or an empty list if nothing was found. 1113 1116 * @see #getAllNearest(Point, Collection, Predicate) 1114 * 1117 * 1115 1118 * @param p The point on screen. 1116 1119 * @param predicate the returned object has to fulfill certain properties.
Note:
See TracChangeset
for help on using the changeset viewer.