Index: trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java	(revision 5921)
+++ trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java	(revision 5922)
@@ -66,4 +66,5 @@
 import org.openstreetmap.josm.gui.MapFrame;
 import org.openstreetmap.josm.gui.MapView;
+import org.openstreetmap.josm.gui.NavigatableComponent;
 import org.openstreetmap.josm.gui.layer.Layer;
 import org.openstreetmap.josm.gui.layer.MapViewPaintable;
@@ -86,4 +87,5 @@
     private Node lastUsedNode = null;
     private double PHI=Math.toRadians(90);
+    private double toleranceMultiplier;
 
     private Node mouseOnExistingNode;
@@ -215,4 +217,6 @@
         wayIsFinished = currentBaseNode == null;
 
+        toleranceMultiplier = 0.01 * NavigatableComponent.PROP_SNAP_DISTANCE.get();
+
         snapHelper.init();
         snapCheckboxMenuItem.getAction().setEnabled(true);
@@ -276,4 +280,5 @@
      * redraw to (possibly) get rid of helper line if selection changes.
      */
+    @Override
     public void eventDispatched(AWTEvent event) {
         if(Main.map == null || Main.map.mapView == null || !Main.map.mapView.isActiveLayerDrawable())
@@ -335,4 +340,5 @@
      * redraw to (possibly) get rid of helper line if selection changes.
      */
+    @Override
     public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
         if(!Main.map.mapView.isActiveLayerDrawable())
@@ -450,5 +456,7 @@
                 // project found node to snapping line
                 newEN = snapHelper.getSnapPoint(foundPoint);
-                if (foundPoint.distance(newEN) > 1e-4) {
+                // do not add new node if there is some node within snapping distance
+                double tolerance = Main.map.mapView.getDist100Pixel() * toleranceMultiplier;
+                if (foundPoint.distance(newEN) > tolerance) {
                     n = new Node(newEN); // point != projected, so we create new node
                     newNode = true;
@@ -631,5 +639,5 @@
         if (n != null && Main.map.mapView.viewportFollowing) {
             Main.map.mapView.smoothScrollTo(n.getEastNorth());
-        };
+        }
         computeHelperLine();
         removeHighlighting();
@@ -1082,5 +1090,5 @@
 
         // This happens when nothing is selected, but we still want to highlight the "target node"
-        if (mouseOnExistingNode == null && getCurrentDataSet().getSelected().size() == 0
+        if (mouseOnExistingNode == null && getCurrentDataSet().getSelected().isEmpty()
                 && mousePos != null) {
             mouseOnExistingNode = Main.map.mapView.getNearestNode(mousePos, OsmPrimitive.isSelectablePredicate);
@@ -1095,5 +1103,5 @@
 
         // Insert the node into all the nearby way segments
-        if (mouseOnExistingWays.size() == 0) {
+        if (mouseOnExistingWays.isEmpty()) {
             Main.map.mapView.setNewCursor(cursor, this);
             redrawIfRequired();
@@ -1115,4 +1123,5 @@
     }
 
+    @Override
     public void paint(Graphics2D g, MapView mv, Bounds box) {
         // sanity checks
@@ -1685,5 +1694,5 @@
         MouseListener anglePopupListener = new PopupMenuLauncher( new JPopupMenu() {
             JCheckBoxMenuItem repeatedCb = new JCheckBoxMenuItem(new AbstractAction(tr("Toggle snapping by {0}", getShortcut().getKeyText())){
-                public void actionPerformed(ActionEvent e) {
+                @Override public void actionPerformed(ActionEvent e) {
                     boolean sel=((JCheckBoxMenuItem) e.getSource()).getState();
                     Main.pref.put("draw.anglesnap.toggleOnRepeatedA", sel);
@@ -1692,5 +1701,5 @@
             });
             JCheckBoxMenuItem helperCb = new JCheckBoxMenuItem(new AbstractAction(tr("Show helper geometry")){
-                public void actionPerformed(ActionEvent e) {
+                @Override public void actionPerformed(ActionEvent e) {
                     boolean sel=((JCheckBoxMenuItem) e.getSource()).getState();
                     Main.pref.put("draw.anglesnap.drawConstructionGeometry", sel);
@@ -1702,5 +1711,5 @@
             });
             JCheckBoxMenuItem projectionCb = new JCheckBoxMenuItem(new AbstractAction(tr("Snap to node projections")){
-                public void actionPerformed(ActionEvent e) {
+                @Override public void actionPerformed(ActionEvent e) {
                     boolean sel=((JCheckBoxMenuItem) e.getSource()).getState();
                     Main.pref.put("draw.anglesnap.projectionsnap", sel);
@@ -1717,5 +1726,5 @@
                 add(projectionCb);;
                 add(new AbstractAction(tr("Disable")) {
-                    public void actionPerformed(ActionEvent e) {
+                    @Override public void actionPerformed(ActionEvent e) {
                         saveAngles("180");
                         init();
@@ -1724,5 +1733,5 @@
                 });
                 add(new AbstractAction(tr("0,90,...")) {
-                    public void actionPerformed(ActionEvent e) {
+                    @Override public void actionPerformed(ActionEvent e) {
                         saveAngles("0","90","180");
                         init();
@@ -1731,5 +1740,5 @@
                 });
                 add(new AbstractAction(tr("0,45,90,...")) {
-                    public void actionPerformed(ActionEvent e) {
+                    @Override public void actionPerformed(ActionEvent e) {
                         saveAngles("0","45","90","135","180");
                         init();
@@ -1738,5 +1747,5 @@
                 });
                 add(new AbstractAction(tr("0,30,45,60,90,...")) {
-                    public void actionPerformed(ActionEvent e) {
+                    @Override public void actionPerformed(ActionEvent e) {
                         saveAngles("0","30","45","60","90","120","135","150","180");
                         init();
