Ignore:
Timestamp:
2017-08-24T00:15:51+02:00 (7 years ago)
Author:
Don-vip
Message:

see #15182 - deprecate Main.map and Main.isDisplayingMapView(). Replacements: gui.MainApplication.getMap() / gui.MainApplication.isDisplayingMapView()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/ImageryAdjustAction.java

    r12620 r12630  
    2929import org.openstreetmap.josm.data.imagery.OffsetBookmark;
    3030import org.openstreetmap.josm.gui.ExtendedDialog;
     31import org.openstreetmap.josm.gui.MainApplication;
     32import org.openstreetmap.josm.gui.MapFrame;
     33import org.openstreetmap.josm.gui.MapView;
    3134import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer;
    3235import org.openstreetmap.josm.gui.layer.imagery.TileSourceDisplaySettings;
     
    7275        EastNorth curOff = old == null ? EastNorth.ZERO : old.getDisplacement(Main.getProjection());
    7376        LatLon center;
    74         if (Main.isDisplayingMapView()) {
    75             center = Main.getProjection().eastNorth2latlon(Main.map.mapView.getCenter());
     77        if (MainApplication.isDisplayingMapView()) {
     78            center = Main.getProjection().eastNorth2latlon(MainApplication.getMap().mapView.getCenter());
    7679        } else {
    7780            center = LatLon.ZERO;
     
    98101
    99102    protected void addListeners() {
    100         Main.map.mapView.addMouseListener(this);
    101         Main.map.mapView.addMouseMotionListener(this);
     103        MapView mapView = MainApplication.getMap().mapView;
     104        mapView.addMouseListener(this);
     105        mapView.addMouseMotionListener(this);
    102106        try {
    103107            Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.KEY_EVENT_MASK);
     
    126130            Logging.error(ex);
    127131        }
    128         if (Main.isDisplayingMapView()) {
    129             Main.map.mapView.removeMouseMotionListener(this);
    130             Main.map.mapView.removeMouseListener(this);
     132        if (MainApplication.isDisplayingMapView()) {
     133            MapFrame map = MainApplication.getMap();
     134            map.mapView.removeMouseMotionListener(this);
     135            map.mapView.removeMouseListener(this);
    131136        }
    132137    }
     
    172177        if (layer.isVisible()) {
    173178            requestFocusInMapView();
    174             prevEastNorth = Main.map.mapView.getEastNorth(e.getX(), e.getY());
    175             Main.map.mapView.setNewCursor(Cursor.MOVE_CURSOR, this);
     179            MapView mapView = MainApplication.getMap().mapView;
     180            prevEastNorth = mapView.getEastNorth(e.getX(), e.getY());
     181            mapView.setNewCursor(Cursor.MOVE_CURSOR, this);
    176182        }
    177183    }
     
    180186    public void mouseDragged(MouseEvent e) {
    181187        if (layer == null || prevEastNorth == null) return;
    182         EastNorth eastNorth = Main.map.mapView.getEastNorth(e.getX(), e.getY());
     188        EastNorth eastNorth = MainApplication.getMap().mapView.getEastNorth(e.getX(), e.getY());
    183189        EastNorth d = tempOffset.getDisplacement().add(eastNorth).subtract(prevEastNorth);
    184190        tempOffset.setDisplacement(d);
     
    192198    @Override
    193199    public void mouseReleased(MouseEvent e) {
    194         Main.map.mapView.repaint();
    195         Main.map.mapView.resetCursor(this);
     200        MapView mapView = MainApplication.getMap().mapView;
     201        mapView.repaint();
     202        mapView.resetCursor(this);
    196203        prevEastNorth = null;
    197204    }
     
    199206    @Override
    200207    public void actionPerformed(ActionEvent e) {
    201         if (offsetDialog != null || layer == null || Main.map == null)
     208        MapFrame map = MainApplication.getMap();
     209        if (offsetDialog != null || layer == null || map == null)
    202210            return;
    203         oldMapMode = Main.map.mapMode;
     211        oldMapMode = map.mapMode;
    204212        super.actionPerformed(e);
    205213    }
     
    266274            }
    267275            updateOffsetIntl();
    268             if (Main.isDisplayingMapView()) {
    269                 Main.map.repaint();
     276            if (MainApplication.isDisplayingMapView()) {
     277                MainApplication.getMap().repaint();
    270278            }
    271279        }
     
    334342
    335343        private void restoreMapModeState() {
    336             if (Main.map == null)
     344            MapFrame map = MainApplication.getMap();
     345            if (map == null)
    337346                return;
    338347            if (oldMapMode != null) {
    339                 Main.map.selectMapMode(oldMapMode);
     348                map.selectMapMode(oldMapMode);
    340349                oldMapMode = null;
    341350            } else {
    342                 Main.map.selectSelectTool(false);
     351                map.selectSelectTool(false);
    343352            }
    344353        }
Note: See TracChangeset for help on using the changeset viewer.