Ignore:
Timestamp:
2018-08-13T22:53:18+02:00 (6 years ago)
Author:
donvip
Message:

update to JOSM 14153

Location:
applications/editors/josm/plugins/cadastre-fr
Files:
26 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/cadastre-fr/.classpath

    r33671 r34458  
    22<classpath>
    33        <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>
    59        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
    610        <classpathentry combineaccessrules="false" kind="src" path="/JOSM"/>
  • applications/editors/josm/plugins/cadastre-fr/build.xml

    r34290 r34458  
    44    <property name="commit.message" value="Changed constructor for Plugin"/>
    55    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    6     <property name="plugin.main.version" value="13927"/>
     6    <property name="plugin.main.version" value="14153"/>
    77   
    88    <!-- Configure these properties (replace "..." accordingly).
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/CadastrePlugin.java

    r34355 r34458  
    2323import javax.swing.KeyStroke;
    2424
    25 import org.openstreetmap.josm.Main;
    2625import org.openstreetmap.josm.actions.ExtensionFileFilter;
    2726import org.openstreetmap.josm.actions.JosmAction;
     
    2928import org.openstreetmap.josm.data.projection.AbstractProjection;
    3029import org.openstreetmap.josm.data.projection.Projection;
     30import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3131import org.openstreetmap.josm.gui.IconToggleButton;
    3232import org.openstreetmap.josm.gui.MainApplication;
     
    5757import org.openstreetmap.josm.plugins.fr.cadastre.session.CadastreSessionImporter;
    5858import org.openstreetmap.josm.plugins.fr.cadastre.wms.WMSLayer;
     59import org.openstreetmap.josm.spi.preferences.Config;
    5960import org.openstreetmap.josm.tools.Logging;
    6061
     
    153154 * <br>                - move the grabber from CadastrPlugin singleton to each wmsLayer instance to allow grabbing
    154155 *                       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()
    156157 * <br>                - fix list of raster images (Feuilles) parsing failing after a Cadastre server change/maintenance
    157158 * <br>2.3 11-Jan-2013 - add various improvements from Don-Vip (Vincent Privat) trac #8175, #8229 and #5626.
     
    239240
    240241    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();
    243244        } else {
    244             cacheDir = Main.pref.get("cadastrewms.cacheDir");
     245            cacheDir = Config.getPref().get("cadastrewms.cacheDir");
    245246        }
    246247        if (cacheDir.charAt(cacheDir.length()-1) != File.separatorChar)
     
    267268                @Override
    268269                public void actionPerformed(ActionEvent ev) {
    269                     Main.pref.putBoolean("cadastrewms.autosourcing", menuSource.isSelected());
     270                    Config.getPref().putBoolean("cadastrewms.autosourcing", menuSource.isSelected());
    270271                    autoSourcing = menuSource.isSelected();
    271272                }
     
    285286            //cadastreJMenu.add(menuResetCookie); not required any more
    286287            //cadastreJMenu.add(menuLambertZone);
    287             //if (Main.pref.getBoolean("cadastrewms.buildingsMenu", false))
     288            //if (Config.getPref().getBoolean("cadastrewms.buildingsMenu", false))
    288289            //    cadastreJMenu.add(menuActionBuildings);
    289290            cadastreJMenu.add(menuLoadFromCache);
     
    297298    public static void refreshConfiguration() {
    298299        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);
    302303        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"));
    305306        } else {
    306307            backgroundTransparent = false;
    307308            transparency = 1.0f;
    308309        }
    309         String currentResolution = Main.pref.get("cadastrewms.resolution", "high");
     310        String currentResolution = Config.getPref().get("cadastrewms.resolution", "high");
    310311        if (currentResolution.equals("high")) {
    311312            imageWidth = 1000; imageHeight = 800;
     
    323324        grabStyles = "";
    324325        int countLayers = 0;
    325         if (Main.pref.getBoolean("cadastrewms.layerWater", true)) {
     326        if (Config.getPref().getBoolean("cadastrewms.layerWater", true)) {
    326327            grabLayers += LAYER_WATER + ",";
    327328            grabStyles += STYLE_WATER + ",";
    328329            countLayers++;
    329330        }
    330         if (Main.pref.getBoolean("cadastrewms.layerBuilding", true)) {
     331        if (Config.getPref().getBoolean("cadastrewms.layerBuilding", true)) {
    331332            grabLayers += LAYER_BULDINGS + ",";
    332333            grabStyles += STYLE_BUILDING + ",";
    333334            countLayers++;
    334335        }
    335         if (Main.pref.getBoolean("cadastrewms.layerSymbol", true)) {
     336        if (Config.getPref().getBoolean("cadastrewms.layerSymbol", true)) {
    336337            grabLayers += LAYER_SYMBOL + ",";
    337338            grabStyles += STYLE_SYMBOL + ",";
    338339            countLayers++;
    339340        }
    340         if (Main.pref.getBoolean("cadastrewms.layerParcel", true)) {
     341        if (Config.getPref().getBoolean("cadastrewms.layerParcel", true)) {
    341342            grabLayers += LAYER_PARCELS + ",";
    342343            grabStyles += STYLE_PARCELS + ",";
    343344            countLayers++;
    344345        }
    345         if (Main.pref.getBoolean("cadastrewms.layerNumero", true)) {
     346        if (Config.getPref().getBoolean("cadastrewms.layerNumero", true)) {
    346347            grabLayers += LAYER_NUMERO + ",";
    347348            grabStyles += STYLE_NUMERO + ",";
    348349            countLayers++;
    349350        }
    350         if (Main.pref.getBoolean("cadastrewms.layerLabel", true)) {
     351        if (Config.getPref().getBoolean("cadastrewms.layerLabel", true)) {
    351352            grabLayers += LAYER_LABEL + ",";
    352353            grabStyles += STYLE_LABEL + ",";
    353354            countLayers++;
    354355        }
    355         if (Main.pref.getBoolean("cadastrewms.layerLieudit", true)) {
     356        if (Config.getPref().getBoolean("cadastrewms.layerLieudit", true)) {
    356357            grabLayers += LAYER_LIEUDIT + ",";
    357358            grabStyles += STYLE_LIEUDIT + ",";
    358359            countLayers++;
    359360        }
    360         if (Main.pref.getBoolean("cadastrewms.layerSection", true)) {
     361        if (Config.getPref().getBoolean("cadastrewms.layerSection", true)) {
    361362            grabLayers += LAYER_SECTION + ",";
    362363            grabStyles += STYLE_SECTION + ",";
    363364            countLayers++;
    364365        }
    365         if (Main.pref.getBoolean("cadastrewms.layerCommune", true)) {
     366        if (Config.getPref().getBoolean("cadastrewms.layerCommune", true)) {
    366367            grabLayers += LAYER_COMMUNE + ",";
    367368            grabStyles += STYLE_COMMUNE + ",";
     
    372373            grabStyles = grabStyles.substring(0, grabStyles.length()-1);
    373374        } 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 "
    375376                    + "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);
    378379            grabLayers += LAYER_BULDINGS + "," + LAYER_PARCELS;
    379380            grabStyles += STYLE_BUILDING + "," + STYLE_PARCELS;
     
    416417
    417418    public static boolean isLambert() {
    418         String code = Main.getProjection().toCode();
     419        String code = ProjectionRegistry.getProjection().toCode();
    419420        return Arrays.asList(ProjectionPreference.lambert.allCodes()).contains(code);
    420421    }
    421422
    422423    public static boolean isUtm_france_dom() {
    423         String code = Main.getProjection().toCode();
     424        String code = ProjectionRegistry.getProjection().toCode();
    424425        return Arrays.asList(ProjectionPreference.utm_france_dom.allCodes()).contains(code);
    425426    }
    426427
    427428    public static boolean isLambert_cc9() {
    428         String code = Main.getProjection().toCode();
     429        String code = ProjectionRegistry.getProjection().toCode();
    429430        return Arrays.asList(ProjectionPreference.lambert_cc9.allCodes()).contains(code);
    430431    }
     
    436437    public static int getCadastreProjectionLayoutZone() {
    437438        int zone = -1;
    438         Projection proj = Main.getProjection();
     439        Projection proj = ProjectionRegistry.getProjection();
    439440        if (proj instanceof AbstractProjection) {
    440441            Integer code = ((AbstractProjection) proj).getEpsgCode();
     
    471472    // FIXME: this is a temporary solution.
    472473    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)) {
    474475            try {
    475476                dialog.setAlwaysOnTop(true);
     
    506507    private static String checkSourceMillesime() {
    507508        int currentYear = Calendar.getInstance().get(Calendar.YEAR);
    508         String src = Main.pref.get("cadastrewms.source",
     509        String src = Config.getPref().get("cadastrewms.source",
    509510            "cadastre-dgi-fr source : Direction G\u00e9n\u00e9rale des Imp\u00f4ts - Cadastre. Mise \u00e0 jour : AAAA");
    510511        String srcYear = src.substring(src.lastIndexOf(" ")+1);
     
    518519            Logging.info("Replace source year "+srcYear+" by current year "+currentYear);
    519520            src = src.substring(0, src.lastIndexOf(" ")+1)+currentYear;
    520             Main.pref.put("cadastrewms.source", src);
     521            Config.getPref().put("cadastrewms.source", src);
    521522        }
    522523        return src;
     
    530531            @Override
    531532            public void run() {
    532                 if (JOptionPane.showConfirmDialog(Main.parent,
     533                if (JOptionPane.showConfirmDialog(MainApplication.getMainFrame(),
    533534                        tr("To enable the cadastre WMS plugin, change\n"
    534535                                + "the current projection to one of the cadastre\n"
     
    536537                                tr("Change the current projection"), JOptionPane.OK_CANCEL_OPTION)
    537538                    == JOptionPane.OK_OPTION) {
    538                     PreferenceDialog p = new PreferenceDialog(Main.parent);
     539                    PreferenceDialog p = new PreferenceDialog(MainApplication.getMainFrame());
    539540                    p.selectPreferencesTabByClass(MapPreference.class);
    540541                    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  
    88import javax.swing.JOptionPane;
    99
    10 import org.openstreetmap.josm.Main;
    1110import org.openstreetmap.josm.actions.JosmAction;
     11import org.openstreetmap.josm.gui.MainApplication;
    1212import org.openstreetmap.josm.plugins.fr.cadastre.wms.DownloadSVGTask;
    1313import org.openstreetmap.josm.plugins.fr.cadastre.wms.WMSLayer;
     
    3232        if (wmsLayer != null) {
    3333            if (wmsLayer.isRaster()) {
    34                 JOptionPane.showMessageDialog(Main.parent,
     34                JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
    3535                        tr("Only on vectorized layers"), tr("Error"),
    3636                        JOptionPane.ERROR_MESSAGE);
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionGrabPlanImage.java

    r33640 r34458  
    1010import javax.swing.JOptionPane;
    1111
    12 import org.openstreetmap.josm.Main;
    1312import org.openstreetmap.josm.actions.JosmAction;
    1413import org.openstreetmap.josm.gui.MainApplication;
     
    1716import org.openstreetmap.josm.plugins.fr.cadastre.wms.RasterImageGeoreferencer;
    1817import org.openstreetmap.josm.plugins.fr.cadastre.wms.WMSLayer;
     18import org.openstreetmap.josm.spi.preferences.Config;
    1919
    2020public class MenuActionGrabPlanImage extends JosmAction implements Runnable {
     
    4545        if (MainApplication.getLayerManager().containsLayer(wmsLayer))
    4646            return;
    47         JOptionPane.showMessageDialog(Main.parent, tr("Georeferencing interrupted"));
     47        JOptionPane.showMessageDialog(MainApplication.getMainFrame(), tr("Georeferencing interrupted"));
    4848        rasterImageGeoreferencer.actionInterrupted();
    4949    }
     
    8787            } else {
    8888                rasterImageGeoreferencer.addListener();
    89                 if (Main.pref.getBoolean("cadastrewms.noImageCropping", false) == false)
     89                if (Config.getPref().getBoolean("cadastrewms.noImageCropping", false) == false)
    9090                    rasterImageGeoreferencer.startCropping(wmsLayer);
    9191                else
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionLoadFromCache.java

    r33640 r34458  
    1111import javax.swing.JOptionPane;
    1212
    13 import org.openstreetmap.josm.Main;
    1413import org.openstreetmap.josm.actions.JosmAction;
    1514import org.openstreetmap.josm.gui.MainApplication;
     
    3231     */
    3332    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);
    3535    }
    3636
     
    5353                            !(CadastrePlugin.isUtm_france_dom()))
    5454                    || (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),
    5657                                tr("Error"), JOptionPane.ERROR_MESSAGE);
    5758                        continue;
     
    6768                        if (cacheZone >= 0 && cacheZone <= 9) {
    6869                            if (cacheZone != layoutZone) {
    69                                 JOptionPane.showMessageDialog(Main.parent,
     70                                JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
    7071                                        tr("Cannot load cache {0} which is not compatible with current projection zone", filename),
    7172                                        tr("Error"), JOptionPane.ERROR_MESSAGE);
     
    7576                        }
    7677                    } catch (NumberFormatException ex) {
    77                         JOptionPane.showMessageDialog(Main.parent,
     78                        JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
    7879                                tr("Selected file {0} is not a cache file from this plugin (invalid extension)", filename),
    7980                                tr("Error"), JOptionPane.ERROR_MESSAGE);
     
    8485                        for (Layer l : MainApplication.getLayerManager().getLayers()) {
    8586                            if (l instanceof WMSLayer && l.getName().equals(location)) {
    86                                 JOptionPane.showMessageDialog(Main.parent,
     87                                JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
    8788                                        tr("The location {0} is already on screen. Cache not loaded.", filename),
    8889                                        tr("Error"), JOptionPane.ERROR_MESSAGE);
     
    115116        fc.setAcceptAllFileFilterUsed(false);
    116117
    117         int answer = fc.showOpenDialog(Main.parent);
     118        int answer = fc.showOpenDialog(MainApplication.getMainFrame());
    118119        if (answer != JFileChooser.APPROVE_OPTION)
    119120            return null;
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionNewLocation.java

    r33640 r34458  
    1414import javax.swing.JTextField;
    1515
    16 import org.openstreetmap.josm.Main;
    1716import org.openstreetmap.josm.actions.JosmAction;
    1817import org.openstreetmap.josm.gui.MainApplication;
     
    2120import org.openstreetmap.josm.plugins.fr.cadastre.wms.DownloadWMSVectorImage;
    2221import org.openstreetmap.josm.plugins.fr.cadastre.wms.WMSLayer;
     22import org.openstreetmap.josm.spi.preferences.Config;
    2323import org.openstreetmap.josm.tools.GBC;
    2424import org.openstreetmap.josm.tools.Logging;
     
    7878        JPanel p = new JPanel(new GridBagLayout());
    7979        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"));
    8181        inputTown.setToolTipText(tr("<html>Enter the town,village or city name.<br>"
    8282                + "Use the syntax and punctuation known by www.cadastre.gouv.fr .</html>"));
     
    8787        }
    8888        inputDepartement.setToolTipText(tr("<html>Departement number (optional)</html>"));
    89         if (!Main.pref.get("cadastrewms.codeDepartement").equals("")) {
     89        if (!Config.getPref().get("cadastrewms.codeDepartement").equals("")) {
    9090            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")))
    9292                    inputDepartement.setSelectedIndex(i/2);
    9393            }
     
    107107            }
    108108        };
    109         pane.createDialog(Main.parent, tr("Add new layer")).setVisible(true);
     109        pane.createDialog(MainApplication.getMainFrame(), tr("Add new layer")).setVisible(true);
    110110        if (!Integer.valueOf(JOptionPane.OK_OPTION).equals(pane.getValue()))
    111111            return null;
     
    115115            location = inputTown.getText().toUpperCase();
    116116            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);
    120120            if (MainApplication.getMap() != null) {
    121121                for (Layer l : MainApplication.getLayerManager().getLayers()) {
     
    131131            CadastrePlugin.addWMSLayer(wmsLayer);
    132132            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) {
    134135            wmsLayer = (WMSLayer) MainApplication.getLayerManager().getActiveLayer();
    135136        }
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionOpenPreferences.java

    r33638 r34458  
    77import java.awt.event.ActionEvent;
    88
    9 import org.openstreetmap.josm.Main;
    109import org.openstreetmap.josm.actions.JosmAction;
     10import org.openstreetmap.josm.gui.MainApplication;
    1111import org.openstreetmap.josm.gui.preferences.PreferenceDialog;
    1212import org.openstreetmap.josm.plugins.fr.cadastre.preferences.CadastrePreferenceSetting;
     
    2626    @Override
    2727    public void actionPerformed(ActionEvent e) {
    28         PreferenceDialog p = new PreferenceDialog(Main.parent);
     28        PreferenceDialog p = new PreferenceDialog(MainApplication.getMainFrame());
    2929        p.selectPreferencesTabByClass(CadastrePreferenceSetting.class);
    3030        p.setVisible(true);
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionSaveRasterAs.java

    r34115 r34458  
    2525import org.opengis.parameter.GeneralParameterValue;
    2626import org.opengis.parameter.ParameterValueGroup;
    27 import org.openstreetmap.josm.Main;
    2827import org.openstreetmap.josm.actions.JosmAction;
     28import org.openstreetmap.josm.gui.MainApplication;
    2929import org.openstreetmap.josm.plugins.fr.cadastre.wms.WMSLayer;
    3030import org.openstreetmap.josm.tools.Logging;
     
    8787        fc.addChoosableFileFilter(filtrePng);
    8888        fc.setFileFilter(filtreTiff);
    89         int returnVal = fc.showSaveDialog(Main.parent);
     89        int returnVal = fc.showSaveDialog(MainApplication.getMainFrame());
    9090        if (returnVal == JFileChooser.APPROVE_OPTION) {
    9191            file = fc.getSelectedFile();
     
    9696                try {
    9797                    ImageIO.write(bi, "png", file);
    98 /*
     98                    /*
    9999                    FileOutputStream flux = new FileOutputStream(file);
    100100                    BufferedOutputStream fluxBuf = new BufferedOutputStream(flux);
     
    102102                    codec.encode(bi);
    103103                    fluxBuf.close();
    104 */
     104                    */
    105105                } catch (IOException e) {
    106106                    e.printStackTrace();
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/WMSDownloadAction.java

    r33640 r34458  
    99import javax.swing.JOptionPane;
    1010
    11 import org.openstreetmap.josm.Main;
    1211import org.openstreetmap.josm.gui.MainApplication;
    1312//import org.openstreetmap.josm.actions.JosmAction;
    1413import org.openstreetmap.josm.gui.layer.Layer;
    1514import org.openstreetmap.josm.plugins.fr.cadastre.wms.WMSLayer;
     15import org.openstreetmap.josm.spi.preferences.Config;
    1616
    1717final class WMSDownloadAction {
     
    3737            if (existingWMSlayers.size() == 0)
    3838                return new MenuActionNewLocation().addNewLayer(existingWMSlayers);
    39             if (Main.pref.getBoolean("cadastrewms.autoFirstLayer", false)) {
     39            if (Config.getPref().getBoolean("cadastrewms.autoFirstLayer", false)) {
    4040                return existingWMSlayers.get(0);
    4141            } else {
    42                 JOptionPane.showMessageDialog(Main.parent,
     42                JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
    4343                        tr("More than one WMS layer present\nSelect one of them first, then retry"));
    4444            }
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/mapmode/Address.java

    r34223 r34458  
    4141import javax.swing.event.ChangeListener;
    4242
    43 import org.openstreetmap.josm.Main;
    4443import org.openstreetmap.josm.actions.mapmode.MapMode;
    4544import org.openstreetmap.josm.command.AddCommand;
     
    4847import org.openstreetmap.josm.command.Command;
    4948import org.openstreetmap.josm.command.SequenceCommand;
     49import org.openstreetmap.josm.data.UndoRedoHandler;
    5050import org.openstreetmap.josm.data.coor.EastNorth;
    5151import org.openstreetmap.josm.data.osm.DataSet;
    5252import org.openstreetmap.josm.data.osm.Node;
     53import org.openstreetmap.josm.data.osm.OsmDataManager;
    5354import org.openstreetmap.josm.data.osm.OsmPrimitive;
    5455import org.openstreetmap.josm.data.osm.Relation;
     
    5859import org.openstreetmap.josm.gui.MainApplication;
    5960import org.openstreetmap.josm.gui.MapView;
     61import org.openstreetmap.josm.spi.preferences.Config;
    6062import org.openstreetmap.josm.tools.GBC;
    6163import org.openstreetmap.josm.tools.ImageProvider;
     
    145147                addStreetNameOrRelation(currentMouseNode, cmds);
    146148                Command c = new SequenceCommand("Add node address", cmds);
    147                 Main.main.undoRedo.add(c);
     149                UndoRedoHandler.getInstance().add(c);
    148150                setNewSelection(currentMouseNode);
    149151            } else {
     
    159161                }
    160162                if (currentMouseNode.get(tagHouseStreet) != null) {
    161                     if (Main.pref.getBoolean("cadastrewms.addr.dontUseRelation", false)) {
     163                    if (Config.getPref().getBoolean("cadastrewms.addr.dontUseRelation", false)) {
    162164                        inputStreet.setText(currentMouseNode.get(tagHouseStreet));
    163165                        if (ctrl) {
     
    253255        Map<String, String> tags = new HashMap<>();
    254256        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));
    256258        addStreetNameOrRelation(osm, cmds);
    257259        try {
    258260            applyInputNumberChange();
    259261            Command c = new SequenceCommand("Add node address", cmds);
    260             Main.main.undoRedo.add(c);
     262            UndoRedoHandler.getInstance().add(c);
    261263            setNewSelection(osm);
    262264        } catch (NumberFormatException ex) {
     
    276278
    277279    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)) {
    279281            cmds.add(new ChangePropertyCommand(osm, tagHouseStreet, inputStreet.getText()));
    280282        } else if (selectedWay != null) {
     
    293295                newRel.addMember(new RelationMember(relationAddrStreetRole, selectedWay));
    294296                newRel.addMember(new RelationMember(relationMemberHouse, osm));
    295                 cmds.add(new AddCommand(Main.main.getEditDataSet(), newRel));
     297                cmds.add(new AddCommand(OsmDataManager.getInstance().getEditDataSet(), newRel));
    296298            }
    297299        }
     
    301303        // DrawAction.mouseReleased() but without key modifiers
    302304        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));
    304306        List<WaySegment> wss = MainApplication.getMap().mapView.getNearestWaySegments(e.getPoint(), OsmPrimitive::isSelectable);
    305307        Map<Way, List<Integer>> insertPoints = new HashMap<>();
     
    371373
    372374            int snapToIntersectionThreshold
    373             = Main.pref.getInt("edit.snap-intersection-threshold", 10);
     375            = Config.getPref().getInt("edit.snap-intersection-threshold", 10);
    374376
    375377            // only adjust to intersection if within snapToIntersectionThreshold pixel of mouse click; otherwise
     
    478480        p.add(minusOne, GBC.std().insets(10, 0, 10, 0));
    479481        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));
    481483        tagPolygon.addChangeListener(new ChangeListener() {
    482484            @Override
    483485            public void stateChanged(ChangeEvent arg0) {
    484                 Main.pref.putBoolean("cadastrewms.addr.onBuilding", tagPolygon.isSelected());
     486                Config.getPref().putBoolean("cadastrewms.addr.onBuilding", tagPolygon.isSelected());
    485487            }
    486488        });
     
    494496                JOptionPane.PLAIN_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION,
    495497                null, options, null);
    496         dialog = pane.createDialog(Main.parent, tr("Enter addresses"));
     498        dialog = pane.createDialog(MainApplication.getMainFrame(), tr("Enter addresses"));
    497499        dialog.setModal(false);
    498500        dialog.setAlwaysOnTop(true);
    499501        dialog.addComponentListener(new ComponentAdapter() {
    500502            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());
    502504            }
    503505
     
    516518            }
    517519        });
    518         String bounds = Main.pref.get("cadastrewms.addr.bounds", null);
     520        String bounds = Config.getPref().get("cadastrewms.addr.bounds", null);
    519521        if (bounds != null) {
    520522            String[] b = bounds.split(",");
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/upload/CheckSourceUploadHook.java

    r34223 r34458  
    1515import javax.swing.JTextField;
    1616
    17 import org.openstreetmap.josm.Main;
    1817import org.openstreetmap.josm.actions.upload.UploadHook;
    1918import org.openstreetmap.josm.command.ChangePropertyCommand;
    2019import org.openstreetmap.josm.data.APIDataSet;
     20import org.openstreetmap.josm.data.UndoRedoHandler;
    2121import org.openstreetmap.josm.data.osm.Node;
    2222import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2323import org.openstreetmap.josm.data.osm.Way;
     24import org.openstreetmap.josm.gui.MainApplication;
    2425import org.openstreetmap.josm.gui.PrimitiveRenderer;
    2526import org.openstreetmap.josm.plugins.fr.cadastre.CadastrePlugin;
     
    7879            l.setVisibleRowCount(l.getModel().getSize() < 6 ? l.getModel().getSize() : 10);
    7980            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?"),
    8182                   JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION;
    8283            if (bContinue)
    83                 Main.main.undoRedo.add(new ChangePropertyCommand(sel, "source", tf.getText()));
     84                UndoRedoHandler.getInstance().add(new ChangePropertyCommand(sel, "source", tf.getText()));
    8485        }
    8586    }
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/pci/EdigeoPciReader.java

    r34357 r34458  
    4545    private static final BiPredicate<CadastreDownloadData, OsmPrimitive> symbo = (x, p) -> !x.isDownloadSymbol();
    4646    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();
    4848    private static final BiPredicate<CadastreDownloadData, OsmPrimitive> addre = (x, p) -> !x.isDownloadAddress();
    4949    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();
    5151    private static final BiPredicate<CadastreDownloadData, OsmPrimitive> commu = (x, p) -> !x.isDownloadCommune();
    5252
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/preferences/CadastrePreferenceSetting.java

    r34208 r34458  
    2323import javax.swing.SwingConstants;
    2424
    25 import org.openstreetmap.josm.Main;
    2625import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
    2726import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    2827import org.openstreetmap.josm.plugins.fr.cadastre.CadastrePlugin;
    2928import org.openstreetmap.josm.plugins.fr.cadastre.wms.CacheControl;
     29import org.openstreetmap.josm.spi.preferences.Config;
    3030import org.openstreetmap.josm.tools.GBC;
    3131import org.openstreetmap.josm.tools.I18n;
     
    140140
    141141        // 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));
    143143        alterColors.setToolTipText(tr("Replace the original white background by the background color defined in JOSM preferences."));
    144144        cadastrewms.add(alterColors, GBC.eop().insets(0, 0, 0, 0));
    145145
    146146        // 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));
    148148        reversGrey.setToolTipText(
    149149                tr("Invert the original black and white colors (and all intermediate greys). Useful for texts on dark backgrounds."));
     
    157157            }
    158158        });
    159         transparency.setSelected(Main.pref.getBoolean("cadastrewms.backgroundTransparent", false));
     159        transparency.setSelected(Config.getPref().getBoolean("cadastrewms.backgroundTransparent", false));
    160160        transparency.setToolTipText(tr("Allows multiple layers stacking"));
    161161        cadastrewms.add(transparency, GBC.eop().insets(0, 0, 0, 0));
     
    166166        sliderTrans.setMajorTickSpacing(10);
    167167        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));
    169169        sliderTrans.setPaintTicks(true);
    170170        sliderTrans.setPaintLabels(false);
     
    173173
    174174        // 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));
    176176        drawBoundaries.setToolTipText(tr("Draw a rectangle around downloaded data from WMS server."));
    177177        cadastrewms.add(drawBoundaries, GBC.eop().insets(0, 0, 0, 5));
     
    187187        bgResolution.add(grabRes2);
    188188        bgResolution.add(grabRes3);
    189         String currentResolution = Main.pref.get("cadastrewms.resolution", "high");
     189        String currentResolution = Config.getPref().get("cadastrewms.resolution", "high");
    190190        if (currentResolution.equals("high"))
    191191            grabRes1.setSelected(true);
     
    204204        imageInterpolationMethod.addItem(tr("Bilinear (fast)"));
    205205        imageInterpolationMethod.addItem(tr("Bicubic (slow)"));
    206         String savedImageInterpolationMethod = Main.pref.get("cadastrewms.imageInterpolation", "standard");
     206        String savedImageInterpolationMethod = Config.getPref().get("cadastrewms.imageInterpolation", "standard");
    207207        if (savedImageInterpolationMethod.equals("bilinear"))
    208208            imageInterpolationMethod.setSelectedIndex(1);
     
    247247        bgGrabMultiplier.add(grabMultiplier3);
    248248        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);
    250250        if (currentScale.equals(Scale.X1.value))
    251251            grabMultiplier1.setSelected(true);
     
    269269        JLabel jLabelLayers = new JLabel(tr("Layers:"));
    270270        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));
    272272        layerLS3.setToolTipText(tr("Sea, rivers, swimming pools."));
    273273        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));
    275275        layerLS2.setToolTipText(tr("Buildings, covers, underground constructions."));
    276276        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));
    278278        layerLS1.setToolTipText(tr("Symbols like cristian cross."));
    279279        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));
    281281        layerParcel.setToolTipText(tr("Parcels."));
    282282        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));
    284284        layerLabel.setToolTipText(tr("Parcels numbers, street names."));
    285285        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));
    287287        layerNumero.setToolTipText(tr("Address, houses numbers."));
    288288        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));
    290290        layerLieudit.setToolTipText(tr("Locality, hamlet, place."));
    291291        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));
    293293        layerSection.setToolTipText(tr("Cadastral sections and subsections."));
    294294        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));
    296296        layerCommune.setToolTipText(tr("Municipality administrative borders."));
    297297        cadastrewms.add(layerCommune, GBC.eop().insets(5, 0, 5, 0));
     
    301301
    302302        // 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);
    304304        JLabel jLabelRasterDivider = new JLabel(tr("Raster images grab multiplier:"));
    305305        rasterDivider.setText(savedRasterDivider);
     
    308308        cadastrewms.add(rasterDivider, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 5, 200, 5));
    309309        // 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));
    311311        disableImageCropping.setToolTipText(tr("Disable image cropping during georeferencing."));
    312312        cadastrewms.add(disableImageCropping, GBC.std().insets(0, 0, 10, 0));
    313313        // 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));
    315315        enableTableauAssemblage.setToolTipText(tr("Add the \"Tableau(x) d''assemblage\" in the list of cadastre sheets to grab."));
    316316        cadastrewms.add(enableTableauAssemblage, GBC.eop().insets(0, 0, 0, 0));
    317317        // 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));
    319319        simplify2BitsColors.setToolTipText(tr("Replace greyscale by white color (smaller files and memory usage)."));
    320320        cadastrewms.add(simplify2BitsColors, GBC.eop().insets(0, 0, 0, 0));
     
    348348            }
    349349        });
    350         enableCache.setSelected(Main.pref.getBoolean("cadastrewms.enableCaching", true));
     350        enableCache.setSelected(Config.getPref().getBoolean("cadastrewms.enableCaching", true));
    351351        enableCache.setToolTipText(tr("Allows an automatic caching"));
    352352        cadastrewms.add(enableCache, GBC.eop().insets(0, 0, 0, 0));
     
    363363
    364364        // 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));
    366366        autoFirstLayer.setToolTipText(tr("Automatically selects the first WMS layer if multiple layers exist when grabbing."));
    367367        cadastrewms.add(autoFirstLayer, GBC.eop().insets(0, 0, 0, 0));
     
    371371
    372372        // 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));
    374374        dontUseRelation.setToolTipText(tr("Enable this to use the tag \"add:street\" on nodes."));
    375375        cadastrewms.add(dontUseRelation, GBC.eop().insets(0, 0, 0, 0));
     
    384384    @Override
    385385    public boolean ok() {
    386         Main.pref.put("cadastrewms.source", sourcing.getText());
     386        Config.getPref().put("cadastrewms.source", sourcing.getText());
    387387        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());
    393393        if (grabRes1.isSelected())
    394             Main.pref.put("cadastrewms.resolution", "high");
     394            Config.getPref().put("cadastrewms.resolution", "high");
    395395        else if (grabRes2.isSelected())
    396             Main.pref.put("cadastrewms.resolution", "medium");
     396            Config.getPref().put("cadastrewms.resolution", "medium");
    397397        else if (grabRes3.isSelected())
    398             Main.pref.put("cadastrewms.resolution", "low");
     398            Config.getPref().put("cadastrewms.resolution", "low");
    399399        if (imageInterpolationMethod.getSelectedIndex() == 2)
    400             Main.pref.put("cadastrewms.imageInterpolation", "bicubic");
     400            Config.getPref().put("cadastrewms.imageInterpolation", "bicubic");
    401401        else if (imageInterpolationMethod.getSelectedIndex() == 1)
    402             Main.pref.put("cadastrewms.imageInterpolation", "bilinear");
     402            Config.getPref().put("cadastrewms.imageInterpolation", "bilinear");
    403403        else
    404             Main.pref.put("cadastrewms.imageInterpolation", "standard");
     404            Config.getPref().put("cadastrewms.imageInterpolation", "standard");
    405405        if (grabMultiplier1.isSelected())
    406             Main.pref.put("cadastrewms.scale", Scale.X1.toString());
     406            Config.getPref().put("cadastrewms.scale", Scale.X1.toString());
    407407        else if (grabMultiplier2.isSelected())
    408             Main.pref.put("cadastrewms.scale", Scale.X2.toString());
     408            Config.getPref().put("cadastrewms.scale", Scale.X2.toString());
    409409        else if (grabMultiplier3.isSelected())
    410             Main.pref.put("cadastrewms.scale", Scale.X3.toString());
     410            Config.getPref().put("cadastrewms.scale", Scale.X3.toString());
    411411        else {
    412             Main.pref.put("cadastrewms.scale", Scale.SQUARE_100M.toString());
     412            Config.getPref().put("cadastrewms.scale", Scale.SQUARE_100M.toString());
    413413            try {
    414414                int squareSize = Integer.parseInt(grabMultiplier4Size.getText());
    415415                if (squareSize >= 25 && squareSize <= 1000)
    416                     Main.pref.put("cadastrewms.squareSize", grabMultiplier4Size.getText());
     416                    Config.getPref().put("cadastrewms.squareSize", grabMultiplier4Size.getText());
    417417            } catch (NumberFormatException e) {
    418418                Logging.debug(e);
    419419            }
    420420        }
    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());
    430430        try {
    431431            int i = Integer.parseInt(rasterDivider.getText());
    432432            if (i > 0 && i < 13)
    433                 Main.pref.put("cadastrewms.rasterDivider", String.valueOf(i));
     433                Config.getPref().put("cadastrewms.rasterDivider", String.valueOf(i));
    434434        } catch (NumberFormatException e) {
    435435            Logging.debug(e);
    436436        }
    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());
    445445
    446446        // spread data into objects instead of restarting the application
    447447        try {
    448448            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));
    450450        } catch (NumberFormatException e) {
    451451            Logging.debug(e);
    452452        }
    453         Main.pref.putBoolean("cadastrewms.autoFirstLayer", autoFirstLayer.isSelected());
     453        Config.getPref().putBoolean("cadastrewms.autoFirstLayer", autoFirstLayer.isSelected());
    454454        CacheControl.cacheEnabled = enableCache.isSelected();
    455         Main.pref.putBoolean("cadastrewms.addr.dontUseRelation", dontUseRelation.isSelected());
     455        Config.getPref().putBoolean("cadastrewms.addr.dontUseRelation", dontUseRelation.isSelected());
    456456        CadastrePlugin.refreshConfiguration();
    457457        CadastrePlugin.refreshMenu();
     
    462462    private int getNumber(String pref_parameter, int def_value) {
    463463        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)));
    465465        } catch (NumberFormatException e) {
    466466            return def_value;
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/CacheControl.java

    r33640 r34458  
    2020import javax.swing.JOptionPane;
    2121
    22 import org.openstreetmap.josm.Main;
     22import org.openstreetmap.josm.gui.MainApplication;
    2323import org.openstreetmap.josm.gui.util.GuiHelper;
    2424import org.openstreetmap.josm.plugins.fr.cadastre.CadastrePlugin;
    2525import org.openstreetmap.josm.plugins.fr.cadastre.preferences.CadastrePreferenceSetting;
     26import org.openstreetmap.josm.spi.preferences.Config;
    2627import org.openstreetmap.josm.tools.Logging;
    2728
     
    6970
    7071    public CacheControl(WMSLayer wmsLayer) {
    71         cacheEnabled = Main.pref.getBoolean("cadastrewms.enableCaching", true);
     72        cacheEnabled = Config.getPref().getBoolean("cadastrewms.enableCaching", true);
    7273        this.wmsLayer = wmsLayer;
    7374        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)));
    7577        } catch (NumberFormatException e) {
    7678            cacheSize = CadastrePreferenceSetting.DEFAULT_CACHE_SIZE;
     
    121123                            JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null);
    122124                    // 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"));
    124126                    CadastrePlugin.prepareDialog(dialog);
    125127                    dialog.setVisible(true);
     
    160162        } catch (IOException | ClassNotFoundException ex) {
    161163            Logging.error(ex);
    162             GuiHelper.runInEDTAndWait(() -> JOptionPane.showMessageDialog(Main.parent,
     164            GuiHelper.runInEDTAndWait(() -> JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
    163165                    tr("Error loading file.\nProbably an old version of the cache file."),
    164166                    tr("Error"), JOptionPane.ERROR_MESSAGE));
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/CadastreInterface.java

    r34223 r34458  
    2424import javax.swing.JPanel;
    2525
    26 import org.openstreetmap.josm.Main;
    2726import org.openstreetmap.josm.data.coor.EastNorth;
    2827import org.openstreetmap.josm.data.validation.util.Entities;
     
    3231import org.openstreetmap.josm.io.OsmTransferException;
    3332import org.openstreetmap.josm.plugins.fr.cadastre.CadastrePlugin;
     33import org.openstreetmap.josm.spi.preferences.Config;
    3434import org.openstreetmap.josm.tools.GBC;
    3535import org.openstreetmap.josm.tools.HttpClient;
     
    109109            Logging.error(e);
    110110            GuiHelper.runInEDT(() ->
    111                 JOptionPane.showMessageDialog(Main.parent,
     111                JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
    112112                    tr("Town/city {0} not found or not available\n" +
    113113                            "or action canceled", wmsLayer.getLocation())));
     
    221221                        wmsLayer.setCodeCommune(newCodeCommune);
    222222                        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);
    225225                    }
    226226                    checkLayerDuplicates(wmsLayer);
     
    393393        // get "Tableau d'assemblage"
    394394        String inputTA = input;
    395         if (Main.pref.getBoolean("cadastrewms.useTA", false)) {
     395        if (Config.getPref().getBoolean("cadastrewms.useTA", false)) {
    396396            while (inputTA.indexOf(C_TA_IMAGE_LINK_START) != -1) {
    397397                inputTA = inputTA.substring(inputTA.indexOf(C_TA_IMAGE_LINK_START) + C_TA_IMAGE_LINK_START.length()
     
    427427            JOptionPane pane = new JOptionPane(p, JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null);
    428428            // 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"));
    430430            CadastrePlugin.prepareDialog(dialog);
    431431            dialog.setVisible(true);
     
    448448            JOptionPane pane = new JOptionPane(p, JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null);
    449449            // 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"));
    451451            CadastrePlugin.prepareDialog(dialog);
    452452            dialog.setVisible(true);
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/DownloadSVGBuilding.java

    r33640 r34458  
    2020import javax.swing.JOptionPane;
    2121
    22 import org.openstreetmap.josm.Main;
    2322import org.openstreetmap.josm.command.AddCommand;
    2423import org.openstreetmap.josm.command.Command;
    2524import org.openstreetmap.josm.command.SequenceCommand;
     25import org.openstreetmap.josm.data.UndoRedoHandler;
    2626import org.openstreetmap.josm.data.coor.EastNorth;
    2727import org.openstreetmap.josm.data.osm.DataSet;
    2828import org.openstreetmap.josm.data.osm.Node;
     29import org.openstreetmap.josm.data.osm.OsmDataManager;
    2930import org.openstreetmap.josm.data.osm.Way;
     31import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3032import org.openstreetmap.josm.gui.MainApplication;
    3133import org.openstreetmap.josm.gui.MapView;
     
    118120            Way wayToAdd = new Way();
    119121            for (EastNorth eastNorth : path) {
    120                 Node nodeToAdd = new Node(Main.getProjection().eastNorth2latlon(eastNorth));
     122                Node nodeToAdd = new Node(ProjectionRegistry.getProjection().eastNorth2latlon(eastNorth));
    121123                // check if new node is not already created by another new path
    122124                Node nearestNewNode = checkNearestNode(nodeToAdd, svgDataSet.getNodes());
     
    157159        }
    158160
    159         DataSet ds = Main.main.getEditDataSet();
     161        DataSet ds = OsmDataManager.getInstance().getEditDataSet();
    160162        Collection<Command> cmds = new LinkedList<>();
    161163        for (Node node : svgDataSet.getNodes()) {
     
    167169                cmds.add(new AddCommand(ds, way));
    168170        }
    169         Main.main.undoRedo.add(new SequenceCommand(tr("Create buildings"), cmds));
     171        UndoRedoHandler.getInstance().add(new SequenceCommand(tr("Create buildings"), cmds));
    170172        MainApplication.getMap().repaint();
    171173    }
     
    267269        if ((currentView.max.east() - currentView.min.east()) > 1000 ||
    268270                (currentView.max.north() - currentView.min.north() > 1000)) {
    269             JOptionPane.showMessageDialog(Main.parent,
     271            JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
    270272                    tr("To avoid cadastre WMS overload,\nbuilding import size is limited to 1 km2 max."));
    271273            return;
    272274        }
    273275        if (CadastrePlugin.autoSourcing == false) {
    274             JOptionPane.showMessageDialog(Main.parent,
     276            JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
    275277                    tr("Please, enable auto-sourcing and check cadastre millesime."));
    276278            return;
     
    278280        MainApplication.worker.execute(new DownloadSVGBuilding(wmsLayer));
    279281        if (errorMessage != null)
    280             JOptionPane.showMessageDialog(Main.parent, errorMessage);
     282            JOptionPane.showMessageDialog(MainApplication.getMainFrame(), errorMessage);
    281283    }
    282284
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/DownloadSVGTask.java

    r33640 r34458  
    2222import javax.swing.JOptionPane;
    2323
    24 import org.openstreetmap.josm.Main;
    2524import org.openstreetmap.josm.command.AddCommand;
    2625import org.openstreetmap.josm.command.Command;
    2726import org.openstreetmap.josm.command.SequenceCommand;
     27import org.openstreetmap.josm.data.UndoRedoHandler;
    2828import org.openstreetmap.josm.data.coor.EastNorth;
    2929import org.openstreetmap.josm.data.osm.DataSet;
    3030import org.openstreetmap.josm.data.osm.Node;
     31import org.openstreetmap.josm.data.osm.OsmDataManager;
    3132import org.openstreetmap.josm.data.osm.Way;
     33import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3234import org.openstreetmap.josm.gui.MainApplication;
    3335import org.openstreetmap.josm.gui.PleaseWaitRunnable;
     
    123125        List<Node> nodeList = new ArrayList<>();
    124126        for (EastNorth eastNorth : eastNorths.get(bestPath)) {
    125             nodeList.add(new Node(Main.getProjection().eastNorth2latlon(eastNorth)));
     127            nodeList.add(new Node(ProjectionRegistry.getProjection().eastNorth2latlon(eastNorth)));
    126128        }
    127129        Way wayToAdd = new Way();
    128         DataSet ds = Main.main.getEditDataSet();
     130        DataSet ds = OsmDataManager.getInstance().getEditDataSet();
    129131        Collection<Command> cmds = new LinkedList<>();
    130132        for (Node node : nodeList) {
     
    135137
    136138        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));
    138140        MainApplication.getMap().repaint();
    139141    }
     
    215217    public static void download(WMSLayer wmsLayer) {
    216218        if (!CadastrePlugin.autoSourcing) {
    217             JOptionPane.showMessageDialog(Main.parent,
     219            JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
    218220                    tr("Please, enable auto-sourcing and check cadastre millesime."));
    219221            return;
     
    221223        MainApplication.worker.execute(new DownloadSVGTask(wmsLayer));
    222224        if (errorMessage != null)
    223             JOptionPane.showMessageDialog(Main.parent, errorMessage);
     225            JOptionPane.showMessageDialog(MainApplication.getMainFrame(), errorMessage);
    224226    }
    225227}
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/DownloadWMSPlanImage.java

    r33640 r34458  
    1010import javax.swing.JOptionPane;
    1111
    12 import org.openstreetmap.josm.Main;
    1312import org.openstreetmap.josm.data.Bounds;
    1413import org.openstreetmap.josm.gui.MainApplication;
     
    4039                        JOptionPane pane = new JOptionPane(tr("Image already loaded"), JOptionPane.INFORMATION_MESSAGE);
    4140                        // 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(), "");
    4342                        CadastrePlugin.prepareDialog(dialog);
    4443                        dialog.setVisible(true);
     
    7069                            }
    7170                        } else {
    72                             /*JOptionPane.showMessageDialog(Main.parent,tr("Municipality vectorized !\n"+
     71                            /*JOptionPane.showMessageDialog(MainApplication.getMainFrame(),tr("Municipality vectorized !\n"+
    7372                                    "Use the normal Cadastre Grab menu."));*/
    7473                            JOptionPane pane = new JOptionPane(
     
    7675                                    JOptionPane.INFORMATION_MESSAGE);
    7776                            // 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(), "");
    7978                            CadastrePlugin.prepareDialog(dialog);
    8079                            dialog.setVisible(true);
     
    114113        task = MainApplication.worker.submit(t, t);
    115114        if (errorMessage != null)
    116             JOptionPane.showMessageDialog(Main.parent, errorMessage);
     115            JOptionPane.showMessageDialog(MainApplication.getMainFrame(), errorMessage);
    117116    }
    118117
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/DownloadWMSVectorImage.java

    r33682 r34458  
    88import javax.swing.JOptionPane;
    99
    10 import org.openstreetmap.josm.Main;
    1110import org.openstreetmap.josm.data.Bounds;
    1211import org.openstreetmap.josm.gui.MainApplication;
     
    4645                        // set raster image commune bounding box based on current view (before adjustment)
    4746                        GuiHelper.runInEDT(() ->
    48                             JOptionPane.showMessageDialog(Main.parent,
     47                            JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
    4948                                tr("This commune is not vectorized.\nPlease use the other menu entry to georeference a \"Plan image\"")));
    5049                        MainApplication.getLayerManager().removeLayer(wmsLayer);
     
    8988        MainApplication.worker.execute(new DownloadWMSVectorImage(wmsLayer, bounds));
    9089        if (errorMessage != null)
    91             JOptionPane.showMessageDialog(Main.parent, errorMessage);
     90            JOptionPane.showMessageDialog(MainApplication.getMainFrame(), errorMessage);
    9291    }
    9392}
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/EastNorthBound.java

    r33638 r34458  
    44import java.io.Serializable;
    55
    6 import org.openstreetmap.josm.Main;
    76import org.openstreetmap.josm.data.Bounds;
    87import org.openstreetmap.josm.data.coor.EastNorth;
     8import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    99
    1010public class EastNorthBound implements Serializable {
     
    3333
    3434    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));
    3636    }
    3737
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/RasterImageGeoreferencer.java

    r33682 r34458  
    1616import javax.swing.JTextField;
    1717
    18 import org.openstreetmap.josm.Main;
    1918import org.openstreetmap.josm.data.coor.EastNorth;
     19import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2020import org.openstreetmap.josm.gui.MainApplication;
    2121import org.openstreetmap.josm.gui.util.GuiHelper;
     22import org.openstreetmap.josm.spi.preferences.Config;
    2223import org.openstreetmap.josm.tools.GBC;
    2324import org.openstreetmap.josm.tools.Logging;
     
    5657       mode = cGetCorners;
    5758       countMouseClicked = 0;
    58        initialClickDelay = Main.pref.getInt("cadastrewms.georef-click-delay", 200);
     59       initialClickDelay = Config.getPref().getInt("cadastrewms.georef-click-delay", 200);
    5960       mouseClickedTime = System.currentTimeMillis();
    6061       Object[] options = {"OK", "Cancel"};
     
    8081      countMouseClicked = 0;
    8182      mode = cGetLambertCrosspieces;
    82       initialClickDelay = Main.pref.getInt("cadastrewms.georef-click-delay", 200);
     83      initialClickDelay = Config.getPref().getInt("cadastrewms.georef-click-delay", 200);
    8384      mouseClickedTime = System.currentTimeMillis();
    8485      Object[] options = {"OK", "Cancel"};
     
    110111          return;
    111112      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()));
    113114      Logging.info("click:"+countMouseClicked+" ,"+ea+", mode:"+mode);
    114115      if (clickOnTheMap) {
     
    179180     // handle an NPE case I'm not able to reproduce
    180181     if (org1 == null || org2 == null || dst1 == null || dst2 == null) {
    181          JOptionPane.showMessageDialog(Main.parent,
     182         JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
    182183                 tr("Ooops. I failed to catch all coordinates\n"+
    183184                    "correctly. Retry please."));
     
    238239     else
    239240         number = "second";
    240      JDialog dialog = pane.createDialog(Main.parent, tr(
     241     JDialog dialog = pane.createDialog(MainApplication.getMainFrame(), tr(
    241242             "Set {0} Lambert coordinates", number));
    242243     dialog.setModal(false);
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/RasterImageModifier.java

    r34115 r34458  
    77import java.awt.image.IndexColorModel;
    88
    9 import org.openstreetmap.josm.Main;
     9import org.openstreetmap.josm.spi.preferences.Config;
    1010
    1111public class RasterImageModifier extends ImageModifier {
     
    1919    public RasterImageModifier(BufferedImage bi) {
    2020        setBufferedImage(bi);
    21         transparencyEnabled = Main.pref.getBoolean("cadastrewms.backgroundTransparent");
     21        transparencyEnabled = Config.getPref().getBoolean("cadastrewms.backgroundTransparent");
    2222        if (transparencyEnabled)
    2323            makeTransparent();
    24         if (Main.pref.getBoolean("cadastrewms.invertGrey"))
     24        if (Config.getPref().getBoolean("cadastrewms.invertGrey"))
    2525            invertGrey();
    2626    }
     
    6565            BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    6666            // 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);
    6868            for (int y = 0; y < height; y++) {
    6969                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  
    88import java.awt.image.WritableRaster;
    99
    10 import org.openstreetmap.josm.Main;
     10import org.openstreetmap.josm.spi.preferences.Config;
    1111import org.openstreetmap.josm.tools.ColorHelper;
    1212
     
    2525    public VectorImageModifier(BufferedImage bi, boolean monocolor) {
    2626        setBufferedImage(bi);
    27         if (Main.pref.getBoolean("cadastrewms.backgroundTransparent"))
     27        if (Config.getPref().getBoolean("cadastrewms.backgroundTransparent"))
    2828            makeTransparent();
    29         else if (Main.pref.getBoolean("cadastrewms.alterColors"))
     29        else if (Config.getPref().getBoolean("cadastrewms.alterColors"))
    3030            replaceBackground();
    31         if (Main.pref.getBoolean("cadastrewms.invertGrey"))
     31        if (Config.getPref().getBoolean("cadastrewms.invertGrey"))
    3232            invertGrey();
    3333        if (monocolor)
     
    4141        int w = bufferedImage.getWidth();
    4242        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();
    4444        for (int x = 0; x < w; x++) {
    4545            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  
    22package org.openstreetmap.josm.plugins.fr.cadastre.wms;
    33
     4/**
     5 * Exception thrown in case of WMS error.
     6 */
    47public class WMSException extends Exception {
    5     private String message;
    68    private static final long serialVersionUID = 1L;
    79
     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     */
    818    public WMSException(String message) {
    9         super();
    10         this.message = message;
    11     }
    12 
    13     @Override
    14     public String getMessage() {
    15         return message;
     19        super(message);
    1620    }
    1721}
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/WMSLayer.java

    r34115 r34458  
    3131import javax.swing.JOptionPane;
    3232
    33 import org.openstreetmap.josm.Main;
    3433import org.openstreetmap.josm.actions.JosmAction;
    3534import org.openstreetmap.josm.data.Bounds;
    3635import org.openstreetmap.josm.data.coor.EastNorth;
    3736import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
     37import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3838import org.openstreetmap.josm.gui.MainApplication;
    3939import org.openstreetmap.josm.gui.MapView;
     
    4949import org.openstreetmap.josm.plugins.fr.cadastre.actions.mapmode.WMSAdjustAction;
    5050import org.openstreetmap.josm.plugins.fr.cadastre.preferences.CadastrePreferenceSetting;
     51import org.openstreetmap.josm.spi.preferences.Config;
    5152import org.openstreetmap.josm.tools.Logging;
    5253
     
    175176        } else {
    176177            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)));
    179181            } else
    180182                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)));
    182184        }
    183185        grabThread.addImages(dividedBbox);
     
    195197     */
    196198    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());
    199201        double minEast = lambertMin.east()+deltaEast;
    200202        double minNorth = lambertMin.north()+deltaNorth;
     
    212214            // divide to fixed size squares
    213215            // 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)));
    215218            lambertMin = lambertMin.add(-minEast % c, -minNorth % c);
    216219            lambertMax = lambertMax.add(c - lambertMax.east() % c, c - lambertMax.north() % c);
     
    289292            Object savedInterpolation = g.getRenderingHint(RenderingHints.KEY_INTERPOLATION);
    290293            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");
    292295            if (interpolation.equals("bilinear"))
    293296                g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
     
    362365        GeorefImage georefImage =
    363366            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);
    366369        for (GeorefImage img : images) {
    367370            if (img.overlap(georefImage))
     
    438441     */
    439442    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());
    443446        double rasterSizeX = communeBBox.max.getX() - communeBBox.min.getX();
    444447        double rasterSizeY = communeBBox.max.getY() - communeBBox.min.getY();
     
    483486        currentFormat = ois.readInt();;
    484487        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.",
    486490                    currentFormat, this.serializeFormatVersion), tr("Cache Format Error"), JOptionPane.ERROR_MESSAGE);
    487491            return false;
     
    509513        this.communeBBox = new EastNorthBound(new EastNorth(minX, minY), new EastNorth(maxX, maxY));
    510514        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 "+
    512516                    "incompatible with current Lambert zone {1}",
    513517                    this.lambertZone+1, currentLambertZone), tr("Cache Lambert Zone Error"), JOptionPane.ERROR_MESSAGE);
     
    668672
    669673    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");
    671675        if (!crosspieces.equals("0")) {
    672676            int modulo = 25;
Note: See TracChangeset for help on using the changeset viewer.