Mercurial > dive4elements > river
changeset 542:7c57149e8715
Append the x and y ranges determined after zooming with the ZoomboxControl to the attribute document used for the chart creation.
flys-client/trunk@2045 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 03 Jun 2011 06:34:32 +0000 |
parents | ed29599e06e5 |
children | 9c2cf4811a7d |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java flys-client/src/main/java/de/intevation/flys/client/server/ChartOutputServiceImpl.java |
diffstat | 3 files changed, 123 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Wed Jun 01 14:13:29 2011 +0000 +++ b/flys-client/ChangeLog Fri Jun 03 06:34:32 2011 +0000 @@ -1,3 +1,16 @@ +2011-06-03 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/client/server/ChartOutputServiceImpl.java: + Append the selected min and max ranges for x and y axes to the attribute + document. This enables the server to zoom the chart to the specified + view. + + * src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java: + The x and y ranges specified after zooming are stored as instance + variables and used while creating the chart imgage url. The + ChartOutputService will put those ranges into the attribute document for + the chart creation. + 2011-06-01 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java Wed Jun 01 14:13:29 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java Fri Jun 03 06:34:32 2011 +0000 @@ -41,7 +41,6 @@ public static final int THEMEPANEL_MIN_WIDTH = 200; - /** The service that is used to fetch chart information.*/ protected ChartInfoServiceAsync info = GWT.create(ChartInfoService.class); @@ -62,6 +61,11 @@ protected Canvas right; + /** Chart zoom options.*/ + protected double[] xrange; + protected double[] yrange; + + /** * The default constructor to create a new ChartOutputTab. * @@ -81,6 +85,8 @@ left = new Canvas(); right = new Canvas(); tbarPanel = new ChartToolbar(collectionView, this); + xrange = new double[2]; + yrange = new double[2]; left.setBorder("1px solid black"); left.setWidth(THEMEPANEL_MIN_WIDTH); @@ -145,12 +151,12 @@ double[] lower = transformer.transform(evt.getStartX(), evt.getStartY()); double[] upper = transformer.transform(evt.getEndX(), evt.getEndY()); - double xmin = lower[0]; - double xmax = upper[0]; - double ymin = upper[1]; - double ymax = lower[1]; + xrange[0] = lower[0]; + xrange[1] = upper[0]; + yrange[0] = upper[1]; + yrange[1] = lower[1]; - // TODO Trigger the recreation of the chart + updateChartPanel(); } @@ -193,6 +199,11 @@ } + /** + * Returns the existing chart panel. + * + * @return the existing chart panel. + */ public Canvas getChartPanel() { Canvas[] children = right.getChildren(); @@ -227,18 +238,30 @@ } + /** + * Creates a new chart panel with default size. + * + * @return the created chart panel. + */ protected Canvas createChartPanel() { return createChartPanel(DEFAULT_CHART_WIDTH, DEFAULT_CHART_HEIGHT); } + /** + * Creates a new chart panel with specified width and height. + * + * @param width The width for the chart panel. + * @param height The height for the chart panel. + * + * @return the created chart panel. + */ protected Canvas createChartPanel(int width, int height) { Img chart = getChartImg(width, height); chart.setWidth100(); chart.setHeight100(); return chart; - } @@ -260,6 +283,8 @@ * * @param width The width of the requested chart. * @param height The height of the requested chart. + * @param xr Optional x range (used for zooming). + * @param yr Optional y range (used for zooming). * * @return the URL to the chart image. */ @@ -276,6 +301,18 @@ imgUrl += "&width=" + Integer.toString(width); imgUrl += "&height=" + Integer.toString(height); + if (xrange != null) { + GWT.log("Zoom to xrange."); + imgUrl += "&minx=" + Double.toString(xrange[0]); + imgUrl += "&maxx=" + Double.toString(xrange[1]); + } + + if (yrange != null) { + GWT.log("Zoom to xrange."); + imgUrl += "&miny=" + Double.toString(yrange[0]); + imgUrl += "&maxy=" + Double.toString(yrange[1]); + } + return imgUrl; } }
--- a/flys-client/src/main/java/de/intevation/flys/client/server/ChartOutputServiceImpl.java Wed Jun 01 14:13:29 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/ChartOutputServiceImpl.java Fri Jun 03 06:34:32 2011 +0000 @@ -82,7 +82,13 @@ ArtifactNamespaceContext.NAMESPACE_URI, ArtifactNamespaceContext.NAMESPACE_PREFIX); - appendChartSize(req, doc, ec); + Element attributes = ec.create("attributes"); + + appendChartSize(req, attributes, ec); + appendXRange(req, attributes, ec); + appendYRange(req, attributes, ec); + + doc.appendChild(attributes); return doc; } @@ -94,12 +100,12 @@ * document used to adjust chart settings. * * @param req The request object that might contain the chart size. - * @param doc The attribute document used to adjust chart settings. + * @param attributes The attributes element used to adjust chart settings. * @param ec The ElementCreator that might be used to create new Elements. */ protected void appendChartSize( HttpServletRequest req, - Document doc, + Element attributes, ElementCreator ec) { Element size = ec.create("size"); @@ -115,7 +121,63 @@ ec.addAttr(size, "width", width, true); ec.addAttr(size, "height", height, true); - doc.appendChild(size); + attributes.appendChild(size); + } + + + /** + * This method extracts the x range for the chart from request object and + * appends those range - if it exists - to the attribute document used to + * adjust the chart settings. + * + * @param req The request object that might contain the chart size. + * @param doc The attribute document used to adjust chart settings. + * @param ec The ElementCreator that might be used to create new Elements. + */ + protected void appendXRange( + HttpServletRequest req, + Element attributes, + ElementCreator ec) + { + Element range = ec.create("xrange"); + + String from = req.getParameter("minx"); + String to = req.getParameter("maxx"); + + if (from != null && to != null) { + ec.addAttr(range, "from", from, true); + ec.addAttr(range, "to", to, true); + + attributes.appendChild(range); + } + } + + + /** + * This method extracts the x range for the chart from request object and + * appends those range - if it exists - to the attribute document used to + * adjust the chart settings. + * + * @param req The request object that might contain the chart size. + * @param doc The attribute document used to adjust chart settings. + * @param ec The ElementCreator that might be used to create new Elements. + */ + protected void appendYRange( + HttpServletRequest req, + Element attributes, + ElementCreator ec) + { + Element range = ec.create("yrange"); + + String from = req.getParameter("miny"); + String to = req.getParameter("maxy"); + + if (from != null && to != null) { + ec.addAttr(range, "from", from, true); + ec.addAttr(range, "to", to, true); + + attributes.appendChild(range); + } } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :