comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPositionPanel.java @ 800:95cc560ce7c4

Added map controls for digitizing and removing barriers. flys-client/trunk@2321 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 12 Jul 2011 13:43:49 +0000
parents
children 9aa1a453eed5
comparison
equal deleted inserted replaced
799:f4299b90c996 800:95cc560ce7c4
1 package de.intevation.flys.client.client.ui.map;
2
3 import com.smartgwt.client.widgets.Canvas;
4 import com.smartgwt.client.widgets.Label;
5 import com.smartgwt.client.widgets.events.MouseMoveEvent;
6 import com.smartgwt.client.widgets.events.MouseMoveHandler;
7 import com.smartgwt.client.widgets.layout.HLayout;
8
9 import org.gwtopenmaps.openlayers.client.LonLat;
10 import org.gwtopenmaps.openlayers.client.Map;
11 import org.gwtopenmaps.openlayers.client.MapWidget;
12 import org.gwtopenmaps.openlayers.client.Pixel;
13
14
15 /**
16 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
17 */
18 public class MapPositionPanel extends HLayout {
19
20 protected MapWidget mapWidget;
21 protected Map map;
22
23 protected Label x;
24 protected Label y;
25
26
27 public MapPositionPanel(MapWidget mapWidget, final Canvas c) {
28 this.mapWidget = mapWidget;
29 this.map = mapWidget.getMap();
30
31 this.x = new Label();
32 this.y = new Label();
33 Label d = new Label("|");
34
35 setWidth(60);
36 setMembersMargin(2);
37
38 x.setWidth(25);
39 y.setWidth(25);
40 d.setWidth(5);
41
42 addMember(x);
43 addMember(d);
44 addMember(y);
45
46 // TODO We should use the MousePosition control provided by
47 // GwtOpenLayers here instead of calculating the mouse pos manually.
48 c.addMouseMoveHandler(new MouseMoveHandler() {
49 public void onMouseMove(MouseMoveEvent e) {
50 int x = e.getX() - c.getPageLeft();
51 int y = e.getY() - c.getPageTop();
52
53 LonLat point = map.getLonLatFromPixel(new Pixel(x, y));
54 setX(point.lon());
55 setY(point.lat());
56 }
57 });
58 }
59
60
61 protected void setX(double x) {
62 this.x.setContents(String.valueOf(x));
63 }
64
65
66 protected void setY(double y) {
67 this.y.setContents(String.valueOf(y));
68 }
69 }
70 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org