Ticket #12953: patch-layer-manager-migrate-from-mapview-plugins.patch

File patch-layer-manager-migrate-from-mapview-plugins.patch, 68.6 KB (added by michael2402, 3 years ago)
  • CommandLine/src/CommandLine/CommandLine.java

    diff --git a/CommandLine/src/CommandLine/CommandLine.java b/CommandLine/src/CommandLine/CommandLine.java
    index 3bc73ff..5a760ef 100644
    a b public class CommandLine extends Plugin { 
    368368                action = new DummyAction(currentMapFrame, this);
    369369                break;
    370370            case IMAGERYURL:
    371                 Layer layer = Main.map.mapView.getActiveLayer();
     371                Layer layer = Main.getLayerManager().getActiveLayer();
    372372                if (layer != null) {
    373373                    if (!(layer instanceof ImageryLayer)) {
    374                         List<ImageryLayer> imageryLayers = Main.map.mapView.getLayersOfType(ImageryLayer.class);
     374                        List<ImageryLayer> imageryLayers = Main.getLayerManager().getLayersOfType(ImageryLayer.class);
    375375                        if (imageryLayers.size() == 1) {
    376376                            layer = imageryLayers.get(0);
    377377                        }
    public class CommandLine extends Plugin { 
    388388                action = new DummyAction(currentMapFrame, this);
    389389                break;
    390390            case IMAGERYOFFSET:
    391                 Layer olayer = Main.map.mapView.getActiveLayer();
     391                Layer olayer = Main.getLayerManager().getActiveLayer();
    392392                if (olayer != null) {
    393393                    if (!(olayer instanceof ImageryLayer)) {
    394                         List<ImageryLayer> imageryLayers = Main.map.mapView.getLayersOfType(ImageryLayer.class);
     394                        List<ImageryLayer> imageryLayers = Main.getLayerManager().getLayersOfType(ImageryLayer.class);
    395395                        if (imageryLayers.size() == 1) {
    396396                            olayer = imageryLayers.get(0);
    397397                        }
    public class CommandLine extends Plugin { 
    596596                    try (GpxWriter gpxWriter = new GpxWriter(printWriter)) {
    597597                        GpxFilter gpxFilter = new GpxFilter();
    598598                        gpxFilter.initBboxFilter(bbox);
    599                         List<GpxLayer> gpxLayers = Main.map.mapView.getLayersOfType(GpxLayer.class);
     599                        List<GpxLayer> gpxLayers = Main.getLayerManager().getLayersOfType(GpxLayer.class);
    600600                        for (GpxLayer gpxLayer : gpxLayers) {
    601601                            gpxFilter.addGpxData(gpxLayer.data);
    602602                        }
  • DirectUpload/src/org/openstreetmap/josm/plugins/DirectUpload/UploadOsmConnection.java

    diff --git a/DirectUpload/src/org/openstreetmap/josm/plugins/DirectUpload/UploadOsmConnection.java b/DirectUpload/src/org/openstreetmap/josm/plugins/DirectUpload/UploadOsmConnection.java
    index e396af8..1e78cf1 100644
    a b import org.openstreetmap.josm.gui.MapView; 
    1010import org.openstreetmap.josm.gui.dialogs.LayerListDialog;
    1111import org.openstreetmap.josm.gui.layer.GpxLayer;
    1212import org.openstreetmap.josm.gui.layer.Layer;
     13import org.openstreetmap.josm.gui.layer.MainLayerManager;
    1314import org.openstreetmap.josm.io.OsmConnection;
    1415import org.openstreetmap.josm.io.OsmTransferException;
    1516import org.openstreetmap.josm.tools.HttpClient;
    public class UploadOsmConnection extends OsmConnection { 
    4849     */
    4950    GpxData autoSelectTrace() {
    5051        if (Main.map != null && Main.map.mapView != null) {
    51             MapView mv = Main.map.mapView;
     52            MainLayerManager lm = Main.getLayerManager();
    5253//            List<Layer> allLayers = new ArrayList<Layer>(mv.getAllLayersAsList());  // modifiable
    5354            List<Layer> selectedLayers = LayerListDialog.getInstance().getModel().getSelectedLayers();
    54             List<GpxLayer> gpxLayersRemaining = mv.getLayersOfType(GpxLayer.class);
     55            List<GpxLayer> gpxLayersRemaining = lm.getLayersOfType(GpxLayer.class);
    5556            gpxLayersRemaining.removeAll(selectedLayers);
    5657            GpxLayer traceLayer = null;
    5758            // find the first gpx layer inside selected layers
    public class UploadOsmConnection extends OsmConnection { 
    6768                    traceLayer = gpxLayersRemaining.get(0);
    6869                }
    6970                // active layer
    70                 else if (mv.getActiveLayer() instanceof GpxLayer) {
    71                     traceLayer = (GpxLayer) mv.getActiveLayer();
     71                else if (lm.getActiveLayer() instanceof GpxLayer) {
     72                    traceLayer = (GpxLayer) lm.getActiveLayer();
    7273                }
    7374            }
    7475
    7576            if (traceLayer != null) {
    76                 GpxData data = traceLayer.data;
    77                 return data;
     77                return traceLayer.data;
    7878            }
    7979        }
    8080
  • ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileDialog.java

    diff --git a/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileDialog.java b/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileDialog.java
    index 8398071..00e12ab 100644
    a b public class ElevationProfileDialog extends ToggleDialog implements LayerChangeL 
    195195        public void showNotify() {
    196196                MapView.addLayerChangeListener(this);
    197197                if (Main.isDisplayingMapView()) {
    198                         Layer layer = Main.map.mapView.getActiveLayer();
     198                        Layer layer = Main.getLayerManager().getActiveLayer();
    199199                        if (layer instanceof GpxLayer) {
    200200                                setActiveLayer((GpxLayer) layer);
    201201                        }
  • NanoLog/src/nanolog/GPXChooser.java

    diff --git a/NanoLog/src/nanolog/GPXChooser.java b/NanoLog/src/nanolog/GPXChooser.java
    index cded6dd..a9dc1c7 100644
    a b public class GPXChooser extends JDialog { 
    1818
    1919    public static GpxLayer topLayer() {
    2020        // return first found local layer
    21         for( Layer layer : Main.map.mapView.getAllLayers() ) {
     21        for( Layer layer : Main.getLayerManager().getLayers() ) {
    2222            if( layer instanceof GpxLayer && ((GpxLayer)layer).isLocalFile() )
    2323                return (GpxLayer)layer;
    2424        }
  • NanoLog/src/nanolog/NanoLogLayer.java

    diff --git a/NanoLog/src/nanolog/NanoLogLayer.java b/NanoLog/src/nanolog/NanoLogLayer.java
    index 36616d1..3592de7 100644
    a b public class NanoLogLayer extends Layer implements JumpToMarkerActions.JumpToMar 
    297297        @Override
    298298        public void mousePressed( MouseEvent e ) {
    299299            int nearest = nearestEntry(e);
    300             if( nearest > 0 && Main.map.mapView.getActiveLayer() == NanoLogLayer.this ) {
     300            if( nearest > 0 && Main.getLayerManager().getActiveLayer() == NanoLogLayer.this ) {
    301301                dragging = nearest;
    302302                doDrag(e);
    303303            }
  • NanoLog/src/nanolog/NanoLogPanel.java

    diff --git a/NanoLog/src/nanolog/NanoLogPanel.java b/NanoLog/src/nanolog/NanoLogPanel.java
    index 25247b1..a4e1e71 100644
    a b public class NanoLogPanel extends ToggleDialog implements LayerChangeListener, N 
    3636
    3737    public void updateMarkers() {
    3838        List<NanoLogEntry> entries = new ArrayList<>();
    39         for( NanoLogLayer l : Main.map.mapView.getLayersOfType(NanoLogLayer.class) ) {
     39        for( NanoLogLayer l : Main.getLayerManager().getLayersOfType(NanoLogLayer.class) ) {
    4040            entries.addAll(l.getEntries());
    4141        }
    4242        listModel.setEntries(entries);
  • cadastre-fr/src/cadastre_fr/CadastreInterface.java

    diff --git a/cadastre-fr/src/cadastre_fr/CadastreInterface.java b/cadastre-fr/src/cadastre_fr/CadastreInterface.java
    index c48b7c9..f41b6e3 100644
    a b public class CadastreInterface { 
    575575
    576576    private static void checkLayerDuplicates(WMSLayer wmsLayer) throws DuplicateLayerException {
    577577        if (Main.map != null) {
    578             for (Layer l : Main.map.mapView.getAllLayers()) {
     578            for (Layer l : Main.getLayerManager().getLayers()) {
    579579                if (l instanceof WMSLayer && l.getName().equals(wmsLayer.getName()) && (!l.equals(wmsLayer))) {
    580580                    Main.info("Try to grab into a new layer when "+wmsLayer.getName()+" is already opened.");
    581581                    // remove the duplicated layer
  • cadastre-fr/src/cadastre_fr/CadastrePlugin.java

    diff --git a/cadastre-fr/src/cadastre_fr/CadastrePlugin.java b/cadastre-fr/src/cadastre_fr/CadastrePlugin.java
    index c04dcec..cfb36bb 100644
    a b public class CadastrePlugin extends Plugin { 
    455455     */
    456456    public static void addWMSLayer(WMSLayer wmsLayer) {
    457457        if (Main.map != null && Main.map.mapView != null) {
    458             int wmsNewLayerPos = Main.map.mapView.getAllLayers().size();
    459             for(Layer l : Main.map.mapView.getLayersOfType(WMSLayer.class)) {
     458            int wmsNewLayerPos = Main.getLayerManager().getLayers().size();
     459            for(Layer l : Main.getLayerManager().getLayersOfType(WMSLayer.class)) {
    460460                int wmsPos = Main.map.mapView.getLayerPos(l);
    461461                if (wmsPos < wmsNewLayerPos) wmsNewLayerPos = wmsPos;
    462462            }
  • cadastre-fr/src/cadastre_fr/MenuActionGrabPlanImage.java

    diff --git a/cadastre-fr/src/cadastre_fr/MenuActionGrabPlanImage.java b/cadastre-fr/src/cadastre_fr/MenuActionGrabPlanImage.java
    index 7bea280..62453af 100644
    a b  
    11// License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others
    22package cadastre_fr;
    33
    4 import static org.openstreetmap.josm.tools.I18n.tr;
    54import static org.openstreetmap.josm.tools.I18n.marktr;
     5import static org.openstreetmap.josm.tools.I18n.tr;
    66
    77import java.awt.event.ActionEvent;
    88import java.util.ArrayList;
    import javax.swing.JOptionPane; 
    1111
    1212import org.openstreetmap.josm.Main;
    1313import org.openstreetmap.josm.actions.JosmAction;
    14 import org.openstreetmap.josm.gui.layer.Layer;
    1514
    1615public class MenuActionGrabPlanImage extends JosmAction implements Runnable {
    1716
    public class MenuActionGrabPlanImage extends JosmAction implements Runnable { 
    3534    protected void updateEnabledState() {
    3635        if (wmsLayer == null || Main.map == null || Main.map.mapView == null) return;
    3736        if (!rasterImageGeoreferencer.isRunning()) return;
    38         for (Layer l : Main.map.mapView.getAllLayersAsList())
    39             if (l == wmsLayer)
    40                 return;
     37        if (Main.getLayerManager().containsLayer(wmsLayer))
     38                return;
    4139        JOptionPane.showMessageDialog(Main.parent, tr("Georeferencing interrupted"));
    4240        rasterImageGeoreferencer.actionInterrupted();
    4341    }
    4442
    45     public void actionPerformed(ActionEvent ae) {
     43    @Override
     44        public void actionPerformed(ActionEvent ae) {
    4645        if (Main.map != null) {
    4746            if (CadastrePlugin.isCadastreProjection()) {
    4847                wmsLayer = new MenuActionNewLocation().addNewLayer(new ArrayList<WMSLayer>());
    public class MenuActionGrabPlanImage extends JosmAction implements Runnable { 
    5756        }
    5857    }
    5958
    60     public void run() {
     59    @Override
     60        public void run() {
    6161        // wait until plan image is fully loaded and joined into one single image
    6262        boolean loadedFromCache = downloadWMSPlanImage.waitFinished();
    6363        if (loadedFromCache) {
  • cadastre-fr/src/cadastre_fr/MenuActionLoadFromCache.java

    diff --git a/cadastre-fr/src/cadastre_fr/MenuActionLoadFromCache.java b/cadastre-fr/src/cadastre_fr/MenuActionLoadFromCache.java
    index 7c4f214..f29fb34 100644
    a b public class MenuActionLoadFromCache extends JosmAction { 
    6868                    }
    6969                    // check if the selected cache is not already displayed
    7070                    if (Main.map != null) {
    71                         for (Layer l : Main.map.mapView.getAllLayers()) {
     71                        for (Layer l : Main.getLayerManager().getLayers()) {
    7272                            if (l instanceof WMSLayer && l.getName().equals(location)) {
    7373                                JOptionPane.showMessageDialog(Main.parent, tr("The location {0} is already on screen. Cache not loaded.", filename), tr("Error"), JOptionPane.ERROR_MESSAGE);
    7474                                continue nextFile;
  • cadastre-fr/src/cadastre_fr/MenuActionNewLocation.java

    diff --git a/cadastre-fr/src/cadastre_fr/MenuActionNewLocation.java b/cadastre-fr/src/cadastre_fr/MenuActionNewLocation.java
    index 963e2f7..aa09278 100644
    a b public class MenuActionNewLocation extends JosmAction { 
    105105            Main.pref.put("cadastrewms.codeCommune", codeCommune);
    106106            Main.pref.put("cadastrewms.codeDepartement", codeDepartement);
    107107            if (Main.map != null) {
    108                 for (Layer l : Main.map.mapView.getAllLayers()) {
     108                for (Layer l : Main.getLayerManager().getLayers()) {
    109109                    if (l instanceof WMSLayer && l.getName().equalsIgnoreCase(location)) {
    110110                        return null;
    111111                    }
    public class MenuActionNewLocation extends JosmAction { 
    117117            wmsLayer.setDepartement(codeDepartement);
    118118            CadastrePlugin.addWMSLayer(wmsLayer);
    119119            Main.info("Add new layer with Location:" + inputTown.getText());
    120         } else if (existingLayers != null && existingLayers.size() > 0 && Main.map.mapView.getActiveLayer() instanceof WMSLayer) {
    121             wmsLayer = (WMSLayer)Main.map.mapView.getActiveLayer();
     120        } else if (existingLayers != null && existingLayers.size() > 0 && Main.getLayerManager().getActiveLayer() instanceof WMSLayer) {
     121            wmsLayer = (WMSLayer)Main.getLayerManager().getActiveLayer();
    122122        }
    123123
    124124        return wmsLayer;
  • cadastre-fr/src/cadastre_fr/WMSAdjustAction.java

    diff --git a/cadastre-fr/src/cadastre_fr/WMSAdjustAction.java b/cadastre-fr/src/cadastre_fr/WMSAdjustAction.java
    index d400742..e2f817e 100644
    a b public class WMSAdjustAction extends MapMode implements 
    4040
    4141    @Override public void enterMode() {
    4242        if (Main.map != null) {
    43             if (Main.map.mapView.getActiveLayer() instanceof WMSLayer) {
    44                 modifiedLayer = (WMSLayer)Main.map.mapView.getActiveLayer();
     43            if (Main.getLayerManager().getActiveLayer() instanceof WMSLayer) {
     44                modifiedLayer = (WMSLayer)Main.getLayerManager().getActiveLayer();
    4545                super.enterMode();
    4646                Main.map.mapView.addMouseListener(this);
    4747                Main.map.mapView.addMouseMotionListener(this);
  • cadastre-fr/src/cadastre_fr/WMSDownloadAction.java

    diff --git a/cadastre-fr/src/cadastre_fr/WMSDownloadAction.java b/cadastre-fr/src/cadastre_fr/WMSDownloadAction.java
    index c427c04..6700e9d 100644
    a b public class WMSDownloadAction /*extends JosmAction */{ 
    2626        // check if we already have a layer created. if not, create; if yes, reuse.
    2727        ArrayList<WMSLayer> existingWMSlayers = new ArrayList<>();
    2828        if (Main.map != null) {
    29             Layer activeLayer = Main.map.mapView.getActiveLayer();
     29            Layer activeLayer = Main.getLayerManager().getActiveLayer();
    3030            if (activeLayer instanceof WMSLayer)
    3131                return (WMSLayer) activeLayer;
    32             for (Layer l : Main.map.mapView.getAllLayers()) {
     32            for (Layer l : Main.getLayerManager().getLayers()) {
    3333                if (l instanceof WMSLayer) {
    3434                    existingWMSlayers.add((WMSLayer)l);
    3535                }
  • cadastre-fr/src/cadastre_fr/WMSLayer.java

    diff --git a/cadastre-fr/src/cadastre_fr/WMSLayer.java b/cadastre-fr/src/cadastre_fr/WMSLayer.java
    index 42a9be5..045a001 100644
    a b public class WMSLayer extends Layer implements ImageObserver { 
    159159        grabThread.setCanceled(false);
    160160        grabThread.setGrabber(grabber);
    161161        // if it is the first layer, use the communeBBox as grab bbox (and not divided)
    162         if (Main.map.mapView.getAllLayers().size() == 1 ) {
     162        if (Main.getLayerManager().getLayers().size() == 1 ) {
    163163            final Bounds bounds = this.getCommuneBBox().toBounds();
    164164            GuiHelper.runInEDTAndWait(new Runnable() {
    165165                @Override
  • editgpx/src/org/openstreetmap/josm/plugins/editgpx/EditGpxMode.java

    diff --git a/editgpx/src/org/openstreetmap/josm/plugins/editgpx/EditGpxMode.java b/editgpx/src/org/openstreetmap/josm/plugins/editgpx/EditGpxMode.java
    index b19bf33..47ae8ac 100644
    a b public class EditGpxMode extends MapMode implements LayerChangeListener { 
    159159     */
    160160    private void updateLayer() {
    161161
    162         List<EditGpxLayer> layers = Main.map.mapView.getLayersOfType(EditGpxLayer.class);
     162        List<EditGpxLayer> layers = Main.getLayerManager().getLayersOfType(EditGpxLayer.class);
    163163        currentEditLayer = layers.isEmpty()?null:layers.get(0);
    164164
    165165        if(currentEditLayer == null) {
    public class EditGpxMode extends MapMode implements LayerChangeListener { 
    178178        if (oldLayer instanceof EditGpxLayer) {
    179179            currentEditLayer = null;
    180180            if (Main.map.mapMode instanceof EditGpxMode) {
    181                 if (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer) {
     181                if (Main.getLayerManager().getActiveLayer() instanceof OsmDataLayer) {
    182182                    Main.map.selectSelectTool(false);
    183183                } else {
    184184                    Main.map.selectZoomTool(false);
  • editgpx/src/org/openstreetmap/josm/plugins/editgpx/GPXLayerImportAction.java

    diff --git a/editgpx/src/org/openstreetmap/josm/plugins/editgpx/GPXLayerImportAction.java b/editgpx/src/org/openstreetmap/josm/plugins/editgpx/GPXLayerImportAction.java
    index dced68c..e14d438 100644
    a b class GPXLayerImportAction extends AbstractAction { 
    5252        DefaultListModel<GpxLayer> dModel = new DefaultListModel<>();
    5353
    5454        final JList<GpxLayer> layerList = new JList<>(dModel);
    55         Collection<Layer> data = Main.map.mapView.getAllLayers();
     55        Collection<Layer> data = Main.getLayerManager().getLayers();
    5656        int layerCnt = 0;
    5757
    5858        for (Layer l : data){
  • gpsblam/src/org/openstreetmap/josm/plugins/gpsblam/GPSBlamInputData.java

    diff --git a/gpsblam/src/org/openstreetmap/josm/plugins/gpsblam/GPSBlamInputData.java b/gpsblam/src/org/openstreetmap/josm/plugins/gpsblam/GPSBlamInputData.java
    index c1d0748..f0ca6e3 100644
    a b class GPSBlamInputData extends LinkedList<CachedLatLon> { 
    2626    // select a set of GPX points and count how many tracks they have come from,
    2727    // within given radius of line between given points
    2828    GPSBlamInputData(Point p1, Point p2, int radius) {
    29         Collection<Layer> layers = Main.map.mapView.getAllLayers();
     29        Collection<Layer> layers = Main.getLayerManager().getLayers();
    3030        for (Layer l : layers) {
    3131            if (l.isVisible() && l instanceof GpxLayer) {
    3232                for (GpxTrack track : ((GpxLayer)l).data.tracks) {
  • imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/actions/downloadtask/DownloadXmlBoundsTask.java

    diff --git a/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/actions/downloadtask/DownloadXmlBoundsTask.java b/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/actions/downloadtask/DownloadXmlBoundsTask.java
    index 022af80..1acbcf5 100644
    a b public class DownloadXmlBoundsTask extends DownloadOsmTask implements XmlBoundsC 
    7272        protected int getNumDataLayers() {
    7373            int count = 0;
    7474            if (!Main.isDisplayingMapView()) return 0;
    75             for (Layer layer : Main.map.mapView.getAllLayers()) {
     75            for (Layer layer : Main.getLayerManager().getLayers()) {
    7676                if (layer instanceof XmlBoundsLayer) {
    7777                    count++;
    7878                }
    public class DownloadXmlBoundsTask extends DownloadOsmTask implements XmlBoundsC 
    8383        @Override
    8484        protected OsmDataLayer getFirstDataLayer() {
    8585            if (!Main.isDisplayingMapView()) return null;
    86             for (Layer layer : Main.map.mapView.getAllLayersAsList()) {
     86            for (Layer layer : Main.getLayerManager().getLayers()) {
    8787                if (layer instanceof XmlBoundsLayer)
    8888                    return (XmlBoundsLayer) layer;
    8989            }
  • imagery_offset_db/src/iodb/ImageryOffsetTools.java

    diff --git a/imagery_offset_db/src/iodb/ImageryOffsetTools.java b/imagery_offset_db/src/iodb/ImageryOffsetTools.java
    index 28d3aeb..46a159c 100644
    a b public class ImageryOffsetTools { 
    2929    public static ImageryLayer getTopImageryLayer() {
    3030        if( Main.map == null || Main.map.mapView == null )
    3131            return null;
    32         List<ImageryLayer> layers = Main.map.mapView.getLayersOfType(ImageryLayer.class);
     32        List<ImageryLayer> layers = Main.getLayerManager().getLayersOfType(ImageryLayer.class);
    3333        for( ImageryLayer layer : layers ) {
    3434            String url = layer.getInfo().getUrl();
    3535            if( layer.isVisible() && url != null && !url.contains("gps-") ) {
  • imageryadjust/src/imageryadjust/ImageryAdjustMapMode.java

    diff --git a/imageryadjust/src/imageryadjust/ImageryAdjustMapMode.java b/imageryadjust/src/imageryadjust/ImageryAdjustMapMode.java
    index a1defb6..aed80b3 100644
    a b public class ImageryAdjustMapMode extends MapMode implements MouseListener, Mous 
    5353    }
    5454   
    5555    private List<? extends Layer> getVisibleLayers() {
    56         List<? extends Layer> all = new ArrayList<Layer>(Main.map.mapView.getLayersOfType(ImageryLayer.class));
     56        List<? extends Layer> all = new ArrayList<Layer>(Main.getLayerManager().getLayersOfType(ImageryLayer.class));
    5757        Iterator<? extends Layer> it = all.iterator();
    5858        while (it.hasNext()) {
    5959            if (!it.next().isVisible()) it.remove();
    public class ImageryAdjustMapMode extends MapMode implements MouseListener, Mous 
    7575            warnNoImageryLayers();
    7676            return;
    7777        }
    78         List<ImageryLayer> layers = Main.map.mapView.getLayersOfType(ImageryLayer.class);
     78        List<ImageryLayer> layers = Main.getLayerManager().getLayersOfType(ImageryLayer.class);
    7979        if (layers.size() == 1) {
    8080            adjustingLayer = layers.get(0);
    8181        } else {
    public class ImageryAdjustMapMode extends MapMode implements MouseListener, Mous 
    158158                return false;
    159159            if (Main.map.mapView == null)
    160160                return false;
    161             return Main.map.mapView.getActiveLayer() == layer;
     161            return Main.getLayerManager().getActiveLayer() == layer;
    162162        }
    163163
    164164        @Override
    public class ImageryAdjustMapMode extends MapMode implements MouseListener, Mous 
    229229    protected boolean hasImageryLayersToAdjust() {
    230230        if (Main.map == null) return false;
    231231        if (Main.map.mapView == null) return false;
    232         boolean b = ! Main.map.mapView.getLayersOfType(ImageryLayer.class).isEmpty();
     232        boolean b = ! Main.getLayerManager().getLayersOfType(ImageryLayer.class).isEmpty();
    233233        return b;
    234234    }
    235235
  • imagewaypoint/src/org/insignificant/josm/plugins/imagewaypoint/ImageEntries.java

    diff --git a/imagewaypoint/src/org/insignificant/josm/plugins/imagewaypoint/ImageEntries.java b/imagewaypoint/src/org/insignificant/josm/plugins/imagewaypoint/ImageEntries.java
    index 8845717..63af2b0 100644
    a b public final class ImageEntries { 
    7575        this.locatedImages.clear();
    7676
    7777        if (null != Main.map && null != Main.map.mapView) {
    78             final Collection<Layer> layerCollection = Main.map.mapView.getAllLayers();
     78            final Collection<Layer> layerCollection = Main.getLayerManager().getLayers();
    7979            final Layer[] layers = layerCollection.toArray(new Layer[layerCollection.size()]);
    8080
    8181            for (int index = 0; index < layers.length; index++) {
  • imagewaypoint/src/org/insignificant/josm/plugins/imagewaypoint/ImageWayPointPlugin.java

    diff --git a/imagewaypoint/src/org/insignificant/josm/plugins/imagewaypoint/ImageWayPointPlugin.java b/imagewaypoint/src/org/insignificant/josm/plugins/imagewaypoint/ImageWayPointPlugin.java
    index 753b410..4ac1d5e 100644
    a b public final class ImageWayPointPlugin extends org.openstreetmap.josm.plugins.Pl 
    6969                // check to see whether there's already an ImageWayPointLayer
    7070                boolean foundImageWayPointLayer = false;
    7171                if (null != Main.map && null != Main.map.mapView) {
    72                     final Collection<Layer> layerCollection = Main.map.mapView.getAllLayers();
     72                    final Collection<Layer> layerCollection = Main.getLayerManager().getLayers();
    7373                    final Iterator<Layer> layerIterator = layerCollection.iterator();
    7474                    while (layerIterator.hasNext() && !foundImageWayPointLayer) {
    7575                        if (layerIterator.next() instanceof ImageWayPointLayer) {
  • irsrectify/src/irsrectify/IRSRectifyPlugin.java

    diff --git a/irsrectify/src/irsrectify/IRSRectifyPlugin.java b/irsrectify/src/irsrectify/IRSRectifyPlugin.java
    index 267c462..636e136 100644
    a b public class IRSRectifyPlugin extends Plugin { 
    7373            data.data.addPrimitive(offset);
    7474            data.data.addPrimitive(way);
    7575            data.data.setSelected(way.getPrimitiveId());
    76             frame.mapView.setActiveLayer(data);
     76            Main.getLayerManager().setActiveLayer(data);
    7777        }
    7878
    7979        private ImageryLayer findImageryLayer() {
    8080            if( frame == null || frame.mapView == null )
    8181                return null;
    82             for( Layer l : frame.mapView.getAllLayers() )
     82            for( Layer l : Main.getLayerManager().getLayers() )
    8383                if( l instanceof ImageryLayer )
    8484                    return (ImageryLayer)l;
    8585            return null;
    public class IRSRectifyPlugin extends Plugin { 
    8989            if( frame == null || frame.mapView == null )
    9090                return null;
    9191
    92             OsmDataLayer l = frame.mapView.getEditLayer();
     92            OsmDataLayer l = Main.getLayerManager().getEditLayer();
    9393            if( isOffsetLayer(l) )
    9494                return l;
    9595
    9696            // try to find among all layers
    97             for( Layer layer : frame.mapView.getAllLayers() )
     97            for( Layer layer : Main.getLayerManager().getLayers() )
    9898                if( layer instanceof OsmDataLayer && isOffsetLayer((OsmDataLayer)layer) )
    9999                    return (OsmDataLayer) layer;
    100100
  • junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/DigraphCreationTask.java

    diff --git a/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/DigraphCreationTask.java b/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/DigraphCreationTask.java
    index a58f2ad..d13d85e 100644
    a b public class DigraphCreationTask extends PleaseWaitRunnable { 
    6464    OsmTransferException {
    6565        //Prüfen, ob der ausgewählte Layer ein OSMDataLayer ist
    6666        if (Main.map == null
    67                 || !Main.map.isVisible() || !(Main.map.mapView.getActiveLayer() instanceof OsmDataLayer)) {
     67                || !Main.map.isVisible() || !(Main.getLayerManager().getActiveLayer() instanceof OsmDataLayer)) {
    6868            JOptionPane.showMessageDialog(Main.parent, tr("this layer is no osm data layer"));
    6969            return;
    7070        }
    public class DigraphCreationTask extends PleaseWaitRunnable { 
    8383
    8484        OSMGraph graph = new OSMGraph();
    8585        //Der vom Benutzer in JOSM ausgewählte, zur Zeit aktive Layer wird der PLugin-OSM-Layer
    86         plugin.setOsmlayer((OsmDataLayer)Main.map.mapView.getActiveLayer());
     86        plugin.setOsmlayer((OsmDataLayer)Main.getLayerManager().getActiveLayer());
    8787        Iterator<Node> it = Main.main.getCurrentDataSet().getNodes().iterator();
    8888        while (it.hasNext()) {
    8989            graph.addNode(it.next());
    public class DigraphCreationTask extends PleaseWaitRunnable { 
    146146        plugin.setNormalMapMode(Main.map.mapMode);
    147147        Main.map.selectMapMode(plugin.getJcMapMode());
    148148        Main.main.addLayer(plugin.getChannelDigraphLayer());
    149         Main.map.mapView.setActiveLayer(plugin.getChannelDigraphLayer());
     149        Main.getLayerManager().setActiveLayer(plugin.getChannelDigraphLayer());
    150150    }
    151151}
  • junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/JunctionCheckTask.java

    diff --git a/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/JunctionCheckTask.java b/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/JunctionCheckTask.java
    index a133220..5e4169d 100644
    a b public class JunctionCheckTask extends PleaseWaitRunnable{ 
    9090        for (int i = 0; i < jc.getSubJunction().size(); i++) {
    9191            plugin.getChannelDigraph().addJunctioncandidateChannel(jc.getSubJunction().get(i));
    9292        }
    93         Main.map.mapView.setActiveLayer(plugin.getChannelDigraphLayer());
     93        Main.getLayerManager().setActiveLayer(plugin.getChannelDigraphLayer());
    9494    }
    9595}
  • junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/util/RelationProducer.java

    diff --git a/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/util/RelationProducer.java b/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/util/RelationProducer.java
    index 6bb8d89..e319a1d 100644
    a b public class RelationProducer { 
    4141                        .getId(), OsmPrimitiveType.WAY));
    4242            }
    4343        }
    44         Main.map.mapView.setActiveLayer(plugin.getOsmlayer());
     44        Main.getLayerManager().setActiveLayer(plugin.getOsmlayer());
    4545        plugin.getOsmlayer().data.setSelected(ways);
    4646
    4747        Relation jrelation = new Relation();
  • mapdust/src/org/openstreetmap/josm/plugins/mapdust/MapdustPlugin.java

    diff --git a/mapdust/src/org/openstreetmap/josm/plugins/mapdust/MapdustPlugin.java b/mapdust/src/org/openstreetmap/josm/plugins/mapdust/MapdustPlugin.java
    index c7448a6..3ce056b 100644
    a b public class MapdustPlugin extends Plugin implements LayerChangeListener, 
    362362        if (mapdustLayer != null && mapdustLayer.isVisible()) {
    363363            if (event.getButton() == MouseEvent.BUTTON1) {
    364364                if (event.getClickCount() == 2 && !event.isConsumed()) {
    365                     if (Main.map.mapView.getActiveLayer() == getMapdustLayer()) {
     365                    if (Main.getLayerManager().getActiveLayer() == getMapdustLayer()) {
    366366                        /* show add bug dialog */
    367367                        MapdustBug bug = mapdustGUI.getSelectedBug();
    368368                        if (bug != null) {
    public class MapdustPlugin extends Plugin implements LayerChangeListener, 
    619619     * <code>MapdustLayer</code> false otherwise
    620620     */
    621621    private boolean containsMapdustLayer() {
    622         boolean contains = false;
    623         List<Layer> all = Main.map.mapView.getAllLayersAsList();
    624         if (mapdustLayer != null && all.contains(mapdustLayer)) {
    625             contains = true;
    626         }
    627         return contains;
     622        return mapdustLayer != null && Main.getLayerManager().containsLayer(mapdustLayer);
    628623    }
    629624
    630625    /**
  • mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java

    diff --git a/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java b/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
    index 2671966..b23d77c 100644
    a b public final class MapillaryLayer extends AbstractModifiableLayer implements 
    110110      Main.map.mapView.addLayer(this);
    111111      MapView.addEditLayerChangeListener(this, false);
    112112      MapView.addLayerChangeListener(this);
    113       if (Main.map.mapView.getEditLayer() != null)
    114         Main.map.mapView.getEditLayer().data.addDataSetListener(this);
     113      if (Main.getLayerManager().getEditLayer() != null)
     114        Main.getLayerManager().getEditLayer().data.addDataSetListener(this);
    115115      if (MapillaryDownloader.getMode() == MapillaryDownloader.MODES.Automatic)
    116116        MapillaryDownloader.automaticDownload();
    117117      if (MapillaryDownloader.getMode() == MapillaryDownloader.MODES.Semiautomatic)
    public final class MapillaryLayer extends AbstractModifiableLayer implements 
    222222    Main.map.mapView.removeMouseListener(this.mode);
    223223    Main.map.mapView.removeMouseMotionListener(this.mode);
    224224    MapView.removeEditLayerChangeListener(this);
    225     if (Main.map.mapView.getEditLayer() != null)
    226       Main.map.mapView.getEditLayer().data.removeDataSetListener(this);
     225    if (Main.getLayerManager().getEditLayer() != null)
     226      Main.getLayerManager().getEditLayer().data.removeDataSetListener(this);
    227227    clearInstance();
    228228    super.destroy();
    229229  }
    public final class MapillaryLayer extends AbstractModifiableLayer implements 
    285285  @Override
    286286  public synchronized void paint(final Graphics2D g, final MapView mv, final Bounds box) {
    287287    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    288     if (Main.map.mapView.getActiveLayer() == this) {
     288    if (Main.getLayerManager().getActiveLayer() == this) {
    289289      // paint remainder
    290290      g.setPaint(this.hatched);
    291291      g.fill(MapViewGeometryUtil.getNonDownloadedArea(mv, this.data.getBounds()));
    public final class MapillaryLayer extends AbstractModifiableLayer implements 
    322322    if (selectedImage != null && selectedImage.getSequence() != null) {
    323323      selectedImageKey = selectedImage.getSequence().getKey();
    324324    }
    325     g.setStroke(new BasicStroke(this == Main.map.mapView.getActiveLayer() ? 3 : 2));
     325    g.setStroke(new BasicStroke(this == Main.getLayerManager().getActiveLayer() ? 3 : 2));
    326326    for (MapillarySequence seq : getData().getSequences()) {
    327327      if (selectedImageKey != null && selectedImageKey.equals(seq.getKey())) {
    328328        g.setColor(Color.MAGENTA.brighter());
  • mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryDownloadAction.java

    diff --git a/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryDownloadAction.java b/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryDownloadAction.java
    index e957b1d..add64d0 100644
    a b public class MapillaryDownloadAction extends JosmAction { 
    4747      return;
    4848    }
    4949    // Successive calls to this action toggle the active layer between the OSM data layer and the mapillary layer
    50     Main.map.mapView.setActiveLayer(
    51         Main.map.mapView.getActiveLayer() == MapillaryLayer.getInstance()
    52           ? Main.map.mapView.getEditLayer()
     50    Main.getLayerManager().setActiveLayer(
     51        Main.getLayerManager().getActiveLayer() == MapillaryLayer.getInstance()
     52          ? Main.getLayerManager().getEditLayer()
    5353          : MapillaryLayer.getInstance()
    5454    );
    5555  }
  • mapillary/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillaryDownloader.java

    diff --git a/mapillary/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillaryDownloader.java b/mapillary/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillaryDownloader.java
    index 06a8a5a..b3b22ee 100644
    a b public final class MapillaryDownloader { 
    151151   */
    152152  public static void automaticDownload() {
    153153    MapillaryLayer layer = MapillaryLayer.getInstance();
    154     if (Main.map.mapView.getEditLayer() == null)
     154    if (Main.getLayerManager().getEditLayer() == null)
    155155      return;
    156156    if (isAreaTooBig()) {
    157157      tooBigErrorDialog();
    public final class MapillaryDownloader { 
    159159    }
    160160    if (getMode() != MODES.Automatic)
    161161      throw new IllegalStateException("Must be in automatic mode.");
    162     for (Bounds bounds : Main.map.mapView.getEditLayer().data
     162    for (Bounds bounds : Main.getLayerManager().getEditLayer().data
    163163        .getDataSourceBounds()) {
    164164      if (!layer.getData().getBounds().contains(bounds)) {
    165165        layer.getData().getBounds().add(bounds);
    public final class MapillaryDownloader { 
    176176   */
    177177  private static boolean isAreaTooBig() {
    178178    double area = 0;
    179     for (Bounds bounds : Main.map.mapView.getEditLayer().data.getDataSourceBounds()) {
     179    for (Bounds bounds : Main.getLayerManager().getEditLayer().data.getDataSourceBounds()) {
    180180      area += bounds.getArea();
    181181    }
    182182    return area > MAX_AREA;
  • mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/JoinMode.java

    diff --git a/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/JoinMode.java b/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/JoinMode.java
    index 0ede5ef..ae672fb 100644
    a b public class JoinMode extends AbstractMode { 
    7070  @Override
    7171  public void mouseMoved(MouseEvent e) {
    7272    this.lastPos = e;
    73     if (!(Main.map.mapView.getActiveLayer() instanceof MapillaryLayer))
     73    if (!(Main.getLayerManager().getActiveLayer() instanceof MapillaryLayer))
    7474      return;
    7575    MapillaryAbstractImage closestTemp = getClosest(e.getPoint());
    7676    this.data.setHighlightedImage(closestTemp);
  • mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/SelectMode.java

    diff --git a/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/SelectMode.java b/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/SelectMode.java
    index 8c9edd9..64285cb 100644
    a b public class SelectMode extends AbstractMode { 
    5151    if (e.getButton() != MouseEvent.BUTTON1)
    5252      return;
    5353    MapillaryAbstractImage closest = getClosest(e.getPoint());
    54     if (!(Main.map.mapView.getActiveLayer() instanceof MapillaryLayer)
     54    if (!(Main.getLayerManager().getActiveLayer() instanceof MapillaryLayer)
    5555            && closest != null && Main.map.mapMode == Main.map.mapModeSelect) {
    5656      this.lastClicked = this.closest;
    5757      this.data.setSelectedImage(closest);
    5858      return;
    59     } else if (Main.map.mapView.getActiveLayer() != MapillaryLayer
     59    } else if (Main.getLayerManager().getActiveLayer() != MapillaryLayer
    6060            .getInstance())
    6161      return;
    6262    // Double click
    public class SelectMode extends AbstractMode { 
    9797
    9898  @Override
    9999  public void mouseDragged(MouseEvent e) {
    100     if (Main.map.mapView.getActiveLayer() != MapillaryLayer.getInstance()) {
     100    if (Main.getLayerManager().getActiveLayer() != MapillaryLayer.getInstance()) {
    101101      return;
    102102    }
    103103
    public class SelectMode extends AbstractMode { 
    155155   */
    156156  @Override
    157157  public void mouseMoved(MouseEvent e) {
    158     if (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer
     158    if (Main.getLayerManager().getActiveLayer() instanceof OsmDataLayer
    159159            && Main.map.mapMode != Main.map.mapModeSelect) {
    160160      return;
    161161    }
    public class SelectMode extends AbstractMode { 
    166166    MapillaryAbstractImage closestTemp = getClosest(e.getPoint());
    167167
    168168    if (closestTemp != null
    169             && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer
     169            && Main.getLayerManager().getActiveLayer() instanceof OsmDataLayer
    170170            && !this.imageHighlighted) {
    171171      Main.map.mapMode.putValue("active", Boolean.FALSE);
    172172      this.imageHighlighted = true;
    173173
    174174    } else if (closestTemp == null
    175             && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer
     175            && Main.getLayerManager().getActiveLayer() instanceof OsmDataLayer
    176176            && this.imageHighlighted && this.nothingHighlighted) {
    177177      this.nothingHighlighted = false;
    178178      Main.map.mapMode.putValue("active", Boolean.TRUE);
    179179
    180180    } else if (this.imageHighlighted && !this.nothingHighlighted
    181             && Main.map.mapView.getEditLayer().data != null
    182             && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer) {
     181            && Main.getLayerManager().getEditLayer().data != null
     182            && Main.getLayerManager().getActiveLayer() instanceof OsmDataLayer) {
    183183
    184       for (OsmPrimitive primivitive : Main.map.mapView.getEditLayer().data
     184      for (OsmPrimitive primivitive : Main.getLayerManager().getEditLayer().data
    185185              .allPrimitives()) {
    186186        primivitive.setHighlighted(false);
    187187      }
  • measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementLayer.java

    diff --git a/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementLayer.java b/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementLayer.java
    index be5afb7..0db4910 100644
    a b public class MeasurementLayer extends Layer { 
    233233        public void actionPerformed(ActionEvent e) {
    234234            Box panel = Box.createVerticalBox();
    235235            final JList<GpxLayer> layerList = new JList<>(model);
    236             Collection<Layer> data = Main.map.mapView.getAllLayers();
     236            Collection<Layer> data = Main.getLayerManager().getLayers();
    237237            Layer lastLayer = null;
    238238            int layerCnt = 0;
    239239
  • opendata/src/org/openstreetmap/josm/plugins/opendata/core/layers/OdDataLayer.java

    diff --git a/opendata/src/org/openstreetmap/josm/plugins/opendata/core/layers/OdDataLayer.java b/opendata/src/org/openstreetmap/josm/plugins/opendata/core/layers/OdDataLayer.java
    index 6a27cd6..4a6d5f2 100644
    a b public class OdDataLayer extends OsmDataLayer implements OdLayer, LayerChangeLis 
    9191            DataSet dataSet = new DataSet();
    9292            final OdOsmDataLayer layer = new OdOsmDataLayer(this, dataSet, getName()+"/OSM");
    9393            addOsmLayer(layer);
    94             Main.map.mapView.setActiveLayer(osmLayer);
     94            Main.getLayerManager().setActiveLayer(osmLayer);
    9595            if (oapiReq != null) {
    9696                OsmDownloader.downloadOapi(oapiReq);
    9797                // Overpass API does not allow to exclude tags :(
    public class OdDataLayer extends OsmDataLayer implements OdLayer, LayerChangeLis 
    173173    public void makeDiff() {
    174174        final OdDiffLayer layer = new OdDiffLayer(this, getName()+"/Diff");
    175175        addDiffLayer(layer);
    176         Main.map.mapView.setActiveLayer(diffLayer);
     176        Main.getLayerManager().setActiveLayer(diffLayer);
    177177    }
    178178}
  • photoadjust/src/org/openstreetmap/josm/plugins/photoadjust/PhotoAdjustMapMode.java

    diff --git a/photoadjust/src/org/openstreetmap/josm/plugins/photoadjust/PhotoAdjustMapMode.java b/photoadjust/src/org/openstreetmap/josm/plugins/photoadjust/PhotoAdjustMapMode.java
    index 69b2697..aa0fcd5 100644
    a b public class PhotoAdjustMapMode extends MapMode implements LayerChangeListener { 
    132132        // Activate the mode only if the current layer is not a
    133133        // GeoImageLayer.  GeoImageLayer's are handled by the plug-in
    134134        // directly.
    135         if (! (Main.map.mapView.getActiveLayer() instanceof GeoImageLayer)) {
     135        if (! (Main.getLayerManager().getActiveLayer() instanceof GeoImageLayer)) {
    136136            activateMode();
    137137        }
    138138    }
    public class PhotoAdjustMapMode extends MapMode implements LayerChangeListener { 
    207207     */
    208208    private boolean hasLayersToAdjust() {
    209209        if (Main.map == null || Main.map.mapView == null) return false;
    210         return ! Main.map.mapView.getLayersOfType(GeoImageLayer.class).isEmpty();
     210        return ! Main.getLayerManager().getLayersOfType(GeoImageLayer.class).isEmpty();
    211211    }
    212212
    213213    /**
    public class PhotoAdjustMapMode extends MapMode implements LayerChangeListener { 
    216216     * @return list of visible GeoImageLayer's
    217217     */
    218218    private List<GeoImageLayer> getVisibleGeoImageLayers() {
    219         List<GeoImageLayer> all = new ArrayList<>(Main.map.mapView.getLayersOfType(GeoImageLayer.class));
     219        List<GeoImageLayer> all = new ArrayList<>(Main.getLayerManager().getLayersOfType(GeoImageLayer.class));
    220220        Iterator<GeoImageLayer> it = all.iterator();
    221221        while (it.hasNext()) {
    222222            if (!it.next().isVisible()) it.remove();
  • piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerPlugin.java

    diff --git a/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerPlugin.java b/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerPlugin.java
    index 11ee943..40648e4 100644
    a b public class PicLayerPlugin extends Plugin implements LayerChangeListener { 
    158158                new SavePictureCalibrationAction((PicLayerAbstract) arg0).actionPerformed(null);
    159159        }
    160160        // Why should I do all these checks now?
    161         boolean enable = Main.map != null && Main.map.mapView != null && Main.map.mapView.getAllLayers() != null && Main.map.mapView.getAllLayers().size() != 0;
     161        boolean enable = Main.map != null && Main.map.mapView != null && Main.getLayerManager().getLayers() != null && Main.getLayerManager().getLayers().size() != 0;
    162162        newLayerFromFileAction.setEnabled(enable);
    163163        newLayerFromClipboardAction.setEnabled(enable);
    164164    }
  • piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/GenericPicTransformAction.java

    diff --git a/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/GenericPicTransformAction.java b/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/GenericPicTransformAction.java
    index 22a08e2..7fa86d4 100644
    a b public abstract class GenericPicTransformAction extends MapMode implements Mouse 
    5656    @Override
    5757    public void mousePressed(MouseEvent e) {
    5858        // Start action
    59         if ( Main.map.mapView.getActiveLayer() instanceof PicLayerAbstract ) {
    60             currentLayer = (PicLayerAbstract)Main.map.mapView.getActiveLayer();
     59        if ( Main.getLayerManager().getActiveLayer() instanceof PicLayerAbstract ) {
     60            currentLayer = (PicLayerAbstract)Main.getLayerManager().getActiveLayer();
    6161
    6262            if ( currentLayer != null && e.getButton() == MouseEvent.BUTTON1 ) {
    6363                requestFocusInMapView();
    public abstract class GenericPicTransformAction extends MapMode implements Mouse 
    9898    }
    9999
    100100    protected void updateDrawPoints(boolean value) {
    101         Layer active = Main.map.mapView.getActiveLayer();
     101        Layer active = Main.getLayerManager().getActiveLayer();
    102102        if (active instanceof PicLayerAbstract) {
    103103            ((PicLayerAbstract)active).setDrawPoints(value);
    104104        }
  • piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/newlayer/NewLayerFromFileAction.java

    diff --git a/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/newlayer/NewLayerFromFileAction.java b/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/newlayer/NewLayerFromFileAction.java
    index 0b94f8f..783af67 100644
    a b public class NewLayerFromFileAction extends JosmAction { 
    118118            // The first loaded layer will be placed at the top of any other layer of the same class,
    119119            // or at the bottom of the stack if there is no such layer yet
    120120            // The next layers we load will be placed one after the other after this first layer
    121             int newLayerPos = Main.map.mapView.getAllLayers().size();
    122             for(Layer l : Main.map.mapView.getLayersOfType(PicLayerAbstract.class)) {
     121            int newLayerPos = Main.getLayerManager().getLayers().size();
     122            for(Layer l : Main.getLayerManager().getLayersOfType(PicLayerAbstract.class)) {
    123123                int pos = Main.map.mapView.getLayerPos(l);
    124124                if (pos < newLayerPos) newLayerPos = pos;
    125125            }
  • rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/RasterFiltersPlugin.java

    diff --git a/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/RasterFiltersPlugin.java b/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/RasterFiltersPlugin.java
    index 0f65426..3a2a23f 100644
    a b public class RasterFiltersPlugin extends Plugin implements LayerChangeListener { 
    118118                        action.removeFiltersDialog(dialog);
    119119                }
    120120
    121                 if (Main.map.mapView.getAllLayersAsList().size() == 0) {
     121                if (Main.getLayerManager().getLayers().size() == 0) {
    122122
    123123                        Container container = filterButton.getParent();
    124124                        if (container != null)
  • rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/actions/ShowLayerFiltersDialog.java

    diff --git a/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/actions/ShowLayerFiltersDialog.java b/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/actions/ShowLayerFiltersDialog.java
    index 5cc303a..fe91082 100644
    a b public final class ShowLayerFiltersDialog extends AbstractAction implements Laye 
    5050        @Override
    5151        public void actionPerformed(ActionEvent e) {
    5252
    53                 Layer layer = Main.map.mapView.getActiveLayer();
     53                Layer layer = Main.getLayerManager().getActiveLayer();
    5454
    5555                if (layer instanceof ImageryLayer) {
    5656                        for (FiltersDialog temp : dialogs) {
  • rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/model/FiltersManager.java

    diff --git a/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/model/FiltersManager.java b/rasterfilters/src/org/openstreetmap/josm/plugins/rasterfilters/model/FiltersManager.java
    index b8c083e..10aa05a 100644
    a b ActionListener, ItemListener { 
    130130                fp.setPreferredSize(new Dimension(300, fp.getNeededHeight()));
    131131
    132132                filter.changeFilterState(filterState.encodeJson());
    133                 Main.map.mapView.getActiveLayer().setFilterStateChanged();
     133                Main.getLayerManager().getActiveLayer().setFilterStateChanged();
    134134
    135135                fp.createBottomPanel(this);
    136136
    ActionListener, ItemListener { 
    154154                if (filtersMap.get(filterId) != null)
    155155                        filtersMap.get(filterId).changeFilterState(filterState.encodeJson());
    156156
    157                 if (Main.map.mapView.getActiveLayer() != null) {
    158                         Main.map.mapView.getActiveLayer().setFilterStateChanged();
     157                if (Main.getLayerManager().getActiveLayer() != null) {
     158                        Main.getLayerManager().getActiveLayer().setFilterStateChanged();
    159159                }
    160160
    161161        }
    ActionListener, ItemListener { 
    238238                        dialog.getAddButton().setEnabled(true);
    239239                }
    240240
    241                 Main.map.mapView.getActiveLayer().setFilterStateChanged();
     241                Main.getLayerManager().getActiveLayer().setFilterStateChanged();
    242242
    243243        }
    244244
    ActionListener, ItemListener { 
    254254                        UID filterId = filterPanel.getFilterId();
    255255                        disabledFilters.add(filtersMap.get(filterId));
    256256
    257                         Main.map.mapView.getActiveLayer().setFilterStateChanged();
     257                        Main.getLayerManager().getActiveLayer().setFilterStateChanged();
    258258
    259259                } else {
    260260
    261261                        UID filterId = filterPanel.getFilterId();
    262262                        disabledFilters.remove(filtersMap.get(filterId));
    263263
    264                         Main.map.mapView.getActiveLayer().setFilterStateChanged();
     264                        Main.getLayerManager().getActiveLayer().setFilterStateChanged();
    265265
    266266                }
    267267        }
  • routes/src/org/openstreetmap/josm/plugins/routes/RoutesPlugin.java

    diff --git a/routes/src/org/openstreetmap/josm/plugins/routes/RoutesPlugin.java b/routes/src/org/openstreetmap/josm/plugins/routes/RoutesPlugin.java
    index 83f8c27..ffac4fa 100644
    a b public class RoutesPlugin extends Plugin implements LayerChangeListener { 
    7878
    7979    private void checkLayers() {
    8080        if (Main.map != null && Main.map.mapView != null) {
    81             for (Layer layer:Main.map.mapView.getAllLayers()) {
     81            for (Layer layer:Main.getLayerManager().getLayers()) {
    8282                if (layer instanceof OsmDataLayer) {
    8383                    if (!isShown) {
    8484                        isShown = true;
  • routing/src/com/innovant/josm/jrt/core/RoutingGraph.java

    diff --git a/routing/src/com/innovant/josm/jrt/core/RoutingGraph.java b/routing/src/com/innovant/josm/jrt/core/RoutingGraph.java
    index f0ac693..fba2b2d 100644
    a b public class RoutingGraph { 
    349349        List<OsmEdge> path = new ArrayList<>();
    350350        Graph<Node,OsmEdge> g;
    351351        double totalWeight = 0;
    352         RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
     352        RoutingLayer layer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
    353353        RoutingModel routingModel = layer.getRoutingModel();
    354354
    355355        if (graph == null || routingModel.getOnewayChanged())
  • routing/src/com/innovant/josm/plugin/routing/actions/AddRouteNodeAction.java

    diff --git a/routing/src/com/innovant/josm/plugin/routing/actions/AddRouteNodeAction.java b/routing/src/com/innovant/josm/plugin/routing/actions/AddRouteNodeAction.java
    index ccb59d6..acdb4b5 100644
    a b public class AddRouteNodeAction extends MapMode { 
    8282        if (e.getButton() == MouseEvent.BUTTON1) {
    8383            // Search for nearest highway node
    8484            Node node = null;
    85             if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
    86                 RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
     85            if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
     86                RoutingLayer layer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
    8787                node = layer.getNearestHighwayNode(e.getPoint());
    8888                if(node == null) {
    8989                    logger.debug("no selected node");
  • routing/src/com/innovant/josm/plugin/routing/actions/MoveRouteNodeAction.java

    diff --git a/routing/src/com/innovant/josm/plugin/routing/actions/MoveRouteNodeAction.java b/routing/src/com/innovant/josm/plugin/routing/actions/MoveRouteNodeAction.java
    index 10a8d12..55aabd6 100644
    a b public class MoveRouteNodeAction extends MapMode { 
    9595    @Override public void mousePressed(MouseEvent e) {
    9696        // If left button is pressed
    9797        if (e.getButton() == MouseEvent.BUTTON1) {
    98             if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
     98            if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
    9999                requestFocusInMapView();
    100                 RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
     100                RoutingLayer layer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
    101101                RoutingModel routingModel = layer.getRoutingModel();
    102102                // Search for the nearest node in the list
    103103                List<Node> nl = routingModel.getSelectedNodes();
    public class MoveRouteNodeAction extends MapMode { 
    128128    }
    129129
    130130    private void searchAndReplaceNode(Point point) {
    131         if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
    132             RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
     131        if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
     132            RoutingLayer layer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
    133133            RoutingModel routingModel = layer.getRoutingModel();
    134134            RoutingDialog routingDialog = RoutingPlugin.getInstance().getRoutingDialog();
    135135            // Search for nearest highway node
  • routing/src/com/innovant/josm/plugin/routing/actions/RemoveRouteNodeAction.java

    diff --git a/routing/src/com/innovant/josm/plugin/routing/actions/RemoveRouteNodeAction.java b/routing/src/com/innovant/josm/plugin/routing/actions/RemoveRouteNodeAction.java
    index 0b4193a..50bb001 100644
    a b public class RemoveRouteNodeAction extends MapMode { 
    8383    @Override public void mouseClicked(MouseEvent e) {
    8484        // If left button is clicked
    8585        if (e.getButton() == MouseEvent.BUTTON1) {
    86             if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
    87                 RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
     86            if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
     87                RoutingLayer layer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
    8888                RoutingModel routingModel = layer.getRoutingModel();
    8989                // Search for the nearest node in the list
    9090                List<Node> nl = routingModel.getSelectedNodes();
  • routing/src/com/innovant/josm/plugin/routing/gui/RoutingDialog.java

    diff --git a/routing/src/com/innovant/josm/plugin/routing/gui/RoutingDialog.java b/routing/src/com/innovant/josm/plugin/routing/gui/RoutingDialog.java
    index 792d0b4..2782823 100644
    a b public class RoutingDialog extends ToggleDialog { 
    130130
    131131    public void refresh() {
    132132        clearNodes();
    133         if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
    134             RoutingLayer routingLayer = (RoutingLayer)Main.map.mapView.getActiveLayer();
     133        if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
     134            RoutingLayer routingLayer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
    135135            RoutingModel routingModel = routingLayer.getRoutingModel();
    136136            for (Node n : routingModel.getSelectedNodes()) {
    137137                addNode(n);
  • routing/src/com/innovant/josm/plugin/routing/gui/RoutingMenu.java

    diff --git a/routing/src/com/innovant/josm/plugin/routing/gui/RoutingMenu.java b/routing/src/com/innovant/josm/plugin/routing/gui/RoutingMenu.java
    index c4c24f7..9bd84cd 100644
    a b public class RoutingMenu extends JMenu { 
    9292        rshorter.setSelected(true);
    9393        rshorter.addItemListener(new ItemListener() {
    9494            public void itemStateChanged(ItemEvent e) {
    95                 if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
    96                     RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
     95                if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
     96                    RoutingLayer layer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
    9797                    RoutingModel routingModel = layer.getRoutingModel();
    9898                    if (e.getStateChange()==ItemEvent.SELECTED) {
    9999                        routingModel.routingGraph.setTypeRoute(RouteType.SHORTEST);
    public class RoutingMenu extends JMenu { 
    121121        JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(tr("Ignore oneways"));
    122122        cbmi.addItemListener(new ItemListener() {
    123123            public void itemStateChanged(ItemEvent e) {
    124                 if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
    125                     RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
     124                if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
     125                    RoutingLayer layer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
    126126                    RoutingModel routingModel = layer.getRoutingModel();
    127127                    if (e.getStateChange()==ItemEvent.SELECTED)
    128128                        routingModel.routingGraph.getRoutingProfile().setOnewayUse(false);
    public class RoutingMenu extends JMenu { 
    141141        reverseMI = new JMenuItem(tr("Reverse route"));
    142142        reverseMI.addActionListener(new ActionListener() {
    143143            public void actionPerformed(ActionEvent e) {
    144                 if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
    145                     RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
     144                if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
     145                    RoutingLayer layer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
    146146                    RoutingModel routingModel = layer.getRoutingModel();
    147147                    routingModel.reverseNodes();
    148148                    Main.map.repaint();
    public class RoutingMenu extends JMenu { 
    154154        clearMI = new JMenuItem(tr("Clear route"));
    155155        clearMI.addActionListener(new ActionListener() {
    156156            public void actionPerformed(ActionEvent e) {
    157                 if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
    158                     RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
     157                if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
     158                    RoutingLayer layer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
    159159                    RoutingModel routingModel = layer.getRoutingModel();
    160160                    // Reset routing nodes and paths
    161161                    routingModel.reset();
    public class RoutingMenu extends JMenu { 
    170170        regraphMI.addActionListener(new ActionListener() {
    171171            public void actionPerformed(ActionEvent e) {
    172172
    173                 if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
    174                     RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
     173                if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
     174                    RoutingLayer layer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
    175175                    RoutingModel routingModel = layer.getRoutingModel();
    176176                    routingModel.routingGraph.resetGraph();
    177177                    routingModel.routingGraph.createGraph();
  • sds/src/org/openstreetmap/hot/sds/SdsMenu.java

    diff --git a/sds/src/org/openstreetmap/hot/sds/SdsMenu.java b/sds/src/org/openstreetmap/hot/sds/SdsMenu.java
    index c6cadca..5654b23 100644
    a b public class SdsMenu extends JMenu implements LayerChangeListener { 
    5454    }
    5555
    5656    void setEnabledState() {
    57         boolean en = (Main.map != null) && (Main.map.mapView != null) && (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer);
     57        boolean en = (Main.map != null) && (Main.map.mapView != null) && (Main.getLayerManager().getActiveLayer() instanceof OsmDataLayer);
    5858        loadItem.setEnabled(en);
    5959        saveItem.setEnabled(en);
    6060    }
  • sds/src/org/openstreetmap/hot/sds/SdsSaveAction.java

    diff --git a/sds/src/org/openstreetmap/hot/sds/SdsSaveAction.java b/sds/src/org/openstreetmap/hot/sds/SdsSaveAction.java
    index 5ece685..f2691b3 100644
    a b public class SdsSaveAction extends SdsDiskAccessAction { 
    3636
    3737    public boolean doSave() {
    3838        Layer layer = null;
    39         if (Main.isDisplayingMapView() && (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer))
    40             layer = Main.map.mapView.getActiveLayer();
     39        if (Main.isDisplayingMapView() && (Main.getLayerManager().getActiveLayer() instanceof OsmDataLayer))
     40            layer = Main.getLayerManager().getActiveLayer();
    4141
    4242        if (layer == null)
    4343            return false;
  • surveyor/src/at/dallermassl/josm/plugin/surveyor/action/SetWaypointAction.java

    diff --git a/surveyor/src/at/dallermassl/josm/plugin/surveyor/action/SetWaypointAction.java b/surveyor/src/at/dallermassl/josm/plugin/surveyor/action/SetWaypointAction.java
    index 832a140..ec2eda4 100644
    a b public class SetWaypointAction extends AbstractSurveyorAction { 
    124124     */
    125125    public GpxLayer getGpxLayer() {
    126126        if(liveGpsLayer == null) {
    127             Collection<Layer> layers = Main.map.mapView.getAllLayers();
     127            Collection<Layer> layers = Main.getLayerManager().getLayers();
    128128            for (Layer layer : layers) {
    129129                if(layer instanceof LiveGpsLayer) {
    130130                    liveGpsLayer = (LiveGpsLayer) layer;
  • surveyor/src/at/dallermassl/josm/plugin/surveyor/util/LayerUtil.java

    diff --git a/surveyor/src/at/dallermassl/josm/plugin/surveyor/util/LayerUtil.java b/surveyor/src/at/dallermassl/josm/plugin/surveyor/util/LayerUtil.java
    index 3277b97..63e22e4 100644
    a b public class LayerUtil { 
    2323    public static <LayerType extends Layer> LayerType findGpsLayer(String layerName, Class<LayerType> layerType) {
    2424        Layer result = null;
    2525        if(Main.map != null && Main.map.mapView != null) {
    26             for(Layer layer : Main.map.mapView.getAllLayers()) {
     26            for(Layer layer : Main.getLayerManager().getLayers()) {
    2727                if(layerName.equals(layer.getName()) && layerType.isAssignableFrom(layer.getClass())) {
    2828                    result = layer;
    2929                    break;
  • turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditor.java

    diff --git a/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditor.java b/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditor.java
    index 264d923..617d4d6 100644
    a b public class TurnRestrictionEditor extends JDialog implements NavigationControle 
    818818
    819819        public void actionPerformed(ActionEvent e) {
    820820            if (Main.main.getActiveLayer() != getLayer()){
    821                 Main.map.mapView.setActiveLayer(getLayer());
     821                Main.getLayerManager().setActiveLayer(getLayer());
    822822            }
    823823            Relation tr = getTurnRestriction();
    824824            if (tr == null || tr.getDataSet() == null) return;
  • waypoint_search/src/org/openstreetmap/josm/plugins/waypointSearch/Engine.java

    diff --git a/waypoint_search/src/org/openstreetmap/josm/plugins/waypointSearch/Engine.java b/waypoint_search/src/org/openstreetmap/josm/plugins/waypointSearch/Engine.java
    index f33a04b..7889d6c 100644
    a b class Engine { 
    1717        List<Marker> returnList = new ArrayList<>();
    1818        if (gpxLayersExist()) {
    1919            //Loop over marker (waypoint) layers.. it could be more than one
    20             for (Iterator<MarkerLayer> it = Main.map.mapView.getLayersOfType(MarkerLayer.class).iterator(); it.hasNext();) {
     20            for (Iterator<MarkerLayer> it = Main.getLayerManager().getLayersOfType(MarkerLayer.class).iterator(); it.hasNext();) {
    2121                //loop over each marker (waypoint)
    2222                for (Iterator<Marker> markerIterator = it.next().data.iterator(); markerIterator.hasNext();) {
    2323                    Marker marker = markerIterator.next();
    class Engine { 
    3131    }   
    3232   
    3333    static boolean gpxLayersExist() {
    34         return Main.map != null && Main.map.mapView.hasLayers() && !Main.map.mapView.getLayersOfType(MarkerLayer.class).isEmpty();
     34        return Main.map != null && Main.getLayerManager().containsLayers() && !Main.getLayerManager().getLayersOfType(MarkerLayer.class).isEmpty();
    3535    }
    3636}