Mercurial > dive4elements > river
changeset 2398:5d8d24984819
New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
flys-artifacts/trunk@4024 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 10 Feb 2012 10:24:33 +0000 |
parents | c38063bf99da |
children | 73b15736cb80 |
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, 93 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Fri Feb 10 10:20:02 2012 +0000 +++ b/flys-artifacts/ChangeLog Fri Feb 10 10:24:33 2012 +0000 @@ -1,3 +1,17 @@ +2012-02-10 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/exports/ChartGenerator.java: Defined + new abstract methods for setting and getting Bounds. Modified and + renamed getValueAxisRange(). This method is now called + getValueAxisRangeFromRequest() and returns no longer a Range object but + a String array that consists of the raw string values speicified 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 + getValueAxisRangeFromRequest(). + 2012-02-10 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/jfree/TimeBounds.java: Added new @@ -7,7 +21,7 @@ * src/main/java/de/intevation/flys/jfree/DoubleBounds.java: Made 'lower' always be smaller than 'upper' in the default constructor. -2012-02-11 Sascha L. Teichmann <sascha.teichmann@intevation.de> +2012-02-10 Sascha L. Teichmann <sascha.teichmann@intevation.de> * src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java: Give more precise message when an error occurs in W~W relation. @@ -18,7 +32,7 @@ src/main/resources/messages_de.properties: Improved error messages. -2012-02-09 Ingo Weinzierl <ingo@intevation.de> +2012-02-10 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/exports/ChartGenerator.java: Modified and renamend getDomainAxisRange(). This method is now called @@ -31,13 +45,13 @@ a Range object based on the String array returned from getDomainAxisRangeFromRequest(). -2012-02-09 Ingo Weinzierl <ingo@intevation.de> +2012-02-10 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/exports/ChartHelper.java: Added a helper function to determine the min and max bounds (x and y) for TimeSeriesCollections. -2012-02-09 Ingo Weinzierl <ingo@intevation.de> +2012-02-10 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/jfree/TimeBounds.java, src/main/java/de/intevation/flys/jfree/DoubleBounds.java: Removed
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java Fri Feb 10 10:20:02 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java Fri Feb 10 10:24:33 2012 +0000 @@ -49,6 +49,7 @@ import de.intevation.flys.artifacts.FLYSArtifact; import de.intevation.flys.artifacts.resources.Resources; +import de.intevation.flys.jfree.Bounds; import de.intevation.flys.jfree.EnhancedLineAndShapeRenderer; import de.intevation.flys.jfree.StableXYDifferenceRenderer; import de.intevation.flys.jfree.StyledAreaSeriesCollection; @@ -248,6 +249,14 @@ */ public abstract Range[] getRangesForAxis(int index); + public abstract Bounds getXBounds(int axis); + + protected abstract void setXBounds(int axis, Bounds bounds); + + public abstract Bounds getYBounds(int axis); + + protected abstract void setYBounds(int axis, Bounds bounds); + /** * This method should be used by concrete subclasses to add subtitle to @@ -1027,7 +1036,7 @@ } - protected Range getValueAxisRange() { + protected String[] getValueAxisRangeFromRequest() { Element yrange = (Element)XMLUtils.xpath( request, XPATH_CHART_Y_RANGE, @@ -1041,30 +1050,10 @@ String uri = ArtifactNamespaceContext.NAMESPACE_URI; - String lower = yrange.getAttributeNS(uri, "from"); String upper = yrange.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 Y == 0"); - return null; - } - - return from > to - ? new Range(to, from) - : new Range(from, to); - } - catch (NumberFormatException nfe) { - logger.warn("Wrong values for value axis range."); - } - } - - return null; + return new String[] { lower, upper }; }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Fri Feb 10 10:20:02 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Fri Feb 10 10:24:33 2012 +0000 @@ -39,6 +39,7 @@ import de.intevation.artifactdatabase.state.ArtifactAndFacet; import de.intevation.artifactdatabase.state.Facet; +import de.intevation.flys.jfree.Bounds; import de.intevation.flys.jfree.FLYSAnnotation; import de.intevation.flys.jfree.StickyAxisAnnotation; import de.intevation.flys.jfree.CollisionFreeXYTextAnnotation; @@ -500,6 +501,37 @@ } + protected Range getValueAxisRange() { + String[] ranges = getValueAxisRangeFromRequest(); + + if (ranges == null || ranges.length < 2) { + logger.debug("No range specified. Lower and upper Y == 0"); + 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 Y == 0"); + return null; + } + + return from > to + ? new Range(to, from) + : new Range(from, to); + } + catch (NumberFormatException nfe) { + logger.warn("Wrong values for value axis range."); + } + } + + return null; + } + + protected boolean zoomX(XYPlot plot, ValueAxis axis, Range range, Range x) { return zoom(plot, axis, range, x); } @@ -576,6 +608,38 @@ } + @Override + public Bounds getXBounds(int axis) { + // TODO IMPLEMENT ME + throw new RuntimeException( + "XYChartGenerator.getXBounds(int) not implemented"); + } + + + @Override + protected void setXBounds(int axis, Bounds bounds) { + // TODO IMPLEMENT ME + throw new RuntimeException( + "XYChartGenerator.setXBounds(int,Bounds) not implemented"); + } + + + @Override + public Bounds getYBounds(int axis) { + // TODO IMPLEMENT ME + throw new RuntimeException( + "XYChartGenerator.getYBounds(int) not implemented"); + } + + + @Override + protected void setYBounds(int axis, Bounds bounds) { + // TODO IMPLEMENT ME + throw new RuntimeException( + "XYChartGenerator.setYBounds(int,Bounds) not implemented"); + } + + /** Get color for hyk zones by their type (which is the name). */ public Paint colorForHYKZone(String zoneName) { if (zoneName.startsWith("R")) {