Changeset 9851 in osm
- Timestamp:
- 2008-08-15T13:26:27+02:00 (16 years ago)
- Location:
- applications/editors/josm/plugins/slippy_map_chooser/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/slippy_map_chooser/src/SlippyMapChooser.java
r9819 r9851 20 20 import org.openstreetmap.gui.jmapviewer.MapMarkerDot; 21 21 import org.openstreetmap.gui.jmapviewer.MemoryTileCache; 22 import org.openstreetmap.gui.jmapviewer.OsmFileCacheTileLoader; 22 23 import org.openstreetmap.gui.jmapviewer.OsmMercator; 24 import org.openstreetmap.gui.jmapviewer.OsmTileLoader; 23 25 import org.openstreetmap.gui.jmapviewer.OsmTileSource; 24 26 import org.openstreetmap.gui.jmapviewer.interfaces.MapMarker; 27 import org.openstreetmap.gui.jmapviewer.interfaces.TileLoader; 25 28 import org.openstreetmap.gui.jmapviewer.interfaces.TileSource; 26 29 import org.openstreetmap.josm.gui.download.DownloadDialog; … … 51 54 52 55 private TileSource[] sources = { new OsmTileSource.Mapnik(), new OsmTileSource.TilesAtHome() }; 56 TileLoader cachedLoader; 57 TileLoader uncachedLoader; 53 58 54 59 /** … … 57 62 public SlippyMapChooser() { 58 63 super(); 64 cachedLoader = new OsmFileCacheTileLoader(this); 65 uncachedLoader = new OsmTileLoader(this); 59 66 setZoomContolsVisible(false); 60 67 setMapMarkerVisible(false); 61 68 setMinimumSize(new Dimension(350, 350 / 2)); 69 setFileCacheEnabled(SlippyMapChooserPlugin.ENABLE_FILE_CACHE); 70 setMaxTilesInmemory(SlippyMapChooserPlugin.MAX_TILES_IN_MEMORY); 71 } 72 73 public void setMaxTilesInmemory(int tiles) { 74 ((MemoryTileCache) getTileCache()).setCacheSize(tiles); 75 } 76 77 public void setFileCacheEnabled(boolean enabled) { 78 if (enabled) 79 setTileLoader(cachedLoader); 80 else 81 setTileLoader(uncachedLoader); 62 82 } 63 83 -
applications/editors/josm/plugins/slippy_map_chooser/src/SlippyMapChooserPlugin.java
r7343 r9851 12 12 * @author Tim Haussmann 13 13 */ 14 public class SlippyMapChooserPlugin extends Plugin implements PreferenceChangedListener {15 14 public class SlippyMapChooserPlugin extends Plugin implements PreferenceChangedListener { 15 16 16 static String iPluginFolder = ""; 17 18 private static final String KEY_MAX_TILES_IN_DB = "slippy_map_chooser.max_tiles"; 19 private static final String KEY_MAX_TILES_REDUCE_BY = "slippy_map_chooser.max_tiles_reduce_by"; 20 public static boolean DEBUG_MODE = false; 21 22 23 static int MAX_TILES_IN_DB = 200; 24 static int MAX_TILES_REDUCE_BY = 40; 25 26 public SlippyMapChooserPlugin(){ 27 // create the plugin folder 28 // iPluginFolder = getPluginDir(); 29 // File pluginFolder = new File(iPluginFolder); 30 // if(!pluginFolder.exists()) 31 // pluginFolder.mkdir(); 32 // 33 // //init the logger 34 // Logger.setLogFile(iPluginFolder+"\\slippy_map_chooser.log"); 35 36 //Add this plugin to the preference changed listener list 17 18 private static final String KEY_MAX_TILES_IN_MEMORY = "slippy_map_chooser.max_tiles"; 19 private static final String KEY_ENABLE_FILE_CACHE = "slippy_map_chooser.file_cache"; 20 21 static int MAX_TILES_IN_MEMORY = 200; 22 static boolean ENABLE_FILE_CACHE = true; 23 24 public SlippyMapChooserPlugin() { 25 // create the plugin folder 26 // iPluginFolder = getPluginDir(); 27 // File pluginFolder = new File(iPluginFolder); 28 // if(!pluginFolder.exists()) 29 // pluginFolder.mkdir(); 30 // 31 // //init the logger 32 // Logger.setLogFile(iPluginFolder+"\\slippy_map_chooser.log"); 33 34 // Add this plugin to the preference changed listener list 37 35 Main.pref.listener.add(this); 38 39 // load prefs40 String maxTiles = Main.pref.get(KEY_MAX_TILES_IN_ DB);41 if (!maxTiles.equals("")){42 preferenceChanged(KEY_MAX_TILES_IN_ DB, maxTiles);43 } else{44 Main.pref.put(KEY_MAX_TILES_IN_ DB, String.valueOf(MAX_TILES_IN_DB));36 37 // load prefs 38 String maxTiles = Main.pref.get(KEY_MAX_TILES_IN_MEMORY); 39 if (!maxTiles.equals("")) { 40 preferenceChanged(KEY_MAX_TILES_IN_MEMORY, maxTiles); 41 } else { 42 Main.pref.put(KEY_MAX_TILES_IN_MEMORY, Integer.toString(MAX_TILES_IN_MEMORY)); 45 43 } 46 47 String maxTilesReduce = Main.pref.get(KEY_MAX_TILES_REDUCE_BY); 48 if(!maxTilesReduce.equals("")){ 49 preferenceChanged(KEY_MAX_TILES_REDUCE_BY, maxTilesReduce); 50 }else{ 51 Main.pref.put(KEY_MAX_TILES_REDUCE_BY, String.valueOf(MAX_TILES_REDUCE_BY)); 44 String enableFileCache = Main.pref.get(KEY_ENABLE_FILE_CACHE); 45 if (!enableFileCache.equals("")) { 46 preferenceChanged(KEY_ENABLE_FILE_CACHE, enableFileCache); 47 } else { 48 Main.pref.put(KEY_ENABLE_FILE_CACHE, Boolean.toString(ENABLE_FILE_CACHE)); 52 49 } 53 50 } 54 55 56 public void addDownloadSelection(List<DownloadSelection> list){ 57 list.add(new SlippyMapChooser()); 51 52 public void addDownloadSelection(List<DownloadSelection> list) { 53 list.add(new SlippyMapChooser()); 58 54 } 59 55 60 61 56 public void preferenceChanged(String key, String newValue) { 62 if (key.equals(KEY_MAX_TILES_IN_DB)){63 try {64 MAX_TILES_IN_ DB= Integer.parseInt(newValue);65 } catch(Exception e){66 MAX_TILES_IN_ DB= 1000;57 if (KEY_MAX_TILES_IN_MEMORY.equals(key)) { 58 try { 59 MAX_TILES_IN_MEMORY = Integer.parseInt(newValue); 60 } catch (Exception e) { 61 MAX_TILES_IN_MEMORY = 1000; 67 62 } 68 69 }else if(key.equals(KEY_MAX_TILES_REDUCE_BY)){ 70 try{ 71 MAX_TILES_REDUCE_BY = Integer.parseInt(newValue); 72 }catch(Exception e){ 73 MAX_TILES_REDUCE_BY = 100; 63 } else if (KEY_ENABLE_FILE_CACHE.equals(key)) { 64 try { 65 ENABLE_FILE_CACHE = Boolean.parseBoolean(newValue); 66 } catch (Exception e) { 67 MAX_TILES_IN_MEMORY = 1000; 74 68 } 75 69 } 76 70 } 77 71 78 72 }
Note:
See TracChangeset
for help on using the changeset viewer.