Ticket #20564: 20564.patch

File 20564.patch, 3.1 KB (added by Solarspot, 4 years ago)
  • plugins/buildings_tools/src/org/openstreetmap/josm/plugins/buildings_tools/DrawBuildingAction.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/plugins/buildings_tools/src/org/openstreetmap/josm/plugins/buildings_tools/DrawBuildingAction.java b/plugins/buildings_tools/src/org/openstreetmap/josm/plugins/buildings_tools/DrawBuildingAction.java
    a b  
    5050        None, Drawing, DrawingWidth, DrawingAngFix
    5151    }
    5252
    53     private final Cursor cursorCrosshair;
    5453    private final Cursor cursorJoinNode;
    5554    private final Cursor cursorJoinWay;
    5655    private Cursor currCursor;
     
    7069                Shortcut.registerShortcut("mapmode:buildings",
    7170                        tr("Mode: {0}", tr("Draw buildings")),
    7271                        KeyEvent.VK_B, Shortcut.DIRECT),
    73                 getCursor());
     72                // Set super.cursor to crosshair without overlay because super.cursor is final,
     73                // but we use two different cursors with overlays for rectangular and circular buildings
     74                // the actual cursor is drawn in enterMode()
     75                ImageProvider.getCursor("crosshair", null));
    7476
    75         cursorCrosshair = getCursor();
     77        currCursor = getCursor();
    7678        cursorJoinNode = ImageProvider.getCursor("crosshair", "joinnode");
    7779        cursorJoinWay = ImageProvider.getCursor("crosshair", "joinway");
    78         currCursor = cursorCrosshair;
    7980    }
    8081
    8182    private static Cursor getCursor() {
     
    133134    @Override
    134135    public void enterMode() {
    135136        super.enterMode();
     137        // super.enterMode() draws the basic cursor. Overwrite it immediately with the cursor for the current building mode.
     138        updCursor();
    136139        MapFrame map = MainApplication.getMap();
    137140        if (getLayerManager().getEditDataSet() == null) {
    138141            map.selectSelectTool(false);
    139142            return;
    140143        }
    141144        selectedColor = new NamedColorProperty(marktr("selected"), selectedColor).get();
    142         currCursor = cursorCrosshair;
    143145        map.mapView.addMouseListener(this);
    144146        map.mapView.addMouseMotionListener(this);
    145147        map.mapView.addTemporaryLayer(this);
     
    385387    }
    386388
    387389    private void updCursor() {
    388         if (mousePos == null)
    389             return;
    390390        if (!MainApplication.isDisplayingMapView())
    391391            return;
    392         Node n = null;
    393         if (!ctrl) {
    394             n = MainApplication.getMap().mapView.getNearestNode(mousePos, OsmPrimitive::isSelectable);
     392
     393        if (!ctrl && (mousePos != null)) {
     394            Node n = MainApplication.getMap().mapView.getNearestNode(mousePos, OsmPrimitive::isSelectable);
    395395            if (n != null) {
    396396                setCursor(cursorJoinNode);
    397397                return;