layer_switcher #3

Closed
francesco.mangiacrapa wants to merge 12 commits from layer_switcher into master
5 changed files with 88 additions and 44 deletions
Showing only changes of commit decdb3258e - Show all commits

View File

@ -4,6 +4,7 @@
package org.gcube.portlets.user.geoportaldataviewer.client;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -121,11 +122,6 @@ public class LayerManager {
GWT.log("(" + selectDataInfo.getX1() + "," + selectDataInfo.getY1() + ")(" + selectDataInfo.getX2()
+ "," + selectDataInfo.getY2() + ")");
// for (LayerObject layerObj : layerObjects.values()) {
// // TODO
// isLayerVisible(layerObj.getLayerItem());
// }
BoundsMap mapBBOX = new BoundsMap();
double minX = queryEvent.getGeoQuery().getX1();
double minY = queryEvent.getGeoQuery().getY1();
@ -157,7 +153,19 @@ public class LayerManager {
// for querying detail layers only in this case
if (olMap.getCurrentResolution() < OLMapManager.LAYER_DETAIL_MAX_RESOLUTION) {
listLO.addAll(mapDetailLayerObjects.values());
Collection<LayerObject> collLO = mapDetailLayerObjects.values();
listLO.addAll(collLO);
ArrayList<LayerObject> layerVisibility = new ArrayList<LayerObject>(collLO.size());
layerVisibility.addAll(collLO);
//Managing layer visibility
for (LayerObject layerObject : layerVisibility) {
boolean isLayerVisible = olMap.isLayerVisible(layerObject.getLayerItem().getName());
if(!isLayerVisible) {
GWT.log("From querying removing layername: "+layerObject.getLayerItem().getName() + ", it is not visible");
listLO.remove(layerObject);
}
}
}
GeoportalDataViewerServiceAsync.Util.getInstance().getDataResult(listLO, olMap.getProjectionCode(),
@ -567,7 +575,9 @@ public class LayerManager {
Label layerLabel = new Label();
layerLabel.setType(LabelType.INFO);
layerLabel.setText(layerSourceName);
String layerName = StringUtil.fullNameToLayerName(layerSourceName, ":");
layerLabel.setText(layerName);
layerLabel.setTitle(layerSourceName);
layerLabel.getElement().getStyle().setMarginTop(10, Unit.PX);
layerLabel.getElement().getStyle().setMarginBottom(5, Unit.PX);
flowPanel.add(layerLabel);

View File

@ -38,7 +38,7 @@ public class OLMapManager {
private ol.Extent dragEndExtent = null;
public static final int QUERY_MIN_ZOOM_LEVEL = 13;
public static final Double LAYER_DETAIL_MIN_RESOLUTION = 0.01;
public static final Double LAYER_DETAIL_MAX_RESOLUTION = 13.2;
public static final Double LAYER_DETAIL_MAX_RESOLUTION = 18.5;
/**
@ -255,11 +255,4 @@ public class OLMapManager {
olMap.hidePopup();
}
// /**
// * Removes the detail layers.
// */
// public void removeDetailLayers() {
// olMap.removeAllDetailLayers();
// }
}

View File

@ -344,7 +344,7 @@ public abstract class OpenLayerOSM {
String key = layerItem.getName();
Image layer = wmsLayerMap.get(key);
Image layer = wmsLayerMap.get(layerItem.getName());
if (layer == null) {
ImageWmsParams imageWMSParams = OLFactory.createOptions();
imageWMSParams.setLayers(layerItem.getName());
@ -722,6 +722,27 @@ public abstract class OpenLayerOSM {
return wmsLayerMap;
}
/**
* Checks if is layer visible.
*
* @param layerName the layer name
* @return true, if is layer visible
*/
public boolean isLayerVisible(String layerName) {
String key = layerName;
Image layer = wmsLayerMap.get(key);
if (layer != null)
return layer.getVisible();
layer = wmsDetailsLayerMap.get(key);
if (layer != null)
return layer.getVisible();
return false;
}
/**
* Sets the WMS detail layer visible.
*

View File

@ -2,11 +2,14 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui.dandd;
import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent.DO_LAYER_ACTION;
import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.CheckBox;
import com.github.gwtbootstrap.client.ui.Label;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.github.gwtbootstrap.client.ui.constants.LabelType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style.Unit;
@ -23,7 +26,6 @@ import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;
@ -42,13 +44,11 @@ public class DragDropLayer extends FlowPanel {
this.applicationBus = applicationBus;
this.layerItem = layer;
int layerSep = layer.getName().lastIndexOf(":");
String layerName = layerSep > 0 && (layerSep + 1) < layer.getName().length()
? layer.getName().substring(layerSep + 1, layer.getName().length())
: layer.getName();
String layerName = StringUtil.fullNameToLayerName(layer.getName(), ":");
this.label = new Label(layerName);
this.label.setTitle(layer.getName());
this.label.setType(LabelType.INFO);
getElement().getStyle().setMarginTop(5, Unit.PX);
getElement().getStyle().setMarginBottom(10, Unit.PX);
@ -72,7 +72,7 @@ public class DragDropLayer extends FlowPanel {
rs.setWidth("250px");
FlexTable ft = new FlexTable();
ft.setWidget(0, 0, draggableButton);
draggableButton.setTitle("Drag me to change my position");
draggableButton.setTitle("Drag me up or down to change my position on the Map");
checkBoxVisibility.getElement().getStyle().setMarginLeft(10, Unit.PX);
checkBoxVisibility.setValue(true);

View File

@ -12,7 +12,7 @@ import com.google.gwt.i18n.client.DateTimeFormat;
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 16, 2020
* Nov 16, 2020
*/
public class StringUtil {
@ -21,42 +21,62 @@ public class StringUtil {
/**
* Ellipsize.
*
* @param input the input string that may be subjected to shortening
* @param maxCharacters the maximum characters that must be returned for the input string
* @param input the input string that may be subjected to shortening
* @param maxCharacters the maximum characters that must be returned for the
* input string
* @return the string
* @throws Exception the exception
*/
public static String ellipsize(String input, int maxCharacters) {
if(input==null)
return "";
if (input == null)
return "";
if (input.length() < maxCharacters)
return input;
if (input.length() < maxCharacters)
return input;
return input.substring(0, maxCharacters)+"...";
return input.substring(0, maxCharacters) + "...";
}
public static String formatDate(String date) {
if(date==null)
if (date == null)
return date;
Date theDate = null;
try {
if(date.endsWith(NO_TIME)) {
if (date.endsWith(NO_TIME)) {
date = date.replaceAll(NO_TIME, "");
theDate = DateTimeFormat.getFormat("yyyyMMdd").parse(date);
}else {
} else {
theDate = DateTimeFormat.getFormat("yyyyMMdd_HH-mm-ss").parse(date);
}
}catch (Exception e) {
//Window.alert(e.toString());
} catch (Exception e) {
// Window.alert(e.toString());
}
if(theDate!=null) {
if (theDate != null) {
return DateTimeFormat.getFormat("dd-MM-yyyy").format(theDate);
}
return date;
}
/**
* Full name to layer name.
*
* @param layerFullName the layer full name
* @param splitChar the split char
* @return the string
*/
public static String fullNameToLayerName(String layerFullName, String splitChar) {
if (layerFullName == null || layerFullName.isEmpty())
return layerFullName;
int layerSep = layerFullName.lastIndexOf(splitChar);
return layerSep > 0 && (layerSep + 1) < layerFullName.length()
? layerFullName.substring(layerSep + 1, layerFullName.length())
: layerFullName;
}
}