Mercurial > dive4elements > river
changeset 7105:ab57b6eee71c generator-refactoring
Add refactored LongitudinalSectionGenerator2 that inherits DiagramGenerator
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Mon, 23 Sep 2013 16:41:12 +0200 (2013-09-23) |
parents | eb3a2bc5d591 |
children | ed8623b989f3 |
files | artifacts/doc/conf/generators.xml artifacts/src/main/java/org/dive4elements/river/exports/LongitudinalSectionGenerator2.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 | 6 files changed, 69 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/doc/conf/generators.xml Mon Sep 23 16:00:02 2013 +0200 +++ b/artifacts/doc/conf/generators.xml Mon Sep 23 16:41:12 2013 +0200 @@ -6,7 +6,7 @@ <output-generator names="cross_section_chartinfo" class="org.dive4elements.river.exports.CrossSectionInfoGenerator"/> <output-generator names="computed_discharge_curve" class="org.dive4elements.river.exports.ComputedDischargeCurveGenerator"/> <output-generator names="computed_discharge_curve_chartinfo" class="org.dive4elements.river.exports.ComputedDischargeCurveInfoGenerator"/> - <output-generator names="longitudinal_section,longitudinal_section_chartinfo" class="org.dive4elements.river.exports.LongitudinalSectionGenerator" converter="org.dive4elements.river.exports.DiagramAttributes"> + <output-generator names="longitudinal_section,longitudinal_section_chartinfo" class="org.dive4elements.river.exports.LongitudinalSectionGenerator2" converter="org.dive4elements.river.exports.DiagramAttributes"> <axis name="W"/> <axis name="D"/> <axis name="Q"/>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/LongitudinalSectionGenerator2.java Mon Sep 23 16:41:12 2013 +0200 @@ -0,0 +1,64 @@ +/* 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.chart.axis.NumberAxis; + + +public class LongitudinalSectionGenerator2 extends DiagramGenerator +{ + public static final String I18N_CHART_SHORT_SUBTITLE = + "chart.longitudinal.section.shortsubtitle"; + + public static final String I18N_CHART_LOCATION_SUBTITLE = + "chart.longitudinal.section.locsubtitle"; + + private static Logger logger = + Logger.getLogger(LongitudinalSectionGenerator.class); + + @Override + public String getDefaultChartSubtitle() { + double[] dist = getRange(); + + Object[] args = null; + if (dist == null || dist.length != 2 || + Double.isNaN(dist[0]) || Double.isNaN(dist[1])) { + args = new Object[] {getRiverName()}; + return msg(I18N_CHART_SHORT_SUBTITLE, "", args); + } else if (Math.abs(dist[0] - dist[1]) < 1E-5) { + args = new Object[] {getRiverName(), dist[1]}; + return msg(I18N_CHART_LOCATION_SUBTITLE, "", args); + } + return super.getDefaultChartSubtitle(); + } + + /** + * Create Axis for given index. + * @return axis with according internationalized label. + */ + @Override + protected NumberAxis createYAxis(int index) { + // TODO decide what to do with this. + return super.createYAxis(index); + /* + NumberAxis axis = super.createYAxis(index); + + // "Q" Axis shall include 0. + if (index == YAXIS.Q.idx) { + axis.setAutoRangeIncludesZero(true); + } + else { + axis.setAutoRangeIncludesZero(false); + } + + return axis;*/ + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/resources/messages.properties Mon Sep 23 16:00:02 2013 +0200 +++ b/artifacts/src/main/resources/messages.properties Mon Sep 23 16:41:12 2013 +0200 @@ -152,6 +152,7 @@ chart.longitudinal.section.title = W-Longitudinal Section chart.longitudinal.section.subtitle = Range: {0}-km {1,number,#.###} - {2,number,#.###} chart.longitudinal.section.shortsubtitle = {0} +chart.longitudinal.section.locsubtitle = {0} km {1,number,#.###} chart.longitudinal.section.xaxis.label = {0}-km chart.longitudinal.section.yaxis.label = W [{0}] chart.longitudinal.section.yaxis.second.label = Q [m\u00b3/s]
--- a/artifacts/src/main/resources/messages_de.properties Mon Sep 23 16:00:02 2013 +0200 +++ b/artifacts/src/main/resources/messages_de.properties Mon Sep 23 16:41:12 2013 +0200 @@ -158,6 +158,7 @@ chart.longitudinal.section.title = W-L\u00e4ngsschnitt chart.longitudinal.section.subtitle = Bereich: {0}-km {1,number,#.###} - {2,number,#.###} chart.longitudinal.section.shortsubtitle = {0} +chart.longitudinal.section.locsubtitle = {0} km {1,number,#.###} chart.longitudinal.section.xaxis.label = {0}-km chart.longitudinal.section.yaxis.label = W [{0}] chart.longitudinal.section.yaxis.second.label = Q [m\u00b3/s]
--- a/artifacts/src/main/resources/messages_de_DE.properties Mon Sep 23 16:00:02 2013 +0200 +++ b/artifacts/src/main/resources/messages_de_DE.properties Mon Sep 23 16:41:12 2013 +0200 @@ -157,6 +157,7 @@ chart.longitudinal.section.title = W-L\u00e4ngsschnitt chart.longitudinal.section.subtitle = Bereich: {0}-km {1,number,#.###} - {2,number,#.###} chart.longitudinal.section.shortsubtitle = {0} +chart.longitudinal.section.locsubtitle = {0} km {1,number,#.###} chart.longitudinal.section.xaxis.label = {0}-km chart.longitudinal.section.yaxis.label = W [{0}] chart.longitudinal.section.yaxis.second.label = Q [m\u00b3/s]
--- a/artifacts/src/main/resources/messages_en.properties Mon Sep 23 16:00:02 2013 +0200 +++ b/artifacts/src/main/resources/messages_en.properties Mon Sep 23 16:41:12 2013 +0200 @@ -157,6 +157,7 @@ chart.longitudinal.section.title = W-Longitudinal Section chart.longitudinal.section.subtitle = Range: {0}-km {1,number,#.###} - {2,number,#.###} chart.longitudinal.section.shortsubtitle = {0} +chart.longitudinal.section.locsubtitle = {0} km {1,number,#.###} chart.longitudinal.section.xaxis.label = {0}-km chart.longitudinal.section.yaxis.label = W [{0}] chart.longitudinal.section.yaxis.second.label = Q [m\u00b3/s]