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/mapmode/ExtrudeAction.java

    r12620 r12630  
    4545import org.openstreetmap.josm.data.osm.WaySegment;
    4646import org.openstreetmap.josm.data.preferences.ColorProperty;
     47import org.openstreetmap.josm.gui.MainApplication;
    4748import org.openstreetmap.josm.gui.MainMenu;
     49import org.openstreetmap.josm.gui.MapFrame;
    4850import org.openstreetmap.josm.gui.MapView;
    4951import org.openstreetmap.josm.gui.draw.MapViewPath;
     
    205207        @Override
    206208        protected void updateEnabledState() {
    207             setEnabled(Main.map != null && Main.map.mapMode instanceof ExtrudeAction);
     209            MapFrame map = MainApplication.getMap();
     210            setEnabled(map != null && map.mapMode instanceof ExtrudeAction);
    208211        }
    209212    }
     
    293296    public void enterMode() {
    294297        super.enterMode();
    295         Main.map.mapView.addMouseListener(this);
    296         Main.map.mapView.addMouseMotionListener(this);
     298        MapFrame map = MainApplication.getMap();
     299        map.mapView.addMouseListener(this);
     300        map.mapView.addMouseMotionListener(this);
    297301        ignoreNextKeyRelease = true;
    298         Main.map.keyDetector.addKeyListener(this);
    299         Main.map.keyDetector.addModifierExListener(this);
     302        map.keyDetector.addKeyListener(this);
     303        map.keyDetector.addModifierExListener(this);
    300304    }
    301305
     
    321325    @Override
    322326    public void exitMode() {
    323         Main.map.mapView.removeMouseListener(this);
    324         Main.map.mapView.removeMouseMotionListener(this);
    325         Main.map.mapView.removeTemporaryLayer(this);
     327        MapFrame map = MainApplication.getMap();
     328        map.mapView.removeMouseListener(this);
     329        map.mapView.removeMouseMotionListener(this);
     330        map.mapView.removeTemporaryLayer(this);
    326331        dualAlignCheckboxMenuItem.getAction().setEnabled(false);
    327         Main.map.keyDetector.removeKeyListener(this);
    328         Main.map.keyDetector.removeModifierExListener(this);
     332        map.keyDetector.removeKeyListener(this);
     333        map.keyDetector.removeModifierExListener(this);
    329334        super.exitMode();
    330335    }
     
    339344    @Override
    340345    public void modifiersExChanged(int modifiers) {
    341         if (!Main.isDisplayingMapView() || !Main.map.mapView.isActiveLayerDrawable())
     346        MapFrame map = MainApplication.getMap();
     347        if (!MainApplication.isDisplayingMapView() || !map.mapView.isActiveLayerDrawable())
    342348            return;
    343349        updateKeyModifiersEx(modifiers);
    344350        if (mode == Mode.select) {
    345             Main.map.mapView.setNewCursor(ctrl ? cursorTranslate : alt ? cursorCreateNew : shift ? cursorCreateNodes : cursor, this);
     351            map.mapView.setNewCursor(ctrl ? cursorTranslate : alt ? cursorCreateNew : shift ? cursorCreateNodes : cursor, this);
    346352        }
    347353    }
     
    380386    @Override
    381387    public void mousePressed(MouseEvent e) {
    382         if (!Main.map.mapView.isActiveLayerVisible())
     388        MapFrame map = MainApplication.getMap();
     389        if (!map.mapView.isActiveLayerVisible())
    383390            return;
    384391        if (!(Boolean) this.getValue("active"))
     
    390397        updateKeyModifiers(e);
    391398
    392         selectedNode = Main.map.mapView.getNearestNode(e.getPoint(), OsmPrimitive::isSelectable);
    393         selectedSegment = Main.map.mapView.getNearestWaySegment(e.getPoint(), OsmPrimitive::isSelectable);
     399        selectedNode = map.mapView.getNearestNode(e.getPoint(), OsmPrimitive::isSelectable);
     400        selectedSegment = map.mapView.getNearestWaySegment(e.getPoint(), OsmPrimitive::isSelectable);
    394401
    395402        // If nothing gets caught, stay in select mode
     
    441448        moveCommand2 = null;
    442449
    443         Main.map.mapView.addTemporaryLayer(this);
     450        map.mapView.addTemporaryLayer(this);
    444451
    445452        updateStatusLine();
    446         Main.map.mapView.repaint();
     453        map.mapView.repaint();
    447454
    448455        // Make note of time pressed
     
    459466    @Override
    460467    public void mouseDragged(MouseEvent e) {
    461         if (!Main.map.mapView.isActiveLayerVisible())
     468        MapView mapView = MainApplication.getMap().mapView;
     469        if (!mapView.isActiveLayerVisible())
    462470            return;
    463471
     
    471479            //move, create new and extrude mode - move the selected segment
    472480
    473             EastNorth mouseEn = Main.map.mapView.getEastNorth(e.getPoint().x, e.getPoint().y);
     481            EastNorth mouseEn = mapView.getEastNorth(e.getPoint().x, e.getPoint().y);
    474482            EastNorth bestMovement = calculateBestMovementAndNewNodes(mouseEn);
    475483
    476             Main.map.mapView.setNewCursor(Cursor.MOVE_CURSOR, this);
     484            mapView.setNewCursor(Cursor.MOVE_CURSOR, this);
    477485
    478486            if (dualAlignActive) {
     
    511519            }
    512520
    513             Main.map.mapView.repaint();
     521            mapView.repaint();
    514522        }
    515523    }
     
    522530    public void mouseReleased(MouseEvent e) {
    523531
    524         if (!Main.map.mapView.isActiveLayerVisible())
     532        MapView mapView = MainApplication.getMap().mapView;
     533        if (!mapView.isActiveLayerVisible())
    525534            return;
    526535
     
    553562            updateKeyModifiers(e);
    554563            // Switch back into select mode
    555             Main.map.mapView.setNewCursor(ctrl ? cursorTranslate : alt ? cursorCreateNew : shift ? cursorCreateNodes : cursor, this);
    556             Main.map.mapView.removeTemporaryLayer(this);
     564            mapView.setNewCursor(ctrl ? cursorTranslate : alt ? cursorCreateNew : shift ? cursorCreateNodes : cursor, this);
     565            mapView.removeTemporaryLayer(this);
    557566            selectedSegment = null;
    558567            moveCommand = null;
     
    560569            dualAlignSegmentCollapsed = false;
    561570            updateStatusLine();
    562             Main.map.mapView.repaint();
     571            mapView.repaint();
    563572        }
    564573    }
     
    574583    private static void addNewNode(MouseEvent e) {
    575584        // Should maybe do the same as in DrawAction and fetch all nearby segments?
    576         WaySegment ws = Main.map.mapView.getNearestWaySegment(e.getPoint(), OsmPrimitive::isSelectable);
     585        MapView mapView = MainApplication.getMap().mapView;
     586        WaySegment ws = mapView.getNearestWaySegment(e.getPoint(), OsmPrimitive::isSelectable);
    577587        if (ws != null) {
    578             Node n = new Node(Main.map.mapView.getLatLon(e.getX(), e.getY()));
     588            Node n = new Node(mapView.getLatLon(e.getX(), e.getY()));
    579589            EastNorth a = ws.getFirstNode().getEastNorth();
    580590            EastNorth b = ws.getSecondNode().getEastNorth();
     
    743753    private EastNorth calculateBestMovement(EastNorth mouseEn) {
    744754
    745         EastNorth initialMouseEn = Main.map.mapView.getEastNorth(initialMousePos.x, initialMousePos.y);
     755        EastNorth initialMouseEn = MainApplication.getMap().mapView.getEastNorth(initialMousePos.x, initialMousePos.y);
    746756        EastNorth mouseMovement = mouseEn.subtract(initialMouseEn);
    747757
     
    926936        double distance = Main.getProjection().eastNorth2latlon(initialN1en).greatCircleDistance(
    927937                Main.getProjection().eastNorth2latlon(n1movedEn));
    928         Main.map.statusLine.setDist(distance);
     938        MainApplication.getMap().statusLine.setDist(distance);
    929939        updateStatusLine();
    930940
Note: See TracChangeset for help on using the changeset viewer.