Changeset 18805 in osm


Ignore:
Timestamp:
2009-11-25T20:01:09+01:00 (15 years ago)
Author:
dhansen
Message:

Update gui to reflect limits on zoom levels from underlying map sources.

Location:
applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapPreferenceSetting.java

    r18355 r18805  
    1111import javax.swing.JSpinner;
    1212import javax.swing.SpinnerNumberModel;
     13import java.awt.event.ActionListener;
     14import java.awt.event.ActionEvent;
    1315import java.util.Collection;
    1416
     
    7577        slippymapTab.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL));
    7678
     79        tileSourceCombo.addActionListener(new ActionListener() {
     80            public void actionPerformed(ActionEvent e) {
     81                //Main.debug("updating spinner models because of tileSourceCombo");
     82                updateSpinnerModels();
     83            }
     84        });
     85
    7786        this.loadSettings();
     87        updateSpinnerModels();
    7888    }
    7989
     90
     91    void updateSpinnerModel(JSpinner s, int min, int max)
     92    {
     93        int val = (Integer)s.getValue();
     94        //Main.debug("updating spinner model val: " + val + " " + min + "->" + max);
     95        val = Math.min(max, val);
     96        val = Math.max(min, val);
     97        SpinnerNumberModel model = new SpinnerNumberModel(val, min, max, 1);
     98        s.setModel(model);
     99    }
     100
     101    void updateSpinnerModels()
     102    {
     103        TileSource ts = (TileSource)this.tileSourceCombo.getSelectedItem();
     104        int min = ts.getMinZoom();
     105        int max = ts.getMaxZoom();
     106        updateSpinnerModel(minZoomLvl, min, max);
     107        updateSpinnerModel(maxZoomLvl, min, max);
     108    }
    80109
    81110    /**
  • applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapPreferences.java

    r18741 r18805  
    3838    {
    3939        String name = Main.pref.get(PREFERENCE_TILE_SOURCE);
     40        return getMapSource(name);
     41    }
     42    public static TileSource getMapSource(String name)
     43    {
    4044        List<TileSource> sources = SlippyMapPreferences.getAllMapSources();
    4145        TileSource source = sources.get(0);
     
    185189                maxZoomLvl = SlippyMapPreferences.__getMinZoomLvl();
    186190        }
     191        TileSource ts = getMapSource();
     192        if (ts != null && ts.getMaxZoom() < SlippyMapPreferences.__getMinZoomLvl()) {
     193                System.err.println("decreasing maxZoomLvl to match new tile source");
     194            maxZoomLvl = ts.getMaxZoom();
     195        }
    187196        return maxZoomLvl;
    188197    }
Note: See TracChangeset for help on using the changeset viewer.