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

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

File:
1 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}
Note: See TracChangeset for help on using the changeset viewer.