Ignore:
Timestamp:
18.08.2008 01:27:58 (4 years ago)
Author:
stoecker
Message:

Added virtual nodes in select mode. Closes #595.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r794 r805  
    3232public class NavigatableComponent extends JComponent implements Helpful { 
    3333 
    34  
    3534        public static final EastNorth world = Main.proj.latlon2eastNorth(new LatLon(Projection.MAX_LAT, Projection.MAX_LON)); 
    36  
     35        public static final int snapDistance = sqr(Main.pref.getInteger("node.snap-distance", 10)); 
     36 
     37        private static int sqr(int a) { return a*a;} 
    3738        /** 
    3839         * The scale factor in x or y-units per pixel. This means, if scale = 10, 
     
    141142                        Point sp = getPoint(n.eastNorth); 
    142143                        double dist = p.distanceSq(sp); 
    143                         if (minDistanceSq > dist && dist < 100) { 
     144                        if (minDistanceSq > dist && dist < snapDistance) { 
    144145                                minDistanceSq = p.distanceSq(sp); 
    145146                                minPrimitive = n; 
     
    180181                                double b = p.distanceSq(A); 
    181182                                double perDist = a-(a-b+c)*(a-b+c)/4/c; // perpendicular distance squared 
    182                                 if (perDist < 100 && a < c+100 && b < c+100) { 
     183                                if (perDist < snapDistance && a < c+snapDistance && b < c+snapDistance) { 
    183184                                        List<WaySegment> l; 
    184185                                        if (nearest.containsKey(perDist)) { 
     
    228229                WaySegment nearestWaySeg = getNearestWaySegment(p); 
    229230                return nearestWaySeg == null ? null : nearestWaySeg.way; 
    230     } 
     231        } 
    231232 
    232233        /** 
     
    240241         * If nothing is found, return <code>null</code>. 
    241242         * 
    242          * @param p                              The point on screen. 
    243          * @return      The primitive that is nearest to the point p. 
     243         * @param p The point on screen. 
     244         * @return  The primitive that is nearest to the point p. 
    244245         */ 
    245246        public OsmPrimitive getNearest(Point p) { 
    246247                OsmPrimitive osm = getNearestNode(p); 
    247248                if (osm == null) 
     249                { 
    248250                        osm = getNearestWay(p); 
     251                } 
    249252                return osm; 
    250253        } 
     
    258261                        return Collections.emptySet(); 
    259262                return Collections.singleton(osm); 
    260         } 
    261  
    262         @Deprecated 
    263         public OsmPrimitive getNearest(Point p, boolean segmentInsteadWay) { 
    264                 return getNearest(p); 
    265263        } 
    266264 
     
    290288                                double b = p.distanceSq(A); 
    291289                                double perDist = a-(a-b+c)*(a-b+c)/4/c; // perpendicular distance squared 
    292                                 if (perDist < 100 && a < c+100 && b < c+100) { 
     290                                if (perDist < snapDistance && a < c+snapDistance && b < c+snapDistance) { 
    293291                                        nearest.add(w); 
    294292                                                break; 
     
    299297                for (Node n : Main.ds.nodes) { 
    300298                        if (!n.deleted && !n.incomplete 
    301                                         && getPoint(n.eastNorth).distanceSq(p) < 100) { 
     299                                        && getPoint(n.eastNorth).distanceSq(p) < snapDistance) { 
    302300                                nearest.add(n); 
    303301                        } 
     
    318316                for (Node n : Main.ds.nodes) { 
    319317                        if (!n.deleted && !n.incomplete 
    320                                         && getPoint(n.eastNorth).distanceSq(p) < 100) { 
     318                                        && getPoint(n.eastNorth).distanceSq(p) < snapDistance) { 
    321319                                nearest.add(n); 
    322320                        } 
Note: See TracChangeset for help on using the changeset viewer.