Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveGenerator.java @ 1092:0eb585cd3882
Added limited themeing-support for MainValues.
flys-artifacts/trunk@2595 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 26 Aug 2011 12:44:12 +0000 |
parents | e298c4d28927 |
children | 1ea7eb72aaa6 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveGenerator.java Fri Aug 26 12:42:12 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveGenerator.java Fri Aug 26 12:44:12 2011 +0000 @@ -6,12 +6,13 @@ import org.w3c.dom.Document; +import java.awt.Color; import org.jfree.chart.JFreeChart; +import org.jfree.chart.annotations.XYAnnotation; import org.jfree.chart.title.TextTitle; +import org.jfree.chart.plot.XYPlot; import org.jfree.data.xy.XYSeries; -import org.jfree.chart.axis.ValueAxis; -import org.jfree.chart.plot.XYPlot; -import org.jfree.chart.annotations.XYAnnotation; +import org.jfree.data.xy.XYSeriesCollection; import de.intevation.artifacts.Artifact; @@ -24,6 +25,8 @@ import de.intevation.flys.jfree.StickyAxisAnnotation; +import de.intevation.flys.utils.ThemeUtil; + /** * An OutGenerator that generates discharge curves. @@ -50,11 +53,15 @@ 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)"; /** List of Annotations (specifically, Main Values). */ protected List<XYAnnotation> annotations; - // TODO Add pseudodataseries for having mainvalue-text in legend. + /** Pseudo-Dataseries to have a legend for annotations. */ + protected XYSeriesCollection pseudoAnnotationData = null; + // TODO Let theme pass through to annotations-facets. @@ -126,15 +133,26 @@ */ protected void doMainValueWAnnotations(Object o, Document theme) { logger.debug("ComputedDischargeCurveGenerator set W MainValues."); + if (pseudoAnnotationData == null) { + pseudoAnnotationData = new XYSeriesCollection(); + } + + Color color = ThemeUtil.parseLineColorField(theme); + if (color == null) { + color = Color.black; + } + List<NamedDouble> mainValuesW = (List<NamedDouble>) o; for (NamedDouble mv: mainValuesW) { float pos = (float) mv.getValue(); String text = mv.getName(); StickyAxisAnnotation ta = new StickyAxisAnnotation(text, pos, StickyAxisAnnotation.SimpleAxis.Y_AXIS); - logger.debug("Adding W: " + text + " : " + pos); + ta.setPaint(color); this.annotations.add(ta); } + String label = msg(I18N_MAINVALUES_W_LABEL, I18N_MAINVALUES_W_LABEL, null); + pseudoAnnotationData.addSeries(new StyledXYSeries(label, theme)); } @@ -143,13 +161,26 @@ */ protected void doMainValueQAnnotations(Object o, Document theme) { logger.debug("ComputedDischargeCurveGenerator set Q MainValues."); + + Color color = ThemeUtil.parseLineColorField(theme); + if (color == null) { + color = Color.black; + } + + if (pseudoAnnotationData == null) { + pseudoAnnotationData = new XYSeriesCollection(); + } + List<NamedDouble> mainValuesQ = (List<NamedDouble>) o; for (NamedDouble mv: mainValuesQ) { float pos = (float) mv.getValue(); String text = mv.getName(); StickyAxisAnnotation ta = new StickyAxisAnnotation(text, pos); + ta.setPaint(color); this.annotations.add(ta); } + String label = msg(I18N_MAINVALUES_Q_LABEL, I18N_MAINVALUES_Q_LABEL, null); + pseudoAnnotationData.addSeries(new StyledXYSeries(label, theme)); } @@ -196,7 +227,19 @@ addFirstAxisSeries(series); } - + /** + * Add datasets to plot. + * @param plot plot to add datasets to. + * @todo merge with LongitudinalSectionGenerator/superclass. + */ + @Override + protected void addDatasets(XYPlot plot) { + super.addDatasets(plot); + if (pseudoAnnotationData != null) { + plot.setDataset(2, pseudoAnnotationData); + } + } + protected String getSeriesName(WQKms wqkms) { Object[] args = new Object[] { getRiverName(),