layer_switcher #3

Closed
francesco.mangiacrapa wants to merge 12 commits from layer_switcher into master
12 changed files with 282 additions and 71 deletions
Showing only changes of commit 56f23d9acc - Show all commits

View File

@ -18,6 +18,7 @@
<wb-module deploy-name="geoportal-data-viewer-app-2.0.0-SNAPSHOT">
@ -38,6 +39,7 @@
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
@ -58,6 +60,7 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
@ -78,6 +81,7 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
@ -94,6 +98,7 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
@ -110,12 +115,10 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="geoportal-data-common-1.2.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-common/geoportal-data-common">
<dependent-module archiveName="geoportal-data-common-1.2.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-common/geoportal-data-common">
<dependency-type>uses</dependency-type>
</dependent-module>
@ -136,6 +139,7 @@
<property name="java-output-path" value="/geoportal-data-viewer-app/target/geoportal-data-viewer-app-0.0.1-SNAPSHOT/WEB-INF/classes"/>
@ -154,6 +158,7 @@
<property name="context-root" value="geoportal-data-viewer-app"/>
@ -174,6 +179,7 @@
</wb-module>
@ -194,4 +200,5 @@
</project-modules>

View File

@ -6,7 +6,7 @@
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard' /> -->
<inherits name='com.google.gwt.user.theme.standard.Standard' />
<inherits name='ol.GwtOL' />

View File

@ -13,6 +13,9 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMap
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ClosedViewDetailsEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ClosedViewDetailsEventHandler;
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.events.DoActionOnDetailLayersEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.MapExtentToEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.MapExtentToEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent;
@ -23,7 +26,6 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMini
import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.GeonaDataViewMainPanel;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.dandd.DragDropLayer;
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery;
@ -38,7 +40,6 @@ import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.RootPanel;
import ol.Coordinate;
@ -89,24 +90,8 @@ public class GeoportalDataViewer implements EntryPoint {
* This is the entry point method.
*/
public void onModuleLoad() {
FlowPanel fp = new FlowPanel();
for (int i = 0; i < 10; i++) {
DragDropLayer dandd = new DragDropLayer("Layer: "+i, true, true);
fp.add(dandd);
}
RootPanel.get(APP_DIV).add(fp);
mainPanel = new GeonaDataViewMainPanel(applicationBus, getClientHeight());
//RootPanel.get(APP_DIV).add(mainPanel);
RootPanel.get(APP_DIV).add(mainPanel);
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@ -209,7 +194,6 @@ public class GeoportalDataViewer implements EntryPoint {
});
bindEvents();
}
/**
@ -353,6 +337,34 @@ public class GeoportalDataViewer implements EntryPoint {
}
});
applicationBus.addHandler(DoActionOnDetailLayersEvent.TYPE, new DoActionOnDetailLayersEventHandler() {
@Override
public void onDoActionOnDetailLayers(DoActionOnDetailLayersEvent doActionOnDetailLayersEvent) {
DO_LAYER_ACTION doAction = doActionOnDetailLayersEvent.getDoAction();
switch (doAction) {
case OPACITY:
olMapMng.getOLOSMMap().setWMSDetailLayerOpacity(doActionOnDetailLayersEvent.getLayerSource(),
doActionOnDetailLayersEvent.getOpacity());
break;
case SWAP:
break;
case VISIBILITY:
olMapMng.getOLOSMMap().setWMSDetailLayerVisible(doActionOnDetailLayersEvent.getLayerSource(),
doActionOnDetailLayersEvent.getVisibility());
break;
default:
break;
}
}
});
}
private void performWFSQueryOnCentroid(RecordDV record) {

View File

@ -89,6 +89,8 @@ public class LayerManager {
private org.gcube.application.geoportalcommon.shared.LayerItem baseLayerFromISProfile;
private OverlayLayerManager overlayLayerManager;
/**
* Instantiates a new layer manager.
*
@ -96,6 +98,7 @@ public class LayerManager {
*/
public LayerManager(HandlerManager applicationBus) {
this.applicationBus = applicationBus;
overlayLayerManager = new OverlayLayerManager(applicationBus);
bindEvents();
}
@ -312,6 +315,8 @@ public class LayerManager {
public void removeAllDetailLayers() {
mapDetailLayerObjects.clear();
olMap.removeAllDetailLayers();
overlayLayerManager.resetLayers();
overlayLayerManager.hide();
}
/**
@ -422,6 +427,8 @@ public class LayerManager {
if (dlo == null) {
mapDetailLayerObjects.put(key, lo);
olMap.addWMSDetailLayer(layerItem);
overlayLayerManager.addLayerItem(layerItem);
overlayLayerManager.show();
} else {
GWT.log("Skipping detail layer " + key + " already added to Map");
}

View File

@ -0,0 +1,40 @@
package org.gcube.portlets.user.geoportaldataviewer.client;
import java.util.ArrayList;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.dandd.DragDropLayer;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.FlowPanel;
public class OverlayLayerManager extends DialogBox {
ArrayList<LayerItem> layers = new ArrayList<LayerItem>();
FlowPanel fp = new FlowPanel();
private HandlerManager applicationBus;
public OverlayLayerManager(HandlerManager applicationBus) {
this.applicationBus = applicationBus;
setText("Layers");
getElement().addClassName("myOverlayLayerManager");
fp.getElement().getStyle().setMarginTop(10, Unit.PX);
fp.getElement().getStyle().setMarginBottom(10, Unit.PX);
add(fp);
//getElement().getStyle().setZIndex(100);
}
void addLayerItem(LayerItem layer) {
DragDropLayer dandd = new DragDropLayer(applicationBus, layer, true, true);
layers.add(layer);
fp.add(dandd);
}
public void resetLayers() {
layers.clear();
fp.clear();
}
}

View File

@ -0,0 +1,96 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import com.google.gwt.event.shared.GwtEvent;
/**
* The Class DoActionOnDetailLayersEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Oct 8, 2021
*/
public class DoActionOnDetailLayersEvent extends GwtEvent<DoActionOnDetailLayersEventHandler> {
public static Type<DoActionOnDetailLayersEventHandler> TYPE = new Type<DoActionOnDetailLayersEventHandler>();
/**
* The Enum DO_LAYER_ACTION.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Oct 8, 2021
*/
public static enum DO_LAYER_ACTION {
VISIBILITY, SWAP, OPACITY
}
private DO_LAYER_ACTION doAction;
private LayerItem layerSource;
private LayerItem layerTarget;
private int opacity;
private boolean visibility;
/**
* Instantiates a new added layer to map event.
*
* @param action the action
* @param layerSource the layer source
* @param layerTarget the layer target
*/
public DoActionOnDetailLayersEvent(DO_LAYER_ACTION action, LayerItem layerSource, LayerItem layerTarget) {
this.layerSource = layerSource;
this.layerTarget = layerTarget;
this.doAction = action;
}
public void setOpacity(int opacity) {
this.opacity = opacity;
}
public void setVisibility(boolean visibility) {
this.visibility = visibility;
}
/**
* Gets the associated type.
*
* @return the associated type
*/
@Override
public Type<DoActionOnDetailLayersEventHandler> getAssociatedType() {
return TYPE;
}
/**
* Dispatch.
*
* @param handler the handler
*/
@Override
protected void dispatch(DoActionOnDetailLayersEventHandler handler) {
handler.onDoActionOnDetailLayers(this);
}
public DO_LAYER_ACTION getDoAction() {
return doAction;
}
public LayerItem getLayerSource() {
return layerSource;
}
public LayerItem getLayerTarget() {
return layerTarget;
}
public int getOpacity() {
return opacity;
}
public boolean getVisibility() {
return visibility;
}
}

View File

@ -0,0 +1,21 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import com.google.gwt.event.shared.EventHandler;
/**
* The Interface DoActionOnDetailLayersEventHandler.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Oct 8, 2021
*/
public interface DoActionOnDetailLayersEventHandler extends EventHandler {
/**
* On do action on detail layers.
*
* @param doActionOnDetailLayersEvent the do action on detail layers event
*/
void onDoActionOnDetailLayers(DoActionOnDetailLayersEvent doActionOnDetailLayersEvent);
}

View File

@ -58,7 +58,6 @@ import ol.source.Source;
import ol.source.Vector;
import ol.source.XyzOptions;
// TODO: Auto-generated Javadoc
/**
* The Class OpenLayerOSM.
*
@ -131,7 +130,9 @@ public abstract class OpenLayerOSM {
private boolean isQueryPointActive;
private java.util.Map<String, Image> wmsDetailsLayerMap;
private HashMap<String, Image> wmsDetailsLayerMap;
private Integer[] wmsDetailsLayerZIndex = new Integer[100];
private HashMap<String, Image> wmsLayerMap;
@ -149,6 +150,10 @@ public abstract class OpenLayerOSM {
public OpenLayerOSM(String divTargetId, HandlerManager eventBus) {
this.eventBus = eventBus;
for (int i = 0; i < 100; i++) {
wmsDetailsLayerZIndex[i] = 1000 + i;
}
// create a OSM-layer
XyzOptions xyzOptions = OLFactory.createOptions();
// osmSourceOptions.setCrossOrigin("Anonymous");
@ -414,9 +419,6 @@ public abstract class OpenLayerOSM {
}
Image wmsLayer = new Image(layerOptions);
// visibleLayerItems
map.addLayer(wmsLayer);
wmsDetailsLayerMap.put(key, wmsLayer);
@ -716,7 +718,6 @@ public abstract class OpenLayerOSM {
return this.map != null;
}
/**
* Gets the layers from map.
*
@ -770,4 +771,29 @@ public abstract class OpenLayerOSM {
return wmsLayerMap;
}
public void setWMSDetailLayerVisible(LayerItem layerItem, boolean visible) {
String key = layerItem.getName();
Image layer = wmsDetailsLayerMap.get(key);
layer.setVisible(visible);
}
public void setWMSDetailLayerOpacity(LayerItem layerItem, int opacity) {
String key = layerItem.getName();
Image layer = wmsDetailsLayerMap.get(key);
layer.setOpacity(opacity);
}
public void swapLayers(LayerItem layerItem, LayerItem layerItem2) {
String key1 = layerItem.getName();
Image layer1 = wmsDetailsLayerMap.get(key1);
String key2 = layerItem.getName();
Image layer2 = wmsDetailsLayerMap.get(key2);
int zIndex1 = layer1.getZIndex();
int zIndex2 = layer2.getZIndex();
layer1.setZIndex(zIndex2);
layer2.setZIndex(zIndex1);
}
}

View File

@ -1,11 +1,17 @@
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.shared.gis.LayerItem;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.CheckBox;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.DragLeaveEvent;
import com.google.gwt.event.dom.client.DragLeaveHandler;
import com.google.gwt.event.dom.client.DragOverEvent;
@ -14,6 +20,9 @@ import com.google.gwt.event.dom.client.DragStartEvent;
import com.google.gwt.event.dom.client.DragStartHandler;
import com.google.gwt.event.dom.client.DropEvent;
import com.google.gwt.event.dom.client.DropHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
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;
@ -28,9 +37,11 @@ public class DragDropLayer extends FlowPanel {
private Label label;
private CheckBox checkBoxVisibility = new CheckBox();
private Button button = new Button();
private HandlerManager applicationBus;
public DragDropLayer(String text, boolean draggable, boolean droppable) {
this.label = new Label(text);
public DragDropLayer(HandlerManager applicationBus, LayerItem layer, boolean draggable, boolean droppable) {
this.applicationBus = applicationBus;
this.label = new Label(layer.getName());
getElement().getStyle().setMarginTop(5, Unit.PX);
getElement().getStyle().setMarginBottom(10, Unit.PX);
@ -53,11 +64,23 @@ public class DragDropLayer extends FlowPanel {
FlexTable ft = new FlexTable();
ft.setWidget(0, 0, button);
checkBoxVisibility.getElement().getStyle().setMarginLeft(10, Unit.PX);
checkBoxVisibility.setValue(true);
ft.setWidget(0, 1, checkBoxVisibility);
ft.setWidget(0, 2, label);
ft.setWidget(1, 2, new SimplePanel(rs));
add(ft);
button.setIcon(IconType.MOVE);
checkBoxVisibility.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
DoActionOnDetailLayersEvent dae = new DoActionOnDetailLayersEvent(DO_LAYER_ACTION.VISIBILITY, layer, null);
dae.setVisibility(checkBoxVisibility.getValue());
applicationBus.fireEvent(dae);
}
});
}
private void initDrag() {

View File

@ -1,25 +0,0 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui.dandd;
import com.github.gwtbootstrap.client.ui.CheckBox;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
public class LayerContainer extends FlowPanel{
private CheckBox checkBoxVisibility = new CheckBox();
private Label label;
private RangeSlider rs = new RangeSlider();
private HorizontalPanel hp = new HorizontalPanel();
private DragDropLayer dd = new DragDropLayer(DEBUG_ID_PREFIX, true, true);
public LayerContainer(String layerName) {
add(dd);
hp.add(checkBoxVisibility);
label = new Label(layerName);
hp.add(label);
add(hp);
add(rs);
}
}

View File

@ -6,7 +6,7 @@
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard' /> -->
<inherits name='com.google.gwt.user.theme.standard.Standard' />
<inherits name='ol.GwtOL' />

View File

@ -334,3 +334,7 @@ body {
background: #04AA6D;
cursor: pointer;
}
.myOverlayLayerManager{
border-radius: 20px;
}