Ticket #2287: JOSM.Select.patch

File JOSM.Select.patch, 1.6 KB (added by robome, 17 years ago)

Select path

  • src/org/openstreetmap/josm/gui/NavigatableComponent.java

     
    149149
    150150    /**
    151151     * Return the nearest point to the screen point given.
    152      * If a node within 10 pixel is found, the nearest node is returned.
     152     * If a node within snapDistance pixel is found, the nearest node is returned.
    153153     */
    154154    public final Node getNearestNode(Point p) {
    155155        double minDistanceSq = Double.MAX_VALUE;
     
    159159                continue;
    160160            Point sp = getPoint(n.eastNorth);
    161161            double dist = p.distanceSq(sp);
    162             if (minDistanceSq > dist && dist < snapDistance) {
    163                 minDistanceSq = p.distanceSq(sp);
     162            if (dist < snapDistance && dist < minDistanceSq) {
     163                minDistanceSq = dist;
    164164                minPrimitive = n;
    165165            }
    166             // prefer already selected node when multiple nodes on one point
    167             else if(minDistanceSq == dist && n.selected && !minPrimitive.selected)
     166            // when multiple nodes on one point, prefer nodes later
     167            // in the list (i.e. newer nodes) except when the current minimum
     168            // is an already selected node
     169            else if (dist == minDistanceSq)
    168170            {
    169                 minPrimitive = n;
     171                if (!minPrimitive.selected)
     172                    minPrimitive = n;
    170173            }
    171174        }
    172175        return minPrimitive;