comparison flys-client/src/main/java/org/dive4elements/river/client/client/ui/map/MapPositionPanel.java @ 5834:f507086aa94b

Repaired internal references.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 12:31:32 +0200
parents flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPositionPanel.java@c1292aab6aa9
children 821a02bbfb4e
comparison
equal deleted inserted replaced
5833:a2bdc0f524e8 5834:f507086aa94b
1 package de.intevation.flys.client.client.ui.map;
2
3 import com.google.gwt.i18n.client.NumberFormat;
4
5 import com.smartgwt.client.types.Alignment;
6 import com.smartgwt.client.widgets.Label;
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 import org.gwtopenmaps.openlayers.client.event.EventHandler;
14 import org.gwtopenmaps.openlayers.client.event.EventObject;
15 import org.gwtopenmaps.openlayers.client.util.JSObject;
16
17 /**
18 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
19 */
20 public class MapPositionPanel extends HLayout {
21
22 protected MapWidget mapWidget;
23 protected final Map map;
24
25 protected Label x;
26 protected Label y;
27
28
29 public MapPositionPanel(MapWidget mapWidget) {
30 this.mapWidget = mapWidget;
31 this.map = mapWidget.getMap();
32
33 this.x = new Label();
34 this.y = new Label();
35 Label d = new Label("|");
36
37 setAlign(Alignment.RIGHT);
38 setMembersMargin(2);
39
40 setWidth(150);
41 x.setWidth(25);
42 y.setWidth(25);
43 d.setWidth(5);
44
45 addMember(x);
46 addMember(d);
47 addMember(y);
48
49 // TODO This is not an optimal way to get the mouse position but makes
50 // the wrapper canvas superfluous.
51 this.map.getEvents().register("mousemove", map, new EventHandler() {
52
53 @Override
54 public void onHandle(EventObject eventObject) {
55 JSObject xy = eventObject.getJSObject().getProperty("xy");
56 Pixel px = Pixel.narrowToPixel(xy);
57 LonLat lonlat = map.getLonLatFromPixel(px);
58
59 setX(lonlat.lon());
60 setY(lonlat.lat());
61 }
62 });
63 }
64
65
66 protected void setX(double x) {
67 NumberFormat f = NumberFormat.getFormat("#0.0000");
68 this.x.setContents(f.format(x).toString());
69 }
70
71
72 protected void setY(double y) {
73 NumberFormat f = NumberFormat.getFormat("#0.0000");
74 this.y.setContents(f.format(y).toString());
75 }
76 }
77 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org