comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/DigitizePanel.java @ 5612:4f935415bb20

Hopefully fix for some map resizing issues.
author Christian Lins <christian.lins@intevation.de>
date Tue, 09 Apr 2013 15:32:46 +0200
parents 8d0af912351c
children
comparison
equal deleted inserted replaced
5611:17e2324c760e 5612:4f935415bb20
1 package de.intevation.flys.client.client.ui; 1 package de.intevation.flys.client.client.ui;
2 2
3 import com.google.gwt.core.client.GWT; 3 import com.google.gwt.core.client.GWT;
4 import com.google.gwt.user.client.rpc.AsyncCallback; 4 import com.google.gwt.user.client.rpc.AsyncCallback;
5
6 import com.smartgwt.client.types.VerticalAlignment; 5 import com.smartgwt.client.types.VerticalAlignment;
7 import com.smartgwt.client.util.SC; 6 import com.smartgwt.client.util.SC;
8 import com.smartgwt.client.widgets.Canvas; 7 import com.smartgwt.client.widgets.Canvas;
9 import com.smartgwt.client.widgets.Label; 8 import com.smartgwt.client.widgets.Label;
10 import com.smartgwt.client.widgets.events.ParentMovedEvent; 9 import com.smartgwt.client.widgets.events.ParentMovedEvent;
33 32
34 import java.util.List; 33 import java.util.List;
35 34
36 import org.gwtopenmaps.openlayers.client.Map; 35 import org.gwtopenmaps.openlayers.client.Map;
37 import org.gwtopenmaps.openlayers.client.control.Attribution; 36 import org.gwtopenmaps.openlayers.client.control.Attribution;
37 import org.gwtopenmaps.openlayers.client.layer.TransitionEffect;
38 import org.gwtopenmaps.openlayers.client.layer.WMS; 38 import org.gwtopenmaps.openlayers.client.layer.WMS;
39 import org.gwtopenmaps.openlayers.client.layer.WMSOptions; 39 import org.gwtopenmaps.openlayers.client.layer.WMSOptions;
40 import org.gwtopenmaps.openlayers.client.layer.WMSParams; 40 import org.gwtopenmaps.openlayers.client.layer.WMSParams;
41 41
42 42
61 } 61 }
62 62
63 63
64 @Override 64 @Override
65 public Canvas create(DataList list) { 65 public Canvas create(DataList list) {
66 List<Data> data = list.getAll(); // FIXME: data is not used? getAll() side-effects?
67 helperContainer.addVisibilityChangedHandler(this); 66 helperContainer.addVisibilityChangedHandler(this);
68 67
69 DataList clone = (DataList) list.clone(); 68 DataList clone = (DataList) list.clone();
70 List<Data> all = clone.getAll(); 69 List<Data> all = clone.getAll();
71 all.remove(UESK_BARRIERS); 70 all.remove(UESK_BARRIERS);
104 */ 103 */
105 @Override 104 @Override
106 protected Canvas createWidget(DataList data) { 105 protected Canvas createWidget(DataList data) {
107 GWT.log("DigitizePanel - createWidget()"); 106 GWT.log("DigitizePanel - createWidget()");
108 107
109 VLayout layout = new VLayout(); 108 VLayout layout = new VLayout();
110 layout.setAlign(VerticalAlignment.TOP); 109 layout.setAlign(VerticalAlignment.TOP);
111 layout.setHeight(25); 110 layout.setHeight(25);
112 111
113 int size = data.size(); 112 int size = data.size();
114 113
130 } 129 }
131 130
132 131
133 @Override 132 @Override
134 protected Data[] getData() { 133 protected Data[] getData() {
135 Data[] total = new Data[1]; 134 final Data[] total = new Data[1];
136 135
137 if (floodMap != null) { 136 if (floodMap != null) {
138 DataItem item = new DefaultDataItem( 137 DataItem item = new DefaultDataItem(
139 UESK_BARRIERS, UESK_BARRIERS, floodMap.getFeaturesAsGeoJSON()); 138 UESK_BARRIERS, UESK_BARRIERS, floodMap.getFeaturesAsGeoJSON());
140 total[0] = new DefaultData( 139 total[0] = new DefaultData(
162 } 161 }
163 }); 162 });
164 helperContainer.addParentMovedHandler(new ParentMovedHandler() { 163 helperContainer.addParentMovedHandler(new ParentMovedHandler() {
165 @Override 164 @Override
166 public void onParentMoved(ParentMovedEvent event) { 165 public void onParentMoved(ParentMovedEvent event) {
166 mapPanel.getFloodMap().updateSize();
167 }
168 });
169 helperContainer.addVisibilityChangedHandler(new VisibilityChangedHandler() {
170 @Override
171 public void onVisibilityChanged(VisibilityChangedEvent event) {
167 mapPanel.doLayout(helperContainer.getWidth(), helperContainer.getHeight()); 172 mapPanel.doLayout(helperContainer.getWidth(), helperContainer.getHeight());
168 } 173 }
169 }); 174 });
170 helperContainer.addMember(mapPanel); 175 helperContainer.addMember(mapPanel);
171 176
172 parameterList.registerCollectionViewTabHandler(this); 177 parameterList.registerCollectionViewTabHandler(this);
173 178
174 WMS axis = getLayer( 179 WMS axis = getLayer(
175 mapInfo.getWmsUrl(), mapInfo.getWmsLayers(), 180 mapInfo.getWmsUrl(), mapInfo.getWmsLayers(),
176 mapInfo.getProjection(), false); 181 mapInfo.getProjection(), false, true);
177 WMS back = getLayer( 182 WMS back = getLayer(
178 mapInfo.getBackgroundWmsUrl(), mapInfo.getBackgroundWmsLayers(), 183 mapInfo.getBackgroundWmsUrl(), mapInfo.getBackgroundWmsLayers(),
179 mapInfo.getProjection(), false); 184 mapInfo.getProjection(), false, false);
180 185
181 map.addLayer(back); 186 map.addLayer(back);
182 map.addLayer(axis); 187 map.addLayer(axis);
183 188
184 String hws = getDataValue("state.winfo.uesk.dc-hws", "uesk.hws"); 189 String hws = getDataValue("state.winfo.uesk.dc-hws", "uesk.hws");
186 WMS hwsLayer = getLayer( 191 WMS hwsLayer = getLayer(
187 //TODO: Use Mapinfo to get hws layer infos. 192 //TODO: Use Mapinfo to get hws layer infos.
188 mapInfo.getWmsUrl().replace("river", "user"), 193 mapInfo.getWmsUrl().replace("river", "user"),
189 "ms_layer-hws-lines" + artifact.getUuid(), 194 "ms_layer-hws-lines" + artifact.getUuid(),
190 mapInfo.getProjection(), 195 mapInfo.getProjection(),
191 false); 196 false, true);
192 map.addLayer(hwsLayer); 197 map.addLayer(hwsLayer);
193 } 198 }
194 String userRgd = getDataValue("state.winfo.uesk.user-rgd", "uesk.user-rgd"); 199 String userRgd = getDataValue("state.winfo.uesk.user-rgd", "uesk.user-rgd");
195 if (userRgd != null && userRgd.length() > 0) { 200 if (userRgd != null && userRgd.length() > 0) {
196 WMS userLayer = getLayer( 201 WMS userLayer = getLayer(
197 //TODO: Use Mapinfo to get hws layer infos. 202 //TODO: Use Mapinfo to get hws layer infos.
198 mapInfo.getWmsUrl().replace("river", "user"), 203 mapInfo.getWmsUrl().replace("river", "user"),
199 "ms_layer-user-rgd" + artifact.getUuid(), 204 "ms_layer-user-rgd" + artifact.getUuid(),
200 mapInfo.getProjection(), 205 mapInfo.getProjection(),
201 false); 206 false, true);
202 map.addLayer(userLayer); 207 map.addLayer(userLayer);
203 } 208 }
204 map.addControl(new Attribution()); 209 map.addControl(new Attribution());
205 map.zoomToMaxExtent(); 210 map.zoomToMaxExtent();
206 } 211
207 212 mapPanel.doLayout(helperContainer.getWidth(), helperContainer.getHeight());
208 213 }
209 protected WMS getLayer(String url, String layers, String proj, boolean x) { 214
210 WMSParams params = new WMSParams(); 215
216 protected WMS getLayer(String url, String layers, String proj, boolean isBaseLayer, boolean singleTiled) {
217 final WMSParams params = new WMSParams();
211 params.setLayers(layers); 218 params.setLayers(layers);
212 params.setFormat("image/png"); 219 params.setFormat("image/png");
213 params.setIsTransparent(!x); 220 params.setIsTransparent(!isBaseLayer);
214 221
215 WMSOptions opts = new WMSOptions(); 222 final WMSOptions opts = new WMSOptions();
216 opts.setProjection(proj); 223 opts.setProjection(proj);
217 opts.setSingleTile(true); 224 opts.setSingleTile(false); // FIXME: Make working...
225 opts.setTransitionEffect(TransitionEffect.RESIZE);
218 opts.setRatio(1); 226 opts.setRatio(1);
219 opts.setBuffer(0); 227 opts.setBuffer(0);
220 if (layers.equals("OSM-WMS-Dienst")) { 228 if (layers.equals("OSM-WMS-Dienst")) {
221 opts.setAttribution(MSG.attribution()); 229 opts.setAttribution(MSG.attribution());
222 } 230 }
223 WMS wms = new WMS(layers, url, params, opts); 231 final WMS wms = new WMS(layers, url, params, opts);
224 wms.setIsVisible(true); 232 wms.setIsVisible(true);
225 wms.setIsBaseLayer(x); 233 wms.setIsBaseLayer(isBaseLayer);
226 234
227 return wms; 235 return wms;
228 } 236 }
229 237
230 238

http://dive4elements.wald.intevation.org