Changeset 34458 in osm for applications/editors/josm/plugins
- Timestamp:
- 2018-08-13T22:53:18+02:00 (6 years ago)
- Location:
- applications/editors/josm/plugins/cadastre-fr
- Files:
-
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/.classpath
r33671 r34458 2 2 <classpath> 3 3 <classpathentry kind="src" path="src"/> 4 <classpathentry kind="src" path="test/unit"/> 4 <classpathentry kind="src" output="bintest" path="test/unit"> 5 <attributes> 6 <attribute name="test" value="true"/> 7 </attributes> 8 </classpathentry> 5 9 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> 6 10 <classpathentry combineaccessrules="false" kind="src" path="/JOSM"/> -
applications/editors/josm/plugins/cadastre-fr/build.xml
r34290 r34458 4 4 <property name="commit.message" value="Changed constructor for Plugin"/> 5 5 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 6 <property name="plugin.main.version" value="1 3927"/>6 <property name="plugin.main.version" value="14153"/> 7 7 8 8 <!-- Configure these properties (replace "..." accordingly). -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/CadastrePlugin.java
r34355 r34458 23 23 import javax.swing.KeyStroke; 24 24 25 import org.openstreetmap.josm.Main;26 25 import org.openstreetmap.josm.actions.ExtensionFileFilter; 27 26 import org.openstreetmap.josm.actions.JosmAction; … … 29 28 import org.openstreetmap.josm.data.projection.AbstractProjection; 30 29 import org.openstreetmap.josm.data.projection.Projection; 30 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 31 31 import org.openstreetmap.josm.gui.IconToggleButton; 32 32 import org.openstreetmap.josm.gui.MainApplication; … … 57 57 import org.openstreetmap.josm.plugins.fr.cadastre.session.CadastreSessionImporter; 58 58 import org.openstreetmap.josm.plugins.fr.cadastre.wms.WMSLayer; 59 import org.openstreetmap.josm.spi.preferences.Config; 59 60 import org.openstreetmap.josm.tools.Logging; 60 61 … … 153 154 * <br> - move the grabber from CadastrPlugin singleton to each wmsLayer instance to allow grabbing 154 155 * of multiple municipalities in parallel. 155 * <br>2.2 01-Jul-2011 - replace deprecated Main.proj by newest Main.getProjection()156 * <br>2.2 01-Jul-2011 - replace deprecated Main.proj by newest ProjectionRegistry.getProjection() 156 157 * <br> - fix list of raster images (Feuilles) parsing failing after a Cadastre server change/maintenance 157 158 * <br>2.3 11-Jan-2013 - add various improvements from Don-Vip (Vincent Privat) trac #8175, #8229 and #5626. … … 239 240 240 241 private static void initCacheDir() { 241 if ( Main.pref.get("cadastrewms.cacheDir").isEmpty()) {242 cacheDir = new File( Main.pref.getDirs().getCacheDirectory(true), "cadastrewms").getAbsolutePath();242 if (Config.getPref().get("cadastrewms.cacheDir").isEmpty()) { 243 cacheDir = new File(Config.getDirs().getCacheDirectory(true), "cadastrewms").getAbsolutePath(); 243 244 } else { 244 cacheDir = Main.pref.get("cadastrewms.cacheDir");245 cacheDir = Config.getPref().get("cadastrewms.cacheDir"); 245 246 } 246 247 if (cacheDir.charAt(cacheDir.length()-1) != File.separatorChar) … … 267 268 @Override 268 269 public void actionPerformed(ActionEvent ev) { 269 Main.pref.putBoolean("cadastrewms.autosourcing", menuSource.isSelected());270 Config.getPref().putBoolean("cadastrewms.autosourcing", menuSource.isSelected()); 270 271 autoSourcing = menuSource.isSelected(); 271 272 } … … 285 286 //cadastreJMenu.add(menuResetCookie); not required any more 286 287 //cadastreJMenu.add(menuLambertZone); 287 //if ( Main.pref.getBoolean("cadastrewms.buildingsMenu", false))288 //if (Config.getPref().getBoolean("cadastrewms.buildingsMenu", false)) 288 289 // cadastreJMenu.add(menuActionBuildings); 289 290 cadastreJMenu.add(menuLoadFromCache); … … 297 298 public static void refreshConfiguration() { 298 299 source = checkSourceMillesime(); 299 autoSourcing = Main.pref.getBoolean("cadastrewms.autosourcing", true);300 alterColors = Main.pref.getBoolean("cadastrewms.alterColors");301 drawBoundaries = Main.pref.getBoolean("cadastrewms.drawBoundaries", false);300 autoSourcing = Config.getPref().getBoolean("cadastrewms.autosourcing", true); 301 alterColors = Config.getPref().getBoolean("cadastrewms.alterColors"); 302 drawBoundaries = Config.getPref().getBoolean("cadastrewms.drawBoundaries", false); 302 303 if (alterColors) { 303 backgroundTransparent = Main.pref.getBoolean("cadastrewms.backgroundTransparent");304 transparency = Float.parseFloat( Main.pref.get("cadastrewms.brightness", "1.0f"));304 backgroundTransparent = Config.getPref().getBoolean("cadastrewms.backgroundTransparent"); 305 transparency = Float.parseFloat(Config.getPref().get("cadastrewms.brightness", "1.0f")); 305 306 } else { 306 307 backgroundTransparent = false; 307 308 transparency = 1.0f; 308 309 } 309 String currentResolution = Main.pref.get("cadastrewms.resolution", "high");310 String currentResolution = Config.getPref().get("cadastrewms.resolution", "high"); 310 311 if (currentResolution.equals("high")) { 311 312 imageWidth = 1000; imageHeight = 800; … … 323 324 grabStyles = ""; 324 325 int countLayers = 0; 325 if ( Main.pref.getBoolean("cadastrewms.layerWater", true)) {326 if (Config.getPref().getBoolean("cadastrewms.layerWater", true)) { 326 327 grabLayers += LAYER_WATER + ","; 327 328 grabStyles += STYLE_WATER + ","; 328 329 countLayers++; 329 330 } 330 if ( Main.pref.getBoolean("cadastrewms.layerBuilding", true)) {331 if (Config.getPref().getBoolean("cadastrewms.layerBuilding", true)) { 331 332 grabLayers += LAYER_BULDINGS + ","; 332 333 grabStyles += STYLE_BUILDING + ","; 333 334 countLayers++; 334 335 } 335 if ( Main.pref.getBoolean("cadastrewms.layerSymbol", true)) {336 if (Config.getPref().getBoolean("cadastrewms.layerSymbol", true)) { 336 337 grabLayers += LAYER_SYMBOL + ","; 337 338 grabStyles += STYLE_SYMBOL + ","; 338 339 countLayers++; 339 340 } 340 if ( Main.pref.getBoolean("cadastrewms.layerParcel", true)) {341 if (Config.getPref().getBoolean("cadastrewms.layerParcel", true)) { 341 342 grabLayers += LAYER_PARCELS + ","; 342 343 grabStyles += STYLE_PARCELS + ","; 343 344 countLayers++; 344 345 } 345 if ( Main.pref.getBoolean("cadastrewms.layerNumero", true)) {346 if (Config.getPref().getBoolean("cadastrewms.layerNumero", true)) { 346 347 grabLayers += LAYER_NUMERO + ","; 347 348 grabStyles += STYLE_NUMERO + ","; 348 349 countLayers++; 349 350 } 350 if ( Main.pref.getBoolean("cadastrewms.layerLabel", true)) {351 if (Config.getPref().getBoolean("cadastrewms.layerLabel", true)) { 351 352 grabLayers += LAYER_LABEL + ","; 352 353 grabStyles += STYLE_LABEL + ","; 353 354 countLayers++; 354 355 } 355 if ( Main.pref.getBoolean("cadastrewms.layerLieudit", true)) {356 if (Config.getPref().getBoolean("cadastrewms.layerLieudit", true)) { 356 357 grabLayers += LAYER_LIEUDIT + ","; 357 358 grabStyles += STYLE_LIEUDIT + ","; 358 359 countLayers++; 359 360 } 360 if ( Main.pref.getBoolean("cadastrewms.layerSection", true)) {361 if (Config.getPref().getBoolean("cadastrewms.layerSection", true)) { 361 362 grabLayers += LAYER_SECTION + ","; 362 363 grabStyles += STYLE_SECTION + ","; 363 364 countLayers++; 364 365 } 365 if ( Main.pref.getBoolean("cadastrewms.layerCommune", true)) {366 if (Config.getPref().getBoolean("cadastrewms.layerCommune", true)) { 366 367 grabLayers += LAYER_COMMUNE + ","; 367 368 grabStyles += STYLE_COMMUNE + ","; … … 372 373 grabStyles = grabStyles.substring(0, grabStyles.length()-1); 373 374 } else { 374 JOptionPane.showMessageDialog(Main .parent, tr("Please enable at least two WMS layers in the cadastre-fr "375 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), tr("Please enable at least two WMS layers in the cadastre-fr " 375 376 + "plugin configuration.\nLayers ''Building'' and ''Parcel'' added by default.")); 376 Main.pref.putBoolean("cadastrewms.layerBuilding", true);377 Main.pref.putBoolean("cadastrewms.layerParcel", true);377 Config.getPref().putBoolean("cadastrewms.layerBuilding", true); 378 Config.getPref().putBoolean("cadastrewms.layerParcel", true); 378 379 grabLayers += LAYER_BULDINGS + "," + LAYER_PARCELS; 379 380 grabStyles += STYLE_BUILDING + "," + STYLE_PARCELS; … … 416 417 417 418 public static boolean isLambert() { 418 String code = Main.getProjection().toCode();419 String code = ProjectionRegistry.getProjection().toCode(); 419 420 return Arrays.asList(ProjectionPreference.lambert.allCodes()).contains(code); 420 421 } 421 422 422 423 public static boolean isUtm_france_dom() { 423 String code = Main.getProjection().toCode();424 String code = ProjectionRegistry.getProjection().toCode(); 424 425 return Arrays.asList(ProjectionPreference.utm_france_dom.allCodes()).contains(code); 425 426 } 426 427 427 428 public static boolean isLambert_cc9() { 428 String code = Main.getProjection().toCode();429 String code = ProjectionRegistry.getProjection().toCode(); 429 430 return Arrays.asList(ProjectionPreference.lambert_cc9.allCodes()).contains(code); 430 431 } … … 436 437 public static int getCadastreProjectionLayoutZone() { 437 438 int zone = -1; 438 Projection proj = Main.getProjection();439 Projection proj = ProjectionRegistry.getProjection(); 439 440 if (proj instanceof AbstractProjection) { 440 441 Integer code = ((AbstractProjection) proj).getEpsgCode(); … … 471 472 // FIXME: this is a temporary solution. 472 473 public static void prepareDialog(JDialog dialog) { 473 if ( Main.pref.getBoolean("window-handling.option-pane-always-on-top", true)) {474 if (Config.getPref().getBoolean("window-handling.option-pane-always-on-top", true)) { 474 475 try { 475 476 dialog.setAlwaysOnTop(true); … … 506 507 private static String checkSourceMillesime() { 507 508 int currentYear = Calendar.getInstance().get(Calendar.YEAR); 508 String src = Main.pref.get("cadastrewms.source",509 String src = Config.getPref().get("cadastrewms.source", 509 510 "cadastre-dgi-fr source : Direction G\u00e9n\u00e9rale des Imp\u00f4ts - Cadastre. Mise \u00e0 jour : AAAA"); 510 511 String srcYear = src.substring(src.lastIndexOf(" ")+1); … … 518 519 Logging.info("Replace source year "+srcYear+" by current year "+currentYear); 519 520 src = src.substring(0, src.lastIndexOf(" ")+1)+currentYear; 520 Main.pref.put("cadastrewms.source", src);521 Config.getPref().put("cadastrewms.source", src); 521 522 } 522 523 return src; … … 530 531 @Override 531 532 public void run() { 532 if (JOptionPane.showConfirmDialog(Main .parent,533 if (JOptionPane.showConfirmDialog(MainApplication.getMainFrame(), 533 534 tr("To enable the cadastre WMS plugin, change\n" 534 535 + "the current projection to one of the cadastre\n" … … 536 537 tr("Change the current projection"), JOptionPane.OK_CANCEL_OPTION) 537 538 == JOptionPane.OK_OPTION) { 538 PreferenceDialog p = new PreferenceDialog(Main .parent);539 PreferenceDialog p = new PreferenceDialog(MainApplication.getMainFrame()); 539 540 p.selectPreferencesTabByClass(MapPreference.class); 540 541 p.getTabbedPane().getSetting(ProjectionPreference.class).selectProjection(ProjectionPreference.lambert_cc9); -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionBoundaries.java
r33638 r34458 8 8 import javax.swing.JOptionPane; 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.wms.DownloadSVGTask; 13 13 import org.openstreetmap.josm.plugins.fr.cadastre.wms.WMSLayer; … … 32 32 if (wmsLayer != null) { 33 33 if (wmsLayer.isRaster()) { 34 JOptionPane.showMessageDialog(Main .parent,34 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 35 35 tr("Only on vectorized layers"), tr("Error"), 36 36 JOptionPane.ERROR_MESSAGE); -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionGrabPlanImage.java
r33640 r34458 10 10 import javax.swing.JOptionPane; 11 11 12 import org.openstreetmap.josm.Main;13 12 import org.openstreetmap.josm.actions.JosmAction; 14 13 import org.openstreetmap.josm.gui.MainApplication; … … 17 16 import org.openstreetmap.josm.plugins.fr.cadastre.wms.RasterImageGeoreferencer; 18 17 import org.openstreetmap.josm.plugins.fr.cadastre.wms.WMSLayer; 18 import org.openstreetmap.josm.spi.preferences.Config; 19 19 20 20 public class MenuActionGrabPlanImage extends JosmAction implements Runnable { … … 45 45 if (MainApplication.getLayerManager().containsLayer(wmsLayer)) 46 46 return; 47 JOptionPane.showMessageDialog(Main .parent, tr("Georeferencing interrupted"));47 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), tr("Georeferencing interrupted")); 48 48 rasterImageGeoreferencer.actionInterrupted(); 49 49 } … … 87 87 } else { 88 88 rasterImageGeoreferencer.addListener(); 89 if ( Main.pref.getBoolean("cadastrewms.noImageCropping", false) == false)89 if (Config.getPref().getBoolean("cadastrewms.noImageCropping", false) == false) 90 90 rasterImageGeoreferencer.startCropping(wmsLayer); 91 91 else -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionLoadFromCache.java
r33640 r34458 11 11 import javax.swing.JOptionPane; 12 12 13 import org.openstreetmap.josm.Main;14 13 import org.openstreetmap.josm.actions.JosmAction; 15 14 import org.openstreetmap.josm.gui.MainApplication; … … 32 31 */ 33 32 public MenuActionLoadFromCache() { 34 super(tr(name), "cadastre_small", tr("Load location from cache (only if cache is enabled)"), null, false, "cadastrefr/loadfromcache", true); 33 super(tr(name), "cadastre_small", 34 tr("Load location from cache (only if cache is enabled)"), null, false, "cadastrefr/loadfromcache", true); 35 35 } 36 36 … … 53 53 !(CadastrePlugin.isUtm_france_dom())) 54 54 || (ext.length() == 1) && !(CadastrePlugin.isLambert())) { 55 JOptionPane.showMessageDialog(Main.parent, tr("{0} not allowed with the current projection", filename), 55 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 56 tr("{0} not allowed with the current projection", filename), 56 57 tr("Error"), JOptionPane.ERROR_MESSAGE); 57 58 continue; … … 67 68 if (cacheZone >= 0 && cacheZone <= 9) { 68 69 if (cacheZone != layoutZone) { 69 JOptionPane.showMessageDialog(Main .parent,70 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 70 71 tr("Cannot load cache {0} which is not compatible with current projection zone", filename), 71 72 tr("Error"), JOptionPane.ERROR_MESSAGE); … … 75 76 } 76 77 } catch (NumberFormatException ex) { 77 JOptionPane.showMessageDialog(Main .parent,78 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 78 79 tr("Selected file {0} is not a cache file from this plugin (invalid extension)", filename), 79 80 tr("Error"), JOptionPane.ERROR_MESSAGE); … … 84 85 for (Layer l : MainApplication.getLayerManager().getLayers()) { 85 86 if (l instanceof WMSLayer && l.getName().equals(location)) { 86 JOptionPane.showMessageDialog(Main .parent,87 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 87 88 tr("The location {0} is already on screen. Cache not loaded.", filename), 88 89 tr("Error"), JOptionPane.ERROR_MESSAGE); … … 115 116 fc.setAcceptAllFileFilterUsed(false); 116 117 117 int answer = fc.showOpenDialog(Main .parent);118 int answer = fc.showOpenDialog(MainApplication.getMainFrame()); 118 119 if (answer != JFileChooser.APPROVE_OPTION) 119 120 return null; -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionNewLocation.java
r33640 r34458 14 14 import javax.swing.JTextField; 15 15 16 import org.openstreetmap.josm.Main;17 16 import org.openstreetmap.josm.actions.JosmAction; 18 17 import org.openstreetmap.josm.gui.MainApplication; … … 21 20 import org.openstreetmap.josm.plugins.fr.cadastre.wms.DownloadWMSVectorImage; 22 21 import org.openstreetmap.josm.plugins.fr.cadastre.wms.WMSLayer; 22 import org.openstreetmap.josm.spi.preferences.Config; 23 23 import org.openstreetmap.josm.tools.GBC; 24 24 import org.openstreetmap.josm.tools.Logging; … … 78 78 JPanel p = new JPanel(new GridBagLayout()); 79 79 JLabel labelLocation = new JLabel(tr("Commune")); 80 final JTextField inputTown = new JTextField( Main.pref.get("cadastrewms.location"));80 final JTextField inputTown = new JTextField(Config.getPref().get("cadastrewms.location")); 81 81 inputTown.setToolTipText(tr("<html>Enter the town,village or city name.<br>" 82 82 + "Use the syntax and punctuation known by www.cadastre.gouv.fr .</html>")); … … 87 87 } 88 88 inputDepartement.setToolTipText(tr("<html>Departement number (optional)</html>")); 89 if (! Main.pref.get("cadastrewms.codeDepartement").equals("")) {89 if (!Config.getPref().get("cadastrewms.codeDepartement").equals("")) { 90 90 for (int i = 0; i < departements.length; i += 2) { 91 if (departements[i].equals( Main.pref.get("cadastrewms.codeDepartement")))91 if (departements[i].equals(Config.getPref().get("cadastrewms.codeDepartement"))) 92 92 inputDepartement.setSelectedIndex(i/2); 93 93 } … … 107 107 } 108 108 }; 109 pane.createDialog(Main .parent, tr("Add new layer")).setVisible(true);109 pane.createDialog(MainApplication.getMainFrame(), tr("Add new layer")).setVisible(true); 110 110 if (!Integer.valueOf(JOptionPane.OK_OPTION).equals(pane.getValue())) 111 111 return null; … … 115 115 location = inputTown.getText().toUpperCase(); 116 116 codeDepartement = departements[inputDepartement.getSelectedIndex()*2]; 117 Main.pref.put("cadastrewms.location", location);118 Main.pref.put("cadastrewms.codeCommune", codeCommune);119 Main.pref.put("cadastrewms.codeDepartement", codeDepartement);117 Config.getPref().put("cadastrewms.location", location); 118 Config.getPref().put("cadastrewms.codeCommune", codeCommune); 119 Config.getPref().put("cadastrewms.codeDepartement", codeDepartement); 120 120 if (MainApplication.getMap() != null) { 121 121 for (Layer l : MainApplication.getLayerManager().getLayers()) { … … 131 131 CadastrePlugin.addWMSLayer(wmsLayer); 132 132 Logging.info("Add new layer with Location:" + inputTown.getText()); 133 } else if (existingLayers != null && existingLayers.size() > 0 && MainApplication.getLayerManager().getActiveLayer() instanceof WMSLayer) { 133 } else if (existingLayers != null && existingLayers.size() > 0 134 && MainApplication.getLayerManager().getActiveLayer() instanceof WMSLayer) { 134 135 wmsLayer = (WMSLayer) MainApplication.getLayerManager().getActiveLayer(); 135 136 } -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionOpenPreferences.java
r33638 r34458 7 7 import java.awt.event.ActionEvent; 8 8 9 import org.openstreetmap.josm.Main;10 9 import org.openstreetmap.josm.actions.JosmAction; 10 import org.openstreetmap.josm.gui.MainApplication; 11 11 import org.openstreetmap.josm.gui.preferences.PreferenceDialog; 12 12 import org.openstreetmap.josm.plugins.fr.cadastre.preferences.CadastrePreferenceSetting; … … 26 26 @Override 27 27 public void actionPerformed(ActionEvent e) { 28 PreferenceDialog p = new PreferenceDialog(Main .parent);28 PreferenceDialog p = new PreferenceDialog(MainApplication.getMainFrame()); 29 29 p.selectPreferencesTabByClass(CadastrePreferenceSetting.class); 30 30 p.setVisible(true); -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionSaveRasterAs.java
r34115 r34458 25 25 import org.opengis.parameter.GeneralParameterValue; 26 26 import org.opengis.parameter.ParameterValueGroup; 27 import org.openstreetmap.josm.Main;28 27 import org.openstreetmap.josm.actions.JosmAction; 28 import org.openstreetmap.josm.gui.MainApplication; 29 29 import org.openstreetmap.josm.plugins.fr.cadastre.wms.WMSLayer; 30 30 import org.openstreetmap.josm.tools.Logging; … … 87 87 fc.addChoosableFileFilter(filtrePng); 88 88 fc.setFileFilter(filtreTiff); 89 int returnVal = fc.showSaveDialog(Main .parent);89 int returnVal = fc.showSaveDialog(MainApplication.getMainFrame()); 90 90 if (returnVal == JFileChooser.APPROVE_OPTION) { 91 91 file = fc.getSelectedFile(); … … 96 96 try { 97 97 ImageIO.write(bi, "png", file); 98 /*98 /* 99 99 FileOutputStream flux = new FileOutputStream(file); 100 100 BufferedOutputStream fluxBuf = new BufferedOutputStream(flux); … … 102 102 codec.encode(bi); 103 103 fluxBuf.close(); 104 */104 */ 105 105 } catch (IOException e) { 106 106 e.printStackTrace(); -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/WMSDownloadAction.java
r33640 r34458 9 9 import javax.swing.JOptionPane; 10 10 11 import org.openstreetmap.josm.Main;12 11 import org.openstreetmap.josm.gui.MainApplication; 13 12 //import org.openstreetmap.josm.actions.JosmAction; 14 13 import org.openstreetmap.josm.gui.layer.Layer; 15 14 import org.openstreetmap.josm.plugins.fr.cadastre.wms.WMSLayer; 15 import org.openstreetmap.josm.spi.preferences.Config; 16 16 17 17 final class WMSDownloadAction { … … 37 37 if (existingWMSlayers.size() == 0) 38 38 return new MenuActionNewLocation().addNewLayer(existingWMSlayers); 39 if ( Main.pref.getBoolean("cadastrewms.autoFirstLayer", false)) {39 if (Config.getPref().getBoolean("cadastrewms.autoFirstLayer", false)) { 40 40 return existingWMSlayers.get(0); 41 41 } else { 42 JOptionPane.showMessageDialog(Main .parent,42 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 43 43 tr("More than one WMS layer present\nSelect one of them first, then retry")); 44 44 } -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/mapmode/Address.java
r34223 r34458 41 41 import javax.swing.event.ChangeListener; 42 42 43 import org.openstreetmap.josm.Main;44 43 import org.openstreetmap.josm.actions.mapmode.MapMode; 45 44 import org.openstreetmap.josm.command.AddCommand; … … 48 47 import org.openstreetmap.josm.command.Command; 49 48 import org.openstreetmap.josm.command.SequenceCommand; 49 import org.openstreetmap.josm.data.UndoRedoHandler; 50 50 import org.openstreetmap.josm.data.coor.EastNorth; 51 51 import org.openstreetmap.josm.data.osm.DataSet; 52 52 import org.openstreetmap.josm.data.osm.Node; 53 import org.openstreetmap.josm.data.osm.OsmDataManager; 53 54 import org.openstreetmap.josm.data.osm.OsmPrimitive; 54 55 import org.openstreetmap.josm.data.osm.Relation; … … 58 59 import org.openstreetmap.josm.gui.MainApplication; 59 60 import org.openstreetmap.josm.gui.MapView; 61 import org.openstreetmap.josm.spi.preferences.Config; 60 62 import org.openstreetmap.josm.tools.GBC; 61 63 import org.openstreetmap.josm.tools.ImageProvider; … … 145 147 addStreetNameOrRelation(currentMouseNode, cmds); 146 148 Command c = new SequenceCommand("Add node address", cmds); 147 Main.main.undoRedo.add(c);149 UndoRedoHandler.getInstance().add(c); 148 150 setNewSelection(currentMouseNode); 149 151 } else { … … 159 161 } 160 162 if (currentMouseNode.get(tagHouseStreet) != null) { 161 if ( Main.pref.getBoolean("cadastrewms.addr.dontUseRelation", false)) {163 if (Config.getPref().getBoolean("cadastrewms.addr.dontUseRelation", false)) { 162 164 inputStreet.setText(currentMouseNode.get(tagHouseStreet)); 163 165 if (ctrl) { … … 253 255 Map<String, String> tags = new HashMap<>(); 254 256 tags.put(tagHouseNumber, inputNumber.getText()); 255 cmds.add(new ChangePropertyCommand( Main.main.getEditDataSet(), Collections.singleton(osm), tags));257 cmds.add(new ChangePropertyCommand(OsmDataManager.getInstance().getEditDataSet(), Collections.singleton(osm), tags)); 256 258 addStreetNameOrRelation(osm, cmds); 257 259 try { 258 260 applyInputNumberChange(); 259 261 Command c = new SequenceCommand("Add node address", cmds); 260 Main.main.undoRedo.add(c);262 UndoRedoHandler.getInstance().add(c); 261 263 setNewSelection(osm); 262 264 } catch (NumberFormatException ex) { … … 276 278 277 279 private void addStreetNameOrRelation(OsmPrimitive osm, Collection<Command> cmds) { 278 if ( Main.pref.getBoolean("cadastrewms.addr.dontUseRelation", false)) {280 if (Config.getPref().getBoolean("cadastrewms.addr.dontUseRelation", false)) { 279 281 cmds.add(new ChangePropertyCommand(osm, tagHouseStreet, inputStreet.getText())); 280 282 } else if (selectedWay != null) { … … 293 295 newRel.addMember(new RelationMember(relationAddrStreetRole, selectedWay)); 294 296 newRel.addMember(new RelationMember(relationMemberHouse, osm)); 295 cmds.add(new AddCommand( Main.main.getEditDataSet(), newRel));297 cmds.add(new AddCommand(OsmDataManager.getInstance().getEditDataSet(), newRel)); 296 298 } 297 299 } … … 301 303 // DrawAction.mouseReleased() but without key modifiers 302 304 Node n = new Node(MainApplication.getMap().mapView.getLatLon(e.getX(), e.getY())); 303 cmds.add(new AddCommand( Main.main.getEditDataSet(), n));305 cmds.add(new AddCommand(OsmDataManager.getInstance().getEditDataSet(), n)); 304 306 List<WaySegment> wss = MainApplication.getMap().mapView.getNearestWaySegments(e.getPoint(), OsmPrimitive::isSelectable); 305 307 Map<Way, List<Integer>> insertPoints = new HashMap<>(); … … 371 373 372 374 int snapToIntersectionThreshold 373 = Main.pref.getInt("edit.snap-intersection-threshold", 10);375 = Config.getPref().getInt("edit.snap-intersection-threshold", 10); 374 376 375 377 // only adjust to intersection if within snapToIntersectionThreshold pixel of mouse click; otherwise … … 478 480 p.add(minusOne, GBC.std().insets(10, 0, 10, 0)); 479 481 p.add(plusOne, GBC.std().insets(0, 0, 10, 0)); 480 tagPolygon.setSelected( Main.pref.getBoolean("cadastrewms.addr.onBuilding", false));482 tagPolygon.setSelected(Config.getPref().getBoolean("cadastrewms.addr.onBuilding", false)); 481 483 tagPolygon.addChangeListener(new ChangeListener() { 482 484 @Override 483 485 public void stateChanged(ChangeEvent arg0) { 484 Main.pref.putBoolean("cadastrewms.addr.onBuilding", tagPolygon.isSelected());486 Config.getPref().putBoolean("cadastrewms.addr.onBuilding", tagPolygon.isSelected()); 485 487 } 486 488 }); … … 494 496 JOptionPane.PLAIN_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION, 495 497 null, options, null); 496 dialog = pane.createDialog(Main .parent, tr("Enter addresses"));498 dialog = pane.createDialog(MainApplication.getMainFrame(), tr("Enter addresses")); 497 499 dialog.setModal(false); 498 500 dialog.setAlwaysOnTop(true); 499 501 dialog.addComponentListener(new ComponentAdapter() { 500 502 protected void rememberGeometry() { 501 Main.pref.put("cadastrewms.addr.bounds", dialog.getX()+","+dialog.getY()+","+dialog.getWidth()+","+dialog.getHeight());503 Config.getPref().put("cadastrewms.addr.bounds", dialog.getX()+","+dialog.getY()+","+dialog.getWidth()+","+dialog.getHeight()); 502 504 } 503 505 … … 516 518 } 517 519 }); 518 String bounds = Main.pref.get("cadastrewms.addr.bounds", null);520 String bounds = Config.getPref().get("cadastrewms.addr.bounds", null); 519 521 if (bounds != null) { 520 522 String[] b = bounds.split(","); -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/upload/CheckSourceUploadHook.java
r34223 r34458 15 15 import javax.swing.JTextField; 16 16 17 import org.openstreetmap.josm.Main;18 17 import org.openstreetmap.josm.actions.upload.UploadHook; 19 18 import org.openstreetmap.josm.command.ChangePropertyCommand; 20 19 import org.openstreetmap.josm.data.APIDataSet; 20 import org.openstreetmap.josm.data.UndoRedoHandler; 21 21 import org.openstreetmap.josm.data.osm.Node; 22 22 import org.openstreetmap.josm.data.osm.OsmPrimitive; 23 23 import org.openstreetmap.josm.data.osm.Way; 24 import org.openstreetmap.josm.gui.MainApplication; 24 25 import org.openstreetmap.josm.gui.PrimitiveRenderer; 25 26 import org.openstreetmap.josm.plugins.fr.cadastre.CadastrePlugin; … … 78 79 l.setVisibleRowCount(l.getModel().getSize() < 6 ? l.getModel().getSize() : 10); 79 80 p.add(new JScrollPane(l), GBC.eol().fill()); 80 boolean bContinue = JOptionPane.showConfirmDialog(Main .parent, p, tr("Add \"source=...\" to elements?"),81 boolean bContinue = JOptionPane.showConfirmDialog(MainApplication.getMainFrame(), p, tr("Add \"source=...\" to elements?"), 81 82 JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION; 82 83 if (bContinue) 83 Main.main.undoRedo.add(new ChangePropertyCommand(sel, "source", tf.getText()));84 UndoRedoHandler.getInstance().add(new ChangePropertyCommand(sel, "source", tf.getText())); 84 85 } 85 86 } -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/pci/EdigeoPciReader.java
r34357 r34458 45 45 private static final BiPredicate<CadastreDownloadData, OsmPrimitive> symbo = (x, p) -> !x.isDownloadSymbol(); 46 46 private static final BiPredicate<CadastreDownloadData, OsmPrimitive> parce = (x, p) -> !x.isDownloadParcel(); 47 private static final BiPredicate<CadastreDownloadData, OsmPrimitive> parcn = (x, p) -> !x.isDownloadParcelNumber();47 //private static final BiPredicate<CadastreDownloadData, OsmPrimitive> parcn = (x, p) -> !x.isDownloadParcelNumber(); 48 48 private static final BiPredicate<CadastreDownloadData, OsmPrimitive> addre = (x, p) -> !x.isDownloadAddress(); 49 49 private static final BiPredicate<CadastreDownloadData, OsmPrimitive> local = (x, p) -> !x.isDownloadLocality(); 50 private static final BiPredicate<CadastreDownloadData, OsmPrimitive> secti = (x, p) -> !x.isDownloadSection();50 //private static final BiPredicate<CadastreDownloadData, OsmPrimitive> secti = (x, p) -> !x.isDownloadSection(); 51 51 private static final BiPredicate<CadastreDownloadData, OsmPrimitive> commu = (x, p) -> !x.isDownloadCommune(); 52 52 -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/preferences/CadastrePreferenceSetting.java
r34208 r34458 23 23 import javax.swing.SwingConstants; 24 24 25 import org.openstreetmap.josm.Main;26 25 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting; 27 26 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 28 27 import org.openstreetmap.josm.plugins.fr.cadastre.CadastrePlugin; 29 28 import org.openstreetmap.josm.plugins.fr.cadastre.wms.CacheControl; 29 import org.openstreetmap.josm.spi.preferences.Config; 30 30 import org.openstreetmap.josm.tools.GBC; 31 31 import org.openstreetmap.josm.tools.I18n; … … 140 140 141 141 // option to alter the original colors of the wms images 142 alterColors.setSelected( Main.pref.getBoolean("cadastrewms.alterColors", false));142 alterColors.setSelected(Config.getPref().getBoolean("cadastrewms.alterColors", false)); 143 143 alterColors.setToolTipText(tr("Replace the original white background by the background color defined in JOSM preferences.")); 144 144 cadastrewms.add(alterColors, GBC.eop().insets(0, 0, 0, 0)); 145 145 146 146 // option to reverse the grey colors (to see texts background) 147 reversGrey.setSelected( Main.pref.getBoolean("cadastrewms.invertGrey", false));147 reversGrey.setSelected(Config.getPref().getBoolean("cadastrewms.invertGrey", false)); 148 148 reversGrey.setToolTipText( 149 149 tr("Invert the original black and white colors (and all intermediate greys). Useful for texts on dark backgrounds.")); … … 157 157 } 158 158 }); 159 transparency.setSelected( Main.pref.getBoolean("cadastrewms.backgroundTransparent", false));159 transparency.setSelected(Config.getPref().getBoolean("cadastrewms.backgroundTransparent", false)); 160 160 transparency.setToolTipText(tr("Allows multiple layers stacking")); 161 161 cadastrewms.add(transparency, GBC.eop().insets(0, 0, 0, 0)); … … 166 166 sliderTrans.setMajorTickSpacing(10); 167 167 sliderTrans.setMinorTickSpacing(1); 168 sliderTrans.setValue((int) (Float.parseFloat( Main.pref.get("cadastrewms.brightness", "1.0f"))*10));168 sliderTrans.setValue((int) (Float.parseFloat(Config.getPref().get("cadastrewms.brightness", "1.0f"))*10)); 169 169 sliderTrans.setPaintTicks(true); 170 170 sliderTrans.setPaintLabels(false); … … 173 173 174 174 // option to draw boundaries of downloaded data 175 drawBoundaries.setSelected( Main.pref.getBoolean("cadastrewms.drawBoundaries", false));175 drawBoundaries.setSelected(Config.getPref().getBoolean("cadastrewms.drawBoundaries", false)); 176 176 drawBoundaries.setToolTipText(tr("Draw a rectangle around downloaded data from WMS server.")); 177 177 cadastrewms.add(drawBoundaries, GBC.eop().insets(0, 0, 0, 5)); … … 187 187 bgResolution.add(grabRes2); 188 188 bgResolution.add(grabRes3); 189 String currentResolution = Main.pref.get("cadastrewms.resolution", "high");189 String currentResolution = Config.getPref().get("cadastrewms.resolution", "high"); 190 190 if (currentResolution.equals("high")) 191 191 grabRes1.setSelected(true); … … 204 204 imageInterpolationMethod.addItem(tr("Bilinear (fast)")); 205 205 imageInterpolationMethod.addItem(tr("Bicubic (slow)")); 206 String savedImageInterpolationMethod = Main.pref.get("cadastrewms.imageInterpolation", "standard");206 String savedImageInterpolationMethod = Config.getPref().get("cadastrewms.imageInterpolation", "standard"); 207 207 if (savedImageInterpolationMethod.equals("bilinear")) 208 208 imageInterpolationMethod.setSelectedIndex(1); … … 247 247 bgGrabMultiplier.add(grabMultiplier3); 248 248 bgGrabMultiplier.add(grabMultiplier4); 249 String currentScale = Main.pref.get("cadastrewms.scale", DEFAULT_GRAB_MULTIPLIER);249 String currentScale = Config.getPref().get("cadastrewms.scale", DEFAULT_GRAB_MULTIPLIER); 250 250 if (currentScale.equals(Scale.X1.value)) 251 251 grabMultiplier1.setSelected(true); … … 269 269 JLabel jLabelLayers = new JLabel(tr("Layers:")); 270 270 cadastrewms.add(jLabelLayers, GBC.std().insets(0, 5, 10, 0)); 271 layerLS3.setSelected( Main.pref.getBoolean("cadastrewms.layerWater", true));271 layerLS3.setSelected(Config.getPref().getBoolean("cadastrewms.layerWater", true)); 272 272 layerLS3.setToolTipText(tr("Sea, rivers, swimming pools.")); 273 273 cadastrewms.add(layerLS3, GBC.std().insets(5, 0, 5, 0)); 274 layerLS2.setSelected( Main.pref.getBoolean("cadastrewms.layerBuilding", true));274 layerLS2.setSelected(Config.getPref().getBoolean("cadastrewms.layerBuilding", true)); 275 275 layerLS2.setToolTipText(tr("Buildings, covers, underground constructions.")); 276 276 cadastrewms.add(layerLS2, GBC.std().insets(5, 0, 5, 0)); 277 layerLS1.setSelected( Main.pref.getBoolean("cadastrewms.layerSymbol", true));277 layerLS1.setSelected(Config.getPref().getBoolean("cadastrewms.layerSymbol", true)); 278 278 layerLS1.setToolTipText(tr("Symbols like cristian cross.")); 279 279 cadastrewms.add(layerLS1, GBC.std().insets(5, 0, 5, 0)); 280 layerParcel.setSelected( Main.pref.getBoolean("cadastrewms.layerParcel", true));280 layerParcel.setSelected(Config.getPref().getBoolean("cadastrewms.layerParcel", true)); 281 281 layerParcel.setToolTipText(tr("Parcels.")); 282 282 cadastrewms.add(layerParcel, GBC.eop().insets(5, 0, 5, 0)); 283 layerLabel.setSelected( Main.pref.getBoolean("cadastrewms.layerLabel", true));283 layerLabel.setSelected(Config.getPref().getBoolean("cadastrewms.layerLabel", true)); 284 284 layerLabel.setToolTipText(tr("Parcels numbers, street names.")); 285 285 cadastrewms.add(layerLabel, GBC.std().insets(70, 0, 5, 0)); 286 layerNumero.setSelected( Main.pref.getBoolean("cadastrewms.layerNumero", true));286 layerNumero.setSelected(Config.getPref().getBoolean("cadastrewms.layerNumero", true)); 287 287 layerNumero.setToolTipText(tr("Address, houses numbers.")); 288 288 cadastrewms.add(layerNumero, GBC.std().insets(5, 0, 5, 0)); 289 layerLieudit.setSelected( Main.pref.getBoolean("cadastrewms.layerLieudit", true));289 layerLieudit.setSelected(Config.getPref().getBoolean("cadastrewms.layerLieudit", true)); 290 290 layerLieudit.setToolTipText(tr("Locality, hamlet, place.")); 291 291 cadastrewms.add(layerLieudit, GBC.std().insets(5, 0, 5, 0)); 292 layerSection.setSelected( Main.pref.getBoolean("cadastrewms.layerSection", true));292 layerSection.setSelected(Config.getPref().getBoolean("cadastrewms.layerSection", true)); 293 293 layerSection.setToolTipText(tr("Cadastral sections and subsections.")); 294 294 cadastrewms.add(layerSection, GBC.std().insets(5, 0, 5, 0)); 295 layerCommune.setSelected( Main.pref.getBoolean("cadastrewms.layerCommune", true));295 layerCommune.setSelected(Config.getPref().getBoolean("cadastrewms.layerCommune", true)); 296 296 layerCommune.setToolTipText(tr("Municipality administrative borders.")); 297 297 cadastrewms.add(layerCommune, GBC.eop().insets(5, 0, 5, 0)); … … 301 301 302 302 // for raster images (not vectorized), image grab divider (from 1 to 12) 303 String savedRasterDivider = Main.pref.get("cadastrewms.rasterDivider", DEFAULT_RASTER_DIVIDER);303 String savedRasterDivider = Config.getPref().get("cadastrewms.rasterDivider", DEFAULT_RASTER_DIVIDER); 304 304 JLabel jLabelRasterDivider = new JLabel(tr("Raster images grab multiplier:")); 305 305 rasterDivider.setText(savedRasterDivider); … … 308 308 cadastrewms.add(rasterDivider, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 5, 200, 5)); 309 309 // option to disable image cropping during raster image georeferencing 310 disableImageCropping.setSelected( Main.pref.getBoolean("cadastrewms.noImageCropping", false));310 disableImageCropping.setSelected(Config.getPref().getBoolean("cadastrewms.noImageCropping", false)); 311 311 disableImageCropping.setToolTipText(tr("Disable image cropping during georeferencing.")); 312 312 cadastrewms.add(disableImageCropping, GBC.std().insets(0, 0, 10, 0)); 313 313 // option to add the "Tableau d'assemblage" in list of sheets to grab 314 enableTableauAssemblage.setSelected( Main.pref.getBoolean("cadastrewms.useTA", false));314 enableTableauAssemblage.setSelected(Config.getPref().getBoolean("cadastrewms.useTA", false)); 315 315 enableTableauAssemblage.setToolTipText(tr("Add the \"Tableau(x) d''assemblage\" in the list of cadastre sheets to grab.")); 316 316 cadastrewms.add(enableTableauAssemblage, GBC.eop().insets(0, 0, 0, 0)); 317 317 // option to use 2 bits colors only 318 simplify2BitsColors.setSelected( Main.pref.getBoolean("cadastrewms.raster2bitsColors", false));318 simplify2BitsColors.setSelected(Config.getPref().getBoolean("cadastrewms.raster2bitsColors", false)); 319 319 simplify2BitsColors.setToolTipText(tr("Replace greyscale by white color (smaller files and memory usage).")); 320 320 cadastrewms.add(simplify2BitsColors, GBC.eop().insets(0, 0, 0, 0)); … … 348 348 } 349 349 }); 350 enableCache.setSelected( Main.pref.getBoolean("cadastrewms.enableCaching", true));350 enableCache.setSelected(Config.getPref().getBoolean("cadastrewms.enableCaching", true)); 351 351 enableCache.setToolTipText(tr("Allows an automatic caching")); 352 352 cadastrewms.add(enableCache, GBC.eop().insets(0, 0, 0, 0)); … … 363 363 364 364 // option to select the first WMS layer 365 autoFirstLayer.setSelected( Main.pref.getBoolean("cadastrewms.autoFirstLayer", false));365 autoFirstLayer.setSelected(Config.getPref().getBoolean("cadastrewms.autoFirstLayer", false)); 366 366 autoFirstLayer.setToolTipText(tr("Automatically selects the first WMS layer if multiple layers exist when grabbing.")); 367 367 cadastrewms.add(autoFirstLayer, GBC.eop().insets(0, 0, 0, 0)); … … 371 371 372 372 // option to use or not relations in addresses 373 dontUseRelation.setSelected( Main.pref.getBoolean("cadastrewms.addr.dontUseRelation", false));373 dontUseRelation.setSelected(Config.getPref().getBoolean("cadastrewms.addr.dontUseRelation", false)); 374 374 dontUseRelation.setToolTipText(tr("Enable this to use the tag \"add:street\" on nodes.")); 375 375 cadastrewms.add(dontUseRelation, GBC.eop().insets(0, 0, 0, 0)); … … 384 384 @Override 385 385 public boolean ok() { 386 Main.pref.put("cadastrewms.source", sourcing.getText());386 Config.getPref().put("cadastrewms.source", sourcing.getText()); 387 387 CadastrePlugin.source = sourcing.getText(); 388 Main.pref.putBoolean("cadastrewms.alterColors", alterColors.isSelected());389 Main.pref.putBoolean("cadastrewms.invertGrey", reversGrey.isSelected());390 Main.pref.putBoolean("cadastrewms.backgroundTransparent", transparency.isSelected());391 Main.pref.put("cadastrewms.brightness", Float.toString((float) sliderTrans.getValue()/10));392 Main.pref.putBoolean("cadastrewms.drawBoundaries", drawBoundaries.isSelected());388 Config.getPref().putBoolean("cadastrewms.alterColors", alterColors.isSelected()); 389 Config.getPref().putBoolean("cadastrewms.invertGrey", reversGrey.isSelected()); 390 Config.getPref().putBoolean("cadastrewms.backgroundTransparent", transparency.isSelected()); 391 Config.getPref().put("cadastrewms.brightness", Float.toString((float) sliderTrans.getValue()/10)); 392 Config.getPref().putBoolean("cadastrewms.drawBoundaries", drawBoundaries.isSelected()); 393 393 if (grabRes1.isSelected()) 394 Main.pref.put("cadastrewms.resolution", "high");394 Config.getPref().put("cadastrewms.resolution", "high"); 395 395 else if (grabRes2.isSelected()) 396 Main.pref.put("cadastrewms.resolution", "medium");396 Config.getPref().put("cadastrewms.resolution", "medium"); 397 397 else if (grabRes3.isSelected()) 398 Main.pref.put("cadastrewms.resolution", "low");398 Config.getPref().put("cadastrewms.resolution", "low"); 399 399 if (imageInterpolationMethod.getSelectedIndex() == 2) 400 Main.pref.put("cadastrewms.imageInterpolation", "bicubic");400 Config.getPref().put("cadastrewms.imageInterpolation", "bicubic"); 401 401 else if (imageInterpolationMethod.getSelectedIndex() == 1) 402 Main.pref.put("cadastrewms.imageInterpolation", "bilinear");402 Config.getPref().put("cadastrewms.imageInterpolation", "bilinear"); 403 403 else 404 Main.pref.put("cadastrewms.imageInterpolation", "standard");404 Config.getPref().put("cadastrewms.imageInterpolation", "standard"); 405 405 if (grabMultiplier1.isSelected()) 406 Main.pref.put("cadastrewms.scale", Scale.X1.toString());406 Config.getPref().put("cadastrewms.scale", Scale.X1.toString()); 407 407 else if (grabMultiplier2.isSelected()) 408 Main.pref.put("cadastrewms.scale", Scale.X2.toString());408 Config.getPref().put("cadastrewms.scale", Scale.X2.toString()); 409 409 else if (grabMultiplier3.isSelected()) 410 Main.pref.put("cadastrewms.scale", Scale.X3.toString());410 Config.getPref().put("cadastrewms.scale", Scale.X3.toString()); 411 411 else { 412 Main.pref.put("cadastrewms.scale", Scale.SQUARE_100M.toString());412 Config.getPref().put("cadastrewms.scale", Scale.SQUARE_100M.toString()); 413 413 try { 414 414 int squareSize = Integer.parseInt(grabMultiplier4Size.getText()); 415 415 if (squareSize >= 25 && squareSize <= 1000) 416 Main.pref.put("cadastrewms.squareSize", grabMultiplier4Size.getText());416 Config.getPref().put("cadastrewms.squareSize", grabMultiplier4Size.getText()); 417 417 } catch (NumberFormatException e) { 418 418 Logging.debug(e); 419 419 } 420 420 } 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());421 Config.getPref().putBoolean("cadastrewms.layerWater", layerLS3.isSelected()); 422 Config.getPref().putBoolean("cadastrewms.layerBuilding", layerLS2.isSelected()); 423 Config.getPref().putBoolean("cadastrewms.layerSymbol", layerLS1.isSelected()); 424 Config.getPref().putBoolean("cadastrewms.layerParcel", layerParcel.isSelected()); 425 Config.getPref().putBoolean("cadastrewms.layerLabel", layerLabel.isSelected()); 426 Config.getPref().putBoolean("cadastrewms.layerNumero", layerNumero.isSelected()); 427 Config.getPref().putBoolean("cadastrewms.layerLieudit", layerLieudit.isSelected()); 428 Config.getPref().putBoolean("cadastrewms.layerSection", layerSection.isSelected()); 429 Config.getPref().putBoolean("cadastrewms.layerCommune", layerCommune.isSelected()); 430 430 try { 431 431 int i = Integer.parseInt(rasterDivider.getText()); 432 432 if (i > 0 && i < 13) 433 Main.pref.put("cadastrewms.rasterDivider", String.valueOf(i));433 Config.getPref().put("cadastrewms.rasterDivider", String.valueOf(i)); 434 434 } catch (NumberFormatException e) { 435 435 Logging.debug(e); 436 436 } 437 Main.pref.putBoolean("cadastrewms.noImageCropping", disableImageCropping.isSelected());438 Main.pref.putBoolean("cadastrewms.useTA", enableTableauAssemblage.isSelected());439 Main.pref.putBoolean("cadastrewms.raster2bitsColors", simplify2BitsColors.isSelected());440 if (crosspiece1.isSelected()) Main.pref.put("cadastrewms.crosspieces", "0");441 else if (crosspiece2.isSelected()) Main.pref.put("cadastrewms.crosspieces", "1");442 else if (crosspiece3.isSelected()) Main.pref.put("cadastrewms.crosspieces", "2");443 else if (crosspiece4.isSelected()) Main.pref.put("cadastrewms.crosspieces", "3");444 Main.pref.putBoolean("cadastrewms.enableCaching", enableCache.isSelected());437 Config.getPref().putBoolean("cadastrewms.noImageCropping", disableImageCropping.isSelected()); 438 Config.getPref().putBoolean("cadastrewms.useTA", enableTableauAssemblage.isSelected()); 439 Config.getPref().putBoolean("cadastrewms.raster2bitsColors", simplify2BitsColors.isSelected()); 440 if (crosspiece1.isSelected()) Config.getPref().put("cadastrewms.crosspieces", "0"); 441 else if (crosspiece2.isSelected()) Config.getPref().put("cadastrewms.crosspieces", "1"); 442 else if (crosspiece3.isSelected()) Config.getPref().put("cadastrewms.crosspieces", "2"); 443 else if (crosspiece4.isSelected()) Config.getPref().put("cadastrewms.crosspieces", "3"); 444 Config.getPref().putBoolean("cadastrewms.enableCaching", enableCache.isSelected()); 445 445 446 446 // spread data into objects instead of restarting the application 447 447 try { 448 448 CacheControl.cacheSize = Integer.parseInt(cacheSize.getText()); 449 Main.pref.put("cadastrewms.cacheSize", String.valueOf(CacheControl.cacheSize));449 Config.getPref().put("cadastrewms.cacheSize", String.valueOf(CacheControl.cacheSize)); 450 450 } catch (NumberFormatException e) { 451 451 Logging.debug(e); 452 452 } 453 Main.pref.putBoolean("cadastrewms.autoFirstLayer", autoFirstLayer.isSelected());453 Config.getPref().putBoolean("cadastrewms.autoFirstLayer", autoFirstLayer.isSelected()); 454 454 CacheControl.cacheEnabled = enableCache.isSelected(); 455 Main.pref.putBoolean("cadastrewms.addr.dontUseRelation", dontUseRelation.isSelected());455 Config.getPref().putBoolean("cadastrewms.addr.dontUseRelation", dontUseRelation.isSelected()); 456 456 CadastrePlugin.refreshConfiguration(); 457 457 CadastrePlugin.refreshMenu(); … … 462 462 private int getNumber(String pref_parameter, int def_value) { 463 463 try { 464 return Integer.parseInt( Main.pref.get(pref_parameter, String.valueOf(def_value)));464 return Integer.parseInt(Config.getPref().get(pref_parameter, String.valueOf(def_value))); 465 465 } catch (NumberFormatException e) { 466 466 return def_value; -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/CacheControl.java
r33640 r34458 20 20 import javax.swing.JOptionPane; 21 21 22 import org.openstreetmap.josm. Main;22 import org.openstreetmap.josm.gui.MainApplication; 23 23 import org.openstreetmap.josm.gui.util.GuiHelper; 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.spi.preferences.Config; 26 27 import org.openstreetmap.josm.tools.Logging; 27 28 … … 69 70 70 71 public CacheControl(WMSLayer wmsLayer) { 71 cacheEnabled = Main.pref.getBoolean("cadastrewms.enableCaching", true);72 cacheEnabled = Config.getPref().getBoolean("cadastrewms.enableCaching", true); 72 73 this.wmsLayer = wmsLayer; 73 74 try { 74 cacheSize = Integer.parseInt(Main.pref.get("cadastrewms.cacheSize", String.valueOf(CadastrePreferenceSetting.DEFAULT_CACHE_SIZE))); 75 cacheSize = Integer.parseInt(Config.getPref().get("cadastrewms.cacheSize", 76 String.valueOf(CadastrePreferenceSetting.DEFAULT_CACHE_SIZE))); 75 77 } catch (NumberFormatException e) { 76 78 cacheSize = CadastrePreferenceSetting.DEFAULT_CACHE_SIZE; … … 121 123 JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null); 122 124 // this below is a temporary workaround to fix the "always on top" issue 123 JDialog dialog = pane.createDialog(Main .parent, tr("Select Feuille"));125 JDialog dialog = pane.createDialog(MainApplication.getMainFrame(), tr("Select Feuille")); 124 126 CadastrePlugin.prepareDialog(dialog); 125 127 dialog.setVisible(true); … … 160 162 } catch (IOException | ClassNotFoundException ex) { 161 163 Logging.error(ex); 162 GuiHelper.runInEDTAndWait(() -> JOptionPane.showMessageDialog(Main .parent,164 GuiHelper.runInEDTAndWait(() -> JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 163 165 tr("Error loading file.\nProbably an old version of the cache file."), 164 166 tr("Error"), JOptionPane.ERROR_MESSAGE)); -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/CadastreInterface.java
r34223 r34458 24 24 import javax.swing.JPanel; 25 25 26 import org.openstreetmap.josm.Main;27 26 import org.openstreetmap.josm.data.coor.EastNorth; 28 27 import org.openstreetmap.josm.data.validation.util.Entities; … … 32 31 import org.openstreetmap.josm.io.OsmTransferException; 33 32 import org.openstreetmap.josm.plugins.fr.cadastre.CadastrePlugin; 33 import org.openstreetmap.josm.spi.preferences.Config; 34 34 import org.openstreetmap.josm.tools.GBC; 35 35 import org.openstreetmap.josm.tools.HttpClient; … … 109 109 Logging.error(e); 110 110 GuiHelper.runInEDT(() -> 111 JOptionPane.showMessageDialog(Main .parent,111 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 112 112 tr("Town/city {0} not found or not available\n" + 113 113 "or action canceled", wmsLayer.getLocation()))); … … 221 221 wmsLayer.setCodeCommune(newCodeCommune); 222 222 wmsLayer.setLocation(newLocation); 223 Main.pref.put("cadastrewms.codeCommune", newCodeCommune);224 Main.pref.put("cadastrewms.location", newLocation);223 Config.getPref().put("cadastrewms.codeCommune", newCodeCommune); 224 Config.getPref().put("cadastrewms.location", newLocation); 225 225 } 226 226 checkLayerDuplicates(wmsLayer); … … 393 393 // get "Tableau d'assemblage" 394 394 String inputTA = input; 395 if ( Main.pref.getBoolean("cadastrewms.useTA", false)) {395 if (Config.getPref().getBoolean("cadastrewms.useTA", false)) { 396 396 while (inputTA.indexOf(C_TA_IMAGE_LINK_START) != -1) { 397 397 inputTA = inputTA.substring(inputTA.indexOf(C_TA_IMAGE_LINK_START) + C_TA_IMAGE_LINK_START.length() … … 427 427 JOptionPane pane = new JOptionPane(p, JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null); 428 428 // this below is a temporary workaround to fix the "always on top" issue 429 JDialog dialog = pane.createDialog(Main .parent, tr("Select commune"));429 JDialog dialog = pane.createDialog(MainApplication.getMainFrame(), tr("Select commune")); 430 430 CadastrePlugin.prepareDialog(dialog); 431 431 dialog.setVisible(true); … … 448 448 JOptionPane pane = new JOptionPane(p, JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null); 449 449 // this below is a temporary workaround to fix the "always on top" issue 450 JDialog dialog = pane.createDialog(Main .parent, tr("Select Feuille"));450 JDialog dialog = pane.createDialog(MainApplication.getMainFrame(), tr("Select Feuille")); 451 451 CadastrePlugin.prepareDialog(dialog); 452 452 dialog.setVisible(true); -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/DownloadSVGBuilding.java
r33640 r34458 20 20 import javax.swing.JOptionPane; 21 21 22 import org.openstreetmap.josm.Main;23 22 import org.openstreetmap.josm.command.AddCommand; 24 23 import org.openstreetmap.josm.command.Command; 25 24 import org.openstreetmap.josm.command.SequenceCommand; 25 import org.openstreetmap.josm.data.UndoRedoHandler; 26 26 import org.openstreetmap.josm.data.coor.EastNorth; 27 27 import org.openstreetmap.josm.data.osm.DataSet; 28 28 import org.openstreetmap.josm.data.osm.Node; 29 import org.openstreetmap.josm.data.osm.OsmDataManager; 29 30 import org.openstreetmap.josm.data.osm.Way; 31 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 30 32 import org.openstreetmap.josm.gui.MainApplication; 31 33 import org.openstreetmap.josm.gui.MapView; … … 118 120 Way wayToAdd = new Way(); 119 121 for (EastNorth eastNorth : path) { 120 Node nodeToAdd = new Node( Main.getProjection().eastNorth2latlon(eastNorth));122 Node nodeToAdd = new Node(ProjectionRegistry.getProjection().eastNorth2latlon(eastNorth)); 121 123 // check if new node is not already created by another new path 122 124 Node nearestNewNode = checkNearestNode(nodeToAdd, svgDataSet.getNodes()); … … 157 159 } 158 160 159 DataSet ds = Main.main.getEditDataSet();161 DataSet ds = OsmDataManager.getInstance().getEditDataSet(); 160 162 Collection<Command> cmds = new LinkedList<>(); 161 163 for (Node node : svgDataSet.getNodes()) { … … 167 169 cmds.add(new AddCommand(ds, way)); 168 170 } 169 Main.main.undoRedo.add(new SequenceCommand(tr("Create buildings"), cmds));171 UndoRedoHandler.getInstance().add(new SequenceCommand(tr("Create buildings"), cmds)); 170 172 MainApplication.getMap().repaint(); 171 173 } … … 267 269 if ((currentView.max.east() - currentView.min.east()) > 1000 || 268 270 (currentView.max.north() - currentView.min.north() > 1000)) { 269 JOptionPane.showMessageDialog(Main .parent,271 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 270 272 tr("To avoid cadastre WMS overload,\nbuilding import size is limited to 1 km2 max.")); 271 273 return; 272 274 } 273 275 if (CadastrePlugin.autoSourcing == false) { 274 JOptionPane.showMessageDialog(Main .parent,276 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 275 277 tr("Please, enable auto-sourcing and check cadastre millesime.")); 276 278 return; … … 278 280 MainApplication.worker.execute(new DownloadSVGBuilding(wmsLayer)); 279 281 if (errorMessage != null) 280 JOptionPane.showMessageDialog(Main .parent, errorMessage);282 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), errorMessage); 281 283 } 282 284 -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/DownloadSVGTask.java
r33640 r34458 22 22 import javax.swing.JOptionPane; 23 23 24 import org.openstreetmap.josm.Main;25 24 import org.openstreetmap.josm.command.AddCommand; 26 25 import org.openstreetmap.josm.command.Command; 27 26 import org.openstreetmap.josm.command.SequenceCommand; 27 import org.openstreetmap.josm.data.UndoRedoHandler; 28 28 import org.openstreetmap.josm.data.coor.EastNorth; 29 29 import org.openstreetmap.josm.data.osm.DataSet; 30 30 import org.openstreetmap.josm.data.osm.Node; 31 import org.openstreetmap.josm.data.osm.OsmDataManager; 31 32 import org.openstreetmap.josm.data.osm.Way; 33 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 32 34 import org.openstreetmap.josm.gui.MainApplication; 33 35 import org.openstreetmap.josm.gui.PleaseWaitRunnable; … … 123 125 List<Node> nodeList = new ArrayList<>(); 124 126 for (EastNorth eastNorth : eastNorths.get(bestPath)) { 125 nodeList.add(new Node( Main.getProjection().eastNorth2latlon(eastNorth)));127 nodeList.add(new Node(ProjectionRegistry.getProjection().eastNorth2latlon(eastNorth))); 126 128 } 127 129 Way wayToAdd = new Way(); 128 DataSet ds = Main.main.getEditDataSet();130 DataSet ds = OsmDataManager.getInstance().getEditDataSet(); 129 131 Collection<Command> cmds = new LinkedList<>(); 130 132 for (Node node : nodeList) { … … 135 137 136 138 cmds.add(new AddCommand(ds, wayToAdd)); 137 Main.main.undoRedo.add(new SequenceCommand(tr("Create boundary"), cmds));139 UndoRedoHandler.getInstance().add(new SequenceCommand(tr("Create boundary"), cmds)); 138 140 MainApplication.getMap().repaint(); 139 141 } … … 215 217 public static void download(WMSLayer wmsLayer) { 216 218 if (!CadastrePlugin.autoSourcing) { 217 JOptionPane.showMessageDialog(Main .parent,219 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 218 220 tr("Please, enable auto-sourcing and check cadastre millesime.")); 219 221 return; … … 221 223 MainApplication.worker.execute(new DownloadSVGTask(wmsLayer)); 222 224 if (errorMessage != null) 223 JOptionPane.showMessageDialog(Main .parent, errorMessage);225 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), errorMessage); 224 226 } 225 227 } -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/DownloadWMSPlanImage.java
r33640 r34458 10 10 import javax.swing.JOptionPane; 11 11 12 import org.openstreetmap.josm.Main;13 12 import org.openstreetmap.josm.data.Bounds; 14 13 import org.openstreetmap.josm.gui.MainApplication; … … 40 39 JOptionPane pane = new JOptionPane(tr("Image already loaded"), JOptionPane.INFORMATION_MESSAGE); 41 40 // this below is a temporary workaround to fix the "always on top" issue 42 JDialog dialog = pane.createDialog(Main .parent, "");41 JDialog dialog = pane.createDialog(MainApplication.getMainFrame(), ""); 43 42 CadastrePlugin.prepareDialog(dialog); 44 43 dialog.setVisible(true); … … 70 69 } 71 70 } else { 72 /*JOptionPane.showMessageDialog(Main .parent,tr("Municipality vectorized !\n"+71 /*JOptionPane.showMessageDialog(MainApplication.getMainFrame(),tr("Municipality vectorized !\n"+ 73 72 "Use the normal Cadastre Grab menu."));*/ 74 73 JOptionPane pane = new JOptionPane( … … 76 75 JOptionPane.INFORMATION_MESSAGE); 77 76 // this below is a temporary workaround to fix the "always on top" issue 78 JDialog dialog = pane.createDialog(Main .parent, "");77 JDialog dialog = pane.createDialog(MainApplication.getMainFrame(), ""); 79 78 CadastrePlugin.prepareDialog(dialog); 80 79 dialog.setVisible(true); … … 114 113 task = MainApplication.worker.submit(t, t); 115 114 if (errorMessage != null) 116 JOptionPane.showMessageDialog(Main .parent, errorMessage);115 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), errorMessage); 117 116 } 118 117 -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/DownloadWMSVectorImage.java
r33682 r34458 8 8 import javax.swing.JOptionPane; 9 9 10 import org.openstreetmap.josm.Main;11 10 import org.openstreetmap.josm.data.Bounds; 12 11 import org.openstreetmap.josm.gui.MainApplication; … … 46 45 // set raster image commune bounding box based on current view (before adjustment) 47 46 GuiHelper.runInEDT(() -> 48 JOptionPane.showMessageDialog(Main .parent,47 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 49 48 tr("This commune is not vectorized.\nPlease use the other menu entry to georeference a \"Plan image\""))); 50 49 MainApplication.getLayerManager().removeLayer(wmsLayer); … … 89 88 MainApplication.worker.execute(new DownloadWMSVectorImage(wmsLayer, bounds)); 90 89 if (errorMessage != null) 91 JOptionPane.showMessageDialog(Main .parent, errorMessage);90 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), errorMessage); 92 91 } 93 92 } -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/EastNorthBound.java
r33638 r34458 4 4 import java.io.Serializable; 5 5 6 import org.openstreetmap.josm.Main;7 6 import org.openstreetmap.josm.data.Bounds; 8 7 import org.openstreetmap.josm.data.coor.EastNorth; 8 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 9 9 10 10 public class EastNorthBound implements Serializable { … … 33 33 34 34 public Bounds toBounds() { 35 return new Bounds( Main.getProjection().eastNorth2latlon(min), Main.getProjection().eastNorth2latlon(max));35 return new Bounds(ProjectionRegistry.getProjection().eastNorth2latlon(min), ProjectionRegistry.getProjection().eastNorth2latlon(max)); 36 36 } 37 37 -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/RasterImageGeoreferencer.java
r33682 r34458 16 16 import javax.swing.JTextField; 17 17 18 import org.openstreetmap.josm.Main;19 18 import org.openstreetmap.josm.data.coor.EastNorth; 19 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 20 20 import org.openstreetmap.josm.gui.MainApplication; 21 21 import org.openstreetmap.josm.gui.util.GuiHelper; 22 import org.openstreetmap.josm.spi.preferences.Config; 22 23 import org.openstreetmap.josm.tools.GBC; 23 24 import org.openstreetmap.josm.tools.Logging; … … 56 57 mode = cGetCorners; 57 58 countMouseClicked = 0; 58 initialClickDelay = Main.pref.getInt("cadastrewms.georef-click-delay", 200);59 initialClickDelay = Config.getPref().getInt("cadastrewms.georef-click-delay", 200); 59 60 mouseClickedTime = System.currentTimeMillis(); 60 61 Object[] options = {"OK", "Cancel"}; … … 80 81 countMouseClicked = 0; 81 82 mode = cGetLambertCrosspieces; 82 initialClickDelay = Main.pref.getInt("cadastrewms.georef-click-delay", 200);83 initialClickDelay = Config.getPref().getInt("cadastrewms.georef-click-delay", 200); 83 84 mouseClickedTime = System.currentTimeMillis(); 84 85 Object[] options = {"OK", "Cancel"}; … … 110 111 return; 111 112 if (ignoreMouseClick) return; // In case we are currently just allowing zooming to read lambert coordinates 112 EastNorth ea = Main.getProjection().latlon2eastNorth(MainApplication.getMap().mapView.getLatLon(e.getX(), e.getY()));113 EastNorth ea = ProjectionRegistry.getProjection().latlon2eastNorth(MainApplication.getMap().mapView.getLatLon(e.getX(), e.getY())); 113 114 Logging.info("click:"+countMouseClicked+" ,"+ea+", mode:"+mode); 114 115 if (clickOnTheMap) { … … 179 180 // handle an NPE case I'm not able to reproduce 180 181 if (org1 == null || org2 == null || dst1 == null || dst2 == null) { 181 JOptionPane.showMessageDialog(Main .parent,182 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 182 183 tr("Ooops. I failed to catch all coordinates\n"+ 183 184 "correctly. Retry please.")); … … 238 239 else 239 240 number = "second"; 240 JDialog dialog = pane.createDialog(Main .parent, tr(241 JDialog dialog = pane.createDialog(MainApplication.getMainFrame(), tr( 241 242 "Set {0} Lambert coordinates", number)); 242 243 dialog.setModal(false); -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/RasterImageModifier.java
r34115 r34458 7 7 import java.awt.image.IndexColorModel; 8 8 9 import org.openstreetmap.josm. Main;9 import org.openstreetmap.josm.spi.preferences.Config; 10 10 11 11 public class RasterImageModifier extends ImageModifier { … … 19 19 public RasterImageModifier(BufferedImage bi) { 20 20 setBufferedImage(bi); 21 transparencyEnabled = Main.pref.getBoolean("cadastrewms.backgroundTransparent");21 transparencyEnabled = Config.getPref().getBoolean("cadastrewms.backgroundTransparent"); 22 22 if (transparencyEnabled) 23 23 makeTransparent(); 24 if ( Main.pref.getBoolean("cadastrewms.invertGrey"))24 if (Config.getPref().getBoolean("cadastrewms.invertGrey")) 25 25 invertGrey(); 26 26 } … … 65 65 BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); 66 66 // converting grey scale colors to black/white is configurable (use less resources but is less readable) 67 boolean simplifyColors = Main.pref.getBoolean("cadastrewms.raster2bitsColors", false);67 boolean simplifyColors = Config.getPref().getBoolean("cadastrewms.raster2bitsColors", false); 68 68 for (int y = 0; y < height; y++) { 69 69 for (int x = 0; x < width; x++) { -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/VectorImageModifier.java
r33638 r34458 8 8 import java.awt.image.WritableRaster; 9 9 10 import org.openstreetmap.josm. Main;10 import org.openstreetmap.josm.spi.preferences.Config; 11 11 import org.openstreetmap.josm.tools.ColorHelper; 12 12 … … 25 25 public VectorImageModifier(BufferedImage bi, boolean monocolor) { 26 26 setBufferedImage(bi); 27 if ( Main.pref.getBoolean("cadastrewms.backgroundTransparent"))27 if (Config.getPref().getBoolean("cadastrewms.backgroundTransparent")) 28 28 makeTransparent(); 29 else if ( Main.pref.getBoolean("cadastrewms.alterColors"))29 else if (Config.getPref().getBoolean("cadastrewms.alterColors")) 30 30 replaceBackground(); 31 if ( Main.pref.getBoolean("cadastrewms.invertGrey"))31 if (Config.getPref().getBoolean("cadastrewms.invertGrey")) 32 32 invertGrey(); 33 33 if (monocolor) … … 41 41 int w = bufferedImage.getWidth(); 42 42 int h = bufferedImage.getHeight(); 43 int josmBackgroundColor = ColorHelper.html2color( Main.pref.get("color.background", "#000000")).getRGB();43 int josmBackgroundColor = ColorHelper.html2color(Config.getPref().get("color.background", "#000000")).getRGB(); 44 44 for (int x = 0; x < w; x++) { 45 45 for (int y = 0; y < h; y++) { -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/WMSException.java
r33638 r34458 2 2 package org.openstreetmap.josm.plugins.fr.cadastre.wms; 3 3 4 /** 5 * Exception thrown in case of WMS error. 6 */ 4 7 public class WMSException extends Exception { 5 private String message;6 8 private static final long serialVersionUID = 1L; 7 9 10 /** 11 * Constructs a new {@code WMSException} with the specified detail message. 12 * The cause is not initialized, and may subsequently be initialized by 13 * a call to {@link #initCause}. 14 * 15 * @param message the detail message. The detail message is saved for 16 * later retrieval by the {@link #getMessage()} method. 17 */ 8 18 public WMSException(String message) { 9 super(); 10 this.message = message; 11 } 12 13 @Override 14 public String getMessage() { 15 return message; 19 super(message); 16 20 } 17 21 } -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/WMSLayer.java
r34115 r34458 31 31 import javax.swing.JOptionPane; 32 32 33 import org.openstreetmap.josm.Main;34 33 import org.openstreetmap.josm.actions.JosmAction; 35 34 import org.openstreetmap.josm.data.Bounds; 36 35 import org.openstreetmap.josm.data.coor.EastNorth; 37 36 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 37 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 38 38 import org.openstreetmap.josm.gui.MainApplication; 39 39 import org.openstreetmap.josm.gui.MapView; … … 49 49 import org.openstreetmap.josm.plugins.fr.cadastre.actions.mapmode.WMSAdjustAction; 50 50 import org.openstreetmap.josm.plugins.fr.cadastre.preferences.CadastrePreferenceSetting; 51 import org.openstreetmap.josm.spi.preferences.Config; 51 52 import org.openstreetmap.josm.tools.Logging; 52 53 … … 175 176 } else { 176 177 if (isRaster) { 177 divideBbox(new Bounds(Main.getProjection().eastNorth2latlon(rasterMin), Main.getProjection().eastNorth2latlon(rasterMax)), 178 Integer.parseInt(Main.pref.get("cadastrewms.rasterDivider", CadastrePreferenceSetting.DEFAULT_RASTER_DIVIDER))); 178 divideBbox(new Bounds(ProjectionRegistry.getProjection().eastNorth2latlon(rasterMin), 179 ProjectionRegistry.getProjection().eastNorth2latlon(rasterMax)), 180 Integer.parseInt(Config.getPref().get("cadastrewms.rasterDivider", CadastrePreferenceSetting.DEFAULT_RASTER_DIVIDER))); 179 181 } else 180 182 divideBbox(b, 181 Integer.parseInt( Main.pref.get("cadastrewms.scale", CadastrePreferenceSetting.DEFAULT_GRAB_MULTIPLIER)));183 Integer.parseInt(Config.getPref().get("cadastrewms.scale", CadastrePreferenceSetting.DEFAULT_GRAB_MULTIPLIER))); 182 184 } 183 185 grabThread.addImages(dividedBbox); … … 195 197 */ 196 198 private void divideBbox(Bounds b, int factor) { 197 EastNorth lambertMin = Main.getProjection().latlon2eastNorth(b.getMin());198 EastNorth lambertMax = Main.getProjection().latlon2eastNorth(b.getMax());199 EastNorth lambertMin = ProjectionRegistry.getProjection().latlon2eastNorth(b.getMin()); 200 EastNorth lambertMax = ProjectionRegistry.getProjection().latlon2eastNorth(b.getMax()); 199 201 double minEast = lambertMin.east()+deltaEast; 200 202 double minNorth = lambertMin.north()+deltaNorth; … … 212 214 // divide to fixed size squares 213 215 // grab all square in a spiral starting from the center (usually the most interesting place) 214 int c = Integer.parseInt(Main.pref.get("cadastrewms.squareSize", String.valueOf(CadastrePreferenceSetting.DEFAULT_SQUARE_SIZE))); 216 int c = Integer.parseInt(Config.getPref().get("cadastrewms.squareSize", 217 String.valueOf(CadastrePreferenceSetting.DEFAULT_SQUARE_SIZE))); 215 218 lambertMin = lambertMin.add(-minEast % c, -minNorth % c); 216 219 lambertMax = lambertMax.add(c - lambertMax.east() % c, c - lambertMax.north() % c); … … 289 292 Object savedInterpolation = g.getRenderingHint(RenderingHints.KEY_INTERPOLATION); 290 293 if (savedInterpolation == null) savedInterpolation = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR; 291 String interpolation = Main.pref.get("cadastrewms.imageInterpolation", "standard");294 String interpolation = Config.getPref().get("cadastrewms.imageInterpolation", "standard"); 292 295 if (interpolation.equals("bilinear")) 293 296 g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); … … 362 365 GeorefImage georefImage = 363 366 new GeorefImage(null, 364 Main.getProjection().latlon2eastNorth(bounds.getMin()),365 Main.getProjection().latlon2eastNorth(bounds.getMax()), this);367 ProjectionRegistry.getProjection().latlon2eastNorth(bounds.getMin()), 368 ProjectionRegistry.getProjection().latlon2eastNorth(bounds.getMax()), this); 366 369 for (GeorefImage img : images) { 367 370 if (img.overlap(georefImage)) … … 438 441 */ 439 442 public void setRasterBounds(Bounds bounds) { 440 EastNorth rasterCenter = Main.getProjection().latlon2eastNorth(bounds.getCenter());441 EastNorth eaMin = Main.getProjection().latlon2eastNorth(bounds.getMin());442 EastNorth eaMax = Main.getProjection().latlon2eastNorth(bounds.getMax());443 EastNorth rasterCenter = ProjectionRegistry.getProjection().latlon2eastNorth(bounds.getCenter()); 444 EastNorth eaMin = ProjectionRegistry.getProjection().latlon2eastNorth(bounds.getMin()); 445 EastNorth eaMax = ProjectionRegistry.getProjection().latlon2eastNorth(bounds.getMax()); 443 446 double rasterSizeX = communeBBox.max.getX() - communeBBox.min.getX(); 444 447 double rasterSizeY = communeBBox.max.getY() - communeBBox.min.getY(); … … 483 486 currentFormat = ois.readInt();; 484 487 if (currentFormat < 2) { 485 JOptionPane.showMessageDialog(Main.parent, tr("Unsupported cache file version; found {0}, expected {1}\nCreate a new one.", 488 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 489 tr("Unsupported cache file version; found {0}, expected {1}\nCreate a new one.", 486 490 currentFormat, this.serializeFormatVersion), tr("Cache Format Error"), JOptionPane.ERROR_MESSAGE); 487 491 return false; … … 509 513 this.communeBBox = new EastNorthBound(new EastNorth(minX, minY), new EastNorth(maxX, maxY)); 510 514 if (this.lambertZone != currentLambertZone && currentLambertZone != -1) { 511 JOptionPane.showMessageDialog(Main .parent, tr("Lambert zone {0} in cache "+515 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), tr("Lambert zone {0} in cache "+ 512 516 "incompatible with current Lambert zone {1}", 513 517 this.lambertZone+1, currentLambertZone), tr("Cache Lambert Zone Error"), JOptionPane.ERROR_MESSAGE); … … 668 672 669 673 private void paintCrosspieces(Graphics g, MapView mv) { 670 String crosspieces = Main.pref.get("cadastrewms.crosspieces", "0");674 String crosspieces = Config.getPref().get("cadastrewms.crosspieces", "0"); 671 675 if (!crosspieces.equals("0")) { 672 676 int modulo = 25;
Note:
See TracChangeset
for help on using the changeset viewer.