Changeset 23575 in osm
- Timestamp:
- 2010-10-12T21:11:33+02:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/slippymap
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/slippymap/build.xml
r22550 r23575 28 28 29 29 <property name="commit.message" value="Added haiti imagery tile source" /> 30 <property name="plugin.main.version" value="3 408" />30 <property name="plugin.main.version" value="3602" /> 31 31 32 32 <property name="josm" location="../../core/dist/josm-custom.jar"/> -
applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapPlugin.java
r23190 r23575 1 1 package org.openstreetmap.josm.plugins.slippymap; 2 2 3 import java.util.ArrayList; 3 4 import java.util.List; 4 5 6 import org.openstreetmap.gui.jmapviewer.OsmTileSource.CycleMap; 7 import org.openstreetmap.gui.jmapviewer.OsmTileSource.Mapnik; 8 import org.openstreetmap.gui.jmapviewer.OsmTileSource.TilesAtHome; 9 import org.openstreetmap.gui.jmapviewer.interfaces.TileSource; 5 10 import org.openstreetmap.josm.Main; 6 11 import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent; 7 12 import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener; 8 13 import org.openstreetmap.josm.gui.MapFrame; 14 import org.openstreetmap.josm.gui.bbox.SlippyMapBBoxChooser; 15 import org.openstreetmap.josm.gui.bbox.SlippyMapBBoxChooser.TileSourceProvider; 9 16 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 10 17 import org.openstreetmap.josm.plugins.Plugin; … … 19 26 public class SlippyMapPlugin extends Plugin implements PreferenceChangedListener 20 27 { 21 public SlippyMapPlugin(PluginInformation info) 22 { 23 super(info); 24 Main.pref.addPreferenceChangeListener(this); 25 } 28 public SlippyMapPlugin(PluginInformation info) 29 { 30 super(info); 31 Main.pref.addPreferenceChangeListener(this); 32 SlippyMapBBoxChooser.addTileSourceProvider(new TileSourceProvider() { 33 public List<TileSource> getTileSources() { 34 List<TileSource> result = new ArrayList<TileSource>(); 35 for (TileSource ts: SlippyMapPreferences.getAllMapSources()) { 36 if (ts instanceof Mapnik || ts instanceof CycleMap || ts instanceof TilesAtHome) { 37 continue; // Already included in default list 38 } 39 result.add(ts); 40 } 41 return result; 42 } 43 }); 44 } 26 45 27 28 29 30 31 32 33 34 35 46 @Override 47 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) 48 { 49 if (newFrame != null && SlippyMapPreferences.getMapSource() != SlippyMapPreferences.NO_DEFAULT_TILE_SOURCE) { 50 SlippyMapLayer smlayer; 51 smlayer = new SlippyMapLayer(); 52 Main.main.addLayer(smlayer); 53 } 54 } 36 55 37 38 39 40 41 42 43 44 45 46 56 /* 57 * (non-Javadoc) 58 * 59 * @see org.openstreetmap.josm.plugins.Plugin#getPreferenceSetting() 60 */ 61 @Override 62 public PreferenceSetting getPreferenceSetting() 63 { 64 return new SlippyMapPreferenceSetting(); 65 } 47 66 48 49 50 51 52 53 54 55 56 57 58 59 60 67 /* 68 * (non-Javadoc) 69 * 70 * @seeorg.openstreetmap.josm.data.Preferences.PreferenceChangedListener# 71 * preferenceChanged(java.lang.String, java.lang.String) 72 */ 73 public void preferenceChanged(PreferenceChangeEvent event) { 74 if (!Main.isDisplayingMapView()) { 75 return; 76 } 77 List<SlippyMapLayer> layes = Main.map.mapView.getLayersOfType(SlippyMapLayer.class); 78 assert layes.size() <= 1; 79 SlippyMapLayer layer = layes.isEmpty()?null:layes.get(0); 61 80 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 81 if (event.getKey().equals(SlippyMapPreferences.PREFERENCE_TILE_SOURCE)) { 82 if (layer == null && SlippyMapPreferences.getMapSource() != SlippyMapPreferences.NO_DEFAULT_TILE_SOURCE) { 83 Main.map.mapView.addLayer(new SlippyMapLayer()); 84 } else if (layer != null && SlippyMapPreferences.getMapSource() == SlippyMapPreferences.NO_DEFAULT_TILE_SOURCE) { 85 Main.map.mapView.removeLayer(layer); 86 } else if (layer == null && SlippyMapPreferences.getMapSource() == SlippyMapPreferences.NO_DEFAULT_TILE_SOURCE) { 87 // Do nothing 88 } else { 89 layer.newTileStorage(); 90 } 91 } else if (event.getKey().startsWith(SlippyMapPreferences.PREFERENCE_PREFIX) && layer != null) { 92 // System.err.println(this + ".preferenceChanged('" + key + "', '" 93 // + newValue + "') called"); 94 // when fade background changed, no need to clear tile storage 95 // TODO move this code to SlippyMapPreferences class. 96 if (!event.getKey().equals(SlippyMapPreferences.PREFERENCE_FADE_BACKGROUND)) { 97 layer.autoZoomPopup.setSelected(SlippyMapPreferences.getAutozoom()); 98 } 99 layer.redraw(); 100 } 101 } 83 102 84 103 }
Note:
See TracChangeset
for help on using the changeset viewer.