Ticket #23422: 23422.patch
| File 23422.patch, 5.4 KB (added by , 23 months ago) |
|---|
-
src/org/openstreetmap/josm/actions/mapmode/ParallelWayAction.java
125 125 126 126 private boolean snap; 127 127 128 private final MapView mv;129 130 128 // Mouse tracking state 131 129 private Point mousePressedPos; 132 130 private boolean mouseIsDown; … … 145 143 * Constructs a new {@code ParallelWayAction}. 146 144 * @param mapFrame Map frame 147 145 */ 148 public ParallelWayAction( MapFrame mapFrame) {146 public ParallelWayAction() { 149 147 super(tr("Parallel"), "parallel", tr("Make parallel copies of ways"), 150 148 Shortcut.registerShortcut("mapmode:parallel", tr("Mode: {0}", 151 149 tr("Parallel")), KeyEvent.VK_P, Shortcut.SHIFT), 152 150 ImageProvider.getCursor("normal", "parallel")); 153 151 setHelpId(ht("/Action/Parallel")); 154 mv = mapFrame.mapView;155 152 } 156 153 157 154 @Override … … 163 160 164 161 // #19887: overwrite default: we want to show the distance to the original way 165 162 MainApplication.getMap().statusLine.setAutoLength(false); 166 163 MapView mv = MainApplication.getMap().mapView; 167 164 mv.addMouseListener(this); 168 165 mv.addMouseMotionListener(this); 169 166 mv.addTemporaryLayer(temporaryLayer); … … 179 176 @Override 180 177 public void exitMode() { 181 178 super.exitMode(); 179 MapView mv = MainApplication.getMap().mapView; 182 180 mv.removeMouseListener(this); 183 181 mv.removeMouseMotionListener(this); 184 182 mv.removeTemporaryLayer(temporaryLayer); … … 213 211 214 212 @Override 215 213 public void modifiersExChanged(int modifiers) { 216 if ( MainApplication.getMap() == null || mv == null || !mv.isActiveLayerDrawable())214 if (!MainApplication.isDisplayingMapView() || !MainApplication.getMap().mapView.isActiveLayerDrawable()) 217 215 return; 218 216 219 217 // Should only get InputEvents due to the mask in enterMode … … 247 245 default: throw new AssertionError(); 248 246 } 249 247 if (newCursor != null) { 250 mv.setNewCursor(newCursor, this);248 MainApplication.getMap().mapView.setNewCursor(newCursor, this); 251 249 } 252 250 } 253 251 … … 258 256 } 259 257 260 258 private boolean sanityCheck() { 259 MapView mv = MainApplication.getMap().mapView; 261 260 // @formatter:off 262 261 boolean areWeSane = 263 262 mv.isActiveLayerVisible() && … … 303 302 304 303 if (!mouseHasBeenDragged) { 305 304 // use point from press or click event? (or are these always the same) 306 Way nearestWay = mv.getNearestWay(e.getPoint(), OsmPrimitive::isSelectable);305 Way nearestWay = MainApplication.getMap().mapView.getNearestWay(e.getPoint(), OsmPrimitive::isSelectable); 307 306 if (nearestWay == null) { 308 307 if (matchesCurrentModifiers(SET_SELECTED_MODIFIER_COMBO)) { 309 308 clearSourceWays(); … … 381 380 382 381 // Calculate distance to the reference line 383 382 Point p = e.getPoint(); 383 MapView mv = MainApplication.getMap().mapView; 384 384 EastNorth enp = mv.getEastNorth((int) p.getX(), (int) p.getY()); 385 385 EastNorth nearestPointOnRefLine = Geometry.closestPointToLine(referenceSegment.getFirstNode().getEastNorth(), 386 386 referenceSegment.getSecondNode().getEastNorth(), enp); … … 498 498 499 499 // TODO: rename 500 500 private boolean initParallelWays(Point p, boolean copyTags) { 501 referenceSegment = mv.getNearestWaySegment(p, OsmPrimitive::isUsable, true);501 referenceSegment = MainApplication.getMap().mapView.getNearestWaySegment(p, OsmPrimitive::isUsable, true); 502 502 if (referenceSegment == null) 503 503 return false; 504 504 -
src/org/openstreetmap/josm/gui/MapFrame.java
251 251 addMapMode(new IconToggleButton(mapModeDraw, false)); 252 252 addMapMode(new IconToggleButton(mapModeZoom, true)); 253 253 addMapMode(new IconToggleButton(mapModeDelete, true)); 254 addMapMode(new IconToggleButton(new ParallelWayAction( this), true));254 addMapMode(new IconToggleButton(new ParallelWayAction(), true)); 255 255 addMapMode(new IconToggleButton(new ExtrudeAction(), true)); 256 256 addMapMode(new IconToggleButton(new ImproveWayAccuracyAction(), false)); 257 257 addMapMode(new IconToggleButton(new SplitMode(), false)); -
test/unit/org/openstreetmap/josm/actions/mapmode/ParallelWayActionTest.java
30 30 try { 31 31 MainApplication.getLayerManager().addLayer(layer); 32 32 MapFrame map = MainApplication.getMap(); 33 ParallelWayAction mapMode = new ParallelWayAction( map);33 ParallelWayAction mapMode = new ParallelWayAction(); 34 34 MapMode oldMapMode = map.mapMode; 35 35 assertTrue(map.selectMapMode(mapMode)); 36 36 assertEquals(mapMode, map.mapMode);
