Mercurial > dive4elements > river
changeset 1041:c3902ff2d3bd
Added legend for annotations to LongitudinalSectionDiagram.
flys-artifacts/trunk@2502 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 18 Aug 2011 13:46:10 +0000 (2011-08-18) |
parents | 5411a33014e0 |
children | 8873c43119ca |
files | flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java flys-artifacts/src/main/resources/messages.properties flys-artifacts/src/main/resources/messages_de.properties flys-artifacts/src/main/resources/messages_de_DE.properties flys-artifacts/src/main/resources/messages_en.properties |
diffstat | 5 files changed, 40 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java Wed Aug 17 13:05:15 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java Thu Aug 18 13:46:10 2011 +0000 @@ -13,6 +13,7 @@ import org.jfree.data.Range; import org.jfree.data.xy.XYSeries; import org.jfree.ui.TextAnchor; +import org.jfree.data.xy.XYSeriesCollection; import org.w3c.dom.Document; @@ -45,6 +46,9 @@ public static final String I18N_CHART_TITLE = "chart.longitudinal.section.title"; + public static final String I18N_ANNOTATIONS_LABEL = + "chart.longitudinal.annotations.label"; + public static final String I18N_CHART_SUBTITLE = "chart.longitudinal.section.subtitle"; @@ -65,8 +69,13 @@ protected boolean inverted; + /** List of annotations to insert in plot. */ protected List<Annotation> annotations; + /** Pseudo-Dataseries to have a legend for the annotations. */ + protected XYSeriesCollection pseudoAnnotationData = null; + + public LongitudinalSectionGenerator() { super(); annotations = new ArrayList<Annotation>(); @@ -235,11 +244,20 @@ * Register annotations available for the diagram. * * @param o list of annotations (data of facet). - * @param theme ignored. + * @param theme yet ignored. */ protected void doAnnotationsOut(Object o, Document theme) { logger.debug("LongitudinalSectionGenerator.doAnnotationsOut"); this.annotations = (List<Annotation>) o; + + // Add (empty) pseudo series. + if (pseudoAnnotationData == null) { + pseudoAnnotationData = new XYSeriesCollection(); + } + // Localized legend. + Object[] args = new Object[] {getRiverName()}; + String label = msg(I18N_ANNOTATIONS_LABEL, "", args); + pseudoAnnotationData.addSeries(new StyledXYSeries(label, theme)); } @@ -311,6 +329,23 @@ } + /** + * Add datasets to plot. + * @param plot plot to add datasets to. + */ + @Override + protected void addDatasets(XYPlot plot) { + super.addDatasets(plot); + if (pseudoAnnotationData != null) { + plot.setDataset(2, pseudoAnnotationData); + } + } + + + /** + * Get name of series (displayed in legend). + * @return name of the series. + */ protected String getSeriesName(WQKms wqkms, String mode) { String name = wqkms.getName(); String prefix = name != null && name.indexOf(mode) >= 0 ? null : mode;
--- a/flys-artifacts/src/main/resources/messages.properties Wed Aug 17 13:05:15 2011 +0000 +++ b/flys-artifacts/src/main/resources/messages.properties Thu Aug 18 13:46:10 2011 +0000 @@ -32,6 +32,7 @@ chart.longitudinal.section.xaxis.label = km chart.longitudinal.section.yaxis.label = W [NN + m] chart.longitudinal.section.yaxis.second.label = Q [m\u00b3/s] +chart.longitudinal.annotations.label = {0}.km chart.discharge.curve.title = Discharge Curve chart.discharge.curve.xaxis.label = Q [m\u00b3/s] chart.discharge.curve.yaxis.label = W [cm]
--- a/flys-artifacts/src/main/resources/messages_de.properties Wed Aug 17 13:05:15 2011 +0000 +++ b/flys-artifacts/src/main/resources/messages_de.properties Thu Aug 18 13:46:10 2011 +0000 @@ -32,6 +32,7 @@ chart.longitudinal.section.xaxis.label = km chart.longitudinal.section.yaxis.label = W [NN + m] chart.longitudinal.section.yaxis.second.label = Q [m\u00b3/s] +chart.longitudinal.annotations.label = {0}.km chart.discharge.curve.title = Abflusskurve chart.discharge.curve.xaxis.label = Q [m\u00b3/s] chart.discharge.curve.yaxis.label = W [cm]
--- a/flys-artifacts/src/main/resources/messages_de_DE.properties Wed Aug 17 13:05:15 2011 +0000 +++ b/flys-artifacts/src/main/resources/messages_de_DE.properties Thu Aug 18 13:46:10 2011 +0000 @@ -32,6 +32,7 @@ chart.longitudinal.section.xaxis.label = km chart.longitudinal.section.yaxis.label = W [NN + m] chart.longitudinal.section.yaxis.second.label = Q [m\u00b3/s] +chart.longitudinal.annotations.label = {0}.km chart.discharge.curve.title = Abflusskurve chart.discharge.curve.xaxis.label = Q [m\u00b3/s] chart.discharge.curve.yaxis.label = W [cm]
--- a/flys-artifacts/src/main/resources/messages_en.properties Wed Aug 17 13:05:15 2011 +0000 +++ b/flys-artifacts/src/main/resources/messages_en.properties Thu Aug 18 13:46:10 2011 +0000 @@ -32,6 +32,7 @@ chart.longitudinal.section.xaxis.label = km chart.longitudinal.section.yaxis.label = W [NN + m] chart.longitudinal.section.yaxis.second.label = Q [m\u00b3/s] +chart.longitudinal.annotations.label = {0}.km chart.discharge.curve.title = Discharge Curve chart.discharge.curve.xaxis.label = Q [m\u00b3/s] chart.discharge.curve.yaxis.label = W [cm]