Changeset 9824 in josm for trunk/src/org/openstreetmap/josm


Ignore:
Timestamp:
2016-02-18T17:46:28+01:00 (9 years ago)
Author:
bastiK
Message:

applied #12539 - reverse zoom with mouse wheel (patch by kolesar)

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/MapMover.java

    r9818 r9824  
    2121import javax.swing.KeyStroke;
    2222
     23import org.openstreetmap.gui.jmapviewer.JMapViewer;
     24
    2325import org.openstreetmap.josm.Main;
    2426import org.openstreetmap.josm.actions.mapmode.SelectAction;
    2527import org.openstreetmap.josm.data.coor.EastNorth;
     28import org.openstreetmap.josm.data.preferences.BooleanProperty;
     29import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent;
     30import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener;
    2631import org.openstreetmap.josm.tools.Destroyable;
    2732import org.openstreetmap.josm.tools.Shortcut;
     
    3439 */
    3540public class MapMover extends MouseAdapter implements MouseMotionListener, MouseWheelListener, Destroyable {
     41
     42    public static final BooleanProperty PROP_ZOOM_REVERSE_WHEEL = new BooleanProperty("zoom.reverse-wheel", false);
     43
     44    private static final JMapViewerUpdater jMapViewerUpdater = new JMapViewerUpdater();
     45
     46    private static class JMapViewerUpdater implements PreferenceChangedListener {
     47
     48        JMapViewerUpdater() {
     49            Main.pref.addPreferenceChangeListener(this);
     50            updateJMapViewer();
     51        }
     52
     53        @Override
     54        public void preferenceChanged(PreferenceChangeEvent e) {
     55            if (MapMover.PROP_ZOOM_REVERSE_WHEEL.getKey().equals(e.getKey())) {
     56                updateJMapViewer();
     57            }
     58        }
     59
     60        private void updateJMapViewer() {
     61            JMapViewer.zoomReverseWheel = MapMover.PROP_ZOOM_REVERSE_WHEEL.get();
     62        }
     63    }
    3664
    3765    private final class ZoomerAction extends AbstractAction {
     
    214242    @Override
    215243    public void mouseWheelMoved(MouseWheelEvent e) {
    216         nc.zoomManyTimes(e.getX(), e.getY(), e.getWheelRotation());
     244        int rotation = PROP_ZOOM_REVERSE_WHEEL.get() ? -e.getWheelRotation() : e.getWheelRotation();
     245        nc.zoomManyTimes(e.getX(), e.getY(), rotation);
    217246    }
    218247
  • trunk/src/org/openstreetmap/josm/gui/preferences/display/LafPreference.java

    r9783 r9824  
    2323import org.openstreetmap.josm.Main;
    2424import org.openstreetmap.josm.actions.ExpertToggleAction;
     25import org.openstreetmap.josm.gui.MapMover;
    2526import org.openstreetmap.josm.gui.dialogs.ToggleDialog;
    2627import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
     
    6263    private final JCheckBox isoDates = new JCheckBox(tr("Display ISO dates"));
    6364    private final JCheckBox nativeFileChoosers = new JCheckBox(tr("Use native file choosers (nicer, but do not support file filters)"));
     65    private final JCheckBox zoomReverseWheel = new JCheckBox(tr("Reverse zoom with mouse wheel"));
    6466
    6567    @Override
     
    141143        panel.add(nativeFileChoosers, GBC.eop().insets(20, 0, 0, 0));
    142144
     145        zoomReverseWheel.setToolTipText(
     146                tr("Check if you feel opposite direction more convenient"));
     147        zoomReverseWheel.setSelected(MapMover.PROP_ZOOM_REVERSE_WHEEL.get());
     148        panel.add(zoomReverseWheel, GBC.eop().insets(20, 0, 0, 0));
     149
    143150        panel.add(Box.createVerticalGlue(), GBC.eol().insets(0, 20, 0, 0));
    144151
     
    162169        Main.pref.put(DateUtils.PROP_ISO_DATES.getKey(), isoDates.isSelected());
    163170        Main.pref.put(FileChooserManager.PROP_USE_NATIVE_FILE_DIALOG.getKey(), nativeFileChoosers.isSelected());
     171        Main.pref.put(MapMover.PROP_ZOOM_REVERSE_WHEEL.getKey(), zoomReverseWheel.isSelected());
    164172        mod |= Main.pref.put("laf", ((LookAndFeelInfo) lafCombo.getSelectedItem()).getClassName());
    165173        return mod;
Note: See TracChangeset for help on using the changeset viewer.