Changeset 24620 in osm for applications


Ignore:
Timestamp:
2010-12-06T16:59:19+01:00 (14 years ago)
Author:
upliner
Message:

add TMS layers to the slippymap chooser like it was in the original slippymap plugin

Location:
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/ImageryLayerInfo.java

    r24510 r24620  
    1212import java.util.Collections;
    1313import java.util.LinkedList;
     14import java.util.List;
    1415
    1516import org.openstreetmap.josm.Main;
     
    102103        Main.pref.putArray("imagery.layers", coll);
    103104    }
     105
     106    public List<ImageryInfo> getLayers() {
     107        return Collections.unmodifiableList(layers);
     108    }
    104109}
  • applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/ImageryPlugin.java

    r24615 r24620  
    2121import org.openstreetmap.josm.gui.MainMenu;
    2222import org.openstreetmap.josm.gui.MapFrame;
     23import org.openstreetmap.josm.gui.bbox.SlippyMapBBoxChooser;
    2324import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    2425import org.openstreetmap.josm.plugins.Plugin;
     
    2627import org.openstreetmap.josm.plugins.PluginInformation;
    2728import org.openstreetmap.josm.plugins.PluginProxy;
     29import org.openstreetmap.josm.plugins.imagery.tms.TMSTileSourceProvider;
    2830import org.openstreetmap.josm.plugins.imagery.wms.Map_Rectifier_WMSmenuAction;
    2931import org.openstreetmap.josm.plugins.imagery.wms.WMSAdapter;
     
    207209        refreshMenu();
    208210        initRemoteControl();
     211        SlippyMapBBoxChooser.addTileSourceProvider(new TMSTileSourceProvider());
    209212    }
    210213
  • applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/ImageryPreferenceEditor.java

    r24615 r24620  
    6161    private JSpinner minZoomLvl;
    6262    private JSpinner maxZoomLvl;
     63    private JCheckBox addToSlippyMapChosser = new JCheckBox();
    6364
    6465    private JPanel buildCommonSettingsPanel(final PreferenceTabbedPane gui) {
     
    156157    private JPanel buildTMSSettingsPanel() {
    157158        JPanel tmsTab = new JPanel(new GridBagLayout());
     159
    158160        minZoomLvl = new JSpinner(new SpinnerNumberModel(TMSPreferences.DEFAULT_MIN_ZOOM, TMSPreferences.MIN_ZOOM, TMSPreferences.MAX_ZOOM, 1));
    159161        maxZoomLvl = new JSpinner(new SpinnerNumberModel(TMSPreferences.DEFAULT_MAX_ZOOM, TMSPreferences.MIN_ZOOM, TMSPreferences.MAX_ZOOM, 1));
     
    175177        tmsTab.add(this.maxZoomLvl, GBC.eol().fill(GBC.HORIZONTAL));
    176178
    177         tmsTab.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL));
     179        tmsTab.add(new JLabel(tr("Add to slippymap chooser: ")), GBC.std());
     180        tmsTab.add(GBC.glue(5, 0), GBC.std().fill(GBC.HORIZONTAL));
     181        tmsTab.add(addToSlippyMapChosser, GBC.eol().fill(GBC.HORIZONTAL));
    178182
    179183        this.autozoomActive.setSelected(TMSPreferences.PROP_DEFAULT_AUTOZOOM.get());
    180184        this.autoloadTiles.setSelected(TMSPreferences.PROP_DEFAULT_AUTOLOAD.get());
     185        this.addToSlippyMapChosser.setSelected(TMSPreferences.PROP_ADD_TO_SLIPPYMAP_CHOOSER.get());
    181186        this.maxZoomLvl.setValue(TMSPreferences.getMaxZoomLvl(null));
    182187        this.minZoomLvl.setValue(TMSPreferences.getMinZoomLvl(null));
     
    220225    @Override
    221226    public boolean ok() {
     227        boolean restartRequired = false;
    222228        plugin.info.save();
    223229        plugin.refreshMenu();
     
    232238        Main.pref.put("imagery.wms.browser", browser.getEditor().getItem().toString());
    233239
     240        if (TMSPreferences.PROP_ADD_TO_SLIPPYMAP_CHOOSER.get() != this.addToSlippyMapChosser.isSelected())
     241            restartRequired = true;
     242        TMSPreferences.PROP_ADD_TO_SLIPPYMAP_CHOOSER.put(this.addToSlippyMapChosser.isSelected());
    234243        TMSPreferences.PROP_DEFAULT_AUTOZOOM.put(this.autozoomActive.isSelected());
    235244        TMSPreferences.PROP_DEFAULT_AUTOLOAD.put(this.autoloadTiles.isSelected());
     
    242251        ImageryPreferences.PROP_SHARPEN_LEVEL.put(sharpen.getSelectedIndex());
    243252
    244         return false;
     253        return restartRequired;
    245254    }
    246255
  • applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/ImageryPreferences.java

    r24615 r24620  
    2424        Main.pref.putColor("imagery.fade", color);
    2525    }
     26
     27    public static boolean isUrlWithPatterns(String url) {
     28        return url != null && url.contains("{") && url.contains("}");
     29    }
    2630}
  • applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/tms/TMSLayer.java

    r24615 r24620  
    5353import org.openstreetmap.josm.gui.layer.Layer;
    5454import org.openstreetmap.josm.plugins.imagery.ImageryInfo;
    55 import org.openstreetmap.josm.plugins.imagery.ImageryInfo.ImageryType;
    5655import org.openstreetmap.josm.plugins.imagery.ImageryLayer;
    5756import org.openstreetmap.josm.plugins.imagery.ImageryPreferences;
     
    184183        this.setVisible(true);
    185184
    186         if (info.getImageryType() == ImageryType.TMS) {
    187             if(isUrlWithPatterns(info.getURL())) {
    188                 initTileSource(new TemplatedTMSTileSource(info.getName(), info.getURL(), info.getMaxZoom()));
    189             } else {
    190                 initTileSource(new TMSTileSource(info.getName(),info.getURL(), info.getMaxZoom()));
    191             }
    192         } else if (info.getImageryType() == ImageryType.BING) {
    193             initTileSource(new BingAerialTileSource());
    194         } else throw new IllegalStateException("cannot create TMSLayer with non-TMS ImageryInfo");
     185        TileSource source = TMSPreferences.getTileSource(info);
     186        if (source == null)
     187            throw new IllegalStateException("cannot create TMSLayer with non-TMS ImageryInfo");
     188        initTileSource(source);
    195189
    196190        tileOptionMenu = new JPopupMenu();
     
    364358            }
    365359        });
    366     }
    367 
    368     public static boolean isUrlWithPatterns(String url) {
    369         return url != null && url.contains("{") && url.contains("}");
    370360    }
    371361
  • applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/tms/TMSPreferences.java

    r24552 r24620  
    44import org.openstreetmap.josm.data.preferences.BooleanProperty;
    55import org.openstreetmap.josm.data.preferences.IntegerProperty;
     6import org.openstreetmap.josm.plugins.imagery.ImageryInfo;
     7import org.openstreetmap.josm.plugins.imagery.ImageryInfo.ImageryType;
     8import org.openstreetmap.josm.plugins.imagery.ImageryPreferences;
    69
    710/**
     
    2730    public static final IntegerProperty PROP_MAX_ZOOM_LVL = new IntegerProperty(PREFERENCE_PREFIX + ".max_zoom_lvl", DEFAULT_MAX_ZOOM);
    2831    public static final BooleanProperty PROP_DRAW_DEBUG = new BooleanProperty(PREFERENCE_PREFIX + ".draw_debug", false);
     32    public static final BooleanProperty PROP_ADD_TO_SLIPPYMAP_CHOOSER = new BooleanProperty(PREFERENCE_PREFIX + ".add_to_slippymap_chooser", true);
    2933
    3034    static int checkMaxZoomLvl(int maxZoomLvl, TileSource ts)
     
    8084        PROP_MIN_ZOOM_LVL.put(minZoomLvl);
    8185    }
     86
     87    public static TileSource getTileSource(ImageryInfo info) {
     88        if (info.getImageryType() == ImageryType.TMS) {
     89            if(ImageryPreferences.isUrlWithPatterns(info.getURL())) {
     90                return new TemplatedTMSTileSource(info.getName(), info.getURL(), info.getMaxZoom());
     91            } else {
     92                return new TMSTileSource(info.getName(),info.getURL(), info.getMaxZoom());
     93            }
     94        } else if (info.getImageryType() == ImageryType.BING) {
     95            return new BingAerialTileSource();
     96        }
     97        return null;
     98    }
    8299}
  • applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/wms/WMSGrabber.java

    r24615 r24620  
    3131import org.openstreetmap.josm.io.OsmTransferException;
    3232import org.openstreetmap.josm.io.ProgressInputStream;
     33import org.openstreetmap.josm.plugins.imagery.ImageryPreferences;
    3334import org.openstreetmap.josm.plugins.imagery.wms.GeorefImage.State;
    3435
    3536
    3637public class WMSGrabber extends Grabber {
    37     public static boolean isUrlWithPatterns(String url) {
    38         return url != null && url.contains("{") && url.contains("}");
    39     }
    4038
    4139    protected String baseURL;
     
    4644        this.baseURL = layer.getInfo().getURL();
    4745        /* URL containing placeholders? */
    48         urlWithPatterns = isUrlWithPatterns(baseURL);
     46        urlWithPatterns = ImageryPreferences.isUrlWithPatterns(baseURL);
    4947    }
    5048
  • applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/wms/WMSLayer.java

    r24615 r24620  
    3030import org.openstreetmap.josm.actions.SaveActionBase;
    3131import org.openstreetmap.josm.data.Bounds;
    32 import org.openstreetmap.josm.data.ProjectionBounds;
    3332import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent;
    3433import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener;
     34import org.openstreetmap.josm.data.ProjectionBounds;
    3535import org.openstreetmap.josm.data.coor.EastNorth;
    3636import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
     
    4242import org.openstreetmap.josm.io.CacheFiles;
    4343import org.openstreetmap.josm.plugins.imagery.ImageryInfo;
     44import org.openstreetmap.josm.plugins.imagery.ImageryInfo.ImageryType;
    4445import org.openstreetmap.josm.plugins.imagery.ImageryLayer;
    4546import org.openstreetmap.josm.plugins.imagery.ImageryPlugin;
    46 import org.openstreetmap.josm.plugins.imagery.ImageryInfo.ImageryType;
     47import org.openstreetmap.josm.plugins.imagery.ImageryPreferences;
    4748import org.openstreetmap.josm.plugins.imagery.wms.GeorefImage.State;
    4849import org.openstreetmap.josm.tools.ImageProvider;
     
    112113            WMSGrabber.getProjection(info.getURL(), true);
    113114            startGrabberThreads();
    114             if(info.getImageryType() == ImageryType.WMS && !WMSGrabber.isUrlWithPatterns(info.getURL())) {
     115            if(info.getImageryType() == ImageryType.WMS && !ImageryPreferences.isUrlWithPatterns(info.getURL())) {
    115116                if (!(info.getURL().endsWith("&") || info.getURL().endsWith("?"))) {
    116117                    if (!confirmMalformedUrl(info.getURL())) {
Note: See TracChangeset for help on using the changeset viewer.