comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/minfo/BedCampaignChart.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/ui/minfo/BedCampaignChart.java@821a02bbfb4e
children 172338b1407f
comparison
equal deleted inserted replaced
5837:d9901a08d0a6 5838:5aa05a7a34b7
1 package org.dive4elements.river.client.client.ui.minfo;
2
3 import com.google.gwt.core.client.GWT;
4 import com.google.gwt.json.client.JSONNumber;
5 import com.google.gwt.json.client.JSONObject;
6 import com.google.gwt.json.client.JSONString;
7 import com.smartgwt.client.types.Alignment;
8 import com.smartgwt.client.widgets.Img;
9 import com.smartgwt.client.widgets.events.ResizedHandler;
10 import com.smartgwt.client.widgets.layout.VLayout;
11
12 import org.dive4elements.river.client.client.Config;
13 import org.dive4elements.river.client.shared.model.Artifact;
14
15 public class BedCampaignChart extends VLayout {
16
17 private final Artifact artifact;
18
19 protected Img chartImg;
20
21 public BedCampaignChart(Artifact artifact, ResizedHandler resizeHandler) {
22 super();
23
24 this.artifact = artifact;
25 this.chartImg = new Img();
26
27 addResizedHandler(resizeHandler);
28 setAlign(Alignment.CENTER);
29 }
30
31 public void update() {
32 Config config = Config.getInstance();
33 String locale = config.getLocale();
34
35 int hWidth = getWidth() - 12;
36 int hHeight = getHeight() - 12;
37
38 if ((int) (hHeight * 4f / 3) < hWidth) {
39 hWidth = (int) (hHeight * 4f / 3);
40 }
41 else {
42 hHeight = (int) (hWidth * 3f / 4);
43 }
44
45 String river = artifact.getArtifactDescription().getRiver();
46
47 JSONObject jfix = new JSONObject();
48 JSONObject jfilter = new JSONObject();
49 JSONObject jrName = new JSONObject();
50 JSONString jrValue = new JSONString(river);
51 JSONObject jextent = new JSONObject();
52 JSONNumber jwidth = new JSONNumber(hWidth);
53 JSONNumber jheight = new JSONNumber(hHeight);
54
55 jrName.put("name", jrValue);
56 jfilter.put("river", jrName);
57 jextent.put("width", jwidth);
58 jextent.put("height", jheight);
59 jfilter.put("extent", jextent);
60 jfix.put("bed", jfilter);
61 String filter = jfix.toString();
62
63 String imgUrl = GWT.getModuleBaseURL();
64 imgUrl += "bed-km-chart";
65 imgUrl += "?locale=" + locale;
66 imgUrl += "&filter=" + filter;
67
68 if (chartImg != null && hasMember(chartImg)) {
69 chartImg.setWidth(hWidth);
70 chartImg.setHeight(hHeight);
71 chartImg.setSrc(imgUrl);
72 }
73 else {
74 chartImg = new Img(imgUrl, hWidth, hHeight);
75 addMember(chartImg);
76 }
77 }
78 }

http://dive4elements.wald.intevation.org