Search in sources :

Example 56 with MapLayer

use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.

the class AddSpeciesInArea method loadAreaLayers.

public void loadAreaLayers() {
    try {
        List<MapLayer> layers = null;
        Map m = args;
        if (m != null) {
            for (Object o : m.entrySet()) {
                if (((Map.Entry) o).getKey() instanceof String && ((Map.Entry) o).getKey().equals(StringConstants.POLYGON_LAYERS)) {
                    layers = (List<MapLayer>) ((Map.Entry) o).getValue();
                }
            }
        }
        for (int i = 0; layers != null && i < layers.size(); i++) {
            MapLayer lyr = layers.get(i);
            Radio rAr = new Radio(lyr.getDisplayName());
            rAr.setId(lyr.getDisplayName().replaceAll(" ", "") + i);
            rAr.setValue(lyr.getName());
            rAr.setParent(rgArea);
            rgArea.insertBefore(rAr, rAreaCurrent);
        }
        if (!allSpecies) {
            //set as default in the zul
            rAreaSelected = rAreaWorld;
        } else {
            rAreaWorld.setVisible(false);
            rAreaAustralia.setVisible(false);
            for (int i = 0; i < rgArea.getItemCount(); i++) {
                if (rgArea.getItemAtIndex(i).isVisible()) {
                    rAreaSelected = rgArea.getItemAtIndex(i);
                    rgArea.setSelectedItem(rAreaSelected);
                    Clients.evalJavaScript("jq('#" + rAreaSelected.getUuid() + "-real').attr('checked', true);");
                    break;
                }
            }
        }
    } catch (Exception e) {
        LOGGER.error(StringConstants.UNABLE_TO_LOAD_ACTIVE_AREA_LAYERS, e);
    }
}
Also used : MapLayer(au.org.emii.portal.menu.MapLayer) Radio(org.zkoss.zul.Radio) HashMap(java.util.HashMap) Map(java.util.Map)

Example 57 with MapLayer

use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.

the class ToolComposer method onCheck$rgSpeciesBk.

public void onCheck$rgSpeciesBk(Event event) {
    if (rgSpeciesBk == null) {
        return;
    }
    Radio selectedItem = rgSpeciesBk.getSelectedItem();
    try {
        if (selectedItem == null && event != null) {
            selectedItem = (Radio) ((org.zkoss.zk.ui.event.ForwardEvent) event).getOrigin().getTarget();
        }
    } catch (Exception e) {
        LOGGER.error(StringConstants.FAILED_TO_SET_RADIO, e);
    }
    try {
        if (vboxImportSL != null && event != null && selectedItem != rSpeciesUploadLSID) {
            vboxImportSL.setVisible(false);
        }
        if (event != null && vboxImportSLBk != null && selectedItem != rSpeciesUploadLSIDBk) {
            vboxImportSLBk.setVisible(false);
        }
        if (selectedItem == rSpeciesSearchBk && divSpeciesSearchBk != null) {
            divSpeciesSearchBk.setVisible(true);
            vboxMultipleBk.setVisible(false);
            if (event != null) {
                toggles();
            }
            return;
        }
        if (divSpeciesSearchBk != null) {
            divSpeciesSearchBk.setVisible(false);
        }
        if (selectedItem == rSpeciesUploadLSIDBk) {
            btnOk.setDisabled(true);
            vboxImportSLBk.setVisible(true);
            vboxMultiple.setVisible(false);
        } else if (selectedItem == rSpeciesUploadSpeciesBk) {
            btnOk.setVisible(true);
        }
        if (rMultipleBk != null && rMultipleBk.isSelected()) {
            vboxMultipleBk.setVisible(true);
        } else {
            vboxMultipleBk.setVisible(false);
        }
        if (event != null) {
            toggles();
        }
        // set default geospatial kosher checkboxes unless a map layers has
        // been chosen
        MapLayer ml;
        Query q;
        if (rgSpeciesBk.getSelectedItem() != null && rgSpeciesBk.getSelectedItem().getValue() != null && (ml = getMapComposer().getMapLayer(rgSpeciesBk.getSelectedItem().getLabel())) != null && (q = ml.getSpeciesQuery()) != null && q instanceof BiocacheQuery) {
            setGeospatialKosherCheckboxesBk(((BiocacheQuery) q).getGeospatialKosher());
        } else {
            setGeospatialKosherCheckboxesBk(defaultGeospatialKosher);
        }
        updateGeospatialKosherCheckboxesBk();
    } catch (Exception e) {
        LOGGER.error("error selecting background species radio", e);
    }
}
Also used : MapLayer(au.org.emii.portal.menu.MapLayer) org.zkoss.zk.ui.event(org.zkoss.zk.ui.event) IOException(java.io.IOException)

Example 58 with MapLayer

use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.

the class RemoteMapImpl method createLocalLayer.

public MapLayer createLocalLayer(int type, String label) {
    MapLayer layer = new MapLayer();
    layer.setName(label);
    layer.setLayer(label);
    layer.setId(label);
    layer.setEnvColour(StringConstants.RED);
    int colour = Util.nextColour();
    int r = (colour >> 16) & 0x000000ff;
    int g = (colour >> 8) & 0x000000ff;
    int b = (colour) & 0x000000ff;
    layer.setBlueVal(b);
    layer.setGreenVal(g);
    layer.setRedVal(r);
    layer.setType(type);
    layer.setSubType(type);
    return layer;
}
Also used : MapLayer(au.org.emii.portal.menu.MapLayer)

Example 59 with MapLayer

use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.

the class MapComposer method redrawLayersList.

public void redrawLayersList() {
    int idx = activeLayersList.getSelectedIndex();
    List<MapLayer> activeLayers = getPortalSession().getActiveLayers();
    activeLayersList.setModel(new ListModelList(activeLayers, true));
    activeLayersList.setSelectedIndex(idx);
    if (layerLegendNameRefresh != null) {
        try {
            layerLegendNameRefresh.onEvent(new ForwardEvent("", this, null, llc2MapLayer.getDisplayName()));
        } catch (Exception e) {
            LOGGER.error("failed to refresh legend name with current map layer", e);
        }
    }
    lblSelectedLayer.setValue(llc2MapLayer.getDisplayName());
    adjustActiveLayersList();
}
Also used : ForwardEvent(org.zkoss.zk.ui.event.ForwardEvent) HasMapLayer(au.org.emii.portal.menu.HasMapLayer) MapLayer(au.org.emii.portal.menu.MapLayer) ParseException(org.json.simple.parser.ParseException)

Example 60 with MapLayer

use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.

the class MapComposer method updateLayerControls.

public void updateLayerControls() {
    adjustActiveLayersList();
    //remove any scatterplot legend
    Component c = getFellowIfAny("scatterplotlayerlegend");
    if (c != null) {
        c.detach();
    }
    //remove children
    for (int i = layerControls.getChildren().size() - 1; i >= 0; i--) {
        layerControls.getChildren().get(i).detach();
    }
    MapLayer selectedLayer = this.getActiveLayersSelection(false);
    if (selectedLayer == null) {
        if (activeLayersList.getItemCount() > 0) {
            activeLayersList.setSelectedIndex(0);
            selectedLayer = (MapLayer) activeLayersList.getModel().getElementAt(0);
        } else {
            return;
        }
    }
    lblSelectedLayer.setValue(selectedLayer.getDisplayName());
    String page;
    Window window;
    if (selectedLayer.getType() == LayerUtilitiesImpl.SCATTERPLOT) {
        page = "WEB-INF/zul/legend/LayerLegendScatterplot.zul";
    } else if (selectedLayer.getType() == LayerUtilitiesImpl.MAP) {
        page = "WEB-INF/zul/legend/MapOptions.zul";
    } else {
        Map params = new HashMap();
        llc2MapLayer = selectedLayer;
        params.put("map_layer", llc2MapLayer);
        window = (Window) Executions.createComponents("WEB-INF/zul/legend/LayerLegendGeneral.zul", layerControls, params);
        try {
            window.doEmbedded();
        } catch (Exception e) {
            LOGGER.error("error setting up layer legend", e);
        }
        return;
    }
    window = (Window) Executions.createComponents(page, layerControls, null);
    try {
        if (window instanceof HasMapLayer) {
            ((HasMapLayer) window).setMapLayer(selectedLayer);
        }
    } catch (Exception e) {
        LOGGER.error("failed to set map layer to window: " + (window != null ? window.getId() : "window is null"), e);
    }
    try {
        window.doEmbedded();
    } catch (Exception e) {
        LOGGER.error("error setting layer legend", e);
    }
}
Also used : Window(org.zkoss.zul.Window) HasMapLayer(au.org.emii.portal.menu.HasMapLayer) MapLayer(au.org.emii.portal.menu.MapLayer) HasMapLayer(au.org.emii.portal.menu.HasMapLayer) SpeciesAutoCompleteComponent(au.org.ala.spatial.composer.species.SpeciesAutoCompleteComponent) Component(org.zkoss.zk.ui.Component) RemoteMap(au.org.emii.portal.util.RemoteMap) ParseException(org.json.simple.parser.ParseException)

Aggregations

MapLayer (au.org.emii.portal.menu.MapLayer)131 HasMapLayer (au.org.emii.portal.menu.HasMapLayer)34 JSONObject (org.json.simple.JSONObject)24 MapComposer (au.org.emii.portal.composer.MapComposer)20 ParseException (org.json.simple.parser.ParseException)18 IOException (java.io.IOException)16 MapLayerMetadata (au.org.emii.portal.menu.MapLayerMetadata)15 SelectedArea (au.org.emii.portal.menu.SelectedArea)14 Facet (au.org.ala.legend.Facet)12 List (java.util.List)10 XmlArrayList (com.thoughtworks.xstream.persistence.XmlArrayList)9 JSONParser (org.json.simple.parser.JSONParser)9 JSONArray (org.json.simple.JSONArray)8 URL (java.net.URL)7 ArrayList (java.util.ArrayList)7 SuspendNotAllowedException (org.zkoss.zk.ui.SuspendNotAllowedException)7 LegendObject (au.org.ala.legend.LegendObject)6 Component (org.zkoss.zk.ui.Component)6 Geometry (com.vividsolutions.jts.geom.Geometry)5 ParseException (com.vividsolutions.jts.io.ParseException)5