Changeset 12796 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2017-09-09T13:34:52+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/coor/conversion/LatLonParser.java
r12795 r12796 17 17 * @since 12792 18 18 */ 19 public class LatLonParser {19 public final class LatLonParser { 20 20 21 21 /** Character denoting South, as string */ -
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r12795 r12796 1072 1072 MessageNotifier.setNotifierCallback(MainApplication::notifyNewMessages); 1073 1073 DeleteCommand.setDeletionCallback(DeleteAction.defaultDeletionCallback); 1074 OsmUrlToBounds.setMapSizeSupplier(() -> { 1075 if (isDisplayingMapView()) { 1076 MapView mapView = getMap().mapView; 1077 return new Dimension(mapView.getWidth(), mapView.getHeight()); 1078 } else { 1079 return GuiHelper.getScreenSize(); 1080 } 1081 }); 1074 1082 } 1075 1083 -
trunk/src/org/openstreetmap/josm/tools/OsmUrlToBounds.java
r12630 r12796 7 7 import java.util.HashMap; 8 8 import java.util.Map; 9 import java.util.function.Supplier; 9 10 10 11 import org.openstreetmap.josm.Main; … … 15 16 import org.openstreetmap.josm.data.projection.Projection; 16 17 import org.openstreetmap.josm.data.projection.Projections; 17 import org.openstreetmap.josm.gui.MainApplication;18 import org.openstreetmap.josm.gui.MapView;19 import org.openstreetmap.josm.gui.util.GuiHelper;20 18 21 19 /** … … 24 22 public final class OsmUrlToBounds { 25 23 private static final String SHORTLINK_PREFIX = "http://osm.org/go/"; 24 25 private static Supplier<Dimension> mapSize = () -> new Dimension(800, 600); 26 26 27 27 private OsmUrlToBounds() { … … 205 205 } 206 206 207 private static Dimension getScreenSize() {208 if (MainApplication.isDisplayingMapView()) {209 MapView mapView = MainApplication.getMap().mapView;210 return new Dimension(mapView.getWidth(), mapView.getHeight());211 } else {212 return GuiHelper.getScreenSize();213 }207 /** 208 * Sets the map size supplier. 209 * @param mapSizeSupplier returns the map size in pixels 210 * @since 12796 211 */ 212 public static void setMapSizeSupplier(Supplier<Dimension> mapSizeSupplier) { 213 mapSize = mapSizeSupplier; 214 214 } 215 215 … … 224 224 */ 225 225 public static Bounds positionToBounds(final double lat, final double lon, final int zoom) { 226 final Dimension screenSize = getScreenSize();226 final Dimension screenSize = mapSize.get(); 227 227 double scale = (1 << zoom) * TILE_SIZE_IN_PIXELS / (2 * Math.PI * Ellipsoid.WGS84.a); 228 228 double deltaX = screenSize.getWidth() / 2.0 / scale; … … 246 246 final EastNorth max = mercator.latlon2eastNorth(b.getMax()); 247 247 final double deltaX = max.getX() - min.getX(); 248 final double scale = getScreenSize().getWidth() / deltaX;248 final double scale = mapSize.get().getWidth() / deltaX; 249 249 final double x = scale * (2 * Math.PI * Ellipsoid.WGS84.a) / TILE_SIZE_IN_PIXELS; 250 250 return (int) Math.round(Math.log(x) / Math.log(2));
Note:
See TracChangeset
for help on using the changeset viewer.