Ignore:
Timestamp:
2013-11-03T03:01:01+01:00 (10 years ago)
Author:
Don-vip
Message:

fix #3744 - Refresh list of TMS layers of download dialog when imagery preferences are changed

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

Legend:

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

    r6316 r6364  
    4242import org.openstreetmap.josm.gui.layer.TMSLayer;
    4343
    44 public class SlippyMapBBoxChooser extends JMapViewer implements BBoxChooser{
     44public class SlippyMapBBoxChooser extends JMapViewer implements BBoxChooser {
    4545
    4646    public interface TileSourceProvider {
     
    139139    }
    140140
    141 
    142141    /**
    143142     * Plugins that wish to add custom tile sources to slippy map choose should call this method
     
    175174    private Bounds bbox;
    176175
    177     // upper left and lower right corners of the selection rectangle (x/y on
    178     // ZOOM_MAX)
     176    // upper left and lower right corners of the selection rectangle (x/y on ZOOM_MAX)
    179177    Point iSelectionRectStart;
    180178    Point iSelectionRectEnd;
    181179
     180    /**
     181     * Constructs a new {@code SlippyMapBBoxChooser}.
     182     */
    182183    public SlippyMapBBoxChooser() {
    183         super();
    184184        TMSLayer.setMaxWorkers();
    185185        cachedLoader = TMSLayer.loaderFactory.makeTileLoader(this);
     
    191191        setMinimumSize(new Dimension(350, 350 / 2));
    192192        // We need to set an initial size - this prevents a wrong zoom selection
    193         // for
    194         // the area before the component has been displayed the first time
     193        // for the area before the component has been displayed the first time
    195194        setBounds(new Rectangle(getMinimumSize()));
    196195        if (cachedLoader == null) {
     
    201200        setMaxTilesInMemory(Main.pref.getInteger("slippy_map_chooser.max_tiles", 1000));
    202201
    203         List<TileSource> tileSources = new ArrayList<TileSource>();
    204         for (TileSourceProvider provider: providers) {
    205             tileSources.addAll(provider.getTileSources());
    206         }
     202        List<TileSource> tileSources = getTileSources();
    207203
    208204        iSourceButton = new SourceButton(tileSources);
     
    224220
    225221        new SlippyMapControler(this, this, iSizeButton, iSourceButton);
     222    }
     223   
     224    private List<TileSource> getTileSources() {
     225        List<TileSource> tileSources = new ArrayList<TileSource>();
     226        for (TileSourceProvider provider: providers) {
     227            tileSources.addAll(provider.getTileSources());
     228        }
     229        return tileSources;
    226230    }
    227231
     
    390394        repaint();
    391395    }
     396   
     397    /**
     398     * Refreshes the tile sources
     399     * @since 6364
     400     */
     401    public final void refreshTileSources() {
     402        iSourceButton.setSources(getTileSources());
     403    }
    392404}
  • trunk/src/org/openstreetmap/josm/gui/bbox/SourceButton.java

    r3719 r6364  
    88import java.awt.Point;
    99import java.awt.RenderingHints;
    10 import java.util.List;
     10import java.util.Collection;
    1111
    1212import javax.swing.ImageIcon;
    1313
    1414import org.openstreetmap.gui.jmapviewer.interfaces.TileSource;
     15import org.openstreetmap.josm.tools.CheckParameterUtil;
    1516import org.openstreetmap.josm.tools.ImageProvider;
    1617
     
    2324    private int layerHeight;
    2425
    25     private final TileSource[] sources;
     26    private TileSource[] sources;
    2627
    2728    private ImageIcon enlargeImage;
     
    3435    public static final int HIDE_OR_SHOW = 1;
    3536
    36     public SourceButton(List<TileSource> sources) {
    37         this.sources = sources.toArray(new TileSource[sources.size()]);
     37    public SourceButton(Collection<TileSource> sources) {
     38        setSources(sources);
    3839        this.currentMap = 2;
    3940        enlargeImage = ImageProvider.get("layer-switcher-maximize.png");
    4041        shrinkImage = ImageProvider.get("layer-switcher-minimize.png");
     42    }
     43   
     44    /**
     45     * Set the tile sources.
     46     * @param sources The tile sources to display
     47     * @since 6364
     48     */
     49    public final void setSources(Collection<TileSource> sources) {
     50        CheckParameterUtil.ensureParameterNotNull(sources, "sources");
     51        this.sources = sources.toArray(new TileSource[sources.size()]);
    4152    }
    4253
Note: See TracChangeset for help on using the changeset viewer.