annotate gwt-client/src/main/java/org/dive4elements/river/client/client/ui/minfo/BedloadCampaignChart.java @ 9801:1d7a72a50183 3.2.x tip

Assume Compose V2, consistently
author Tom Gottfried <tom@intevation.de>
date Thu, 23 Nov 2023 10:14:13 +0100
parents 0d7c8c943b60
children
rev   line source
5861
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5993
ea9eef426962 Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5861
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5861
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5993
ea9eef426962 Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5861
diff changeset
6 * documentation coming with Dive4Elements River for details.
5861
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
9 package org.dive4elements.river.client.client.ui.minfo;
3705
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
10
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
11 import com.google.gwt.core.client.GWT;
8865
0d7c8c943b60 URL-encode URLs (potentially) containing invalid characters.
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
12 import com.google.gwt.http.client.URL;
3705
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
13 import com.google.gwt.json.client.JSONNumber;
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
14 import com.google.gwt.json.client.JSONObject;
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
15 import com.google.gwt.json.client.JSONString;
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
16 import com.smartgwt.client.types.Alignment;
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
17 import com.smartgwt.client.widgets.Img;
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
18 import com.smartgwt.client.widgets.events.ResizedHandler;
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
19 import com.smartgwt.client.widgets.layout.VLayout;
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
20
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
21 import org.dive4elements.river.client.client.Config;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
22 import org.dive4elements.river.client.shared.model.Artifact;
3705
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24 public class BedloadCampaignChart extends VLayout {
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
26 private final Artifact artifact;
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
27
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
28 protected Img chartImg;
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
29
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 5993
diff changeset
30 public BedloadCampaignChart(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 5993
diff changeset
31 Artifact artifact,
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 5993
diff changeset
32 ResizedHandler resizeHandler
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 5993
diff changeset
33 ) {
3705
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
34 super();
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
35
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
36 this.artifact = artifact;
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
37 this.chartImg = new Img();
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
38
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
39 addResizedHandler(resizeHandler);
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
40 setAlign(Alignment.CENTER);
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
41 }
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
42
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
43 public void update() {
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
44 Config config = Config.getInstance();
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
45 String locale = config.getLocale();
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
46
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
47 int hWidth = getWidth() - 12;
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
48 int hHeight = getHeight() - 12;
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
49
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
50 if ((int) (hHeight * 4f / 3) < hWidth) {
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
51 hWidth = (int) (hHeight * 4f / 3);
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
52 }
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
53 else {
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
54 hHeight = (int) (hWidth * 3f / 4);
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
55 }
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
56
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
57 String river = artifact.getArtifactDescription().getRiver();
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
58
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
59 JSONObject jfix = new JSONObject();
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
60 JSONObject jfilter = new JSONObject();
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
61 JSONObject jrName = new JSONObject();
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
62 JSONString jrValue = new JSONString(river);
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
63 JSONObject jextent = new JSONObject();
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
64 JSONNumber jwidth = new JSONNumber(hWidth);
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
65 JSONNumber jheight = new JSONNumber(hHeight);
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
66
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
67 jrName.put("name", jrValue);
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
68 jfilter.put("river", jrName);
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
69 jextent.put("width", jwidth);
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
70 jextent.put("height", jheight);
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
71 jfilter.put("extent", jextent);
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
72 jfix.put("bedload", jfilter);
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
73 String filter = jfix.toString();
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
74
8865
0d7c8c943b60 URL-encode URLs (potentially) containing invalid characters.
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
75 String imgUrl = URL.encode(GWT.getModuleBaseURL()
0d7c8c943b60 URL-encode URLs (potentially) containing invalid characters.
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
76 + "bedload-km-chart"
0d7c8c943b60 URL-encode URLs (potentially) containing invalid characters.
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
77 + "?locale=" + locale
0d7c8c943b60 URL-encode URLs (potentially) containing invalid characters.
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
78 + "&filter=" + filter);
3705
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
79
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
80 if (chartImg != null && hasMember(chartImg)) {
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
81 chartImg.setWidth(hWidth);
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
82 chartImg.setHeight(hHeight);
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
83 chartImg.setSrc(imgUrl);
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
84 }
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
85 else {
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
86 chartImg = new Img(imgUrl, hWidth, hHeight);
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
87 addMember(chartImg);
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
88 }
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
89 }
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
90 }

http://dive4elements.wald.intevation.org