annotate gwt-client/src/main/java/org/dive4elements/river/client/client/widgets/DischargeTablesChart.java @ 5838:5aa05a7a34b7

Rename modules to more fitting names.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 15:23:37 +0200
parents flys-client/src/main/java/org/dive4elements/river/client/client/widgets/DischargeTablesChart.java@821a02bbfb4e
children 172338b1407f
rev   line source
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
1 package org.dive4elements.river.client.client.widgets;
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
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
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
9 import org.dive4elements.river.client.shared.model.Artifact;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
10 import org.dive4elements.river.client.shared.model.ArtifactDescription;
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
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 }

http://dive4elements.wald.intevation.org