Changeset 3600 in josm for trunk/src/org


Ignore:
Timestamp:
2010-10-11T21:58:03+02:00 (14 years ago)
Author:
jttt
Message:

Use IntegerProperty for snap distance (because plugins are also reading this value so it shouldn't be magic string)

File:
1 edited

Legend:

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

    r3594 r3600  
    3636import org.openstreetmap.josm.data.osm.Way;
    3737import org.openstreetmap.josm.data.osm.WaySegment;
     38import org.openstreetmap.josm.data.preferences.IntegerProperty;
    3839import org.openstreetmap.josm.data.projection.Projection;
    3940import org.openstreetmap.josm.gui.help.Helpful;
     
    5556        void zoomChanged();
    5657    }
     58
     59    public static final IntegerProperty PROP_SNAP_DISTANCE = new IntegerProperty("mappaint.node.snap-distance", 10);
    5760
    5861    /**
     
    461464     * neither does the result *order*.
    462465     * It solely depends on the distance to point p.
    463      * 
     466     *
    464467     * @return a sorted map with the keys representing the distance of
    465468     *      their associated nodes to point p.
     
    471474
    472475        if (ds != null) {
    473             double dist, snapDistanceSq = Main.pref.getInteger("mappaint.node.snap-distance", 10);
     476            double dist, snapDistanceSq = PROP_SNAP_DISTANCE.get();
    474477            snapDistanceSq *= snapDistanceSq;
    475478
    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()))) {
    477480                if (predicate.evaluate(n)
    478481                        && (dist = getPoint2D(n).distanceSq(p)) < snapDistanceSq)
     
    497500     * neither does the result *order*.
    498501     * It solely depends on the distance to point p.
    499      * 
     502     *
    500503     * @return All nodes nearest to point p that are in a belt from
    501504     *      dist(nearest) to dist(nearest)+4px around p and
     
    544547     * neither does the result *order*.
    545548     * It solely depends on the distance to point p.
    546      * 
     549     *
    547550     * @return All nodes nearest to point p that are in a belt from
    548551     *      dist(nearest) to dist(nearest)+4px around p.
    549552     * @see #getNearestNodes(Point, Collection, Predicate)
    550      * 
     553     *
    551554     * @param p the point for which to search the nearest segment.
    552555     * @param predicate the returned objects have to fulfill certain properties.
     
    558561    /**
    559562     * The *result* depends on the current map selection state.
    560      * 
     563     *
    561564     * If more than one node within node.snap-distance pixels is found,
    562565     * the nearest node selected is returned.
    563      * 
     566     *
    564567     * If no such node is found, the nearest new/id=0 node within
    565568     * about the same distance as the true nearest node is returned.
    566      * 
     569     *
    567570     * If no such node is found either, the true nearest
    568571     * node to p is returned.
    569      * 
     572     *
    570573     * Finally, if a node is not found at all, return null.
    571      * 
     574     *
    572575     * @return A node within snap-distance to point p,
    573576     *      that is chosen by the algorithm described.
    574      * 
     577     *
    575578     * @param p the screen point
    576579     * @param predicate this parameter imposes a condition on the returned object, e.g.
     
    616619     * neither does the result *order*.
    617620     * It solely depends on the distance to point p.
    618      * 
     621     *
    619622     * @return a sorted map with the keys representing the perpendicular
    620623     *      distance of their associated way segments to point p.
     
    685688     * Segments within 10px of p are searched and sorted by their distance to @param p,
    686689     * then, within groups of equally distant segments, prefer those that are selected.
    687      * 
     690     *
    688691     * @return all segments within 10px of p that are not in ignore,
    689692     *          sorted by their perpendicular distance.
    690      * 
     693     *
    691694     * @param p the point for which to search the nearest segments.
    692695     * @param ignore a collection of segments which are not to be returned.
     
    716719    /**
    717720     * The result *order* depends on the current map selection state.
    718      * 
     721     *
    719722     * @return all segments within 10px of p, sorted by their perpendicular distance.
    720723     * @see #getNearestWaySegments(Point, Collection, Predicate)
     
    729732    /**
    730733     * The *result* depends on the current map selection state.
    731      * 
     734     *
    732735     * @return The nearest way segment to point p,
    733736     *      prefer a nearest, selected way segment, if found.
     
    761764     * neither does the result *order*.
    762765     * It solely depends on the perpendicular distance to point p.
    763      * 
     766     *
    764767     * @return all nearest ways to the screen point given that are not in ignore.
    765768     * @see #getNearestWaySegments(Point, Collection, Predicate)
    766      * 
     769     *
    767770     * @param p the point for which to search the nearest ways.
    768771     * @param ignore a collection of ways which are not to be returned.
     
    792795     * neither does the result *order*.
    793796     * It solely depends on the perpendicular distance to point p.
    794      * 
     797     *
    795798     * @return all nearest ways to the screen point given.
    796799     * @see #getNearestWays(Point, Collection, Predicate)
    797      * 
     800     *
    798801     * @param p the point for which to search the nearest ways.
    799802     * @param predicate the returned object has to fulfill certain properties.
     
    827830     * neither does the result *order*.
    828831     * It solely depends on the distance to point p.
    829      * 
     832     *
    830833     * First, nodes will be searched. If there are nodes within BBox found,
    831834     * return a collection of those nodes only.
    832      * 
     835     *
    833836     * If no nodes are found, search for nearest ways. If there are ways
    834837     * within BBox found, return a collection of those ways only.
    835      * 
     838     *
    836839     * If nothing is found, return an empty collection.
    837      * 
     840     *
    838841     * @return Primitives nearest to the given screen point that are not in ignore.
    839842     * @see #getNearestNodes(Point, Collection, Predicate)
    840843     * @see #getNearestWays(Point, Collection, Predicate)
    841      * 
     844     *
    842845     * @param p The point on screen.
    843846     * @param ignore a collection of ways which are not to be returned.
     
    867870     * neither does the result *order*.
    868871     * It solely depends on the distance to point p.
    869      * 
     872     *
    870873     * @return Primitives nearest to the given screen point.
    871874     * @see #getNearests(Point, Collection, Predicate)
    872      * 
     875     *
    873876     * @param p The point on screen.
    874877     * @param predicate the returned object has to fulfill certain properties.
     
    880883    /**
    881884     * This is used as a helper routine to {@link #getNearestNodeOrWay(Point, Predicate, boolean)}
    882      * 
     885     *
    883886     * @return true, if the node fulfills certain properties wrt p and use_sel
    884      * 
     887     *
    885888     * @param osm node to check
    886889     * @param p point clicked
     
    903906    /**
    904907     * The *result* depends on the current map selection state IF use_selected is true.
    905      * 
     908     *
    906909     * IF use_selected is true, use {@link #getNearestNode(Point, Predicate)} to find
    907910     * the nearest, selected node.  If not found, try {@link #getNearestWaySegment(Point, Predicate)}
    908911     * to find the nearest selected way.
    909      * 
     912     *
    910913     * IF use_selected is false, or if no selected primitive was found, do the following.
    911      * 
     914     *
    912915     * If the nearest node found is within 4px of p, simply take it.
    913916     * Else, find the nearest way segment. Then, if p is closer to its
    914917     * middle than to the node, take the way segment, else take the node.
    915      * 
     918     *
    916919     * Finally, if no nearest primitive is found at all, return null.
    917920     *
     
    974977                        osm = ws.way;
    975978                    } else {
    976                         int maxWaySegLenSq = 3*Main.pref.getInteger("mappaint.node.snap-distance", 10);
     979                        int maxWaySegLenSq = 3*PROP_SNAP_DISTANCE.get();
    977980                        maxWaySegLenSq *= maxWaySegLenSq;
    978981
     
    996999    /**
    9971000     * Convenience method to {@link #getNearestNodeOrWay(Point, Predicate, boolean)}.
    998      * 
     1001     *
    9991002     * @return The nearest primitive to point p.
    10001003     */
     
    10331036
    10341037    /**
    1035      * 
     1038     *
    10361039     * @param pt point to project onto (ab)
    10371040     * @param a root of vector
     
    10541057     * if r = 0 returns a, if r=1 returns b,
    10551058     * if r = 0.5 returns center between a and b, etc..
    1056      * 
     1059     *
    10571060     * @param r scale value
    10581061     * @param a root of vector
     
    10741077     * neither does the result *order*.
    10751078     * It solely depends on the distance to point p.
    1076      * 
     1079     *
    10771080     * @return a list of all objects that are nearest to point p and
    10781081     *          not in ignore or an empty list if nothing was found.
    1079      * 
     1082     *
    10801083     * @param p The point on screen.
    10811084     * @param ignore a collection of ways which are not to be returned.
     
    11081111     * neither does the result *order*.
    11091112     * It solely depends on the distance to point p.
    1110      * 
     1113     *
    11111114     * @return a list of all objects that are nearest to point p
    11121115     *          or an empty list if nothing was found.
    11131116     * @see #getAllNearest(Point, Collection, Predicate)
    1114      * 
     1117     *
    11151118     * @param p The point on screen.
    11161119     * @param predicate the returned object has to fulfill certain properties.
Note: See TracChangeset for help on using the changeset viewer.