Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/client/widgets/DischargeTablesChart.java @ 5100:3557570fef51
Renamed 'Pegelnullpunkt/Gauge zero ground' to 'PNP/GZG'.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Tue, 26 Feb 2013 10:39:22 +0100 |
parents | 6ae99d996f79 |
children |
rev | line source |
---|---|
4218
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.client.widgets; |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import com.google.gwt.core.client.GWT; |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 import com.smartgwt.client.widgets.Canvas; |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import com.smartgwt.client.widgets.Img; |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 import com.smartgwt.client.widgets.events.ResizedEvent; |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 import com.smartgwt.client.widgets.events.ResizedHandler; |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 import de.intevation.flys.client.shared.model.Artifact; |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 import de.intevation.flys.client.shared.model.ArtifactDescription; |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 public class DischargeTablesChart extends Canvas implements ResizedHandler { |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 protected Artifact artifact; |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 protected Img img; |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 public DischargeTablesChart() { |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 super(); |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 } |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 public DischargeTablesChart(Artifact artifact) { |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 super(); |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 this.artifact = artifact; |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 init(); |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 } |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 private void init() { |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 addChild(createImage()); |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 addResizedHandler(this); |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 setSize("100%", "100%"); |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 } |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 protected Img createImage() { |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 img = new Img(getUrl()); |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 img.setSize("100%", "100%"); |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 return img; |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 } |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 protected String getUrl() { |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 String url = GWT.getModuleBaseURL(); |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 url += "dischargetablesoverview"; |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 url += "?gauge=" + getGauge(); |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 url += "&format=png"; |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 String[] timerange = getTimerange(); |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 url += "&lower=" + timerange[0]; |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 url += "&upper=" + timerange[1]; |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 int width = 600; |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 int height = 400; |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 if (img != null) { |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 width = img.getWidth(); |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 height = img.getHeight(); |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 } |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 url += "&width=" + String.valueOf(width); |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 url += "&height=" + String.valueOf(height); |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 // add time millis to 'deactivate' caching |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 url += "&timemillis" + System.currentTimeMillis(); |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 GWT.log("DischargeTablesService URL = '" + url + "'"); |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 return url; |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 } |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 protected String getGauge() { |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 ArtifactDescription desc = artifact.getArtifactDescription(); |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 return desc.getReferenceGauge(); |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 } |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 protected String[] getTimerange() { |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 ArtifactDescription desc = artifact.getArtifactDescription(); |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 String yearStr = desc.getDataValueAsString("year_range"); |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 if (yearStr != null && yearStr.length() > 0) { |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 return yearStr.split(";"); |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
80 } |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 return new String[2]; |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 } |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
84 |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 @Override |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 public void onResized(ResizedEvent event) { |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 GWT.log("resized discharge tables overview chart"); |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
88 img.setSrc(getUrl()); |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 } |
6ae99d996f79
flys/issue903: Display the discharge tables of the selected gauge as chart in historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
90 } |