Mercurial > dive4elements > river
view gwt-client/src/main/java/org/dive4elements/river/client/client/ui/sq/SQCampaignChart.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/sq/SQCampaignChart.java@821a02bbfb4e |
children | 172338b1407f |
line wrap: on
line source
package org.dive4elements.river.client.client.ui.sq; 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 org.dive4elements.river.client.client.Config; import org.dive4elements.river.client.shared.model.Artifact; public class SQCampaignChart extends VLayout { private final Artifact artifact; protected Img chartImg; public SQCampaignChart(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("sq", jfilter); String filter = jfix.toString(); String imgUrl = GWT.getModuleBaseURL(); imgUrl += "sq-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); } } }