Changeset 12255 in osm for applications/editors/josm/plugins/lakewalker/src/org/openstreetmap
- Timestamp:
- 2008-12-07T22:09:45+01:00 (16 years ago)
- Location:
- applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerAction.java
r12186 r12255 50 50 protected Collection<Way> ways = new ArrayList<Way>(); 51 51 52 /** maximum size in bytes for the sum of all tiles in a WMS-layer cache directory. */53 private static final long MAXCACHESIZE = 20*1024*1024*1024;54 55 /** maximum age in ms since epoch for tiles in a WMS-layer cache directory. */56 private static final long MAXCACHEAGE = 3650*24*60*60*1000;57 58 52 public LakewalkerAction(String name) { 59 53 super(name, "lakewalker-sml", tr("Lake Walker."), … … 100 94 */ 101 95 private void cleanupCache() { 96 final long maxCacheAge = System.currentTimeMillis()-Main.pref.getInteger(LakewalkerPreferences.PREF_MAXCACHEAGE, 100)*24*60*60*1000L; 97 final long maxCacheSize = Main.pref.getInteger(LakewalkerPreferences.PREF_MAXCACHESIZE, 300)*1024*1024; 102 98 103 99 for (String wmsFolder : LakewalkerPreferences.WMSLAYERS) { … … 117 113 // delete aged or oversized, keep newest. Once size/age limit was reached delete all older files 118 114 long folderSize = 0; 119 long timeDefiningOverage = System.currentTimeMillis()-MAXCACHEAGE;120 115 boolean quickdelete = false; 121 116 for (File cacheEntry : wmsCache) { … … 123 118 if (!quickdelete) { 124 119 folderSize += cacheEntry.length(); 125 if (folderSize > MAXCACHESIZE) {120 if (folderSize > maxCacheSize) { 126 121 quickdelete = true; 127 } else if (cacheEntry.lastModified() < timeDefiningOverage) {122 } else if (cacheEntry.lastModified() < maxCacheAge) { 128 123 quickdelete = true; 129 124 } -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerPlugin.java
r11924 r12255 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 4 5 import javax.swing.JMenu;6 import javax.swing.JMenuItem;7 8 5 import org.openstreetmap.josm.Main; 6 import org.openstreetmap.josm.gui.MainMenu; 9 7 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 10 8 import org.openstreetmap.josm.plugins.Plugin; … … 17 15 public class LakewalkerPlugin extends Plugin { 18 16 public LakewalkerPlugin() { 19 Main .main.menu.add(Main.main.menu.toolsMenu, new LakewalkerAction(tr("Lake Walker")));17 MainMenu.add(Main.main.menu.toolsMenu, new LakewalkerAction(tr("Lake Walker"))); 20 18 } 21 19 -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerPreferences.java
r11938 r12255 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 4 5 import javax.swing.Box; 5 6 import javax.swing.JLabel; 6 7 import javax.swing.JPanel; … … 29 30 public static final String PREF_WAYTYPE = "lakewalker.waytype"; 30 31 public static final String PREF_WMS = "lakewalker.wms"; 32 public static final String PREF_MAXCACHESIZE = "lakewalker.maxcachesize"; 33 public static final String PREF_MAXCACHEAGE = "lakewalker.maxcacheage"; 31 34 32 35 protected IntConfigurer maxSegsConfig = new IntConfigurer(); … … 52 55 protected StringEnumConfigurer wmsConfig = new StringEnumConfigurer(WMSLAYERS); 53 56 protected JLabel wmsLabel = new JLabel(tr("WMS Layer")); 57 protected IntConfigurer maxCacheSizeConfig = new IntConfigurer(); 58 protected JLabel maxCacheSizeLabel = new JLabel(tr("Maximum cache size (MB)")); 59 protected IntConfigurer maxCacheAgeConfig = new IntConfigurer(); 60 protected JLabel maxCacheAgeLabel = new JLabel(tr("Maximum cache age (days)")); 54 61 55 62 public void addGui(PreferenceDialog gui) { … … 65 72 lakeTypeConfig.setToolTipText(tr("Tag ways as water, coastline, land or nothing. Default is water.")); 66 73 wmsConfig.setToolTipText(tr("Which WMS layer to use for tracing against. Default is IR1.")); 67 74 maxCacheSizeConfig.setToolTipText(tr("Maximum size of each cache directory in bytes. Default is 300MB")); 75 maxCacheAgeConfig.setToolTipText(tr("Maximum age of each cached file in days. Default is 100")); 76 68 77 String description = tr("An plugin to trace water bodies on Landsat imagery."); 69 78 JPanel prefPanel = gui.createPreferenceTab("lakewalker.png", I18n.tr("Lakewalker Plugin Preferences"), description); … … 81 90 lakeTypeConfig.setValue(Main.pref.get(PREF_WAYTYPE, "water")); 82 91 wmsConfig.setValue(Main.pref.get(PREF_WMS, "IR1")); 92 maxCacheSizeConfig.setValue(Main.pref.getInteger(PREF_MAXCACHESIZE, 300)); 93 maxCacheAgeConfig.setValue(Main.pref.getInteger(PREF_MAXCACHEAGE, 100)); 83 94 } 84 95 … … 109 120 prefPanel.add(wmsLabel, labelConstraints); 110 121 prefPanel.add(wmsConfig.getControls(), dataConstraints); 122 prefPanel.add(maxCacheSizeLabel, labelConstraints); 123 prefPanel.add(maxCacheSizeConfig.getControls(), dataConstraints); 124 prefPanel.add(maxCacheAgeLabel, labelConstraints); 125 prefPanel.add(maxCacheAgeConfig.getControls(), dataConstraints); 126 127 prefPanel.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL)); 128 111 129 } 112 130 … … 126 144 Main.pref.put(PREF_WAYTYPE, lakeTypeConfig.getValueString()); 127 145 Main.pref.put(PREF_WMS, wmsConfig.getValueString()); 146 Main.pref.put(PREF_MAXCACHESIZE, maxCacheSizeConfig.getValueString()); 147 Main.pref.put(PREF_MAXCACHEAGE, maxCacheAgeConfig.getValueString()); 128 148 } 129 149
Note:
See TracChangeset
for help on using the changeset viewer.