Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveGenerator.java @ 1713:6d9184c745dd
Bugfix: #226 Set the upper bound of duration curve charts to 364.
flys-artifacts/trunk@2985 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 17 Oct 2011 11:04:53 +0000 |
parents | 7e19449d7826 |
children | eb35570df0e8 |
line wrap: on
line source
package de.intevation.flys.exports; import org.apache.log4j.Logger; import org.w3c.dom.Document; import org.jfree.chart.JFreeChart; import org.jfree.chart.title.TextTitle; import org.jfree.data.xy.XYSeries; import de.intevation.artifacts.Artifact; import de.intevation.artifactdatabase.state.Facet; import de.intevation.flys.artifacts.FLYSArtifact; import de.intevation.flys.artifacts.model.FacetTypes; import de.intevation.flys.artifacts.model.WQKms; import de.intevation.flys.jfree.FLYSAnnotation; /** * An OutGenerator that generates discharge curves. * * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public class ComputedDischargeCurveGenerator extends DischargeCurveGenerator implements FacetTypes { /** The logger used in this generator. */ private static Logger logger = Logger.getLogger(ComputedDischargeCurveGenerator.class); public static final String I18N_CHART_TITLE = "chart.computed.discharge.curve.title"; public static final String I18N_CHART_SUBTITLE = "chart.computed.discharge.curve.subtitle"; public static final String I18N_YAXIS_LABEL = "chart.computed.discharge.curve.yaxis.label"; public static final String I18N_CHART_TITLE_DEFAULT = "Abflusskurve"; public static final String I18N_YAXIS_LABEL_DEFAULT = "W [NN + m]"; public static final String I18N_MAINVALUES_Q_LABEL = "Q (Haupt- und Extremwerte)"; public static final String I18N_MAINVALUES_W_LABEL = "W (Haupt- und Extremwerte)"; /** Trivial Constructor. */ public ComputedDischargeCurveGenerator () { super(); } @Override protected String getChartTitle() { return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); } @Override protected void addSubtitles(JFreeChart chart) { double[] dist = getRange(); Object[] args = new Object[] { getRiverName(), dist[0] }; String subtitle = msg(I18N_CHART_SUBTITLE, "", args); chart.addSubtitle(new TextTitle(subtitle)); } @Override protected String getYAxisLabel() { return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT); } @Override public void doOut( Artifact artifact, Facet facet, Document attr, boolean visible ) { String name = (facet != null) ? facet.getName() : null; logger.debug("ComputedDischargeCurveGenerator.doOut: " + name); if (name == null) { logger.warn("Broken facet in computed discharge out generation."); return; } FLYSArtifact flys = (FLYSArtifact) artifact; Facet f = flys.getNativeFacet(facet); if (name.equals(COMPUTED_DISCHARGE_Q)) { doQOut((WQKms) f.getData(artifact, context), facet, attr, visible); } else if (name.equals(COMPUTED_DISCHARGE_MAINVALUES_Q)) { doMainValueQAnnotations( f.getData(artifact, context), facet, attr,visible); } else if (name.equals(COMPUTED_DISCHARGE_MAINVALUES_W)) { doMainValueWAnnotations( f.getData(artifact, context), facet, attr,visible); } else { logger.warn("Unknown facet type for computed discharge: " + name); return; } } /** * Store W MainValues as annotations for later plotting. */ protected void doMainValueWAnnotations( Object o, Facet facet, Document theme, boolean visible ) { logger.debug("ComputedDischargeCurveGenerator set W MainValues."); FLYSAnnotation fa = (FLYSAnnotation) o; fa.setTheme(theme); fa.setLabel(facet.getDescription()); addAnnotations(fa, visible); } /** * Store Q MainValues as annotations for later plotting. */ protected void doMainValueQAnnotations( Object o, Facet facet, Document theme, boolean visible ) { logger.debug("ComputedDischargeCurveGenerator set Q MainValues."); FLYSAnnotation fa = (FLYSAnnotation) o; fa.setTheme(theme); fa.setLabel(facet.getDescription()); addAnnotations(fa, visible); } /** * Add Q-Series to plot. * @param wqkms actual data * @param theme theme to use. */ protected void doQOut( WQKms wqkms, Facet facet, Document theme, boolean visible ) { int size = wqkms.size(); double[] res = new double[3]; XYSeries series = new StyledXYSeries(facet.getDescription(), theme); for (int i = 0; i < size; i++) { res = wqkms.get(i, res); series.add(res[1], res[0]); } addFirstAxisSeries(series, visible); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :