Index: trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java	(revision 947)
+++ trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java	(revision 948)
@@ -2,6 +2,6 @@
 package org.openstreetmap.josm.actions;
 
+import static org.openstreetmap.josm.tools.I18n.marktr;
 import static org.openstreetmap.josm.tools.I18n.tr;
-import static org.openstreetmap.josm.tools.I18n.marktr;
 
 import java.awt.event.ActionEvent;
@@ -12,6 +12,4 @@
 
 import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.data.coor.EastNorth;
-import org.openstreetmap.josm.data.coor.LatLon;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
@@ -24,75 +22,67 @@
 public class AutoScaleAction extends JosmAction {
 
-	public static final String[] modes = {
-		marktr("data"),
-		marktr("layer"),
-		marktr("selection"),
-		marktr("conflict")
-	};
-	private final String mode;
+    public static final String[] modes = { marktr("data"), marktr("layer"), marktr("selection"), marktr("conflict") };
+    private final String mode;
 
-	private static int getModeShortcut(String mode) {
-		int shortcut = -1;
+    private static int getModeShortcut(String mode) {
+        int shortcut = -1;
 
-		if(mode.equals("data")) {
-			shortcut = KeyEvent.VK_1;
-		}        
-		if(mode.equals("layer")) {
-			shortcut = KeyEvent.VK_2;
-		}
-		if(mode.equals("selection")) {
-			shortcut = KeyEvent.VK_3;
-		}
-		if(mode.equals("conflict")) {
-			shortcut = KeyEvent.VK_4;
-		}
+        if (mode.equals("data")) {
+            shortcut = KeyEvent.VK_1;
+        }
+        if (mode.equals("layer")) {
+            shortcut = KeyEvent.VK_2;
+        }
+        if (mode.equals("selection")) {
+            shortcut = KeyEvent.VK_3;
+        }
+        if (mode.equals("conflict")) {
+            shortcut = KeyEvent.VK_4;
+        }
 
-		return shortcut;
-	}
-    
-	public AutoScaleAction(String mode) {
-		super(tr("Zoom to {0}", tr(mode)), "dialogs/autoscale/"+mode, tr("Zoom the view to {0}.", tr(mode)), AutoScaleAction.getModeShortcut(mode), 0, true);
-		String modeHelp = Character.toUpperCase(mode.charAt(0))+mode.substring(1);
-		putValue("help", "Action/AutoScale/"+modeHelp);
-		this.mode = mode;
-	}
+        return shortcut;
+    }
 
-	public void actionPerformed(ActionEvent e) {
-		if (Main.map != null) {
-			BoundingXYVisitor bbox = getBoundingBox();
-			if (bbox != null) {
-				Main.map.mapView.recalculateCenterScale(bbox);
-			}
-		}
-		putValue("active", true);
-	}
+    public AutoScaleAction(String mode) {
+        super(tr("Zoom to {0}", tr(mode)), "dialogs/autoscale/" + mode, tr("Zoom the view to {0}.", tr(mode)),
+                AutoScaleAction.getModeShortcut(mode), 0, true);
+        String modeHelp = Character.toUpperCase(mode.charAt(0)) + mode.substring(1);
+        putValue("help", "Action/AutoScale/" + modeHelp);
+        this.mode = mode;
+    }
 
-	private BoundingXYVisitor getBoundingBox() {
-		BoundingXYVisitor v = new BoundingXYVisitor();
-		if (mode.equals("data")) {
-			for (Layer l : Main.map.mapView.getAllLayers())
-				l.visitBoundingBox(v);
-		} else if (mode.equals("layer"))
-			Main.map.mapView.getActiveLayer().visitBoundingBox(v);
-		else if (mode.equals("selection") || mode.equals("conflict")) {
-			Collection<OsmPrimitive> sel = mode.equals("selection") ? Main.ds.getSelected() : Main.map.conflictDialog.conflicts.keySet();
-			if (sel.isEmpty()) {
-	    		JOptionPane.showMessageDialog(Main.parent,
-	    				mode.equals("selection") ? tr("Nothing selected to zoom to.") : tr("No conflicts to zoom to"));
-	        		return null;
-			}
-			for (OsmPrimitive osm : sel)
-				osm.visit(v);
-			// increase bbox by 0.001 degrees on each side. this is required 
-			// especially if the bbox contains one single node, but helpful 
-			// in most other cases as well.
-			if (v.min != null && v.max != null) // && v.min.north() == v.max.north() && v.min.east() == v.max.east()) {
-			{
-				EastNorth en = new EastNorth(0.0001,0.0001);
-				v.min = new EastNorth(v.min.east()-en.east(), v.min.north()-en.north());
-				v.max = new EastNorth(v.max.east()+en.east(), v.max.north()+en.north());
-			}
-		}
-		return v;
-	}
+    public void actionPerformed(ActionEvent e) {
+        if (Main.map != null) {
+            BoundingXYVisitor bbox = getBoundingBox();
+            if (bbox != null) {
+                Main.map.mapView.recalculateCenterScale(bbox);
+            }
+        }
+        putValue("active", true);
+    }
+
+    private BoundingXYVisitor getBoundingBox() {
+        BoundingXYVisitor v = new BoundingXYVisitor();
+        if (mode.equals("data")) {
+            for (Layer l : Main.map.mapView.getAllLayers())
+                l.visitBoundingBox(v);
+        } else if (mode.equals("layer"))
+            Main.map.mapView.getActiveLayer().visitBoundingBox(v);
+        else if (mode.equals("selection") || mode.equals("conflict")) {
+            Collection<OsmPrimitive> sel = mode.equals("selection") ? Main.ds.getSelected()
+                    : Main.map.conflictDialog.conflicts.keySet();
+            if (sel.isEmpty()) {
+                JOptionPane.showMessageDialog(Main.parent,
+                        mode.equals("selection") ? tr("Nothing selected to zoom to.") : tr("No conflicts to zoom to"));
+                return null;
+            }
+            for (OsmPrimitive osm : sel)
+                osm.visit(v);
+            // increase bbox by 0.001 degrees on each side. this is required 
+            // especially if the bbox contains one single node, but helpful 
+            // in most other cases as well.
+            v.enlargeBoundingBox();
+        }
+        return v;
+    }
 }
Index: trunk/src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java	(revision 947)
+++ trunk/src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java	(revision 948)
@@ -5,11 +5,12 @@
 import org.openstreetmap.josm.data.Bounds;
 import org.openstreetmap.josm.data.coor.EastNorth;
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.Relation;
 import org.openstreetmap.josm.data.osm.RelationMember;
-import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.Way;
 
 /**
- * Calculates the total bounding rectangle of a series of OsmPrimitives, using the 
+ * Calculates the total bounding rectangle of a series of {@link OsmPrimitive} objects, using the 
  * EastNorth values as reference.
  * @author imi
@@ -17,44 +18,70 @@
 public class BoundingXYVisitor implements Visitor {
 
-	public EastNorth min, max;
+    public EastNorth min, max;
 
-	public void visit(Node n) {
-		visit(n.eastNorth);
-	}
+    public void visit(Node n) {
+        visit(n.eastNorth);
+    }
 
-	public void visit(Way w) {
-		w.visitNodes(this);
-	}
+    public void visit(Way w) {
+        w.visitNodes(this);
+    }
 
-	public void visit(Relation e) {
-		// only use direct members
-		for (RelationMember m : e.members) {
-			if (!(m.member instanceof Relation)) {
-				m.member.visit(this);
-			}
-		}
-	}
+    public void visit(Relation e) {
+        // only use direct members
+        for (RelationMember m : e.members) {
+            if (!(m.member instanceof Relation)) {
+                m.member.visit(this);
+            }
+        }
+    }
 
-	public void visit(EastNorth eastNorth) {
-		if (eastNorth != null) {
-			if (min == null)
-				min = eastNorth;
-			else if (eastNorth.east() < min.east() || eastNorth.north() < min.north())
-				min = new EastNorth(Math.min(min.east(), eastNorth.east()), Math.min(min.north(), eastNorth.north()));
-			
-			if (max == null)
-				max = eastNorth;
-			else if (eastNorth.east() > max.east() || eastNorth.north() > max.north())
-				max = new EastNorth(Math.max(max.east(), eastNorth.east()), Math.max(max.north(), eastNorth.north()));
-		}
-	}
+    public void visit(EastNorth eastNorth) {
+        if (eastNorth != null) {
+            if (min == null)
+                min = eastNorth;
+            else if (eastNorth.east() < min.east() || eastNorth.north() < min.north())
+                min = new EastNorth(Math.min(min.east(), eastNorth.east()), Math.min(min.north(), eastNorth.north()));
 
-	/**
-	 * @return The bounding box or <code>null</code> if no coordinates have passed
-	 */
-	public Bounds getBounds() {
-		if (min == null || max == null)
-			return null;
-		return new Bounds(Main.proj.eastNorth2latlon(min), Main.proj.eastNorth2latlon(max));
-	}
+            if (max == null)
+                max = eastNorth;
+            else if (eastNorth.east() > max.east() || eastNorth.north() > max.north())
+                max = new EastNorth(Math.max(max.east(), eastNorth.east()), Math.max(max.north(), eastNorth.north()));
+        }
+    }
+
+    /**
+     * @return The bounding box or <code>null</code> if no coordinates have passed
+     */
+    public Bounds getBounds() {
+        if (min == null || max == null)
+            return null;
+        return new Bounds(Main.proj.eastNorth2latlon(min), Main.proj.eastNorth2latlon(max));
+    }
+
+    /**
+     * Enlarges the calculated bounding box by 0.0001 degrees. 
+     * If the bounding box has not been set (<code>min</code> or <code>max</code>
+     * equal <code>null</code>) this method does not do anything.
+     *    
+     * @param enlargeDegree
+     */
+    public void enlargeBoundingBox() {
+        enlargeBoundingBox(0.0001);
+    }
+
+    /**
+     * Enlarges the calculated bounding box by the specified number of degrees. 
+     * If the bounding box has not been set (<code>min</code> or <code>max</code>
+     * equal <code>null</code>) this method does not do anything.
+     *    
+     * @param enlargeDegree
+     */
+    public void enlargeBoundingBox(double enlargeDegree) {
+        if (min == null || max == null)
+            return;
+        EastNorth en = new EastNorth(enlargeDegree, enlargeDegree);
+        min = new EastNorth(min.east() - en.east(), min.north() - en.north());
+        max = new EastNorth(max.east() + en.east(), max.north() + en.north());
+    }
 }
