Ignore:
Timestamp:
2017-08-26T21:28:34+02:00 (9 years ago)
Author:
zverik
Message:

Upgrade API in imagery_offset_db

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/imagery_offset_db/src/iodb/ImageryOffsetTools.java

    r33309 r33547  
    1212import org.openstreetmap.josm.data.imagery.OffsetBookmark;
    1313import org.openstreetmap.josm.data.projection.Projection;
     14import org.openstreetmap.josm.gui.MainApplication;
    1415import org.openstreetmap.josm.gui.MapView;
    1516import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer;
     
    3637     */
    3738    public static AbstractTileSourceLayer getTopImageryLayer() {
    38         if (Main.map == null || Main.map.mapView == null)
     39        if (!MainApplication.isDisplayingMapView())
    3940            return null;
    40         List<AbstractTileSourceLayer> layers = Main.getLayerManager().getLayersOfType(AbstractTileSourceLayer.class);
     41        List<AbstractTileSourceLayer> layers = MainApplication.getLayerManager().getLayersOfType(AbstractTileSourceLayer.class);
    4142        for (AbstractTileSourceLayer layer : layers) {
    4243            String url = layer.getInfo().getUrl();
     
    5455    public static LatLon getMapCenter() {
    5556        Projection proj = Main.getProjection();
    56         return Main.map == null || Main.map.mapView == null
    57                 ? new LatLon(0, 0) : proj.eastNorth2latlon(Main.map.mapView.getCenter());
     57        return !MainApplication.isDisplayingMapView()
     58                ? new LatLon(0, 0) : proj.eastNorth2latlon(MainApplication.getMap().mapView.getCenter());
    5859    }
    5960
     
    6768    public static LatLon getLayerOffset(AbstractTileSourceLayer layer, LatLon center) {
    6869        Projection proj = Main.getProjection();
    69         EastNorth offsetCenter = Main.map.mapView.getCenter();
     70        EastNorth offsetCenter = MainApplication.getMap().mapView.getCenter();
    7071        EastNorth centerOffset = offsetCenter.add(-layer.getDisplaySettings().getDx(),
    7172                -layer.getDisplaySettings().getDy());
     
    121122
    122123    public static int getCurrentZoom() {
    123         if (Main.map == null || Main.map.mapView == null) {
     124        if (!MainApplication.isDisplayingMapView()) {
    124125            return 1;
    125126        }
    126         MapView mv = Main.map.mapView;
     127        MapView mv = MainApplication.getMap().mapView;
    127128        LatLon topLeft = mv.getLatLon(0, 0);
    128129        LatLon botRight = mv.getLatLon(mv.getWidth(), mv.getHeight());
Note: See TracChangeset for help on using the changeset viewer.