Changeset 14495 in josm
- Timestamp:
- 2018-12-02T17:37:47+01:00 (6 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/bbox/SlippyMapBBoxChooser.java
r14330 r14495 13 13 import java.awt.geom.Path2D; 14 14 import java.util.ArrayList; 15 import java.util.Arrays;16 15 import java.util.Collections; 17 16 import java.util.HashMap; … … 90 89 public List<TileSource> getTileSources() { 91 90 if (!TMSLayer.PROP_ADD_TO_SLIPPYMAP_CHOOSER.get()) return Collections.<TileSource>emptyList(); 92 List<TileSource> sources = new ArrayList<>(); 93 for (ImageryInfo info : this.getImageryInfos()) { 94 try { 95 TileSource source = TMSLayer.getTileSourceStatic(info); 96 if (source != null) { 97 sources.add(source); 98 } 99 } catch (IllegalArgumentException ex) { 100 Logging.warn(ex); 101 if (ex.getMessage() != null && !ex.getMessage().isEmpty()) { 102 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 103 ex.getMessage(), tr("Warning"), 104 JOptionPane.WARNING_MESSAGE); 105 } 106 } 91 return imageryInfosToTileSources(getImageryInfos()); 92 } 93 } 94 95 /** 96 * TileSource provider for the slippymap chooser - providing default OSM tile source 97 * @since 14495 98 */ 99 public static class DefaultOsmTileSourceProvider implements TileSourceProvider { 100 101 protected static final StringProperty DEFAULT_OSM_TILE_URL = new StringProperty( 102 "default.osm.tile.source.url", "https://{switch:a,b,c}.tile.openstreetmap.org/{zoom}/{x}/{y}.png"); 103 104 @Override 105 public List<TileSource> getTileSources() { 106 List<TileSource> result = imageryInfosToTileSources(ImageryLayerInfo.instance.getLayers().stream() 107 .filter(l -> l.getUrl().equals(DEFAULT_OSM_TILE_URL.get())).collect(Collectors.toList())); 108 if (result.isEmpty()) { 109 result.add(new OsmTileSource.Mapnik()); 107 110 } 108 return sources; 111 return result; 112 } 113 114 /** 115 * Returns the default OSM tile source. 116 * @return the default OSM tile source 117 */ 118 public static TileSource get() { 119 return new DefaultOsmTileSourceProvider().getTileSources().get(0); 109 120 } 110 121 } … … 136 147 } 137 148 149 static List<TileSource> imageryInfosToTileSources(List<ImageryInfo> imageryInfos) { 150 List<TileSource> sources = new ArrayList<>(); 151 for (ImageryInfo info : imageryInfos) { 152 try { 153 TileSource source = TMSLayer.getTileSourceStatic(info); 154 if (source != null) { 155 sources.add(source); 156 } 157 } catch (IllegalArgumentException ex) { 158 Logging.warn(ex); 159 if (ex.getMessage() != null && !ex.getMessage().isEmpty()) { 160 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 161 ex.getMessage(), tr("Warning"), 162 JOptionPane.WARNING_MESSAGE); 163 } 164 } 165 } 166 return sources; 167 } 168 138 169 /** 139 170 * Plugins that wish to add custom tile sources to slippy map choose should call this method … … 146 177 private static CopyOnWriteArrayList<TileSourceProvider> providers = new CopyOnWriteArrayList<>(); 147 178 static { 148 addTileSourceProvider( () -> Arrays.<TileSource>asList(newOsmTileSource.Mapnik()));179 addTileSourceProvider(new DefaultOsmTileSourceProvider()); 149 180 addTileSourceProvider(new TMSTileSourceProvider()); 150 181 addTileSourceProvider(new CurrentLayersTileSourceProvider()); -
trunk/src/org/openstreetmap/josm/gui/history/CoordinateInfoViewer.java
r14463 r14495 19 19 import org.openstreetmap.gui.jmapviewer.JMapViewer; 20 20 import org.openstreetmap.gui.jmapviewer.MapMarkerDot; 21 import org.openstreetmap.gui.jmapviewer.tilesources.OsmTileSource;22 21 import org.openstreetmap.josm.data.coor.LatLon; 23 22 import org.openstreetmap.josm.data.coor.conversion.DecimalDegreesCoordinateFormat; … … 25 24 import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive; 26 25 import org.openstreetmap.josm.gui.NavigatableComponent; 26 import org.openstreetmap.josm.gui.bbox.SlippyMapBBoxChooser; 27 27 import org.openstreetmap.josm.gui.util.GuiHelper; 28 28 import org.openstreetmap.josm.gui.widgets.JosmTextArea; … … 323 323 MapViewer(HistoryBrowserModel model) { 324 324 this.updater = new Updater(model, PointInTimeType.REFERENCE_POINT_IN_TIME); 325 setTileSource( newOsmTileSource.Mapnik()); // for attribution325 setTileSource(SlippyMapBBoxChooser.DefaultOsmTileSourceProvider.get()); // for attribution 326 326 setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY)); 327 327 addMouseListener(new MouseAdapter() { -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreference.java
r14390 r14495 53 53 import org.openstreetmap.gui.jmapviewer.interfaces.MapPolygon; 54 54 import org.openstreetmap.gui.jmapviewer.interfaces.MapRectangle; 55 import org.openstreetmap.gui.jmapviewer.tilesources.OsmTileSource;56 55 import org.openstreetmap.josm.data.coor.EastNorth; 57 56 import org.openstreetmap.josm.data.imagery.ImageryInfo; … … 63 62 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 64 63 import org.openstreetmap.josm.gui.MainApplication; 64 import org.openstreetmap.josm.gui.bbox.SlippyMapBBoxChooser; 65 65 import org.openstreetmap.josm.gui.download.DownloadDialog; 66 66 import org.openstreetmap.josm.gui.help.HelpUtil; … … 356 356 // Add default item map 357 357 defaultMap = new JMapViewer(); 358 defaultMap.setTileSource( newOsmTileSource.Mapnik()); // for attribution358 defaultMap.setTileSource(SlippyMapBBoxChooser.DefaultOsmTileSourceProvider.get()); // for attribution 359 359 defaultMap.addMouseListener(new MouseAdapter() { 360 360 @Override
Note:
See TracChangeset
for help on using the changeset viewer.