comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPanel.java @ 5538:ef32ab3c1679

d4e/client: Map preview in DigitizePanel is now properly resized (as long as the project is not reopened).
author Christian Lins <christian.lins@intevation.de>
date Mon, 25 Mar 2013 14:36:39 +0100
parents 95e23bcf6a50
children 8d0af912351c
comparison
equal deleted inserted replaced
5397:7eb6e1f16e9d 5538:ef32ab3c1679
1 package de.intevation.flys.client.client.ui.map; 1 package de.intevation.flys.client.client.ui.map;
2 2
3 import com.google.gwt.core.client.GWT; 3 import com.google.gwt.core.client.GWT;
4 import com.smartgwt.client.widgets.events.ParentMovedEvent; 4 import com.google.gwt.user.client.ui.AbsolutePanel;
5 import com.smartgwt.client.widgets.events.ParentMovedHandler;
6 import com.smartgwt.client.widgets.events.ResizedEvent;
7 import com.smartgwt.client.widgets.events.ResizedHandler;
8 import com.smartgwt.client.widgets.layout.VLayout;
9 5
10 import de.intevation.flys.client.shared.model.BBox; 6 import de.intevation.flys.client.shared.model.BBox;
11 import de.intevation.flys.client.shared.model.MapInfo; 7 import de.intevation.flys.client.shared.model.MapInfo;
12 8
13 import org.gwtopenmaps.openlayers.client.Bounds; 9 import org.gwtopenmaps.openlayers.client.Bounds;
15 11
16 /** 12 /**
17 * Panel that contains a MapWidget and a MapToolbar. 13 * Panel that contains a MapWidget and a MapToolbar.
18 * This panel is used by the flood map calculation input helper. 14 * This panel is used by the flood map calculation input helper.
19 */ 15 */
20 public class MapPanel extends VLayout { 16 public class MapPanel extends AbsolutePanel {
21 17
22 protected MapToolbar toolbar; 18 protected MapToolbar toolbar;
23 19
24 protected FloodMap floodMap; 20 protected FloodMap floodMap;
25 protected MapWidget floodMapWidget; 21 protected MapWidget floodMapWidget;
41 initLayout(); 37 initLayout();
42 } 38 }
43 39
44 40
45 private void initLayout() { 41 private void initLayout() {
46 setWidth100(); 42 setWidth("100%");
47 setHeight100(); 43 setHeight("100%");
48 44
49 floodMapWidget = floodMap.getMapWidget(); 45 floodMapWidget = floodMap.getMapWidget();
50 toolbar = new MapToolbar(floodMap, digitizeEnabled); 46 toolbar = new MapToolbar(floodMap, digitizeEnabled);
51 47
52 addMember(toolbar); 48 add(toolbar);
53 addMember(floodMapWidget); 49 add(floodMapWidget);
54
55 addResizedHandler(new ResizedHandler() {
56 @Override
57 public void onResized(ResizedEvent event) {
58 doLayout();
59 }
60 });
61
62 addParentMovedHandler(new ParentMovedHandler() {
63 @Override
64 public void onParentMoved(ParentMovedEvent event) {
65 floodMapWidget.getMap().updateSize();
66 }
67 });
68 } 50 }
69 51
70 protected void doLayout() { 52 public void updateSize() {
71 int width = getWidth(); 53 floodMapWidget.getMap().updateSize();
72 int height = getHeight(); 54 }
55
56 public void doLayout(int w, int h) {
57 int width = w;
58 int height = h;
73 GWT.log("MapPanel.size: " + width + "x" + height); 59 GWT.log("MapPanel.size: " + width + "x" + height);
74 60
75 width -= 2; // minus black borders 61 width -= 2; // minus black borders
76 height -= toolbar.getHeight() + 4; 62 height -= toolbar.getHeight() + 4;
77 63

http://dive4elements.wald.intevation.org