Changeset 35740 in osm for applications/editors/josm/plugins
- Timestamp:
- 2021-05-02T11:21:05+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/buildings_tools/src/org/openstreetmap/josm/plugins/buildings_tools/DrawBuildingAction.java
r35669 r35740 40 40 import org.openstreetmap.josm.gui.util.KeyPressReleaseListener; 41 41 import org.openstreetmap.josm.gui.util.ModifierExListener; 42 import org.openstreetmap.josm.spi.preferences.Config; 43 import org.openstreetmap.josm.spi.preferences.PreferenceChangedListener; 42 44 import org.openstreetmap.josm.tools.Geometry; 43 45 import org.openstreetmap.josm.tools.ImageProvider; … … 51 53 } 52 54 53 private final Cursor cursorCrosshair;54 55 private final Cursor cursorJoinNode; 55 56 private final Cursor cursorJoinWay; … … 65 66 66 67 final transient Building building = new Building(); 68 69 private final PreferenceChangedListener shapeChangeListener = event -> updCursor(); 67 70 68 71 public DrawBuildingAction() { … … 71 74 tr("Mode: {0}", tr("Draw buildings")), 72 75 KeyEvent.VK_B, Shortcut.DIRECT), 73 getCursor()); 74 75 cursorCrosshair = getCursor(); 76 // Set super.cursor to crosshair without overlay because super.cursor is final, 77 // but we use two different cursors with overlays for rectangular and circular buildings 78 // the actual cursor is drawn in enterMode() 79 ImageProvider.getCursor("crosshair", null)); 80 81 currCursor = getCursor(); 76 82 cursorJoinNode = ImageProvider.getCursor("crosshair", "joinnode"); 77 83 cursorJoinWay = ImageProvider.getCursor("crosshair", "joinway"); 78 currCursor = cursorCrosshair;79 84 } 80 85 … … 134 139 public void enterMode() { 135 140 super.enterMode(); 141 136 142 MapFrame map = MainApplication.getMap(); 137 143 if (getLayerManager().getEditDataSet() == null) { … … 140 146 } 141 147 selectedColor = new NamedColorProperty(marktr("selected"), selectedColor).get(); 142 currCursor = cursorCrosshair;143 148 map.mapView.addMouseListener(this); 144 149 map.mapView.addMouseMotionListener(this); … … 147 152 map.keyDetector.addModifierExListener(this); 148 153 SelectionEventManager.getInstance().addSelectionListener(this); 154 Config.getPref().addKeyPreferenceChangeListener("buildings_tool.shape", shapeChangeListener); 155 149 156 updateSnap(getLayerManager().getEditDataSet().getSelected()); 157 // super.enterMode() draws the basic cursor. Overwrite it with the cursor for the current building mode. 158 updCursor(); 150 159 } 151 160 … … 160 169 map.keyDetector.removeModifierExListener(this); 161 170 SelectionEventManager.getInstance().removeSelectionListener(this); 171 Config.getPref().removeKeyPreferenceChangeListener("buildings_tool.shape", shapeChangeListener); 172 162 173 if (mode != Mode.None) 163 174 map.mapView.repaint(); … … 386 397 387 398 private void updCursor() { 388 if (mousePos == null)389 return;390 399 if (!MainApplication.isDisplayingMapView()) 391 400 return; 392 Node n = null; 393 if (!ctrl ) {394 n = MainApplication.getMap().mapView.getNearestNode(mousePos, OsmPrimitive::isSelectable);401 402 if (!ctrl && (mousePos != null)) { 403 Node n = MainApplication.getMap().mapView.getNearestNode(mousePos, OsmPrimitive::isSelectable); 395 404 if (n != null) { 396 405 setCursor(cursorJoinNode);
Note:
See TracChangeset
for help on using the changeset viewer.