Ignore:
Timestamp:
2010-02-07T23:49:38+01:00 (14 years ago)
Author:
pieren
Message:

from Clément Ménier, new WMLayer always on bottom

Location:
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java

    r19894 r19928  
    2323import org.openstreetmap.josm.gui.MapFrame;
    2424import org.openstreetmap.josm.gui.IconToggleButton;
     25import org.openstreetmap.josm.gui.layer.Layer;
    2526import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    2627import org.openstreetmap.josm.plugins.Plugin;
     
    296297    }
    297298   
     299    /**
     300     * Adds the WMSLayer following this rule:<br/>
     301     * - if a WMSLayer exists place this new layer just before this layer<br/>
     302     * - Otherwise place it at the bottom
     303     * @param wmsLayer the wmsLayer to add
     304     */
     305    public static void addWMSLayer(WMSLayer wmsLayer) {
     306        if (Main.map != null && Main.map.mapView != null) {
     307            int wmsNewLayerPos = Main.map.mapView.getAllLayers().size();
     308            for(Layer l : Main.map.mapView.getLayersOfType(WMSLayer.class)) {
     309                int wmsPos = Main.map.mapView.getLayerPos(l);
     310                if (wmsPos < wmsNewLayerPos) wmsNewLayerPos = wmsPos;
     311            }
     312            Main.main.addLayer(wmsLayer);
     313            // Move the layer to its new position
     314            Main.map.mapView.moveLayer(wmsLayer, wmsNewLayerPos);
     315        } else
     316            Main.main.addLayer(wmsLayer);
     317    }
     318   
    298319    private static String checkSourceMillesime() {
    299320        java.util.Calendar calendar = java.util.Calendar.getInstance();
     
    313334        return src;
    314335    }
     336   
    315337}
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionLoadFromCache.java

    r18720 r19928  
    7575                    // create layer and load cache
    7676                    WMSLayer wmsLayer = new WMSLayer("", "", Integer.parseInt(ext)-1);
    77                     if (wmsLayer.getCacheControl().loadCache(file, layoutZone))
    78                         Main.main.addLayer(wmsLayer);
    79                    
     77                    if (wmsLayer.getCacheControl().loadCache(file, layoutZone)) {
     78                        CadastrePlugin.addWMSLayer(wmsLayer);
     79                    }                   
    8080                }
    8181            }
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionNewLocation.java

    r19267 r19928  
    8585                zone = ((UTM_20N_France_DOM)Main.proj).getCurrentGeodesic();
    8686            wmsLayer = new WMSLayer(location, codeCommune, zone);
    87             Main.main.addLayer(wmsLayer);
     87            CadastrePlugin.addWMSLayer(wmsLayer);
    8888            System.out.println("Add new layer with Location:" + inputTown.getText());
    8989        } else if (existingLayers != null && existingLayers.size() > 0 && Main.map.mapView.getActiveLayer() instanceof WMSLayer) {
Note: See TracChangeset for help on using the changeset viewer.