Changeset 12630 in josm for trunk/src/org/openstreetmap/josm/actions/mapmode
- Timestamp:
- 2017-08-24T00:15:51+02:00 (8 years ago)
- 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 13 13 import org.openstreetmap.josm.data.coor.LatLon; 14 14 import org.openstreetmap.josm.data.osm.NoteData; 15 import org.openstreetmap.josm.gui.MainApplication; 16 import org.openstreetmap.josm.gui.MapFrame; 15 17 import org.openstreetmap.josm.gui.NoteInputDialog; 16 18 import org.openstreetmap.josm.gui.Notification; … … 48 50 public void enterMode() { 49 51 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); 52 55 } 53 56 … … 55 58 public void exitMode() { 56 59 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); 59 63 } 60 64 … … 65 69 return; 66 70 } 67 Main.map.selectMapMode(Main.map.mapModeSelect); 71 MapFrame map = MainApplication.getMap(); 72 map.selectMapMode(map.mapModeSelect); 68 73 69 74 NoteInputDialog dialog = new NoteInputDialog(Main.parent, tr("Create new note"), tr("Create note")); … … 76 81 String input = dialog.getInputText(); 77 82 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); 79 84 noteData.createNote(latlon, input); 80 85 } else { … … 86 91 public void doKeyPressed(KeyEvent e) { 87 92 if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { 88 Main.map.selectMapMode(Main.map.mapModeSelect); 93 MapFrame map = MainApplication.getMap(); 94 map.selectMapMode(map.mapModeSelect); 89 95 } 90 96 } -
trunk/src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java
r12537 r12630 21 21 import org.openstreetmap.josm.data.osm.Relation; 22 22 import org.openstreetmap.josm.data.osm.WaySegment; 23 import org.openstreetmap.josm.gui.MainApplication; 24 import org.openstreetmap.josm.gui.MapFrame; 25 import org.openstreetmap.josm.gui.MapView; 23 26 import org.openstreetmap.josm.gui.dialogs.relation.RelationDialogManager; 24 27 import org.openstreetmap.josm.gui.layer.Layer; … … 110 113 drawTargetHighlight = Main.pref.getBoolean("draw.target-highlight", true); 111 114 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); 114 118 // This is required to update the cursors when ctrl/shift/alt is pressed 115 Main.map.keyDetector.addModifierExListener(this);119 map.keyDetector.addModifierExListener(this); 116 120 } 117 121 … … 119 123 public void exitMode() { 120 124 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); 124 129 removeHighlighting(); 125 130 } … … 245 250 */ 246 251 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) 250 256 return; 251 257 252 258 DeleteParameters parameters = getDeleteParameters(e, modifiers); 253 Main.map.mapView.setNewCursor(parameters.mode.cursor(), this);259 map.mapView.setNewCursor(parameters.mode.cursor(), this); 254 260 } 255 261 … … 288 294 if (e.getButton() != MouseEvent.BUTTON1) 289 295 return; 290 if (!Main.map.mapView.isActiveLayerVisible()) 296 MapFrame map = MainApplication.getMap(); 297 if (!map.mapView.isActiveLayerVisible()) 291 298 return; 292 299 293 300 // request focus in order to enable the expected keyboard shortcuts 294 301 // 295 Main.map.mapView.requestFocus();302 map.mapView.requestFocus(); 296 303 297 304 Command c = buildDeleteCommands(e, e.getModifiersEx(), false); … … 318 325 @Override 319 326 protected void updateEnabledState() { 320 setEnabled(Main.isDisplayingMapView() && Main .map.mapView.isActiveLayerDrawable());327 setEnabled(MainApplication.isDisplayingMapView() && MainApplication.getMap().mapView.isActiveLayerDrawable()); 321 328 } 322 329 … … 363 370 DeleteParameters result = new DeleteParameters(); 364 371 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); 366 374 if (result.nearestNode == null) { 367 result.nearestSegment = Main.map.mapView.getNearestWaySegment(e.getPoint(), OsmPrimitive::isSelectable);375 result.nearestSegment = mapView.getNearestWaySegment(e.getPoint(), OsmPrimitive::isSelectable); 368 376 if (result.nearestSegment != null) { 369 377 if (shift) { -
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r12517 r12630 54 54 import org.openstreetmap.josm.data.preferences.DoubleProperty; 55 55 import org.openstreetmap.josm.data.preferences.StrokeProperty; 56 import org.openstreetmap.josm.gui.MainApplication; 56 57 import org.openstreetmap.josm.gui.MainMenu; 58 import org.openstreetmap.josm.gui.MapFrame; 57 59 import org.openstreetmap.josm.gui.MapView; 58 60 import org.openstreetmap.josm.gui.MapViewState.MapViewPoint; … … 270 272 snapCheckboxMenuItem.getAction().setEnabled(true); 271 273 272 Main.map.statusLine.getAnglePanel().addMouseListener(snapHelper.anglePopupListener); 274 MapFrame map = MainApplication.getMap(); 275 map.statusLine.getAnglePanel().addMouseListener(snapHelper.anglePopupListener); 273 276 Main.registerActionShortcut(backspaceAction, backspaceShortcut); 274 277 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); 278 281 SelectionEventManager.getInstance().addSelectionListenerForEdt(this); 279 282 280 Main.map.keyDetector.addKeyListener(this);281 Main.map.keyDetector.addModifierExListener(this);283 map.keyDetector.addKeyListener(this); 284 map.keyDetector.addModifierExListener(this); 282 285 ignoreNextKeyRelease = true; 283 286 } … … 286 289 public void exitMode() { 287 290 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); 291 295 SelectionEventManager.getInstance().removeSelectionListener(this); 292 296 Main.unregisterActionShortcut(backspaceAction, backspaceShortcut); … … 294 298 snapCheckboxMenuItem.getAction().setEnabled(false); 295 299 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); 298 302 299 303 removeHighlighting(); 300 Main.map.keyDetector.removeKeyListener(this);301 Main.map.keyDetector.removeModifierExListener(this);304 map.keyDetector.removeKeyListener(this); 305 map.keyDetector.removeModifierExListener(this); 302 306 } 303 307 … … 307 311 @Override 308 312 public void modifiersExChanged(int modifiers) { 309 if (!Main.isDisplayingMapView() || !Main .map.mapView.isActiveLayerDrawable())313 if (!MainApplication.isDisplayingMapView() || !MainApplication.getMap().mapView.isActiveLayerDrawable()) 310 314 return; 311 315 updateKeyModifiersEx(modifiers); … … 341 345 @Override 342 346 public void selectionChanged(SelectionChangeEvent event) { 343 if (!Main .map.mapView.isActiveLayerDrawable())347 if (!MainApplication.getMap().mapView.isActiveLayerDrawable()) 344 348 return; 345 349 computeHelperLine(); … … 360 364 lastUsedNode = null; 361 365 wayIsFinished = true; 362 Main .map.selectSelectTool(true);366 MainApplication.getMap().selectSelectTool(true); 363 367 snapHelper.noSnapNow(); 364 368 … … 392 396 if (e.getButton() != MouseEvent.BUTTON1) 393 397 return; 394 if (!Main.map.mapView.isActiveLayerDrawable()) 398 MapView mapView = MainApplication.getMap().mapView; 399 if (!mapView.isActiveLayerDrawable()) 395 400 return; 396 401 // request focus in order to enable the expected keyboard shortcuts 397 402 // 398 Main.map.mapView.requestFocus();403 mapView.requestFocus(); 399 404 400 405 if (e.getClickCount() > 1 && mousePos != null && mousePos.equals(oldMousePos)) { … … 417 422 418 423 boolean newNode = false; 419 Node n = Main.map.mapView.getNearestNode(mousePos, OsmPrimitive::isSelectable);424 Node n = mapView.getNearestNode(mousePos, OsmPrimitive::isSelectable); 420 425 if (ctrl) { 421 426 Iterator<Way> it = ds.getSelectedWays().iterator(); … … 453 458 newEN = snapHelper.getSnapPoint(foundPoint); 454 459 // 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; 456 461 if (foundPoint.distance(newEN) > tolerance) { 457 462 n = new Node(newEN); // point != projected, so we create new node … … 459 464 } 460 465 } 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()); 462 467 newEN = snapHelper.isSnapOn() ? snapHelper.getSnapPoint(mouseEN) : mouseEN; 463 468 n = new Node(newEN); //create node at clicked point … … 486 491 if (!ctrl) { 487 492 // 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); 490 495 if (snapHelper.isActive()) { 491 496 tryToMoveNodeOnIntersection(wss, n); … … 622 627 // from aerial imagery or GPS tracks. 623 628 if (VIEWPORT_FOLLOWING.get()) { 624 Main.map.mapView.smoothScrollTo(n.getEastNorth());629 mapView.smoothScrollTo(n.getEastNorth()); 625 630 } 626 631 computeHelperLine(); … … 767 772 @Override 768 773 public void mouseMoved(MouseEvent e) { 769 if (!Main .map.mapView.isActiveLayerDrawable())774 if (!MainApplication.getMap().mapView.isActiveLayerDrawable()) 770 775 return; 771 776 … … 787 792 private void tryToSetBaseSegmentForAngleSnap() { 788 793 if (mousePos != null) { 789 WaySegment seg = Main .map.mapView.getNearestWaySegment(mousePos, OsmPrimitive::isSelectable);794 WaySegment seg = MainApplication.getMap().mapView.getNearestWaySegment(mousePos, OsmPrimitive::isSelectable); 790 795 if (seg != null) { 791 796 snapHelper.setBaseSegment(seg); … … 809 814 Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected(); 810 815 811 MapView mv = Main .map.mapView;816 MapView mv = MainApplication.getMap().mapView; 812 817 Node currentMouseNode = null; 813 818 mouseOnExistingNode = null; … … 864 869 865 870 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); 870 876 } 871 877 … … 1060 1066 // fall through to default action. 1061 1067 // (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()) { 1063 1070 n.setEastNorth(intersection); 1064 1071 return; … … 1113 1120 private void addHighlighting() { 1114 1121 newHighlights = new HashSet<>(); 1122 MapView mapView = MainApplication.getMap().mapView; 1115 1123 1116 1124 // if ctrl key is held ("no join"), don't highlight anything 1117 1125 if (ctrl) { 1118 Main.map.mapView.setNewCursor(cursor, this);1126 mapView.setNewCursor(cursor, this); 1119 1127 redrawIfRequired(); 1120 1128 return; … … 1123 1131 // This happens when nothing is selected, but we still want to highlight the "target node" 1124 1132 if (mouseOnExistingNode == null && mousePos != null && getLayerManager().getEditDataSet().selectionEmpty()) { 1125 mouseOnExistingNode = Main.map.mapView.getNearestNode(mousePos, OsmPrimitive::isSelectable);1133 mouseOnExistingNode = mapView.getNearestNode(mousePos, OsmPrimitive::isSelectable); 1126 1134 } 1127 1135 1128 1136 if (mouseOnExistingNode != null) { 1129 Main.map.mapView.setNewCursor(cursorJoinNode, this);1137 mapView.setNewCursor(cursorJoinNode, this); 1130 1138 newHighlights.add(mouseOnExistingNode); 1131 1139 redrawIfRequired(); … … 1135 1143 // Insert the node into all the nearby way segments 1136 1144 if (mouseOnExistingWays.isEmpty()) { 1137 Main.map.mapView.setNewCursor(cursor, this);1145 mapView.setNewCursor(cursor, this); 1138 1146 redrawIfRequired(); 1139 1147 return; 1140 1148 } 1141 1149 1142 Main.map.mapView.setNewCursor(cursorJoinWay, this);1150 mapView.setNewCursor(cursorJoinWay, this); 1143 1151 newHighlights.addAll(mouseOnExistingWays); 1144 1152 redrawIfRequired(); … … 1157 1165 public void paint(Graphics2D g, MapView mv, Bounds box) { 1158 1166 // sanity checks 1159 if (Main.map.mapView == null || mousePos == null 1167 MapView mapView = MainApplication.getMap().mapView; 1168 if (mapView == null || mousePos == null 1160 1169 // don't draw line if we don't know where from or where to 1161 1170 || currentMouseEastNorth == null || getCurrentBaseNode() == null 1162 1171 // 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()) 1164 1173 return; 1165 1174 … … 1368 1377 @Override 1369 1378 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); 1371 1381 } 1372 1382 } -
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawSnapHelper.java
r12620 r12630 25 25 import org.openstreetmap.josm.data.osm.Way; 26 26 import org.openstreetmap.josm.data.osm.WaySegment; 27 import org.openstreetmap.josm.gui.MainApplication; 28 import org.openstreetmap.josm.gui.MapView; 27 29 import org.openstreetmap.josm.gui.MapViewState; 28 30 import org.openstreetmap.josm.gui.MapViewState.MapViewPoint; … … 335 337 */ 336 338 public void checkAngleSnapping(EastNorth currentEN, double baseHeading, double curHeading) { 339 MapView mapView = MainApplication.getMap().mapView; 337 340 EastNorth p0 = drawAction.getCurrentBaseNode().getEastNorth(); 338 341 EastNorth snapPoint = currentEN; … … 375 378 pe = Math.sin(phi); 376 379 pn = Math.cos(phi); 377 double scale = 20 * Main.map.mapView.getDist100Pixel();380 double scale = 20 * mapView.getDist100Pixel(); 378 381 dir2 = new EastNorth(e0 + scale * pe, n0 + scale * pn); 379 382 snapPoint = getSnapPoint(currentEN); … … 384 387 385 388 // 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); 387 390 double distance = this.drawAction.getCurrentBaseNode().getCoor().greatCircleDistance(mouseLatLon); 388 391 double hdg = Utils.toDegrees(p0.heading(snapPoint)); … … 436 439 double dn = p.north()-n0; 437 440 double l = de*pe+dn*pn; 438 double delta = Main .map.mapView.getDist100Pixel()/20;441 double delta = MainApplication.getMap().mapView.getDist100Pixel()/20; 439 442 if (!absoluteFix && l < delta) { 440 443 active = false; -
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 -
trunk/src/org/openstreetmap/josm/actions/mapmode/ImproveWayAccuracyAction.java
r12581 r12630 40 40 import org.openstreetmap.josm.data.preferences.IntegerProperty; 41 41 import org.openstreetmap.josm.data.preferences.StrokeProperty; 42 import org.openstreetmap.josm.gui.MainApplication; 43 import org.openstreetmap.josm.gui.MapFrame; 42 44 import org.openstreetmap.josm.gui.MapView; 43 45 import org.openstreetmap.josm.gui.draw.MapViewPath; … … 138 140 readPreferences(); 139 141 140 mv = Main.map.mapView; 142 MapFrame map = MainApplication.getMap(); 143 mv = map.mapView; 141 144 mousePos = null; 142 145 oldModeHelpText = ""; … … 148 151 updateStateByCurrentSelection(); 149 152 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); 153 156 DataSet.addSelectionListener(this); 154 157 155 Main.map.keyDetector.addModifierExListener(this);158 map.keyDetector.addModifierExListener(this); 156 159 } 157 160 … … 165 168 super.exitMode(); 166 169 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); 170 174 DataSet.removeSelectionListener(this); 171 175 172 Main.map.keyDetector.removeModifierExListener(this);176 map.keyDetector.removeModifierExListener(this); 173 177 temporaryLayer.invalidate(); 174 178 } … … 179 183 if (!newModeHelpText.equals(oldModeHelpText)) { 180 184 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(); 183 188 } 184 189 } … … 348 353 @Override 349 354 public void modifiersExChanged(int modifiers) { 350 if (!Main.isDisplayingMapView() || !Main .map.mapView.isActiveLayerDrawable()) {355 if (!MainApplication.isDisplayingMapView() || !MainApplication.getMap().mapView.isActiveLayerDrawable()) { 351 356 return; 352 357 } -
trunk/src/org/openstreetmap/josm/actions/mapmode/ImproveWayAccuracyHelper.java
r10716 r12630 6 6 import java.util.List; 7 7 8 import org.openstreetmap.josm.Main;9 8 import org.openstreetmap.josm.data.coor.EastNorth; 10 9 import org.openstreetmap.josm.data.osm.Node; … … 12 11 import org.openstreetmap.josm.data.osm.Way; 13 12 import org.openstreetmap.josm.data.osm.WaySegment; 13 import org.openstreetmap.josm.gui.MainApplication; 14 14 import org.openstreetmap.josm.gui.MapView; 15 15 import org.openstreetmap.josm.tools.Geometry; … … 57 57 } 58 58 59 return Main .map.mapView.getNearestWay(p, OsmPrimitive::isSelectable);59 return MainApplication.getMap().mapView.getNearestWay(p, OsmPrimitive::isSelectable); 60 60 } 61 61 -
trunk/src/org/openstreetmap/josm/actions/mapmode/MapMode.java
r12526 r12630 16 16 import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener; 17 17 import org.openstreetmap.josm.data.osm.OsmPrimitive; 18 import org.openstreetmap.josm.gui.MainApplication; 18 19 import org.openstreetmap.josm.gui.MapFrame; 19 20 import org.openstreetmap.josm.gui.layer.Layer; … … 99 100 Main.pref.addPreferenceChangeListener(this); 100 101 readPreferences(); 101 Main .map.mapView.setNewCursor(cursor, this);102 MainApplication.getMap().mapView.setNewCursor(cursor, this); 102 103 updateStatusLine(); 103 104 } … … 109 110 putValue("active", Boolean.FALSE); 110 111 Main.pref.removePreferenceChangeListener(this); 111 Main .map.mapView.resetCursor(this);112 MainApplication.getMap().mapView.resetCursor(this); 112 113 } 113 114 114 115 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(); 118 120 } 119 121 } … … 134 136 @Override 135 137 public void actionPerformed(ActionEvent e) { 136 if (Main.isDisplayingMapView()) { 137 Main .map.selectMapMode(this);138 if (MainApplication.isDisplayingMapView()) { 139 MainApplication.getMap().selectMapMode(this); 138 140 } 139 141 } … … 225 227 if (isEnabled()) { 226 228 // request focus in order to enable the expected keyboard shortcuts (see #8710) 227 Main .map.mapView.requestFocus();229 MainApplication.getMap().mapView.requestFocus(); 228 230 } 229 231 } -
trunk/src/org/openstreetmap/josm/actions/mapmode/ParallelWayAction.java
r12620 r12630 25 25 import javax.swing.JOptionPane; 26 26 27 import org.openstreetmap.josm.Main;28 27 import org.openstreetmap.josm.data.Bounds; 29 28 import org.openstreetmap.josm.data.SystemOfMeasurement; … … 40 39 import org.openstreetmap.josm.data.preferences.IntegerProperty; 41 40 import org.openstreetmap.josm.data.preferences.StrokeProperty; 41 import org.openstreetmap.josm.gui.MainApplication; 42 42 import org.openstreetmap.josm.gui.MapFrame; 43 43 import org.openstreetmap.josm.gui.MapView; … … 172 172 mv.addTemporaryLayer(temporaryLayer); 173 173 174 // //Needed to update the mouse cursor if modifiers are changed when the mouse is motionless175 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); 176 176 sourceWays = new LinkedHashSet<>(getLayerManager().getEditDataSet().getSelectedWays()); 177 177 for (Way w : sourceWays) { … … 186 186 mv.removeMouseMotionListener(this); 187 187 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); 191 192 removeWayHighlighting(sourceWays); 192 193 pWays = null; … … 217 218 @Override 218 219 public void modifiersExChanged(int modifiers) { 219 if (Main .map== null || mv == null || !mv.isActiveLayerDrawable())220 if (MainApplication.getMap() == null || mv == null || !mv.isActiveLayerDrawable()) 220 221 return; 221 222 … … 431 432 pWays.changeOffset(d); 432 433 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(); 435 437 temporaryLayer.invalidate(); 436 438 } -
trunk/src/org/openstreetmap/josm/actions/mapmode/PlayHeadDragMode.java
r11713 r12630 8 8 import java.awt.event.MouseEvent; 9 9 10 import org.openstreetmap.josm.Main;11 10 import org.openstreetmap.josm.data.coor.EastNorth; 11 import org.openstreetmap.josm.gui.MainApplication; 12 import org.openstreetmap.josm.gui.MapFrame; 12 13 import org.openstreetmap.josm.gui.layer.markerlayer.PlayHeadMarker; 13 14 import org.openstreetmap.josm.tools.Shortcut; … … 38 39 @Override public void enterMode() { 39 40 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); 42 44 } 43 45 44 46 @Override public void exitMode() { 45 47 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); 48 51 } 49 52 … … 62 65 } 63 66 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())); 65 68 mousePos = p; 66 69 } … … 74 77 updateKeyModifiers(ev); 75 78 76 EastNorth en = Main .map.mapView.getEastNorth(ev.getX(), ev.getY());79 EastNorth en = MainApplication.getMap().mapView.getEastNorth(ev.getX(), ev.getY()); 77 80 if (!shift) { 78 81 playHeadMarker.reposition(en); -
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r12620 r12630 40 40 import org.openstreetmap.josm.data.osm.visitor.paint.WireframeMapRenderer; 41 41 import org.openstreetmap.josm.gui.ExtendedDialog; 42 import org.openstreetmap.josm.gui.MainApplication; 42 43 import org.openstreetmap.josm.gui.MapFrame; 43 44 import org.openstreetmap.josm.gui.MapView; … … 209 210 virtualManager.init(); 210 211 // 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); 213 215 } 214 216 … … 220 222 mv.removeMouseMotionListener(this); 221 223 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); 224 227 removeHighlighting(); 225 228 } … … 227 230 @Override 228 231 public void modifiersExChanged(int modifiers) { 229 if (!Main.isDisplayingMapView() || oldEvent == null) return; 232 if (!MainApplication.isDisplayingMapView() || oldEvent == null) return; 230 233 if (giveUserFeedback(oldEvent, modifiers)) { 231 234 mv.repaint(); … … 568 571 startingDraggingPos = null; 569 572 mouseReleaseTime = System.currentTimeMillis(); 573 MapFrame map = MainApplication.getMap(); 570 574 571 575 if (mode == Mode.SELECT) { … … 578 582 // Select Draw Tool if no selection has been made 579 583 if (!cancelDrawMode && getLayerManager().getEditDataSet().selectionEmpty()) { 580 Main.map.selectDrawTool(true);584 map.selectDrawTool(true); 581 585 updateStatusLine(); 582 586 return; … … 599 603 // We need to do it like this as otherwise drawAction will see a double 600 604 // click and switch back to SelectMode 601 Main.worker.execute(() -> Main.map.selectDrawTool(true));605 Main.worker.execute(() -> map.selectDrawTool(true)); 602 606 return; 603 607 } … … 630 634 @Override 631 635 public void doKeyPressed(KeyEvent e) { 632 if (!repeatedKeySwitchLassoOption || !Main.isDisplayingMapView() || !getShortcut().isEvent(e)) 636 if (!repeatedKeySwitchLassoOption || !MainApplication.isDisplayingMapView() || !getShortcut().isEvent(e)) 633 637 return; 634 638 if (Logging.isDebugEnabled()) { … … 636 640 } 637 641 e.consume(); 642 MapFrame map = MainApplication.getMap(); 638 643 if (!lassoMode) { 639 Main.map.selectMapMode(Main.map.mapModeSelectLasso);644 map.selectMapMode(map.mapModeSelectLasso); 640 645 } else { 641 Main.map.selectMapMode(Main.map.mapModeSelect);646 map.selectMapMode(map.mapModeSelect); 642 647 } 643 648 } … … 751 756 Collection<Way> ways = ds.getSelectedWays(); 752 757 if (doesImpactStatusLine(affectedNodes, ways)) { 753 Main .map.statusLine.setDist(ways);758 MainApplication.getMap().statusLine.setDist(ways); 754 759 } 755 760 } finally { -
trunk/src/org/openstreetmap/josm/actions/mapmode/ZoomAction.java
r11713 r12630 8 8 import java.awt.event.MouseEvent; 9 9 10 import org.openstreetmap.josm. Main;10 import org.openstreetmap.josm.gui.MainApplication; 11 11 import org.openstreetmap.josm.gui.MapFrame; 12 12 import org.openstreetmap.josm.gui.MapView; … … 53 53 @Override 54 54 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; 57 57 mv.zoomToFactor(mv.getEastNorth(r.x+r.width/2, r.y+r.height/2), r.getWidth()/mv.getWidth()); 58 58 } … … 61 61 @Override public void enterMode() { 62 62 super.enterMode(); 63 selectionManager.register(Main .map.mapView, false);63 selectionManager.register(MainApplication.getMap().mapView, false); 64 64 } 65 65 66 66 @Override public void exitMode() { 67 67 super.exitMode(); 68 selectionManager.unregister(Main .map.mapView);68 selectionManager.unregister(MainApplication.getMap().mapView); 69 69 } 70 70
Note:
See TracChangeset
for help on using the changeset viewer.