Changeset 13201 in josm for trunk/src


Ignore:
Timestamp:
2017-12-16T18:37:30+01:00 (7 years ago)
Author:
Don-vip
Message:

fix #15039 - prevent zoom level from jumping after click on slider (patch by ar2988-os)

File:
1 edited

Legend:

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

    r12537 r13201  
    55
    66import java.awt.Dimension;
    7 import java.beans.PropertyChangeEvent;
    8 import java.beans.PropertyChangeListener;
    97
    108import javax.swing.JSlider;
     
    1412
    1513import org.openstreetmap.josm.gui.help.Helpful;
     14import org.openstreetmap.josm.gui.NavigatableComponent.ZoomChangeListener;
    1615
    1716/**
    1817 * This is the slider used in the top left corner of the map view. It allows the user to select the scale
    1918 */
    20 class MapSlider extends JSlider implements PropertyChangeListener, ChangeListener, Helpful {
     19class MapSlider extends JSlider implements ZoomChangeListener, ChangeListener, Helpful {
    2120
    2221    private static final double ZOOM_STEP = 1.1;
     
    2928        setOpaque(false);
    3029        this.mv = mv;
    31         mv.addPropertyChangeListener("scale", this);
     30        NavigatableComponent.addZoomChangeListener(this);
    3231        addChangeListener(this);
    3332        // Call this manually once so it gets setup correctly
    34         propertyChange(null);
     33        zoomChanged();
    3534        int w = UIManager.getDefaults().getInt("Slider.thumbWidth") + 150;
    3635        setPreferredSize(new Dimension(w, 27));
     
    3837
    3938    @Override
    40     public void propertyChange(PropertyChangeEvent evt) {
     39    public void zoomChanged() {
    4140        double maxScale = this.mv.getMaxScale();
    4241        int zoom = (int) Math.round(Math.log(maxScale/mv.getScale())/Math.log(ZOOM_STEP));
     
    6362            mv.zoomTo(this.mv.getCenter(), snapped);
    6463        }
    65         propertyChange(null);
     64        zoomChanged();
    6665    }
    6766
Note: See TracChangeset for help on using the changeset viewer.