# HG changeset patch # User Andre Heinecke # Date 1379947272 -7200 # Node ID ab57b6eee71c95e3f787b5a0ce8708c75a0801f2 # Parent eb3a2bc5d5912f2a3fbb121b1acd5df23ecec9d2 Add refactored LongitudinalSectionGenerator2 that inherits DiagramGenerator diff -r eb3a2bc5d591 -r ab57b6eee71c artifacts/doc/conf/generators.xml --- 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 @@ - + diff -r eb3a2bc5d591 -r ab57b6eee71c artifacts/src/main/java/org/dive4elements/river/exports/LongitudinalSectionGenerator2.java --- /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 : diff -r eb3a2bc5d591 -r ab57b6eee71c artifacts/src/main/resources/messages.properties --- 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] diff -r eb3a2bc5d591 -r ab57b6eee71c artifacts/src/main/resources/messages_de.properties --- 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] diff -r eb3a2bc5d591 -r ab57b6eee71c artifacts/src/main/resources/messages_de_DE.properties --- 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] diff -r eb3a2bc5d591 -r ab57b6eee71c artifacts/src/main/resources/messages_en.properties --- 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]