use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.
the class LayerLegendScatterplotController method updateCbHighlightArea.
private void updateCbHighlightArea() {
for (int i = cbHighlightArea.getItemCount() - 1; i >= 0; i--) {
cbHighlightArea.removeItemAt(i);
}
boolean selectionSuccessful = false;
for (MapLayer ml : getMapComposer().getPolygonLayers()) {
Comboitem ci = new Comboitem(ml.getDisplayName());
ci.setValue(ml);
ci.setParent(cbHighlightArea);
if (data != null && data.getHighlightSa() != null && data.getHighlightSa().getMapLayer().getName().equals(ml.getName())) {
cbHighlightArea.setSelectedItem(ci);
selectionSuccessful = true;
}
}
//this may be a deleted layer or current view or au or world
if (!selectionSuccessful && data != null && data.getHighlightSa() != null) {
MapLayer ml = data.getHighlightSa().getMapLayer();
if (ml != null) {
Comboitem ci = new Comboitem(ml.getDisplayName() + " (DELETED LAYER)");
ci.setValue(ml);
ci.setParent(cbHighlightArea);
cbHighlightArea.setSelectedItem(ci);
} else {
String name = "Previous area";
if (data.getHighlightSa().getWkt() != null) {
if (data.getHighlightSa().getWkt().equals(CommonData.getSettings().getProperty(CommonData.AUSTRALIA_WKT))) {
name = CommonData.getSettings().getProperty(CommonData.AUSTRALIA_NAME);
} else if (data.getHighlightSa().getWkt().equals(CommonData.WORLD_WKT)) {
name = "World";
}
}
Comboitem ci = new Comboitem(name);
ci.setValue(data.getHighlightSa().getWkt());
ci.setParent(cbHighlightArea);
cbHighlightArea.setSelectedItem(ci);
}
}
}
use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.
the class MapComposer method addPointsOfInterestLayer.
public MapLayer addPointsOfInterestLayer(String wkt, String label, String displayName) {
MapLayer mapLayer = null;
if (safeToPerformMapAction()) {
if (portalSessionUtilities.getUserDefinedById(getPortalSession(), label) == null) {
mapLayer = remoteMap.createWKTLayer(wkt, label);
mapLayer.setDisplayName(displayName);
mapLayer.setPointsOfInterestWS(CommonData.getLayersServer() + "/intersect/poi/wkt");
mapLayer.setOpacity((float) 0.4);
mapLayer.setDynamicStyle(true);
activateLayer(mapLayer, true, true);
} else {
// fail
showMessage("WKT layer already exists");
LOGGER.debug("refusing to add a new layer with name " + label + " because it already exists in the menu");
}
}
return mapLayer;
}
use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.
the class MapComposer method deactiveLayer.
public void deactiveLayer(MapLayer itemToRemove, boolean updateMapAndLayerControls, boolean recursive, boolean updateOnly) {
if (itemToRemove != null) {
Query q = itemToRemove.getSpeciesQuery();
if (q instanceof UserDataQuery) {
String pid = q.getQ();
Map<String, UserDataDTO> htUserSpecies = (Map) getMapComposer().getSession().getAttribute(StringConstants.USERPOINTS);
if (htUserSpecies != null) {
htUserSpecies.remove(pid);
}
}
// update the active layers list
List<MapLayer> activeLayers = getPortalSession().getActiveLayers();
if (activeLayers != null) {
LOGGER.debug("obtained activelayers arraylist from session, count: " + activeLayers.size());
if (!activeLayers.isEmpty()) {
ListModelList listmodel = (ListModelList) activeLayersList.getModel();
if (listmodel != null) {
listmodel.remove(itemToRemove);
if (activeLayers.isEmpty()) {
lblSelectedLayer.setValue("No layers added");
}
}
} else {
LOGGER.debug("active layers list is empty, so not updating it");
}
}
if (updateMapAndLayerControls) {
if (!updateOnly) {
// tell openlayers to kill the layer
openLayersJavascript.removeMapLayerNow(itemToRemove);
}
updateLayerControls();
removeFromSession(itemToRemove.getName());
}
// descend children if we were called recursively
if (recursive && itemToRemove.hasChildren()) {
for (MapLayer child : itemToRemove.getChildren()) {
deactiveLayer(child, updateMapAndLayerControls, true);
}
}
}
refreshContextualMenu();
}
use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.
the class MapComposer method load.
/**
* Initial building of the tree menu and active layers list based on the
* values obtained from the current session.
* <p/>
* JavaScript for loading default map layers and setting the default zoombox
* is in SessionInit.java
*/
public void load() {
LOGGER.debug("entering loadMapLayers");
PortalSession portalSession = getPortalSession();
List<MapLayer> activeLayers = portalSession.getActiveLayers();
// model and renderer for active layers list
ListModelList activeLayerModel = new ListModelList(activeLayers, true);
// tell the list about them...
if (activeLayers.isEmpty()) {
MapLayer ml = remoteMap.createLocalLayer(LayerUtilitiesImpl.MAP, "Map options");
ml.setRemoveable(false);
activeLayers.add(ml);
}
activeLayersList.setModel(activeLayerModel);
activeLayersList.setItemRenderer(activeLayerRenderer);
activeLayersList.setSelectedIndex(activeLayerModel.size() - 1);
updateLayerControls();
refreshContextualMenu();
}
use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.
the class AddFacetController method getSelectedArea.
public SelectedArea getSelectedArea() {
String area = rAreaSelected.getValue();
SelectedArea selectedarea = null;
try {
if (StringConstants.CURRENT.equals(area)) {
selectedarea = new SelectedArea(null, getMapComposer().getViewArea());
} else if (StringConstants.AUSTRALIA.equals(area)) {
selectedarea = new SelectedArea(null, CommonData.getSettings().getProperty(CommonData.AUSTRALIA_WKT));
} else if (StringConstants.WORLD.equals(area)) {
selectedarea = new SelectedArea(null, CommonData.WORLD_WKT);
} else {
List<MapLayer> layers = getMapComposer().getPolygonLayers();
for (MapLayer ml : layers) {
if (area.equals(ml.getName())) {
selectedarea = new SelectedArea(ml, null);
break;
}
}
//for 'all areas'
if (selectedarea == null) {
selectedarea = new SelectedArea(null, area);
}
}
} catch (Exception e) {
LOGGER.error("Unable to retrieve selected area", e);
}
return selectedarea;
}
Aggregations