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

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

Location:
trunk/src/org/openstreetmap/josm/actions/mapmode
Files:
12 edited

Legend:

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

    r12620 r12630  
    1313import org.openstreetmap.josm.data.coor.LatLon;
    1414import org.openstreetmap.josm.data.osm.NoteData;
     15import org.openstreetmap.josm.gui.MainApplication;
     16import org.openstreetmap.josm.gui.MapFrame;
    1517import org.openstreetmap.josm.gui.NoteInputDialog;
    1618import org.openstreetmap.josm.gui.Notification;
     
    4850    public void enterMode() {
    4951        super.enterMode();
    50         Main.map.mapView.addMouseListener(this);
    51         Main.map.keyDetector.addKeyListener(this);
     52        MapFrame map = MainApplication.getMap();
     53        map.mapView.addMouseListener(this);
     54        map.keyDetector.addKeyListener(this);
    5255    }
    5356
     
    5558    public void exitMode() {
    5659        super.exitMode();
    57         Main.map.mapView.removeMouseListener(this);
    58         Main.map.keyDetector.removeKeyListener(this);
     60        MapFrame map = MainApplication.getMap();
     61        map.mapView.removeMouseListener(this);
     62        map.keyDetector.removeKeyListener(this);
    5963    }
    6064
     
    6569            return;
    6670        }
    67         Main.map.selectMapMode(Main.map.mapModeSelect);
     71        MapFrame map = MainApplication.getMap();
     72        map.selectMapMode(map.mapModeSelect);
    6873
    6974        NoteInputDialog dialog = new NoteInputDialog(Main.parent, tr("Create new note"), tr("Create note"));
     
    7681        String input = dialog.getInputText();
    7782        if (input != null && !input.isEmpty()) {
    78             LatLon latlon = Main.map.mapView.getLatLon(e.getPoint().x, e.getPoint().y);
     83            LatLon latlon = map.mapView.getLatLon(e.getPoint().x, e.getPoint().y);
    7984            noteData.createNote(latlon, input);
    8085        } else {
     
    8691    public void doKeyPressed(KeyEvent e) {
    8792        if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
    88             Main.map.selectMapMode(Main.map.mapModeSelect);
     93            MapFrame map = MainApplication.getMap();
     94            map.selectMapMode(map.mapModeSelect);
    8995        }
    9096    }
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java

    r12537 r12630  
    2121import org.openstreetmap.josm.data.osm.Relation;
    2222import org.openstreetmap.josm.data.osm.WaySegment;
     23import org.openstreetmap.josm.gui.MainApplication;
     24import org.openstreetmap.josm.gui.MapFrame;
     25import org.openstreetmap.josm.gui.MapView;
    2326import org.openstreetmap.josm.gui.dialogs.relation.RelationDialogManager;
    2427import org.openstreetmap.josm.gui.layer.Layer;
     
    110113        drawTargetHighlight = Main.pref.getBoolean("draw.target-highlight", true);
    111114
    112         Main.map.mapView.addMouseListener(this);
    113         Main.map.mapView.addMouseMotionListener(this);
     115        MapFrame map = MainApplication.getMap();
     116        map.mapView.addMouseListener(this);
     117        map.mapView.addMouseMotionListener(this);
    114118        // This is required to update the cursors when ctrl/shift/alt is pressed
    115         Main.map.keyDetector.addModifierExListener(this);
     119        map.keyDetector.addModifierExListener(this);
    116120    }
    117121
     
    119123    public void exitMode() {
    120124        super.exitMode();
    121         Main.map.mapView.removeMouseListener(this);
    122         Main.map.mapView.removeMouseMotionListener(this);
    123         Main.map.keyDetector.removeModifierExListener(this);
     125        MapFrame map = MainApplication.getMap();
     126        map.mapView.removeMouseListener(this);
     127        map.mapView.removeMouseMotionListener(this);
     128        map.keyDetector.removeModifierExListener(this);
    124129        removeHighlighting();
    125130    }
     
    245250     */
    246251    private void updateCursor(MouseEvent e, int modifiers) {
    247         if (!Main.isDisplayingMapView())
    248             return;
    249         if (!Main.map.mapView.isActiveLayerVisible() || e == null)
     252        if (!MainApplication.isDisplayingMapView())
     253            return;
     254        MapFrame map = MainApplication.getMap();
     255        if (!map.mapView.isActiveLayerVisible() || e == null)
    250256            return;
    251257
    252258        DeleteParameters parameters = getDeleteParameters(e, modifiers);
    253         Main.map.mapView.setNewCursor(parameters.mode.cursor(), this);
     259        map.mapView.setNewCursor(parameters.mode.cursor(), this);
    254260    }
    255261
     
    288294        if (e.getButton() != MouseEvent.BUTTON1)
    289295            return;
    290         if (!Main.map.mapView.isActiveLayerVisible())
     296        MapFrame map = MainApplication.getMap();
     297        if (!map.mapView.isActiveLayerVisible())
    291298            return;
    292299
    293300        // request focus in order to enable the expected keyboard shortcuts
    294301        //
    295         Main.map.mapView.requestFocus();
     302        map.mapView.requestFocus();
    296303
    297304        Command c = buildDeleteCommands(e, e.getModifiersEx(), false);
     
    318325    @Override
    319326    protected void updateEnabledState() {
    320         setEnabled(Main.isDisplayingMapView() && Main.map.mapView.isActiveLayerDrawable());
     327        setEnabled(MainApplication.isDisplayingMapView() && MainApplication.getMap().mapView.isActiveLayerDrawable());
    321328    }
    322329
     
    363370        DeleteParameters result = new DeleteParameters();
    364371
    365         result.nearestNode = Main.map.mapView.getNearestNode(e.getPoint(), OsmPrimitive::isSelectable);
     372        MapView mapView = MainApplication.getMap().mapView;
     373        result.nearestNode = mapView.getNearestNode(e.getPoint(), OsmPrimitive::isSelectable);
    366374        if (result.nearestNode == null) {
    367             result.nearestSegment = Main.map.mapView.getNearestWaySegment(e.getPoint(), OsmPrimitive::isSelectable);
     375            result.nearestSegment = mapView.getNearestWaySegment(e.getPoint(), OsmPrimitive::isSelectable);
    368376            if (result.nearestSegment != null) {
    369377                if (shift) {
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java

    r12517 r12630  
    5454import org.openstreetmap.josm.data.preferences.DoubleProperty;
    5555import org.openstreetmap.josm.data.preferences.StrokeProperty;
     56import org.openstreetmap.josm.gui.MainApplication;
    5657import org.openstreetmap.josm.gui.MainMenu;
     58import org.openstreetmap.josm.gui.MapFrame;
    5759import org.openstreetmap.josm.gui.MapView;
    5860import org.openstreetmap.josm.gui.MapViewState.MapViewPoint;
     
    270272        snapCheckboxMenuItem.getAction().setEnabled(true);
    271273
    272         Main.map.statusLine.getAnglePanel().addMouseListener(snapHelper.anglePopupListener);
     274        MapFrame map = MainApplication.getMap();
     275        map.statusLine.getAnglePanel().addMouseListener(snapHelper.anglePopupListener);
    273276        Main.registerActionShortcut(backspaceAction, backspaceShortcut);
    274277
    275         Main.map.mapView.addMouseListener(this);
    276         Main.map.mapView.addMouseMotionListener(this);
    277         Main.map.mapView.addTemporaryLayer(this);
     278        map.mapView.addMouseListener(this);
     279        map.mapView.addMouseMotionListener(this);
     280        map.mapView.addTemporaryLayer(this);
    278281        SelectionEventManager.getInstance().addSelectionListenerForEdt(this);
    279282
    280         Main.map.keyDetector.addKeyListener(this);
    281         Main.map.keyDetector.addModifierExListener(this);
     283        map.keyDetector.addKeyListener(this);
     284        map.keyDetector.addModifierExListener(this);
    282285        ignoreNextKeyRelease = true;
    283286    }
     
    286289    public void exitMode() {
    287290        super.exitMode();
    288         Main.map.mapView.removeMouseListener(this);
    289         Main.map.mapView.removeMouseMotionListener(this);
    290         Main.map.mapView.removeTemporaryLayer(this);
     291        MapFrame map = MainApplication.getMap();
     292        map.mapView.removeMouseListener(this);
     293        map.mapView.removeMouseMotionListener(this);
     294        map.mapView.removeTemporaryLayer(this);
    291295        SelectionEventManager.getInstance().removeSelectionListener(this);
    292296        Main.unregisterActionShortcut(backspaceAction, backspaceShortcut);
     
    294298        snapCheckboxMenuItem.getAction().setEnabled(false);
    295299
    296         Main.map.statusLine.getAnglePanel().removeMouseListener(snapHelper.anglePopupListener);
    297         Main.map.statusLine.activateAnglePanel(false);
     300        map.statusLine.getAnglePanel().removeMouseListener(snapHelper.anglePopupListener);
     301        map.statusLine.activateAnglePanel(false);
    298302
    299303        removeHighlighting();
    300         Main.map.keyDetector.removeKeyListener(this);
    301         Main.map.keyDetector.removeModifierExListener(this);
     304        map.keyDetector.removeKeyListener(this);
     305        map.keyDetector.removeModifierExListener(this);
    302306    }
    303307
     
    307311    @Override
    308312    public void modifiersExChanged(int modifiers) {
    309         if (!Main.isDisplayingMapView() || !Main.map.mapView.isActiveLayerDrawable())
     313        if (!MainApplication.isDisplayingMapView() || !MainApplication.getMap().mapView.isActiveLayerDrawable())
    310314            return;
    311315        updateKeyModifiersEx(modifiers);
     
    341345    @Override
    342346    public void selectionChanged(SelectionChangeEvent event) {
    343         if (!Main.map.mapView.isActiveLayerDrawable())
     347        if (!MainApplication.getMap().mapView.isActiveLayerDrawable())
    344348            return;
    345349        computeHelperLine();
     
    360364        lastUsedNode = null;
    361365        wayIsFinished = true;
    362         Main.map.selectSelectTool(true);
     366        MainApplication.getMap().selectSelectTool(true);
    363367        snapHelper.noSnapNow();
    364368
     
    392396        if (e.getButton() != MouseEvent.BUTTON1)
    393397            return;
    394         if (!Main.map.mapView.isActiveLayerDrawable())
     398        MapView mapView = MainApplication.getMap().mapView;
     399        if (!mapView.isActiveLayerDrawable())
    395400            return;
    396401        // request focus in order to enable the expected keyboard shortcuts
    397402        //
    398         Main.map.mapView.requestFocus();
     403        mapView.requestFocus();
    399404
    400405        if (e.getClickCount() > 1 && mousePos != null && mousePos.equals(oldMousePos)) {
     
    417422
    418423        boolean newNode = false;
    419         Node n = Main.map.mapView.getNearestNode(mousePos, OsmPrimitive::isSelectable);
     424        Node n = mapView.getNearestNode(mousePos, OsmPrimitive::isSelectable);
    420425        if (ctrl) {
    421426            Iterator<Way> it = ds.getSelectedWays().iterator();
     
    453458                newEN = snapHelper.getSnapPoint(foundPoint);
    454459                // do not add new node if there is some node within snapping distance
    455                 double tolerance = Main.map.mapView.getDist100Pixel() * toleranceMultiplier;
     460                double tolerance = mapView.getDist100Pixel() * toleranceMultiplier;
    456461                if (foundPoint.distance(newEN) > tolerance) {
    457462                    n = new Node(newEN); // point != projected, so we create new node
     
    459464                }
    460465            } else { // n==null, no node found in clicked area
    461                 EastNorth mouseEN = Main.map.mapView.getEastNorth(e.getX(), e.getY());
     466                EastNorth mouseEN = mapView.getEastNorth(e.getX(), e.getY());
    462467                newEN = snapHelper.isSnapOn() ? snapHelper.getSnapPoint(mouseEN) : mouseEN;
    463468                n = new Node(newEN); //create node at clicked point
     
    486491            if (!ctrl) {
    487492                // Insert the node into all the nearby way segments
    488                 List<WaySegment> wss = Main.map.mapView.getNearestWaySegments(
    489                         Main.map.mapView.getPoint(n), OsmPrimitive::isSelectable);
     493                List<WaySegment> wss = mapView.getNearestWaySegments(
     494                        mapView.getPoint(n), OsmPrimitive::isSelectable);
    490495                if (snapHelper.isActive()) {
    491496                    tryToMoveNodeOnIntersection(wss, n);
     
    622627        // from aerial imagery or GPS tracks.
    623628        if (VIEWPORT_FOLLOWING.get()) {
    624             Main.map.mapView.smoothScrollTo(n.getEastNorth());
     629            mapView.smoothScrollTo(n.getEastNorth());
    625630        }
    626631        computeHelperLine();
     
    767772    @Override
    768773    public void mouseMoved(MouseEvent e) {
    769         if (!Main.map.mapView.isActiveLayerDrawable())
     774        if (!MainApplication.getMap().mapView.isActiveLayerDrawable())
    770775            return;
    771776
     
    787792    private void tryToSetBaseSegmentForAngleSnap() {
    788793        if (mousePos != null) {
    789             WaySegment seg = Main.map.mapView.getNearestWaySegment(mousePos, OsmPrimitive::isSelectable);
     794            WaySegment seg = MainApplication.getMap().mapView.getNearestWaySegment(mousePos, OsmPrimitive::isSelectable);
    790795            if (seg != null) {
    791796                snapHelper.setBaseSegment(seg);
     
    809814        Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected();
    810815
    811         MapView mv = Main.map.mapView;
     816        MapView mv = MainApplication.getMap().mapView;
    812817        Node currentMouseNode = null;
    813818        mouseOnExistingNode = null;
     
    864869
    865870    static void showStatusInfo(double angle, double hdg, double distance, boolean activeFlag) {
    866         Main.map.statusLine.setAngle(angle);
    867         Main.map.statusLine.activateAnglePanel(activeFlag);
    868         Main.map.statusLine.setHeading(hdg);
    869         Main.map.statusLine.setDist(distance);
     871        MapFrame map = MainApplication.getMap();
     872        map.statusLine.setAngle(angle);
     873        map.statusLine.activateAnglePanel(activeFlag);
     874        map.statusLine.setHeading(hdg);
     875        map.statusLine.setDist(distance);
    870876    }
    871877
     
    10601066        // fall through to default action.
    10611067        // (for semi-parallel lines, intersection might be miles away!)
    1062         if (Main.map.mapView.getPoint2D(n).distance(Main.map.mapView.getPoint2D(intersection)) < SNAP_TO_INTERSECTION_THRESHOLD.get()) {
     1068        MapFrame map = MainApplication.getMap();
     1069        if (map.mapView.getPoint2D(n).distance(map.mapView.getPoint2D(intersection)) < SNAP_TO_INTERSECTION_THRESHOLD.get()) {
    10631070            n.setEastNorth(intersection);
    10641071            return;
     
    11131120    private void addHighlighting() {
    11141121        newHighlights = new HashSet<>();
     1122        MapView mapView = MainApplication.getMap().mapView;
    11151123
    11161124        // if ctrl key is held ("no join"), don't highlight anything
    11171125        if (ctrl) {
    1118             Main.map.mapView.setNewCursor(cursor, this);
     1126            mapView.setNewCursor(cursor, this);
    11191127            redrawIfRequired();
    11201128            return;
     
    11231131        // This happens when nothing is selected, but we still want to highlight the "target node"
    11241132        if (mouseOnExistingNode == null && mousePos != null && getLayerManager().getEditDataSet().selectionEmpty()) {
    1125             mouseOnExistingNode = Main.map.mapView.getNearestNode(mousePos, OsmPrimitive::isSelectable);
     1133            mouseOnExistingNode = mapView.getNearestNode(mousePos, OsmPrimitive::isSelectable);
    11261134        }
    11271135
    11281136        if (mouseOnExistingNode != null) {
    1129             Main.map.mapView.setNewCursor(cursorJoinNode, this);
     1137            mapView.setNewCursor(cursorJoinNode, this);
    11301138            newHighlights.add(mouseOnExistingNode);
    11311139            redrawIfRequired();
     
    11351143        // Insert the node into all the nearby way segments
    11361144        if (mouseOnExistingWays.isEmpty()) {
    1137             Main.map.mapView.setNewCursor(cursor, this);
     1145            mapView.setNewCursor(cursor, this);
    11381146            redrawIfRequired();
    11391147            return;
    11401148        }
    11411149
    1142         Main.map.mapView.setNewCursor(cursorJoinWay, this);
     1150        mapView.setNewCursor(cursorJoinWay, this);
    11431151        newHighlights.addAll(mouseOnExistingWays);
    11441152        redrawIfRequired();
     
    11571165    public void paint(Graphics2D g, MapView mv, Bounds box) {
    11581166        // sanity checks
    1159         if (Main.map.mapView == null || mousePos == null
     1167        MapView mapView = MainApplication.getMap().mapView;
     1168        if (mapView == null || mousePos == null
    11601169                // don't draw line if we don't know where from or where to
    11611170                || currentMouseEastNorth == null || getCurrentBaseNode() == null
    11621171                // don't draw line if mouse is outside window
    1163                 || !Main.map.mapView.getState().getForView(mousePos.getX(), mousePos.getY()).isInView())
     1172                || !mapView.getState().getForView(mousePos.getX(), mousePos.getY()).isInView())
    11641173            return;
    11651174
     
    13681377        @Override
    13691378        protected void updateEnabledState() {
    1370             setEnabled(Main.map != null && Main.map.mapMode instanceof DrawAction);
     1379            MapFrame map = MainApplication.getMap();
     1380            setEnabled(map != null && map.mapMode instanceof DrawAction);
    13711381        }
    13721382    }
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DrawSnapHelper.java

    r12620 r12630  
    2525import org.openstreetmap.josm.data.osm.Way;
    2626import org.openstreetmap.josm.data.osm.WaySegment;
     27import org.openstreetmap.josm.gui.MainApplication;
     28import org.openstreetmap.josm.gui.MapView;
    2729import org.openstreetmap.josm.gui.MapViewState;
    2830import org.openstreetmap.josm.gui.MapViewState.MapViewPoint;
     
    335337     */
    336338    public void checkAngleSnapping(EastNorth currentEN, double baseHeading, double curHeading) {
     339        MapView mapView = MainApplication.getMap().mapView;
    337340        EastNorth p0 = drawAction.getCurrentBaseNode().getEastNorth();
    338341        EastNorth snapPoint = currentEN;
     
    375378                pe = Math.sin(phi);
    376379                pn = Math.cos(phi);
    377                 double scale = 20 * Main.map.mapView.getDist100Pixel();
     380                double scale = 20 * mapView.getDist100Pixel();
    378381                dir2 = new EastNorth(e0 + scale * pe, n0 + scale * pn);
    379382                snapPoint = getSnapPoint(currentEN);
     
    384387
    385388        // find out the distance, in metres, between the base point and projected point
    386         LatLon mouseLatLon = Main.map.mapView.getProjection().eastNorth2latlon(snapPoint);
     389        LatLon mouseLatLon = mapView.getProjection().eastNorth2latlon(snapPoint);
    387390        double distance = this.drawAction.getCurrentBaseNode().getCoor().greatCircleDistance(mouseLatLon);
    388391        double hdg = Utils.toDegrees(p0.heading(snapPoint));
     
    436439        double dn = p.north()-n0;
    437440        double l = de*pe+dn*pn;
    438         double delta = Main.map.mapView.getDist100Pixel()/20;
     441        double delta = MainApplication.getMap().mapView.getDist100Pixel()/20;
    439442        if (!absoluteFix && l < delta) {
    440443            active = false;
  • 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
  • trunk/src/org/openstreetmap/josm/actions/mapmode/ImproveWayAccuracyAction.java

    r12581 r12630  
    4040import org.openstreetmap.josm.data.preferences.IntegerProperty;
    4141import org.openstreetmap.josm.data.preferences.StrokeProperty;
     42import org.openstreetmap.josm.gui.MainApplication;
     43import org.openstreetmap.josm.gui.MapFrame;
    4244import org.openstreetmap.josm.gui.MapView;
    4345import org.openstreetmap.josm.gui.draw.MapViewPath;
     
    138140        readPreferences();
    139141
    140         mv = Main.map.mapView;
     142        MapFrame map = MainApplication.getMap();
     143        mv = map.mapView;
    141144        mousePos = null;
    142145        oldModeHelpText = "";
     
    148151        updateStateByCurrentSelection();
    149152
    150         Main.map.mapView.addMouseListener(this);
    151         Main.map.mapView.addMouseMotionListener(this);
    152         Main.map.mapView.addTemporaryLayer(temporaryLayer);
     153        map.mapView.addMouseListener(this);
     154        map.mapView.addMouseMotionListener(this);
     155        map.mapView.addTemporaryLayer(temporaryLayer);
    153156        DataSet.addSelectionListener(this);
    154157
    155         Main.map.keyDetector.addModifierExListener(this);
     158        map.keyDetector.addModifierExListener(this);
    156159    }
    157160
     
    165168        super.exitMode();
    166169
    167         Main.map.mapView.removeMouseListener(this);
    168         Main.map.mapView.removeMouseMotionListener(this);
    169         Main.map.mapView.removeTemporaryLayer(temporaryLayer);
     170        MapFrame map = MainApplication.getMap();
     171        map.mapView.removeMouseListener(this);
     172        map.mapView.removeMouseMotionListener(this);
     173        map.mapView.removeTemporaryLayer(temporaryLayer);
    170174        DataSet.removeSelectionListener(this);
    171175
    172         Main.map.keyDetector.removeModifierExListener(this);
     176        map.keyDetector.removeModifierExListener(this);
    173177        temporaryLayer.invalidate();
    174178    }
     
    179183        if (!newModeHelpText.equals(oldModeHelpText)) {
    180184            oldModeHelpText = newModeHelpText;
    181             Main.map.statusLine.setHelpText(newModeHelpText);
    182             Main.map.statusLine.repaint();
     185            MapFrame map = MainApplication.getMap();
     186            map.statusLine.setHelpText(newModeHelpText);
     187            map.statusLine.repaint();
    183188        }
    184189    }
     
    348353    @Override
    349354    public void modifiersExChanged(int modifiers) {
    350         if (!Main.isDisplayingMapView() || !Main.map.mapView.isActiveLayerDrawable()) {
     355        if (!MainApplication.isDisplayingMapView() || !MainApplication.getMap().mapView.isActiveLayerDrawable()) {
    351356            return;
    352357        }
  • trunk/src/org/openstreetmap/josm/actions/mapmode/ImproveWayAccuracyHelper.java

    r10716 r12630  
    66import java.util.List;
    77
    8 import org.openstreetmap.josm.Main;
    98import org.openstreetmap.josm.data.coor.EastNorth;
    109import org.openstreetmap.josm.data.osm.Node;
     
    1211import org.openstreetmap.josm.data.osm.Way;
    1312import org.openstreetmap.josm.data.osm.WaySegment;
     13import org.openstreetmap.josm.gui.MainApplication;
    1414import org.openstreetmap.josm.gui.MapView;
    1515import org.openstreetmap.josm.tools.Geometry;
     
    5757        }
    5858
    59         return Main.map.mapView.getNearestWay(p, OsmPrimitive::isSelectable);
     59        return MainApplication.getMap().mapView.getNearestWay(p, OsmPrimitive::isSelectable);
    6060    }
    6161
  • trunk/src/org/openstreetmap/josm/actions/mapmode/MapMode.java

    r12526 r12630  
    1616import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener;
    1717import org.openstreetmap.josm.data.osm.OsmPrimitive;
     18import org.openstreetmap.josm.gui.MainApplication;
    1819import org.openstreetmap.josm.gui.MapFrame;
    1920import org.openstreetmap.josm.gui.layer.Layer;
     
    99100        Main.pref.addPreferenceChangeListener(this);
    100101        readPreferences();
    101         Main.map.mapView.setNewCursor(cursor, this);
     102        MainApplication.getMap().mapView.setNewCursor(cursor, this);
    102103        updateStatusLine();
    103104    }
     
    109110        putValue("active", Boolean.FALSE);
    110111        Main.pref.removePreferenceChangeListener(this);
    111         Main.map.mapView.resetCursor(this);
     112        MainApplication.getMap().mapView.resetCursor(this);
    112113    }
    113114
    114115    protected void updateStatusLine() {
    115         if (Main.map != null && Main.map.statusLine != null) {
    116             Main.map.statusLine.setHelpText(getModeHelpText());
    117             Main.map.statusLine.repaint();
     116        MapFrame map = MainApplication.getMap();
     117        if (map != null && map.statusLine != null) {
     118            map.statusLine.setHelpText(getModeHelpText());
     119            map.statusLine.repaint();
    118120        }
    119121    }
     
    134136    @Override
    135137    public void actionPerformed(ActionEvent e) {
    136         if (Main.isDisplayingMapView()) {
    137             Main.map.selectMapMode(this);
     138        if (MainApplication.isDisplayingMapView()) {
     139            MainApplication.getMap().selectMapMode(this);
    138140        }
    139141    }
     
    225227        if (isEnabled()) {
    226228            // request focus in order to enable the expected keyboard shortcuts (see #8710)
    227             Main.map.mapView.requestFocus();
     229            MainApplication.getMap().mapView.requestFocus();
    228230        }
    229231    }
  • trunk/src/org/openstreetmap/josm/actions/mapmode/ParallelWayAction.java

    r12620 r12630  
    2525import javax.swing.JOptionPane;
    2626
    27 import org.openstreetmap.josm.Main;
    2827import org.openstreetmap.josm.data.Bounds;
    2928import org.openstreetmap.josm.data.SystemOfMeasurement;
     
    4039import org.openstreetmap.josm.data.preferences.IntegerProperty;
    4140import org.openstreetmap.josm.data.preferences.StrokeProperty;
     41import org.openstreetmap.josm.gui.MainApplication;
    4242import org.openstreetmap.josm.gui.MapFrame;
    4343import org.openstreetmap.josm.gui.MapView;
     
    172172        mv.addTemporaryLayer(temporaryLayer);
    173173
    174         //// Needed to update the mouse cursor if modifiers are changed when the mouse is motionless
    175         Main.map.keyDetector.addModifierExListener(this);
     174        // Needed to update the mouse cursor if modifiers are changed when the mouse is motionless
     175        MainApplication.getMap().keyDetector.addModifierExListener(this);
    176176        sourceWays = new LinkedHashSet<>(getLayerManager().getEditDataSet().getSelectedWays());
    177177        for (Way w : sourceWays) {
     
    186186        mv.removeMouseMotionListener(this);
    187187        mv.removeTemporaryLayer(temporaryLayer);
    188         Main.map.statusLine.setDist(-1);
    189         Main.map.statusLine.repaint();
    190         Main.map.keyDetector.removeModifierExListener(this);
     188        MapFrame map = MainApplication.getMap();
     189        map.statusLine.setDist(-1);
     190        map.statusLine.repaint();
     191        map.keyDetector.removeModifierExListener(this);
    191192        removeWayHighlighting(sourceWays);
    192193        pWays = null;
     
    217218    @Override
    218219    public void modifiersExChanged(int modifiers) {
    219         if (Main.map == null || mv == null || !mv.isActiveLayerDrawable())
     220        if (MainApplication.getMap() == null || mv == null || !mv.isActiveLayerDrawable())
    220221            return;
    221222
     
    431432        pWays.changeOffset(d);
    432433
    433         Main.map.statusLine.setDist(Math.abs(snappedRealD));
    434         Main.map.statusLine.repaint();
     434        MapFrame map = MainApplication.getMap();
     435        map.statusLine.setDist(Math.abs(snappedRealD));
     436        map.statusLine.repaint();
    435437        temporaryLayer.invalidate();
    436438    }
  • trunk/src/org/openstreetmap/josm/actions/mapmode/PlayHeadDragMode.java

    r11713 r12630  
    88import java.awt.event.MouseEvent;
    99
    10 import org.openstreetmap.josm.Main;
    1110import org.openstreetmap.josm.data.coor.EastNorth;
     11import org.openstreetmap.josm.gui.MainApplication;
     12import org.openstreetmap.josm.gui.MapFrame;
    1213import org.openstreetmap.josm.gui.layer.markerlayer.PlayHeadMarker;
    1314import org.openstreetmap.josm.tools.Shortcut;
     
    3839    @Override public void enterMode() {
    3940        super.enterMode();
    40         Main.map.mapView.addMouseListener(this);
    41         Main.map.mapView.addMouseMotionListener(this);
     41        MapFrame map = MainApplication.getMap();
     42        map.mapView.addMouseListener(this);
     43        map.mapView.addMouseMotionListener(this);
    4244    }
    4345
    4446    @Override public void exitMode() {
    4547        super.exitMode();
    46         Main.map.mapView.removeMouseListener(this);
    47         Main.map.mapView.removeMouseMotionListener(this);
     48        MapFrame map = MainApplication.getMap();
     49        map.mapView.removeMouseListener(this);
     50        map.mapView.removeMouseMotionListener(this);
    4851    }
    4952
     
    6265        }
    6366        if (p.distance(mousePos) == 0) return;
    64         playHeadMarker.drag(Main.map.mapView.getEastNorth(ev.getX(), ev.getY()));
     67        playHeadMarker.drag(MainApplication.getMap().mapView.getEastNorth(ev.getX(), ev.getY()));
    6568        mousePos = p;
    6669    }
     
    7477        updateKeyModifiers(ev);
    7578
    76         EastNorth en = Main.map.mapView.getEastNorth(ev.getX(), ev.getY());
     79        EastNorth en = MainApplication.getMap().mapView.getEastNorth(ev.getX(), ev.getY());
    7780        if (!shift) {
    7881            playHeadMarker.reposition(en);
  • trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

    r12620 r12630  
    4040import org.openstreetmap.josm.data.osm.visitor.paint.WireframeMapRenderer;
    4141import org.openstreetmap.josm.gui.ExtendedDialog;
     42import org.openstreetmap.josm.gui.MainApplication;
    4243import org.openstreetmap.josm.gui.MapFrame;
    4344import org.openstreetmap.josm.gui.MapView;
     
    209210        virtualManager.init();
    210211        // This is required to update the cursors when ctrl/shift/alt is pressed
    211         Main.map.keyDetector.addModifierExListener(this);
    212         Main.map.keyDetector.addKeyListener(this);
     212        MapFrame map = MainApplication.getMap();
     213        map.keyDetector.addModifierExListener(this);
     214        map.keyDetector.addKeyListener(this);
    213215    }
    214216
     
    220222        mv.removeMouseMotionListener(this);
    221223        mv.setVirtualNodesEnabled(false);
    222         Main.map.keyDetector.removeModifierExListener(this);
    223         Main.map.keyDetector.removeKeyListener(this);
     224        MapFrame map = MainApplication.getMap();
     225        map.keyDetector.removeModifierExListener(this);
     226        map.keyDetector.removeKeyListener(this);
    224227        removeHighlighting();
    225228    }
     
    227230    @Override
    228231    public void modifiersExChanged(int modifiers) {
    229         if (!Main.isDisplayingMapView() || oldEvent == null) return;
     232        if (!MainApplication.isDisplayingMapView() || oldEvent == null) return;
    230233        if (giveUserFeedback(oldEvent, modifiers)) {
    231234            mv.repaint();
     
    568571        startingDraggingPos = null;
    569572        mouseReleaseTime = System.currentTimeMillis();
     573        MapFrame map = MainApplication.getMap();
    570574
    571575        if (mode == Mode.SELECT) {
     
    578582            // Select Draw Tool if no selection has been made
    579583            if (!cancelDrawMode && getLayerManager().getEditDataSet().selectionEmpty()) {
    580                 Main.map.selectDrawTool(true);
     584                map.selectDrawTool(true);
    581585                updateStatusLine();
    582586                return;
     
    599603                        // We need to do it like this as otherwise drawAction will see a double
    600604                        // click and switch back to SelectMode
    601                         Main.worker.execute(() -> Main.map.selectDrawTool(true));
     605                        Main.worker.execute(() -> map.selectDrawTool(true));
    602606                        return;
    603607                    }
     
    630634    @Override
    631635    public void doKeyPressed(KeyEvent e) {
    632         if (!repeatedKeySwitchLassoOption || !Main.isDisplayingMapView() || !getShortcut().isEvent(e))
     636        if (!repeatedKeySwitchLassoOption || !MainApplication.isDisplayingMapView() || !getShortcut().isEvent(e))
    633637            return;
    634638        if (Logging.isDebugEnabled()) {
     
    636640        }
    637641        e.consume();
     642        MapFrame map = MainApplication.getMap();
    638643        if (!lassoMode) {
    639             Main.map.selectMapMode(Main.map.mapModeSelectLasso);
     644            map.selectMapMode(map.mapModeSelectLasso);
    640645        } else {
    641             Main.map.selectMapMode(Main.map.mapModeSelect);
     646            map.selectMapMode(map.mapModeSelect);
    642647        }
    643648    }
     
    751756                Collection<Way> ways = ds.getSelectedWays();
    752757                if (doesImpactStatusLine(affectedNodes, ways)) {
    753                     Main.map.statusLine.setDist(ways);
     758                    MainApplication.getMap().statusLine.setDist(ways);
    754759                }
    755760            } finally {
  • trunk/src/org/openstreetmap/josm/actions/mapmode/ZoomAction.java

    r11713 r12630  
    88import java.awt.event.MouseEvent;
    99
    10 import org.openstreetmap.josm.Main;
     10import org.openstreetmap.josm.gui.MainApplication;
    1111import org.openstreetmap.josm.gui.MapFrame;
    1212import org.openstreetmap.josm.gui.MapView;
     
    5353    @Override
    5454    public void selectionEnded(Rectangle r, MouseEvent e) {
    55         if (r.width >= 3 && r.height >= 3 && Main.isDisplayingMapView()) {
    56             MapView mv = Main.map.mapView;
     55        if (r.width >= 3 && r.height >= 3 && MainApplication.isDisplayingMapView()) {
     56            MapView mv = MainApplication.getMap().mapView;
    5757            mv.zoomToFactor(mv.getEastNorth(r.x+r.width/2, r.y+r.height/2), r.getWidth()/mv.getWidth());
    5858        }
     
    6161    @Override public void enterMode() {
    6262        super.enterMode();
    63         selectionManager.register(Main.map.mapView, false);
     63        selectionManager.register(MainApplication.getMap().mapView, false);
    6464    }
    6565
    6666    @Override public void exitMode() {
    6767        super.exitMode();
    68         selectionManager.unregister(Main.map.mapView);
     68        selectionManager.unregister(MainApplication.getMap().mapView);
    6969    }
    7070
Note: See TracChangeset for help on using the changeset viewer.