diff --git a/src/org/openstreetmap/josm/gui/MapMover.java b/src/org/openstreetmap/josm/gui/MapMover.java
index ed694864cc..c2338f6e53 100644
|
a
|
b
|
public class MapMover extends MouseAdapter implements Destroyable {
|
| 185 | 185 | if (allowMovement) { |
| 186 | 186 | doMoveForDrag(e); |
| 187 | 187 | } else { |
| 188 | | endMovement(); |
| | 188 | endMovement(e); |
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | 191 | |
| … |
… |
public class MapMover extends MouseAdapter implements Destroyable {
|
| 195 | 195 | } |
| 196 | 196 | EastNorth center = nc.getCenter(); |
| 197 | 197 | EastNorth mouseCenter = nc.getEastNorth(e.getX(), e.getY()); |
| 198 | | nc.zoomTo(mousePosMoveStart.getEastNorth().add(center).subtract(mouseCenter)); |
| | 198 | nc.zoomTo(e, mousePosMoveStart.getEastNorth().add(center).subtract(mouseCenter)); |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
| … |
… |
public class MapMover extends MouseAdapter implements Destroyable {
|
| 217 | 217 | @Override |
| 218 | 218 | public void mouseReleased(MouseEvent e) { |
| 219 | 219 | if (e.getButton() == MouseEvent.BUTTON3 || (PlatformManager.isPlatformOsx() && e.getButton() == MouseEvent.BUTTON1)) { |
| 220 | | endMovement(); |
| | 220 | endMovement(e); |
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | 223 | |
| … |
… |
public class MapMover extends MouseAdapter implements Destroyable {
|
| 237 | 237 | /** |
| 238 | 238 | * End the movement. Setting back the cursor and clear the movement variables |
| 239 | 239 | */ |
| 240 | | private void endMovement() { |
| | 240 | private void endMovement(MouseEvent e) { |
| 241 | 241 | if (!movementInProgress()) { |
| 242 | 242 | return; |
| 243 | 243 | } |
| | 244 | doMoveForDrag(e); |
| 244 | 245 | nc.resetCursor(this); |
| 245 | 246 | mousePosMoveStart = null; |
| 246 | 247 | MainApplication.getLayerManager().getLayers().forEach(Layer::invalidate); |
| … |
… |
public class MapMover extends MouseAdapter implements Destroyable {
|
| 270 | 271 | if (e.getModifiersEx() == MouseEvent.CTRL_DOWN_MASK) { |
| 271 | 272 | doMoveForDrag(e); |
| 272 | 273 | } else { |
| 273 | | endMovement(); |
| | 274 | endMovement(e); |
| 274 | 275 | } |
| 275 | 276 | } |
| 276 | 277 | } |
diff --git a/src/org/openstreetmap/josm/gui/NavigatableComponent.java b/src/org/openstreetmap/josm/gui/NavigatableComponent.java
index cde5057396..224d980482 100644
|
a
|
b
|
import java.awt.event.ComponentAdapter;
|
| 8 | 8 | import java.awt.event.ComponentEvent; |
| 9 | 9 | import java.awt.event.HierarchyEvent; |
| 10 | 10 | import java.awt.event.HierarchyListener; |
| | 11 | import java.awt.event.InputEvent; |
| | 12 | import java.awt.event.MouseEvent; |
| 11 | 13 | import java.awt.geom.AffineTransform; |
| 12 | 14 | import java.awt.geom.Point2D; |
| 13 | 15 | import java.nio.charset.StandardCharsets; |
| … |
… |
public class NavigatableComponent extends JComponent implements Helpful {
|
| 77 | 79 | |
| 78 | 80 | /** |
| 79 | 81 | * Interface to notify listeners of the change of the zoom area. |
| | 82 | * If you need to not paint during panning, override {@link #zoomChanged(InputEvent)}. |
| 80 | 83 | * @since 10600 (functional interface) |
| 81 | 84 | */ |
| 82 | 85 | @FunctionalInterface |
| … |
… |
public class NavigatableComponent extends JComponent implements Helpful {
|
| 85 | 88 | * Method called when the zoom area has changed. |
| 86 | 89 | */ |
| 87 | 90 | void zoomChanged(); |
| | 91 | |
| | 92 | /** |
| | 93 | * Method called when the zoom area has changed. |
| | 94 | * @param event The originating input event. May be {@code null}. |
| | 95 | * @since xxx |
| | 96 | */ |
| | 97 | default void zoomChanged(InputEvent event) { |
| | 98 | zoomChanged(); |
| | 99 | } |
| 88 | 100 | } |
| 89 | 101 | |
| 90 | 102 | /** |
| … |
… |
public class NavigatableComponent extends JComponent implements Helpful {
|
| 141 | 153 | } |
| 142 | 154 | } |
| 143 | 155 | |
| | 156 | /** |
| | 157 | * Fire zoom changed events. Kept for backwards compatibility. |
| | 158 | * @deprecated Since xxx, use {@link #fireZoomChanged(InputEvent)} instead ({@code null} safe) |
| | 159 | */ |
| | 160 | @Deprecated |
| 144 | 161 | protected static void fireZoomChanged() { |
| | 162 | |
| | 163 | } |
| | 164 | |
| | 165 | protected static void fireZoomChanged(InputEvent originatingEvent) { |
| 145 | 166 | GuiHelper.runInEDTAndWait(() -> { |
| 146 | 167 | for (ZoomChangeListener l : zoomChangeListeners) { |
| 147 | | l.zoomChanged(); |
| | 168 | l.zoomChanged(originatingEvent); |
| 148 | 169 | } |
| 149 | 170 | }); |
| | 171 | // Just in case someone, somewhere, decided to subclass this and override fireZoomChanged. |
| | 172 | fireZoomChanged(); |
| 150 | 173 | } |
| 151 | 174 | |
| 152 | 175 | // The only events that may move/resize this map view are window movements or changes to the map view size. |
| … |
… |
public class NavigatableComponent extends JComponent implements Helpful {
|
| 617 | 640 | * @param initial true if this call initializes the viewport. |
| 618 | 641 | */ |
| 619 | 642 | public void zoomTo(EastNorth center, double scale, boolean initial) { |
| | 643 | zoomTo(null, center, scale, initial); |
| | 644 | } |
| | 645 | |
| | 646 | /** |
| | 647 | * Zoom to the given coordinate and scale. |
| | 648 | * |
| | 649 | * @param e The originating input event |
| | 650 | * @param center The center x-value (easting) to zoom to. |
| | 651 | * @param scale The scale to use. |
| | 652 | * @param initial true if this call initializes the viewport. |
| | 653 | */ |
| | 654 | void zoomTo(InputEvent e, EastNorth center, double scale, boolean initial) { |
| 620 | 655 | Bounds b = getProjection().getWorldBoundsLatLon(); |
| 621 | 656 | ProjectionBounds pb = getProjection().getWorldBoundsBoxEastNorth(); |
| 622 | 657 | double newScale = scale; |
| … |
… |
public class NavigatableComponent extends JComponent implements Helpful {
|
| 682 | 717 | newCenter = newCenter.subtract(enShift); |
| 683 | 718 | |
| 684 | 719 | EastNorth oldCenter = getCenter(); |
| 685 | | if (!newCenter.equals(oldCenter) || !Utils.equalsEpsilon(getScale(), newScale)) { |
| | 720 | if (!newCenter.equals(oldCenter) || !Utils.equalsEpsilon(getScale(), newScale) |
| | 721 | || (e != null && e.getID() == MouseEvent.MOUSE_RELEASED)) { |
| 686 | 722 | if (!initial) { |
| 687 | 723 | pushZoomUndo(oldCenter, getScale()); |
| 688 | 724 | } |
| 689 | | zoomNoUndoTo(newCenter, newScale, initial); |
| | 725 | zoomNoUndoTo(e, newCenter, newScale, initial); |
| 690 | 726 | } |
| 691 | 727 | } |
| 692 | 728 | |
| 693 | 729 | /** |
| 694 | 730 | * Zoom to the given coordinate without adding to the zoom undo buffer. |
| 695 | 731 | * |
| | 732 | * @param originatingEvent The originating input event |
| 696 | 733 | * @param newCenter The center x-value (easting) to zoom to. |
| 697 | 734 | * @param newScale The scale to use. |
| 698 | 735 | * @param initial true if this call initializes the viewport. |
| 699 | 736 | */ |
| 700 | | private void zoomNoUndoTo(EastNorth newCenter, double newScale, boolean initial) { |
| | 737 | private void zoomNoUndoTo(InputEvent originatingEvent, EastNorth newCenter, double newScale, boolean initial) { |
| 701 | 738 | if (!Utils.equalsEpsilon(getScale(), newScale)) { |
| 702 | 739 | state = state.usingScale(newScale); |
| 703 | 740 | } |
| … |
… |
public class NavigatableComponent extends JComponent implements Helpful {
|
| 706 | 743 | } |
| 707 | 744 | if (!initial) { |
| 708 | 745 | repaint(); |
| 709 | | fireZoomChanged(); |
| | 746 | fireZoomChanged(originatingEvent); |
| 710 | 747 | } |
| 711 | 748 | } |
| 712 | 749 | |
| … |
… |
public class NavigatableComponent extends JComponent implements Helpful {
|
| 718 | 755 | zoomTo(newCenter, getScale()); |
| 719 | 756 | } |
| 720 | 757 | |
| | 758 | /** |
| | 759 | * Zoom to given east/north. |
| | 760 | * @param e The originating input event |
| | 761 | * @param newCenter new center coordinates |
| | 762 | */ |
| | 763 | void zoomTo(InputEvent e, EastNorth newCenter) { |
| | 764 | zoomTo(e, newCenter, getScale(), false); |
| | 765 | } |
| | 766 | |
| 721 | 767 | /** |
| 722 | 768 | * Zoom to given lat/lon. |
| 723 | 769 | * @param newCenter new center coordinates |
| … |
… |
public class NavigatableComponent extends JComponent implements Helpful {
|
| 943 | 989 | if (!zoomUndoBuffer.isEmpty()) { |
| 944 | 990 | ZoomData zoom = zoomUndoBuffer.pop(); |
| 945 | 991 | zoomRedoBuffer.push(new ZoomData(getCenter(), getScale())); |
| 946 | | zoomNoUndoTo(zoom.getCenterEastNorth(), zoom.getScale(), false); |
| | 992 | zoomNoUndoTo(null, zoom.getCenterEastNorth(), zoom.getScale(), false); |
| 947 | 993 | } |
| 948 | 994 | } |
| 949 | 995 | |
| … |
… |
public class NavigatableComponent extends JComponent implements Helpful {
|
| 954 | 1000 | if (!zoomRedoBuffer.isEmpty()) { |
| 955 | 1001 | ZoomData zoom = zoomRedoBuffer.pop(); |
| 956 | 1002 | zoomUndoBuffer.push(new ZoomData(getCenter(), getScale())); |
| 957 | | zoomNoUndoTo(zoom.getCenterEastNorth(), zoom.getScale(), false); |
| | 1003 | zoomNoUndoTo(null, zoom.getCenterEastNorth(), zoom.getScale(), false); |
| 958 | 1004 | } |
| 959 | 1005 | } |
| 960 | 1006 | |
diff --git a/src/org/openstreetmap/josm/gui/autofilter/AutoFilterManager.java b/src/org/openstreetmap/josm/gui/autofilter/AutoFilterManager.java
index 3a7ccb67a2..c96baef2b3 100644
|
a
|
b
|
package org.openstreetmap.josm.gui.autofilter;
|
| 4 | 4 | import static org.openstreetmap.josm.tools.I18n.tr; |
| 5 | 5 | |
| 6 | 6 | import java.awt.Graphics2D; |
| | 7 | import java.awt.event.InputEvent; |
| | 8 | import java.awt.event.MouseEvent; |
| 7 | 9 | import java.util.ArrayList; |
| 8 | 10 | import java.util.Arrays; |
| 9 | 11 | import java.util.Collection; |
| … |
… |
implements ZoomChangeListener, MapModeChangeListener, DataSetListener, Preferenc
|
| 127 | 129 | registerAutoFilterRules(AutoFilterRule.defaultRules()); |
| 128 | 130 | } |
| 129 | 131 | |
| 130 | | private synchronized void updateButtons() { |
| | 132 | private void updateButtons() { |
| | 133 | updateButtons(null); |
| | 134 | } |
| | 135 | |
| | 136 | private synchronized void updateButtons(InputEvent inputEvent) { |
| | 137 | // Don't update while dragging |
| | 138 | if (inputEvent != null && inputEvent instanceof MouseEvent && |
| | 139 | ((MouseEvent) inputEvent).getID() == MouseEvent.MOUSE_DRAGGED) { |
| | 140 | return; |
| | 141 | } |
| 131 | 142 | MapFrame map = MainApplication.getMap(); |
| 132 | 143 | if (enabledRule != null && map != null |
| 133 | 144 | && enabledRule.getMinZoomLevel() <= Selector.GeneralSelector.scale2level(map.mapView.getDist100Pixel())) { |
| … |
… |
implements ZoomChangeListener, MapModeChangeListener, DataSetListener, Preferenc
|
| 261 | 272 | |
| 262 | 273 | @Override |
| 263 | 274 | public void zoomChanged() { |
| 264 | | updateButtons(); |
| | 275 | this.zoomChanged(null); |
| | 276 | } |
| | 277 | |
| | 278 | @Override |
| | 279 | public void zoomChanged(InputEvent event) { |
| | 280 | updateButtons(event); |
| 265 | 281 | } |
| 266 | 282 | |
| 267 | 283 | @Override |