Changeset 12630 in josm for trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java
- Timestamp:
- 2017-08-24T00:15:51+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java
r12620 r12630 45 45 import org.openstreetmap.josm.data.osm.WaySegment; 46 46 import org.openstreetmap.josm.data.preferences.ColorProperty; 47 import org.openstreetmap.josm.gui.MainApplication; 47 48 import org.openstreetmap.josm.gui.MainMenu; 49 import org.openstreetmap.josm.gui.MapFrame; 48 50 import org.openstreetmap.josm.gui.MapView; 49 51 import org.openstreetmap.josm.gui.draw.MapViewPath; … … 205 207 @Override 206 208 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); 208 211 } 209 212 } … … 293 296 public void enterMode() { 294 297 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); 297 301 ignoreNextKeyRelease = true; 298 Main.map.keyDetector.addKeyListener(this);299 Main.map.keyDetector.addModifierExListener(this);302 map.keyDetector.addKeyListener(this); 303 map.keyDetector.addModifierExListener(this); 300 304 } 301 305 … … 321 325 @Override 322 326 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); 326 331 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); 329 334 super.exitMode(); 330 335 } … … 339 344 @Override 340 345 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()) 342 348 return; 343 349 updateKeyModifiersEx(modifiers); 344 350 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); 346 352 } 347 353 } … … 380 386 @Override 381 387 public void mousePressed(MouseEvent e) { 382 if (!Main.map.mapView.isActiveLayerVisible()) 388 MapFrame map = MainApplication.getMap(); 389 if (!map.mapView.isActiveLayerVisible()) 383 390 return; 384 391 if (!(Boolean) this.getValue("active")) … … 390 397 updateKeyModifiers(e); 391 398 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); 394 401 395 402 // If nothing gets caught, stay in select mode … … 441 448 moveCommand2 = null; 442 449 443 Main.map.mapView.addTemporaryLayer(this);450 map.mapView.addTemporaryLayer(this); 444 451 445 452 updateStatusLine(); 446 Main.map.mapView.repaint();453 map.mapView.repaint(); 447 454 448 455 // Make note of time pressed … … 459 466 @Override 460 467 public void mouseDragged(MouseEvent e) { 461 if (!Main.map.mapView.isActiveLayerVisible()) 468 MapView mapView = MainApplication.getMap().mapView; 469 if (!mapView.isActiveLayerVisible()) 462 470 return; 463 471 … … 471 479 //move, create new and extrude mode - move the selected segment 472 480 473 EastNorth mouseEn = Main.map.mapView.getEastNorth(e.getPoint().x, e.getPoint().y);481 EastNorth mouseEn = mapView.getEastNorth(e.getPoint().x, e.getPoint().y); 474 482 EastNorth bestMovement = calculateBestMovementAndNewNodes(mouseEn); 475 483 476 Main.map.mapView.setNewCursor(Cursor.MOVE_CURSOR, this);484 mapView.setNewCursor(Cursor.MOVE_CURSOR, this); 477 485 478 486 if (dualAlignActive) { … … 511 519 } 512 520 513 Main.map.mapView.repaint();521 mapView.repaint(); 514 522 } 515 523 } … … 522 530 public void mouseReleased(MouseEvent e) { 523 531 524 if (!Main.map.mapView.isActiveLayerVisible()) 532 MapView mapView = MainApplication.getMap().mapView; 533 if (!mapView.isActiveLayerVisible()) 525 534 return; 526 535 … … 553 562 updateKeyModifiers(e); 554 563 // 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); 557 566 selectedSegment = null; 558 567 moveCommand = null; … … 560 569 dualAlignSegmentCollapsed = false; 561 570 updateStatusLine(); 562 Main.map.mapView.repaint();571 mapView.repaint(); 563 572 } 564 573 } … … 574 583 private static void addNewNode(MouseEvent e) { 575 584 // 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); 577 587 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())); 579 589 EastNorth a = ws.getFirstNode().getEastNorth(); 580 590 EastNorth b = ws.getSecondNode().getEastNorth(); … … 743 753 private EastNorth calculateBestMovement(EastNorth mouseEn) { 744 754 745 EastNorth initialMouseEn = Main .map.mapView.getEastNorth(initialMousePos.x, initialMousePos.y);755 EastNorth initialMouseEn = MainApplication.getMap().mapView.getEastNorth(initialMousePos.x, initialMousePos.y); 746 756 EastNorth mouseMovement = mouseEn.subtract(initialMouseEn); 747 757 … … 926 936 double distance = Main.getProjection().eastNorth2latlon(initialN1en).greatCircleDistance( 927 937 Main.getProjection().eastNorth2latlon(n1movedEn)); 928 Main .map.statusLine.setDist(distance);938 MainApplication.getMap().statusLine.setDist(distance); 929 939 updateStatusLine(); 930 940
Note:
See TracChangeset
for help on using the changeset viewer.