Mercurial > dive4elements > river
view flys-client/src/main/java/de/intevation/flys/client/client/ui/ChartOutputTab.java @ 280:b493d606fdef
Enabled the client to request charts in different sizes.
flys-client/trunk@1909 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 12 May 2011 09:14:46 +0000 |
parents | f4c8ce11df33 |
children | c271012a97a3 |
line wrap: on
line source
package de.intevation.flys.client.client.ui; import java.util.Date; import com.google.gwt.core.client.GWT; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.Img; import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.events.CloseClickHandler; import com.smartgwt.client.widgets.events.CloseClientEvent; import de.intevation.flys.client.shared.model.Collection; import de.intevation.flys.client.shared.model.OutputMode; import de.intevation.flys.client.client.Config; import de.intevation.flys.client.shared.model.Artifact; /** * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public class ChartOutputTab extends OutputTab { /** The canvas that wraps the chart toolbar.*/ protected Canvas tbarPanel; /** The canvas that wraps the theme editor.*/ protected Canvas left; /** The canvas that wraps the chart.*/ protected Canvas right; /** * The default constructor to create a new ChartOutputTab. * * @param title The title of this tab. * @param collection The Collection which this chart belongs to. * @param mode The OutputMode. */ public ChartOutputTab( String title, Collection collection, OutputMode mode, CollectionView collectionView ){ super(title, collection, mode); tbarPanel = new Canvas(); left = new Canvas(); right = new Canvas(); tbarPanel.setBorder("1px solid black"); tbarPanel.setHeight(25); left.setBorder("1px solid black"); left.setWidth("25%"); right.setWidth("*"); VLayout vLayout = new VLayout(); vLayout.setMembersMargin(2); HLayout hLayout = new HLayout(); hLayout.setWidth100(); hLayout.setHeight100(); hLayout.setMembersMargin(10); hLayout.addMember(left); hLayout.addMember(right); right.addChild(createChartPanel()); left.addChild(createThemeControlPanel()); tbarPanel.addChild( createTBarPanel(collectionView)); vLayout.addMember(tbarPanel); vLayout.addMember(hLayout); setPane(vLayout); } protected Canvas createTBarPanel( final CollectionView collectionView ) { HLayout hLayout = new HLayout(); hLayout.setWidth100(); hLayout.setHeight100(); hLayout.setMembersMargin(10); IButton datacage = new IButton("Datenkorb"); datacage.setHeight(25); datacage.setMargin(5); hLayout.addMember(datacage); datacage.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { GWT.log("Clicked 'datacage' button."); openDatacageWindow( collectionView.getArtifact()); } }); return hLayout; } protected void openDatacageWindow(Artifact artifact) { final DatacageWindow dc = new DatacageWindow(artifact); dc.addCloseClickHandler(new CloseClickHandler() { public void onCloseClick(CloseClientEvent event) { dc.destroy(); } }); dc.show(); } protected Canvas createChartPanel() { Img chart = getChartImg(); chart.setWidth100(); chart.setHeight100(); return chart; } protected Canvas createThemeControlPanel() { Label label = new Label("Themensteuerung"); label.setHeight(25); label.setMargin(5); return label; } /** * Builds the chart image and returns it. * * @return the chart image. */ protected Img getChartImg() { return new Img(getImgUrl()); } /** * Builds the URL that points to the chart image. * * @return the URL to the chart image. */ protected String getImgUrl() { Config config = Config.getInstance(); String imgUrl = GWT.getModuleBaseURL(); imgUrl += "chart"; imgUrl += "?uuid=" + collection.identifier(); imgUrl += "&type=" + mode.getName(); imgUrl += "&server=" + config.getServerUrl(); imgUrl += "&locale=" + config.getLocale(); imgUrl += "×tamp=" + new Date().getTime(); imgUrl += "&width=" + Integer.toString(600); imgUrl += "&height=" + Integer.toString(500); return imgUrl; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :