Changeset 12630 in josm
- Timestamp:
- 2017-08-24T00:15:51+02:00 (7 years ago)
- Location:
- trunk
- Files:
-
- 157 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r12629 r12630 60 60 import org.openstreetmap.josm.data.projection.Projection; 61 61 import org.openstreetmap.josm.data.projection.ProjectionChangeListener; 62 import org.openstreetmap.josm.gui.MainApplication; 62 63 import org.openstreetmap.josm.gui.MainMenu; 63 64 import org.openstreetmap.josm.gui.MainPanel; … … 119 120 * 120 121 * @return <code>true</code> if JOSM currently displays a map view 121 */ 122 * @deprecated use {@link org.openstreetmap.josm.gui.MainApplication#isDisplayingMapView()} 123 */ 124 @Deprecated 122 125 public static boolean isDisplayingMapView() { 123 126 return map != null && map.mapView != null; … … 151 154 * There should be no need to access this to access any map data. Use {@link #layerManager} instead. 152 155 * 156 * @deprecated Use {@link org.openstreetmap.josm.gui.MainApplication#getMap()} instead 153 157 * @see MainPanel 154 158 */ 159 @Deprecated 155 160 public static MapFrame map; 156 161 … … 1135 1140 } 1136 1141 if (newValue != null && oldBounds != null) { 1137 Main .map.mapView.zoomTo(oldBounds);1142 MainApplication.getMap().mapView.zoomTo(oldBounds); 1138 1143 } 1139 1144 /* TODO - remove layers with fixed projection */ -
trunk/src/org/openstreetmap/josm/actions/AbstractInfoAction.java
r12620 r12630 19 19 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 20 20 import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec; 21 import org.openstreetmap.josm.gui.MainApplication; 21 22 import org.openstreetmap.josm.gui.help.HelpUtil; 22 23 import org.openstreetmap.josm.tools.ImageProvider; … … 105 106 } 106 107 107 Note noteToShow = Main .isDisplayingMapView() ? Main.map.noteDialog.getSelectedNote() : null;108 Note noteToShow = MainApplication.isDisplayingMapView() ? MainApplication.getMap().noteDialog.getSelectedNote() : null; 108 109 109 110 // filter out new primitives which are not yet uploaded to the server -
trunk/src/org/openstreetmap/josm/actions/AbstractPasteAction.java
r12560 r12630 11 11 import org.openstreetmap.josm.Main; 12 12 import org.openstreetmap.josm.data.coor.EastNorth; 13 import org.openstreetmap.josm.gui.MainApplication; 14 import org.openstreetmap.josm.gui.MapView; 13 15 import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils; 14 16 import org.openstreetmap.josm.gui.datatransfer.OsmTransferHandler; … … 68 70 protected EastNorth computePastePosition(ActionEvent e) { 69 71 // default to paste in center of map (pasted via menu or cursor not in MapView) 70 EastNorth mPosition = Main.map.mapView.getCenter(); 72 MapView mapView = MainApplication.getMap().mapView; 73 EastNorth mPosition = mapView.getCenter(); 71 74 // We previously checked for modifier to know if the action has been trigerred via shortcut or via menu 72 75 // But this does not work if the shortcut is changed to a single key (see #9055) … … 74 77 if (e != null && !getValue(NAME).equals(e.getActionCommand())) { 75 78 final Point mp = MouseInfo.getPointerInfo().getLocation(); 76 final Point tl = Main.map.mapView.getLocationOnScreen();79 final Point tl = mapView.getLocationOnScreen(); 77 80 final Point pos = new Point(mp.x-tl.x, mp.y-tl.y); 78 if ( Main.map.mapView.contains(pos)) {79 mPosition = Main.map.mapView.getEastNorth(pos.x, pos.y);81 if (mapView.contains(pos)) { 82 mPosition = mapView.getEastNorth(pos.x, pos.y); 80 83 } 81 84 } -
trunk/src/org/openstreetmap/josm/actions/AddNodeAction.java
r12104 r12630 14 14 import org.openstreetmap.josm.data.osm.Node; 15 15 import org.openstreetmap.josm.data.osm.OsmPrimitive; 16 import org.openstreetmap.josm.gui.MainApplication; 17 import org.openstreetmap.josm.gui.MapView; 16 18 import org.openstreetmap.josm.gui.dialogs.LatLonDialog; 17 19 import org.openstreetmap.josm.tools.Shortcut; … … 66 68 Main.main.undoRedo.add(new AddCommand(nnew)); 67 69 getLayerManager().getEditDataSet().setSelected(nnew); 68 if (Main.map.mapView != null && !Main.map.mapView.getRealBounds().contains(nnew.getCoor())) { 70 MapView mapView = MainApplication.getMap().mapView; 71 if (mapView != null && !mapView.getRealBounds().contains(nnew.getCoor())) { 69 72 AutoScaleAction.zoomTo(Collections.<OsmPrimitive>singleton(nnew)); 70 73 } -
trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java
r12620 r12630 29 29 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 30 30 import org.openstreetmap.josm.data.validation.TestError; 31 import org.openstreetmap.josm.gui.MainApplication; 31 32 import org.openstreetmap.josm.gui.MapFrame; 32 33 import org.openstreetmap.josm.gui.MapFrameListener; 33 34 import org.openstreetmap.josm.gui.MapView; 35 import org.openstreetmap.josm.gui.dialogs.ConflictDialog; 34 36 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 35 37 import org.openstreetmap.josm.gui.dialogs.ValidatorDialog.ValidatorBoundingXYVisitor; … … 102 104 bboxCalculator.enlargeBoundingBox(); 103 105 if (bboxCalculator.getBounds() != null) { 104 Main .map.mapView.zoomTo(bboxCalculator);106 MainApplication.getMap().mapView.zoomTo(bboxCalculator); 105 107 } 106 108 } … … 191 193 */ 192 194 public void autoScale() { 193 if (Main.isDisplayingMapView()) { 195 if (MainApplication.isDisplayingMapView()) { 196 MapView mapView = MainApplication.getMap().mapView; 194 197 switch (mode) { 195 198 case "previous": 196 Main.map.mapView.zoomPrevious();199 mapView.zoomPrevious(); 197 200 break; 198 201 case "next": 199 Main.map.mapView.zoomNext();202 mapView.zoomNext(); 200 203 break; 201 204 default: 202 205 BoundingXYVisitor bbox = getBoundingBox(); 203 206 if (bbox != null && bbox.getBounds() != null) { 204 Main.map.mapView.zoomTo(bbox);207 mapView.zoomTo(bbox); 205 208 } 206 209 } … … 254 257 255 258 private static BoundingXYVisitor modeProblem(ValidatorBoundingXYVisitor v) { 256 TestError error = Main .map.validatorDialog.getSelectedError();259 TestError error = MainApplication.getMap().validatorDialog.getSelectedError(); 257 260 if (error == null) 258 261 return null; … … 288 291 } 289 292 } else { 290 Conflict<? extends OsmPrimitive> c = Main.map.conflictDialog.getSelectedConflict(); 293 ConflictDialog conflictDialog = MainApplication.getMap().conflictDialog; 294 Conflict<? extends OsmPrimitive> c = conflictDialog.getSelectedConflict(); 291 295 if (c != null) { 292 296 sel.add(c.getMy()); 293 } else if ( Main.map.conflictDialog.getConflicts() != null) {294 sel = Main.map.conflictDialog.getConflicts().getMyConflictParties();297 } else if (conflictDialog.getConflicts() != null) { 298 sel = conflictDialog.getConflicts().getMyConflictParties(); 295 299 } 296 300 } … … 350 354 protected void updateEnabledState() { 351 355 DataSet ds = getLayerManager().getEditDataSet(); 356 MapFrame map = MainApplication.getMap(); 352 357 switch (mode) { 353 358 case "selection": … … 358 363 break; 359 364 case "conflict": 360 setEnabled( Main.map != null && Main.map.conflictDialog.getSelectedConflict() != null);365 setEnabled(map != null && map.conflictDialog.getSelectedConflict() != null); 361 366 break; 362 367 case "download": … … 364 369 break; 365 370 case "problem": 366 setEnabled( Main.map != null && Main.map.validatorDialog.getSelectedError() != null);371 setEnabled(map != null && map.validatorDialog.getSelectedError() != null); 367 372 break; 368 373 case "previous": 369 setEnabled(Main .isDisplayingMapView() && Main.map.mapView.hasZoomUndoEntries());374 setEnabled(MainApplication.isDisplayingMapView() && map.mapView.hasZoomUndoEntries()); 370 375 break; 371 376 case "next": 372 setEnabled(Main .isDisplayingMapView() && Main.map.mapView.hasZoomRedoEntries());377 setEnabled(MainApplication.isDisplayingMapView() && map.mapView.hasZoomRedoEntries()); 373 378 break; 374 379 default: -
trunk/src/org/openstreetmap/josm/actions/CreateMultipolygonAction.java
r12188 r12630 36 36 import org.openstreetmap.josm.data.osm.RelationMember; 37 37 import org.openstreetmap.josm.data.osm.Way; 38 import org.openstreetmap.josm.gui.MainApplication; 38 39 import org.openstreetmap.josm.gui.Notification; 39 40 import org.openstreetmap.josm.gui.dialogs.relation.DownloadRelationMemberTask; … … 113 114 // uses 'SwingUtilities.invokeLater' to fire events so we have to do the same.) 114 115 SwingUtilities.invokeLater(() -> { 115 Main .map.relationListDialog.selectRelation(relation);116 MainApplication.getMap().relationListDialog.selectRelation(relation); 116 117 if (Main.pref.getBoolean("multipoly.show-relation-editor", false)) { 117 118 //Open relation edit window, if set up in preferences -
trunk/src/org/openstreetmap/josm/actions/DeleteAction.java
r12504 r12630 9 9 import java.util.Collection; 10 10 11 import org.openstreetmap.josm.Main;12 11 import org.openstreetmap.josm.data.osm.OsmPrimitive; 12 import org.openstreetmap.josm.gui.MainApplication; 13 import org.openstreetmap.josm.gui.MapFrame; 13 14 import org.openstreetmap.josm.tools.Shortcut; 14 15 … … 30 31 @Override 31 32 public void actionPerformed(ActionEvent e) { 32 if (!isEnabled() || !Main.map.mapView.isActiveLayerVisible()) 33 MapFrame map = MainApplication.getMap(); 34 if (!isEnabled() || !map.mapView.isActiveLayerVisible()) 33 35 return; 34 Main.map.mapModeDelete.doActionPerformed(e);36 map.mapModeDelete.doActionPerformed(e); 35 37 } 36 38 -
trunk/src/org/openstreetmap/josm/actions/DialogsToggleAction.java
r12132 r12630 9 9 10 10 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.gui.MainApplication; 12 import org.openstreetmap.josm.gui.MapFrame; 11 13 import org.openstreetmap.josm.tools.ImageProvider; 12 14 import org.openstreetmap.josm.tools.Shortcut; … … 47 49 48 50 protected void setMode() { 49 if (Main .isDisplayingMapView()) {51 if (MainApplication.isDisplayingMapView()) { 50 52 boolean selected = isSelected(); 51 53 if (!selected) { … … 53 55 sideToolbarPreviouslyVisible = Main.pref.getBoolean("sidetoolbar.visible", true); 54 56 } 55 Main.map.setDialogsPanelVisible(selected); 56 Main.map.statusLine.setVisible(selected || Main.pref.getBoolean("statusbar.always-visible", true)); 57 MapFrame map = MainApplication.getMap(); 58 map.setDialogsPanelVisible(selected); 59 map.statusLine.setVisible(selected || Main.pref.getBoolean("statusbar.always-visible", true)); 57 60 Main.main.menu.setVisible(selected || Main.pref.getBoolean("menu.always-visible", true)); 58 61 // Toolbars listen to preference changes, use it here … … 63 66 Main.pref.put("sidetoolbar.visible", selected); 64 67 } 65 Main.map.mapView.rememberLastPositionOnScreen();68 map.mapView.rememberLastPositionOnScreen(); 66 69 } 67 70 } -
trunk/src/org/openstreetmap/josm/actions/DownloadAction.java
r12620 r12630 24 24 import org.openstreetmap.josm.data.ProjectionBounds; 25 25 import org.openstreetmap.josm.data.ViewportData; 26 import org.openstreetmap.josm.gui.MainApplication; 27 import org.openstreetmap.josm.gui.MapFrame; 26 28 import org.openstreetmap.josm.gui.download.DownloadDialog; 27 29 import org.openstreetmap.josm.gui.util.GuiHelper; … … 125 127 } 126 128 // Zoom to the larger download bounds 127 if (Main.map != null && bounds != null) { 129 MapFrame map = MainApplication.getMap(); 130 if (map != null && bounds != null) { 128 131 final ProjectionBounds pb = bounds; 129 GuiHelper.runInEDTAndWait(() -> Main.map.mapView.zoomTo(new ViewportData(pb)));132 GuiHelper.runInEDTAndWait(() -> map.mapView.zoomTo(new ViewportData(pb))); 130 133 } 131 134 }); -
trunk/src/org/openstreetmap/josm/actions/DownloadNotesInViewAction.java
r11743 r12630 11 11 import org.openstreetmap.josm.actions.downloadtasks.PostDownloadHandler; 12 12 import org.openstreetmap.josm.data.Bounds; 13 import org.openstreetmap.josm.gui.MainApplication; 13 14 import org.openstreetmap.josm.io.OnlineResource; 14 15 … … 43 44 @Override 44 45 public void actionPerformed(ActionEvent e) { 45 final Bounds bounds = Main .map.mapView.getRealBounds();46 final Bounds bounds = MainApplication.getMap().mapView.getRealBounds(); 46 47 DownloadNotesTask task = new DownloadNotesTask(); 47 48 task.setZoomAfterDownload(false); -
trunk/src/org/openstreetmap/josm/actions/DownloadOsmInViewAction.java
r11743 r12630 11 11 import org.openstreetmap.josm.actions.downloadtasks.PostDownloadHandler; 12 12 import org.openstreetmap.josm.data.Bounds; 13 import org.openstreetmap.josm.gui.MainApplication; 13 14 import org.openstreetmap.josm.io.BoundingBoxDownloader; 14 15 import org.openstreetmap.josm.io.OnlineResource; … … 31 32 @Override 32 33 public void actionPerformed(ActionEvent e) { 33 final Bounds bounds = Main .map.mapView.getRealBounds();34 final Bounds bounds = MainApplication.getMap().mapView.getRealBounds(); 34 35 DownloadOsmInViewTask task = new DownloadOsmInViewTask(); 35 36 task.setZoomAfterDownload(false); -
trunk/src/org/openstreetmap/josm/actions/FollowLineAction.java
r12351 r12630 19 19 import org.openstreetmap.josm.data.osm.OsmPrimitive; 20 20 import org.openstreetmap.josm.data.osm.Way; 21 import org.openstreetmap.josm.gui.MainApplication; 22 import org.openstreetmap.josm.gui.MapFrame; 21 23 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 22 24 import org.openstreetmap.josm.tools.Shortcut; … … 63 65 if (osmLayer == null) 64 66 return; 65 if (!(Main.map.mapMode instanceof DrawAction)) return; // We are not on draw mode 67 MapFrame map = MainApplication.getMap(); 68 if (!(map.mapMode instanceof DrawAction)) return; // We are not on draw mode 66 69 67 70 Collection<Node> selectedPoints = osmLayer.data.getSelectedNodes(); … … 70 73 return; 71 74 72 Node last = ((DrawAction) Main.map.mapMode).getCurrentBaseNode();75 Node last = ((DrawAction) map.mapMode).getCurrentBaseNode(); 73 76 if (last == null) 74 77 return; … … 122 125 // from aerial imagery or GPS tracks. 123 126 if (DrawAction.VIEWPORT_FOLLOWING.get()) { 124 Main.map.mapView.smoothScrollTo(newPoint.getEastNorth());127 map.mapView.smoothScrollTo(newPoint.getEastNorth()); 125 128 } 126 129 } -
trunk/src/org/openstreetmap/josm/actions/ImageryAdjustAction.java
r12620 r12630 29 29 import org.openstreetmap.josm.data.imagery.OffsetBookmark; 30 30 import org.openstreetmap.josm.gui.ExtendedDialog; 31 import org.openstreetmap.josm.gui.MainApplication; 32 import org.openstreetmap.josm.gui.MapFrame; 33 import org.openstreetmap.josm.gui.MapView; 31 34 import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer; 32 35 import org.openstreetmap.josm.gui.layer.imagery.TileSourceDisplaySettings; … … 72 75 EastNorth curOff = old == null ? EastNorth.ZERO : old.getDisplacement(Main.getProjection()); 73 76 LatLon center; 74 if (Main .isDisplayingMapView()) {75 center = Main.getProjection().eastNorth2latlon(Main .map.mapView.getCenter());77 if (MainApplication.isDisplayingMapView()) { 78 center = Main.getProjection().eastNorth2latlon(MainApplication.getMap().mapView.getCenter()); 76 79 } else { 77 80 center = LatLon.ZERO; … … 98 101 99 102 protected void addListeners() { 100 Main.map.mapView.addMouseListener(this); 101 Main.map.mapView.addMouseMotionListener(this); 103 MapView mapView = MainApplication.getMap().mapView; 104 mapView.addMouseListener(this); 105 mapView.addMouseMotionListener(this); 102 106 try { 103 107 Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.KEY_EVENT_MASK); … … 126 130 Logging.error(ex); 127 131 } 128 if (Main.isDisplayingMapView()) { 129 Main.map.mapView.removeMouseMotionListener(this); 130 Main.map.mapView.removeMouseListener(this); 132 if (MainApplication.isDisplayingMapView()) { 133 MapFrame map = MainApplication.getMap(); 134 map.mapView.removeMouseMotionListener(this); 135 map.mapView.removeMouseListener(this); 131 136 } 132 137 } … … 172 177 if (layer.isVisible()) { 173 178 requestFocusInMapView(); 174 prevEastNorth = Main.map.mapView.getEastNorth(e.getX(), e.getY()); 175 Main.map.mapView.setNewCursor(Cursor.MOVE_CURSOR, this); 179 MapView mapView = MainApplication.getMap().mapView; 180 prevEastNorth = mapView.getEastNorth(e.getX(), e.getY()); 181 mapView.setNewCursor(Cursor.MOVE_CURSOR, this); 176 182 } 177 183 } … … 180 186 public void mouseDragged(MouseEvent e) { 181 187 if (layer == null || prevEastNorth == null) return; 182 EastNorth eastNorth = Main .map.mapView.getEastNorth(e.getX(), e.getY());188 EastNorth eastNorth = MainApplication.getMap().mapView.getEastNorth(e.getX(), e.getY()); 183 189 EastNorth d = tempOffset.getDisplacement().add(eastNorth).subtract(prevEastNorth); 184 190 tempOffset.setDisplacement(d); … … 192 198 @Override 193 199 public void mouseReleased(MouseEvent e) { 194 Main.map.mapView.repaint(); 195 Main.map.mapView.resetCursor(this); 200 MapView mapView = MainApplication.getMap().mapView; 201 mapView.repaint(); 202 mapView.resetCursor(this); 196 203 prevEastNorth = null; 197 204 } … … 199 206 @Override 200 207 public void actionPerformed(ActionEvent e) { 201 if (offsetDialog != null || layer == null || Main.map == null) 208 MapFrame map = MainApplication.getMap(); 209 if (offsetDialog != null || layer == null || map == null) 202 210 return; 203 oldMapMode = Main.map.mapMode;211 oldMapMode = map.mapMode; 204 212 super.actionPerformed(e); 205 213 } … … 266 274 } 267 275 updateOffsetIntl(); 268 if (Main .isDisplayingMapView()) {269 Main .map.repaint();276 if (MainApplication.isDisplayingMapView()) { 277 MainApplication.getMap().repaint(); 270 278 } 271 279 } … … 334 342 335 343 private void restoreMapModeState() { 336 if (Main.map == null) 344 MapFrame map = MainApplication.getMap(); 345 if (map == null) 337 346 return; 338 347 if (oldMapMode != null) { 339 Main.map.selectMapMode(oldMapMode);348 map.selectMapMode(oldMapMode); 340 349 oldMapMode = null; 341 350 } else { 342 Main.map.selectSelectTool(false);351 map.selectSelectTool(false); 343 352 } 344 353 } -
trunk/src/org/openstreetmap/josm/actions/InfoWebAction.java
r9136 r12630 12 12 import org.openstreetmap.josm.data.osm.OsmPrimitive; 13 13 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 14 import org.openstreetmap.josm.gui.MainApplication; 14 15 import org.openstreetmap.josm.tools.Shortcut; 15 16 … … 59 60 private void updateEnabledStateWithNotes() { 60 61 // Allows enabling if a note is selected, even if no OSM object is selected 61 if (!isEnabled() && Main .isDisplayingMapView() && Main.map.noteDialog.getSelectedNote() != null) {62 if (!isEnabled() && MainApplication.isDisplayingMapView() && MainApplication.getMap().noteDialog.getSelectedNote() != null) { 62 63 setEnabled(true); 63 64 } -
trunk/src/org/openstreetmap/josm/actions/JoinNodeWayAction.java
r10716 r12630 30 30 import org.openstreetmap.josm.data.osm.WaySegment; 31 31 import org.openstreetmap.josm.data.projection.Projections; 32 import org.openstreetmap.josm.gui.MainApplication; 33 import org.openstreetmap.josm.gui.MapView; 32 34 import org.openstreetmap.josm.tools.Geometry; 33 35 import org.openstreetmap.josm.tools.MultiMap; … … 92 94 93 95 // Planning phase: decide where we'll insert the nodes and put it all in "data" 96 MapView mapView = MainApplication.getMap().mapView; 94 97 for (Node node : selectedNodes) { 95 List<WaySegment> wss = Main.map.mapView.getNearestWaySegments( 96 Main.map.mapView.getPoint(node), OsmPrimitive::isSelectable); 97 98 List<WaySegment> wss = mapView.getNearestWaySegments(mapView.getPoint(node), OsmPrimitive::isSelectable); 98 99 MultiMap<Way, Integer> insertPoints = new MultiMap<>(); 99 100 for (WaySegment ws : wss) { -
trunk/src/org/openstreetmap/josm/actions/JumpToAction.java
r12620 r12630 21 21 import org.openstreetmap.josm.data.coor.LatLon; 22 22 import org.openstreetmap.josm.gui.ExtendedDialog; 23 import org.openstreetmap.josm.gui.MainApplication; 23 24 import org.openstreetmap.josm.gui.MapView; 24 25 import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils; … … 98 99 */ 99 100 public void showJumpToDialog() { 100 if (!Main .isDisplayingMapView()) {101 if (!MainApplication.isDisplayingMapView()) { 101 102 return; 102 103 } 103 MapView mv = Main .map.mapView;104 MapView mv = MainApplication.getMap().mapView; 104 105 105 106 final Optional<Bounds> boundsFromClipboard = Optional … … 208 209 @Override 209 210 protected void updateEnabledState() { 210 setEnabled(Main .isDisplayingMapView());211 setEnabled(MainApplication.isDisplayingMapView()); 211 212 } 212 213 -
trunk/src/org/openstreetmap/josm/actions/LassoModeAction.java
r11713 r12630 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import org.openstreetmap.josm.Main;7 6 import org.openstreetmap.josm.actions.mapmode.MapMode; 7 import org.openstreetmap.josm.gui.MainApplication; 8 import org.openstreetmap.josm.gui.MapFrame; 8 9 import org.openstreetmap.josm.gui.layer.Layer; 9 10 import org.openstreetmap.josm.tools.ImageProvider; … … 27 28 @Override 28 29 public void enterMode() { 29 if (Main.isDisplayingMapView()) { 30 Main.map.mapModeSelect.setLassoMode(true); 31 Main.map.mapModeSelect.enterMode(); 30 if (MainApplication.isDisplayingMapView()) { 31 MapFrame map = MainApplication.getMap(); 32 map.mapModeSelect.setLassoMode(true); 33 map.mapModeSelect.enterMode(); 32 34 } 33 35 super.enterMode(); … … 36 38 @Override 37 39 public void exitMode() { 38 if (Main.isDisplayingMapView()) { 39 Main.map.mapModeSelect.setLassoMode(false); 40 Main.map.mapModeSelect.exitMode(); 40 if (MainApplication.isDisplayingMapView()) { 41 MapFrame map = MainApplication.getMap(); 42 map.mapModeSelect.setLassoMode(false); 43 map.mapModeSelect.exitMode(); 41 44 } 42 45 super.exitMode(); … … 45 48 @Override 46 49 public boolean layerIsSupported(Layer l) { 47 return Main .map.mapModeSelect.layerIsSupported(l);50 return MainApplication.getMap().mapModeSelect.layerIsSupported(l); 48 51 } 49 52 } -
trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java
r12620 r12630 35 35 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 36 36 import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec; 37 import org.openstreetmap.josm.gui.MainApplication; 38 import org.openstreetmap.josm.gui.MapView; 37 39 import org.openstreetmap.josm.gui.Notification; 38 40 import org.openstreetmap.josm.gui.conflict.tags.CombinePrimitiveResolverDialog; … … 75 77 76 78 if (selectedNodes.size() == 1) { 77 List<Node> nearestNodes = Main.map.mapView.getNearestNodes( 78 Main.map.mapView.getPoint(selectedNodes.get(0)), selectedNodes, OsmPrimitive::isUsable); 79 MapView mapView = MainApplication.getMap().mapView; 80 List<Node> nearestNodes = mapView.getNearestNodes( 81 mapView.getPoint(selectedNodes.get(0)), selectedNodes, OsmPrimitive::isUsable); 79 82 if (nearestNodes.isEmpty()) { 80 83 new Notification( -
trunk/src/org/openstreetmap/josm/actions/MoveAction.java
r12316 r12630 19 19 import org.openstreetmap.josm.data.osm.OsmPrimitive; 20 20 import org.openstreetmap.josm.data.osm.visitor.AllNodesVisitor; 21 import org.openstreetmap.josm.gui.MainApplication; 22 import org.openstreetmap.josm.gui.MapView; 21 23 import org.openstreetmap.josm.tools.Shortcut; 22 24 … … 102 104 DataSet ds = getLayerManager().getEditDataSet(); 103 105 104 if (!Main .isDisplayingMapView() || ds == null)106 if (!MainApplication.isDisplayingMapView() || ds == null) 105 107 return; 106 108 … … 108 110 // achive an 1-pixel movement 109 111 110 EastNorth en1 = Main.map.mapView.getEastNorth(100, 100); 111 EastNorth en2 = Main.map.mapView.getEastNorth(101, 101); 112 MapView mapView = MainApplication.getMap().mapView; 113 EastNorth en1 = mapView.getEastNorth(100, 100); 114 EastNorth en2 = mapView.getEastNorth(101, 101); 112 115 113 116 double distx = en2.east() - en1.east(); … … 162 165 } 163 166 164 Main.map.mapView.repaint();167 mapView.repaint(); 165 168 } 166 169 -
trunk/src/org/openstreetmap/josm/actions/MoveNodeAction.java
r10552 r12630 13 13 import org.openstreetmap.josm.data.osm.Node; 14 14 import org.openstreetmap.josm.data.osm.OsmPrimitive; 15 import org.openstreetmap.josm.gui.MainApplication; 15 16 import org.openstreetmap.josm.gui.dialogs.LatLonDialog; 16 17 … … 50 51 // move the node 51 52 Main.main.undoRedo.add(new MoveCommand(n, coordinates)); 52 Main .map.mapView.repaint();53 MainApplication.getMap().mapView.repaint(); 53 54 } 54 55 -
trunk/src/org/openstreetmap/josm/actions/OpenFileAction.java
r12620 r12630 33 33 import org.openstreetmap.josm.Main; 34 34 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 35 import org.openstreetmap.josm.gui.MainApplication; 36 import org.openstreetmap.josm.gui.MapFrame; 35 37 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 36 38 import org.openstreetmap.josm.gui.widgets.AbstractFileChooser; … … 178 180 @Override 179 181 protected void finish() { 180 if (Main.map != null) { 181 Main.map.repaint(); 182 MapFrame map = MainApplication.getMap(); 183 if (map != null) { 184 map.repaint(); 182 185 } 183 186 } -
trunk/src/org/openstreetmap/josm/actions/RedoAction.java
r6380 r12630 9 9 10 10 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.gui.MainApplication; 12 import org.openstreetmap.josm.gui.MapFrame; 11 13 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 12 14 import org.openstreetmap.josm.tools.Shortcut; … … 31 33 @Override 32 34 public void actionPerformed(ActionEvent e) { 33 if (Main.map == null) 35 MapFrame map = MainApplication.getMap(); 36 if (map == null) 34 37 return; 35 Main.map.repaint();38 map.repaint(); 36 39 Main.main.undoRedo.redo(); 37 40 } -
trunk/src/org/openstreetmap/josm/actions/SelectByInternalPointAction.java
r11247 r12630 17 17 import org.openstreetmap.josm.data.osm.RelationMember; 18 18 import org.openstreetmap.josm.data.osm.Way; 19 import org.openstreetmap.josm.data.projection.Projection; 20 import org.openstreetmap.josm.gui.MainApplication; 19 21 import org.openstreetmap.josm.tools.Geometry; 20 22 … … 61 63 } 62 64 } 65 Projection projection = MainApplication.getMap().mapView.getProjection(); 63 66 for (Relation r : ds.getRelations()) { 64 67 if (r.isUsable() && r.isMultipolygon() && r.isSelectable() && Geometry.isNodeInsideMultiPolygon(n, r, null)) { … … 72 75 // estimate multipolygon size by its bounding box area 73 76 BBox bBox = r.getBBox(); 74 EastNorth en1 = Main.map.mapView.getProjection().latlon2eastNorth(bBox.getTopLeft());75 EastNorth en2 = Main.map.mapView.getProjection().latlon2eastNorth(bBox.getBottomRight());77 EastNorth en1 = projection.latlon2eastNorth(bBox.getTopLeft()); 78 EastNorth en2 = projection.latlon2eastNorth(bBox.getBottomRight()); 76 79 double s = Math.abs((en1.east() - en2.east()) * (en1.north() - en2.north())); 77 80 found.put(s <= 0 ? 1e8 : s, r); -
trunk/src/org/openstreetmap/josm/actions/SessionLoadAction.java
r12620 r12630 21 21 import org.openstreetmap.josm.Main; 22 22 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 23 import org.openstreetmap.josm.gui.MainApplication; 23 24 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 24 25 import org.openstreetmap.josm.gui.layer.Layer; … … 133 134 private void addLayers() { 134 135 if (layers != null && !layers.isEmpty()) { 135 boolean noMap = Main .map== null;136 boolean noMap = MainApplication.getMap() == null; 136 137 for (Layer l : layers) { 137 138 if (canceled) … … 143 144 } 144 145 if (noMap && viewport != null) { 145 Main .map.mapView.scheduleZoomTo(viewport.getEastNorthViewport(Main.getProjection()));146 MainApplication.getMap().mapView.scheduleZoomTo(viewport.getEastNorthViewport(Main.getProjection())); 146 147 } 147 148 } -
trunk/src/org/openstreetmap/josm/actions/SessionSaveAsAction.java
r12620 r12630 35 35 import org.openstreetmap.josm.gui.ExtendedDialog; 36 36 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 37 import org.openstreetmap.josm.gui.MainApplication; 37 38 import org.openstreetmap.josm.gui.MapFrame; 38 39 import org.openstreetmap.josm.gui.MapFrameListener; … … 283 284 @Override 284 285 protected void updateEnabledState() { 285 setEnabled(Main .isDisplayingMapView());286 setEnabled(MainApplication.isDisplayingMapView()); 286 287 } 287 288 -
trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java
r12287 r12630 43 43 import org.openstreetmap.josm.gui.DefaultNameFormatter; 44 44 import org.openstreetmap.josm.gui.ExtendedDialog; 45 import org.openstreetmap.josm.gui.MainApplication; 46 import org.openstreetmap.josm.gui.MapFrame; 45 47 import org.openstreetmap.josm.gui.Notification; 46 48 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 255 257 list.addListSelectionListener(e -> { 256 258 final Way selected = list.getSelectedValue(); 257 if (selected != null && Main .isDisplayingMapView() && selected.getNodesCount() > 1) {259 if (selected != null && MainApplication.isDisplayingMapView() && selected.getNodesCount() > 1) { 258 260 final Collection<WaySegment> segments = new ArrayList<>(selected.getNodesCount() - 1); 259 261 final Iterator<Node> it = selected.getNodes().iterator(); … … 272 274 protected void setHighlightedWaySegments(Collection<WaySegment> segments) { 273 275 selectedWay.getDataSet().setHighlightedWaySegments(segments); 274 Main .map.mapView.repaint();276 MainApplication.getMap().mapView.repaint(); 275 277 } 276 278 … … 542 544 Arrays.asList("outer", "inner", "forward", "backward", "north", "south", "east", "west")); 543 545 544 final boolean isMapModeDraw = Main.map != null && Main.map.mapMode == Main.map.mapModeDraw; 546 final MapFrame map = MainApplication.getMap(); 547 final boolean isMapModeDraw = map != null && map.mapMode == map.mapModeDraw; 545 548 546 549 // Change the original way -
trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java
r12620 r12630 39 39 import org.openstreetmap.josm.gui.DefaultNameFormatter; 40 40 import org.openstreetmap.josm.gui.ExtendedDialog; 41 import org.openstreetmap.josm.gui.MainApplication; 41 42 import org.openstreetmap.josm.gui.MapView; 42 43 import org.openstreetmap.josm.gui.Notification; … … 308 309 309 310 // If this wasn't called from menu, place it where the cursor is/was 311 MapView mv = MainApplication.getMap().mapView; 310 312 if (e.getSource() instanceof JPanel) { 311 MapView mv = Main.map.mapView;312 313 n.setCoor(mv.getLatLon(mv.lastMEvent.getX(), mv.lastMEvent.getY())); 313 314 } … … 315 316 Main.main.undoRedo.add(new SequenceCommand(tr("Unglued Node"), cmds)); 316 317 getLayerManager().getEditDataSet().setSelected(n); 317 Main.map.mapView.repaint();318 mv.repaint(); 318 319 } 319 320 -
trunk/src/org/openstreetmap/josm/actions/UndoAction.java
r6380 r12630 9 9 10 10 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.gui.MainApplication; 12 import org.openstreetmap.josm.gui.MapFrame; 11 13 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 12 14 import org.openstreetmap.josm.tools.Shortcut; … … 31 33 @Override 32 34 public void actionPerformed(ActionEvent e) { 33 if (Main.map == null) 35 MapFrame map = MainApplication.getMap(); 36 if (map == null) 34 37 return; 35 Main.map.repaint();38 map.repaint(); 36 39 Main.main.undoRedo.undo(); 37 40 } -
trunk/src/org/openstreetmap/josm/actions/UploadAction.java
r12537 r12630 22 22 import org.openstreetmap.josm.data.conflict.ConflictCollection; 23 23 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 24 import org.openstreetmap.josm.gui.MainApplication; 24 25 import org.openstreetmap.josm.gui.io.UploadDialog; 25 26 import org.openstreetmap.josm.gui.io.UploadPrimitivesTask; … … 259 260 if (!isEnabled()) 260 261 return; 261 if (Main .map== null) {262 if (MainApplication.getMap() == null) { 262 263 JOptionPane.showMessageDialog( 263 264 Main.parent, -
trunk/src/org/openstreetmap/josm/actions/ValidateAction.java
r12211 r12630 18 18 import org.openstreetmap.josm.data.validation.TestError; 19 19 import org.openstreetmap.josm.data.validation.util.AggregatePrimitivesVisitor; 20 import org.openstreetmap.josm.gui.MainApplication; 21 import org.openstreetmap.josm.gui.MapFrame; 20 22 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 21 23 import org.openstreetmap.josm.gui.layer.ValidatorLayer; … … 62 64 */ 63 65 public void doValidate(boolean getSelectedItems) { 64 if (Main.map == null || !Main.map.isVisible()) 66 MapFrame map = MainApplication.getMap(); 67 if (map == null || !map.isVisible()) 65 68 return; 66 69 … … 140 143 // 141 144 GuiHelper.runInEDT(() -> { 142 Main.map.validatorDialog.tree.setErrors(errors); 143 Main.map.validatorDialog.unfurlDialog(); 145 MapFrame map = MainApplication.getMap(); 146 map.validatorDialog.tree.setErrors(errors); 147 map.validatorDialog.unfurlDialog(); 144 148 //FIXME: nicer way to find / invalidate the corresponding error layer 145 149 Main.getLayerManager().getLayersOfType(ValidatorLayer.class).forEach(ValidatorLayer::invalidate); -
trunk/src/org/openstreetmap/josm/actions/ZoomInAction.java
r10318 r12630 9 9 10 10 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.gui.MainApplication; 11 12 import org.openstreetmap.josm.tools.Shortcut; 12 13 … … 46 47 @Override 47 48 public void actionPerformed(ActionEvent e) { 48 if (!Main .isDisplayingMapView()) return;49 Main .map.mapView.zoomIn();49 if (!MainApplication.isDisplayingMapView()) return; 50 MainApplication.getMap().mapView.zoomIn(); 50 51 } 51 52 -
trunk/src/org/openstreetmap/josm/actions/ZoomOutAction.java
r10318 r12630 9 9 10 10 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.gui.MainApplication; 11 12 import org.openstreetmap.josm.tools.Shortcut; 12 13 … … 32 33 @Override 33 34 public void actionPerformed(ActionEvent e) { 34 if (!Main .isDisplayingMapView()) return;35 Main .map.mapView.zoomOut();35 if (!MainApplication.isDisplayingMapView()) return; 36 MainApplication.getMap().mapView.zoomOut(); 36 37 } 37 38 -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTask.java
r11784 r12630 18 18 import org.openstreetmap.josm.data.ViewportData; 19 19 import org.openstreetmap.josm.data.gpx.GpxData; 20 import org.openstreetmap.josm.gui.MainApplication; 21 import org.openstreetmap.josm.gui.MapFrame; 20 22 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 21 23 import org.openstreetmap.josm.gui.layer.GpxLayer; … … 170 172 mergeLayer.mergeFrom(layer); 171 173 mergeLayer.invalidate(); 172 if (Main.map != null && zoomAfterDownload && layer instanceof GpxLayer) { 173 Main.map.mapView.scheduleZoomTo(new ViewportData(layer.getViewProjectionBounds())); 174 MapFrame map = MainApplication.getMap(); 175 if (map != null && zoomAfterDownload && layer instanceof GpxLayer) { 176 map.mapView.scheduleZoomTo(new ViewportData(layer.getViewProjectionBounds())); 174 177 } 175 178 return mergeLayer; -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadNotesTask.java
r12620 r12630 19 19 import org.openstreetmap.josm.data.osm.NoteData; 20 20 import org.openstreetmap.josm.data.preferences.IntegerProperty; 21 import org.openstreetmap.josm.gui.MainApplication; 22 import org.openstreetmap.josm.gui.MapFrame; 21 23 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 22 24 import org.openstreetmap.josm.gui.layer.NoteLayer; … … 132 134 if (!noteLayers.isEmpty()) { 133 135 noteLayers.get(0).getNoteData().addNotes(notesData); 134 if (Main.map != null && zoomAfterDownload) { 135 Main.map.mapView.scheduleZoomTo(new ViewportData(noteLayer.getViewProjectionBounds())); 136 MapFrame map = MainApplication.getMap(); 137 if (map != null && zoomAfterDownload) { 138 map.mapView.scheduleZoomTo(new ViewportData(noteLayer.getViewProjectionBounds())); 136 139 } 137 140 } else { -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmChangeTask.java
r12620 r12630 32 32 import org.openstreetmap.josm.data.osm.history.HistoryRelation; 33 33 import org.openstreetmap.josm.data.osm.history.HistoryWay; 34 import org.openstreetmap.josm.gui.MainApplication; 34 35 import org.openstreetmap.josm.gui.history.HistoryLoadTask; 35 36 import org.openstreetmap.josm.gui.progress.ProgressMonitor; … … 195 196 // No more primitive to update. Processing is finished 196 197 // Be sure all updated primitives are correctly drawn 197 Main .map.repaint();198 MainApplication.getMap().repaint(); 198 199 } else { 199 200 // Some primitives still need to be loaded -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
r12620 r12630 27 27 import org.openstreetmap.josm.data.osm.Way; 28 28 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 29 import org.openstreetmap.josm.gui.MainApplication; 30 import org.openstreetmap.josm.gui.MapFrame; 29 31 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 30 32 import org.openstreetmap.josm.gui.io.UpdatePrimitivesTask; … … 228 230 229 231 protected OsmDataLayer getEditLayer() { 230 if (!Main .isDisplayingMapView()) return null;232 if (!MainApplication.isDisplayingMapView()) return null; 231 233 return Main.getLayerManager().getEditLayer(); 232 234 } … … 280 282 Collection<OsmPrimitive> primitivesToUpdate = searchPrimitivesToUpdate(bounds, layer.data); 281 283 layer.mergeFrom(dataSet); 282 if (Main.map != null && zoomAfterDownload && bounds != null) { 283 Main.map.mapView.zoomTo(new ViewportData(computeBbox(bounds))); 284 MapFrame map = MainApplication.getMap(); 285 if (map != null && zoomAfterDownload && bounds != null) { 286 map.mapView.zoomTo(new ViewportData(computeBbox(bounds))); 284 287 } 285 288 if (!primitivesToUpdate.isEmpty()) { -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadReferrersTask.java
r10601 r12630 25 25 import org.openstreetmap.josm.data.osm.PrimitiveId; 26 26 import org.openstreetmap.josm.data.osm.Way; 27 import org.openstreetmap.josm.gui.MainApplication; 28 import org.openstreetmap.josm.gui.MapFrame; 27 29 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 28 30 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 131 133 JOptionPane.WARNING_MESSAGE 132 134 ); 133 Main.map.conflictDialog.unfurlDialog(); 134 Main.map.repaint(); 135 MapFrame map = MainApplication.getMap(); 136 map.conflictDialog.unfurlDialog(); 137 map.repaint(); 135 138 } 136 139 -
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 -
trunk/src/org/openstreetmap/josm/actions/relation/DeleteRelationsAction.java
r10453 r12630 10 10 import org.openstreetmap.josm.actions.mapmode.DeleteAction; 11 11 import org.openstreetmap.josm.data.osm.Relation; 12 import org.openstreetmap.josm.gui.MainApplication; 13 import org.openstreetmap.josm.gui.MapFrame; 12 14 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 13 15 import org.openstreetmap.josm.tools.ImageProvider; … … 35 37 DeleteAction.deleteRelations(layer, toDelete); 36 38 // clear selection after deletion 37 if (Main.map.relationListDialog != null) 38 Main.map.relationListDialog.selectRelations(null); 39 MapFrame map = MainApplication.getMap(); 40 if (map.relationListDialog != null) 41 map.relationListDialog.selectRelations(null); 39 42 } 40 43 -
trunk/src/org/openstreetmap/josm/actions/relation/DownloadMembersAction.java
r10657 r12630 10 10 import org.openstreetmap.josm.Main; 11 11 import org.openstreetmap.josm.data.osm.OsmPrimitive; 12 import org.openstreetmap.josm.gui.MainApplication; 12 13 import org.openstreetmap.josm.gui.dialogs.relation.DownloadRelationTask; 13 14 import org.openstreetmap.josm.io.OnlineResource; … … 33 34 @Override 34 35 public void actionPerformed(ActionEvent e) { 35 if (!isEnabled() || relations.isEmpty() || !Main .isDisplayingMapView()) return;36 if (!isEnabled() || relations.isEmpty() || !MainApplication.isDisplayingMapView()) return; 36 37 Main.worker.submit(new DownloadRelationTask(relations, Main.getLayerManager().getEditLayer())); 37 38 } -
trunk/src/org/openstreetmap/josm/actions/relation/DownloadSelectedIncompleteMembersAction.java
r10717 r12630 12 12 import org.openstreetmap.josm.data.osm.OsmPrimitive; 13 13 import org.openstreetmap.josm.data.osm.Relation; 14 import org.openstreetmap.josm.gui.MainApplication; 14 15 import org.openstreetmap.josm.gui.dialogs.relation.DownloadRelationMemberTask; 15 16 import org.openstreetmap.josm.io.OnlineResource; … … 49 50 @Override 50 51 public void actionPerformed(ActionEvent e) { 51 if (!isEnabled() || relations.isEmpty() || !Main .isDisplayingMapView()) return;52 if (!isEnabled() || relations.isEmpty() || !MainApplication.isDisplayingMapView()) return; 52 53 Main.worker.submit(new DownloadRelationMemberTask( 53 54 relations, -
trunk/src/org/openstreetmap/josm/actions/relation/EditRelationAction.java
r10428 r12630 16 16 import org.openstreetmap.josm.data.osm.Relation; 17 17 import org.openstreetmap.josm.data.osm.RelationMember; 18 import org.openstreetmap.josm.gui.MainApplication; 18 19 import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor; 19 20 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 42 43 public static Set<RelationMember> getMembersForCurrentSelection(Relation r) { 43 44 Set<RelationMember> members = new HashSet<>(); 44 if (Main .isDisplayingMapView()) {45 if (MainApplication.isDisplayingMapView()) { 45 46 OsmDataLayer editLayer = Main.getLayerManager().getEditLayer(); 46 47 if (editLayer != null && editLayer.data != null) { … … 61 62 */ 62 63 public static void launchEditor(Relation toEdit) { 63 if (toEdit == null || toEdit.isDeleted() || !Main .isDisplayingMapView()) return;64 if (toEdit == null || toEdit.isDeleted() || !MainApplication.isDisplayingMapView()) return; 64 65 RelationEditor.getEditor(Main.getLayerManager().getEditLayer(), toEdit, 65 66 getMembersForCurrentSelection(toEdit)).setVisible(true); -
trunk/src/org/openstreetmap/josm/actions/relation/RecentRelationsAction.java
r11869 r12630 22 22 import org.openstreetmap.josm.data.osm.Relation; 23 23 import org.openstreetmap.josm.gui.DefaultNameFormatter; 24 import org.openstreetmap.josm.gui.MainApplication; 24 25 import org.openstreetmap.josm.gui.SideButton; 25 26 import org.openstreetmap.josm.gui.layer.Layer; … … 123 124 */ 124 125 public static List<Relation> getRecentRelationsOnActiveLayer() { 125 if (!Main .isDisplayingMapView())126 if (!MainApplication.isDisplayingMapView()) 126 127 return Collections.emptyList(); 127 128 Layer activeLayer = Main.getLayerManager().getActiveLayer(); -
trunk/src/org/openstreetmap/josm/actions/relation/SelectInRelationListAction.java
r8510 r12630 6 6 import java.awt.event.ActionEvent; 7 7 8 import org.openstreetmap.josm.Main; 8 import org.openstreetmap.josm.gui.MainApplication; 9 import org.openstreetmap.josm.gui.MapFrame; 9 10 import org.openstreetmap.josm.tools.ImageProvider; 10 11 … … 26 27 @Override 27 28 public void actionPerformed(ActionEvent e) { 28 if (!isEnabled() || relations.isEmpty() || Main.map == null || Main.map.relationListDialog == null) return; 29 Main.map.relationListDialog.unfurlDialog(); 30 Main.map.relationListDialog.selectRelations(relations); 29 MapFrame map = MainApplication.getMap(); 30 if (!isEnabled() || relations.isEmpty() || map == null || map.relationListDialog == null) return; 31 map.relationListDialog.unfurlDialog(); 32 map.relationListDialog.selectRelations(relations); 31 33 } 32 34 } -
trunk/src/org/openstreetmap/josm/actions/relation/SelectMembersAction.java
r11038 r12630 11 11 import org.openstreetmap.josm.data.osm.OsmPrimitive; 12 12 import org.openstreetmap.josm.data.osm.Relation; 13 import org.openstreetmap.josm.gui.MainApplication; 13 14 import org.openstreetmap.josm.tools.ImageProvider; 14 15 … … 36 37 @Override 37 38 public void actionPerformed(ActionEvent e) { 38 if (!isEnabled() || relations.isEmpty() || !Main .isDisplayingMapView()) return;39 if (!isEnabled() || relations.isEmpty() || !MainApplication.isDisplayingMapView()) return; 39 40 40 41 Set<OsmPrimitive> members = new HashSet<>(); -
trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java
r12620 r12630 51 51 import org.openstreetmap.josm.data.osm.OsmPrimitive; 52 52 import org.openstreetmap.josm.gui.ExtendedDialog; 53 import org.openstreetmap.josm.gui.MainApplication; 54 import org.openstreetmap.josm.gui.MapFrame; 53 55 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 54 56 import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSException; … … 696 698 public void receiveSearchResult(DataSet ds, Collection<OsmPrimitive> result, int foundMatches, SearchSetting setting) { 697 699 ds.setSelected(result); 700 MapFrame map = MainApplication.getMap(); 698 701 if (foundMatches == 0) { 699 702 final String msg; … … 710 713 msg = null; 711 714 } 712 if ( Main.map != null) {713 Main.map.statusLine.setHelpText(msg);715 if (map != null) { 716 map.statusLine.setHelpText(msg); 714 717 } 715 718 if (!GraphicsEnvironment.isHeadless()) { … … 722 725 } 723 726 } else { 724 Main.map.statusLine.setHelpText(tr("Found {0} matches", foundMatches));727 map.statusLine.setHelpText(tr("Found {0} matches", foundMatches)); 725 728 } 726 729 } -
trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java
r12620 r12630 36 36 import org.openstreetmap.josm.data.osm.Tagged; 37 37 import org.openstreetmap.josm.data.osm.Way; 38 import org.openstreetmap.josm.gui.MainApplication; 38 39 import org.openstreetmap.josm.gui.mappaint.Environment; 39 40 import org.openstreetmap.josm.gui.mappaint.mapcss.Selector; … … 1551 1552 @Override 1552 1553 protected Collection<Bounds> getBounds(OsmPrimitive primitive) { 1553 if (!Main .isDisplayingMapView()) {1554 if (!MainApplication.isDisplayingMapView()) { 1554 1555 return null; 1555 1556 } 1556 return Collections.singleton(Main .map.mapView.getRealBounds());1557 return Collections.singleton(MainApplication.getMap().mapView.getRealBounds()); 1557 1558 } 1558 1559 -
trunk/src/org/openstreetmap/josm/actions/upload/UploadNotesTask.java
r12620 r12630 15 15 import org.openstreetmap.josm.data.osm.NoteData; 16 16 import org.openstreetmap.josm.gui.ExceptionDialogUtil; 17 import org.openstreetmap.josm.gui.MainApplication; 17 18 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 18 19 import org.openstreetmap.josm.gui.progress.ProgressMonitor; … … 123 124 StringBuilder sb = new StringBuilder(); 124 125 for (Map.Entry<Note, Exception> entry : failedNotes.entrySet()) { 125 sb.append(tr("Note {0} failed: {1}", entry.getKey().getId(), entry.getValue().getMessage())) ;126 sb.append('\n');126 sb.append(tr("Note {0} failed: {1}", entry.getKey().getId(), entry.getValue().getMessage())) 127 .append('\n'); 127 128 } 128 129 Logging.error("Notes failed to upload: " + sb.toString()); 129 JOptionPane.showMessageDialog(Main.map, sb.toString(), tr("Notes failed to upload"), JOptionPane.ERROR_MESSAGE); 130 JOptionPane.showMessageDialog(MainApplication.getMap(), sb.toString(), 131 tr("Notes failed to upload"), JOptionPane.ERROR_MESSAGE); 130 132 ExceptionDialogUtil.explainException(failedNotes.values().iterator().next()); 131 133 } -
trunk/src/org/openstreetmap/josm/actions/upload/ValidateUploadHook.java
r12279 r12630 22 22 import org.openstreetmap.josm.data.validation.util.AggregatePrimitivesVisitor; 23 23 import org.openstreetmap.josm.gui.ExtendedDialog; 24 import org.openstreetmap.josm.gui.MainApplication; 25 import org.openstreetmap.josm.gui.MapFrame; 24 26 import org.openstreetmap.josm.gui.dialogs.validator.ValidatorTreePanel; 25 27 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 77 79 editLayer.validationErrors.addAll(errors); 78 80 } 79 if (Main.map != null) { 80 Main.map.validatorDialog.tree.setErrors(errors); 81 MapFrame map = MainApplication.getMap(); 82 if (map != null) { 83 map.validatorDialog.tree.setErrors(errors); 81 84 } 82 85 if (errors.isEmpty()) … … 148 151 OsmValidator.initializeTests(); 149 152 OsmValidator.initializeErrorLayer(); 150 Main .map.validatorDialog.unfurlDialog();153 MainApplication.getMap().validatorDialog.unfurlDialog(); 151 154 Main.getLayerManager().getLayersOfType(ValidatorLayer.class).forEach(ValidatorLayer::invalidate); 152 155 return false; -
trunk/src/org/openstreetmap/josm/command/conflict/ConflictAddCommand.java
r12620 r12630 15 15 import org.openstreetmap.josm.data.osm.OsmPrimitive; 16 16 import org.openstreetmap.josm.gui.DefaultNameFormatter; 17 import org.openstreetmap.josm.gui.MainApplication; 17 18 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 18 19 import org.openstreetmap.josm.tools.ImageProvider; … … 64 65 @Override 65 66 public void undoCommand() { 66 if (Main .isDisplayingMapView() && !Main.getLayerManager().containsLayer(getLayer())) {67 if (MainApplication.isDisplayingMapView() && !Main.getLayerManager().containsLayer(getLayer())) { 67 68 Logging.warn(tr("Layer ''{0}'' does not exist any more. Cannot remove conflict for object ''{1}''.", 68 69 getLayer().getName(), -
trunk/src/org/openstreetmap/josm/command/conflict/ConflictResolveCommand.java
r12620 r12630 10 10 import org.openstreetmap.josm.data.conflict.Conflict; 11 11 import org.openstreetmap.josm.data.conflict.ConflictCollection; 12 import org.openstreetmap.josm.gui.MainApplication; 12 13 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 13 14 import org.openstreetmap.josm.tools.Logging; … … 71 72 super.undoCommand(); 72 73 73 if (Main .isDisplayingMapView()) {74 if (MainApplication.isDisplayingMapView()) { 74 75 if (!Main.getLayerManager().containsLayer(getLayer())) { 75 76 Logging.warn(tr("Cannot undo command ''{0}'' because layer ''{1}'' is not present any more", -
trunk/src/org/openstreetmap/josm/data/imagery/OffsetBookmark.java
r12620 r12630 19 19 import org.openstreetmap.josm.data.projection.Projection; 20 20 import org.openstreetmap.josm.data.projection.Projections; 21 import org.openstreetmap.josm.gui.MainApplication; 21 22 import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer; 22 23 import org.openstreetmap.josm.gui.layer.ImageryLayer; … … 246 247 public static void bookmarkOffset(String name, AbstractTileSourceLayer layer) { 247 248 LatLon center; 248 if (Main .isDisplayingMapView()) {249 center = Main.getProjection().eastNorth2latlon(Main .map.mapView.getCenter());249 if (MainApplication.isDisplayingMapView()) { 250 center = Main.getProjection().eastNorth2latlon(MainApplication.getMap().mapView.getCenter()); 250 251 } else { 251 252 center = LatLon.ZERO; -
trunk/src/org/openstreetmap/josm/data/osm/FilterMatcher.java
r12383 r12630 6 6 import java.util.List; 7 7 8 import org.openstreetmap.josm.Main;9 8 import org.openstreetmap.josm.actions.search.SearchAction.SearchMode; 10 9 import org.openstreetmap.josm.actions.search.SearchCompiler; … … 12 11 import org.openstreetmap.josm.actions.search.SearchCompiler.Not; 13 12 import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError; 13 import org.openstreetmap.josm.gui.MainApplication; 14 import org.openstreetmap.josm.gui.MapFrame; 14 15 import org.openstreetmap.josm.tools.SubclassFilteredCollection; 15 16 … … 224 225 225 226 private static FilterType test(List<FilterInfo> filters, OsmPrimitive primitive, boolean hidden) { 226 227 MapFrame map = MainApplication.getMap(); 227 228 if (primitive.isIncomplete() || 228 ( Main.map != null && Main.map.mapMode != null && Main.map.mapMode.getPreservedPrimitives().contains(primitive)))229 (map != null && map.mapMode != null && map.mapMode.getPreservedPrimitives().contains(primitive))) 229 230 return FilterType.NOT_FILTERED; 230 231 -
trunk/src/org/openstreetmap/josm/data/osm/FilterModel.java
r12620 r12630 19 19 import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError; 20 20 import org.openstreetmap.josm.data.osm.Filter.FilterPreferenceEntry; 21 import org.openstreetmap.josm.gui.MainApplication; 21 22 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 22 23 import org.openstreetmap.josm.gui.widgets.OSDLabel; … … 323 324 lblOSD.setSize(lblOSD.getPreferredSize()); 324 325 325 int dx = Main .map.mapView.getWidth() - lblOSD.getPreferredSize().width - 15;326 int dx = MainApplication.getMap().mapView.getWidth() - lblOSD.getPreferredSize().width - 15; 326 327 int dy = 15; 327 328 g.translate(dx, dy); -
trunk/src/org/openstreetmap/josm/data/osm/NoteData.java
r12620 r12630 10 10 import java.util.Map; 11 11 12 import org.openstreetmap.josm.Main;13 12 import org.openstreetmap.josm.data.coor.LatLon; 14 13 import org.openstreetmap.josm.data.notes.Note; … … 16 15 import org.openstreetmap.josm.data.notes.NoteComment; 17 16 import org.openstreetmap.josm.gui.JosmUserIdentityManager; 17 import org.openstreetmap.josm.gui.MainApplication; 18 import org.openstreetmap.josm.gui.MapFrame; 18 19 import org.openstreetmap.josm.tools.ListenerList; 19 20 import org.openstreetmap.josm.tools.Logging; … … 85 86 } 86 87 87 /** Returns the currently selected note 88 /** 89 * Returns the currently selected note 88 90 * @return currently selected note 89 91 */ … … 92 94 } 93 95 94 /** Set a selected note. Causes the dialog to select the note and 96 /** 97 * Set a selected note. Causes the dialog to select the note and 95 98 * the note layer to draw the selected note's comments. 96 99 * @param note Selected note. Null indicates no selection … … 98 101 public void setSelectedNote(Note note) { 99 102 selectedNote = note; 100 if (Main.map != null) { 101 Main.map.noteDialog.selectionChanged(); 103 MapFrame map = MainApplication.getMap(); 104 if (map != null) { 105 map.noteDialog.selectionChanged(); 102 106 } 103 107 listeners.fireEvent(l -> l.selectedNoteChanged(this)); … … 232 236 233 237 private void dataUpdated() { 234 if (Main .isDisplayingMapView()) {235 Main .map.noteDialog.setNotes(getSortedNotes());238 if (MainApplication.isDisplayingMapView()) { 239 MainApplication.getMap().noteDialog.setNotes(getSortedNotes()); 236 240 } 237 241 listeners.fireEvent(l -> l.noteDataUpdated(this)); -
trunk/src/org/openstreetmap/josm/data/osm/history/HistoryDataSet.java
r12190 r12630 18 18 import org.openstreetmap.josm.data.osm.PrimitiveId; 19 19 import org.openstreetmap.josm.data.osm.SimplePrimitiveId; 20 import org.openstreetmap.josm.gui.MainApplication; 20 21 import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; 21 22 import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener; … … 226 227 @Override 227 228 public void layerRemoving(LayerRemoveEvent e) { 228 if (!Main .isDisplayingMapView()) return;229 if (!MainApplication.isDisplayingMapView()) return; 229 230 if (Main.getLayerManager().getLayers().isEmpty()) { 230 231 data.clear(); -
trunk/src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java
r12163 r12630 15 15 import org.openstreetmap.josm.data.osm.RelationMember; 16 16 import org.openstreetmap.josm.data.osm.Way; 17 import org.openstreetmap.josm.gui.MainApplication; 18 import org.openstreetmap.josm.gui.MapFrame; 17 19 18 20 /** … … 197 199 return; 198 200 // convert size from meters to east/north units 199 double enSize = size * Main.map.mapView.getScale() / Main.map.mapView.getDist100Pixel() * 100; 201 MapFrame map = MainApplication.getMap(); 202 double enSize = size * map.mapView.getScale() / map.mapView.getDist100Pixel() * 100; 200 203 visit(bounds.getMin().add(-enSize/2, -enSize/2)); 201 204 visit(bounds.getMax().add(+enSize/2, +enSize/2)); -
trunk/src/org/openstreetmap/josm/gui/ImageryMenu.java
r12125 r12630 160 160 // list all imagery entries where the current map location 161 161 // is within the imagery bounds 162 if (Main .isDisplayingMapView()) {163 MapView mv = Main .map.mapView;162 if (MainApplication.isDisplayingMapView()) { 163 MapView mv = MainApplication.getMap().mapView; 164 164 LatLon pos = mv.getProjection().eastNorth2latlon(mv.getCenter()); 165 165 final List<ImageryInfo> inViewLayers = new ArrayList<>(); -
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r12629 r12630 106 106 private static final List<String> COMMAND_LINE_ARGS = new ArrayList<>(); 107 107 108 /** 109 * The MapFrame. 110 */ 111 static MapFrame map; 112 108 113 private final MainFrame mainFrame; 109 114 … … 225 230 public static List<String> getCommandLineArgs() { 226 231 return Collections.unmodifiableList(COMMAND_LINE_ARGS); 232 } 233 234 /** 235 * Returns the MapFrame. 236 * <p> 237 * There should be no need to access this to access any map data. Use {@link #layerManager} instead. 238 * @return the MapFrame 239 * @see MainPanel 240 * @since 12630 (as a replacement to {@code Main.map}) 241 */ 242 public static MapFrame getMap() { 243 return map; 244 } 245 246 /** 247 * Replies true if JOSM currently displays a map view. False, if it doesn't, i.e. if 248 * it only shows the MOTD panel. 249 * <p> 250 * You do not need this when accessing the layer manager. The layer manager will be empty if no map view is shown. 251 * 252 * @return <code>true</code> if JOSM currently displays a map view 253 * @since 12630 (as a replacement to {@code Main.isDisplayingMapView()}) 254 */ 255 @SuppressWarnings("deprecation") 256 public static boolean isDisplayingMapView() { 257 return map != null && map.mapView != null; 227 258 } 228 259 -
trunk/src/org/openstreetmap/josm/gui/MainPanel.java
r11713 r12630 44 44 * @param showMap If the map should be displayed. 45 45 */ 46 @SuppressWarnings("deprecation") 46 47 protected synchronized void updateContent(boolean showMap) { 47 48 GuiHelper.assertCallFromEdt(); … … 65 66 map = null; 66 67 Main.map = map; 68 MainApplication.map = map; 67 69 add(getGettingStarted(), BorderLayout.CENTER); 68 70 } … … 83 85 } 84 86 87 @SuppressWarnings("deprecation") 85 88 private MapFrame createNewMapFrame() { 86 89 MapFrame mapFrame = new MapFrame(null); 87 90 // Required by many components. 88 91 Main.map = mapFrame; 92 MainApplication.map = mapFrame; 89 93 90 94 mapFrame.fillPanel(this); -
trunk/src/org/openstreetmap/josm/gui/MapMover.java
r12338 r12630 169 169 boolean allowMovement = (e.getModifiersEx() & (MouseEvent.BUTTON3_DOWN_MASK | offMask)) == MouseEvent.BUTTON3_DOWN_MASK; 170 170 if (Main.isPlatformOsx()) { 171 MapFrame map = MainApplication.getMap(); 171 172 int macMouseMask = MouseEvent.CTRL_DOWN_MASK | MouseEvent.BUTTON1_DOWN_MASK; 172 173 boolean macMovement = e.getModifiersEx() == macMouseMask; 173 boolean allowedMode = ! Main.map.mapModeSelect.equals(Main.map.mapMode)174 || SelectAction.Mode.SELECT.equals( Main.map.mapModeSelect.getMode());174 boolean allowedMode = !map.mapModeSelect.equals(map.mapMode) 175 || SelectAction.Mode.SELECT.equals(map.mapModeSelect.getMode()); 175 176 allowMovement |= macMovement && allowedMode; 176 177 } -
trunk/src/org/openstreetmap/josm/gui/MapStatus.java
r12620 r12630 406 406 try { 407 407 final MouseState ms = incomingMouseState.take(); 408 if (parent != Main .map)408 if (parent != MainApplication.getMap()) 409 409 return; // exit, if new parent. 410 410 -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r12620 r12630 562 562 } 563 563 564 MapFrame map = MainApplication.getMap(); 564 565 if (AutoFilterManager.getInstance().getCurrentAutoFilter() != null) { 565 566 AutoFilterManager.getInstance().drawOSDText(tempG); 566 } else if (Main .isDisplayingMapView() && Main.map.filterDialog != null) {567 Main.map.filterDialog.drawOSDText(tempG);567 } else if (MainApplication.isDisplayingMapView() && map.filterDialog != null) { 568 map.filterDialog.drawOSDText(tempG); 568 569 } 569 570 … … 660 661 @Override 661 662 public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { 662 if (Main.map != null) { 663 MapFrame map = MainApplication.getMap(); 664 if (map != null) { 663 665 /* This only makes the buttons look disabled. Disabling the actions as well requires 664 666 * the user to re-select the tool after i.e. moving a layer. While testing I found … … 666 668 * order. This way it works as visual clue for new users */ 667 669 // FIXME: This does not belong here. 668 for (final AbstractButton b: Main.map.allMapModeButtons) {670 for (final AbstractButton b: map.allMapModeButtons) { 669 671 MapMode mode = (MapMode) b.getAction(); 670 672 final boolean activeLayerSupported = mode.layerIsSupported(layerManager.getActiveLayer()); -
trunk/src/org/openstreetmap/josm/gui/NotificationManager.java
r11996 r12630 114 114 int x; 115 115 int y; 116 if (Main.isDisplayingMapView() && Main.map.mapView.getHeight() > 0) { 117 MapView mv = Main.map.mapView; 116 MapFrame map = MainApplication.getMap(); 117 if (MainApplication.isDisplayingMapView() && map.mapView.getHeight() > 0) { 118 MapView mv = map.mapView; 118 119 Point mapViewPos = SwingUtilities.convertPoint(mv.getParent(), mv.getX(), mv.getY(), Main.parent); 119 120 x = mapViewPos.x + margin; 120 y = mapViewPos.y + mv.getHeight() - Main.map.statusLine.getHeight() - size.height - margin;121 y = mapViewPos.y + mv.getHeight() - map.statusLine.getHeight() - size.height - margin; 121 122 } else { 122 123 x = margin; -
trunk/src/org/openstreetmap/josm/gui/SelectionManager.java
r11945 r12630 184 184 public void mousePressed(MouseEvent e) { 185 185 if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() > 1 && Main.getLayerManager().getEditDataSet() != null) { 186 SelectByInternalPointAction.performSelection(Main .map.mapView.getEastNorth(e.getX(), e.getY()),186 SelectByInternalPointAction.performSelection(MainApplication.getMap().mapView.getEastNorth(e.getX(), e.getY()), 187 187 (e.getModifiersEx() & MouseEvent.SHIFT_DOWN_MASK) != 0, 188 188 (e.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) != 0); -
trunk/src/org/openstreetmap/josm/gui/autofilter/AutoFilterButton.java
r12474 r12630 11 11 import javax.swing.JButton; 12 12 13 import org.openstreetmap.josm.Main;14 13 import org.openstreetmap.josm.actions.JosmAction; 15 14 import org.openstreetmap.josm.data.preferences.ColorProperty; 15 import org.openstreetmap.josm.gui.MainApplication; 16 16 17 17 /** … … 36 36 if (filter.equals(afm.getCurrentAutoFilter())) { 37 37 afm.setCurrentAutoFilter(null); 38 Main .map.filterDialog.getFilterModel().executeFilters();38 MainApplication.getMap().filterDialog.getFilterModel().executeFilters(); 39 39 } else { 40 40 afm.setCurrentAutoFilter(filter); -
trunk/src/org/openstreetmap/josm/gui/autofilter/AutoFilterManager.java
r12620 r12630 43 43 import org.openstreetmap.josm.data.preferences.BooleanProperty; 44 44 import org.openstreetmap.josm.data.preferences.StringProperty; 45 import org.openstreetmap.josm.gui.MainApplication; 45 46 import org.openstreetmap.josm.gui.MapFrame; 46 47 import org.openstreetmap.josm.gui.MapFrame.MapModeChangeListener; 48 import org.openstreetmap.josm.gui.MapView; 47 49 import org.openstreetmap.josm.gui.NavigatableComponent; 48 50 import org.openstreetmap.josm.gui.NavigatableComponent.ZoomChangeListener; … … 130 132 131 133 private synchronized void updateButtons() { 132 if (enabledRule != null && Main.map != null 133 && enabledRule.getMinZoomLevel() <= Selector.GeneralSelector.scale2level(Main.map.mapView.getDist100Pixel())) { 134 MapFrame map = MainApplication.getMap(); 135 if (enabledRule != null && map != null 136 && enabledRule.getMinZoomLevel() <= Selector.GeneralSelector.scale2level(map.mapView.getDist100Pixel())) { 134 137 // Retrieve the values from current rule visible on screen 135 138 NavigableSet<String> values = getNumericValues(enabledRule.getKey(), enabledRule.getValueComparator()); … … 148 151 int i = 0; 149 152 int maxWidth = 16; 153 MapView mapView = MainApplication.getMap().mapView; 150 154 for (final String value : values.descendingSet()) { 151 155 Filter filter = new Filter(); … … 161 165 buttons.put(value, button); 162 166 maxWidth = Math.max(maxWidth, button.getPreferredSize().width); 163 Main.map.mapView.add(button).setLocation(3, 60 + 22*i++);167 mapView.add(button).setLocation(3, 60 + 22*i++); 164 168 } 165 169 for (AutoFilterButton b : buttons.values()) { 166 170 b.setSize(maxWidth, 20); 167 171 } 168 Main.map.mapView.validate();172 mapView.validate(); 169 173 } 170 174 171 175 private void removeAllButtons() { 172 176 for (Iterator<String> it = buttons.keySet().iterator(); it.hasNext();) { 173 Main .map.mapView.remove(buttons.get(it.next()));177 MainApplication.getMap().mapView.remove(buttons.get(it.next())); 174 178 it.remove(); 175 179 } … … 193 197 Set<String> values = new TreeSet<>(); 194 198 if (ds != null) { 195 BBox bbox = Main .map.mapView.getState().getViewArea().getLatLonBoundsBox().toBBox();199 BBox bbox = MainApplication.getMap().mapView.getState().getViewArea().getLatLonBoundsBox().toBBox(); 196 200 Consumer<OsmPrimitive> consumer = getTagValuesConsumer(key, values); 197 201 ds.searchNodes(bbox).forEach(consumer); … … 388 392 setCurrentAutoFilter(null); 389 393 removeAllButtons(); 390 if (Main.map != null) { 391 Main.map.filterDialog.getFilterModel().executeFilters(); 394 MapFrame map = MainApplication.getMap(); 395 if (map != null) { 396 map.filterDialog.getFilterModel().executeFilters(); 392 397 } 393 398 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java
r12279 r12630 42 42 import org.openstreetmap.josm.data.osm.DataSet; 43 43 import org.openstreetmap.josm.data.osm.OsmPrimitive; 44 import org.openstreetmap.josm.gui.MainApplication; 44 45 import org.openstreetmap.josm.gui.SideButton; 45 46 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 463 464 break; 464 465 } 465 Main .map.repaint();466 MainApplication.getMap().repaint(); 466 467 } 467 468 -
trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java
r12620 r12630 56 56 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 57 57 import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec; 58 import org.openstreetmap.josm.gui.MainApplication; 58 59 import org.openstreetmap.josm.gui.NavigatableComponent; 59 60 import org.openstreetmap.josm.gui.OsmPrimitivRenderer; … … 130 131 lstConflicts.addMouseListener(new MouseEventHandler()); 131 132 } 132 addListSelectionListener(e -> Main .map.mapView.repaint());133 addListSelectionListener(e -> MainApplication.getMap().mapView.repaint()); 133 134 134 135 SideButton btnResolve = new SideButton(actResolve); … … 210 211 lstConflicts.setSelectedIndex(index); 211 212 } 212 Main .map.mapView.repaint();213 MainApplication.getMap().mapView.repaint(); 213 214 } 214 215 … … 632 633 ); 633 634 unfurlDialog(); 634 Main .map.repaint();635 MainApplication.getMap().repaint(); 635 636 }); 636 637 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/FilterDialog.java
r12400 r12630 40 40 import org.openstreetmap.josm.data.osm.event.TagsChangedEvent; 41 41 import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent; 42 import org.openstreetmap.josm.gui.MainApplication; 42 43 import org.openstreetmap.josm.gui.MapFrame; 43 44 import org.openstreetmap.josm.gui.MapFrame.MapModeChangeListener; … … 88 89 MapFrame.removeMapModeChangeListener(this); 89 90 filterModel.model.clearFilterFlags(); 90 Main .map.mapView.repaint();91 MainApplication.getMap().mapView.repaint(); 91 92 } 92 93 -
trunk/src/org/openstreetmap/josm/gui/dialogs/FilterTableModel.java
r12620 r12630 11 11 import javax.swing.table.AbstractTableModel; 12 12 13 import org.openstreetmap.josm.Main;14 13 import org.openstreetmap.josm.data.osm.Filter; 15 14 import org.openstreetmap.josm.data.osm.FilterModel; 16 15 import org.openstreetmap.josm.data.osm.OsmPrimitive; 16 import org.openstreetmap.josm.gui.MainApplication; 17 import org.openstreetmap.josm.gui.MapFrame; 17 18 import org.openstreetmap.josm.gui.autofilter.AutoFilterManager; 18 19 import org.openstreetmap.josm.gui.widgets.OSDLabel; … … 87 88 88 89 private void updateMap() { 89 if (Main.map != null && model.isChanged()) { 90 Main.map.filterDialog.updateDialogHeader(); 90 MapFrame map = MainApplication.getMap(); 91 if (map != null && model.isChanged()) { 92 map.filterDialog.updateDialogHeader(); 91 93 } 92 94 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDialog.java
r12279 r12630 26 26 import org.openstreetmap.josm.gui.DefaultNameFormatter; 27 27 import org.openstreetmap.josm.gui.ExtendedDialog; 28 import org.openstreetmap.josm.gui.MainApplication; 28 29 import org.openstreetmap.josm.gui.NavigatableComponent; 29 30 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 116 117 final Collection<OsmPrimitive> sel = Main.getLayerManager().getEditDataSet().getAllSelected(); 117 118 ElemStyles elemstyles = MapPaintStyles.getStyles(); 118 NavigatableComponent nc = Main .map.mapView;119 NavigatableComponent nc = MainApplication.getMap().mapView; 119 120 double scale = nc.getDist100Pixel(); 120 121 -
trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
r11905 r12630 44 44 import org.openstreetmap.josm.actions.MergeLayerAction; 45 45 import org.openstreetmap.josm.data.preferences.AbstractProperty; 46 import org.openstreetmap.josm.gui.MainApplication; 47 import org.openstreetmap.josm.gui.MapFrame; 46 48 import org.openstreetmap.josm.gui.MapView; 47 49 import org.openstreetmap.josm.gui.SideButton; … … 507 509 Layer layer = (Layer) value; 508 510 if (layer instanceof NativeScaleLayer) { 509 boolean active = ((NativeScaleLayer) layer) == Main .map.mapView.getNativeScaleLayer();511 boolean active = ((NativeScaleLayer) layer) == MainApplication.getMap().mapView.getNativeScaleLayer(); 510 512 cb.setSelected(active); 511 513 cb.setToolTipText(active … … 824 826 List<Integer> sel = getSelectedRows(); 825 827 List<Layer> layers = getLayers(); 828 MapView mapView = MainApplication.getMap().mapView; 826 829 for (int row : sel) { 827 830 Layer l1 = layers.get(row); 828 831 Layer l2 = layers.get(row-1); 829 Main.map.mapView.moveLayer(l2, row);830 Main.map.mapView.moveLayer(l1, row-1);832 mapView.moveLayer(l2, row); 833 mapView.moveLayer(l1, row-1); 831 834 } 832 835 fireTableDataChanged(); … … 859 862 Collections.reverse(sel); 860 863 List<Layer> layers = getLayers(); 864 MapView mapView = MainApplication.getMap().mapView; 861 865 for (int row : sel) { 862 866 Layer l1 = layers.get(row); 863 867 Layer l2 = layers.get(row+1); 864 Main.map.mapView.moveLayer(l1, row+1);865 Main.map.mapView.moveLayer(l2, row);868 mapView.moveLayer(l1, row+1); 869 mapView.moveLayer(l2, row); 866 870 } 867 871 fireTableDataChanged(); … … 999 1003 break; 1000 1004 case 1: 1001 NativeScaleLayer oldLayer = Main.map.mapView.getNativeScaleLayer(); 1005 MapFrame map = MainApplication.getMap(); 1006 NativeScaleLayer oldLayer = map.mapView.getNativeScaleLayer(); 1002 1007 if (oldLayer == l) { 1003 Main.map.mapView.setNativeScaleLayer(null);1008 map.mapView.setNativeScaleLayer(null); 1004 1009 } else if (l instanceof NativeScaleLayer) { 1005 Main.map.mapView.setNativeScaleLayer((NativeScaleLayer) l);1010 map.mapView.setNativeScaleLayer((NativeScaleLayer) l); 1006 1011 if (oldLayer != null) { 1007 1012 int idx = getLayers().indexOf(oldLayer); -
trunk/src/org/openstreetmap/josm/gui/dialogs/MinimapDialog.java
r11452 r12630 8 8 import java.util.Collections; 9 9 10 import org.openstreetmap.josm.Main;11 10 import org.openstreetmap.josm.data.Bounds; 11 import org.openstreetmap.josm.gui.MainApplication; 12 12 import org.openstreetmap.josm.gui.MapView; 13 13 import org.openstreetmap.josm.gui.NavigatableComponent; … … 55 55 @Override 56 56 public void zoomChanged() { 57 if (!skipEvents && Main .isDisplayingMapView()) {58 MapView mv = Main .map.mapView;57 if (!skipEvents && MainApplication.isDisplayingMapView()) { 58 MapView mv = MainApplication.getMap().mapView; 59 59 final Bounds currentBounds = new Bounds( 60 60 mv.getLatLon(0, mv.getHeight()), … … 72 72 if (!skipEvents) { 73 73 skipEvents = true; 74 Main .map.mapView.zoomTo(slippyMap.getBoundingBox());74 MainApplication.getMap().mapView.zoomTo(slippyMap.getBoundingBox()); 75 75 skipEvents = false; 76 76 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/NotesDialog.java
r12279 r12630 36 36 import org.openstreetmap.josm.data.notes.NoteComment; 37 37 import org.openstreetmap.josm.data.osm.NoteData; 38 import org.openstreetmap.josm.gui.MainApplication; 39 import org.openstreetmap.josm.gui.MapFrame; 38 40 import org.openstreetmap.josm.gui.NoteInputDialog; 39 41 import org.openstreetmap.josm.gui.NoteSortDialog; … … 99 101 public void mouseClicked(MouseEvent e) { 100 102 if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2 && noteData != null && noteData.getSelectedNote() != null) { 101 Main .map.mapView.zoomTo(noteData.getSelectedNote().getLatLon());103 MainApplication.getMap().mapView.zoomTo(noteData.getSelectedNote().getLatLon()); 102 104 } 103 105 } … … 161 163 noteData = null; 162 164 model.clearData(); 163 if (Main.map.mapMode instanceof AddNoteAction) { 164 Main.map.selectMapMode(Main.map.mapModeSelect); 165 MapFrame map = MainApplication.getMap(); 166 if (map.mapMode instanceof AddNoteAction) { 167 map.selectMapMode(map.mapModeSelect); 165 168 } 166 169 } … … 297 300 Note note = displayList.getSelectedValue(); 298 301 if (note == null) { 299 JOptionPane.showMessageDialog(Main .map,302 JOptionPane.showMessageDialog(MainApplication.getMap(), 300 303 "You must select a note first", 301 304 "No note selected", … … 355 358 Main.getLayerManager().addLayer(new NoteLayer()); 356 359 } 357 Main .map.selectMapMode(new AddNoteAction(noteData));360 MainApplication.getMap().selectMapMode(new AddNoteAction(noteData)); 358 361 } 359 362 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
r12528 r12630 57 57 import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent; 58 58 import org.openstreetmap.josm.gui.DefaultNameFormatter; 59 import org.openstreetmap.josm.gui.MainApplication; 59 60 import org.openstreetmap.josm.gui.MapView; 60 61 import org.openstreetmap.josm.gui.NavigatableComponent; … … 209 210 210 211 //update highlights 211 if (highlightEnabled && focused == displaylist && Main .isDisplayingMapView() && highlightHelper.highlightOnly(sel)) {212 Main .map.mapView.repaint();212 if (highlightEnabled && focused == displaylist && MainApplication.isDisplayingMapView() && highlightHelper.highlightOnly(sel)) { 213 MainApplication.getMap().mapView.repaint(); 213 214 } 214 215 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
r12279 r12630 67 67 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 68 68 import org.openstreetmap.josm.gui.DefaultNameFormatter; 69 import org.openstreetmap.josm.gui.MainApplication; 70 import org.openstreetmap.josm.gui.MapFrame; 69 71 import org.openstreetmap.josm.gui.OsmPrimitivRenderer; 70 72 import org.openstreetmap.josm.gui.PopupMenuHandler; … … 212 214 actEditRelationSelection.actionPerformed(null); 213 215 } 214 } else if (highlightEnabled && Main .isDisplayingMapView() && helper.highlightOnly(model.getElementAt(idx))) {215 Main .map.mapView.repaint();216 } else if (highlightEnabled && MainApplication.isDisplayingMapView() && helper.highlightOnly(model.getElementAt(idx))) { 217 MainApplication.getMap().mapView.repaint(); 216 218 } 217 219 } … … 442 444 return; 443 445 box.enlargeBoundingBox(); 444 Main .map.mapView.zoomTo(box);446 MainApplication.getMap().mapView.zoomTo(box); 445 447 } 446 448 … … 615 617 if (selection != null) { 616 618 remember(selection); 619 MapFrame map = MainApplication.getMap(); 617 620 if (selection.size() == 2) { 618 621 Iterator<? extends OsmPrimitive> it = selection.iterator(); … … 624 627 LatLon c2 = ((Node) n2).getCoor(); 625 628 if (c1 != null && c2 != null) { 626 Main.map.statusLine.setDist(c1.greatCircleDistance(c2));629 map.statusLine.setDist(c1.greatCircleDistance(c2)); 627 630 return; 628 631 } 629 632 } 630 633 } 631 Main.map.statusLine.setDist(634 map.statusLine.setDist( 632 635 new SubclassFilteredCollection<OsmPrimitive, Way>(selection, Way.class::isInstance)); 633 636 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java
r12302 r12630 43 43 import org.openstreetmap.josm.data.validation.TestError; 44 44 import org.openstreetmap.josm.data.validation.ValidatorVisitor; 45 import org.openstreetmap.josm.gui.MainApplication; 46 import org.openstreetmap.josm.gui.MapFrame; 45 47 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 46 48 import org.openstreetmap.josm.gui.PopupMenuHandler; … … 315 317 tree.resetErrors(); 316 318 OsmValidator.saveIgnoredErrors(); 317 Main .map.repaint();319 MainApplication.getMap().repaint(); 318 320 } 319 321 } … … 524 526 fixButton.setEnabled(hasFixes); 525 527 popupMenuHandler.setPrimitives(sel); 526 if (Main.map != null) { 527 Main.map.repaint(); 528 MapFrame map = MainApplication.getMap(); 529 if (map != null) { 530 map.repaint(); 528 531 } 529 532 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/BasicChangesetQueryPanel.java
r12620 r12630 22 22 import org.openstreetmap.josm.data.Bounds; 23 23 import org.openstreetmap.josm.gui.JosmUserIdentityManager; 24 import org.openstreetmap.josm.gui.MainApplication; 25 import org.openstreetmap.josm.gui.MapView; 24 26 import org.openstreetmap.josm.gui.widgets.HtmlPanel; 25 27 import org.openstreetmap.josm.gui.widgets.JMultilineLabel; … … 165 167 } 166 168 167 // query for changesets in the current map view only if there *is* a current 168 // map view 169 // query for changesets in the current map view only if there *is* a current map view 169 170 lbl = lblQueries.get(BasicQuery.CHANGESETS_IN_MAP_VIEW); 170 if (!Main .isDisplayingMapView()) {171 if (!MainApplication.isDisplayingMapView()) { 171 172 rbQueries.get(BasicQuery.CHANGESETS_IN_MAP_VIEW).setEnabled(false); 172 173 lbl.setText(tr("<html>Download changesets in the current map view.<br><em>Disabled. " + … … 241 242 break; 242 243 case CHANGESETS_IN_MAP_VIEW: 243 Bounds b = Main.map.mapView.getLatLonBounds(Main.map.mapView.getBounds()); 244 MapView mapView = MainApplication.getMap().mapView; 245 Bounds b = mapView.getLatLonBounds(mapView.getBounds()); 244 246 query = query.inBbox(b); 245 247 break; -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r12620 r12630 83 83 import org.openstreetmap.josm.gui.DefaultNameFormatter; 84 84 import org.openstreetmap.josm.gui.ExtendedDialog; 85 import org.openstreetmap.josm.gui.MainApplication; 85 86 import org.openstreetmap.josm.gui.PopupMenuHandler; 86 87 import org.openstreetmap.josm.gui.SideButton; … … 385 386 public void mouseClicked(MouseEvent e) { 386 387 //update highlights 387 if (Main .isDisplayingMapView()) {388 if (MainApplication.isDisplayingMapView()) { 388 389 int row = membershipTable.rowAtPoint(e.getPoint()); 389 390 if (row >= 0 && highlightHelper.highlightOnly((Relation) membershipTable.getValueAt(row, 0))) { 390 Main .map.mapView.repaint();391 MainApplication.getMap().mapView.repaint(); 391 392 } 392 393 } … … 484 485 private void editMembership(int row) { 485 486 Relation relation = (Relation) membershipData.getValueAt(row, 0); 486 Main .map.relationListDialog.selectRelation(relation);487 MainApplication.getMap().relationListDialog.selectRelation(relation); 487 488 RelationEditor.getEditor( 488 489 Main.getLayerManager().getEditLayer(), -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ChildRelationBrowser.java
r12620 r12630 36 36 import org.openstreetmap.josm.gui.DefaultNameFormatter; 37 37 import org.openstreetmap.josm.gui.ExceptionDialogUtil; 38 import org.openstreetmap.josm.gui.MainApplication; 38 39 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 39 40 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 420 421 refreshView(r); 421 422 } 422 SwingUtilities.invokeLater(Main .map::repaint);423 SwingUtilities.invokeLater(MainApplication.getMap()::repaint); 423 424 } catch (OsmTransferException e) { 424 425 if (canceled) { -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/DownloadRelationMemberTask.java
r12620 r12630 13 13 import javax.swing.SwingUtilities; 14 14 15 import org.openstreetmap.josm.Main;16 15 import org.openstreetmap.josm.data.osm.DataSet; 17 16 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 19 18 import org.openstreetmap.josm.gui.DefaultNameFormatter; 20 19 import org.openstreetmap.josm.gui.ExceptionDialogUtil; 20 import org.openstreetmap.josm.gui.MainApplication; 21 21 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 22 22 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 83 83 @Override 84 84 protected void finish() { 85 Main .map.repaint();85 MainApplication.getMap().repaint(); 86 86 if (canceled) 87 87 return; -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/DownloadRelationTask.java
r12620 r12630 10 10 import javax.swing.SwingUtilities; 11 11 12 import org.openstreetmap.josm.Main;13 12 import org.openstreetmap.josm.data.osm.DataSet; 14 13 import org.openstreetmap.josm.data.osm.DataSetMerger; … … 16 15 import org.openstreetmap.josm.gui.DefaultNameFormatter; 17 16 import org.openstreetmap.josm.gui.ExceptionDialogUtil; 17 import org.openstreetmap.josm.gui.MainApplication; 18 18 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 19 19 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 102 102 layer.mergeFrom(allDownloads); 103 103 layer.onPostDownloadFromServer(); 104 Main .map.repaint();104 MainApplication.getMap().repaint(); 105 105 }); 106 106 } catch (OsmTransferException | InvocationTargetException | InterruptedException e) { -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTable.java
r10683 r12630 28 28 import org.openstreetmap.josm.data.osm.RelationMember; 29 29 import org.openstreetmap.josm.data.osm.Way; 30 import org.openstreetmap.josm.gui.MainApplication; 30 31 import org.openstreetmap.josm.gui.dialogs.relation.sort.WayConnectionType; 31 32 import org.openstreetmap.josm.gui.dialogs.relation.sort.WayConnectionType.Direction; … … 108 109 109 110 private transient ListSelectionListener highlighterListener = lse -> { 110 if (Main .isDisplayingMapView()) {111 if (MainApplication.isDisplayingMapView()) { 111 112 Collection<RelationMember> sel = getMemberTableModel().getSelectedMembers(); 112 113 final Set<OsmPrimitive> toHighlight = new HashSet<>(); … … 117 118 } 118 119 SwingUtilities.invokeLater(() -> { 119 if (Main .isDisplayingMapView() && highlightHelper.highlightOnly(toHighlight)) {120 Main .map.mapView.repaint();120 if (MainApplication.isDisplayingMapView() && highlightHelper.highlightOnly(toHighlight)) { 121 MainApplication.getMap().mapView.repaint(); 121 122 } 122 123 }); … … 128 129 if (!highlightEnabled) return; 129 130 getMemberTableModel().getSelectionModel().addListSelectionListener(highlighterListener); 130 if (Main .isDisplayingMapView()) {131 if (MainApplication.isDisplayingMapView()) { 131 132 HighlightHelper.clearAllHighlighted(); 132 Main .map.mapView.repaint();133 MainApplication.getMap().mapView.repaint(); 133 134 } 134 135 } … … 153 154 getMemberTableModel().getSelectionModel().removeListSelectionListener(highlighterListener); 154 155 highlighterListener = null; 155 if (Main .isDisplayingMapView()) {156 if (MainApplication.isDisplayingMapView()) { 156 157 HighlightHelper.clearAllHighlighted(); 157 Main .map.mapView.repaint();158 MainApplication.getMap().mapView.repaint(); 158 159 } 159 160 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/SavingAction.java
r12048 r12630 21 21 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 22 22 import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec; 23 import org.openstreetmap.josm.gui.MainApplication; 23 24 import org.openstreetmap.josm.gui.dialogs.relation.IRelationEditor; 24 25 import org.openstreetmap.josm.gui.dialogs.relation.MemberTable; … … 82 83 } 83 84 // Relation list gets update in EDT so selecting my be postponed to following EDT run 84 SwingUtilities.invokeLater(() -> Main .map.relationListDialog.selectRelation(newRelation));85 SwingUtilities.invokeLater(() -> MainApplication.getMap().relationListDialog.selectRelation(newRelation)); 85 86 } 86 87 … … 140 141 ); 141 142 if (ret == 0) { 142 Main .map.conflictDialog.unfurlDialog();143 MainApplication.getMap().conflictDialog.unfurlDialog(); 143 144 } 144 145 return ret == 0; -
trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java
r12620 r12630 39 39 import org.openstreetmap.josm.data.preferences.BooleanProperty; 40 40 import org.openstreetmap.josm.data.preferences.IntegerProperty; 41 import org.openstreetmap.josm.gui.MainApplication; 41 42 import org.openstreetmap.josm.gui.MapView; 42 43 import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils; … … 408 409 tpDownloadAreaSelectors.setSelectedIndex(idx); 409 410 410 if (Main .isDisplayingMapView()) {411 MapView mv = Main .map.mapView;411 if (MainApplication.isDisplayingMapView()) { 412 MapView mv = MainApplication.getMap().mapView; 412 413 currentBounds = new Bounds( 413 414 mv.getLatLon(0, mv.getHeight()), -
trunk/src/org/openstreetmap/josm/gui/io/AbstractPrimitiveTask.java
r10611 r12630 7 7 import java.util.Set; 8 8 9 import org.openstreetmap.josm.Main;10 9 import org.openstreetmap.josm.actions.AutoScaleAction; 11 10 import org.openstreetmap.josm.data.osm.DataSet; … … 16 15 import org.openstreetmap.josm.data.osm.Way; 17 16 import org.openstreetmap.josm.gui.ExceptionDialogUtil; 17 import org.openstreetmap.josm.gui.MainApplication; 18 18 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 19 19 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 186 186 GuiHelper.runInEDTAndWait(() -> { 187 187 layer.mergeFrom(ds); 188 if (zoom && Main .map!= null)188 if (zoom && MainApplication.getMap() != null) 189 189 AutoScaleAction.zoomTo(ds.allPrimitives()); 190 190 layer.onPostDownloadFromServer(); -
trunk/src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java
r12370 r12630 28 28 import org.openstreetmap.josm.Main; 29 29 import org.openstreetmap.josm.data.osm.Changeset; 30 import org.openstreetmap.josm.gui.MainApplication; 30 31 import org.openstreetmap.josm.gui.widgets.HistoryComboBox; 31 32 import org.openstreetmap.josm.gui.widgets.JMultilineLabel; … … 84 85 sourceLabel.addHyperlinkListener(e -> { 85 86 if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) { 86 final String source = Main .map.mapView.getLayerInformationForSourceTag();87 final String source = MainApplication.getMap().mapView.getLayerInformationForSourceTag(); 87 88 hcbUploadSource.setText(Utils.shortenString(source, Changeset.MAX_CHANGESET_TAG_LENGTH)); 88 89 // Fix #9965 -
trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
r12620 r12630 89 89 import org.openstreetmap.josm.data.projection.Projections; 90 90 import org.openstreetmap.josm.gui.ExtendedDialog; 91 import org.openstreetmap.josm.gui.MainApplication; 91 92 import org.openstreetmap.josm.gui.MapView; 92 93 import org.openstreetmap.josm.gui.NavigatableComponent.ZoomChangeListener; … … 261 262 262 263 protected void initTileSource(T tileSource) { 263 coordinateConverter = new TileCoordinateConverter(Main .map.mapView, tileSource, getDisplaySettings());264 coordinateConverter = new TileCoordinateConverter(MainApplication.getMap().mapView, tileSource, getDisplaySettings()); 264 265 attribution.initialize(tileSource); 265 266 … … 852 853 853 854 private TileSet getVisibleTileSet() { 854 ProjectionBounds bounds = Main .map.mapView.getState().getViewArea().getProjectionBounds();855 ProjectionBounds bounds = MainApplication.getMap().mapView.getState().getViewArea().getProjectionBounds(); 855 856 return getTileSet(bounds, currentZoomLevel); 856 857 } … … 987 988 drawImageInside(g, img, anchorImage, anchorScreen, null); 988 989 } 989 if (tile instanceof ReprojectionTile && ((ReprojectionTile) tile).needsUpdate(Main.map.mapView.getScale())) { 990 MapView mapView = MainApplication.getMap().mapView; 991 if (tile instanceof ReprojectionTile && ((ReprojectionTile) tile).needsUpdate(mapView.getScale())) { 990 992 // This means we have a reprojected tile in memory cache, but not at 991 993 // current scale. Generally, the positioning of the tile will still -
trunk/src/org/openstreetmap/josm/gui/layer/AlignImageryPanel.java
r11386 r12630 15 15 import javax.swing.border.EtchedBorder; 16 16 17 import org.openstreetmap.josm.Main;18 17 import org.openstreetmap.josm.data.imagery.ImageryInfo; 19 18 import org.openstreetmap.josm.data.preferences.BooleanProperty; 19 import org.openstreetmap.josm.gui.MainApplication; 20 import org.openstreetmap.josm.gui.MapFrame; 20 21 import org.openstreetmap.josm.gui.util.GuiHelper; 21 22 import org.openstreetmap.josm.gui.widgets.JMultilineLabel; … … 54 55 closeButton.setToolTipText(tr("Hide this message and never show it again")); 55 56 closeButton.addActionListener(e -> { 56 if (Main .isDisplayingMapView()) {57 Main .map.removeTopPanel(AlignImageryPanel.class);57 if (MainApplication.isDisplayingMapView()) { 58 MainApplication.getMap().removeTopPanel(AlignImageryPanel.class); 58 59 if (doNotShowAgain.isSelected()) { 59 60 showAgain.put(Boolean.FALSE); … … 83 84 public static void addNagPanelIfNeeded(ImageryInfo infoToAdd) { 84 85 BooleanProperty showAgain = new BooleanProperty("message.imagery.nagPanel." + infoToAdd.getUrl(), true); 85 if (Main.isDisplayingMapView() && showAgain.get() && !infoToAdd.isGeoreferenceValid() 86 && Main.map.getTopPanel(AlignImageryPanel.class) == null) { 86 MapFrame map = MainApplication.getMap(); 87 if (MainApplication.isDisplayingMapView() && showAgain.get() && !infoToAdd.isGeoreferenceValid() 88 && map.getTopPanel(AlignImageryPanel.class) == null) { 87 89 double w = GuiHelper.getScreenSize().getWidth(); 88 Main.map.addTopPanel(new AlignImageryPanel(w > 1300, showAgain, infoToAdd));90 map.addTopPanel(new AlignImageryPanel(w > 1300, showAgain, infoToAdd)); 89 91 } 90 92 } -
trunk/src/org/openstreetmap/josm/gui/layer/ImageryLayer.java
r12460 r12630 35 35 import org.openstreetmap.josm.data.imagery.OffsetBookmark; 36 36 import org.openstreetmap.josm.data.preferences.IntegerProperty; 37 import org.openstreetmap.josm.gui.MainApplication; 38 import org.openstreetmap.josm.gui.MapView; 37 39 import org.openstreetmap.josm.gui.MenuScroller; 38 40 import org.openstreetmap.josm.gui.layer.imagery.ImageryFilterSettings; … … 81 83 82 84 public double getPPD() { 83 if (!Main .isDisplayingMapView())85 if (!MainApplication.isDisplayingMapView()) 84 86 return Main.getProjection().getDefaultZoomInPPD(); 85 ProjectionBounds bounds = Main.map.mapView.getProjectionBounds(); 86 return Main.map.mapView.getWidth() / (bounds.maxEast - bounds.minEast); 87 MapView mapView = MainApplication.getMap().mapView; 88 ProjectionBounds bounds = mapView.getProjectionBounds(); 89 return mapView.getWidth() / (bounds.maxEast - bounds.minEast); 87 90 } 88 91 … … 206 209 setOffset(b); 207 210 Main.main.menu.imageryMenu.refreshOffsetMenu(); 208 Main .map.repaint();211 MainApplication.getMap().repaint(); 209 212 } 210 213 } -
trunk/src/org/openstreetmap/josm/gui/layer/LayerManager.java
r11905 r12630 12 12 import java.util.function.Consumer; 13 13 14 import org.openstreetmap.josm. Main;14 import org.openstreetmap.josm.gui.MainApplication; 15 15 import org.openstreetmap.josm.gui.util.GuiHelper; 16 16 import org.openstreetmap.josm.tools.JosmRuntimeException; … … 232 232 insertLayerAt(layer, position); 233 233 fireLayerAdded(layer, initialZoom); 234 if (Main .map!= null) {234 if (MainApplication.getMap() != null) { 235 235 layer.hookUpMapView(); // needs to be after fireLayerAdded 236 236 } -
trunk/src/org/openstreetmap/josm/gui/layer/NoteLayer.java
r12620 r12630 32 32 import org.openstreetmap.josm.data.osm.NoteData.NoteDataUpdateListener; 33 33 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 34 import org.openstreetmap.josm.gui.MainApplication; 34 35 import org.openstreetmap.josm.gui.MapView; 35 36 import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils; … … 73 74 @Override 74 75 public void hookUpMapView() { 75 Main .map.mapView.addMouseListener(this);76 MainApplication.getMap().mapView.addMouseListener(this); 76 77 } 77 78 78 79 @Override 79 80 public synchronized void destroy() { 80 Main .map.mapView.removeMouseListener(this);81 MainApplication.getMap().mapView.removeMouseListener(this); 81 82 noteData.removeNoteDataUpdateListener(this); 82 83 super.destroy(); … … 134 135 int width = icon.getIconWidth(); 135 136 int height = icon.getIconHeight(); 136 g.drawImage(icon.getImage(), p.x - (width / 2), p.y - height, Main .map.mapView);137 g.drawImage(icon.getImage(), p.x - (width / 2), p.y - height, MainApplication.getMap().mapView); 137 138 } 138 139 if (noteData.getSelectedNote() != null) { … … 260 261 Note closestNote = null; 261 262 for (Note note : noteData.getNotes()) { 262 Point notePoint = Main .map.mapView.getPoint(note.getLatLon());263 Point notePoint = MainApplication.getMap().mapView.getPoint(note.getLatLon()); 263 264 //move the note point to the center of the icon where users are most likely to click when selecting 264 265 notePoint.setLocation(notePoint.getX(), notePoint.getY() - iconHeight / 2); -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r12620 r12630 87 87 import org.openstreetmap.josm.data.validation.TestError; 88 88 import org.openstreetmap.josm.gui.ExtendedDialog; 89 import org.openstreetmap.josm.gui.MainApplication; 90 import org.openstreetmap.josm.gui.MapFrame; 89 91 import org.openstreetmap.josm.gui.MapView; 90 92 import org.openstreetmap.josm.gui.MapViewState.MapViewPoint; … … 176 178 public void setRecentRelation(Relation relation) { 177 179 recentRelations.put(relation, null); 178 if (Main.map != null && Main.map.relationListDialog != null) { 179 Main.map.relationListDialog.enableRecentRelations(); 180 MapFrame map = MainApplication.getMap(); 181 if (map != null && map.relationListDialog != null) { 182 map.relationListDialog.enableRecentRelations(); 180 183 } 181 184 } … … 188 191 public void removeRecentRelation(Relation relation) { 189 192 recentRelations.remove(relation); 190 if (Main.map != null && Main.map.relationListDialog != null) { 191 Main.map.relationListDialog.enableRecentRelations(); 193 MapFrame map = MainApplication.getMap(); 194 if (map != null && map.relationListDialog != null) { 195 map.relationListDialog.enableRecentRelations(); 192 196 } 193 197 } … … 478 482 Rendering painter = MapRendererFactory.getInstance().createActiveRenderer(g, mv, inactive); 479 483 painter.render(data, virtual, box); 480 Main .map.conflictDialog.paintConflicts(g, mv);484 MainApplication.getMap().conflictDialog.paintConflicts(g, mv); 481 485 } 482 486 … … 571 575 invalidate(); 572 576 // warn about new conflicts 573 if (numNewConflicts > 0 && Main.map != null && Main.map.conflictDialog != null) { 574 Main.map.conflictDialog.warnNumNewConflicts(numNewConflicts); 577 MapFrame map = MainApplication.getMap(); 578 if (numNewConflicts > 0 && map != null && map.conflictDialog != null) { 579 map.conflictDialog.warnNumNewConflicts(numNewConflicts); 575 580 } 576 581 } -
trunk/src/org/openstreetmap/josm/gui/layer/ValidatorLayer.java
r12028 r12630 22 22 import org.openstreetmap.josm.data.validation.Severity; 23 23 import org.openstreetmap.josm.data.validation.TestError; 24 import org.openstreetmap.josm.gui.MainApplication; 24 25 import org.openstreetmap.josm.gui.MapView; 25 26 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; … … 49 50 super(tr("Validation errors")); 50 51 Main.getLayerManager().addLayerChangeListener(this); 51 Main .map.validatorDialog.tree.addInvalidationListener(invalidator);52 MainApplication.getMap().validatorDialog.tree.addInvalidationListener(invalidator); 52 53 } 53 54 … … 68 69 @Override 69 70 public void paint(final Graphics2D g, final MapView mv, Bounds bounds) { 70 DefaultMutableTreeNode root = Main .map.validatorDialog.tree.getRoot();71 DefaultMutableTreeNode root = MainApplication.getMap().validatorDialog.tree.getRoot(); 71 72 if (root == null || root.getChildCount() == 0) 72 73 return; … … 94 95 public String getToolTipText() { 95 96 MultiMap<Severity, TestError> errorTree = new MultiMap<>(); 96 List<TestError> errors = Main .map.validatorDialog.tree.getErrors();97 List<TestError> errors = MainApplication.getMap().validatorDialog.tree.getErrors(); 97 98 for (TestError e : errors) { 98 99 errorTree.put(e.getSeverity(), e); … … 173 174 @Override 174 175 public synchronized void destroy() { 175 Main .map.validatorDialog.tree.removeInvalidationListener(invalidator);176 MainApplication.getMap().validatorDialog.tree.removeInvalidationListener(invalidator); 176 177 Main.getLayerManager().removeLayerChangeListener(this); 177 178 super.destroy(); -
trunk/src/org/openstreetmap/josm/gui/layer/WMTSLayer.java
r12620 r12630 14 14 import org.openstreetmap.josm.data.imagery.WMTSTileSource; 15 15 import org.openstreetmap.josm.data.projection.Projection; 16 import org.openstreetmap.josm.gui.MainApplication; 16 17 import org.openstreetmap.josm.gui.layer.imagery.TileSourceDisplaySettings; 17 18 import org.openstreetmap.josm.tools.Logging; … … 71 72 @Override 72 73 public int getBestZoom() { 73 if (!Main .isDisplayingMapView())74 if (!MainApplication.isDisplayingMapView()) 74 75 return 0; 75 76 ScaleList scaleList = getNativeScales(); … … 77 78 return getMaxZoomLvl(); 78 79 } 79 double displayScale = Main .map.mapView.getScale();80 double displayScale = MainApplication.getMap().mapView.getScale(); 80 81 if (coordinateConverter.requiresReprojection()) { 81 82 displayScale *= Main.getProjection().getMetersPerUnit(); -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java
r12620 r12630 71 71 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 72 72 import org.openstreetmap.josm.gui.ExtendedDialog; 73 import org.openstreetmap.josm.gui.MainApplication; 73 74 import org.openstreetmap.josm.gui.layer.GpxLayer; 74 75 import org.openstreetmap.josm.gui.layer.Layer; … … 194 195 BoundingXYVisitor bbox = new BoundingXYVisitor(); 195 196 yLayer.visitBoundingBox(bbox); 196 Main .map.mapView.zoomTo(bbox);197 MainApplication.getMap().mapView.zoomTo(bbox); 197 198 } 198 199 -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java
r12620 r12630 47 47 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 48 48 import org.openstreetmap.josm.gui.ExtendedDialog; 49 import org.openstreetmap.josm.gui.MainApplication; 49 50 import org.openstreetmap.josm.gui.MapFrame; 50 51 import org.openstreetmap.josm.gui.MapFrame.MapModeChangeListener; … … 458 459 459 460 private static Dimension scaledDimension(Image thumb) { 460 final double d = Main .map.mapView.getDist100Pixel();461 final double d = MainApplication.getMap().mapView.getDist100Pixel(); 461 462 final double size = 10 /*meter*/; /* size of the photo on the map */ 462 463 double s = size * 100 /*px*/ / d; … … 778 779 ImageEntry img = data.get(idx); 779 780 if (img.getPos() != null) { 780 Point imgCenter = Main .map.mapView.getPoint(img.getPos());781 Point imgCenter = MainApplication.getMap().mapView.getPoint(img.getPos()); 781 782 Rectangle imgRect; 782 783 if (useThumbs && img.hasThumbnail()) { … … 932 933 mouseAdapter = new MouseAdapter() { 933 934 private boolean isMapModeOk() { 934 return Main.map.mapMode == null || isSupportedMapMode(Main.map.mapMode); 935 MapMode mapMode = MainApplication.getMap().mapMode; 936 return mapMode == null || isSupportedMapMode(mapMode); 935 937 } 936 938 … … 977 979 978 980 mapModeListener = (oldMapMode, newMapMode) -> { 981 MapView mapView = MainApplication.getMap().mapView; 979 982 if (newMapMode == null || isSupportedMapMode(newMapMode)) { 980 Main.map.mapView.addMouseListener(mouseAdapter);981 Main.map.mapView.addMouseMotionListener(mouseMotionAdapter);983 mapView.addMouseListener(mouseAdapter); 984 mapView.addMouseMotionListener(mouseMotionAdapter); 982 985 } else { 983 Main.map.mapView.removeMouseListener(mouseAdapter);984 Main.map.mapView.removeMouseMotionListener(mouseMotionAdapter);986 mapView.removeMouseListener(mouseAdapter); 987 mapView.removeMouseMotionListener(mouseMotionAdapter); 985 988 } 986 989 }; 987 990 988 991 MapFrame.addMapModeChangeListener(mapModeListener); 989 mapModeListener.mapModeChange(null, Main .map.mapMode);992 mapModeListener.mapModeChange(null, MainApplication.getMap().mapMode); 990 993 991 994 Main.getLayerManager().addActiveLayerChangeListener(e -> { 992 995 if (Main.getLayerManager().getActiveLayer() == this) { 993 996 // only in select mode it is possible to click the images 994 Main .map.selectSelectTool(false);997 MainApplication.getMap().selectSelectTool(false); 995 998 } 996 999 }); … … 1006 1009 if (e.getRemovedLayer() == GeoImageLayer.this) { 1007 1010 stopLoadThumbs(); 1008 Main.map.mapView.removeMouseListener(mouseAdapter); 1009 Main.map.mapView.removeMouseMotionListener(mouseMotionAdapter); 1011 MapView mapView = MainApplication.getMap().mapView; 1012 mapView.removeMouseListener(mouseAdapter); 1013 mapView.removeMouseMotionListener(mouseMotionAdapter); 1010 1014 MapFrame.removeMapModeChangeListener(mapModeListener); 1011 1015 currentPhoto = -1; … … 1025 1029 }); 1026 1030 1027 if (Main.map.getToggleDialog(ImageViewerDialog.class) == null) { 1031 MapFrame map = MainApplication.getMap(); 1032 if (map.getToggleDialog(ImageViewerDialog.class) == null) { 1028 1033 ImageViewerDialog.newInstance(); 1029 Main.map.addToggleDialog(ImageViewerDialog.getInstance());1034 map.addToggleDialog(ImageViewerDialog.getInstance()); 1030 1035 } 1031 1036 } -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageViewerDialog.java
r12460 r12630 23 23 24 24 import org.openstreetmap.josm.Main; 25 import org.openstreetmap.josm.gui.MainApplication; 25 26 import org.openstreetmap.josm.gui.dialogs.DialogsPanel.Action; 26 27 import org.openstreetmap.josm.gui.dialogs.ToggleDialog; … … 236 237 centerView = button.isEnabled() && button.isSelected(); 237 238 if (centerView && currentEntry != null && currentEntry.getPos() != null) { 238 Main .map.mapView.zoomTo(currentEntry.getPos());239 MainApplication.getMap().mapView.zoomTo(currentEntry.getPos()); 239 240 } 240 241 } else if (COMMAND_ZOOM.equals(action)) { … … 309 310 imageChanged = currentEntry != entry; 310 311 311 if (centerView && entry != null && Main .isDisplayingMapView() && entry.getPos() != null) {312 Main .map.mapView.zoomTo(entry.getPos());312 if (centerView && entry != null && MainApplication.isDisplayingMapView() && entry.getPos() != null) { 313 MainApplication.getMap().mapView.zoomTo(entry.getPos()); 313 314 } 314 315 -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ThumbsLoader.java
r12620 r12630 21 21 import org.openstreetmap.josm.data.cache.BufferedImageCacheEntry; 22 22 import org.openstreetmap.josm.data.cache.JCSCacheManager; 23 import org.openstreetmap.josm.gui.MainApplication; 23 24 import org.openstreetmap.josm.tools.ExifReader; 24 25 import org.openstreetmap.josm.tools.Logging; … … 79 80 public void run() { 80 81 Logging.debug("Load Thumbnails"); 81 tracker = new MediaTracker(Main .map.mapView);82 tracker = new MediaTracker(MainApplication.getMap().mapView); 82 83 for (ImageEntry entry : data) { 83 84 if (stop) return; … … 87 88 entry.setThumbnail(loadThumb(entry)); 88 89 89 if (layer != null && Main .isDisplayingMapView()) {90 if (layer != null && MainApplication.isDisplayingMapView()) { 90 91 layer.updateBufferAndRepaint(); 91 92 } -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/ChooseTrackVisibilityAction.java
r12279 r12630 36 36 import org.openstreetmap.josm.data.gpx.GpxTrack; 37 37 import org.openstreetmap.josm.gui.ExtendedDialog; 38 import org.openstreetmap.josm.gui.MainApplication; 38 39 import org.openstreetmap.josm.gui.layer.GpxLayer; 39 40 import org.openstreetmap.josm.tools.GBC; … … 279 280 if (v != 1 && v != 2) { 280 281 layer.trackVisibility = Arrays.copyOf(trackVisibilityBackup, layer.trackVisibility.length); 281 Main .map.repaint();282 MainApplication.getMap().repaint(); 282 283 return; 283 284 } -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/CustomizeDrawingAction.java
r12377 r12630 19 19 20 20 import org.openstreetmap.josm.Main; 21 import org.openstreetmap.josm.gui.MainApplication; 21 22 import org.openstreetmap.josm.gui.layer.GpxLayer; 22 23 import org.openstreetmap.josm.gui.layer.Layer; … … 111 112 panel.savePreferences(layer.getName(), f); 112 113 } 113 Main .map.repaint();114 MainApplication.getMap().repaint(); 114 115 } 115 116 -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/ImportAudioAction.java
r12328 r12630 26 26 import org.openstreetmap.josm.data.gpx.WayPoint; 27 27 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 28 import org.openstreetmap.josm.gui.MainApplication; 28 29 import org.openstreetmap.josm.gui.layer.GpxLayer; 29 30 import org.openstreetmap.josm.gui.layer.markerlayer.AudioMarker; … … 115 116 } 116 117 Main.getLayerManager().addLayer(ml); 117 Main .map.repaint();118 MainApplication.getMap().repaint(); 118 119 } 119 120 } -
trunk/src/org/openstreetmap/josm/gui/layer/imagery/ReprojectionTile.java
r12148 r12630 13 13 import org.openstreetmap.josm.data.projection.Projection; 14 14 import org.openstreetmap.josm.data.projection.Projections; 15 import org.openstreetmap.josm.gui.MainApplication; 15 16 import org.openstreetmap.josm.tools.ImageWarp; 16 17 import org.openstreetmap.josm.tools.Utils; … … 101 102 */ 102 103 protected void transform(BufferedImage imageIn) { 103 if (!Main .isDisplayingMapView()) {104 if (!MainApplication.isDisplayingMapView()) { 104 105 reset(); 105 106 return; 106 107 } 107 double scaleMapView = Main .map.mapView.getScale();108 double scaleMapView = MainApplication.getMap().mapView.getScale(); 108 109 ImageWarp.Interpolation interpolation; 109 110 switch (Main.pref.get("imagery.warp.pixel-interpolation", "bilinear")) { -
trunk/src/org/openstreetmap/josm/gui/layer/imagery/ZoomToNativeLevelAction.java
r12603 r12630 8 8 import javax.swing.AbstractAction; 9 9 10 import org.openstreetmap.josm. Main;10 import org.openstreetmap.josm.gui.MainApplication; 11 11 import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer; 12 12 … … 31 31 public void actionPerformed(ActionEvent ae) { 32 32 double newFactor = Math.sqrt(layer.getScaleFactor(layer.getZoomLevel())); 33 Main .map.mapView.zoomToFactor(newFactor);33 MainApplication.getMap().mapView.zoomToFactor(newFactor); 34 34 layer.invalidate(); 35 35 } -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/AudioMarker.java
r12328 r12630 7 7 import java.util.Collections; 8 8 9 import org.openstreetmap.josm.Main;10 9 import org.openstreetmap.josm.data.coor.LatLon; 11 10 import org.openstreetmap.josm.data.gpx.GpxConstants; 12 11 import org.openstreetmap.josm.data.gpx.GpxLink; 13 12 import org.openstreetmap.josm.data.gpx.WayPoint; 13 import org.openstreetmap.josm.gui.MainApplication; 14 14 import org.openstreetmap.josm.io.audio.AudioPlayer; 15 15 import org.openstreetmap.josm.io.audio.AudioUtil; … … 56 56 try { 57 57 // first enable tracing the audio along the track 58 Main .map.mapView.playHeadMarker.animate();58 MainApplication.getMap().mapView.playHeadMarker.animate(); 59 59 60 60 AudioPlayer.play(audioUrl, offset + syncOffset + after); -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/ButtonMarker.java
r10234 r12630 13 13 import org.openstreetmap.josm.Main; 14 14 import org.openstreetmap.josm.data.coor.LatLon; 15 import org.openstreetmap.josm.gui.MainApplication; 15 16 import org.openstreetmap.josm.gui.MapView; 16 17 import org.openstreetmap.josm.tools.template_engine.TemplateEngineDataProvider; … … 38 39 39 40 @Override public boolean containsPoint(Point p) { 40 Point screen = Main .map.mapView.getPoint(getEastNorth());41 Point screen = MainApplication.getMap().mapView.getPoint(getEastNorth()); 41 42 buttonRectangle.setLocation(screen.x+4, screen.y+2); 42 43 return buttonRectangle.contains(p); -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java
r12620 r12630 39 39 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 40 40 import org.openstreetmap.josm.data.preferences.ColorProperty; 41 import org.openstreetmap.josm.gui.MainApplication; 41 42 import org.openstreetmap.josm.gui.MapView; 42 43 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; … … 351 352 } 352 353 } 353 Main .map.mapView.zoomTo(currentMarker.getEastNorth());354 MainApplication.getMap().mapView.zoomTo(currentMarker.getEastNorth()); 354 355 } 355 356 … … 370 371 } 371 372 } 372 Main .map.mapView.zoomTo(currentMarker.getEastNorth());373 MainApplication.getMap().mapView.zoomTo(currentMarker.getEastNorth()); 373 374 } 374 375 … … 413 414 414 415 private static void playAdjacentMarker(Marker startMarker, boolean next) { 415 if (!Main .isDisplayingMapView())416 if (!MainApplication.isDisplayingMapView()) 416 417 return; 417 418 Marker m = null; … … 565 566 return; 566 567 } 567 PlayHeadMarker playHeadMarker = Main .map.mapView.playHeadMarker;568 PlayHeadMarker playHeadMarker = MainApplication.getMap().mapView.playHeadMarker; 568 569 if (playHeadMarker == null) 569 570 return; -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/PlayHeadMarker.java
r12579 r12630 22 22 import org.openstreetmap.josm.data.gpx.GpxTrackSegment; 23 23 import org.openstreetmap.josm.data.gpx.WayPoint; 24 import org.openstreetmap.josm.gui.MainApplication; 25 import org.openstreetmap.josm.gui.MapFrame; 24 26 import org.openstreetmap.josm.gui.MapView; 25 27 import org.openstreetmap.josm.gui.layer.GpxLayer; … … 63 65 if (!enabled) return; 64 66 dropTolerance = Main.pref.getInteger("marker.playHeadDropTolerance", 50); 65 if (Main.isDisplayingMapView()) { 66 Main.map.mapView.addMouseListener(new MouseAdapter() { 67 if (MainApplication.isDisplayingMapView()) { 68 MapFrame map = MainApplication.getMap(); 69 map.mapView.addMouseListener(new MouseAdapter() { 67 70 @Override public void mousePressed(MouseEvent ev) { 68 71 if (ev.getButton() == MouseEvent.BUTTON1 && playHead.containsPoint(ev.getPoint())) { 69 72 /* when we get a click on the marker, we need to switch mode to avoid 70 73 * getting confused with other drag operations (like select) */ 71 oldMode = Main.map.mapMode;74 oldMode = map.mapMode; 72 75 oldCoor = getCoor(); 73 76 PlayHeadDragMode playHeadDragMode = new PlayHeadDragMode(playHead); 74 Main.map.selectMapMode(playHeadDragMode);77 map.selectMapMode(playHeadDragMode); 75 78 playHeadDragMode.mousePressed(ev); 76 79 } … … 82 85 @Override 83 86 public boolean containsPoint(Point p) { 84 Point screen = Main .map.mapView.getPoint(getEastNorth());87 Point screen = MainApplication.getMap().mapView.getPoint(getEastNorth()); 85 88 Rectangle r = new Rectangle(screen.x, screen.y, symbol.getIconWidth(), 86 89 symbol.getIconHeight()); … … 121 124 setCoor(oldCoor); 122 125 } 123 Main.map.selectMapMode(oldMode); 124 Main.map.mapView.repaint(); 126 MapFrame map = MainApplication.getMap(); 127 map.selectMapMode(oldMode); 128 map.mapView.repaint(); 125 129 if (timer != null) { 126 130 timer.start(); … … 134 138 public void drag(EastNorth en) { 135 139 setEastNorth(en); 136 Main .map.mapView.repaint();140 MainApplication.getMap().mapView.repaint(); 137 141 } 138 142 … … 148 152 if (recent != null && recent.parentLayer != null && recent.parentLayer.fromLayer != null) { 149 153 /* work out EastNorth equivalent of 50 (default) pixels tolerance */ 150 Point p = Main.map.mapView.getPoint(en); 151 EastNorth enPlus25px = Main.map.mapView.getEastNorth(p.x+dropTolerance, p.y); 154 MapView mapView = MainApplication.getMap().mapView; 155 Point p = mapView.getPoint(en); 156 EastNorth enPlus25px = mapView.getEastNorth(p.x+dropTolerance, p.y); 152 157 cw = recent.parentLayer.fromLayer.data.nearestPointOnTrack(en, enPlus25px.east() - en.east()); 153 158 } … … 202 207 return; 203 208 /* First, see if we dropped onto an existing audio marker in the layer being played */ 204 Point startPoint = Main.map.mapView.getPoint(en); 209 MapView mapView = MainApplication.getMap().mapView; 210 Point startPoint = mapView.getPoint(en); 205 211 AudioMarker ca = null; 206 212 if (recent.parentLayer != null) { … … 225 231 if (ca == null) { 226 232 /* work out EastNorth equivalent of 50 (default) pixels tolerance */ 227 Point p = Main.map.mapView.getPoint(en);228 EastNorth enPlus25px = Main.map.mapView.getEastNorth(p.x+dropTolerance, p.y);233 Point p = mapView.getPoint(en); 234 EastNorth enPlus25px = mapView.getEastNorth(p.x+dropTolerance, p.y); 229 235 WayPoint cw = recent.parentLayer.fromLayer.data.nearestPointOnTrack(en, enPlus25px.east() - en.east()); 230 236 if (cw == null) { … … 345 351 (audioTime - w1.time)/(w2.time - w1.time))); 346 352 time = audioTime; 353 MapView mapView = MainApplication.getMap().mapView; 347 354 if (jumpToMarker) { 348 355 jumpToMarker = false; 349 Main.map.mapView.zoomTo(w1.getEastNorth());350 } 351 Main.map.mapView.repaint();356 mapView.zoomTo(w1.getEastNorth()); 357 } 358 mapView.repaint(); 352 359 } 353 360 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintMenu.java
r10453 r12630 14 14 import org.openstreetmap.josm.Main; 15 15 import org.openstreetmap.josm.actions.JosmAction; 16 import org.openstreetmap.josm.gui.MainApplication; 16 17 import org.openstreetmap.josm.gui.dialogs.MapPaintDialog; 17 18 import org.openstreetmap.josm.gui.layer.GpxLayer; … … 66 67 @Override 67 68 public void updateEnabledState() { 68 setEnabled(Main .isDisplayingMapView() && (Main.getLayerManager().getEditLayer() != null || mapHasGpxorMarkerLayer()));69 setEnabled(MainApplication.isDisplayingMapView() && (Main.getLayerManager().getEditLayer() != null || mapHasGpxorMarkerLayer())); 69 70 } 70 71 -
trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/MapImage.java
r12303 r12630 12 12 import javax.swing.ImageIcon; 13 13 14 import org.openstreetmap.josm.Main; 14 import org.openstreetmap.josm.gui.MainApplication; 15 import org.openstreetmap.josm.gui.MapView; 15 16 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles; 16 17 import org.openstreetmap.josm.gui.mappaint.StyleSource; … … 149 150 if (temporary) { 150 151 disabledImgCache = null; 151 Main.map.mapView.preferenceChanged(null); // otherwise repaint is ignored, because layer hasn't changed 152 Main.map.mapView.repaint(); 152 MapView mapView = MainApplication.getMap().mapView; 153 mapView.preferenceChanged(null); // otherwise repaint is ignored, because layer hasn't changed 154 mapView.repaint(); 153 155 } 154 156 temporary = false; -
trunk/src/org/openstreetmap/josm/gui/preferences/map/MapPaintPreference.java
r12620 r12630 20 20 21 21 import org.openstreetmap.josm.Main; 22 import org.openstreetmap.josm.gui.MainApplication; 22 23 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles; 23 24 import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource; … … 179 180 MapPaintStyles.readFromPreferences(); 180 181 } 181 if (Main .isDisplayingMapView()) {182 if (MainApplication.isDisplayingMapView()) { 182 183 MapPaintStyles.getStyles().clearCached(); 183 184 } -
trunk/src/org/openstreetmap/josm/gui/progress/PleaseWaitProgressMonitor.java
r12369 r12630 12 12 13 13 import org.openstreetmap.josm.Main; 14 import org.openstreetmap.josm.gui.MainApplication; 14 15 import org.openstreetmap.josm.gui.MapFrame; 15 16 import org.openstreetmap.josm.gui.MapStatus.BackgroundProgressMonitor; … … 107 108 108 109 BackgroundProgressMonitor backgroundMonitor = null; 109 MapFrame map = Main .map;110 MapFrame map = MainApplication.getMap(); 110 111 if (map != null) { 111 112 backgroundMonitor = map.statusLine.progressMonitor; … … 314 315 } 315 316 BackgroundProgressMonitor backgroundMonitor = null; 316 MapFrame map = Main .map;317 MapFrame map = MainApplication.getMap(); 317 318 if (map != null) { 318 319 backgroundMonitor = map.statusLine.progressMonitor; … … 339 340 dialog = null; 340 341 Main.currentProgressMonitor = null; 341 MapFrame map = Main .map;342 MapFrame map = MainApplication.getMap(); 342 343 if (map != null) { 343 344 map.statusLine.progressMonitor.setVisible(false); … … 354 355 doInEDT(() -> { 355 356 if (dialog != null) { 356 dialog.setInBackgroundPossible(taskId != null && Main .isDisplayingMapView());357 dialog.setInBackgroundPossible(taskId != null && MainApplication.isDisplayingMapView()); 357 358 reset(); 358 359 getDialog(); … … 366 367 doInEDT(() -> { 367 368 if (dialog != null) { 368 dialog.setInBackgroundPossible(taskId != null && Main .isDisplayingMapView());369 dialog.setInBackgroundPossible(taskId != null && MainApplication.isDisplayingMapView()); 369 370 } 370 371 }); -
trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingComboBox.java
r12620 r12630 24 24 25 25 import org.openstreetmap.josm.Main; 26 import org.openstreetmap.josm.gui.MainApplication; 27 import org.openstreetmap.josm.gui.MapFrame; 26 28 import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils; 27 29 import org.openstreetmap.josm.gui.widgets.JosmComboBox; … … 51 53 @Override 52 54 public void focusLost(FocusEvent e) { 53 if (Main.map != null) { 54 Main.map.keyDetector.setEnabled(true); 55 MapFrame map = MainApplication.getMap(); 56 if (map != null) { 57 map.keyDetector.setEnabled(true); 55 58 } 56 59 } … … 58 61 @Override 59 62 public void focusGained(FocusEvent e) { 60 if (Main.map != null) { 61 Main.map.keyDetector.setEnabled(false); 63 MapFrame map = MainApplication.getMap(); 64 if (map != null) { 65 map.keyDetector.setEnabled(false); 62 66 } 63 67 // save unix system selection (middle mouse paste) -
trunk/src/org/openstreetmap/josm/gui/widgets/JosmPasswordField.java
r12620 r12630 13 13 import javax.swing.text.JTextComponent; 14 14 15 import org.openstreetmap.josm.Main; 15 import org.openstreetmap.josm.gui.MainApplication; 16 import org.openstreetmap.josm.gui.MapFrame; 16 17 import org.openstreetmap.josm.tools.Logging; 17 18 … … 99 100 @Override 100 101 public void focusGained(FocusEvent e) { 101 if (Main.map != null) { 102 Main.map.keyDetector.setEnabled(false); 102 MapFrame map = MainApplication.getMap(); 103 if (map != null) { 104 map.keyDetector.setEnabled(false); 103 105 } 104 106 } … … 106 108 @Override 107 109 public void focusLost(FocusEvent e) { 108 if (Main.map != null) { 109 Main.map.keyDetector.setEnabled(true); 110 MapFrame map = MainApplication.getMap(); 111 if (map != null) { 112 map.keyDetector.setEnabled(true); 110 113 } 111 114 } -
trunk/src/org/openstreetmap/josm/gui/widgets/JosmTextArea.java
r11308 r12630 9 9 import javax.swing.text.Document; 10 10 11 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.gui.MainApplication; 12 import org.openstreetmap.josm.gui.MapFrame; 12 13 13 14 /** … … 105 106 @Override 106 107 public void focusGained(FocusEvent e) { 107 if (Main.map != null) { 108 Main.map.keyDetector.setEnabled(false); 108 MapFrame map = MainApplication.getMap(); 109 if (map != null) { 110 map.keyDetector.setEnabled(false); 109 111 } 110 112 } … … 112 114 @Override 113 115 public void focusLost(FocusEvent e) { 114 if (Main.map != null) { 115 Main.map.keyDetector.setEnabled(true); 116 MapFrame map = MainApplication.getMap(); 117 if (map != null) { 118 map.keyDetector.setEnabled(true); 116 119 } 117 120 } -
trunk/src/org/openstreetmap/josm/gui/widgets/JosmTextField.java
r11809 r12630 14 14 import javax.swing.text.Document; 15 15 16 import org.openstreetmap.josm.Main; 16 import org.openstreetmap.josm.gui.MainApplication; 17 import org.openstreetmap.josm.gui.MapFrame; 17 18 18 19 /** … … 168 169 @Override 169 170 public void focusGained(FocusEvent e) { 170 if (Main.map != null) { 171 Main.map.keyDetector.setEnabled(false); 171 MapFrame map = MainApplication.getMap(); 172 if (map != null) { 173 map.keyDetector.setEnabled(false); 172 174 } 173 175 repaint(); … … 176 178 @Override 177 179 public void focusLost(FocusEvent e) { 178 if (Main.map != null) { 179 Main.map.keyDetector.setEnabled(true); 180 MapFrame map = MainApplication.getMap(); 181 if (map != null) { 182 map.keyDetector.setEnabled(true); 180 183 } 181 184 repaint(); -
trunk/src/org/openstreetmap/josm/io/NoteImporter.java
r12620 r12630 12 12 import org.openstreetmap.josm.actions.ExtensionFileFilter; 13 13 import org.openstreetmap.josm.data.notes.Note; 14 import org.openstreetmap.josm.gui.MainApplication; 14 15 import org.openstreetmap.josm.gui.layer.NoteLayer; 15 16 import org.openstreetmap.josm.gui.progress.ProgressMonitor; … … 63 64 final List<Note> fileNotes = new NoteReader(in).parse(); 64 65 List<NoteLayer> noteLayers = null; 65 if (Main .map!= null) {66 if (MainApplication.getMap() != null) { 66 67 noteLayers = Main.getLayerManager().getLayersOfType(NoteLayer.class); 67 68 } -
trunk/src/org/openstreetmap/josm/io/OsmApi.java
r12620 r12630 30 30 import org.openstreetmap.josm.data.osm.OsmPrimitive; 31 31 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 32 import org.openstreetmap.josm.gui.MainApplication; 32 33 import org.openstreetmap.josm.gui.layer.ImageryLayer; 33 34 import org.openstreetmap.josm.gui.layer.Layer; … … 241 242 * to load the layers in the first place because they would have 242 243 * been disabled! */ 243 if (Main .isDisplayingMapView()) {244 if (MainApplication.isDisplayingMapView()) { 244 245 for (Layer l : Main.getLayerManager().getLayersOfType(ImageryLayer.class)) { 245 246 if (((ImageryLayer) l).getInfo().isBlacklisted()) { -
trunk/src/org/openstreetmap/josm/io/WMSLayerExporter.java
r10345 r12630 7 7 import java.io.ObjectOutputStream; 8 8 9 import org.openstreetmap.josm.Main;10 9 import org.openstreetmap.josm.data.Preferences; 11 10 import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryPreferenceEntry; 11 import org.openstreetmap.josm.gui.MainApplication; 12 12 import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer; 13 13 import org.openstreetmap.josm.gui.layer.Layer; … … 40 40 try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file))) { 41 41 oos.writeInt(CURRENT_FILE_VERSION); // file version 42 oos.writeObject(Main .map.mapView.getCenter());42 oos.writeObject(MainApplication.getMap().mapView.getCenter()); 43 43 ImageryPreferenceEntry entry = new ImageryPreferenceEntry(((AbstractTileSourceLayer) layer).getInfo()); 44 44 oos.writeObject(Preferences.serializeStruct(entry, ImageryPreferenceEntry.class)); -
trunk/src/org/openstreetmap/josm/io/WMSLayerImporter.java
r10615 r12630 17 17 import org.openstreetmap.josm.data.imagery.ImageryInfo; 18 18 import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryPreferenceEntry; 19 import org.openstreetmap.josm.gui.MainApplication; 19 20 import org.openstreetmap.josm.gui.layer.ImageryLayer; 20 21 import org.openstreetmap.josm.gui.progress.ProgressMonitor; … … 88 89 Main.getLayerManager().addLayer(layer); 89 90 if (zoomTo != null) { 90 Main .map.mapView.zoomTo(zoomTo);91 MainApplication.getMap().mapView.zoomTo(zoomTo); 91 92 } 92 93 }); -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandler.java
r12620 r12630 14 14 import org.openstreetmap.josm.data.osm.Node; 15 15 import org.openstreetmap.josm.data.osm.OsmPrimitive; 16 import org.openstreetmap.josm.gui.MainApplication; 17 import org.openstreetmap.josm.gui.MapView; 16 18 import org.openstreetmap.josm.gui.util.GuiHelper; 17 19 import org.openstreetmap.josm.io.remotecontrol.AddTagsDialog; … … 85 87 Node node = null; 86 88 87 if (Main.isDisplayingMapView()) { 88 Point p = Main.map.mapView.getPoint(ll); 89 node = Main.map.mapView.getNearestNode(p, OsmPrimitive::isUsable); 89 if (MainApplication.isDisplayingMapView()) { 90 MapView mapView = MainApplication.getMap().mapView; 91 Point p = mapView.getPoint(ll); 92 node = mapView.getNearestNode(p, OsmPrimitive::isUsable); 90 93 if (node != null && node.getCoor().greatCircleDistance(ll) > Main.pref.getDouble("remotecontrol.tolerance", 0.1)) { 91 94 node = null; // node is too far … … 103 106 AutoScaleAction.autoScale("selection"); 104 107 } else { 105 Main .map.mapView.repaint();108 MainApplication.getMap().mapView.repaint(); 106 109 } 107 110 // parse parameter addtags=tag1=value1|tag2=vlaue2 -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddWayHandler.java
r10716 r12630 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.Point;7 6 import java.util.ArrayList; 8 7 import java.util.Arrays; … … 23 22 import org.openstreetmap.josm.data.osm.OsmPrimitive; 24 23 import org.openstreetmap.josm.data.osm.Way; 24 import org.openstreetmap.josm.gui.MainApplication; 25 import org.openstreetmap.josm.gui.MapView; 25 26 import org.openstreetmap.josm.gui.util.GuiHelper; 26 27 import org.openstreetmap.josm.io.remotecontrol.AddTagsDialog; … … 125 126 Node nd = null; 126 127 127 if (Main .isDisplayingMapView()) {128 Point p = Main.map.mapView.getPoint(ll);129 nd = Main.map.mapView.getNearestNode(p, OsmPrimitive::isUsable);128 if (MainApplication.isDisplayingMapView()) { 129 MapView mapView = MainApplication.getMap().mapView; 130 nd = mapView.getNearestNode(mapView.getPoint(ll), OsmPrimitive::isUsable); 130 131 if (nd != null && nd.getCoor().greatCircleDistance(ll) > Main.pref.getDouble("remote.tolerance", 0.1)) { 131 132 nd = null; // node is too far … … 171 172 AutoScaleAction.autoScale("selection"); 172 173 } else { 173 Main .map.mapView.repaint();174 MainApplication.getMap().mapView.repaint(); 174 175 } 175 176 return way; -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/ImageryHandler.java
r12620 r12630 10 10 import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType; 11 11 import org.openstreetmap.josm.data.imagery.ImageryLayerInfo; 12 import org.openstreetmap.josm.gui.MainApplication; 12 13 import org.openstreetmap.josm.gui.layer.ImageryLayer; 13 14 import org.openstreetmap.josm.gui.util.GuiHelper; … … 95 96 protected void handleRequest() throws RequestHandlerErrorException { 96 97 final ImageryInfo imgInfo = buildImageryInfo(); 97 if (Main .isDisplayingMapView()) {98 if (MainApplication.isDisplayingMapView()) { 98 99 for (ImageryLayer layer : Main.getLayerManager().getLayersOfType(ImageryLayer.class)) { 99 100 if (layer.getInfo().equals(imgInfo)) { -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java
r12620 r12630 26 26 import org.openstreetmap.josm.data.osm.SimplePrimitiveId; 27 27 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 28 import org.openstreetmap.josm.gui.MainApplication; 29 import org.openstreetmap.josm.gui.MapFrame; 28 30 import org.openstreetmap.josm.gui.util.GuiHelper; 29 31 import org.openstreetmap.josm.io.remotecontrol.AddTagsDialog; … … 184 186 ds.setSelected(newSel); 185 187 zoom(newSel, bbox); 186 if (Main.isDisplayingMapView() && Main.map.relationListDialog != null) { 187 Main.map.relationListDialog.selectRelations(null); // unselect all relations to fix #7342 188 Main.map.relationListDialog.dataChanged(null); 189 Main.map.relationListDialog.selectRelations(Utils.filteredCollection(newSel, Relation.class)); 188 MapFrame map = MainApplication.getMap(); 189 if (MainApplication.isDisplayingMapView() && map.relationListDialog != null) { 190 map.relationListDialog.selectRelations(null); // unselect all relations to fix #7342 191 map.relationListDialog.dataChanged(null); 192 map.relationListDialog.selectRelations(Utils.filteredCollection(newSel, Relation.class)); 190 193 } 191 194 }); … … 233 236 if (!"download".equals(args.get("zoom_mode")) && !primitives.isEmpty()) { 234 237 AutoScaleAction.autoScale("selection"); 235 } else if (Main .isDisplayingMapView()) {238 } else if (MainApplication.isDisplayingMapView()) { 236 239 // make sure this isn't called unless there *is* a MapView 237 240 GuiHelper.executeByMainWorkerInEDT(() -> { 238 241 BoundingXYVisitor bbox1 = new BoundingXYVisitor(); 239 242 bbox1.visit(bbox); 240 Main .map.mapView.zoomTo(bbox1);243 MainApplication.getMap().mapView.zoomTo(bbox1); 241 244 }); 242 245 } -
trunk/src/org/openstreetmap/josm/io/session/SessionWriter.java
r12620 r12630 32 32 import org.openstreetmap.josm.data.coor.LatLon; 33 33 import org.openstreetmap.josm.data.projection.Projections; 34 import org.openstreetmap.josm.gui.MainApplication; 35 import org.openstreetmap.josm.gui.MapView; 34 36 import org.openstreetmap.josm.gui.layer.GpxLayer; 35 37 import org.openstreetmap.josm.gui.layer.Layer; … … 262 264 Element centerEl = doc.createElement("center"); 263 265 viewportEl.appendChild(centerEl); 264 EastNorth center = Main.map.mapView.getCenter(); 266 MapView mapView = MainApplication.getMap().mapView; 267 EastNorth center = mapView.getCenter(); 265 268 LatLon centerLL = Projections.inverseProject(center); 266 269 centerEl.setAttribute("lat", Double.toString(centerLL.lat())); … … 268 271 Element scale = doc.createElement("scale"); 269 272 viewportEl.appendChild(scale); 270 double dist100px = Main.map.mapView.getDist100Pixel();273 double dist100px = mapView.getDist100Pixel(); 271 274 scale.setAttribute("meter-per-pixel", Double.toString(dist100px / 100)); 272 275 } -
trunk/src/org/openstreetmap/josm/tools/Geometry.java
r12620 r12630 35 35 import org.openstreetmap.josm.data.projection.Projection; 36 36 import org.openstreetmap.josm.data.projection.Projections; 37 import org.openstreetmap.josm.gui.MainApplication; 38 import org.openstreetmap.josm.gui.MapFrame; 37 39 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 38 40 … … 553 555 */ 554 556 public static Area getAreaLatLon(Relation multipolygon) { 555 final Multipolygon mp = Main.map == null || Main.map.mapView == null 557 MapFrame map = MainApplication.getMap(); 558 final Multipolygon mp = map == null || map.mapView == null 556 559 ? new Multipolygon(multipolygon) 557 560 : MultipolygonCache.getInstance().get(multipolygon); … … 693 696 public static double multipolygonArea(Relation multipolygon) { 694 697 double area = 0.0; 695 final Multipolygon mp = Main.map == null || Main.map.mapView == null 698 MapFrame map = MainApplication.getMap(); 699 final Multipolygon mp = map == null || map.mapView == null 696 700 ? new Multipolygon(multipolygon) 697 701 : MultipolygonCache.getInstance().get(multipolygon); -
trunk/src/org/openstreetmap/josm/tools/MultikeyActionsHandler.java
r12520 r12630 24 24 25 25 import org.openstreetmap.josm.Main; 26 import org.openstreetmap.josm.gui.MainApplication; 26 27 import org.openstreetmap.josm.tools.MultikeyShortcutAction.MultikeyInfo; 27 28 … … 42 43 @Override 43 44 public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { 44 Main .map.statusLine.resetHelpText(STATUS_BAR_ID);45 MainApplication.getMap().statusLine.resetHelpText(STATUS_BAR_ID); 45 46 } 46 47 … … 114 115 } 115 116 lastAction = null; 116 Main .map.statusLine.resetHelpText(STATUS_BAR_ID);117 MainApplication.getMap().statusLine.resetHelpText(STATUS_BAR_ID); 117 118 return true; 118 119 } … … 147 148 lastAction = this; 148 149 timer.schedule(new MyTimerTask(lastTimestamp, lastAction), DIALOG_DELAY); 149 Main .map.statusLine.setHelpText(STATUS_BAR_ID, tr("{0}... [please type its number]", (String) action.getValue(SHORT_DESCRIPTION)));150 MainApplication.getMap().statusLine.setHelpText(STATUS_BAR_ID, tr("{0}... [please type its number]", (String) action.getValue(SHORT_DESCRIPTION))); 150 151 } 151 152 -
trunk/src/org/openstreetmap/josm/tools/OsmUrlToBounds.java
r12620 r12630 15 15 import org.openstreetmap.josm.data.projection.Projection; 16 16 import org.openstreetmap.josm.data.projection.Projections; 17 import org.openstreetmap.josm.gui.MainApplication; 18 import org.openstreetmap.josm.gui.MapView; 17 19 import org.openstreetmap.josm.gui.util.GuiHelper; 18 20 … … 204 206 205 207 private static Dimension getScreenSize() { 206 if (Main.isDisplayingMapView()) { 207 return new Dimension(Main.map.mapView.getWidth(), Main.map.mapView.getHeight()); 208 if (MainApplication.isDisplayingMapView()) { 209 MapView mapView = MainApplication.getMap().mapView; 210 return new Dimension(mapView.getWidth(), mapView.getHeight()); 208 211 } else { 209 212 return GuiHelper.getScreenSize(); -
trunk/test/performance/org/openstreetmap/josm/gui/mappaint/MapRendererPerformanceTest.java
r12620 r12630 26 26 import org.junit.rules.Timeout; 27 27 import org.openstreetmap.josm.JOSMFixture; 28 import org.openstreetmap.josm.Main;29 28 import org.openstreetmap.josm.PerformanceTestUtils; 30 29 import org.openstreetmap.josm.TestUtils; … … 36 35 import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer.StyleRecord; 37 36 import org.openstreetmap.josm.data.projection.Projections; 37 import org.openstreetmap.josm.gui.MainApplication; 38 38 import org.openstreetmap.josm.gui.NavigatableComponent; 39 39 import org.openstreetmap.josm.gui.mappaint.StyleSetting.BooleanStyleSetting; … … 95 95 g.setColor(Color.BLACK); 96 96 g.fillRect(0, 0, IMG_WIDTH, IMG_WIDTH); 97 nc = Main .map.mapView;97 nc = MainApplication.getMap().mapView; 98 98 nc.setBounds(0, 0, IMG_WIDTH, IMG_HEIGHT); 99 99 -
trunk/test/unit/org/openstreetmap/josm/actions/mapmode/AddNoteActionTest.java
r12563 r12630 13 13 import org.openstreetmap.josm.data.osm.DataSet; 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.layer.OsmDataLayer; 16 18 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 39 41 Main.getLayerManager().addLayer(layer); 40 42 AddNoteAction mapMode = new AddNoteAction(new NoteData(Collections.<Note>emptyList())); 41 MapMode oldMapMode = Main.map.mapMode; 42 assertTrue(Main.map.selectMapMode(mapMode)); 43 assertEquals(mapMode, Main.map.mapMode); 44 assertTrue(Main.map.selectMapMode(oldMapMode)); 43 MapFrame map = MainApplication.getMap(); 44 MapMode oldMapMode = map.mapMode; 45 assertTrue(map.selectMapMode(mapMode)); 46 assertEquals(mapMode, map.mapMode); 47 assertTrue(map.selectMapMode(oldMapMode)); 45 48 } finally { 46 49 Main.getLayerManager().removeLayer(layer); -
trunk/test/unit/org/openstreetmap/josm/actions/mapmode/DeleteActionTest.java
r12563 r12630 11 11 import org.openstreetmap.josm.actions.mapmode.DeleteAction.DeleteMode; 12 12 import org.openstreetmap.josm.data.osm.DataSet; 13 import org.openstreetmap.josm.gui.MainApplication; 14 import org.openstreetmap.josm.gui.MapFrame; 13 15 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 14 16 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 37 39 Main.getLayerManager().addLayer(layer); 38 40 DeleteAction mapMode = new DeleteAction(); 39 MapMode oldMapMode = Main.map.mapMode; 40 assertTrue(Main.map.selectMapMode(mapMode)); 41 assertEquals(mapMode, Main.map.mapMode); 42 assertTrue(Main.map.selectMapMode(oldMapMode)); 41 MapFrame map = MainApplication.getMap(); 42 MapMode oldMapMode = map.mapMode; 43 assertTrue(map.selectMapMode(mapMode)); 44 assertEquals(mapMode, map.mapMode); 45 assertTrue(map.selectMapMode(oldMapMode)); 43 46 } finally { 44 47 Main.getLayerManager().removeLayer(layer); -
trunk/test/unit/org/openstreetmap/josm/actions/mapmode/DrawActionTest.java
r12563 r12630 23 23 import org.openstreetmap.josm.data.osm.OsmPrimitive; 24 24 import org.openstreetmap.josm.data.osm.Way; 25 import org.openstreetmap.josm.gui.MainApplication; 26 import org.openstreetmap.josm.gui.MapFrame; 25 27 import org.openstreetmap.josm.gui.OsmPrimitivRenderer; 26 28 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 56 58 57 59 // fix map view position 58 Main.map.mapView.zoomTo(new EastNorth(0, 0), 1); 60 MapFrame map = MainApplication.getMap(); 61 map.mapView.zoomTo(new EastNorth(0, 0), 1); 59 62 60 63 Node n1 = new Node(new EastNorth(0, 0)); … … 69 72 70 73 try { 71 assertTrue( Main.map.selectDrawTool(false));74 assertTrue(map.selectDrawTool(false)); 72 75 73 Main.map.mapModeDraw.mouseReleased(new MouseEvent(74 Main.map,76 map.mapModeDraw.mouseReleased(new MouseEvent( 77 map, 75 78 MouseEvent.MOUSE_RELEASED, 76 79 2000, -
trunk/test/unit/org/openstreetmap/josm/actions/mapmode/ExtrudeActionTest.java
r12563 r12630 11 11 import org.openstreetmap.josm.actions.mapmode.ExtrudeAction.Mode; 12 12 import org.openstreetmap.josm.data.osm.DataSet; 13 import org.openstreetmap.josm.gui.MainApplication; 14 import org.openstreetmap.josm.gui.MapFrame; 13 15 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 14 16 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 37 39 Main.getLayerManager().addLayer(layer); 38 40 ExtrudeAction mapMode = new ExtrudeAction(); 39 MapMode oldMapMode = Main.map.mapMode; 40 assertTrue(Main.map.selectMapMode(mapMode)); 41 assertEquals(mapMode, Main.map.mapMode); 42 assertTrue(Main.map.selectMapMode(oldMapMode)); 41 MapFrame map = MainApplication.getMap(); 42 MapMode oldMapMode = map.mapMode; 43 assertTrue(map.selectMapMode(mapMode)); 44 assertEquals(mapMode, map.mapMode); 45 assertTrue(map.selectMapMode(oldMapMode)); 43 46 } finally { 44 47 Main.getLayerManager().removeLayer(layer); -
trunk/test/unit/org/openstreetmap/josm/actions/mapmode/ImproveWayAccuracyActionTest.java
r12563 r12630 11 11 import org.openstreetmap.josm.actions.mapmode.ImproveWayAccuracyAction.State; 12 12 import org.openstreetmap.josm.data.osm.DataSet; 13 import org.openstreetmap.josm.gui.MainApplication; 14 import org.openstreetmap.josm.gui.MapFrame; 13 15 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 14 16 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 37 39 Main.getLayerManager().addLayer(layer); 38 40 ImproveWayAccuracyAction mapMode = new ImproveWayAccuracyAction(); 39 MapMode oldMapMode = Main.map.mapMode; 40 assertTrue(Main.map.selectMapMode(mapMode)); 41 assertEquals(mapMode, Main.map.mapMode); 42 assertTrue(Main.map.selectMapMode(oldMapMode)); 41 MapFrame map = MainApplication.getMap(); 42 MapMode oldMapMode = map.mapMode; 43 assertTrue(map.selectMapMode(mapMode)); 44 assertEquals(mapMode, map.mapMode); 45 assertTrue(map.selectMapMode(oldMapMode)); 43 46 } finally { 44 47 Main.getLayerManager().removeLayer(layer); -
trunk/test/unit/org/openstreetmap/josm/actions/mapmode/ParallelWayActionTest.java
r12563 r12630 12 12 import org.openstreetmap.josm.actions.mapmode.ParallelWayAction.Modifier; 13 13 import org.openstreetmap.josm.data.osm.DataSet; 14 import org.openstreetmap.josm.gui.MainApplication; 15 import org.openstreetmap.josm.gui.MapFrame; 14 16 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 15 17 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 37 39 try { 38 40 Main.getLayerManager().addLayer(layer); 39 ParallelWayAction mapMode = new ParallelWayAction(Main.map); 40 MapMode oldMapMode = Main.map.mapMode; 41 assertTrue(Main.map.selectMapMode(mapMode)); 42 assertEquals(mapMode, Main.map.mapMode); 43 assertTrue(Main.map.selectMapMode(oldMapMode)); 41 MapFrame map = MainApplication.getMap(); 42 ParallelWayAction mapMode = new ParallelWayAction(map); 43 MapMode oldMapMode = map.mapMode; 44 assertTrue(map.selectMapMode(mapMode)); 45 assertEquals(mapMode, map.mapMode); 46 assertTrue(map.selectMapMode(oldMapMode)); 44 47 } finally { 45 48 Main.getLayerManager().removeLayer(layer); -
trunk/test/unit/org/openstreetmap/josm/actions/mapmode/PlayHeadDragModeTest.java
r12563 r12630 9 9 import org.openstreetmap.josm.Main; 10 10 import org.openstreetmap.josm.data.osm.DataSet; 11 import org.openstreetmap.josm.gui.MainApplication; 12 import org.openstreetmap.josm.gui.MapFrame; 11 13 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 12 14 import org.openstreetmap.josm.gui.layer.markerlayer.PlayHeadMarker; … … 36 38 Main.getLayerManager().addLayer(layer); 37 39 PlayHeadDragMode mapMode = new PlayHeadDragMode(PlayHeadMarker.create()); 38 MapMode oldMapMode = Main.map.mapMode; 39 assertTrue(Main.map.selectMapMode(mapMode)); 40 assertEquals(mapMode, Main.map.mapMode); 41 assertTrue(Main.map.selectMapMode(oldMapMode)); 40 MapFrame map = MainApplication.getMap(); 41 MapMode oldMapMode = map.mapMode; 42 assertTrue(map.selectMapMode(mapMode)); 43 assertEquals(mapMode, map.mapMode); 44 assertTrue(map.selectMapMode(oldMapMode)); 42 45 } finally { 43 46 Main.getLayerManager().removeLayer(layer); -
trunk/test/unit/org/openstreetmap/josm/actions/mapmode/SelectActionTest.java
r12563 r12630 22 22 import org.openstreetmap.josm.data.osm.Node; 23 23 import org.openstreetmap.josm.data.osm.Way; 24 import org.openstreetmap.josm.gui.MainApplication; 24 25 import org.openstreetmap.josm.gui.MapFrame; 25 26 import org.openstreetmap.josm.gui.layer.MainLayerManager; … … 90 91 Main.getLayerManager().addLayer(layer); 91 92 try { 92 SelectAction action = new SelectActionMock(Main.map, dataSet, layer); 93 MapFrame map = MainApplication.getMap(); 94 SelectAction action = new SelectActionMock(map, dataSet, layer); 93 95 nodesMerged = false; 94 96 … … 97 99 98 100 MouseEvent event; 99 event = new MouseEvent( Main.map,101 event = new MouseEvent(map, 100 102 MouseEvent.MOUSE_PRESSED, 101 103 0, … … 105 107 false, MouseEvent.BUTTON1); 106 108 action.mousePressed(event); 107 event = new MouseEvent( Main.map,109 event = new MouseEvent(map, 108 110 MouseEvent.MOUSE_DRAGGED, 109 111 1000, … … 113 115 false, MouseEvent.BUTTON1); 114 116 action.mouseDragged(event); 115 event = new MouseEvent( Main.map,117 event = new MouseEvent(map, 116 118 MouseEvent.MOUSE_RELEASED, 117 119 2000, -
trunk/test/unit/org/openstreetmap/josm/gui/MapScalerTest.java
r12564 r12630 38 38 Main.getLayerManager().addLayer(new OsmDataLayer(new DataSet(), "", null)); 39 39 assertEquals(Color.WHITE, MapScaler.getColor()); 40 MapScaler ms = new MapScaler(Main .map.mapView);40 MapScaler ms = new MapScaler(MainApplication.getMap().mapView); 41 41 assertEquals("/MapView/Scaler", ms.helpTopic()); 42 42 ms.paint(TestUtils.newGraphics()); -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/CommandStackDialogTest.java
r12564 r12630 11 11 import org.openstreetmap.josm.command.Command; 12 12 import org.openstreetmap.josm.data.osm.DataSet; 13 import org.openstreetmap.josm.gui.MainApplication; 14 import org.openstreetmap.josm.gui.MapFrame; 13 15 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 14 16 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 57 59 assertFalse(Main.main.undoRedo.redoCommands.isEmpty()); 58 60 61 MapFrame map = MainApplication.getMap(); 59 62 CommandStackDialog dlg = new CommandStackDialog(); 60 Main.map.addToggleDialog(dlg);63 map.addToggleDialog(dlg); 61 64 dlg.unfurlDialog(); 62 65 assertTrue(dlg.isVisible()); 63 Main.map.removeToggleDialog(dlg);66 map.removeToggleDialog(dlg); 64 67 dlg.hideDialog(); 65 68 assertFalse(dlg.isVisible()); -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/ConflictDialogTest.java
r12564 r12630 17 17 import org.openstreetmap.josm.data.osm.RelationMember; 18 18 import org.openstreetmap.josm.data.osm.Way; 19 import org.openstreetmap.josm.gui.MainApplication; 19 20 import org.openstreetmap.josm.gui.dialogs.ConflictDialog.ConflictPainter; 20 21 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 57 58 public void testConflictPainter() { 58 59 Main.getLayerManager().addLayer(new OsmDataLayer(new DataSet(), "", null)); 59 ConflictPainter cp = new ConflictPainter(Main.map.mapView, new BufferedImage(800, 600, BufferedImage.TYPE_3BYTE_BGR).createGraphics()); 60 ConflictPainter cp = new ConflictPainter(MainApplication.getMap().mapView, 61 new BufferedImage(800, 600, BufferedImage.TYPE_3BYTE_BGR).createGraphics()); 60 62 Node n1 = new Node(1, 1); 61 63 n1.setCoor(new LatLon(1, 1)); -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/MapPaintDialogTest.java
r12564 r12630 6 6 import org.openstreetmap.josm.Main; 7 7 import org.openstreetmap.josm.data.osm.DataSet; 8 import org.openstreetmap.josm.gui.MainApplication; 8 9 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 9 10 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 29 30 public void testInfoAction() { 30 31 Main.getLayerManager().addLayer(new OsmDataLayer(new DataSet(), "", null)); 31 Main .map.mapPaintDialog.new InfoAction().actionPerformed(null);32 MainApplication.getMap().mapPaintDialog.new InfoAction().actionPerformed(null); 32 33 } 33 34 } -
trunk/test/unit/org/openstreetmap/josm/gui/layer/GpxLayerTest.java
r12568 r12630 24 24 import org.openstreetmap.josm.data.osm.DataSet; 25 25 import org.openstreetmap.josm.data.projection.Projections; 26 import org.openstreetmap.josm.gui.MainApplication; 26 27 import org.openstreetmap.josm.gui.widgets.HtmlPanel; 27 28 import org.openstreetmap.josm.io.GpxReaderTest; … … 211 212 Main.getLayerManager().addLayer(layer); 212 213 assertTrue(layer.getMenuEntries().length > 0); 213 layer.paint(TestUtils.newGraphics(), Main .map.mapView, layer.data.getMetaBounds());214 layer.paint(TestUtils.newGraphics(), MainApplication.getMap().mapView, layer.data.getMetaBounds()); 214 215 } finally { 215 216 Main.getLayerManager().removeLayer(layer); -
trunk/test/unit/org/openstreetmap/josm/gui/layer/MarkerLayerTest.java
r12564 r12630 10 10 import org.openstreetmap.josm.data.gpx.GpxData; 11 11 import org.openstreetmap.josm.data.osm.DataSet; 12 import org.openstreetmap.josm.gui.MainApplication; 13 import org.openstreetmap.josm.gui.MapFrame; 12 14 import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer; 13 15 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 32 34 @Test 33 35 public void testPlayHeadMarker() { 36 MapFrame map = MainApplication.getMap(); 34 37 try { 35 38 Main.getLayerManager().addLayer(new OsmDataLayer(new DataSet(), "", null)); 36 39 MarkerLayer layer = new MarkerLayer(new GpxData(), null, null, null); 37 assertNull( Main.map.mapView.playHeadMarker);40 assertNull(map.mapView.playHeadMarker); 38 41 Main.getLayerManager().addLayer(layer); 39 assertNotNull( Main.map.mapView.playHeadMarker);42 assertNotNull(map.mapView.playHeadMarker); 40 43 Main.getLayerManager().removeLayer(layer); 41 44 } finally { 42 Main.map.mapView.playHeadMarker = null;45 map.mapView.playHeadMarker = null; 43 46 } 44 47 } -
trunk/test/unit/org/openstreetmap/josm/gui/layer/OsmDataLayerTest.java
r12159 r12630 22 22 import org.openstreetmap.josm.data.osm.Relation; 23 23 import org.openstreetmap.josm.data.osm.Way; 24 import org.openstreetmap.josm.gui.MainApplication; 24 25 25 26 /** … … 136 137 Main.getLayerManager().addLayer(layer); 137 138 assertTrue(layer.getMenuEntries().length > 0); 138 layer.paint(TestUtils.newGraphics(), Main .map.mapView, new Bounds(LatLon.ZERO));139 layer.paint(TestUtils.newGraphics(), MainApplication.getMap().mapView, new Bounds(LatLon.ZERO)); 139 140 } finally { 140 141 Main.getLayerManager().removeLayer(layer); -
trunk/test/unit/org/openstreetmap/josm/io/NoteImporterTest.java
r10432 r12630 11 11 import org.openstreetmap.josm.Main; 12 12 import org.openstreetmap.josm.TestUtils; 13 import org.openstreetmap.josm.gui.MainApplication; 13 14 import org.openstreetmap.josm.testutils.JOSMTestRules; 14 15 … … 30 31 public void testTicket12531() { 31 32 Main.getLayerManager().resetState(); 32 assertNull(Main .map);33 assertNull(MainApplication.getMap()); 33 34 assertTrue(new NoteImporter().importDataHandleExceptions( 34 35 new File(TestUtils.getRegressionDataFile(12531, "notes.osn")), null));
Note:
See TracChangeset
for help on using the changeset viewer.