Search in sources :

Example 6 with MapComposer

use of au.org.emii.portal.composer.MapComposer in project spatial-portal by AtlasOfLivingAustralia.

the class AreaPolygon method onClick$btnClear.

public void onClick$btnClear(Event event) {
    MapComposer mc = getMapComposer();
    if (layerName != null && mc.getMapLayer(layerName) != null) {
        mc.removeLayer(layerName);
    }
    String script = mc.getOpenLayersJavascript().addPolygonDrawingTool();
    mc.getOpenLayersJavascript().execute(mc.getOpenLayersJavascript().getIFrameReferences() + script);
    displayGeom.setValue("");
    btnNext.setDisabled(true);
    btnClear.setDisabled(true);
    invalidWKT.setValue("");
}
Also used : MapComposer(au.org.emii.portal.composer.MapComposer)

Example 7 with MapComposer

use of au.org.emii.portal.composer.MapComposer in project spatial-portal by AtlasOfLivingAustralia.

the class AreaPolygon method onSelectionGeom.

/**
     * @param event
     */
public void onSelectionGeom(Event event) {
    String selectionGeom = (String) event.getData();
    try {
        String wkt = "";
        if (selectionGeom.contains(StringConstants.NAN_NAN)) {
            displayGeom.setValue("");
        } else {
            wkt = selectionGeom;
            displayGeom.setValue(wkt);
        }
        //get the current MapComposer instance
        MapComposer mc = getMapComposer();
        //add feature to the map as a new layer
        if (wkt.length() > 0) {
            layerName = (mc.getMapLayer(txtLayerName.getValue()) == null) ? txtLayerName.getValue() : mc.getNextAreaLayerName(txtLayerName.getValue());
            MapLayer mapLayer = mc.addWKTLayer(wkt, layerName, txtLayerName.getValue());
            mapLayer.getMapLayerMetadata().setMoreInfo(LayersUtil.getMetadataForWKT(CommonData.lang("metadata_polygon"), wkt));
            if (!validWKT(wkt)) {
                btnNext.setDisabled(true);
                btnClear.setDisabled(false);
            } else {
                btnClear.setDisabled(false);
                btnNext.setDisabled(false);
            }
        }
    } catch (Exception e) {
        LOGGER.error("error mapping user polygon", e);
        btnNext.setDisabled(true);
        btnClear.setDisabled(false);
    }
}
Also used : MapComposer(au.org.emii.portal.composer.MapComposer) MapLayer(au.org.emii.portal.menu.MapLayer) ParseException(com.vividsolutions.jts.io.ParseException)

Example 8 with MapComposer

use of au.org.emii.portal.composer.MapComposer in project spatial-portal by AtlasOfLivingAustralia.

the class AreaRadiusManual method createCircle.

public void createCircle() {
    String wkt = Util.createCircleJs(dLongitude.getValue(), dLatitude.getValue(), dRadius.getValue() * 1000.0);
    if (!StringConstants.NONE.equalsIgnoreCase(wkt)) {
        try {
            MapComposer mc = getMapComposer();
            layerName = (mc.getMapLayer(txtLayerName.getValue()) == null) ? txtLayerName.getValue() : mc.getNextAreaLayerName(txtLayerName.getValue());
            MapLayer mapLayer = mc.addWKTLayer(wkt, layerName, txtLayerName.getValue());
            mapLayer.getMapLayerMetadata().setMoreInfo(LayersUtil.getMetadata(dRadius.getText() + "km radius around longitude " + dLongitude.getText() + ", latitude " + dLatitude.getText()));
            displayGeom.setText(wkt);
        } catch (Exception e) {
            LOGGER.error("Error adding WKT layer", e);
        }
    }
}
Also used : MapComposer(au.org.emii.portal.composer.MapComposer) MapLayer(au.org.emii.portal.menu.MapLayer)

Example 9 with MapComposer

use of au.org.emii.portal.composer.MapComposer in project spatial-portal by AtlasOfLivingAustralia.

the class VisibilityToggleEventListener method onEvent.

@Override
public void onEvent(Event event) throws Exception {
    LOGGER.debug("VisibilityToggleEventListener.onEvent() fired ");
    Checkbox checkbox = (Checkbox) event.getTarget();
    try {
        MapComposer mapComposer = (MapComposer) event.getPage().getFellow(StringConstants.MAPPORTALPAGE);
        if (mapComposer.safeToPerformMapAction()) {
            Listitem listitem = (Listitem) checkbox.getParent().getParent();
            MapLayer layer = listitem.getValue();
            boolean checked = checkbox.isChecked();
            /* checkbox state will be saved automatically in MapLayer instances
                 * with calls to activate/remove in OpenLayersJavascript
                 */
            if (checked) {
                PortalSession portalSession = (PortalSession) Executions.getCurrent().getDesktop().getSession().getAttribute(StringConstants.PORTAL_SESSION);
                openLayersJavascript.execute(openLayersJavascript.getIFrameReferences() + openLayersJavascript.activateMapLayer(layer, false, true) + openLayersJavascript.updateMapLayerIndexes(portalSession.getActiveLayers()));
                checkbox.setTooltiptext("Hide");
                mapComposer.refreshContextualMenu();
            } else {
                openLayersJavascript.removeMapLayerNow(layer);
                checkbox.setTooltiptext("Show");
                mapComposer.refreshContextualMenu();
            }
        } else {
            /* there was a problem performing the action - 'undo'
                 * the user's click on the checkbox
                 */
            checkbox.setChecked(!checkbox.isChecked());
        }
    } catch (Exception e) {
    //toogle won't work if page not completely loaded.
    }
}
Also used : MapComposer(au.org.emii.portal.composer.MapComposer) Checkbox(org.zkoss.zul.Checkbox) MapLayer(au.org.emii.portal.menu.MapLayer) PortalSession(au.org.emii.portal.session.PortalSession) Listitem(org.zkoss.zul.Listitem)

Example 10 with MapComposer

use of au.org.emii.portal.composer.MapComposer in project spatial-portal by AtlasOfLivingAustralia.

the class ActiveLayersRemoveEventListener method onEvent.

@Override
public void onEvent(Event event) throws Exception {
    MapComposer mapComposer = getMapComposer(event);
    if (mapComposer != null && mapComposer.safeToPerformMapAction()) {
        // get reference to the label/image the user clicked on 
        Component target = event.getTarget();
        Listitem listItem = (Listitem) target.getParent().getParent();
        MapLayer activeLayer = listItem.getValue();
        if (activeLayer != null) {
            mapComposer.deactiveLayer(activeLayer, true, false);
        }
    } else {
        LOGGER.debug("MapController reports unsafe to perform action");
    }
}
Also used : MapComposer(au.org.emii.portal.composer.MapComposer) MapLayer(au.org.emii.portal.menu.MapLayer) Listitem(org.zkoss.zul.Listitem) Component(org.zkoss.zk.ui.Component)

Aggregations

MapComposer (au.org.emii.portal.composer.MapComposer)38 MapLayer (au.org.emii.portal.menu.MapLayer)20 Listitem (org.zkoss.zul.Listitem)6 HashMap (java.util.HashMap)5 Component (org.zkoss.zk.ui.Component)5 ParseException (com.vividsolutions.jts.io.ParseException)3 JSONObject (org.json.simple.JSONObject)3 ScatterplotDataDTO (au.org.ala.spatial.dto.ScatterplotDataDTO)2 Query (au.org.ala.spatial.util.Query)2 Geometry (com.vividsolutions.jts.geom.Geometry)2 WKTReader (com.vividsolutions.jts.io.WKTReader)2 DateFormat (java.text.DateFormat)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Checkbox (org.zkoss.zul.Checkbox)2 Facet (au.org.ala.legend.Facet)1 ToolComposer (au.org.ala.spatial.composer.tool.ToolComposer)1 PortalSession (au.org.emii.portal.session.PortalSession)1 IsValidOp (com.vividsolutions.jts.operation.valid.IsValidOp)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1