Search in sources :

Example 36 with MapComposer

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

the class PortalEvent method getMapComposer.

protected MapComposer getMapComposer(Event event) {
    MapComposer mapComposer = null;
    Page page;
    if ((event == null) || ((page = event.getPage()) == null) || ((mapComposer = (MapComposer) page.getFellow(StringConstants.MAPPORTALPAGE)) == null)) {
        LOGGER.debug("Unable to obtain reference to mapPortalPage instance to perform changes " + "I think this is a strange concurrent access problem, I've only ever seen " + "it once (ignoring and proceeding normally)");
    }
    return mapComposer;
}
Also used : MapComposer(au.org.emii.portal.composer.MapComposer) Page(org.zkoss.zk.ui.Page)

Example 37 with MapComposer

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

the class ActiveLayerDNDEventListener method onEvent.

@Override
public void onEvent(Event event) throws Exception {
    LOGGER.debug("active layers item drop received");
    MapComposer mapComposer = getMapComposer(event);
    if (mapComposer != null && mapComposer.safeToPerformMapAction()) {
        LOGGER.debug("inside ActiveLayerDNDEventListener.onEvent()");
        if (event instanceof DropEvent) {
            DropEvent dragEvent = (DropEvent) event;
            // we support the treechildren and other list items...
            Component eventType = dragEvent.getDragged();
            if (eventType instanceof Listitem) {
                reorderList(mapComposer, dragEvent);
            } else {
                LOGGER.debug("unsupported dnd event " + eventType.getClass().getName());
            }
        } else {
            LOGGER.debug("event is not a DropEvent instance: " + event.getClass().getName());
        }
    }
}
Also used : DropEvent(org.zkoss.zk.ui.event.DropEvent) MapComposer(au.org.emii.portal.composer.MapComposer) Listitem(org.zkoss.zul.Listitem) Component(org.zkoss.zk.ui.Component)

Example 38 with MapComposer

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

the class ActiveLayersInfoEventListener 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) {
            if (activeLayer.getSpeciesQuery() != null) {
                Query q = activeLayer.getSpeciesQuery();
                Events.echoEvent(StringConstants.OPEN_HTML, mapComposer, q.getMetadataHtml());
            } else if (activeLayer.getMapLayerMetadata().getMoreInfo() != null && activeLayer.getMapLayerMetadata().getMoreInfo().startsWith("http://")) {
                String infourl = activeLayer.getMapLayerMetadata().getMoreInfo().replace("__", ".");
                if (activeLayer.getSubType() == LayerUtilitiesImpl.SCATTERPLOT) {
                    ScatterplotDataDTO data = activeLayer.getScatterplotDataDTO();
                    infourl += "?dparam=X-Layer:" + data.getLayer1Name();
                    infourl += "&dparam=Y-Layer:" + data.getLayer2Name();
                }
                // send the user to the BIE page for the species
                LOGGER.debug("opening the following url " + infourl);
                Events.echoEvent(StringConstants.OPEN_URL, mapComposer, activeLayer.getMapLayerMetadata().getMoreInfo().replace("__", "."));
            } else if (activeLayer.getMapLayerMetadata().getMoreInfo() != null && activeLayer.getMapLayerMetadata().getMoreInfo().length() > 0) {
                LOGGER.debug("performing a MapComposer.showMessage for following content " + activeLayer.getMapLayerMetadata().getMoreInfo());
                String metadata = activeLayer.getMapLayerMetadata().getMoreInfo();
                Events.echoEvent(StringConstants.OPEN_HTML, mapComposer, metadata);
            } else if (activeLayer.getType() == LayerUtilitiesImpl.MAP) {
                String metaurl = "http://www.google.com/intl/en_au/help/terms_maps.html";
                if ("outline".equalsIgnoreCase(mapComposer.getPortalSession().getBaseLayer())) {
                    metaurl = "openstreetmap_metadata.html";
                } else if ("minimal".equalsIgnoreCase(mapComposer.getPortalSession().getBaseLayer())) {
                    metaurl = "http://www.naturalearthdata.com/about/terms-of-use";
                }
                LOGGER.debug("opening base map metadata for: " + mapComposer.getPortalSession().getBaseLayer() + ", url:" + metaurl);
                Events.echoEvent(StringConstants.OPEN_URL, mapComposer, metaurl);
            } else {
                LOGGER.debug("no metadata is available for current layer");
                mapComposer.showMessage("Metadata currently unavailable");
            }
        }
    } else {
        LOGGER.debug("MapController reports unsafe to perform action");
    }
}
Also used : ScatterplotDataDTO(au.org.ala.spatial.dto.ScatterplotDataDTO) MapComposer(au.org.emii.portal.composer.MapComposer) Query(au.org.ala.spatial.util.Query) 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