Mercurial > dive4elements > river
changeset 7115:a0b00cfe1799 generator-refactoring
Migrate w_differences and remove unused classes
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Tue, 24 Sep 2013 12:25:36 +0200 |
parents | e3333da25634 |
children | 3c7471b929d1 1c4faf9f2570 |
files | artifacts/doc/conf/generators.xml artifacts/src/main/java/org/dive4elements/river/exports/DischargeLongitudinalSectionGenerator.java artifacts/src/main/java/org/dive4elements/river/exports/DischargeLongitudinalSectionInfoGenerator.java artifacts/src/main/java/org/dive4elements/river/exports/WDifferencesCurveGenerator.java artifacts/src/main/java/org/dive4elements/river/exports/WDifferencesCurveInfoGenerator.java artifacts/src/main/resources/messages.properties artifacts/src/main/resources/messages_de.properties artifacts/src/main/resources/messages_de_DE.properties artifacts/src/main/resources/messages_en.properties |
diffstat | 9 files changed, 28 insertions(+), 352 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/doc/conf/generators.xml Tue Sep 24 11:43:21 2013 +0200 +++ b/artifacts/doc/conf/generators.xml Tue Sep 24 12:25:36 2013 +0200 @@ -34,6 +34,30 @@ You have to ensure that there is a W and Q axis accordingly --> <processor class="org.dive4elements.river.exports.process.AreaProcessor" axis="none"/> </output-generator> + <output-generator names="w_differences,w_differences_chartinfo" + class="org.dive4elements.river.exports.DiagramGenerator" + converter="org.dive4elements.river.exports.DiagramAttributes"> + <axis name="W"/> + <axis name="D"/> + <axis name="Q" include-zero="true"/> + <axis name="" type="X"/> + <title key="chart.w_differences.title" default="Differences"/> + <subtitle key="chart.w_differences.subtitle" default="-"> + <arg expr="artifact.river"/> + </subtitle> + <domain-axis key="chart.longitudinal.section.xaxis.label" default="Fluss-Km"> + <arg expr="artifact.river"/> + </domain-axis> + <processor class="org.dive4elements.river.exports.process.AnnotationProcessor" axis="none"/> + <processor class="org.dive4elements.river.exports.process.WOutProcessor" axis="W"/> + <processor class="org.dive4elements.river.exports.process.WDiffProcessor" axis="D"/> + <processor class="org.dive4elements.river.exports.process.QOutProcessor" axis="Q"/> + <processor class="org.dive4elements.river.exports.process.BedheightProcessor" axis="W"/> + <processor class="org.dive4elements.river.exports.process.BedDiffYearProcessor" axis="W"/> + <processor class="org.dive4elements.river.exports.process.BedDiffHeightYearProcessor" axis="W"/> + <processor class="org.dive4elements.river.exports.process.ManualPointsProcessor" axis="W"/> + <processor class="org.dive4elements.river.exports.process.AreaProcessor" axis="none"/> + </output-generator> <output-generator names="duration_curve" class="org.dive4elements.river.exports.DurationCurveGenerator"/> <output-generator names="duration_curve_chartinfo" class="org.dive4elements.river.exports.DurationCurveInfoGenerator"/> <output-generator names="waterlevel_export" class="org.dive4elements.river.exports.WaterlevelExporter"/> @@ -45,8 +69,6 @@ <output-generator names="durationcurve_export" class="org.dive4elements.river.exports.DurationCurveExporter"/> <output-generator names="computed_dischargecurve_export" class="org.dive4elements.river.exports.ComputedDischargeCurveExporter"/> <output-generator names="discharge_longitudinal_section_export" class="org.dive4elements.river.exports.DischargeLongitudinalSectionExporter"/> - <output-generator names="w_differences" class="org.dive4elements.river.exports.WDifferencesCurveGenerator"/> - <output-generator names="w_differences_chartinfo" class="org.dive4elements.river.exports.WDifferencesCurveInfoGenerator"/> <output-generator names="w_differences_export" class="org.dive4elements.river.exports.WDifferencesExporter"/> <output-generator names="floodmap" class="org.dive4elements.river.exports.MapGenerator"/> <output-generator names="map" class="org.dive4elements.river.exports.MapGenerator"/>
--- a/artifacts/src/main/java/org/dive4elements/river/exports/DischargeLongitudinalSectionGenerator.java Tue Sep 24 11:43:21 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,129 +0,0 @@ -/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU AGPL (>=v3) - * and comes with ABSOLUTELY NO WARRANTY! Check out the - * documentation coming with Dive4Elements River for details. - */ - -package org.dive4elements.river.exports; - -import org.apache.log4j.Logger; - -import org.jfree.data.xy.XYSeries; - -import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; -import org.dive4elements.artifactdatabase.state.Facet; - -import org.dive4elements.river.artifacts.model.FacetTypes; -import org.dive4elements.river.artifacts.model.WQCKms; -import org.dive4elements.river.exports.process.Processor; -import org.dive4elements.river.exports.process.QOutProcessor; -import org.dive4elements.river.exports.process.WOutProcessor; - -import org.dive4elements.river.jfree.RiverAnnotation; -import org.dive4elements.river.jfree.StyledXYSeries; -import org.dive4elements.river.themes.ThemeDocument; - - - -/** - * An OutGenerator that generates discharge longitudinal section curves. - * - * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> - */ -public class DischargeLongitudinalSectionGenerator -extends LongitudinalSectionGenerator -implements FacetTypes -{ - private static Logger logger = - Logger.getLogger(DischargeLongitudinalSectionGenerator.class); - - - public DischargeLongitudinalSectionGenerator() { - super(); - } - - - @Override - public void doOut( - ArtifactAndFacet artifactFacet, - ThemeDocument attr, - boolean visible - ) { - logger.debug("DischargeLongitudinalSectionGenerator.doOut"); - - String name = artifactFacet.getFacetName(); - - if (name == null) { - return; - } - - Facet facet = artifactFacet.getFacet(); - - if (name.equals(DISCHARGE_LONGITUDINAL_C)) { - doCorrectedWOut( - (WQCKms) artifactFacet.getData(context), - facet, - attr, - visible); - } - else if (name.equals(LONGITUDINAL_ANNOTATION)) { - doAnnotations((RiverAnnotation) artifactFacet.getData(context), - artifactFacet, attr, visible); - } - else if (FacetTypes.IS.MANUALPOINTS(name)) { - doPoints(artifactFacet.getData(context), - artifactFacet, - attr, visible, YAXIS.W.idx); - } - else { - Processor processor = new WOutProcessor(); - Processor qProcessor = new QOutProcessor(); - if (processor.canHandle(name)) { - processor.doOut(this, artifactFacet, attr, visible, YAXIS.W.idx); - } - else if (qProcessor.canHandle(name)) { - qProcessor.doOut(this, artifactFacet, attr, visible, YAXIS.Q.idx); - } - else { - logger.warn("Unknown facet name: " + name); - } - } - } - - - /** - * Adds a new series for the corrected W curve. - * - * @param wqckms The object that contains the corrected W values. - * @param theme The theme that contains styling information. - */ - protected void doCorrectedWOut( - WQCKms wqckms, - Facet facet, - ThemeDocument theme, - boolean visible - ) { - logger.debug("DischargeLongitudinalSectionGenerator.doCorrectedWOut"); - - int size = wqckms.size(); - - if (size > 0) { - XYSeries series = new StyledXYSeries( - facet.getDescription(), - theme); - - for (int i = 0; i < size; i++) { - series.add(wqckms.getKm(i), wqckms.getC(i)); - } - - addAxisSeries(series, YAXIS.W.idx, visible); - } - - if (wqckms.guessWaterIncreasing()) { - setInverted(true); - } - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/exports/DischargeLongitudinalSectionInfoGenerator.java Tue Sep 24 11:43:21 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU AGPL (>=v3) - * and comes with ABSOLUTELY NO WARRANTY! Check out the - * documentation coming with Dive4Elements River for details. - */ - -package org.dive4elements.river.exports; - - -/** - * A ChartInfoGenerator that generates meta information for specific discharge - * longitudinal section curves. - * - * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> - */ -public class DischargeLongitudinalSectionInfoGenerator -extends ChartInfoGenerator -{ - public DischargeLongitudinalSectionInfoGenerator() { - super(new DischargeLongitudinalSectionGenerator()); - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/exports/WDifferencesCurveGenerator.java Tue Sep 24 11:43:21 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,169 +0,0 @@ -/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU AGPL (>=v3) - * and comes with ABSOLUTELY NO WARRANTY! Check out the - * documentation coming with Dive4Elements River for details. - */ - -package org.dive4elements.river.exports; - -import org.apache.log4j.Logger; - -import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; -import org.dive4elements.artifactdatabase.state.Facet; - -import org.dive4elements.river.artifacts.model.FacetTypes; -import org.dive4elements.river.artifacts.model.WKms; - -import org.dive4elements.river.exports.process.BedDiffYearProcessor; -import org.dive4elements.river.exports.process.BedDiffHeightYearProcessor; -import org.dive4elements.river.exports.process.BedheightProcessor; -import org.dive4elements.river.exports.process.Processor; -import org.dive4elements.river.themes.ThemeDocument; - -import org.jfree.chart.JFreeChart; -import org.jfree.chart.plot.XYPlot; - - -/** - * An OutGenerator that generates w differences curves. - */ -public class WDifferencesCurveGenerator -extends LongitudinalSectionGenerator -implements FacetTypes -{ - /** The logger that is used in this generator. */ - private static Logger logger = Logger.getLogger(WDifferencesCurveGenerator.class); - - public enum YAXIS { - W(0), - D(1), - Q(2); - protected int idx; - private YAXIS(int c) { - idx = c; - } - } - - /** Key for internationalized title of WDiff charts. */ - public final static String I18N_WDIFF_TITLE = "chart.w_differences.title"; - - /** Default for internationalized title (when no translation found). */ - public final static String I18N_WDIFF_TITLE_DEFAULT = "Differences"; - - public final static String I18N_WDIFF_SUBTITLE = - "chart.w_differences.subtitle"; - - - @Override - protected YAxisWalker getYAxisWalker() { - return new YAxisWalker() { - @Override - public int length() { - return YAXIS.values().length; - } - - @Override - public String getId(int idx) { - YAXIS[] yaxes = YAXIS.values(); - return yaxes[idx].toString(); - } - }; - } - - - /** - * Get internationalized title for chart. - * @return internationalized Chart title. - */ - @Override - public String getDefaultChartTitle() { - return msg(I18N_WDIFF_TITLE, I18N_WDIFF_TITLE_DEFAULT); - } - - - @Override - protected String getDefaultChartSubtitle() { - return getRiverName(); - } - - - /** - * Gets key to look up internationalized String for the charts subtitle. - * @return key to look up translated subtitle. - */ - @Override - protected String getChartSubtitleKey() { - return I18N_WDIFF_SUBTITLE; - } - - - /** Handle additional facets (beddifferences). */ - @Override - public void doOut(ArtifactAndFacet bundle, ThemeDocument attr, boolean visible) { - super.doOut(bundle, attr, visible); - - String name = bundle.getFacetName(); - logger.debug("doOut: " + name); - - if (name == null) { - logger.error("No facet name for doOut(). No output generated!"); - return; - } - - Facet facet = bundle.getFacet(); - - if (facet == null) { - return; - } - - Processor bedp = new BedheightProcessor(); - Processor bdyProcessor = new BedDiffYearProcessor(); - Processor bdhyProcessor = new BedDiffHeightYearProcessor(); - - if (bedp.canHandle(name)) { - bedp.doOut(this, bundle, attr, visible, YAXIS.W.idx); - } - else if (bdyProcessor.canHandle(name)) { - bdyProcessor.doOut(this, bundle, attr, visible, YAXIS.W.idx); - } - else if (bdhyProcessor.canHandle(name)) { - bdhyProcessor.doOut(this, bundle, attr, visible, YAXIS.W.idx); - } - else { - logger.warn("WDifferencesCurveGenerator.doOut: unknown facet type " + name); - } - } - - - /** - * Sets the zero base line visible. - */ - @Override - public JFreeChart generateChart() { - JFreeChart chart = super.generateChart(); - if (chart != null && chart.getPlot() != null) { - XYPlot plot = (XYPlot) chart.getPlot(); - plot.setRangeZeroBaselineVisible(true); - } - return chart; - } - - - /** - * Get name of series (displayed in legend). - * @return name of the series. - */ - protected String getSeriesName(WKms wqkms, String mode) { - String name = wqkms.getName(); - String prefix = (name != null && name.indexOf(mode) >= 0) - ? null - : mode; - - return (prefix != null && prefix.length() > 0) - ? prefix + "(" + name +")" - : name; - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/exports/WDifferencesCurveInfoGenerator.java Tue Sep 24 11:43:21 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU AGPL (>=v3) - * and comes with ABSOLUTELY NO WARRANTY! Check out the - * documentation coming with Dive4Elements River for details. - */ - -package org.dive4elements.river.exports; - - -/** - * A ChartInfoGenerator that generates meta information for specific - * w differences. - */ -public class WDifferencesCurveInfoGenerator -extends ChartInfoGenerator -{ - public WDifferencesCurveInfoGenerator() { - super(new WDifferencesCurveGenerator()); - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/resources/messages.properties Tue Sep 24 11:43:21 2013 +0200 +++ b/artifacts/src/main/resources/messages.properties Tue Sep 24 12:25:36 2013 +0200 @@ -198,7 +198,7 @@ chart.reference.curve.y.axis.in.m = Target Station(s) [NN + m] chart.w_differences.title = Differences -chart.w_differences.subtitle = Range: {0}-km {1,number,#.###} - {2,number,#.###} +chart.w_differences.subtitle = {0} chart.w_differences.yaxis.label = m chart.w_differences.yaxis.second.label = W [NN + m]
--- a/artifacts/src/main/resources/messages_de.properties Tue Sep 24 11:43:21 2013 +0200 +++ b/artifacts/src/main/resources/messages_de.properties Tue Sep 24 12:25:36 2013 +0200 @@ -208,7 +208,7 @@ chart.normalized.reference.curve.title = Reduzierte Bezugslinie chart.w_differences.title = Differenzen -chart.w_differences.subtitle = Range: {0}-km {1,number,#.###} - {2,number,#.###} +chart.w_differences.subtitle = {0} chart.w_differences.yaxis.label = m chart.w_differences.yaxis.second.label = W [NN + m]
--- a/artifacts/src/main/resources/messages_de_DE.properties Tue Sep 24 11:43:21 2013 +0200 +++ b/artifacts/src/main/resources/messages_de_DE.properties Tue Sep 24 12:25:36 2013 +0200 @@ -206,7 +206,7 @@ chart.normalized.reference.curve.title = Reduzierte Bezugslinie chart.w_differences.title = Differenzen -chart.w_differences.subtitle = Strecke: {0}-km {1,number,#.###} - {2,number,#.###} +chart.w_differences.subtitle = {0} chart.w_differences.yaxis.label = m chart.w_differences.yaxis.second.label = W [NN + m]
--- a/artifacts/src/main/resources/messages_en.properties Tue Sep 24 11:43:21 2013 +0200 +++ b/artifacts/src/main/resources/messages_en.properties Tue Sep 24 12:25:36 2013 +0200 @@ -211,7 +211,7 @@ chart.normalized.reference.curve.title = Reduced Reference Curve chart.w_differences.title = Differences -chart.w_differences.subtitle = Range: {0}-km {1,number,#.###} - {2,number,#.###} +chart.w_differences.subtitle = {0} chart.w_differences.yaxis.label = m chart.w_differences.yaxis.second.label = W [NN + m]