Changeset 33712 in osm for applications/editors/josm/plugins/lakewalker
- Timestamp:
- 2017-10-08T00:45:17+02:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/lakewalker
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/lakewalker/build.xml
r32680 r33712 5 5 <property name="commit.message" value="Changed the constructor signature of the plugin main class"/> 6 6 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 7 <property name="plugin.main.version" value="1 0580"/>7 <property name="plugin.main.version" value="12856"/> 8 8 9 9 <!-- Configure these properties (replace "..." accordingly). -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerAction.java
r32957 r33712 25 25 import org.openstreetmap.josm.command.SequenceCommand; 26 26 import org.openstreetmap.josm.data.coor.LatLon; 27 import org.openstreetmap.josm.data.osm.DataSet; 27 28 import org.openstreetmap.josm.data.osm.Node; 28 29 import org.openstreetmap.josm.data.osm.Way; 30 import org.openstreetmap.josm.gui.MainApplication; 31 import org.openstreetmap.josm.gui.MapView; 29 32 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 30 33 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 31 34 import org.openstreetmap.josm.tools.ImageProvider; 35 import org.openstreetmap.josm.tools.Logging; 32 36 import org.openstreetmap.josm.tools.Shortcut; 33 37 import org.xml.sax.SAXException; … … 60 64 @Override 61 65 public void actionPerformed(ActionEvent e) { 62 if ( Main.map == null || Main.map.mapView == null|| active)66 if (!MainApplication.isDisplayingMapView() || active) 63 67 return; 64 68 65 69 active = true; 66 oldCursor = Main.map.mapView.getCursor(); 67 Main.map.mapView.setCursor(ImageProvider.getCursor("crosshair", "lakewalker-sml")); 68 Main.map.mapView.addMouseListener(this); 70 MapView mapView = MainApplication.getMap().mapView; 71 oldCursor = mapView.getCursor(); 72 mapView.setCursor(ImageProvider.getCursor("crosshair", "lakewalker-sml")); 73 mapView.addMouseListener(this); 69 74 } 70 75 … … 74 79 */ 75 80 private void cleanupCache() { 76 final long maxCacheAge = System.currentTimeMillis()-Main.pref.getInt eger(LakewalkerPreferences.PREF_MAXCACHEAGE, 100)*24*60*60*1000L;77 final long maxCacheSize = Main.pref.getInt eger(LakewalkerPreferences.PREF_MAXCACHESIZE, 300)*1024*1024L;81 final long maxCacheAge = System.currentTimeMillis()-Main.pref.getInt(LakewalkerPreferences.PREF_MAXCACHEAGE, 100)*24*60*60*1000L; 82 final long maxCacheSize = Main.pref.getInt(LakewalkerPreferences.PREF_MAXCACHESIZE, 300)*1024*1024L; 78 83 79 84 for (String wmsFolder : LakewalkerPreferences.WMSLAYERS) { … … 116 121 protected void lakewalk(Point clickPoint) { 117 122 // Positional data 118 final LatLon pos= Main.map.mapView.getLatLon(clickPoint.x, clickPoint.y);119 final LatLon topLeft = Main.map.mapView.getLatLon(0, 0);120 final LatLon botRight = Main.map.mapView.getLatLon(Main.map.mapView.getWidth(),121 Main.map.mapView.getHeight());123 MapView mapView = MainApplication.getMap().mapView; 124 final LatLon pos = mapView.getLatLon(clickPoint.x, clickPoint.y); 125 final LatLon topLeft = mapView.getLatLon(0, 0); 126 final LatLon botRight = mapView.getLatLon(mapView.getWidth(), mapView.getHeight()); 122 127 123 128 /* 124 129 * Collect options 125 130 */ 126 final int waylen = Main.pref.getInt eger(LakewalkerPreferences.PREF_MAX_SEG, 500);127 final int maxnode = Main.pref.getInt eger(LakewalkerPreferences.PREF_MAX_NODES, 50000);128 final int threshold = Main.pref.getInt eger(LakewalkerPreferences.PREF_THRESHOLD_VALUE, 90);131 final int waylen = Main.pref.getInt(LakewalkerPreferences.PREF_MAX_SEG, 500); 132 final int maxnode = Main.pref.getInt(LakewalkerPreferences.PREF_MAX_NODES, 50000); 133 final int threshold = Main.pref.getInt(LakewalkerPreferences.PREF_THRESHOLD_VALUE, 90); 129 134 final double epsilon = Main.pref.getDouble(LakewalkerPreferences.PREF_EPSILON, 0.0003); 130 final int resolution = Main.pref.getInt eger(LakewalkerPreferences.PREF_LANDSAT_RES, 4000);131 final int tilesize = Main.pref.getInt eger(LakewalkerPreferences.PREF_LANDSAT_SIZE, 2000);135 final int resolution = Main.pref.getInt(LakewalkerPreferences.PREF_LANDSAT_RES, 4000); 136 final int tilesize = Main.pref.getInt(LakewalkerPreferences.PREF_LANDSAT_SIZE, 2000); 132 137 final String startdir = Main.pref.get(LakewalkerPreferences.PREF_START_DIR, "east"); 133 138 final String wmslayer = Main.pref.get(LakewalkerPreferences.PREF_WMS, "IR1"); … … 151 156 new Thread(lakewalkerTask).start(); 152 157 } catch (Exception ex) { 153 Main.error(ex);158 Logging.error(ex); 154 159 } 155 160 } … … 164 169 progressMonitor.createSubTaskMonitor(1, false)); 165 170 } catch (LakewalkerException e) { 166 Main.error(e);171 Logging.error(e); 167 172 } 168 173 … … 219 224 220 225 int nodesinway = 0; 226 DataSet ds = getLayerManager().getEditDataSet(); 221 227 222 228 for (int i = 0; i < nodelist.size(); i++) { … … 231 237 fn = n; 232 238 } 233 commands.add(new AddCommand(n)); 239 commands.add(new AddCommand(ds, n)); 234 240 235 241 } catch (Exception ex) { … … 239 245 way.addNode(n); 240 246 241 if (nodesinway > Main.pref.getInt eger(LakewalkerPreferences.PREF_MAX_SEG, 500)) {247 if (nodesinway > Main.pref.getInt(LakewalkerPreferences.PREF_MAX_SEG, 500)) { 242 248 String waytype = Main.pref.get(LakewalkerPreferences.PREF_WAYTYPE, "water"); 243 249 … … 247 253 248 254 way.put("source", Main.pref.get(LakewalkerPreferences.PREF_SOURCE, "Landsat")); 249 commands.add(new AddCommand(way)); 255 commands.add(new AddCommand(ds, way)); 250 256 251 257 way = new Way(); … … 269 275 way.addNode(fn); 270 276 271 commands.add(new AddCommand(way)); 277 commands.add(new AddCommand(ds, way)); 272 278 273 279 if (!commands.isEmpty()) { 274 280 Main.main.undoRedo.add(new SequenceCommand(tr("Lakewalker trace"), commands)); 275 getLayerManager().getEditDataSet().setSelected(ways);281 ds.setSelected(ways); 276 282 } else { 277 283 System.out.println("Failed"); … … 293 299 if (active) { 294 300 active = false; 295 Main.map.mapView.removeMouseListener(this); 296 Main.map.mapView.setCursor(oldCursor); 301 MapView mapView = MainApplication.getMap().mapView; 302 mapView.removeMouseListener(this); 303 mapView.setCursor(oldCursor); 297 304 lakewalk(e.getPoint()); 298 305 } -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerPlugin.java
r32676 r33712 7 7 8 8 import org.openstreetmap.josm.Main; 9 import org.openstreetmap.josm.gui.MainApplication; 9 10 import org.openstreetmap.josm.gui.MainMenu; 10 11 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; … … 20 21 public LakewalkerPlugin(PluginInformation info) { 21 22 super(info); 22 MainMenu.add(Main .main.menu.moreToolsMenu, new LakewalkerAction(tr("Lake Walker")));23 MainMenu.add(MainApplication.getMenu().moreToolsMenu, new LakewalkerAction(tr("Lake Walker"))); 23 24 } 24 25 … … 29 30 30 31 public static File getLakewalkerCacheDir() { 31 return new File(Main.pref.getCacheDirectory(), "lakewalkerwms"); 32 return new File(Main.pref.getCacheDirectory(true), "lakewalkerwms"); 32 33 } 33 34 } -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerPreferences.java
r33161 r33712 98 98 buildPreferences(prefPanel); 99 99 100 maxSegsConfig.setValue(Main.pref.getInt eger(PREF_MAX_SEG, 500));101 maxNodesConfig.setValue(Main.pref.getInt eger(PREF_MAX_NODES, 50000));102 thresholdConfig.setValue(Main.pref.getInt eger(PREF_THRESHOLD_VALUE, 90));100 maxSegsConfig.setValue(Main.pref.getInt(PREF_MAX_SEG, 500)); 101 maxNodesConfig.setValue(Main.pref.getInt(PREF_MAX_NODES, 50000)); 102 thresholdConfig.setValue(Main.pref.getInt(PREF_THRESHOLD_VALUE, 90)); 103 103 epsilonConfig.setValue(Main.pref.getDouble(PREF_EPSILON, 0.0003)); 104 landsatResConfig.setValue(Main.pref.getInt eger(PREF_LANDSAT_RES, 4000));105 landsatSizeConfig.setValue(Main.pref.getInt eger(PREF_LANDSAT_SIZE, 2000));104 landsatResConfig.setValue(Main.pref.getInt(PREF_LANDSAT_RES, 4000)); 105 landsatSizeConfig.setValue(Main.pref.getInt(PREF_LANDSAT_SIZE, 2000)); 106 106 eastOffsetConfig.setValue(Main.pref.getDouble(PREF_EAST_OFFSET, 0.0)); 107 107 northOffsetConfig.setValue(Main.pref.getDouble(PREF_NORTH_OFFSET, 0.0)); … … 110 110 wmsConfig.setValue(Main.pref.get(PREF_WMS, "IR1")); 111 111 sourceConfig.setValue(Main.pref.get(PREF_SOURCE, "Landsat")); 112 maxCacheSizeConfig.setValue(Main.pref.getInt eger(PREF_MAXCACHESIZE, 300));113 maxCacheAgeConfig.setValue(Main.pref.getInt eger(PREF_MAXCACHEAGE, 100));112 maxCacheSizeConfig.setValue(Main.pref.getInt(PREF_MAXCACHESIZE, 300)); 113 maxCacheAgeConfig.setValue(Main.pref.getInt(PREF_MAXCACHEAGE, 100)); 114 114 } 115 115
Note:
See TracChangeset
for help on using the changeset viewer.