Index: trunk/src/org/openstreetmap/josm/data/coor/conversion/LatLonParser.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/coor/conversion/LatLonParser.java	(revision 12795)
+++ trunk/src/org/openstreetmap/josm/data/coor/conversion/LatLonParser.java	(revision 12796)
@@ -17,5 +17,5 @@
  * @since 12792
  */
-public class LatLonParser {
+public final class LatLonParser {
 
     /** Character denoting South, as string */
Index: trunk/src/org/openstreetmap/josm/gui/MainApplication.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/MainApplication.java	(revision 12795)
+++ trunk/src/org/openstreetmap/josm/gui/MainApplication.java	(revision 12796)
@@ -1072,4 +1072,12 @@
         MessageNotifier.setNotifierCallback(MainApplication::notifyNewMessages);
         DeleteCommand.setDeletionCallback(DeleteAction.defaultDeletionCallback);
+        OsmUrlToBounds.setMapSizeSupplier(() -> {
+            if (isDisplayingMapView()) {
+                MapView mapView = getMap().mapView;
+                return new Dimension(mapView.getWidth(), mapView.getHeight());
+            } else {
+                return GuiHelper.getScreenSize();
+            }
+        });
     }
 
Index: trunk/src/org/openstreetmap/josm/tools/OsmUrlToBounds.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/OsmUrlToBounds.java	(revision 12795)
+++ trunk/src/org/openstreetmap/josm/tools/OsmUrlToBounds.java	(revision 12796)
@@ -7,4 +7,5 @@
 import java.util.HashMap;
 import java.util.Map;
+import java.util.function.Supplier;
 
 import org.openstreetmap.josm.Main;
@@ -15,7 +16,4 @@
 import org.openstreetmap.josm.data.projection.Projection;
 import org.openstreetmap.josm.data.projection.Projections;
-import org.openstreetmap.josm.gui.MainApplication;
-import org.openstreetmap.josm.gui.MapView;
-import org.openstreetmap.josm.gui.util.GuiHelper;
 
 /**
@@ -24,4 +22,6 @@
 public final class OsmUrlToBounds {
     private static final String SHORTLINK_PREFIX = "http://osm.org/go/";
+
+    private static Supplier<Dimension> mapSize = () -> new Dimension(800, 600);
 
     private OsmUrlToBounds() {
@@ -205,11 +205,11 @@
     }
 
-    private static Dimension getScreenSize() {
-        if (MainApplication.isDisplayingMapView()) {
-            MapView mapView = MainApplication.getMap().mapView;
-            return new Dimension(mapView.getWidth(), mapView.getHeight());
-        } else {
-            return GuiHelper.getScreenSize();
-        }
+    /**
+     * Sets the map size supplier.
+     * @param mapSizeSupplier returns the map size in pixels
+     * @since 12796
+     */
+    public static void setMapSizeSupplier(Supplier<Dimension> mapSizeSupplier) {
+        mapSize = mapSizeSupplier;
     }
 
@@ -224,5 +224,5 @@
      */
     public static Bounds positionToBounds(final double lat, final double lon, final int zoom) {
-        final Dimension screenSize = getScreenSize();
+        final Dimension screenSize = mapSize.get();
         double scale = (1 << zoom) * TILE_SIZE_IN_PIXELS / (2 * Math.PI * Ellipsoid.WGS84.a);
         double deltaX = screenSize.getWidth() / 2.0 / scale;
@@ -246,5 +246,5 @@
         final EastNorth max = mercator.latlon2eastNorth(b.getMax());
         final double deltaX = max.getX() - min.getX();
-        final double scale = getScreenSize().getWidth() / deltaX;
+        final double scale = mapSize.get().getWidth() / deltaX;
         final double x = scale * (2 * Math.PI * Ellipsoid.WGS84.a) / TILE_SIZE_IN_PIXELS;
         return (int) Math.round(Math.log(x) / Math.log(2));
