use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.
the class MapComposer method setLayersVisible.
public void setLayersVisible(boolean show) {
PortalSession portalSession = (PortalSession) Executions.getCurrent().getDesktop().getSession().getAttribute(StringConstants.PORTAL_SESSION);
for (Listitem li : activeLayersList.getItems()) {
if (li.getValue() == null || !"Map options".equals(((MapLayer) li.getValue()).getName())) {
Checkbox cb = (Checkbox) li.getFirstChild().getFirstChild();
if (show && !cb.isChecked()) {
openLayersJavascript.execute(openLayersJavascript.getIFrameReferences() + openLayersJavascript.activateMapLayer((MapLayer) li.getValue(), false, true) + openLayersJavascript.updateMapLayerIndexes(portalSession.getActiveLayers()));
} else if (!show && cb.isChecked()) {
openLayersJavascript.removeMapLayerNow((MapLayer) li.getValue());
}
cb.setChecked(show);
cb.setTooltiptext(show ? "Hide" : "Show");
}
}
refreshContextualMenu();
}
use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.
the class MapComposer method replaceWKTwithWMS.
public void replaceWKTwithWMS(MapLayer ml) {
//don't replace if it has a facet or is mapped with WMS or is WKT ENVELOPE
if (ml.getFacets() != null || ml.getWKT() == null || ml.getWKT().startsWith(StringConstants.ENVELOPE) || ml.getUri() != null) {
return;
}
//only replace if WKT upload is successful
String pid = UserShapes.upload(ml.getWKT(), ml.getDisplayName(), ml.getDescription(), Util.getUserEmail(), CommonData.getSettings().getProperty("api_key"));
if (pid != null) {
//2. remove old layer
deactiveLayer(ml, true, false);
//1. create new layer
MapLayer newml = addObjectByPid(pid, ml.getDisplayName(), 1);
newml.setMapLayerMetadata(ml.getMapLayerMetadata());
newml.setAreaSqKm(ml.getAreaSqKm());
newml.setUserDefinedLayer(ml.isUserDefinedLayer());
newml.setDescription(ml.getDescription());
newml.setWKT(ml.getWKT());
}
}
use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.
the class ToolComposer method getSelectedSpeciesBk.
public Query getSelectedSpeciesBk(boolean mapspecies, boolean applycheckboxes) {
Query q = null;
if (rgSpeciesBk == null) {
return q;
}
Radio r = rgSpeciesBk.getSelectedItem();
if (r == null) {
if (rgSpeciesBk.getItemCount() == 0) {
return q;
}
LOGGER.error("rgSpeciesBk item is not selected. step=" + currentStep + " method=" + getTitle() + " rgSpeces item at [0]=" + (rgSpeciesBk != null && rgSpeciesBk.getItemCount() > 0 ? rgSpeciesBk.getItemAtIndex(0).getValue() : "null or no species items in list"));
r = rgSpeciesBk.getItemAtIndex(0);
}
String species = r.getValue();
String id = rgSpeciesBk.getSelectedItem().getId();
MapLayer ml = getMapComposer().getMapLayer(species);
if (ml != null) {
q = ml.getSpeciesQuery();
if (q instanceof BiocacheQuery) {
BiocacheQuery bq = (BiocacheQuery) q;
q = bq.newFacetGeospatialKosher(applycheckboxes ? getGeospatialKosherBk() : null, false);
}
} else {
try {
if ("allspecies".equals(species)) {
q = new BiocacheQuery(null, null, null, null, false, applycheckboxes ? getGeospatialKosherBk() : null);
} else if ("allmapped".equals(species)) {
throw new UnsupportedOperationException("Not yet implemented");
} else if (StringConstants.MULTIPLE.equals(species)) {
String lsids = getMultipleLsidsBk();
if (lsids != null && lsids.length() > 0) {
q = new BiocacheQuery(lsids, null, null, null, false, applycheckboxes ? getGeospatialKosherBk() : null);
}
} else if ("uploadLsid".equals(species)) {
//get the query from species list list
SpeciesListListbox lb = id.endsWith("Bk") ? speciesListListboxBk : speciesListListbox;
q = lb.extractQueryFromSelectedLists(applycheckboxes ? getGeospatialKosher() : null);
} else if ((StringConstants.SEARCH.equals(species) || StringConstants.UPLOAD_SPECIES.equals(species)) && bgSearchSpeciesACComp.hasValidItemSelected()) {
q = bgSearchSpeciesACComp.getQuery((Map) getMapComposer().getSession().getAttribute(StringConstants.USERPOINTS), false, applycheckboxes ? getGeospatialKosherBk() : null);
}
} catch (Exception e) {
LOGGER.warn("Unable to retrieve selected species", e);
}
}
return q;
}
use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.
the class ToolComposer method loadAreaLayersCheckboxes.
public void loadAreaLayersCheckboxes(String selectedAreaName) {
try {
List<MapLayer> layers = getMapComposer().getPolygonLayers();
for (int i = 0; i < layers.size(); i++) {
MapLayer lyr = layers.get(i);
//add only if missing
boolean found = false;
if (getFellow("vboxArea") != null) {
List checkboxes = getFellow("vboxArea").getChildren();
for (int j = 0; j < checkboxes.size(); j++) {
if (checkboxes.get(j) instanceof Checkbox && ((Checkbox) checkboxes.get(j)).getLabel().equals(lyr.getDisplayName())) {
found = true;
break;
}
}
}
if (!found) {
Checkbox rAr = new Checkbox(lyr.getDisplayName());
rAr.setValue(lyr.getName());
if (lyr.getDisplayName().equals(selectedAreaName)) {
rAr.setChecked(true);
}
rAr.setParent(vboxArea);
vboxArea.insertBefore(rAr, cAreaCurrent);
}
}
} catch (Exception e) {
LOGGER.error(StringConstants.UNABLE_TO_LOAD_ACTIVE_AREA_LAYERS, e);
}
}
use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.
the class ToolComposer method getAllSelectedSpecies.
public List<Query> getAllSelectedSpecies() {
List<Query> selected = new ArrayList<Query>();
for (Object species : vboxSpecies.getChildren()) {
Checkbox chk = (Checkbox) species;
if (chk.isChecked()) {
MapLayer ml = getMapComposer().getMapLayer(chk.getValue().toString());
if (ml != null) {
Query q = ml.getSpeciesQuery();
q.setName(ml.getDisplayName());
selected.add(q);
}
}
}
return selected;
}
Aggregations