Mercurial > dive4elements > river
changeset 2261:6aeb71517136
Registered an Info generator for historical discharge curves; made some adaptions in XYChartGenerator, ChartGenerator and TimeseriesChartGenerator.
flys-artifacts/trunk@3916 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 06 Feb 2012 11:14:33 +0000 |
parents | 22bac691d414 |
children | 07d6b386ca76 |
files | flys-artifacts/ChangeLog flys-artifacts/doc/conf/conf.xml flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/ChartInfoGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/InfoGeneratorHelper.java flys-artifacts/src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java |
diffstat | 7 files changed, 77 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Mon Feb 06 10:17:29 2012 +0000 +++ b/flys-artifacts/ChangeLog Mon Feb 06 11:14:33 2012 +0000 @@ -1,3 +1,27 @@ +2012-02-06 Ingo Weinzierl <ingo@intevation.de> + + * doc/conf/conf.xml: Registered the HistoricalDischargeCurveInfoGenerator. + + * src/main/java/de/intevation/flys/exports/HistoricalDischargeCurveInfoGenerator.java: + New. This info generator returns information of a + HistoricalDischargeCurveGenerator. + + * src/main/java/de/intevation/flys/exports/InfoGeneratorHelper.java: Add an + attribute "axistype" to axes nodex based on the JFreeChart Axis type. + Number axes get a "number", date axes a "date". + + * src/main/java/de/intevation/flys/exports/ChartGenerator.java: Defined an + abstract method getRangesForAxis(). + + * src/main/java/de/intevation/flys/exports/ChartInfoGenerator.java: Awaits + now an instance of ChartGenerator instead of XYChartGenerator. + + * src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java: + Implemented the getRangesForAxis() method (copied from XYChartGenerator). + + * src/main/java/de/intevation/flys/exports/XYChartGenerator.java: Added + @Override annotation to getRangesForAxis(). + 2012-02-06 Felix Wolfsteller <felix.wolfsteller@intevation.de> * src/main/java/de/intevation/flys/artifacts/states/WQSelect.java,
--- a/flys-artifacts/doc/conf/conf.xml Mon Feb 06 10:17:29 2012 +0000 +++ b/flys-artifacts/doc/conf/conf.xml Mon Feb 06 11:14:33 2012 +0000 @@ -180,6 +180,7 @@ <output-generator name="reference_curve">de.intevation.flys.exports.ReferenceCurveGenerator</output-generator> <output-generator name="reference_curve_chartinfo">de.intevation.flys.exports.ReferenceCurveInfoGenerator</output-generator> <output-generator name="historical_discharge">de.intevation.flys.exports.HistoricalDischargeCurveGenerator</output-generator> + <output-generator name="historical_discharge_info">de.intevation.flys.exports.HistoricalDischargeCurveInfoGenerator</output-generator> <output-generator name="historical_discharge_export">de.intevation.flys.exports.HistoricalDischargeCurveExporter</output-generator> <!-- Error report generators. --> <output-generator name="discharge_longitudinal_section_report">de.intevation.flys.exports.ReportGenerator</output-generator>
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java Mon Feb 06 10:17:29 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java Mon Feb 06 11:14:33 2012 +0000 @@ -239,6 +239,16 @@ /** + * This method is used to determine the ranges for axes at a given index. + * + * @param index The index of the axes at the plot. + * + * @return a Range[] with [xrange, yrange]; + */ + public abstract Range[] getRangesForAxis(int index); + + + /** * This method should be used by concrete subclasses to add subtitle to * <i>chart</i>. <b>The method in this implementation is empty</b>. *
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartInfoGenerator.java Mon Feb 06 10:17:29 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartInfoGenerator.java Mon Feb 06 11:14:33 2012 +0000 @@ -49,13 +49,13 @@ /** The OutGenerator that creates the charts.*/ - protected XYChartGenerator generator; + protected ChartGenerator generator; protected OutputStream out; - public ChartInfoGenerator(XYChartGenerator generator) { + public ChartInfoGenerator(ChartGenerator generator) { this.generator = generator; }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/InfoGeneratorHelper.java Mon Feb 06 10:17:29 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/InfoGeneratorHelper.java Mon Feb 06 11:14:33 2012 +0000 @@ -11,6 +11,7 @@ import org.jfree.chart.ChartRenderingInfo; import org.jfree.chart.JFreeChart; +import org.jfree.chart.axis.DateAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.XYPlot; import org.jfree.data.Range; @@ -32,10 +33,10 @@ Logger.getLogger(InfoGeneratorHelper.class); - protected XYChartGenerator generator; + protected ChartGenerator generator; - public InfoGeneratorHelper(XYChartGenerator generator) { + public InfoGeneratorHelper(ChartGenerator generator) { this.generator = generator; } @@ -147,6 +148,17 @@ cr.addAttr(e, "from", String.valueOf(range.getLowerBound()), true); cr.addAttr(e, "to", String.valueOf(range.getUpperBound()), true); + logger.debug("Axis is from type: " + axis.getClass()); + + if (axis instanceof DateAxis) { + logger.debug("Add axis type: date"); + cr.addAttr(e, "axistype", "date", true); + } + else { + logger.debug("Add axis type: number"); + cr.addAttr(e, "axistype", "number", true); + } + //Range[] rs = generator.getRangesForDataset(dataset); Range[] rs = generator.getRangesForAxis(pos); Range r = null;
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java Mon Feb 06 10:17:29 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java Mon Feb 06 11:14:33 2012 +0000 @@ -212,5 +212,30 @@ xRanges.put(index, range); } } + + + @Override + public Range[] getRangesForAxis(int index) { + logger.debug("Return ranges for axis at: " + index); + + Range rx = xRanges.get(Integer.valueOf(0)); + Range ry = yRanges.get(Integer.valueOf(index)); + + if (rx == null) { + logger.warn("Range for x axis not set." + + " Using default values: 0 - 1."); + rx = new Range(0, 1); + } + if (ry == null) { + logger.warn("Range for y" + index + + " axis not set. Using default values: 0 - 1."); + ry = new Range(0, 1); + } + + logger.debug("X Range is: " + rx); + logger.debug("Y Range is: " + ry); + + return new Range[] {rx, ry}; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Mon Feb 06 10:17:29 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Mon Feb 06 11:14:33 2012 +0000 @@ -519,6 +519,7 @@ * * @return a Range[] as follows: [x-Range, y-Range]. */ + @Override public Range[] getRangesForAxis(int index) { logger.debug("getRangesForAxis " + index);