Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/client/ui/minfo/BedloadCampaignChart.java @ 3705:f84ed73311f2
Added UI for minfo bed quality calculation and added new services for overview
charts.
flys-client/trunk@5444 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 12 Sep 2012 14:32:17 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/minfo/BedloadCampaignChart.java Wed Sep 12 14:32:17 2012 +0000 @@ -0,0 +1,78 @@ +package de.intevation.flys.client.client.ui.minfo; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.json.client.JSONNumber; +import com.google.gwt.json.client.JSONObject; +import com.google.gwt.json.client.JSONString; +import com.smartgwt.client.types.Alignment; +import com.smartgwt.client.widgets.Img; +import com.smartgwt.client.widgets.events.ResizedHandler; +import com.smartgwt.client.widgets.layout.VLayout; + +import de.intevation.flys.client.client.Config; +import de.intevation.flys.client.shared.model.Artifact; + +public class BedloadCampaignChart extends VLayout { + + private final Artifact artifact; + + protected Img chartImg; + + public BedloadCampaignChart(Artifact artifact, ResizedHandler resizeHandler) { + super(); + + this.artifact = artifact; + this.chartImg = new Img(); + + addResizedHandler(resizeHandler); + setAlign(Alignment.CENTER); + } + + public void update() { + Config config = Config.getInstance(); + String locale = config.getLocale(); + + int hWidth = getWidth() - 12; + int hHeight = getHeight() - 12; + + if ((int) (hHeight * 4f / 3) < hWidth) { + hWidth = (int) (hHeight * 4f / 3); + } + else { + hHeight = (int) (hWidth * 3f / 4); + } + + String river = artifact.getArtifactDescription().getRiver(); + + JSONObject jfix = new JSONObject(); + JSONObject jfilter = new JSONObject(); + JSONObject jrName = new JSONObject(); + JSONString jrValue = new JSONString(river); + JSONObject jextent = new JSONObject(); + JSONNumber jwidth = new JSONNumber(hWidth); + JSONNumber jheight = new JSONNumber(hHeight); + + jrName.put("name", jrValue); + jfilter.put("river", jrName); + jextent.put("width", jwidth); + jextent.put("height", jheight); + jfilter.put("extent", jextent); + jfix.put("bedload", jfilter); + String filter = jfix.toString(); + + String imgUrl = GWT.getModuleBaseURL(); + imgUrl += "bedload-km-chart"; + imgUrl += "?locale=" + locale; + imgUrl += "&filter=" + filter; + + if (chartImg != null && hasMember(chartImg)) { + chartImg.setWidth(hWidth); + chartImg.setHeight(hHeight); + chartImg.setSrc(imgUrl); + } + else { + chartImg = new Img(imgUrl, hWidth, hHeight); + addMember(chartImg); + } + } +}