annotate gwt-client/src/main/java/org/dive4elements/river/client/client/ui/minfo/BedCampaignChart.java @ 5861:172338b1407f

GWT client: Added copyright header.
author Sascha L. Teichmann <teichmann@intevation.de>
date Sun, 28 Apr 2013 14:30:15 +0200
parents 5aa05a7a34b7
children ea9eef426962
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 *
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
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
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
6 * documentation coming with Dive4Elements River for details.
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;
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
12 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
13 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
14 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
15 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
16 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
17 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
18 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
19
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
20 import org.dive4elements.river.client.client.Config;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
21 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
22
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23 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
24
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25 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
26
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
27 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
28
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
29 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
30 super();
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
31
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
32 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
33 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
34
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
35 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
36 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
37 }
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 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
40 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
41 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
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 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
44 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
45
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
46 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
47 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
48 }
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
49 else {
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
50 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
51 }
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 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
54
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
55 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
56 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
57 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
58 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
59 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
60 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
61 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
62
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
63 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
64 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
65 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
66 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
67 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
68 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
69 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
70
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
71 String imgUrl = GWT.getModuleBaseURL();
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
72 imgUrl += "bed-km-chart";
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
73 imgUrl += "?locale=" + locale;
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
74 imgUrl += "&filter=" + filter;
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
75
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
76 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
77 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
78 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
79 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
80 }
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
81 else {
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 = 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
83 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
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 }
f84ed73311f2 Added UI for minfo bed quality calculation and added new services for overview
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
86 }

http://dive4elements.wald.intevation.org