annotate flys-client/src/main/java/de/intevation/flys/client/client/ui/ChartOutputTab.java @ 78:9ca5160cf080

Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab. flys-client/trunk@1584 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 28 Mar 2011 10:45:45 +0000
parents 571843833129
children d327cff11848
rev   line source
75
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.client.client.ui;
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
78
9ca5160cf080 Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
3 import com.google.gwt.core.client.GWT;
9ca5160cf080 Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
4
75
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5 import com.smartgwt.client.widgets.Canvas;
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6 import com.smartgwt.client.widgets.Img;
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7 import com.smartgwt.client.widgets.Label;
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8 import com.smartgwt.client.widgets.layout.HLayout;
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import de.intevation.flys.client.shared.model.Collection;
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import de.intevation.flys.client.shared.model.OutputMode;
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import de.intevation.flys.client.client.Config;
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 /**
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17 */
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 public class ChartOutputTab extends OutputTab {
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 /** The canvas that wraps the theme editor.*/
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 protected Canvas left;
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 /** The canvas that wraps the chart.*/
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 protected Canvas right;
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 /**
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 * The default constructor to create a new ChartOutputTab.
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 *
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 * @param title The title of this tab.
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 * @param collection The Collection which this chart belongs to.
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 * @param mode The OutputMode.
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 */
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 public ChartOutputTab(String title, Collection collection, OutputMode mode){
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 super(title, collection, mode);
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 left = new Canvas();
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 right = new Canvas();
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 left.setWidth("25%");
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 right.setWidth("*");
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 HLayout hLayout = new HLayout();
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 hLayout.setWidth100();
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 hLayout.setHeight100();
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 hLayout.setMembersMargin(10);
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 hLayout.addMember(left);
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 hLayout.addMember(right);
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 Label todo = new Label("TODO: Implement theme editor.");
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 Img chart = getChartImg();
78
9ca5160cf080 Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
53 chart.setWidth100();
9ca5160cf080 Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
54 chart.setHeight100();
75
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 left.addChild(todo);
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 right.addChild(chart);
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 setPane(hLayout);
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 }
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63 /**
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 * Builds the chart image and returns it.
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65 *
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 * @return the chart image.
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67 */
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 protected Img getChartImg() {
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 return new Img(getImgUrl());
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 }
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73 /**
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 * Builds the URL that points to the chart image.
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75 *
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 * @return the URL to the chart image.
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 */
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78 protected String getImgUrl() {
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79 Config config = Config.getInstance();
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80 String server = config.getServerUrl();
78
9ca5160cf080 Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
81 String uuid = collection.getItem(0).identifier();
9ca5160cf080 Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
82
9ca5160cf080 Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
83 String imgUrl = GWT.getModuleBaseURL();
9ca5160cf080 Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
84 imgUrl += "chart";
9ca5160cf080 Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
85 imgUrl += "?target=chart";
9ca5160cf080 Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
86 imgUrl += "&server=" + server;
9ca5160cf080 Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
87 imgUrl += "&mode=img";
9ca5160cf080 Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
88 imgUrl += "&width=600";
9ca5160cf080 Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
89 imgUrl += "&height=400";
9ca5160cf080 Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
90 imgUrl += "&points=false";
9ca5160cf080 Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
91 imgUrl += "&uuid=" + uuid;
9ca5160cf080 Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
92 imgUrl += "&hash=" + "TODO-HASH";
9ca5160cf080 Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
93
9ca5160cf080 Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
94 GWT.log("IMAGE URL = " + imgUrl);
75
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
96 // TODO Build the correct url that points to the OUT() resource of the
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97 // collection.
78
9ca5160cf080 Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
98 return imgUrl;
75
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
99 }
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100 }
571843833129 Added a panel that will be used to display chart output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org