Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java @ 682:591249171c32
#77 The curves in a duration chart will have names now.
flys-artifacts/trunk@2115 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 14 Jun 2011 15:34:27 +0000 |
parents | bc1e4878d7e3 |
children | eab5e5089d77 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java Tue Jun 14 13:54:19 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java Tue Jun 14 15:34:27 2011 +0000 @@ -16,8 +16,11 @@ import de.intevation.artifacts.Artifact; +import de.intevation.flys.model.River; + import de.intevation.flys.artifacts.WINFOArtifact; import de.intevation.flys.artifacts.model.WQDay; +import de.intevation.flys.artifacts.resources.Resources; /** @@ -27,6 +30,9 @@ */ public class DurationCurveGenerator extends XYChartGenerator { + public static final String I18N_DURATION_W = "chart.duration.curve.curve.w"; + public static final String I18N_DURATION_Q = "chart.duration.curve.curve.q"; + private static Logger logger = Logger.getLogger(DurationCurveGenerator.class); @@ -159,11 +165,14 @@ return; } + WINFOArtifact winfo = (WINFOArtifact) artifact; + River river = winfo.getRiver(); + if (facet.equals(DURATION_CURVE_W)) { - doWOut(getDurationCurveData(artifact)); + doWOut(getDurationCurveData(artifact), river.getName()); } else if (facet.equals(DURATION_CURVE_Q)) { - doQOut(getDurationCurveData(artifact)); + doQOut(getDurationCurveData(artifact), river.getName()); } else { logger.warn("Unknown facet name: " + facet); @@ -176,12 +185,14 @@ * Creates the series for a duration curve's W facet. * * @param wqdays The WQDay store that contains the Ws. + * @param river The name of the river. */ - protected void doWOut(WQDay wqdays) { + protected void doWOut(WQDay wqdays, String river) { logger.debug("DurationCurveGenerator.doWOut"); // TODO find the correct series name - XYSeries series = new XYSeries("W-1"); + XYSeries series = new XYSeries( + getSeriesName(river, DURATION_CURVE_W)); int size = wqdays.size(); for (int i = 0; i < size; i++) { @@ -199,12 +210,14 @@ * Creates the series for a duration curve's Q facet. * * @param wqdays The WQDay store that contains the Qs. + * @param river The name of the river. */ - protected void doQOut(WQDay wqdays) { + protected void doQOut(WQDay wqdays, String river) { logger.debug("DurationCurveGenerator.doQOut"); // TODO find the correct series name - XYSeries series = new XYSeries("Q-1"); + XYSeries series = new XYSeries( + getSeriesName(river, DURATION_CURVE_Q)); int size = wqdays.size(); for (int i = 0; i < size; i++) { @@ -230,5 +243,32 @@ WINFOArtifact winfoArtifact = (WINFOArtifact) artifact; return winfoArtifact.getDurationCurveData(); } + + + protected String getSeriesName(String river, String type) { + Object[] args = new Object[] { river }; + + if (type == null || type.length() == 0) { + logger.warn("No duration curve type given."); + return "n/a"; + } + else if (type.equals(DURATION_CURVE_W)) { + return Resources.getMsg( + context.getMeta(), + I18N_DURATION_W, + "W", + args); + } + else if (type.equals(DURATION_CURVE_Q)) { + return Resources.getMsg( + context.getMeta(), + I18N_DURATION_Q, + "W", + args); + } + + logger.warn("Could not determine chart curve type: " + type); + return type; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :