continue testing

This commit is contained in:
francesco 2020-10-26 17:40:38 +01:00
parent 4a0a4c0c64
commit 44dc4c32ca
9 changed files with 210 additions and 41 deletions

28
pom.xml
View File

@ -55,6 +55,20 @@
<!-- <version>3.6.0</version> -->
<!-- <type>pom</type> -->
<!-- <scope>import</scope> -->
<!-- <exclusions> -->
<!-- <exclusion> -->
<!-- <groupId>com.google.gwt</groupId> -->
<!-- <artifactId>gwt-user</artifactId> -->
<!-- </exclusion> -->
<!-- <exclusion> -->
<!-- <groupId>com.google.gwt</groupId> -->
<!-- <artifactId>gwt-servlet</artifactId> -->
<!-- </exclusion> -->
<!-- <exclusion> -->
<!-- <groupId>com.google.gwt</groupId> -->
<!-- <artifactId>gwt-dev</artifactId> -->
<!-- </exclusion> -->
<!-- </exclusions> -->
<!-- </dependency> -->
<!-- </dependencies> -->
</dependencyManagement>
@ -82,6 +96,20 @@
<groupId>com.github.tdesjardins</groupId>
<artifactId>gwt-ol3</artifactId>
<version>8.0.0-gwt2_9</version>
<!-- <exclusions> -->
<!-- <exclusion> -->
<!-- <groupId>com.google.gwt</groupId> -->
<!-- <artifactId>gwt-user</artifactId> -->
<!-- </exclusion> -->
<!-- <exclusion> -->
<!-- <groupId>com.google.gwt</groupId> -->
<!-- <artifactId>gwt-servlet</artifactId> -->
<!-- </exclusion> -->
<!-- <exclusion> -->
<!-- <groupId>com.google.gwt</groupId> -->
<!-- <artifactId>gwt-dev</artifactId> -->
<!-- </exclusion> -->
<!-- </exclusions> -->
</dependency>
<dependency>
<groupId>com.github.gwtbootstrap</groupId>

View File

@ -42,11 +42,6 @@ public class GeoportalDataViewer implements EntryPoint {
*/
public void onModuleLoad() {
// HTMLPanel htmlPanel = new HTMLPanel("");
// htmlPanel.setWidth("500px");
// htmlPanel.setHeight("500px");
// htmlPanel.getElement().setId("map");
//
mainPanel = new GeonaDataViewMainPanel();
RootPanel.get(APP_DIV).add(mainPanel);
@ -56,7 +51,7 @@ public class GeoportalDataViewer implements EntryPoint {
@Override
public void execute() {
osmExample = new OsmExample(mainPanel.getMapPanel().getElement().getId());
//new OsmExample(htmlPanel.getElement().getId());
mainPanel.setMap(osmExample);
}
});
@ -73,7 +68,6 @@ public class GeoportalDataViewer implements EntryPoint {
@Override
public void onSuccess(String result) {
Window.alert(result);
}

View File

@ -2,13 +2,24 @@ package org.gcube.portlets.user.geoportaldataviewer.client.gis;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import ol.Collection;
import ol.Coordinate;
import ol.Map;
import ol.MapBrowserEvent;
import ol.MapOptions;
import ol.OLFactory;
import ol.OLUtil;
import ol.Overlay;
import ol.OverlayOptions;
import ol.View;
import ol.ViewOptions;
import ol.control.Attribution;
import ol.event.EventListener;
import ol.interaction.Draw;
import ol.interaction.DrawOptions;
import ol.interaction.Extent;
import ol.interaction.ExtentOptions;
import ol.interaction.Interaction;
import ol.interaction.KeyboardPan;
import ol.interaction.KeyboardZoom;
import ol.layer.Image;
@ -20,6 +31,7 @@ import ol.source.ImageWms;
import ol.source.ImageWmsOptions;
import ol.source.ImageWmsParams;
import ol.source.Osm;
import ol.source.Vector;
import ol.source.XyzOptions;
/**
@ -35,6 +47,8 @@ public class OsmExample {
private ViewOptions viewOptions = OLFactory.createOptions();
private ProjectionOptions projectionOptions = OLFactory.createOptions();
private Draw pointDraw;
/* (non-Javadoc)
* @see de.desjardins.ol3.demo.client.example.Example#show()
*/
@ -100,6 +114,17 @@ public class OsmExample {
Attribution attribution = new Attribution();
attribution.setCollapsed(true);
map.addClickListener(new EventListener<MapBrowserEvent>() {
@Override
public void onEvent(MapBrowserEvent event) {
// TODO Auto-generated method stub
event.getCoordinate();
addOverlay();
}
});
map.addControl(attribution);
// add some interactions
@ -132,5 +157,66 @@ public class OsmExample {
}
public Draw addPointVectorSource() {
if(pointDraw==null)
initPointInteraction();
map.addInteraction(pointDraw);
return pointDraw;
}
private void initPointInteraction() {
Vector vectorSource = new Vector();
DrawOptions drawOptions = new DrawOptions();
drawOptions.setSource(vectorSource);
drawOptions.setType("Point");
drawOptions.setMaxPoints(1);
drawOptions.setMinPoints(1);
drawOptions.setWrapX(false);
pointDraw = new Draw(drawOptions);
}
public void removeInteraction(Interaction interaction) {
map.removeInteraction(interaction);
}
public void removeInteractions() {
Collection<Interaction> interactions = map.getInteractions();
if(interactions!=null) {
Interaction[] inters = map.getInteractions().getArray();
for (int i = 0; i < inters.length; i++) {
Interaction inter = inters[i];
map.removeInteraction(inter);
}
}
}
public Extent addExtentInteraction() {
ExtentOptions extentOptions = new ExtentOptions();
extentOptions.setWrapX(false);
//StyleOptions styleOptions = new StyleOptions();
//styleOptions.setStroke(stroke);
//styleOptions.set
//extentOptions.setBoxStyle(new ol.style.Style(styleOptions));
Extent extent = new Extent(extentOptions);
map.addInteraction(extent);
return extent;
}
private void addOverlay() {
/**
* Create an overlay to anchor the popup to the map.
*/
OverlayOptions overlayOptions = new OverlayOptions();
overlayOptions.setAutoPan(true);
Overlay overlay = new Overlay(overlayOptions);
map.addOverlay(overlay);
}
}

View File

@ -1,23 +1,23 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui;
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
public class BasePanel extends Composite {
private static BasePanelUiBinder uiBinder = GWT.create(BasePanelUiBinder.class);
interface BasePanelUiBinder extends UiBinder<Widget, BasePanel> {
}
public BasePanel() {
initWidget(uiBinder.createAndBindUi(this));
}
public BasePanel(String firstName) {
initWidget(uiBinder.createAndBindUi(this));
}
}
//package org.gcube.portlets.user.geoportaldataviewer.client.ui;
//
//import com.google.gwt.core.client.GWT;
//import com.google.gwt.uibinder.client.UiBinder;
//import com.google.gwt.user.client.ui.Composite;
//import com.google.gwt.user.client.ui.Widget;
//
//public class BasePanel extends Composite {
//
// private static BasePanelUiBinder uiBinder = GWT.create(BasePanelUiBinder.class);
//
// interface BasePanelUiBinder extends UiBinder<Widget, BasePanel> {
// }
//
// public BasePanel() {
// initWidget(uiBinder.createAndBindUi(this));
// }
//
// public BasePanel(String firstName) {
// initWidget(uiBinder.createAndBindUi(this));
// }
//
//}

View File

@ -1,4 +1,4 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<!-- <!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<ui:style>
@ -8,4 +8,4 @@
</ui:style>
<g:HTMLPanel>
</g:HTMLPanel>
</ui:UiBinder>
</ui:UiBinder> -->

View File

@ -1,7 +1,12 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OsmExample;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.Tab;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
@ -18,14 +23,28 @@ public class GeonaDataViewMainPanel extends Composite {
@UiField
Tab mapPanel;
@UiField
Button dataPointSelection;
@UiField
Button dataBoxSelection;
private HTMLPanel htmlPanel;
private OsmExample map;
public GeonaDataViewMainPanel() {
initWidget(uiBinder.createAndBindUi(this));
htmlPanel = new HTMLPanel("");
htmlPanel.getElement().setId("map");
htmlPanel.setHeight("600px");
mapPanel.add(htmlPanel);
dataPointSelection.setToggle(true);
dataBoxSelection.setToggle(true);
bindHandlers();
}
public void setHeight(int height) {
@ -36,4 +55,30 @@ public class GeonaDataViewMainPanel extends Composite {
return htmlPanel;
}
public void setMap(OsmExample map) {
this.map = map;
}
public void bindHandlers(){
dataPointSelection.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
map.removeInteractions();
map.addPointVectorSource();
}
});
dataBoxSelection.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
map.removeInteractions();
map.addExtentInteraction();
}
});
}
}

View File

@ -7,7 +7,13 @@
</ui:style>
<g:HTMLPanel ui:field="mainHTMLPanel">
<b:TabPanel ui:field="mainTabPanel" tabPosition="top">
<b:Tab ui:field="mapPanel" active="true">
<b:Tab ui:field="mapPanel" active="true" heading="Map">
<b:ButtonToolbar>
<b:ButtonGroup>
<b:Button ui:field="dataPointSelection">Data Point Selection</b:Button>
<b:Button ui:field="dataBoxSelection">Data Box Selection</b:Button>
</b:ButtonGroup>
</b:ButtonToolbar>
</b:Tab>
</b:TabPanel>
</g:HTMLPanel>

View File

@ -1,4 +1,4 @@
ac<%@page contentType="text/html"%>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%-- Uncomment below lines to add portlet taglibs to jsp
@ -8,15 +8,25 @@ ac<%@page contentType="text/html"%>
<portlet:defineObjects />
--%>
<script
src='<%=request.getContextPath()%>/GeoportalDataViewer/js/jquery-1.10.1.min.js'></script>
<script
src='<%=request.getContextPath()%>/GeoportalDataViewer/js/bootstrap.min.js'></script>
<link
href="//cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.4.3/css/ol.css"
rel="stylesheet" type="text/css">
<script
src="//cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.4.3/build/ol.js"
type="text/javascript"></script>
<link rel="stylesheet"
href="<%=request.getContextPath()%>/"GeoportalDataViewer.css"
href="<%=request.getContextPath()%>/GeoportalDataViewer.css"
type="text/css">
<script type="text/javascript"
src="<%=request.getContextPath()%>/GeoportalDataViewer/GeoportalDataViewer.nocache.js"></script>
<!-- <script type="text/javascript"
src='<%=request.getContextPath()%>/js/jquery.autosize.js'></script> -->
<div id="geoportal-data-viewer"></div>

View File

@ -12,8 +12,8 @@
<portlet-mode>VIEW</portlet-mode>
</supports>
<portlet-info>
<title>GeoPortal DataViewerApp Portlet</title>
<short-title>GeoPortal DataViewerApp Portlet</short-title>
<title>GeoPortal-DataViewerApp-Portlet</title>
<short-title>GeoPortal-DataViewerApp-Portlet</short-title>
</portlet-info>
<portlet-preferences>
<preference>