Mercurial > dive4elements > river
changeset 2395:cd4fb19ab892
Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
flys-artifacts/trunk@4021 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 10 Feb 2012 08:56:19 +0000 |
parents | 02ac373b6d69 |
children | 2c62bbe2e415 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java |
diffstat | 3 files changed, 53 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Fri Feb 10 08:43:06 2012 +0000 +++ b/flys-artifacts/ChangeLog Fri Feb 10 08:56:19 2012 +0000 @@ -1,3 +1,16 @@ +2012-02-09 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/exports/ChartGenerator.java: Modified + and renamend getDomainAxisRange(). This method is now called + getDomainAxisRangeFromRequest() and returns no longer a Range object but + a String array that consists of the raw string values specified in the + request document. + + * src/main/java/de/intevation/flys/exports/XYChartGenerator.java: + Implemented the missing method getDomainAxisRange(). This method returns + a Range object based on the String array returned from + getDomainAxisRangeFromRequest(). + 2012-02-09 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/exports/ChartHelper.java: Added a
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java Fri Feb 10 08:43:06 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java Fri Feb 10 08:56:19 2012 +0000 @@ -1003,9 +1003,11 @@ /** - * Get Range of Domain ("X"-) Axis from request. + * Returns the X-Axis range as String array from request document. + * + * @return a String array with [lower, upper]. */ - protected Range getDomainAxisRange() { + protected String[] getDomainAxisRangeFromRequest() { Element xrange = (Element)XMLUtils.xpath( request, XPATH_CHART_X_RANGE, @@ -1021,30 +1023,7 @@ String lower = xrange.getAttributeNS(uri, "from"); String upper = xrange.getAttributeNS(uri, "to"); - if (lower.length() > 0 && upper.length() > 0) { - try { - double from = Double.parseDouble(lower); - double to = Double.parseDouble(upper); - - if (from == 0 && to == 0) { - logger.debug("No range specified. Lower and upper X == 0"); - return null; - } - - if (from > to) { - double tmp = to; - to = from; - from = tmp; - } - - return new Range(from, to); - } - catch (NumberFormatException nfe) { - logger.warn("Wrong values for domain axis range."); - } - } - - return null; + return new String[] { lower, upper }; }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Fri Feb 10 08:43:06 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Fri Feb 10 08:56:19 2012 +0000 @@ -465,6 +465,41 @@ } + protected Range getDomainAxisRange() { + String[] ranges = getDomainAxisRangeFromRequest(); + + if (ranges == null || ranges.length < 2) { + logger.debug("No zoom range for domain axis specified."); + return null; + } + + if (ranges[0].length() > 0 && ranges[1].length() > 0) { + try { + double from = Double.parseDouble(ranges[0]); + double to = Double.parseDouble(ranges[1]); + + if (from == 0 && to == 0) { + logger.debug("No range specified. Lower and upper X == 0"); + return null; + } + + if (from > to) { + double tmp = to; + to = from; + from = tmp; + } + + return new Range(from, to); + } + catch (NumberFormatException nfe) { + logger.warn("Wrong values for domain axis range."); + } + } + + return null; + } + + protected boolean zoomX(XYPlot plot, ValueAxis axis, Range range, Range x) { return zoom(plot, axis, range, x); }