Ignore:
Timestamp:
2023-10-31T17:55:32+01:00 (13 months ago)
Author:
taylor.smock
Message:

Fix #23241: Image icons disappear when moving them

When an image is moved, ImageData#updateImagePosition must be called in order
to reindex the image geographically.

Also fix some SonarLint issues.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/photoadjust/src/org/openstreetmap/josm/plugins/photoadjust/PhotoAdjustWorker.java

    r35978 r36188  
    22package org.openstreetmap.josm.plugins.photoadjust;
    33
     4import java.awt.event.InputEvent;
    45import java.awt.event.MouseEvent;
    56import java.util.List;
     
    2627    // the photo is moved very far.
    2728    private EastNorth dragOffset;
    28     private boolean centerViewIsDisabled = false;
    29     private boolean centerViewNeedsEnable = false;
     29    private boolean centerViewIsDisabled;
     30    private boolean centerViewNeedsEnable;
    3031
    3132    /**
     
    8283            // Check if modifier key is pressed and change to
    8384            // image viewer photo if it is.
    84             final boolean isAlt = (evt.getModifiersEx() & MouseEvent.ALT_DOWN_MASK) == MouseEvent.ALT_DOWN_MASK;
    85             final boolean isCtrl = (evt.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) == MouseEvent.CTRL_DOWN_MASK;
    86             final boolean isShift = (evt.getModifiersEx() & MouseEvent.SHIFT_DOWN_MASK) == MouseEvent.SHIFT_DOWN_MASK;
     85            final boolean isAlt = (evt.getModifiersEx() & InputEvent.ALT_DOWN_MASK) == InputEvent.ALT_DOWN_MASK;
     86            final boolean isCtrl = (evt.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) == InputEvent.CTRL_DOWN_MASK;
     87            final boolean isShift = (evt.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) == InputEvent.SHIFT_DOWN_MASK;
    8788            // ignore key press with shift, to not conflict with selection
    8889            if (isShift) {
     
    112113                                        changeDirection(img, layer.getImageData(), evt);
    113114                                    }
    114                                 } else if (isCtrl && isAlt) {
     115                                } else if (isCtrl) {
    115116                                    movePhoto(img, layer.getImageData(), evt);
    116117                                }
     
    155156    public void doMouseDragged(MouseEvent evt) {
    156157        if (dragData != null && dragPhoto != null) {
    157             if ((evt.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) == MouseEvent.CTRL_DOWN_MASK) {
     158            if ((evt.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) == InputEvent.CTRL_DOWN_MASK) {
    158159                if (dragData.isImageSelected(dragPhoto)) {
    159160                    for (ImageEntry photo: dragData.getSelectedImages()) {
     
    200201     * @param evt Mouse event from one of the mouse adapters.
    201202     */
    202     private void movePhoto(ImageEntry photo, ImageData data, MouseEvent evt) {
     203    private static void movePhoto(ImageEntry photo, ImageData data, MouseEvent evt) {
    203204        LatLon newPos = MainApplication.getMap().mapView.getLatLon(evt.getX(), evt.getY());
    204205        data.updateImagePosition(photo, newPos);
     
    214215        final EastNorth newPosEN = startEN.add(translation);
    215216        final LatLon newPos = MainApplication.getMap().mapView.getProjection().eastNorth2latlon(newPosEN);
    216         photo.setPos(newPos);
    217         photo.flagNewGpsData();
     217        dragData.updateImagePosition(photo, newPos);
    218218    }
    219219
Note: See TracChangeset for help on using the changeset viewer.