Ignore:
Timestamp:
2017-09-19T23:37:58+02:00 (7 years ago)
Author:
donvip
Message:

update to JOSM 12840

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

Legend:

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

    r33639 r33640  
    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="11713"/>
     6    <property name="plugin.main.version" value="12840"/>
    77   
    88    <!-- Configure these properties (replace "..." accordingly).
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/CadastrePlugin.java

    r33639 r33640  
    2828import org.openstreetmap.josm.data.projection.Projection;
    2929import org.openstreetmap.josm.gui.IconToggleButton;
     30import org.openstreetmap.josm.gui.MainApplication;
    3031import org.openstreetmap.josm.gui.MainMenu;
    3132import org.openstreetmap.josm.gui.MapFrame;
     
    5051import org.openstreetmap.josm.plugins.fr.cadastre.session.CadastreSessionImporter;
    5152import org.openstreetmap.josm.plugins.fr.cadastre.wms.WMSLayer;
     53import org.openstreetmap.josm.tools.Logging;
    5254
    5355/**
     
    213215    public CadastrePlugin(PluginInformation info) {
    214216        super(info);
    215         Main.info("Pluging cadastre-fr v"+VERSION+" started...");
     217        Logging.info("Pluging cadastre-fr v"+VERSION+" started...");
    216218        initCacheDir();
    217219
     
    226228    private static void initCacheDir() {
    227229        if (Main.pref.get("cadastrewms.cacheDir").isEmpty()) {
    228             cacheDir = new File(Main.pref.getCacheDirectory(), "cadastrewms").getAbsolutePath();
     230            cacheDir = new File(Main.pref.getCacheDirectory(true), "cadastrewms").getAbsolutePath();
    229231        } else {
    230232            cacheDir = Main.pref.get("cadastrewms.cacheDir");
     
    232234        if (cacheDir.charAt(cacheDir.length()-1) != File.separatorChar)
    233235            cacheDir += File.separatorChar;
    234         Main.info("current cache directory: "+cacheDir);
     236        Logging.info("current cache directory: "+cacheDir);
    235237    }
    236238
    237239    public static void refreshMenu() {
    238         MainMenu menu = Main.main.menu;
     240        MainMenu menu = MainApplication.getMenu();
    239241
    240242        if (cadastreJMenu == null) {
     
    253255                @Override
    254256                public void actionPerformed(ActionEvent ev) {
    255                     Main.pref.put("cadastrewms.autosourcing", menuSource.isSelected());
     257                    Main.pref.putBoolean("cadastrewms.autosourcing", menuSource.isSelected());
    256258                    autoSourcing = menuSource.isSelected();
    257259                }
     
    360362            JOptionPane.showMessageDialog(Main.parent, tr("Please enable at least two WMS layers in the cadastre-fr "
    361363                    + "plugin configuration.\nLayers ''Building'' and ''Parcel'' added by default."));
    362             Main.pref.put("cadastrewms.layerBuilding", true);
    363             Main.pref.put("cadastrewms.layerParcel", true);
     364            Main.pref.putBoolean("cadastrewms.layerBuilding", true);
     365            Main.pref.putBoolean("cadastrewms.layerParcel", true);
    364366            grabLayers += LAYER_BULDINGS + "," + LAYER_PARCELS;
    365367            grabStyles += STYLE_BUILDING + "," + STYLE_PARCELS;
     
    391393            if (oldFrame == null && newFrame != null) {
    392394                setEnabledAll(true);
    393                 Main.map.addMapMode(new IconToggleButton(new WMSAdjustAction()));
    394                 Main.map.addMapMode(new IconToggleButton(new Address()));
     395                MainApplication.getMap().addMapMode(new IconToggleButton(new WMSAdjustAction()));
     396                MainApplication.getMap().addMapMode(new IconToggleButton(new Address()));
    395397            } else if (oldFrame != null && newFrame == null) {
    396398                setEnabledAll(false);
     
    450452            Thread.sleep(milliseconds);
    451453        } catch (InterruptedException e) {
    452             Main.debug(e);
     454            Logging.debug(e);
    453455        }
    454456    }
     
    461463                dialog.setAlwaysOnTop(true);
    462464            } catch (SecurityException e) {
    463                 Main.warn(tr("Warning: failed to put option pane dialog always on top. Exception was: {0}", e.toString()));
     465                Logging.warn(tr("Warning: failed to put option pane dialog always on top. Exception was: {0}", e.toString()));
    464466            }
    465467        }
     
    476478     */
    477479    public static void addWMSLayer(WMSLayer wmsLayer) {
    478         if (Main.map != null && Main.map.mapView != null) {
    479             int wmsNewLayerPos = Main.getLayerManager().getLayers().size();
    480             for (Layer l : Main.getLayerManager().getLayersOfType(WMSLayer.class)) {
    481                 int wmsPos = Main.getLayerManager().getLayers().indexOf(l);
     480        if (MainApplication.isDisplayingMapView()) {
     481            int wmsNewLayerPos = MainApplication.getLayerManager().getLayers().size();
     482            for (Layer l : MainApplication.getLayerManager().getLayersOfType(WMSLayer.class)) {
     483                int wmsPos = MainApplication.getLayerManager().getLayers().indexOf(l);
    482484                if (wmsPos < wmsNewLayerPos) wmsNewLayerPos = wmsPos;
    483485            }
    484             Main.getLayerManager().addLayer(wmsLayer);
     486            MainApplication.getLayerManager().addLayer(wmsLayer);
    485487            // Move the layer to its new position
    486             Main.map.mapView.moveLayer(wmsLayer, wmsNewLayerPos);
     488            MainApplication.getMap().mapView.moveLayer(wmsLayer, wmsNewLayerPos);
    487489        } else
    488             Main.getLayerManager().addLayer(wmsLayer);
     490            MainApplication.getLayerManager().addLayer(wmsLayer);
    489491    }
    490492
     
    499501            year = Integer.decode(srcYear);
    500502        } catch (NumberFormatException e) {
    501             Main.debug(e);
     503            Logging.debug(e);
    502504        }
    503505        if (srcYear.equals("AAAA") || (year != null && year < currentYear)) {
    504             Main.info("Replace source year "+srcYear+" by current year "+currentYear);
     506            Logging.info("Replace source year "+srcYear+" by current year "+currentYear);
    505507            src = src.substring(0, src.lastIndexOf(" ")+1)+currentYear;
    506508            Main.pref.put("cadastrewms.source", src);
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionGrab.java

    r33638 r33640  
    88import java.awt.event.KeyEvent;
    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.CadastrePlugin;
    1313import org.openstreetmap.josm.plugins.fr.cadastre.wms.DownloadWMSVectorImage;
     
    3333    @Override
    3434    public void actionPerformed(ActionEvent e) {
    35         if (Main.map != null) {
     35        if (MainApplication.getMap() != null) {
    3636            if (CadastrePlugin.isCadastreProjection()) {
    3737                WMSLayer wmsLayer = WMSDownloadAction.getLayer();
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionGrabPlanImage.java

    r33638 r33640  
    1212import org.openstreetmap.josm.Main;
    1313import org.openstreetmap.josm.actions.JosmAction;
     14import org.openstreetmap.josm.gui.MainApplication;
    1415import org.openstreetmap.josm.plugins.fr.cadastre.CadastrePlugin;
    1516import org.openstreetmap.josm.plugins.fr.cadastre.wms.DownloadWMSPlanImage;
     
    4041    @Override
    4142    protected void updateEnabledState() {
    42         if (wmsLayer == null || Main.map == null || Main.map.mapView == null) return;
     43        if (wmsLayer == null || !MainApplication.isDisplayingMapView()) return;
    4344        if (!rasterImageGeoreferencer.isRunning()) return;
    44         if (Main.getLayerManager().containsLayer(wmsLayer))
     45        if (MainApplication.getLayerManager().containsLayer(wmsLayer))
    4546            return;
    4647        JOptionPane.showMessageDialog(Main.parent, tr("Georeferencing interrupted"));
     
    5051    @Override
    5152    public void actionPerformed(ActionEvent ae) {
    52         if (Main.map != null) {
     53        if (MainApplication.getMap() != null) {
    5354            if (CadastrePlugin.isCadastreProjection()) {
    5455                wmsLayer = new MenuActionNewLocation().addNewLayer(new ArrayList<WMSLayer>());
     
    5758                downloadWMSPlanImage.download(wmsLayer);
    5859                // download sub-images of the cadastre scan and join them into one single
    59                 Main.worker.execute(this);
     60                MainApplication.worker.execute(this);
    6061            } else {
    6162                CadastrePlugin.askToChangeProjection();
     
    6970        boolean loadedFromCache = downloadWMSPlanImage.waitFinished();
    7071        if (loadedFromCache) {
    71             Main.map.repaint();
     72            wmsLayer.invalidate();
    7273        } else if (wmsLayer.getImages().size() == 0) {
    7374            // action canceled or image loaded from cache (and already georeferenced)
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionLoadFromCache.java

    r33638 r33640  
    1313import org.openstreetmap.josm.Main;
    1414import org.openstreetmap.josm.actions.JosmAction;
     15import org.openstreetmap.josm.gui.MainApplication;
    1516import org.openstreetmap.josm.gui.layer.Layer;
    1617import org.openstreetmap.josm.plugins.fr.cadastre.CadastrePlugin;
     
    2021import org.openstreetmap.josm.plugins.fr.cadastre.wms.CacheFileUTM20NFilter;
    2122import org.openstreetmap.josm.plugins.fr.cadastre.wms.WMSLayer;
     23import org.openstreetmap.josm.tools.Logging;
    2224
    2325public class MenuActionLoadFromCache extends JosmAction {
     
    7072                                continue nextFile;
    7173                            } else
    72                                 Main.info("Load cache " + filename);
     74                                Logging.info("Load cache " + filename);
    7375                        }
    7476                    } catch (NumberFormatException ex) {
    75                         JOptionPane.showMessageDialog(Main.parent, tr("Selected file {0} is not a cache file from this plugin (invalid extension)", filename), tr("Error"), JOptionPane.ERROR_MESSAGE);
     77                        JOptionPane.showMessageDialog(Main.parent,
     78                                tr("Selected file {0} is not a cache file from this plugin (invalid extension)", filename),
     79                                tr("Error"), JOptionPane.ERROR_MESSAGE);
    7680                        continue nextFile;
    7781                    }
    7882                    // check if the selected cache is not already displayed
    79                     if (Main.map != null) {
    80                         for (Layer l : Main.getLayerManager().getLayers()) {
     83                    if (MainApplication.getMap() != null) {
     84                        for (Layer l : MainApplication.getLayerManager().getLayers()) {
    8185                            if (l instanceof WMSLayer && l.getName().equals(location)) {
    82                                 JOptionPane.showMessageDialog(Main.parent, tr("The location {0} is already on screen. Cache not loaded.", filename), tr("Error"), JOptionPane.ERROR_MESSAGE);
     86                                JOptionPane.showMessageDialog(Main.parent,
     87                                        tr("The location {0} is already on screen. Cache not loaded.", filename),
     88                                        tr("Error"), JOptionPane.ERROR_MESSAGE);
    8389                                continue nextFile;
    8490                            }
     
    9399            }
    94100        }
    95 
    96101    }
    97102
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionNewLocation.java

    r33638 r33640  
    1616import org.openstreetmap.josm.Main;
    1717import org.openstreetmap.josm.actions.JosmAction;
     18import org.openstreetmap.josm.gui.MainApplication;
    1819import org.openstreetmap.josm.gui.layer.Layer;
    1920import org.openstreetmap.josm.plugins.fr.cadastre.CadastrePlugin;
     
    2122import org.openstreetmap.josm.plugins.fr.cadastre.wms.WMSLayer;
    2223import org.openstreetmap.josm.tools.GBC;
     24import org.openstreetmap.josm.tools.Logging;
    2325
    2426public class MenuActionNewLocation extends JosmAction {
     
    116118            Main.pref.put("cadastrewms.codeCommune", codeCommune);
    117119            Main.pref.put("cadastrewms.codeDepartement", codeDepartement);
    118             if (Main.map != null) {
    119                 for (Layer l : Main.getLayerManager().getLayers()) {
     120            if (MainApplication.getMap() != null) {
     121                for (Layer l : MainApplication.getLayerManager().getLayers()) {
    120122                    if (l instanceof WMSLayer && l.getName().equalsIgnoreCase(location)) {
    121123                        return null;
     
    128130            wmsLayer.setDepartement(codeDepartement);
    129131            CadastrePlugin.addWMSLayer(wmsLayer);
    130             Main.info("Add new layer with Location:" + inputTown.getText());
    131         } else if (existingLayers != null && existingLayers.size() > 0 && Main.getLayerManager().getActiveLayer() instanceof WMSLayer) {
    132             wmsLayer = (WMSLayer) Main.getLayerManager().getActiveLayer();
     132            Logging.info("Add new layer with Location:" + inputTown.getText());
     133        } else if (existingLayers != null && existingLayers.size() > 0 && MainApplication.getLayerManager().getActiveLayer() instanceof WMSLayer) {
     134            wmsLayer = (WMSLayer) MainApplication.getLayerManager().getActiveLayer();
    133135        }
    134136
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionRefineGeoRef.java

    r33638 r33640  
    77import java.awt.event.ActionEvent;
    88
    9 import org.openstreetmap.josm.Main;
    109import org.openstreetmap.josm.actions.JosmAction;
    1110import org.openstreetmap.josm.plugins.fr.cadastre.CadastrePlugin;
    1211import org.openstreetmap.josm.plugins.fr.cadastre.wms.RasterImageGeoreferencer;
    1312import org.openstreetmap.josm.plugins.fr.cadastre.wms.WMSLayer;
     13import org.openstreetmap.josm.tools.Logging;
    1414
    1515public class MenuActionRefineGeoRef extends JosmAction {
     
    3333    public void actionPerformed(ActionEvent arg0) {
    3434        if (!wmsLayer.isRaster()) {
    35             Main.info("MenuActionRefineGeoRef called for unexpected layer type");
     35            Logging.info("MenuActionRefineGeoRef called for unexpected layer type");
    3636            return;
    3737        }
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionSaveRasterAs.java

    r33638 r33640  
    2828import org.openstreetmap.josm.actions.JosmAction;
    2929import org.openstreetmap.josm.plugins.fr.cadastre.wms.WMSLayer;
     30import org.openstreetmap.josm.tools.Logging;
    3031
    3132public class MenuActionSaveRasterAs extends JosmAction {
     
    107108            } else if (fc.getFileFilter().equals(filtreTiff)) {
    108109                boolean alpha = bi.getColorModel().hasAlpha();
    109                 Main.info("image with alpha channel : " + alpha);
     110                Logging.info("image with alpha channel : " + alpha);
    110111                try {
    111112                    double x = wmsLayer.getImage(0).min.east();
     
    132133                    coverage.dispose(true);
    133134                } catch (Exception e) {
    134                     Main.error(e);
     135                    Logging.error(e);
    135136                }
    136137            }
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/WMSDownloadAction.java

    r33638 r33640  
    1010
    1111import org.openstreetmap.josm.Main;
     12import org.openstreetmap.josm.gui.MainApplication;
    1213//import org.openstreetmap.josm.actions.JosmAction;
    1314import org.openstreetmap.josm.gui.layer.Layer;
    1415import org.openstreetmap.josm.plugins.fr.cadastre.wms.WMSLayer;
    1516
    16 public class WMSDownloadAction {
     17final class WMSDownloadAction {
    1718
    18     public static WMSLayer getLayer() {
     19    private WMSDownloadAction() {
     20        // Hide default constructor
     21    }
     22
     23    static WMSLayer getLayer() {
    1924        // check if we already have a layer created. if not, create; if yes, reuse.
    2025        ArrayList<WMSLayer> existingWMSlayers = new ArrayList<>();
    21         if (Main.map != null) {
    22             Layer activeLayer = Main.getLayerManager().getActiveLayer();
     26        if (MainApplication.getMap() != null) {
     27            Layer activeLayer = MainApplication.getLayerManager().getActiveLayer();
    2328            if (activeLayer instanceof WMSLayer)
    2429                return (WMSLayer) activeLayer;
    25             for (Layer l : Main.getLayerManager().getLayers()) {
     30            for (Layer l : MainApplication.getLayerManager().getLayers()) {
    2631                if (l instanceof WMSLayer) {
    2732                    existingWMSlayers.add((WMSLayer) l);
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/mapmode/Address.java

    r33638 r33640  
    5656import org.openstreetmap.josm.data.osm.Way;
    5757import org.openstreetmap.josm.data.osm.WaySegment;
     58import org.openstreetmap.josm.gui.MainApplication;
    5859import org.openstreetmap.josm.gui.MapView;
    5960import org.openstreetmap.josm.tools.GBC;
    6061import org.openstreetmap.josm.tools.ImageProvider;
     62import org.openstreetmap.josm.tools.Logging;
    6163import org.openstreetmap.josm.tools.Pair;
    6264import org.openstreetmap.josm.tools.Shortcut;
     
    108110        }
    109111        dialog.setVisible(true);
    110         Main.map.mapView.addMouseListener(this);
     112        MainApplication.getMap().mapView.addMouseListener(this);
    111113    }
    112114
    113115    @Override public void exitMode() {
    114         if (Main.map.mapView != null) {
     116        if (MainApplication.getMap().mapView != null) {
    115117            super.exitMode();
    116             Main.map.mapView.removeMouseListener(this);
     118            MainApplication.getMap().mapView.removeMouseListener(this);
    117119        }
    118120        // kill the window completely to fix an issue on some linux distro and full screen mode.
     
    129131        shift = (e.getModifiers() & ActionEvent.SHIFT_MASK) != 0;
    130132        ctrl = (e.getModifiers() & ActionEvent.CTRL_MASK) != 0;
    131         MapView mv = Main.map.mapView;
     133        MapView mv = MainApplication.getMap().mapView;
    132134        Point mousePos = e.getPoint();
    133135        List<Way> mouseOnExistingWays = new ArrayList<>();
     
    155157                        inputNumber.setText(num);
    156158                        applyInputNumberChange();
    157                     } catch (NumberFormatException en) {
    158                         Main.warn("Unable to parse house number \"" + num + "\"");
     159                    } catch (NumberFormatException ex) {
     160                        Logging.warn("Unable to parse house number \"" + num + "\"");
    159161                    }
    160162                }
     
    248250            try {
    249251                revertInputNumberChange();
    250             } catch (NumberFormatException en) {
    251                 Main.warn("Unable to parse house number \"" + inputNumber.getText() + "\"");
     252            } catch (NumberFormatException ex) {
     253                Logging.warn("Unable to parse house number \"" + inputNumber.getText() + "\"");
    252254            }
    253255        }
     
    259261            Main.main.undoRedo.add(c);
    260262            setNewSelection(osm);
    261         } catch (NumberFormatException en) {
    262             Main.warn("Unable to parse house number \"" + inputNumber.getText() + "\"");
     263        } catch (NumberFormatException ex) {
     264            Logging.warn("Unable to parse house number \"" + inputNumber.getText() + "\"");
    263265        }
    264266    }
     
    292294                newRel.addMember(new RelationMember(relationAddrStreetRole, selectedWay));
    293295                newRel.addMember(new RelationMember(relationMemberHouse, osm));
    294                 cmds.add(new AddCommand(newRel));
     296                cmds.add(new AddCommand(Main.main.getEditDataSet(), newRel));
    295297            }
    296298        }
     
    299301    private static Node createNewNode(MouseEvent e, Collection<Command> cmds) {
    300302        // DrawAction.mouseReleased() but without key modifiers
    301         Node n = new Node(Main.map.mapView.getLatLon(e.getX(), e.getY()));
    302         cmds.add(new AddCommand(n));
    303         List<WaySegment> wss = Main.map.mapView.getNearestWaySegments(e.getPoint(), OsmPrimitive::isSelectable);
     303        Node n = new Node(MainApplication.getMap().mapView.getLatLon(e.getX(), e.getY()));
     304        cmds.add(new AddCommand(Main.main.getEditDataSet(), n));
     305        List<WaySegment> wss = MainApplication.getMap().mapView.getNearestWaySegments(e.getPoint(), OsmPrimitive::isSelectable);
    304306        Map<Way, List<Integer>> insertPoints = new HashMap<>();
    305307        for (WaySegment ws : wss) {
     
    370372
    371373            int snapToIntersectionThreshold
    372             = Main.pref.getInteger("edit.snap-intersection-threshold", 10);
     374            = Main.pref.getInt("edit.snap-intersection-threshold", 10);
    373375
    374376            // only adjust to intersection if within snapToIntersectionThreshold pixel of mouse click; otherwise
    375377            // fall through to default action.
    376378            // (for semi-parallel lines, intersection might be miles away!)
    377             if (Main.map.mapView.getPoint(n).distance(Main.map.mapView.getPoint(intersection)) < snapToIntersectionThreshold) {
     379            if (MainApplication.getMap().mapView.getPoint(n).distance(MainApplication.getMap().mapView.getPoint(intersection)) < snapToIntersectionThreshold) {
    378380                n.setEastNorth(intersection);
    379381                return;
     
    414416            return ImageProvider.getCursor("crosshair", null);
    415417        } catch (RuntimeException e) {
    416             Main.warn(e);
     418            Logging.warn(e);
    417419        }
    418420        return Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR);
     
    480482            @Override
    481483            public void stateChanged(ChangeEvent arg0) {
    482                 Main.pref.put("cadastrewms.addr.onBuilding", tagPolygon.isSelected());
     484                Main.pref.putBoolean("cadastrewms.addr.onBuilding", tagPolygon.isSelected());
    483485            }
    484486        });
     
    511513            @Override
    512514            public void windowClosing(WindowEvent arg) {
    513                 Main.map.selectMapMode((MapMode) Main.map.getDefaultButtonAction());
     515                MainApplication.getMap().selectMapMode((MapMode) MainApplication.getMap().getDefaultButtonAction());
    514516            }
    515517        });
     
    532534
    533535    private static void setNewSelection(OsmPrimitive osm) {
    534         DataSet ds = Main.getLayerManager().getEditDataSet();
     536        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    535537        Collection<OsmPrimitive> newSelection = new LinkedList<>(ds.getSelected());
    536538        newSelection.clear();
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/mapmode/WMSAdjustAction.java

    r33638 r33640  
    1515import javax.swing.JOptionPane;
    1616
    17 import org.openstreetmap.josm.Main;
    1817import org.openstreetmap.josm.actions.mapmode.MapMode;
    1918import org.openstreetmap.josm.data.coor.EastNorth;
     19import org.openstreetmap.josm.gui.MainApplication;
    2020import org.openstreetmap.josm.gui.MapView;
    2121import org.openstreetmap.josm.plugins.fr.cadastre.wms.CacheControl;
     
    4545
    4646    @Override public void enterMode() {
    47         if (Main.map != null) {
    48             if (Main.getLayerManager().getActiveLayer() instanceof WMSLayer) {
    49                 modifiedLayer = (WMSLayer) Main.getLayerManager().getActiveLayer();
     47        if (MainApplication.getMap() != null) {
     48            if (MainApplication.getLayerManager().getActiveLayer() instanceof WMSLayer) {
     49                modifiedLayer = (WMSLayer) MainApplication.getLayerManager().getActiveLayer();
    5050                super.enterMode();
    51                 Main.map.mapView.addMouseListener(this);
    52                 Main.map.mapView.addMouseMotionListener(this);
     51                MainApplication.getMap().mapView.addMouseListener(this);
     52                MainApplication.getMap().mapView.addMouseMotionListener(this);
    5353                rasterMoved = false;
    5454                modifiedLayer.adjustModeEnabled = true;
     
    5858                    exitMode();
    5959                }
    60                 Main.map.selectMapMode((MapMode) Main.map.getDefaultButtonAction());
     60                MainApplication.getMap().selectMapMode((MapMode) MainApplication.getMap().getDefaultButtonAction());
    6161            }
    6262        }
     
    6565    @Override public void exitMode() {
    6666        super.exitMode();
    67         Main.map.mapView.removeMouseListener(this);
    68         Main.map.mapView.removeMouseMotionListener(this);
     67        MainApplication.getMap().mapView.removeMouseListener(this);
     68        MainApplication.getMap().mapView.removeMouseMotionListener(this);
    6969        if (rasterMoved && CacheControl.cacheEnabled && modifiedLayer.isRaster()) {
    7070            int reply = JOptionPane.showConfirmDialog(null,
     
    9898            mode = Mode.moveXY;
    9999        rasterMoved = true;
    100         prevEastNorth = Main.map.mapView.getEastNorth(e.getX(), e.getY());
    101         Main.map.mapView.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
     100        prevEastNorth = MainApplication.getMap().mapView.getEastNorth(e.getX(), e.getY());
     101        MainApplication.getMap().mapView.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
    102102    }
    103103
    104104    @Override public void mouseDragged(MouseEvent e) {
    105         EastNorth newEastNorth = Main.map.mapView.getEastNorth(e.getX(), e.getY());
     105        EastNorth newEastNorth = MainApplication.getMap().mapView.getEastNorth(e.getX(), e.getY());
    106106        if (mode == Mode.rotate) {
    107107            rotateFrameOnly(prevEastNorth, newEastNorth);
     
    168168    public void mouseReleased(MouseEvent e) {
    169169        if (mode == Mode.rotate) {
    170             EastNorth newEastNorth = Main.map.mapView.getEastNorth(e.getX(), e.getY());
     170            EastNorth newEastNorth = MainApplication.getMap().mapView.getEastNorth(e.getX(), e.getY());
    171171            rotate(prevEastNorth, newEastNorth);
    172172            if (modifiedLayer != null) {
     
    174174            }
    175175        }
    176         Main.map.mapView.setCursor(Cursor.getDefaultCursor());
     176        MainApplication.getMap().mapView.setCursor(Cursor.getDefaultCursor());
    177177        prevEastNorth = null;
    178178        mode = null;
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/preferences/CadastrePreferenceSetting.java

    r33638 r33640  
    3131import org.openstreetmap.josm.tools.I18n;
    3232import org.openstreetmap.josm.tools.ImageProvider;
     33import org.openstreetmap.josm.tools.Logging;
    3334
    3435/**
     
    385386        Main.pref.put("cadastrewms.source", sourcing.getText());
    386387        CadastrePlugin.source = sourcing.getText();
    387         Main.pref.put("cadastrewms.alterColors", alterColors.isSelected());
    388         Main.pref.put("cadastrewms.invertGrey", reversGrey.isSelected());
    389         Main.pref.put("cadastrewms.backgroundTransparent", transparency.isSelected());
     388        Main.pref.putBoolean("cadastrewms.alterColors", alterColors.isSelected());
     389        Main.pref.putBoolean("cadastrewms.invertGrey", reversGrey.isSelected());
     390        Main.pref.putBoolean("cadastrewms.backgroundTransparent", transparency.isSelected());
    390391        Main.pref.put("cadastrewms.brightness", Float.toString((float) sliderTrans.getValue()/10));
    391         Main.pref.put("cadastrewms.drawBoundaries", drawBoundaries.isSelected());
     392        Main.pref.putBoolean("cadastrewms.drawBoundaries", drawBoundaries.isSelected());
    392393        if (grabRes1.isSelected())
    393394            Main.pref.put("cadastrewms.resolution", "high");
     
    415416                    Main.pref.put("cadastrewms.squareSize", grabMultiplier4Size.getText());
    416417            } catch (NumberFormatException e) {
    417                 Main.debug(e);
     418                Logging.debug(e);
    418419            }
    419420        }
    420         Main.pref.put("cadastrewms.layerWater", layerLS3.isSelected());
    421         Main.pref.put("cadastrewms.layerBuilding", layerLS2.isSelected());
    422         Main.pref.put("cadastrewms.layerSymbol", layerLS1.isSelected());
    423         Main.pref.put("cadastrewms.layerParcel", layerParcel.isSelected());
    424         Main.pref.put("cadastrewms.layerLabel", layerLabel.isSelected());
    425         Main.pref.put("cadastrewms.layerNumero", layerNumero.isSelected());
    426         Main.pref.put("cadastrewms.layerLieudit", layerLieudit.isSelected());
    427         Main.pref.put("cadastrewms.layerSection", layerSection.isSelected());
    428         Main.pref.put("cadastrewms.layerCommune", layerCommune.isSelected());
     421        Main.pref.putBoolean("cadastrewms.layerWater", layerLS3.isSelected());
     422        Main.pref.putBoolean("cadastrewms.layerBuilding", layerLS2.isSelected());
     423        Main.pref.putBoolean("cadastrewms.layerSymbol", layerLS1.isSelected());
     424        Main.pref.putBoolean("cadastrewms.layerParcel", layerParcel.isSelected());
     425        Main.pref.putBoolean("cadastrewms.layerLabel", layerLabel.isSelected());
     426        Main.pref.putBoolean("cadastrewms.layerNumero", layerNumero.isSelected());
     427        Main.pref.putBoolean("cadastrewms.layerLieudit", layerLieudit.isSelected());
     428        Main.pref.putBoolean("cadastrewms.layerSection", layerSection.isSelected());
     429        Main.pref.putBoolean("cadastrewms.layerCommune", layerCommune.isSelected());
    429430        try {
    430431            int i = Integer.parseInt(rasterDivider.getText());
     
    432433                Main.pref.put("cadastrewms.rasterDivider", String.valueOf(i));
    433434        } catch (NumberFormatException e) {
    434             Main.debug(e);
     435            Logging.debug(e);
    435436        }
    436         Main.pref.put("cadastrewms.noImageCropping", disableImageCropping.isSelected());
    437         Main.pref.put("cadastrewms.useTA", enableTableauAssemblage.isSelected());
    438         Main.pref.put("cadastrewms.raster2bitsColors", simplify2BitsColors.isSelected());
     437        Main.pref.putBoolean("cadastrewms.noImageCropping", disableImageCropping.isSelected());
     438        Main.pref.putBoolean("cadastrewms.useTA", enableTableauAssemblage.isSelected());
     439        Main.pref.putBoolean("cadastrewms.raster2bitsColors", simplify2BitsColors.isSelected());
    439440        if (crosspiece1.isSelected()) Main.pref.put("cadastrewms.crosspieces", "0");
    440441        else if (crosspiece2.isSelected()) Main.pref.put("cadastrewms.crosspieces", "1");
    441442        else if (crosspiece3.isSelected()) Main.pref.put("cadastrewms.crosspieces", "2");
    442443        else if (crosspiece4.isSelected()) Main.pref.put("cadastrewms.crosspieces", "3");
    443         Main.pref.put("cadastrewms.enableCaching", enableCache.isSelected());
     444        Main.pref.putBoolean("cadastrewms.enableCaching", enableCache.isSelected());
    444445
    445446        // spread data into objects instead of restarting the application
     
    448449            Main.pref.put("cadastrewms.cacheSize", String.valueOf(CacheControl.cacheSize));
    449450        } catch (NumberFormatException e) {
    450             Main.debug(e);
     451            Logging.debug(e);
    451452        }
    452         Main.pref.put("cadastrewms.autoFirstLayer", autoFirstLayer.isSelected());
     453        Main.pref.putBoolean("cadastrewms.autoFirstLayer", autoFirstLayer.isSelected());
    453454        CacheControl.cacheEnabled = enableCache.isSelected();
    454         Main.pref.put("cadastrewms.addr.dontUseRelation", dontUseRelation.isSelected());
     455        Main.pref.putBoolean("cadastrewms.addr.dontUseRelation", dontUseRelation.isSelected());
    455456        CadastrePlugin.refreshConfiguration();
    456457        CadastrePlugin.refreshMenu();
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/CacheControl.java

    r33638 r33640  
    2424import org.openstreetmap.josm.plugins.fr.cadastre.CadastrePlugin;
    2525import org.openstreetmap.josm.plugins.fr.cadastre.preferences.CadastrePreferenceSetting;
     26import org.openstreetmap.josm.tools.Logging;
    2627
    2728/**
     
    9798            }
    9899            if (size > (long) cacheSize*1024*1024) {
    99                 Main.info("Delete oldest file  \""+ files[oldestFile].getName()
     100                Logging.info("Delete oldest file  \""+ files[oldestFile].getName()
    100101                        + "\" in cache dir to stay under the limit of " + cacheSize + " MB.");
    101102                files[oldestFile].delete();
     
    142143
    143144    private static void delete(File file) {
    144         Main.info("Delete file "+file);
     145        Logging.info("Delete file "+file);
    145146        if (file.exists())
    146147            file.delete();
     
    158159            successfulRead = wmsLayer.read(file, ois, currentLambertZone);
    159160        } catch (IOException | ClassNotFoundException ex) {
    160             Main.error(ex);
    161             GuiHelper.runInEDTAndWait(new Runnable() {
    162                 @Override
    163                 public void run() {
    164                     JOptionPane.showMessageDialog(Main.parent, tr("Error loading file.\nProbably an old version of the cache file."),
    165                             tr("Error"), JOptionPane.ERROR_MESSAGE);
    166                 }
    167             });
     161            Logging.error(ex);
     162            GuiHelper.runInEDTAndWait(() -> JOptionPane.showMessageDialog(Main.parent,
     163                    tr("Error loading file.\nProbably an old version of the cache file."),
     164                    tr("Error"), JOptionPane.ERROR_MESSAGE));
    168165            return false;
    169166        }
     
    211208                    }
    212209                } catch (IOException e) {
    213                     Main.error(e);
     210                    Logging.error(e);
    214211                }
    215212                imagesLock.lock();
     
    222219                wait();
    223220            } catch (InterruptedException e) {
    224                 Main.error(e);
     221                Logging.error(e);
    225222            }
    226223        }
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/CadastreGrabber.java

    r33638 r33640  
    1212import javax.imageio.ImageIO;
    1313
    14 import org.openstreetmap.josm.Main;
    1514import org.openstreetmap.josm.data.coor.EastNorth;
    1615import org.openstreetmap.josm.io.OsmTransferException;
    1716import org.openstreetmap.josm.plugins.fr.cadastre.CadastrePlugin;
     17import org.openstreetmap.josm.tools.Logging;
    1818
    1919public class CadastreGrabber {
     
    5656        str += (int) (cRasterX*(wmsLayer.communeBBox.max.getY() - wmsLayer.communeBBox.min.getY())/(wmsLayer.communeBBox.max.getX() - wmsLayer.communeBBox.min.getX()));
    5757        str += "&exception=application/vnd.ogc.se_inimage&styles="; // required for raster images
    58         Main.info("URL="+str);
     58        Logging.info("URL="+str);
    5959        return new URL(str.replace(" ", "%20"));
    6060    }
     
    7373        str += "&exception=application/vnd.ogc.se_inimage"; // works also without (but slower ?)
    7474        str += "&styles=" + styles;
    75         Main.info("URL="+str);
     75        Logging.info("URL="+str);
    7676        return new URL(str.replace(" ", "%20"));
    7777    }
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/CadastreInterface.java

    r33638 r33640  
    2929import org.openstreetmap.josm.data.coor.EastNorth;
    3030import org.openstreetmap.josm.data.validation.util.Entities;
     31import org.openstreetmap.josm.gui.MainApplication;
    3132import org.openstreetmap.josm.gui.layer.Layer;
    3233import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
     
    3637import org.openstreetmap.josm.plugins.fr.cadastre.CadastrePlugin;
    3738import org.openstreetmap.josm.tools.GBC;
     39import org.openstreetmap.josm.tools.Logging;
    3840
    3941public class CadastreInterface {
     
    103105            openInterface();
    104106        } catch (IOException e) {
    105             Main.error(e);
     107            Logging.error(e);
    106108            GuiHelper.runInEDT(() ->
    107109                JOptionPane.showMessageDialog(Main.parent,
     
    129131                urlConn.connect();
    130132                if (urlConn.getResponseCode() == HttpURLConnection.HTTP_OK) {
    131                     Main.info("GET "+searchFormURL);
     133                    Logging.info("GET "+searchFormURL);
    132134                    BufferedReader in = new BufferedReader(new InputStreamReader(urlConn.getInputStream(), StandardCharsets.UTF_8));
    133135                    while (in.readLine() != null) {
     
    151153                    }
    152154                } else {
    153                     Main.warn("Request to home page failed. Http error:"+urlConn.getResponseCode()+". Try again "+retries+" times");
     155                    Logging.warn("Request to home page failed. Http error:"+urlConn.getResponseCode()+". Try again "+retries+" times");
    154156                    CadastrePlugin.safeSleep(3000);
    155157                    retries--;
     
    164166        cookie = pCookie;
    165167        if (cookie == null || cookie.isEmpty()) {
    166             Main.warn("received empty cookie");
     168            Logging.warn("received empty cookie");
    167169            cookie = null;
    168170        } else {
     
    172174            }
    173175            cookieTimestamp = new Date().getTime();
    174             Main.info("received cookie=" + cookie + " at " + new Date(cookieTimestamp));
     176            Logging.info("received cookie=" + cookie + " at " + new Date(cookieTimestamp));
    175177        }
    176178        return cookie != null;
     
    185187        long now = new Date().getTime();
    186188        if ((now - cookieTimestamp) > COOKIE_EXPIRATION) {
    187             Main.info("cookie received at "+new Date(cookieTimestamp)+" expired (now is "+new Date(now)+")");
     189            Logging.info("cookie received at "+new Date(cookieTimestamp)+" expired (now is "+new Date(now)+")");
    188190            return true;
    189191        }
     
    256258                throw new IOException("Cannot open Cadastre interface. GET response:"+urlConn.getResponseCode());
    257259            }
    258             Main.info("GET "+interfaceURL);
     260            Logging.info("GET "+interfaceURL);
    259261            BufferedReader in = new BufferedReader(new InputStreamReader(urlConn.getInputStream(), StandardCharsets.UTF_8));
    260262            // read the buffer otherwise we sent POST too early
     
    262264            String ln;
    263265            while ((ln = in.readLine()) != null) {
    264                 if (Main.isDebugEnabled()) {
     266                if (Logging.isDebugEnabled()) {
    265267                    lines.append(ln);
    266268                }
    267269            }
    268             if (Main.isDebugEnabled()) {
    269                 Main.debug(lines.toString());
     270            if (Logging.isDebugEnabled()) {
     271                Logging.debug(lines.toString());
    270272            }
    271273        } catch (MalformedURLException e) {
     
    319321            try (OutputStream wr = urlConn.getOutputStream()) {
    320322                wr.write(content.getBytes(StandardCharsets.UTF_8));
    321                 Main.info("POST "+content);
     323                Logging.info("POST "+content);
    322324                wr.flush();
    323325            }
     
    342344                    lines = lines.substring(0, lines.indexOf('\''));
    343345                    lines = Entities.unescape(lines);
    344                     Main.info("interface ref.:"+lines);
     346                    Logging.info("interface ref.:"+lines);
    345347                    return lines;
    346348                } else if (wmsLayer.isRaster() && lines.indexOf(C_INTERFACE_RASTER_TA) != -1) { // "afficherCarteTa.do"
     
    358360                                lines = buildRasterFeuilleInterfaceRef(listOfFeuilles.get(res).ref);
    359361                                lines = Entities.unescape(lines);
    360                                 Main.info("interface ref.:"+lines);
     362                                Logging.info("interface ref.:"+lines);
    361363                                return lines;
    362364                            }
     
    374376            throw (IOException) new IOException("Illegal url.").initCause(e);
    375377        } catch (DuplicateLayerException e) {
    376             Main.error(e);
     378            Logging.error(e);
    377379        }
    378380        return null;
     
    388390                    String lov = input.substring(i+C_OPTION_LIST_START.length()-1, j);
    389391                    if (lov.indexOf('>') != -1) {
    390                         Main.info("parse "+lov);
     392                        Logging.info("parse "+lov);
    391393                        listOfCommunes.add(lov);
    392394                    } else
    393                         Main.error("unable to parse commune string:"+lov);
     395                        Logging.error("unable to parse commune string:"+lov);
    394396                }
    395397                input = input.substring(j+C_OPTION_LIST_END.length());
     
    408410            setCookie(urlConn2);
    409411            urlConn2.connect();
    410             Main.info("GET "+getAllImagesURL);
     412            Logging.info("GET "+getAllImagesURL);
    411413            try (BufferedReader rd = new BufferedReader(new InputStreamReader(urlConn2.getInputStream(), StandardCharsets.UTF_8))) {
    412414                while ((ln = rd.readLine()) != null) {
     
    417419        } catch (IOException e) {
    418420            listOfFeuilles.clear();
    419             Main.error(e);
     421            Logging.error(e);
    420422        }
    421423        return lines.toString();
     
    510512            throw new IOException("Cannot get Cadastre response.");
    511513        }
    512         Main.info("GET "+searchFormURL);
     514        Logging.info("GET "+searchFormURL);
    513515        String ln;
    514516        StringBuilder sb = new StringBuilder();
     
    578580
    579581    private static void checkLayerDuplicates(WMSLayer wmsLayer) throws DuplicateLayerException {
    580         if (Main.map != null) {
    581             for (Layer l : Main.getLayerManager().getLayers()) {
     582        if (MainApplication.getMap() != null) {
     583            for (Layer l : MainApplication.getLayerManager().getLayers()) {
    582584                if (l instanceof WMSLayer && l.getName().equals(wmsLayer.getName()) && (!l.equals(wmsLayer))) {
    583                     Main.info("Try to grab into a new layer when "+wmsLayer.getName()+" is already opened.");
     585                    Logging.info("Try to grab into a new layer when "+wmsLayer.getName()+" is already opened.");
    584586                    // remove the duplicated layer
    585                     Main.getLayerManager().removeLayer(wmsLayer);
     587                    MainApplication.getLayerManager().removeLayer(wmsLayer);
    586588                    throw new DuplicateLayerException();
    587589                }
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/DownloadSVGBuilding.java

    r33638 r33640  
    2828import org.openstreetmap.josm.data.osm.Node;
    2929import org.openstreetmap.josm.data.osm.Way;
     30import org.openstreetmap.josm.gui.MainApplication;
    3031import org.openstreetmap.josm.gui.MapView;
    3132import org.openstreetmap.josm.gui.PleaseWaitRunnable;
    3233import org.openstreetmap.josm.io.OsmTransferException;
    3334import org.openstreetmap.josm.plugins.fr.cadastre.CadastrePlugin;
     35import org.openstreetmap.josm.tools.Logging;
    3436
    3537public class DownloadSVGBuilding extends PleaseWaitRunnable {
     
    6769            }
    6870        } catch (DuplicateLayerException e) {
    69             Main.warn("removed a duplicated layer");
     71            Logging.warn("removed a duplicated layer");
    7072        } catch (WMSException e) {
    7173            errorMessage = e.getMessage();
     
    9193            return true;
    9294        }
    93         Main.warn("Unable to parse SVG data (viewBox)");
     95        Logging.warn("Unable to parse SVG data (viewBox)");
    9496        return false;
    9597    }
     
    137139        // check if the new way or its nodes is already in OSM layer
    138140        for (Node n : svgDataSet.getNodes()) {
    139             Node nearestNewNode = checkNearestNode(n, Main.getLayerManager().getEditDataSet().getNodes());
     141            Node nearestNewNode = checkNearestNode(n, MainApplication.getLayerManager().getEditDataSet().getNodes());
    140142            if (nearestNewNode != n) {
    141143                // replace the SVG node by the OSM node
     
    153155                n.setDeleted(true);
    154156            }
    155 
    156         }
    157 
     157        }
     158
     159        DataSet ds = Main.main.getEditDataSet();
    158160        Collection<Command> cmds = new LinkedList<>();
    159161        for (Node node : svgDataSet.getNodes()) {
    160162            if (!node.isDeleted())
    161                 cmds.add(new AddCommand(node));
     163                cmds.add(new AddCommand(ds, node));
    162164        }
    163165        for (Way way : svgDataSet.getWays()) {
    164166            if (!way.isDeleted())
    165                 cmds.add(new AddCommand(way));
     167                cmds.add(new AddCommand(ds, way));
    166168        }
    167169        Main.main.undoRedo.add(new SequenceCommand(tr("Create buildings"), cmds));
    168         Main.map.repaint();
     170        MainApplication.getMap().repaint();
    169171    }
    170172
     
    233235        str += "&styles=";
    234236        str += "LS2_90";
    235         Main.info("URL="+str);
     237        Logging.info("URL="+str);
    236238        return new URL(str.replace(" ", "%20"));
    237239    }
     
    254256            }
    255257        } catch (IOException e) {
    256             Main.error(e);
     258            Logging.error(e);
    257259        }
    258260        return svg;
     
    260262
    261263    public static void download(WMSLayer wmsLayer) {
    262         MapView mv = Main.map.mapView;
     264        MapView mv = MainApplication.getMap().mapView;
    263265        currentView = new EastNorthBound(mv.getEastNorth(0, mv.getHeight()),
    264266                mv.getEastNorth(mv.getWidth(), 0));
     
    274276            return;
    275277        }
    276         Main.worker.execute(new DownloadSVGBuilding(wmsLayer));
     278        MainApplication.worker.execute(new DownloadSVGBuilding(wmsLayer));
    277279        if (errorMessage != null)
    278280            JOptionPane.showMessageDialog(Main.parent, errorMessage);
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/DownloadSVGTask.java

    r33638 r33640  
    2727import org.openstreetmap.josm.command.SequenceCommand;
    2828import org.openstreetmap.josm.data.coor.EastNorth;
     29import org.openstreetmap.josm.data.osm.DataSet;
    2930import org.openstreetmap.josm.data.osm.Node;
    3031import org.openstreetmap.josm.data.osm.Way;
     32import org.openstreetmap.josm.gui.MainApplication;
    3133import org.openstreetmap.josm.gui.PleaseWaitRunnable;
    3234import org.openstreetmap.josm.io.OsmTransferException;
    3335import org.openstreetmap.josm.plugins.fr.cadastre.CadastrePlugin;
     36import org.openstreetmap.josm.tools.Logging;
    3437
    3538/**
     
    7477            }
    7578        } catch (DuplicateLayerException e) {
    76             Main.warn("removed a duplicated layer");
     79            Logging.warn("removed a duplicated layer");
    7780        } catch (WMSException e) {
    7881            errorMessage = e.getMessage();
     
    98101            return true;
    99102        }
    100         Main.warn("Unable to parse SVG data (viewBox)");
     103        Logging.warn("Unable to parse SVG data (viewBox)");
    101104        return false;
    102105    }
     
    123126        }
    124127        Way wayToAdd = new Way();
     128        DataSet ds = Main.main.getEditDataSet();
    125129        Collection<Command> cmds = new LinkedList<>();
    126130        for (Node node : nodeList) {
    127             cmds.add(new AddCommand(node));
     131            cmds.add(new AddCommand(ds, node));
    128132            wayToAdd.addNode(node);
    129133        }
    130134        wayToAdd.addNode(wayToAdd.getNode(0)); // close the circle
    131135
    132         cmds.add(new AddCommand(wayToAdd));
     136        cmds.add(new AddCommand(ds, wayToAdd));
    133137        Main.main.undoRedo.add(new SequenceCommand(tr("Create boundary"), cmds));
    134         Main.map.repaint();
     138        MainApplication.getMap().repaint();
    135139    }
    136140
     
    183187        str += "&styles=";
    184188        str += "COMMUNE_90";
    185         Main.info("URL="+str);
     189        Logging.info("URL="+str);
    186190        return new URL(str.replace(" ", "%20"));
    187191    }
     
    204208            }
    205209        } catch (IOException e) {
    206             Main.error(e);
     210            Logging.error(e);
    207211        }
    208212        return svg;
     
    215219            return;
    216220        }
    217         Main.worker.execute(new DownloadSVGTask(wmsLayer));
     221        MainApplication.worker.execute(new DownloadSVGTask(wmsLayer));
    218222        if (errorMessage != null)
    219223            JOptionPane.showMessageDialog(Main.parent, errorMessage);
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/DownloadWMSPlanImage.java

    r33638 r33640  
    1212import org.openstreetmap.josm.Main;
    1313import org.openstreetmap.josm.data.Bounds;
     14import org.openstreetmap.josm.gui.MainApplication;
    1415import org.openstreetmap.josm.gui.MapView;
    1516import org.openstreetmap.josm.gui.PleaseWaitRunnable;
    1617import org.openstreetmap.josm.plugins.fr.cadastre.CadastrePlugin;
     18import org.openstreetmap.josm.tools.Logging;
    1719
    1820public class DownloadWMSPlanImage {
     
    8385            } catch (DuplicateLayerException e) {
    8486                // we tried to grab onto a duplicated layer (removed)
    85                 Main.warn("removed a duplicated layer");
     87                Logging.warn("removed a duplicated layer");
    8688            } catch (WMSException e) {
    8789                errorMessage = e.getMessage();
     
    102104
    103105    public void download(WMSLayer wmsLayer) {
    104         MapView mv = Main.map.mapView;
     106        MapView mv = MainApplication.getMap().mapView;
    105107        Bounds bounds = new Bounds(mv.getLatLon(0, mv.getHeight()), mv.getLatLon(mv.getWidth(), 0));
    106108        dontGeoreference = false;
     
    110112        this.wmsLayer = wmsLayer;
    111113        this.bounds = bounds;
    112         task = Main.worker.submit(t, t);
     114        task = MainApplication.worker.submit(t, t);
    113115        if (errorMessage != null)
    114116            JOptionPane.showMessageDialog(Main.parent, errorMessage);
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/DownloadWMSVectorImage.java

    r33638 r33640  
    1010import org.openstreetmap.josm.Main;
    1111import org.openstreetmap.josm.data.Bounds;
     12import org.openstreetmap.josm.gui.MainApplication;
    1213import org.openstreetmap.josm.gui.MapView;
    1314import org.openstreetmap.josm.gui.PleaseWaitRunnable;
     15import org.openstreetmap.josm.tools.Logging;
    1416
    1517public class DownloadWMSVectorImage extends PleaseWaitRunnable {
     
    3638                    if (CacheControl.cacheEnabled) {
    3739                        if (wmsLayer.grabThread.getCacheControl().loadCacheIfExist()) {
    38                             Main.map.mapView.zoomTo(wmsLayer.getFirstViewFromCacheBBox().toBounds());
     40                            MainApplication.getMap().mapView.zoomTo(wmsLayer.getFirstViewFromCacheBBox().toBounds());
    3941                            return;
    4042                        }
     
    4446                        JOptionPane.showMessageDialog(Main.parent,
    4547                                tr("This commune is not vectorized.\nPlease use the other menu entry to georeference a \"Plan image\""));
    46                         Main.getLayerManager().removeLayer(wmsLayer);
     48                        MainApplication.getLayerManager().removeLayer(wmsLayer);
    4749                        wmsLayer = null;
    4850                        return;
     
    5658            } else if (!wmsLayer.hasImages()) {
    5759              // failed to contact WMS of find this commune. Remove layer if empty.
    58               Main.getLayerManager().removeLayer(wmsLayer);
     60              MainApplication.getLayerManager().removeLayer(wmsLayer);
    5961            }
    6062        } catch (DuplicateLayerException e) {
    6163            // we tried to grab onto a duplicated layer (removed)
    62             Main.warn("removed a duplicated layer");
     64            Logging.warn("removed a duplicated layer");
    6365        } catch (WMSException e) {
    64             Main.warn(e);
     66            Logging.warn(e);
    6567            errorMessage = e.getMessage();
    6668            wmsLayer.grabber.getWmsInterface().resetCookie();
     
    8082
    8183    public static void download(WMSLayer wmsLayer) {
    82         MapView mv = Main.map.mapView;
     84        MapView mv = MainApplication.getMap().mapView;
    8385        Bounds bounds = new Bounds(mv.getLatLon(0, mv.getHeight()), mv.getLatLon(mv.getWidth(), 0));
    8486
    85         Main.worker.execute(new DownloadWMSVectorImage(wmsLayer, bounds));
     87        MainApplication.worker.execute(new DownloadWMSVectorImage(wmsLayer, bounds));
    8688        if (errorMessage != null)
    8789            JOptionPane.showMessageDialog(Main.parent, errorMessage);
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/GrabThread.java

    r33638 r33640  
    1010import java.util.concurrent.locks.ReentrantLock;
    1111
    12 import org.openstreetmap.josm.Main;
    1312import org.openstreetmap.josm.data.coor.EastNorth;
    1413import org.openstreetmap.josm.gui.MapView;
    1514import org.openstreetmap.josm.io.OsmTransferException;
    1615import org.openstreetmap.josm.plugins.fr.cadastre.CadastrePlugin;
     16import org.openstreetmap.josm.tools.Logging;
    1717
    1818public class GrabThread extends Thread {
     
    4444            this.notify();
    4545        }
    46         Main.info("Added " + moreImages.size() + " to the grab thread");
     46        Logging.info("Added " + moreImages.size() + " to the grab thread");
    4747        if (wmsLayer.isRaster()) {
    4848            waitNotification();
     
    8989                    GeorefImage newImage;
    9090                    try {
    91                         Main.map.repaint(); // paint the current grab box
     91                        wmsLayer.invalidate(); // paint the current grab box
    9292                        newImage = grabber.grab(wmsLayer, currentGrabImage.min, currentGrabImage.max);
    9393                    } catch (IOException e) {
    94                         Main.warn("Download action canceled by user or server did not respond");
     94                        Logging.warn("Download action canceled by user or server did not respond");
    9595                        setCanceled(true);
    9696                        break;
    9797                    } catch (OsmTransferException e) {
    98                         Main.error("OSM transfer failed");
     98                        Logging.error("OSM transfer failed");
    9999                        setCanceled(true);
    100100                        break;
    101101                    }
    102102                    if (grabber.getWmsInterface().downloadCanceled) {
    103                         Main.info("Download action canceled by user");
     103                        Logging.info("Download action canceled by user");
    104104                        setCanceled(true);
    105105                        break;
     
    123123                        saveToCache(newImage);
    124124                    } catch (NullPointerException e) {
    125                         Main.info("Layer destroyed. Cancel grab thread");
     125                        Logging.info("Layer destroyed. Cancel grab thread");
    126126                        setCanceled(true);
    127127                    }
    128128                }
    129129            }
    130             Main.info("grab thread list empty");
     130            Logging.info("grab thread list empty");
    131131            lockCurrentGrabImage.lock();
    132132            currentGrabImage = null;
     
    164164        if (cacheControl != null) {
    165165            while (!cacheControl.isCachePipeEmpty()) {
    166                 Main.info("Try to close a WMSLayer which is currently saving in cache : wait 1 sec.");
     166                Logging.info("Try to close a WMSLayer which is currently saving in cache : wait 1 sec.");
    167167                CadastrePlugin.safeSleep(1000);
    168168            }
     
    231231            wait();
    232232        } catch (InterruptedException e) {
    233             Main.error(e);
     233            Logging.error(e);
    234234        }
    235235    }
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/RasterImageGeoreferencer.java

    r33638 r33640  
    1818import org.openstreetmap.josm.Main;
    1919import org.openstreetmap.josm.data.coor.EastNorth;
     20import org.openstreetmap.josm.gui.MainApplication;
    2021import org.openstreetmap.josm.tools.GBC;
     22import org.openstreetmap.josm.tools.Logging;
    2123
    2224public class RasterImageGeoreferencer implements MouseListener {
     
    4143
    4244    public void addListener() {
    43         Main.map.mapView.addMouseListener(this);
     45        MainApplication.getMap().mapView.addMouseListener(this);
    4446    }
    4547
     
    5254       mode = cGetCorners;
    5355       countMouseClicked = 0;
    54        initialClickDelay = Main.pref.getInteger("cadastrewms.georef-click-delay", 200);
     56       initialClickDelay = Main.pref.getInt("cadastrewms.georef-click-delay", 200);
    5557       mouseClickedTime = System.currentTimeMillis();
    5658       Object[] options = {"OK", "Cancel"};
     
    7678      countMouseClicked = 0;
    7779      mode = cGetLambertCrosspieces;
    78       initialClickDelay = Main.pref.getInteger("cadastrewms.georef-click-delay", 200);
     80      initialClickDelay = Main.pref.getInt("cadastrewms.georef-click-delay", 200);
    7981      mouseClickedTime = System.currentTimeMillis();
    8082      Object[] options = {"OK", "Cancel"};
     
    99101  public void mouseClicked(MouseEvent e) {
    100102      if (System.currentTimeMillis() - mouseClickedTime < initialClickDelay) {
    101           Main.info("mouse click bounce detected");
     103          Logging.info("mouse click bounce detected");
    102104          return; // mouse click anti-bounce
    103105      } else
     
    106108          return;
    107109      if (ignoreMouseClick) return; // In case we are currently just allowing zooming to read lambert coordinates
    108       EastNorth ea = Main.getProjection().latlon2eastNorth(Main.map.mapView.getLatLon(e.getX(), e.getY()));
    109       Main.info("click:"+countMouseClicked+" ,"+ea+", mode:"+mode);
     110      EastNorth ea = Main.getProjection().latlon2eastNorth(MainApplication.getMap().mapView.getLatLon(e.getX(), e.getY()));
     111      Logging.info("click:"+countMouseClicked+" ,"+ea+", mode:"+mode);
    110112      if (clickOnTheMap) {
    111113          clickOnTheMap = false;
     
    115117          if (ea.east() < wmsLayer.getImage(0).min.east() || ea.east() > wmsLayer.getImage(0).max.east()
    116118                  || ea.north() < wmsLayer.getImage(0).min.north() || ea.north() > wmsLayer.getImage(0).max.north()) {
    117               Main.info("ignore click outside the image");
     119              Logging.info("ignore click outside the image");
    118120              return;
    119121          }
     
    156158     if (selectedValue == 0) { // "Cancel"
    157159         // remove layer
    158          Main.getLayerManager().removeLayer(wmsLayer);
     160         MainApplication.getLayerManager().removeLayer(wmsLayer);
    159161         wmsLayer = null;
    160          Main.map.mapView.removeMouseListener(this);
     162         MainApplication.getMap().mapView.removeMouseListener(this);
    161163         return false;
    162164     }
     
    178180                 tr("Ooops. I failed to catch all coordinates\n"+
    179181                    "correctly. Retry please."));
    180          Main.warn("failed to transform: one coordinate missing:"
     182         Logging.warn("failed to transform: one coordinate missing:"
    181183                    +"org1="+org1+", org2="+org2+", dst1="+dst1+", dst2="+dst2);
    182184         return;
     
    198200  */
    199201 private void endGeoreferencing() {
    200      Main.map.mapView.removeMouseListener(this);
     202     MainApplication.getMap().mapView.removeMouseListener(this);
    201203     affineTransform(ea1, ea2, georefpoint1, georefpoint2);
    202204     wmsLayer.grabThread.saveNewCache();
     
    341343     actionCompleted();
    342344     if (wmsLayer != null) {
    343          Main.getLayerManager().removeLayer(wmsLayer);
     345         MainApplication.getLayerManager().removeLayer(wmsLayer);
    344346         wmsLayer = null;
    345347     }
     
    347349
    348350 @Override
    349  public void mouseEntered(MouseEvent arg0) {
     351 public void mouseEntered(MouseEvent e) {
    350352 }
    351353
    352354 @Override
    353  public void mouseExited(MouseEvent arg0) {
     355 public void mouseExited(MouseEvent e) {
    354356 }
    355357
    356358 @Override
    357  public void mousePressed(MouseEvent arg0) {
     359 public void mousePressed(MouseEvent e) {
    358360 }
    359361
    360362 @Override
    361  public void mouseReleased(MouseEvent arg0) {
     363 public void mouseReleased(MouseEvent e) {
    362364 }
    363365}
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/WMSLayer.java

    r33638 r33640  
    3636import org.openstreetmap.josm.data.coor.EastNorth;
    3737import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
     38import org.openstreetmap.josm.gui.MainApplication;
    3839import org.openstreetmap.josm.gui.MapView;
    3940import org.openstreetmap.josm.gui.dialogs.LayerListDialog;
     
    4849import org.openstreetmap.josm.plugins.fr.cadastre.actions.mapmode.WMSAdjustAction;
    4950import org.openstreetmap.josm.plugins.fr.cadastre.preferences.CadastrePreferenceSetting;
     51import org.openstreetmap.josm.tools.Logging;
    5052
    5153/**
     
    149151        images = null;
    150152        dividedBbox = null;
    151         Main.info("Layer "+location+" destroyed");
     153        Logging.info("Layer "+location+" destroyed");
    152154    }
    153155
     
    167169        grabThread.setGrabber(grabber);
    168170        // if it is the first layer, use the communeBBox as grab bbox (and not divided)
    169         if (Main.getLayerManager().getLayers().size() == 1) {
     171        if (MainApplication.getLayerManager().getLayers().size() == 1) {
    170172            final Bounds bounds = this.getCommuneBBox().toBounds();
    171             GuiHelper.runInEDTAndWait(new Runnable() {
    172                 @Override
    173                 public void run() {
    174                     Main.map.mapView.zoomTo(bounds);
    175                 }
    176             });
     173            GuiHelper.runInEDTAndWait(() -> MainApplication.getMap().mapView.zoomTo(bounds));
    177174            divideBbox(bounds, 1);
    178175        } else {
     
    538535            } catch (EOFException ex) {
    539536                // expected exception when all images are read
    540                 Main.trace(ex);
    541             }
    542         }
    543         Main.info("Cache loaded for location "+location+" with "+images.size()+" images");
     537                Logging.trace(ex);
     538            }
     539        }
     540        Logging.info("Cache loaded for location "+location+" with "+images.size()+" images");
    544541        return true;
    545542    }
     
    703700            img = this.images.get(index);
    704701        } catch (ArrayIndexOutOfBoundsException e) {
    705             Main.error(e);
     702            Logging.error(e);
    706703        }
    707704        imagesLock.unlock();
Note: See TracChangeset for help on using the changeset viewer.