Changeset 6364 in josm for trunk/src/org/openstreetmap/josm/gui/bbox
- Timestamp:
- 2013-11-03T03:01:01+01:00 (10 years ago)
- 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 42 42 import org.openstreetmap.josm.gui.layer.TMSLayer; 43 43 44 public class SlippyMapBBoxChooser extends JMapViewer implements BBoxChooser {44 public class SlippyMapBBoxChooser extends JMapViewer implements BBoxChooser { 45 45 46 46 public interface TileSourceProvider { … … 139 139 } 140 140 141 142 141 /** 143 142 * Plugins that wish to add custom tile sources to slippy map choose should call this method … … 175 174 private Bounds bbox; 176 175 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) 179 177 Point iSelectionRectStart; 180 178 Point iSelectionRectEnd; 181 179 180 /** 181 * Constructs a new {@code SlippyMapBBoxChooser}. 182 */ 182 183 public SlippyMapBBoxChooser() { 183 super();184 184 TMSLayer.setMaxWorkers(); 185 185 cachedLoader = TMSLayer.loaderFactory.makeTileLoader(this); … … 191 191 setMinimumSize(new Dimension(350, 350 / 2)); 192 192 // 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 195 194 setBounds(new Rectangle(getMinimumSize())); 196 195 if (cachedLoader == null) { … … 201 200 setMaxTilesInMemory(Main.pref.getInteger("slippy_map_chooser.max_tiles", 1000)); 202 201 203 List<TileSource> tileSources = new ArrayList<TileSource>(); 204 for (TileSourceProvider provider: providers) { 205 tileSources.addAll(provider.getTileSources()); 206 } 202 List<TileSource> tileSources = getTileSources(); 207 203 208 204 iSourceButton = new SourceButton(tileSources); … … 224 220 225 221 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; 226 230 } 227 231 … … 390 394 repaint(); 391 395 } 396 397 /** 398 * Refreshes the tile sources 399 * @since 6364 400 */ 401 public final void refreshTileSources() { 402 iSourceButton.setSources(getTileSources()); 403 } 392 404 } -
trunk/src/org/openstreetmap/josm/gui/bbox/SourceButton.java
r3719 r6364 8 8 import java.awt.Point; 9 9 import java.awt.RenderingHints; 10 import java.util. List;10 import java.util.Collection; 11 11 12 12 import javax.swing.ImageIcon; 13 13 14 14 import org.openstreetmap.gui.jmapviewer.interfaces.TileSource; 15 import org.openstreetmap.josm.tools.CheckParameterUtil; 15 16 import org.openstreetmap.josm.tools.ImageProvider; 16 17 … … 23 24 private int layerHeight; 24 25 25 private finalTileSource[] sources;26 private TileSource[] sources; 26 27 27 28 private ImageIcon enlargeImage; … … 34 35 public static final int HIDE_OR_SHOW = 1; 35 36 36 public SourceButton( List<TileSource> sources) {37 this.sources = sources.toArray(new TileSource[sources.size()]);37 public SourceButton(Collection<TileSource> sources) { 38 setSources(sources); 38 39 this.currentMap = 2; 39 40 enlargeImage = ImageProvider.get("layer-switcher-maximize.png"); 40 41 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()]); 41 52 } 42 53
Note:
See TracChangeset
for help on using the changeset viewer.