Changeset 33640 in osm for applications/editors/josm/plugins/cadastre-fr/src
- Timestamp:
- 2017-09-19T23:37:58+02:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/CadastrePlugin.java
r33639 r33640 28 28 import org.openstreetmap.josm.data.projection.Projection; 29 29 import org.openstreetmap.josm.gui.IconToggleButton; 30 import org.openstreetmap.josm.gui.MainApplication; 30 31 import org.openstreetmap.josm.gui.MainMenu; 31 32 import org.openstreetmap.josm.gui.MapFrame; … … 50 51 import org.openstreetmap.josm.plugins.fr.cadastre.session.CadastreSessionImporter; 51 52 import org.openstreetmap.josm.plugins.fr.cadastre.wms.WMSLayer; 53 import org.openstreetmap.josm.tools.Logging; 52 54 53 55 /** … … 213 215 public CadastrePlugin(PluginInformation info) { 214 216 super(info); 215 Main.info("Pluging cadastre-fr v"+VERSION+" started...");217 Logging.info("Pluging cadastre-fr v"+VERSION+" started..."); 216 218 initCacheDir(); 217 219 … … 226 228 private static void initCacheDir() { 227 229 if (Main.pref.get("cadastrewms.cacheDir").isEmpty()) { 228 cacheDir = new File(Main.pref.getCacheDirectory( ), "cadastrewms").getAbsolutePath();230 cacheDir = new File(Main.pref.getCacheDirectory(true), "cadastrewms").getAbsolutePath(); 229 231 } else { 230 232 cacheDir = Main.pref.get("cadastrewms.cacheDir"); … … 232 234 if (cacheDir.charAt(cacheDir.length()-1) != File.separatorChar) 233 235 cacheDir += File.separatorChar; 234 Main.info("current cache directory: "+cacheDir);236 Logging.info("current cache directory: "+cacheDir); 235 237 } 236 238 237 239 public static void refreshMenu() { 238 MainMenu menu = Main .main.menu;240 MainMenu menu = MainApplication.getMenu(); 239 241 240 242 if (cadastreJMenu == null) { … … 253 255 @Override 254 256 public void actionPerformed(ActionEvent ev) { 255 Main.pref.put ("cadastrewms.autosourcing", menuSource.isSelected());257 Main.pref.putBoolean("cadastrewms.autosourcing", menuSource.isSelected()); 256 258 autoSourcing = menuSource.isSelected(); 257 259 } … … 360 362 JOptionPane.showMessageDialog(Main.parent, tr("Please enable at least two WMS layers in the cadastre-fr " 361 363 + "plugin configuration.\nLayers ''Building'' and ''Parcel'' added by default.")); 362 Main.pref.put ("cadastrewms.layerBuilding", true);363 Main.pref.put ("cadastrewms.layerParcel", true);364 Main.pref.putBoolean("cadastrewms.layerBuilding", true); 365 Main.pref.putBoolean("cadastrewms.layerParcel", true); 364 366 grabLayers += LAYER_BULDINGS + "," + LAYER_PARCELS; 365 367 grabStyles += STYLE_BUILDING + "," + STYLE_PARCELS; … … 391 393 if (oldFrame == null && newFrame != null) { 392 394 setEnabledAll(true); 393 Main .map.addMapMode(new IconToggleButton(new WMSAdjustAction()));394 Main .map.addMapMode(new IconToggleButton(new Address()));395 MainApplication.getMap().addMapMode(new IconToggleButton(new WMSAdjustAction())); 396 MainApplication.getMap().addMapMode(new IconToggleButton(new Address())); 395 397 } else if (oldFrame != null && newFrame == null) { 396 398 setEnabledAll(false); … … 450 452 Thread.sleep(milliseconds); 451 453 } catch (InterruptedException e) { 452 Main.debug(e);454 Logging.debug(e); 453 455 } 454 456 } … … 461 463 dialog.setAlwaysOnTop(true); 462 464 } catch (SecurityException e) { 463 Main.warn(tr("Warning: failed to put option pane dialog always on top. Exception was: {0}", e.toString()));465 Logging.warn(tr("Warning: failed to put option pane dialog always on top. Exception was: {0}", e.toString())); 464 466 } 465 467 } … … 476 478 */ 477 479 public static void addWMSLayer(WMSLayer wmsLayer) { 478 if (Main .map != null && Main.map.mapView != null) {479 int wmsNewLayerPos = Main .getLayerManager().getLayers().size();480 for (Layer l : Main .getLayerManager().getLayersOfType(WMSLayer.class)) {481 int wmsPos = Main .getLayerManager().getLayers().indexOf(l);480 if (MainApplication.isDisplayingMapView()) { 481 int wmsNewLayerPos = MainApplication.getLayerManager().getLayers().size(); 482 for (Layer l : MainApplication.getLayerManager().getLayersOfType(WMSLayer.class)) { 483 int wmsPos = MainApplication.getLayerManager().getLayers().indexOf(l); 482 484 if (wmsPos < wmsNewLayerPos) wmsNewLayerPos = wmsPos; 483 485 } 484 Main .getLayerManager().addLayer(wmsLayer);486 MainApplication.getLayerManager().addLayer(wmsLayer); 485 487 // Move the layer to its new position 486 Main .map.mapView.moveLayer(wmsLayer, wmsNewLayerPos);488 MainApplication.getMap().mapView.moveLayer(wmsLayer, wmsNewLayerPos); 487 489 } else 488 Main .getLayerManager().addLayer(wmsLayer);490 MainApplication.getLayerManager().addLayer(wmsLayer); 489 491 } 490 492 … … 499 501 year = Integer.decode(srcYear); 500 502 } catch (NumberFormatException e) { 501 Main.debug(e);503 Logging.debug(e); 502 504 } 503 505 if (srcYear.equals("AAAA") || (year != null && year < currentYear)) { 504 Main.info("Replace source year "+srcYear+" by current year "+currentYear);506 Logging.info("Replace source year "+srcYear+" by current year "+currentYear); 505 507 src = src.substring(0, src.lastIndexOf(" ")+1)+currentYear; 506 508 Main.pref.put("cadastrewms.source", src); -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionGrab.java
r33638 r33640 8 8 import java.awt.event.KeyEvent; 9 9 10 import org.openstreetmap.josm.Main;11 10 import org.openstreetmap.josm.actions.JosmAction; 11 import org.openstreetmap.josm.gui.MainApplication; 12 12 import org.openstreetmap.josm.plugins.fr.cadastre.CadastrePlugin; 13 13 import org.openstreetmap.josm.plugins.fr.cadastre.wms.DownloadWMSVectorImage; … … 33 33 @Override 34 34 public void actionPerformed(ActionEvent e) { 35 if (Main .map!= null) {35 if (MainApplication.getMap() != null) { 36 36 if (CadastrePlugin.isCadastreProjection()) { 37 37 WMSLayer wmsLayer = WMSDownloadAction.getLayer(); -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionGrabPlanImage.java
r33638 r33640 12 12 import org.openstreetmap.josm.Main; 13 13 import org.openstreetmap.josm.actions.JosmAction; 14 import org.openstreetmap.josm.gui.MainApplication; 14 15 import org.openstreetmap.josm.plugins.fr.cadastre.CadastrePlugin; 15 16 import org.openstreetmap.josm.plugins.fr.cadastre.wms.DownloadWMSPlanImage; … … 40 41 @Override 41 42 protected void updateEnabledState() { 42 if (wmsLayer == null || Main.map == null || Main.map.mapView == null) return;43 if (wmsLayer == null || !MainApplication.isDisplayingMapView()) return; 43 44 if (!rasterImageGeoreferencer.isRunning()) return; 44 if (Main .getLayerManager().containsLayer(wmsLayer))45 if (MainApplication.getLayerManager().containsLayer(wmsLayer)) 45 46 return; 46 47 JOptionPane.showMessageDialog(Main.parent, tr("Georeferencing interrupted")); … … 50 51 @Override 51 52 public void actionPerformed(ActionEvent ae) { 52 if (Main .map!= null) {53 if (MainApplication.getMap() != null) { 53 54 if (CadastrePlugin.isCadastreProjection()) { 54 55 wmsLayer = new MenuActionNewLocation().addNewLayer(new ArrayList<WMSLayer>()); … … 57 58 downloadWMSPlanImage.download(wmsLayer); 58 59 // download sub-images of the cadastre scan and join them into one single 59 Main .worker.execute(this);60 MainApplication.worker.execute(this); 60 61 } else { 61 62 CadastrePlugin.askToChangeProjection(); … … 69 70 boolean loadedFromCache = downloadWMSPlanImage.waitFinished(); 70 71 if (loadedFromCache) { 71 Main.map.repaint();72 wmsLayer.invalidate(); 72 73 } else if (wmsLayer.getImages().size() == 0) { 73 74 // action canceled or image loaded from cache (and already georeferenced) -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionLoadFromCache.java
r33638 r33640 13 13 import org.openstreetmap.josm.Main; 14 14 import org.openstreetmap.josm.actions.JosmAction; 15 import org.openstreetmap.josm.gui.MainApplication; 15 16 import org.openstreetmap.josm.gui.layer.Layer; 16 17 import org.openstreetmap.josm.plugins.fr.cadastre.CadastrePlugin; … … 20 21 import org.openstreetmap.josm.plugins.fr.cadastre.wms.CacheFileUTM20NFilter; 21 22 import org.openstreetmap.josm.plugins.fr.cadastre.wms.WMSLayer; 23 import org.openstreetmap.josm.tools.Logging; 22 24 23 25 public class MenuActionLoadFromCache extends JosmAction { … … 70 72 continue nextFile; 71 73 } else 72 Main.info("Load cache " + filename);74 Logging.info("Load cache " + filename); 73 75 } 74 76 } catch (NumberFormatException ex) { 75 JOptionPane.showMessageDialog(Main.parent, tr("Selected file {0} is not a cache file from this plugin (invalid extension)", filename), tr("Error"), JOptionPane.ERROR_MESSAGE); 77 JOptionPane.showMessageDialog(Main.parent, 78 tr("Selected file {0} is not a cache file from this plugin (invalid extension)", filename), 79 tr("Error"), JOptionPane.ERROR_MESSAGE); 76 80 continue nextFile; 77 81 } 78 82 // check if the selected cache is not already displayed 79 if (Main .map!= null) {80 for (Layer l : Main .getLayerManager().getLayers()) {83 if (MainApplication.getMap() != null) { 84 for (Layer l : MainApplication.getLayerManager().getLayers()) { 81 85 if (l instanceof WMSLayer && l.getName().equals(location)) { 82 JOptionPane.showMessageDialog(Main.parent, tr("The location {0} is already on screen. Cache not loaded.", filename), tr("Error"), JOptionPane.ERROR_MESSAGE); 86 JOptionPane.showMessageDialog(Main.parent, 87 tr("The location {0} is already on screen. Cache not loaded.", filename), 88 tr("Error"), JOptionPane.ERROR_MESSAGE); 83 89 continue nextFile; 84 90 } … … 93 99 } 94 100 } 95 96 101 } 97 102 -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionNewLocation.java
r33638 r33640 16 16 import org.openstreetmap.josm.Main; 17 17 import org.openstreetmap.josm.actions.JosmAction; 18 import org.openstreetmap.josm.gui.MainApplication; 18 19 import org.openstreetmap.josm.gui.layer.Layer; 19 20 import org.openstreetmap.josm.plugins.fr.cadastre.CadastrePlugin; … … 21 22 import org.openstreetmap.josm.plugins.fr.cadastre.wms.WMSLayer; 22 23 import org.openstreetmap.josm.tools.GBC; 24 import org.openstreetmap.josm.tools.Logging; 23 25 24 26 public class MenuActionNewLocation extends JosmAction { … … 116 118 Main.pref.put("cadastrewms.codeCommune", codeCommune); 117 119 Main.pref.put("cadastrewms.codeDepartement", codeDepartement); 118 if (Main .map!= null) {119 for (Layer l : Main .getLayerManager().getLayers()) {120 if (MainApplication.getMap() != null) { 121 for (Layer l : MainApplication.getLayerManager().getLayers()) { 120 122 if (l instanceof WMSLayer && l.getName().equalsIgnoreCase(location)) { 121 123 return null; … … 128 130 wmsLayer.setDepartement(codeDepartement); 129 131 CadastrePlugin.addWMSLayer(wmsLayer); 130 Main.info("Add new layer with Location:" + inputTown.getText());131 } else if (existingLayers != null && existingLayers.size() > 0 && Main .getLayerManager().getActiveLayer() instanceof WMSLayer) {132 wmsLayer = (WMSLayer) Main .getLayerManager().getActiveLayer();132 Logging.info("Add new layer with Location:" + inputTown.getText()); 133 } else if (existingLayers != null && existingLayers.size() > 0 && MainApplication.getLayerManager().getActiveLayer() instanceof WMSLayer) { 134 wmsLayer = (WMSLayer) MainApplication.getLayerManager().getActiveLayer(); 133 135 } 134 136 -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionRefineGeoRef.java
r33638 r33640 7 7 import java.awt.event.ActionEvent; 8 8 9 import org.openstreetmap.josm.Main;10 9 import org.openstreetmap.josm.actions.JosmAction; 11 10 import org.openstreetmap.josm.plugins.fr.cadastre.CadastrePlugin; 12 11 import org.openstreetmap.josm.plugins.fr.cadastre.wms.RasterImageGeoreferencer; 13 12 import org.openstreetmap.josm.plugins.fr.cadastre.wms.WMSLayer; 13 import org.openstreetmap.josm.tools.Logging; 14 14 15 15 public class MenuActionRefineGeoRef extends JosmAction { … … 33 33 public void actionPerformed(ActionEvent arg0) { 34 34 if (!wmsLayer.isRaster()) { 35 Main.info("MenuActionRefineGeoRef called for unexpected layer type");35 Logging.info("MenuActionRefineGeoRef called for unexpected layer type"); 36 36 return; 37 37 } -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionSaveRasterAs.java
r33638 r33640 28 28 import org.openstreetmap.josm.actions.JosmAction; 29 29 import org.openstreetmap.josm.plugins.fr.cadastre.wms.WMSLayer; 30 import org.openstreetmap.josm.tools.Logging; 30 31 31 32 public class MenuActionSaveRasterAs extends JosmAction { … … 107 108 } else if (fc.getFileFilter().equals(filtreTiff)) { 108 109 boolean alpha = bi.getColorModel().hasAlpha(); 109 Main.info("image with alpha channel : " + alpha);110 Logging.info("image with alpha channel : " + alpha); 110 111 try { 111 112 double x = wmsLayer.getImage(0).min.east(); … … 132 133 coverage.dispose(true); 133 134 } catch (Exception e) { 134 Main.error(e);135 Logging.error(e); 135 136 } 136 137 } -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/WMSDownloadAction.java
r33638 r33640 10 10 11 11 import org.openstreetmap.josm.Main; 12 import org.openstreetmap.josm.gui.MainApplication; 12 13 //import org.openstreetmap.josm.actions.JosmAction; 13 14 import org.openstreetmap.josm.gui.layer.Layer; 14 15 import org.openstreetmap.josm.plugins.fr.cadastre.wms.WMSLayer; 15 16 16 publicclass WMSDownloadAction {17 final class WMSDownloadAction { 17 18 18 public static WMSLayer getLayer() { 19 private WMSDownloadAction() { 20 // Hide default constructor 21 } 22 23 static WMSLayer getLayer() { 19 24 // check if we already have a layer created. if not, create; if yes, reuse. 20 25 ArrayList<WMSLayer> existingWMSlayers = new ArrayList<>(); 21 if (Main .map!= null) {22 Layer activeLayer = Main .getLayerManager().getActiveLayer();26 if (MainApplication.getMap() != null) { 27 Layer activeLayer = MainApplication.getLayerManager().getActiveLayer(); 23 28 if (activeLayer instanceof WMSLayer) 24 29 return (WMSLayer) activeLayer; 25 for (Layer l : Main .getLayerManager().getLayers()) {30 for (Layer l : MainApplication.getLayerManager().getLayers()) { 26 31 if (l instanceof WMSLayer) { 27 32 existingWMSlayers.add((WMSLayer) l); -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/mapmode/Address.java
r33638 r33640 56 56 import org.openstreetmap.josm.data.osm.Way; 57 57 import org.openstreetmap.josm.data.osm.WaySegment; 58 import org.openstreetmap.josm.gui.MainApplication; 58 59 import org.openstreetmap.josm.gui.MapView; 59 60 import org.openstreetmap.josm.tools.GBC; 60 61 import org.openstreetmap.josm.tools.ImageProvider; 62 import org.openstreetmap.josm.tools.Logging; 61 63 import org.openstreetmap.josm.tools.Pair; 62 64 import org.openstreetmap.josm.tools.Shortcut; … … 108 110 } 109 111 dialog.setVisible(true); 110 Main .map.mapView.addMouseListener(this);112 MainApplication.getMap().mapView.addMouseListener(this); 111 113 } 112 114 113 115 @Override public void exitMode() { 114 if (Main .map.mapView != null) {116 if (MainApplication.getMap().mapView != null) { 115 117 super.exitMode(); 116 Main .map.mapView.removeMouseListener(this);118 MainApplication.getMap().mapView.removeMouseListener(this); 117 119 } 118 120 // kill the window completely to fix an issue on some linux distro and full screen mode. … … 129 131 shift = (e.getModifiers() & ActionEvent.SHIFT_MASK) != 0; 130 132 ctrl = (e.getModifiers() & ActionEvent.CTRL_MASK) != 0; 131 MapView mv = Main .map.mapView;133 MapView mv = MainApplication.getMap().mapView; 132 134 Point mousePos = e.getPoint(); 133 135 List<Way> mouseOnExistingWays = new ArrayList<>(); … … 155 157 inputNumber.setText(num); 156 158 applyInputNumberChange(); 157 } catch (NumberFormatException e n) {158 Main.warn("Unable to parse house number \"" + num + "\"");159 } catch (NumberFormatException ex) { 160 Logging.warn("Unable to parse house number \"" + num + "\""); 159 161 } 160 162 } … … 248 250 try { 249 251 revertInputNumberChange(); 250 } catch (NumberFormatException e n) {251 Main.warn("Unable to parse house number \"" + inputNumber.getText() + "\"");252 } catch (NumberFormatException ex) { 253 Logging.warn("Unable to parse house number \"" + inputNumber.getText() + "\""); 252 254 } 253 255 } … … 259 261 Main.main.undoRedo.add(c); 260 262 setNewSelection(osm); 261 } catch (NumberFormatException e n) {262 Main.warn("Unable to parse house number \"" + inputNumber.getText() + "\"");263 } catch (NumberFormatException ex) { 264 Logging.warn("Unable to parse house number \"" + inputNumber.getText() + "\""); 263 265 } 264 266 } … … 292 294 newRel.addMember(new RelationMember(relationAddrStreetRole, selectedWay)); 293 295 newRel.addMember(new RelationMember(relationMemberHouse, osm)); 294 cmds.add(new AddCommand( newRel));296 cmds.add(new AddCommand(Main.main.getEditDataSet(), newRel)); 295 297 } 296 298 } … … 299 301 private static Node createNewNode(MouseEvent e, Collection<Command> cmds) { 300 302 // DrawAction.mouseReleased() but without key modifiers 301 Node n = new Node(Main .map.mapView.getLatLon(e.getX(), e.getY()));302 cmds.add(new AddCommand( n));303 List<WaySegment> wss = Main .map.mapView.getNearestWaySegments(e.getPoint(), OsmPrimitive::isSelectable);303 Node n = new Node(MainApplication.getMap().mapView.getLatLon(e.getX(), e.getY())); 304 cmds.add(new AddCommand(Main.main.getEditDataSet(), n)); 305 List<WaySegment> wss = MainApplication.getMap().mapView.getNearestWaySegments(e.getPoint(), OsmPrimitive::isSelectable); 304 306 Map<Way, List<Integer>> insertPoints = new HashMap<>(); 305 307 for (WaySegment ws : wss) { … … 370 372 371 373 int snapToIntersectionThreshold 372 = Main.pref.getInt eger("edit.snap-intersection-threshold", 10);374 = Main.pref.getInt("edit.snap-intersection-threshold", 10); 373 375 374 376 // only adjust to intersection if within snapToIntersectionThreshold pixel of mouse click; otherwise 375 377 // fall through to default action. 376 378 // (for semi-parallel lines, intersection might be miles away!) 377 if (Main .map.mapView.getPoint(n).distance(Main.map.mapView.getPoint(intersection)) < snapToIntersectionThreshold) {379 if (MainApplication.getMap().mapView.getPoint(n).distance(MainApplication.getMap().mapView.getPoint(intersection)) < snapToIntersectionThreshold) { 378 380 n.setEastNorth(intersection); 379 381 return; … … 414 416 return ImageProvider.getCursor("crosshair", null); 415 417 } catch (RuntimeException e) { 416 Main.warn(e);418 Logging.warn(e); 417 419 } 418 420 return Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR); … … 480 482 @Override 481 483 public void stateChanged(ChangeEvent arg0) { 482 Main.pref.put ("cadastrewms.addr.onBuilding", tagPolygon.isSelected());484 Main.pref.putBoolean("cadastrewms.addr.onBuilding", tagPolygon.isSelected()); 483 485 } 484 486 }); … … 511 513 @Override 512 514 public void windowClosing(WindowEvent arg) { 513 Main .map.selectMapMode((MapMode) Main.map.getDefaultButtonAction());515 MainApplication.getMap().selectMapMode((MapMode) MainApplication.getMap().getDefaultButtonAction()); 514 516 } 515 517 }); … … 532 534 533 535 private static void setNewSelection(OsmPrimitive osm) { 534 DataSet ds = Main .getLayerManager().getEditDataSet();536 DataSet ds = MainApplication.getLayerManager().getEditDataSet(); 535 537 Collection<OsmPrimitive> newSelection = new LinkedList<>(ds.getSelected()); 536 538 newSelection.clear(); -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/mapmode/WMSAdjustAction.java
r33638 r33640 15 15 import javax.swing.JOptionPane; 16 16 17 import org.openstreetmap.josm.Main;18 17 import org.openstreetmap.josm.actions.mapmode.MapMode; 19 18 import org.openstreetmap.josm.data.coor.EastNorth; 19 import org.openstreetmap.josm.gui.MainApplication; 20 20 import org.openstreetmap.josm.gui.MapView; 21 21 import org.openstreetmap.josm.plugins.fr.cadastre.wms.CacheControl; … … 45 45 46 46 @Override public void enterMode() { 47 if (Main .map!= null) {48 if (Main .getLayerManager().getActiveLayer() instanceof WMSLayer) {49 modifiedLayer = (WMSLayer) Main .getLayerManager().getActiveLayer();47 if (MainApplication.getMap() != null) { 48 if (MainApplication.getLayerManager().getActiveLayer() instanceof WMSLayer) { 49 modifiedLayer = (WMSLayer) MainApplication.getLayerManager().getActiveLayer(); 50 50 super.enterMode(); 51 Main .map.mapView.addMouseListener(this);52 Main .map.mapView.addMouseMotionListener(this);51 MainApplication.getMap().mapView.addMouseListener(this); 52 MainApplication.getMap().mapView.addMouseMotionListener(this); 53 53 rasterMoved = false; 54 54 modifiedLayer.adjustModeEnabled = true; … … 58 58 exitMode(); 59 59 } 60 Main .map.selectMapMode((MapMode) Main.map.getDefaultButtonAction());60 MainApplication.getMap().selectMapMode((MapMode) MainApplication.getMap().getDefaultButtonAction()); 61 61 } 62 62 } … … 65 65 @Override public void exitMode() { 66 66 super.exitMode(); 67 Main .map.mapView.removeMouseListener(this);68 Main .map.mapView.removeMouseMotionListener(this);67 MainApplication.getMap().mapView.removeMouseListener(this); 68 MainApplication.getMap().mapView.removeMouseMotionListener(this); 69 69 if (rasterMoved && CacheControl.cacheEnabled && modifiedLayer.isRaster()) { 70 70 int reply = JOptionPane.showConfirmDialog(null, … … 98 98 mode = Mode.moveXY; 99 99 rasterMoved = true; 100 prevEastNorth = Main .map.mapView.getEastNorth(e.getX(), e.getY());101 Main .map.mapView.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));100 prevEastNorth = MainApplication.getMap().mapView.getEastNorth(e.getX(), e.getY()); 101 MainApplication.getMap().mapView.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); 102 102 } 103 103 104 104 @Override public void mouseDragged(MouseEvent e) { 105 EastNorth newEastNorth = Main .map.mapView.getEastNorth(e.getX(), e.getY());105 EastNorth newEastNorth = MainApplication.getMap().mapView.getEastNorth(e.getX(), e.getY()); 106 106 if (mode == Mode.rotate) { 107 107 rotateFrameOnly(prevEastNorth, newEastNorth); … … 168 168 public void mouseReleased(MouseEvent e) { 169 169 if (mode == Mode.rotate) { 170 EastNorth newEastNorth = Main .map.mapView.getEastNorth(e.getX(), e.getY());170 EastNorth newEastNorth = MainApplication.getMap().mapView.getEastNorth(e.getX(), e.getY()); 171 171 rotate(prevEastNorth, newEastNorth); 172 172 if (modifiedLayer != null) { … … 174 174 } 175 175 } 176 Main .map.mapView.setCursor(Cursor.getDefaultCursor());176 MainApplication.getMap().mapView.setCursor(Cursor.getDefaultCursor()); 177 177 prevEastNorth = null; 178 178 mode = null; -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/preferences/CadastrePreferenceSetting.java
r33638 r33640 31 31 import org.openstreetmap.josm.tools.I18n; 32 32 import org.openstreetmap.josm.tools.ImageProvider; 33 import org.openstreetmap.josm.tools.Logging; 33 34 34 35 /** … … 385 386 Main.pref.put("cadastrewms.source", sourcing.getText()); 386 387 CadastrePlugin.source = sourcing.getText(); 387 Main.pref.put ("cadastrewms.alterColors", alterColors.isSelected());388 Main.pref.put ("cadastrewms.invertGrey", reversGrey.isSelected());389 Main.pref.put ("cadastrewms.backgroundTransparent", transparency.isSelected());388 Main.pref.putBoolean("cadastrewms.alterColors", alterColors.isSelected()); 389 Main.pref.putBoolean("cadastrewms.invertGrey", reversGrey.isSelected()); 390 Main.pref.putBoolean("cadastrewms.backgroundTransparent", transparency.isSelected()); 390 391 Main.pref.put("cadastrewms.brightness", Float.toString((float) sliderTrans.getValue()/10)); 391 Main.pref.put ("cadastrewms.drawBoundaries", drawBoundaries.isSelected());392 Main.pref.putBoolean("cadastrewms.drawBoundaries", drawBoundaries.isSelected()); 392 393 if (grabRes1.isSelected()) 393 394 Main.pref.put("cadastrewms.resolution", "high"); … … 415 416 Main.pref.put("cadastrewms.squareSize", grabMultiplier4Size.getText()); 416 417 } catch (NumberFormatException e) { 417 Main.debug(e);418 Logging.debug(e); 418 419 } 419 420 } 420 Main.pref.put ("cadastrewms.layerWater", layerLS3.isSelected());421 Main.pref.put ("cadastrewms.layerBuilding", layerLS2.isSelected());422 Main.pref.put ("cadastrewms.layerSymbol", layerLS1.isSelected());423 Main.pref.put ("cadastrewms.layerParcel", layerParcel.isSelected());424 Main.pref.put ("cadastrewms.layerLabel", layerLabel.isSelected());425 Main.pref.put ("cadastrewms.layerNumero", layerNumero.isSelected());426 Main.pref.put ("cadastrewms.layerLieudit", layerLieudit.isSelected());427 Main.pref.put ("cadastrewms.layerSection", layerSection.isSelected());428 Main.pref.put ("cadastrewms.layerCommune", layerCommune.isSelected());421 Main.pref.putBoolean("cadastrewms.layerWater", layerLS3.isSelected()); 422 Main.pref.putBoolean("cadastrewms.layerBuilding", layerLS2.isSelected()); 423 Main.pref.putBoolean("cadastrewms.layerSymbol", layerLS1.isSelected()); 424 Main.pref.putBoolean("cadastrewms.layerParcel", layerParcel.isSelected()); 425 Main.pref.putBoolean("cadastrewms.layerLabel", layerLabel.isSelected()); 426 Main.pref.putBoolean("cadastrewms.layerNumero", layerNumero.isSelected()); 427 Main.pref.putBoolean("cadastrewms.layerLieudit", layerLieudit.isSelected()); 428 Main.pref.putBoolean("cadastrewms.layerSection", layerSection.isSelected()); 429 Main.pref.putBoolean("cadastrewms.layerCommune", layerCommune.isSelected()); 429 430 try { 430 431 int i = Integer.parseInt(rasterDivider.getText()); … … 432 433 Main.pref.put("cadastrewms.rasterDivider", String.valueOf(i)); 433 434 } catch (NumberFormatException e) { 434 Main.debug(e);435 Logging.debug(e); 435 436 } 436 Main.pref.put ("cadastrewms.noImageCropping", disableImageCropping.isSelected());437 Main.pref.put ("cadastrewms.useTA", enableTableauAssemblage.isSelected());438 Main.pref.put ("cadastrewms.raster2bitsColors", simplify2BitsColors.isSelected());437 Main.pref.putBoolean("cadastrewms.noImageCropping", disableImageCropping.isSelected()); 438 Main.pref.putBoolean("cadastrewms.useTA", enableTableauAssemblage.isSelected()); 439 Main.pref.putBoolean("cadastrewms.raster2bitsColors", simplify2BitsColors.isSelected()); 439 440 if (crosspiece1.isSelected()) Main.pref.put("cadastrewms.crosspieces", "0"); 440 441 else if (crosspiece2.isSelected()) Main.pref.put("cadastrewms.crosspieces", "1"); 441 442 else if (crosspiece3.isSelected()) Main.pref.put("cadastrewms.crosspieces", "2"); 442 443 else if (crosspiece4.isSelected()) Main.pref.put("cadastrewms.crosspieces", "3"); 443 Main.pref.put ("cadastrewms.enableCaching", enableCache.isSelected());444 Main.pref.putBoolean("cadastrewms.enableCaching", enableCache.isSelected()); 444 445 445 446 // spread data into objects instead of restarting the application … … 448 449 Main.pref.put("cadastrewms.cacheSize", String.valueOf(CacheControl.cacheSize)); 449 450 } catch (NumberFormatException e) { 450 Main.debug(e);451 Logging.debug(e); 451 452 } 452 Main.pref.put ("cadastrewms.autoFirstLayer", autoFirstLayer.isSelected());453 Main.pref.putBoolean("cadastrewms.autoFirstLayer", autoFirstLayer.isSelected()); 453 454 CacheControl.cacheEnabled = enableCache.isSelected(); 454 Main.pref.put ("cadastrewms.addr.dontUseRelation", dontUseRelation.isSelected());455 Main.pref.putBoolean("cadastrewms.addr.dontUseRelation", dontUseRelation.isSelected()); 455 456 CadastrePlugin.refreshConfiguration(); 456 457 CadastrePlugin.refreshMenu(); -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/CacheControl.java
r33638 r33640 24 24 import org.openstreetmap.josm.plugins.fr.cadastre.CadastrePlugin; 25 25 import org.openstreetmap.josm.plugins.fr.cadastre.preferences.CadastrePreferenceSetting; 26 import org.openstreetmap.josm.tools.Logging; 26 27 27 28 /** … … 97 98 } 98 99 if (size > (long) cacheSize*1024*1024) { 99 Main.info("Delete oldest file \""+ files[oldestFile].getName()100 Logging.info("Delete oldest file \""+ files[oldestFile].getName() 100 101 + "\" in cache dir to stay under the limit of " + cacheSize + " MB."); 101 102 files[oldestFile].delete(); … … 142 143 143 144 private static void delete(File file) { 144 Main.info("Delete file "+file);145 Logging.info("Delete file "+file); 145 146 if (file.exists()) 146 147 file.delete(); … … 158 159 successfulRead = wmsLayer.read(file, ois, currentLambertZone); 159 160 } catch (IOException | ClassNotFoundException ex) { 160 Main.error(ex); 161 GuiHelper.runInEDTAndWait(new Runnable() { 162 @Override 163 public void run() { 164 JOptionPane.showMessageDialog(Main.parent, tr("Error loading file.\nProbably an old version of the cache file."), 165 tr("Error"), JOptionPane.ERROR_MESSAGE); 166 } 167 }); 161 Logging.error(ex); 162 GuiHelper.runInEDTAndWait(() -> JOptionPane.showMessageDialog(Main.parent, 163 tr("Error loading file.\nProbably an old version of the cache file."), 164 tr("Error"), JOptionPane.ERROR_MESSAGE)); 168 165 return false; 169 166 } … … 211 208 } 212 209 } catch (IOException e) { 213 Main.error(e);210 Logging.error(e); 214 211 } 215 212 imagesLock.lock(); … … 222 219 wait(); 223 220 } catch (InterruptedException e) { 224 Main.error(e);221 Logging.error(e); 225 222 } 226 223 } -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/CadastreGrabber.java
r33638 r33640 12 12 import javax.imageio.ImageIO; 13 13 14 import org.openstreetmap.josm.Main;15 14 import org.openstreetmap.josm.data.coor.EastNorth; 16 15 import org.openstreetmap.josm.io.OsmTransferException; 17 16 import org.openstreetmap.josm.plugins.fr.cadastre.CadastrePlugin; 17 import org.openstreetmap.josm.tools.Logging; 18 18 19 19 public class CadastreGrabber { … … 56 56 str += (int) (cRasterX*(wmsLayer.communeBBox.max.getY() - wmsLayer.communeBBox.min.getY())/(wmsLayer.communeBBox.max.getX() - wmsLayer.communeBBox.min.getX())); 57 57 str += "&exception=application/vnd.ogc.se_inimage&styles="; // required for raster images 58 Main.info("URL="+str);58 Logging.info("URL="+str); 59 59 return new URL(str.replace(" ", "%20")); 60 60 } … … 73 73 str += "&exception=application/vnd.ogc.se_inimage"; // works also without (but slower ?) 74 74 str += "&styles=" + styles; 75 Main.info("URL="+str);75 Logging.info("URL="+str); 76 76 return new URL(str.replace(" ", "%20")); 77 77 } -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/CadastreInterface.java
r33638 r33640 29 29 import org.openstreetmap.josm.data.coor.EastNorth; 30 30 import org.openstreetmap.josm.data.validation.util.Entities; 31 import org.openstreetmap.josm.gui.MainApplication; 31 32 import org.openstreetmap.josm.gui.layer.Layer; 32 33 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; … … 36 37 import org.openstreetmap.josm.plugins.fr.cadastre.CadastrePlugin; 37 38 import org.openstreetmap.josm.tools.GBC; 39 import org.openstreetmap.josm.tools.Logging; 38 40 39 41 public class CadastreInterface { … … 103 105 openInterface(); 104 106 } catch (IOException e) { 105 Main.error(e);107 Logging.error(e); 106 108 GuiHelper.runInEDT(() -> 107 109 JOptionPane.showMessageDialog(Main.parent, … … 129 131 urlConn.connect(); 130 132 if (urlConn.getResponseCode() == HttpURLConnection.HTTP_OK) { 131 Main.info("GET "+searchFormURL);133 Logging.info("GET "+searchFormURL); 132 134 BufferedReader in = new BufferedReader(new InputStreamReader(urlConn.getInputStream(), StandardCharsets.UTF_8)); 133 135 while (in.readLine() != null) { … … 151 153 } 152 154 } else { 153 Main.warn("Request to home page failed. Http error:"+urlConn.getResponseCode()+". Try again "+retries+" times");155 Logging.warn("Request to home page failed. Http error:"+urlConn.getResponseCode()+". Try again "+retries+" times"); 154 156 CadastrePlugin.safeSleep(3000); 155 157 retries--; … … 164 166 cookie = pCookie; 165 167 if (cookie == null || cookie.isEmpty()) { 166 Main.warn("received empty cookie");168 Logging.warn("received empty cookie"); 167 169 cookie = null; 168 170 } else { … … 172 174 } 173 175 cookieTimestamp = new Date().getTime(); 174 Main.info("received cookie=" + cookie + " at " + new Date(cookieTimestamp));176 Logging.info("received cookie=" + cookie + " at " + new Date(cookieTimestamp)); 175 177 } 176 178 return cookie != null; … … 185 187 long now = new Date().getTime(); 186 188 if ((now - cookieTimestamp) > COOKIE_EXPIRATION) { 187 Main.info("cookie received at "+new Date(cookieTimestamp)+" expired (now is "+new Date(now)+")");189 Logging.info("cookie received at "+new Date(cookieTimestamp)+" expired (now is "+new Date(now)+")"); 188 190 return true; 189 191 } … … 256 258 throw new IOException("Cannot open Cadastre interface. GET response:"+urlConn.getResponseCode()); 257 259 } 258 Main.info("GET "+interfaceURL);260 Logging.info("GET "+interfaceURL); 259 261 BufferedReader in = new BufferedReader(new InputStreamReader(urlConn.getInputStream(), StandardCharsets.UTF_8)); 260 262 // read the buffer otherwise we sent POST too early … … 262 264 String ln; 263 265 while ((ln = in.readLine()) != null) { 264 if ( Main.isDebugEnabled()) {266 if (Logging.isDebugEnabled()) { 265 267 lines.append(ln); 266 268 } 267 269 } 268 if ( Main.isDebugEnabled()) {269 Main.debug(lines.toString());270 if (Logging.isDebugEnabled()) { 271 Logging.debug(lines.toString()); 270 272 } 271 273 } catch (MalformedURLException e) { … … 319 321 try (OutputStream wr = urlConn.getOutputStream()) { 320 322 wr.write(content.getBytes(StandardCharsets.UTF_8)); 321 Main.info("POST "+content);323 Logging.info("POST "+content); 322 324 wr.flush(); 323 325 } … … 342 344 lines = lines.substring(0, lines.indexOf('\'')); 343 345 lines = Entities.unescape(lines); 344 Main.info("interface ref.:"+lines);346 Logging.info("interface ref.:"+lines); 345 347 return lines; 346 348 } else if (wmsLayer.isRaster() && lines.indexOf(C_INTERFACE_RASTER_TA) != -1) { // "afficherCarteTa.do" … … 358 360 lines = buildRasterFeuilleInterfaceRef(listOfFeuilles.get(res).ref); 359 361 lines = Entities.unescape(lines); 360 Main.info("interface ref.:"+lines);362 Logging.info("interface ref.:"+lines); 361 363 return lines; 362 364 } … … 374 376 throw (IOException) new IOException("Illegal url.").initCause(e); 375 377 } catch (DuplicateLayerException e) { 376 Main.error(e);378 Logging.error(e); 377 379 } 378 380 return null; … … 388 390 String lov = input.substring(i+C_OPTION_LIST_START.length()-1, j); 389 391 if (lov.indexOf('>') != -1) { 390 Main.info("parse "+lov);392 Logging.info("parse "+lov); 391 393 listOfCommunes.add(lov); 392 394 } else 393 Main.error("unable to parse commune string:"+lov);395 Logging.error("unable to parse commune string:"+lov); 394 396 } 395 397 input = input.substring(j+C_OPTION_LIST_END.length()); … … 408 410 setCookie(urlConn2); 409 411 urlConn2.connect(); 410 Main.info("GET "+getAllImagesURL);412 Logging.info("GET "+getAllImagesURL); 411 413 try (BufferedReader rd = new BufferedReader(new InputStreamReader(urlConn2.getInputStream(), StandardCharsets.UTF_8))) { 412 414 while ((ln = rd.readLine()) != null) { … … 417 419 } catch (IOException e) { 418 420 listOfFeuilles.clear(); 419 Main.error(e);421 Logging.error(e); 420 422 } 421 423 return lines.toString(); … … 510 512 throw new IOException("Cannot get Cadastre response."); 511 513 } 512 Main.info("GET "+searchFormURL);514 Logging.info("GET "+searchFormURL); 513 515 String ln; 514 516 StringBuilder sb = new StringBuilder(); … … 578 580 579 581 private static void checkLayerDuplicates(WMSLayer wmsLayer) throws DuplicateLayerException { 580 if (Main .map!= null) {581 for (Layer l : Main .getLayerManager().getLayers()) {582 if (MainApplication.getMap() != null) { 583 for (Layer l : MainApplication.getLayerManager().getLayers()) { 582 584 if (l instanceof WMSLayer && l.getName().equals(wmsLayer.getName()) && (!l.equals(wmsLayer))) { 583 Main.info("Try to grab into a new layer when "+wmsLayer.getName()+" is already opened.");585 Logging.info("Try to grab into a new layer when "+wmsLayer.getName()+" is already opened."); 584 586 // remove the duplicated layer 585 Main .getLayerManager().removeLayer(wmsLayer);587 MainApplication.getLayerManager().removeLayer(wmsLayer); 586 588 throw new DuplicateLayerException(); 587 589 } -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/DownloadSVGBuilding.java
r33638 r33640 28 28 import org.openstreetmap.josm.data.osm.Node; 29 29 import org.openstreetmap.josm.data.osm.Way; 30 import org.openstreetmap.josm.gui.MainApplication; 30 31 import org.openstreetmap.josm.gui.MapView; 31 32 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 32 33 import org.openstreetmap.josm.io.OsmTransferException; 33 34 import org.openstreetmap.josm.plugins.fr.cadastre.CadastrePlugin; 35 import org.openstreetmap.josm.tools.Logging; 34 36 35 37 public class DownloadSVGBuilding extends PleaseWaitRunnable { … … 67 69 } 68 70 } catch (DuplicateLayerException e) { 69 Main.warn("removed a duplicated layer");71 Logging.warn("removed a duplicated layer"); 70 72 } catch (WMSException e) { 71 73 errorMessage = e.getMessage(); … … 91 93 return true; 92 94 } 93 Main.warn("Unable to parse SVG data (viewBox)");95 Logging.warn("Unable to parse SVG data (viewBox)"); 94 96 return false; 95 97 } … … 137 139 // check if the new way or its nodes is already in OSM layer 138 140 for (Node n : svgDataSet.getNodes()) { 139 Node nearestNewNode = checkNearestNode(n, Main .getLayerManager().getEditDataSet().getNodes());141 Node nearestNewNode = checkNearestNode(n, MainApplication.getLayerManager().getEditDataSet().getNodes()); 140 142 if (nearestNewNode != n) { 141 143 // replace the SVG node by the OSM node … … 153 155 n.setDeleted(true); 154 156 } 155 156 } 157 157 } 158 159 DataSet ds = Main.main.getEditDataSet(); 158 160 Collection<Command> cmds = new LinkedList<>(); 159 161 for (Node node : svgDataSet.getNodes()) { 160 162 if (!node.isDeleted()) 161 cmds.add(new AddCommand( node));163 cmds.add(new AddCommand(ds, node)); 162 164 } 163 165 for (Way way : svgDataSet.getWays()) { 164 166 if (!way.isDeleted()) 165 cmds.add(new AddCommand( way));167 cmds.add(new AddCommand(ds, way)); 166 168 } 167 169 Main.main.undoRedo.add(new SequenceCommand(tr("Create buildings"), cmds)); 168 Main .map.repaint();170 MainApplication.getMap().repaint(); 169 171 } 170 172 … … 233 235 str += "&styles="; 234 236 str += "LS2_90"; 235 Main.info("URL="+str);237 Logging.info("URL="+str); 236 238 return new URL(str.replace(" ", "%20")); 237 239 } … … 254 256 } 255 257 } catch (IOException e) { 256 Main.error(e);258 Logging.error(e); 257 259 } 258 260 return svg; … … 260 262 261 263 public static void download(WMSLayer wmsLayer) { 262 MapView mv = Main .map.mapView;264 MapView mv = MainApplication.getMap().mapView; 263 265 currentView = new EastNorthBound(mv.getEastNorth(0, mv.getHeight()), 264 266 mv.getEastNorth(mv.getWidth(), 0)); … … 274 276 return; 275 277 } 276 Main .worker.execute(new DownloadSVGBuilding(wmsLayer));278 MainApplication.worker.execute(new DownloadSVGBuilding(wmsLayer)); 277 279 if (errorMessage != null) 278 280 JOptionPane.showMessageDialog(Main.parent, errorMessage); -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/DownloadSVGTask.java
r33638 r33640 27 27 import org.openstreetmap.josm.command.SequenceCommand; 28 28 import org.openstreetmap.josm.data.coor.EastNorth; 29 import org.openstreetmap.josm.data.osm.DataSet; 29 30 import org.openstreetmap.josm.data.osm.Node; 30 31 import org.openstreetmap.josm.data.osm.Way; 32 import org.openstreetmap.josm.gui.MainApplication; 31 33 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 32 34 import org.openstreetmap.josm.io.OsmTransferException; 33 35 import org.openstreetmap.josm.plugins.fr.cadastre.CadastrePlugin; 36 import org.openstreetmap.josm.tools.Logging; 34 37 35 38 /** … … 74 77 } 75 78 } catch (DuplicateLayerException e) { 76 Main.warn("removed a duplicated layer");79 Logging.warn("removed a duplicated layer"); 77 80 } catch (WMSException e) { 78 81 errorMessage = e.getMessage(); … … 98 101 return true; 99 102 } 100 Main.warn("Unable to parse SVG data (viewBox)");103 Logging.warn("Unable to parse SVG data (viewBox)"); 101 104 return false; 102 105 } … … 123 126 } 124 127 Way wayToAdd = new Way(); 128 DataSet ds = Main.main.getEditDataSet(); 125 129 Collection<Command> cmds = new LinkedList<>(); 126 130 for (Node node : nodeList) { 127 cmds.add(new AddCommand( node));131 cmds.add(new AddCommand(ds, node)); 128 132 wayToAdd.addNode(node); 129 133 } 130 134 wayToAdd.addNode(wayToAdd.getNode(0)); // close the circle 131 135 132 cmds.add(new AddCommand( wayToAdd));136 cmds.add(new AddCommand(ds, wayToAdd)); 133 137 Main.main.undoRedo.add(new SequenceCommand(tr("Create boundary"), cmds)); 134 Main .map.repaint();138 MainApplication.getMap().repaint(); 135 139 } 136 140 … … 183 187 str += "&styles="; 184 188 str += "COMMUNE_90"; 185 Main.info("URL="+str);189 Logging.info("URL="+str); 186 190 return new URL(str.replace(" ", "%20")); 187 191 } … … 204 208 } 205 209 } catch (IOException e) { 206 Main.error(e);210 Logging.error(e); 207 211 } 208 212 return svg; … … 215 219 return; 216 220 } 217 Main .worker.execute(new DownloadSVGTask(wmsLayer));221 MainApplication.worker.execute(new DownloadSVGTask(wmsLayer)); 218 222 if (errorMessage != null) 219 223 JOptionPane.showMessageDialog(Main.parent, errorMessage); -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/DownloadWMSPlanImage.java
r33638 r33640 12 12 import org.openstreetmap.josm.Main; 13 13 import org.openstreetmap.josm.data.Bounds; 14 import org.openstreetmap.josm.gui.MainApplication; 14 15 import org.openstreetmap.josm.gui.MapView; 15 16 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 16 17 import org.openstreetmap.josm.plugins.fr.cadastre.CadastrePlugin; 18 import org.openstreetmap.josm.tools.Logging; 17 19 18 20 public class DownloadWMSPlanImage { … … 83 85 } catch (DuplicateLayerException e) { 84 86 // we tried to grab onto a duplicated layer (removed) 85 Main.warn("removed a duplicated layer");87 Logging.warn("removed a duplicated layer"); 86 88 } catch (WMSException e) { 87 89 errorMessage = e.getMessage(); … … 102 104 103 105 public void download(WMSLayer wmsLayer) { 104 MapView mv = Main .map.mapView;106 MapView mv = MainApplication.getMap().mapView; 105 107 Bounds bounds = new Bounds(mv.getLatLon(0, mv.getHeight()), mv.getLatLon(mv.getWidth(), 0)); 106 108 dontGeoreference = false; … … 110 112 this.wmsLayer = wmsLayer; 111 113 this.bounds = bounds; 112 task = Main .worker.submit(t, t);114 task = MainApplication.worker.submit(t, t); 113 115 if (errorMessage != null) 114 116 JOptionPane.showMessageDialog(Main.parent, errorMessage); -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/DownloadWMSVectorImage.java
r33638 r33640 10 10 import org.openstreetmap.josm.Main; 11 11 import org.openstreetmap.josm.data.Bounds; 12 import org.openstreetmap.josm.gui.MainApplication; 12 13 import org.openstreetmap.josm.gui.MapView; 13 14 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 15 import org.openstreetmap.josm.tools.Logging; 14 16 15 17 public class DownloadWMSVectorImage extends PleaseWaitRunnable { … … 36 38 if (CacheControl.cacheEnabled) { 37 39 if (wmsLayer.grabThread.getCacheControl().loadCacheIfExist()) { 38 Main .map.mapView.zoomTo(wmsLayer.getFirstViewFromCacheBBox().toBounds());40 MainApplication.getMap().mapView.zoomTo(wmsLayer.getFirstViewFromCacheBBox().toBounds()); 39 41 return; 40 42 } … … 44 46 JOptionPane.showMessageDialog(Main.parent, 45 47 tr("This commune is not vectorized.\nPlease use the other menu entry to georeference a \"Plan image\"")); 46 Main .getLayerManager().removeLayer(wmsLayer);48 MainApplication.getLayerManager().removeLayer(wmsLayer); 47 49 wmsLayer = null; 48 50 return; … … 56 58 } else if (!wmsLayer.hasImages()) { 57 59 // failed to contact WMS of find this commune. Remove layer if empty. 58 Main .getLayerManager().removeLayer(wmsLayer);60 MainApplication.getLayerManager().removeLayer(wmsLayer); 59 61 } 60 62 } catch (DuplicateLayerException e) { 61 63 // we tried to grab onto a duplicated layer (removed) 62 Main.warn("removed a duplicated layer");64 Logging.warn("removed a duplicated layer"); 63 65 } catch (WMSException e) { 64 Main.warn(e);66 Logging.warn(e); 65 67 errorMessage = e.getMessage(); 66 68 wmsLayer.grabber.getWmsInterface().resetCookie(); … … 80 82 81 83 public static void download(WMSLayer wmsLayer) { 82 MapView mv = Main .map.mapView;84 MapView mv = MainApplication.getMap().mapView; 83 85 Bounds bounds = new Bounds(mv.getLatLon(0, mv.getHeight()), mv.getLatLon(mv.getWidth(), 0)); 84 86 85 Main .worker.execute(new DownloadWMSVectorImage(wmsLayer, bounds));87 MainApplication.worker.execute(new DownloadWMSVectorImage(wmsLayer, bounds)); 86 88 if (errorMessage != null) 87 89 JOptionPane.showMessageDialog(Main.parent, errorMessage); -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/GrabThread.java
r33638 r33640 10 10 import java.util.concurrent.locks.ReentrantLock; 11 11 12 import org.openstreetmap.josm.Main;13 12 import org.openstreetmap.josm.data.coor.EastNorth; 14 13 import org.openstreetmap.josm.gui.MapView; 15 14 import org.openstreetmap.josm.io.OsmTransferException; 16 15 import org.openstreetmap.josm.plugins.fr.cadastre.CadastrePlugin; 16 import org.openstreetmap.josm.tools.Logging; 17 17 18 18 public class GrabThread extends Thread { … … 44 44 this.notify(); 45 45 } 46 Main.info("Added " + moreImages.size() + " to the grab thread");46 Logging.info("Added " + moreImages.size() + " to the grab thread"); 47 47 if (wmsLayer.isRaster()) { 48 48 waitNotification(); … … 89 89 GeorefImage newImage; 90 90 try { 91 Main.map.repaint(); // paint the current grab box91 wmsLayer.invalidate(); // paint the current grab box 92 92 newImage = grabber.grab(wmsLayer, currentGrabImage.min, currentGrabImage.max); 93 93 } catch (IOException e) { 94 Main.warn("Download action canceled by user or server did not respond");94 Logging.warn("Download action canceled by user or server did not respond"); 95 95 setCanceled(true); 96 96 break; 97 97 } catch (OsmTransferException e) { 98 Main.error("OSM transfer failed");98 Logging.error("OSM transfer failed"); 99 99 setCanceled(true); 100 100 break; 101 101 } 102 102 if (grabber.getWmsInterface().downloadCanceled) { 103 Main.info("Download action canceled by user");103 Logging.info("Download action canceled by user"); 104 104 setCanceled(true); 105 105 break; … … 123 123 saveToCache(newImage); 124 124 } catch (NullPointerException e) { 125 Main.info("Layer destroyed. Cancel grab thread");125 Logging.info("Layer destroyed. Cancel grab thread"); 126 126 setCanceled(true); 127 127 } 128 128 } 129 129 } 130 Main.info("grab thread list empty");130 Logging.info("grab thread list empty"); 131 131 lockCurrentGrabImage.lock(); 132 132 currentGrabImage = null; … … 164 164 if (cacheControl != null) { 165 165 while (!cacheControl.isCachePipeEmpty()) { 166 Main.info("Try to close a WMSLayer which is currently saving in cache : wait 1 sec.");166 Logging.info("Try to close a WMSLayer which is currently saving in cache : wait 1 sec."); 167 167 CadastrePlugin.safeSleep(1000); 168 168 } … … 231 231 wait(); 232 232 } catch (InterruptedException e) { 233 Main.error(e);233 Logging.error(e); 234 234 } 235 235 } -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/RasterImageGeoreferencer.java
r33638 r33640 18 18 import org.openstreetmap.josm.Main; 19 19 import org.openstreetmap.josm.data.coor.EastNorth; 20 import org.openstreetmap.josm.gui.MainApplication; 20 21 import org.openstreetmap.josm.tools.GBC; 22 import org.openstreetmap.josm.tools.Logging; 21 23 22 24 public class RasterImageGeoreferencer implements MouseListener { … … 41 43 42 44 public void addListener() { 43 Main .map.mapView.addMouseListener(this);45 MainApplication.getMap().mapView.addMouseListener(this); 44 46 } 45 47 … … 52 54 mode = cGetCorners; 53 55 countMouseClicked = 0; 54 initialClickDelay = Main.pref.getInt eger("cadastrewms.georef-click-delay", 200);56 initialClickDelay = Main.pref.getInt("cadastrewms.georef-click-delay", 200); 55 57 mouseClickedTime = System.currentTimeMillis(); 56 58 Object[] options = {"OK", "Cancel"}; … … 76 78 countMouseClicked = 0; 77 79 mode = cGetLambertCrosspieces; 78 initialClickDelay = Main.pref.getInt eger("cadastrewms.georef-click-delay", 200);80 initialClickDelay = Main.pref.getInt("cadastrewms.georef-click-delay", 200); 79 81 mouseClickedTime = System.currentTimeMillis(); 80 82 Object[] options = {"OK", "Cancel"}; … … 99 101 public void mouseClicked(MouseEvent e) { 100 102 if (System.currentTimeMillis() - mouseClickedTime < initialClickDelay) { 101 Main.info("mouse click bounce detected");103 Logging.info("mouse click bounce detected"); 102 104 return; // mouse click anti-bounce 103 105 } else … … 106 108 return; 107 109 if (ignoreMouseClick) return; // In case we are currently just allowing zooming to read lambert coordinates 108 EastNorth ea = Main.getProjection().latlon2eastNorth(Main .map.mapView.getLatLon(e.getX(), e.getY()));109 Main.info("click:"+countMouseClicked+" ,"+ea+", mode:"+mode);110 EastNorth ea = Main.getProjection().latlon2eastNorth(MainApplication.getMap().mapView.getLatLon(e.getX(), e.getY())); 111 Logging.info("click:"+countMouseClicked+" ,"+ea+", mode:"+mode); 110 112 if (clickOnTheMap) { 111 113 clickOnTheMap = false; … … 115 117 if (ea.east() < wmsLayer.getImage(0).min.east() || ea.east() > wmsLayer.getImage(0).max.east() 116 118 || ea.north() < wmsLayer.getImage(0).min.north() || ea.north() > wmsLayer.getImage(0).max.north()) { 117 Main.info("ignore click outside the image");119 Logging.info("ignore click outside the image"); 118 120 return; 119 121 } … … 156 158 if (selectedValue == 0) { // "Cancel" 157 159 // remove layer 158 Main .getLayerManager().removeLayer(wmsLayer);160 MainApplication.getLayerManager().removeLayer(wmsLayer); 159 161 wmsLayer = null; 160 Main .map.mapView.removeMouseListener(this);162 MainApplication.getMap().mapView.removeMouseListener(this); 161 163 return false; 162 164 } … … 178 180 tr("Ooops. I failed to catch all coordinates\n"+ 179 181 "correctly. Retry please.")); 180 Main.warn("failed to transform: one coordinate missing:"182 Logging.warn("failed to transform: one coordinate missing:" 181 183 +"org1="+org1+", org2="+org2+", dst1="+dst1+", dst2="+dst2); 182 184 return; … … 198 200 */ 199 201 private void endGeoreferencing() { 200 Main .map.mapView.removeMouseListener(this);202 MainApplication.getMap().mapView.removeMouseListener(this); 201 203 affineTransform(ea1, ea2, georefpoint1, georefpoint2); 202 204 wmsLayer.grabThread.saveNewCache(); … … 341 343 actionCompleted(); 342 344 if (wmsLayer != null) { 343 Main .getLayerManager().removeLayer(wmsLayer);345 MainApplication.getLayerManager().removeLayer(wmsLayer); 344 346 wmsLayer = null; 345 347 } … … 347 349 348 350 @Override 349 public void mouseEntered(MouseEvent arg0) {351 public void mouseEntered(MouseEvent e) { 350 352 } 351 353 352 354 @Override 353 public void mouseExited(MouseEvent arg0) {355 public void mouseExited(MouseEvent e) { 354 356 } 355 357 356 358 @Override 357 public void mousePressed(MouseEvent arg0) {359 public void mousePressed(MouseEvent e) { 358 360 } 359 361 360 362 @Override 361 public void mouseReleased(MouseEvent arg0) {363 public void mouseReleased(MouseEvent e) { 362 364 } 363 365 } -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/WMSLayer.java
r33638 r33640 36 36 import org.openstreetmap.josm.data.coor.EastNorth; 37 37 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 38 import org.openstreetmap.josm.gui.MainApplication; 38 39 import org.openstreetmap.josm.gui.MapView; 39 40 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; … … 48 49 import org.openstreetmap.josm.plugins.fr.cadastre.actions.mapmode.WMSAdjustAction; 49 50 import org.openstreetmap.josm.plugins.fr.cadastre.preferences.CadastrePreferenceSetting; 51 import org.openstreetmap.josm.tools.Logging; 50 52 51 53 /** … … 149 151 images = null; 150 152 dividedBbox = null; 151 Main.info("Layer "+location+" destroyed");153 Logging.info("Layer "+location+" destroyed"); 152 154 } 153 155 … … 167 169 grabThread.setGrabber(grabber); 168 170 // if it is the first layer, use the communeBBox as grab bbox (and not divided) 169 if (Main .getLayerManager().getLayers().size() == 1) {171 if (MainApplication.getLayerManager().getLayers().size() == 1) { 170 172 final Bounds bounds = this.getCommuneBBox().toBounds(); 171 GuiHelper.runInEDTAndWait(new Runnable() { 172 @Override 173 public void run() { 174 Main.map.mapView.zoomTo(bounds); 175 } 176 }); 173 GuiHelper.runInEDTAndWait(() -> MainApplication.getMap().mapView.zoomTo(bounds)); 177 174 divideBbox(bounds, 1); 178 175 } else { … … 538 535 } catch (EOFException ex) { 539 536 // expected exception when all images are read 540 Main.trace(ex);541 } 542 } 543 Main.info("Cache loaded for location "+location+" with "+images.size()+" images");537 Logging.trace(ex); 538 } 539 } 540 Logging.info("Cache loaded for location "+location+" with "+images.size()+" images"); 544 541 return true; 545 542 } … … 703 700 img = this.images.get(index); 704 701 } catch (ArrayIndexOutOfBoundsException e) { 705 Main.error(e);702 Logging.error(e); 706 703 } 707 704 imagesLock.unlock();
Note:
See TracChangeset
for help on using the changeset viewer.