annotate gwt-client/src/main/java/org/dive4elements/river/client/client/ui/minfo/BedCampaignChart.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: 5993
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 BedCampaignChart 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
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
30 public BedCampaignChart(Artifact artifact, ResizedHandler resizeHandler) {
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
31 super();
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
32
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
33 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
34 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
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 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
37 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
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
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
40 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
41 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
42 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
43
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
44 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
45 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
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 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
48 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
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 else {
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
51 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
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
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
54 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
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 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
57 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
58 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
59 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
60 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
61 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
62 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
63
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
64 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
65 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
66 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
67 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
68 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
69 jfix.put("bed", jfilter);
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
70 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
71
8865
0d7c8c943b60 URL-encode URLs (potentially) containing invalid characters.
Tom Gottfried <tom@intevation.de>
parents: 5993
diff changeset
72 String imgUrl = URL.encode(GWT.getModuleBaseURL()
0d7c8c943b60 URL-encode URLs (potentially) containing invalid characters.
Tom Gottfried <tom@intevation.de>
parents: 5993
diff changeset
73 + "bed-km-chart"
0d7c8c943b60 URL-encode URLs (potentially) containing invalid characters.
Tom Gottfried <tom@intevation.de>
parents: 5993
diff changeset
74 + "?locale=" + locale
0d7c8c943b60 URL-encode URLs (potentially) containing invalid characters.
Tom Gottfried <tom@intevation.de>
parents: 5993
diff changeset
75 + "&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
76
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
77 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
78 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
79 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
80 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
81 }
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
82 else {
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 = 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
84 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
85 }
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
86 }
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
87 }

http://dive4elements.wald.intevation.org