# HG changeset patch # User Felix Wolfsteller # Date 1313675170 0 # Node ID c3902ff2d3bdd2fece8a8482bd8937027879cc45 # Parent 5411a33014e073ce9e1b5238eda98b3ceef24d55 Added legend for annotations to LongitudinalSectionDiagram. flys-artifacts/trunk@2502 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 5411a33014e0 -r c3902ff2d3bd flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java --- 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 annotations; + /** Pseudo-Dataseries to have a legend for the annotations. */ + protected XYSeriesCollection pseudoAnnotationData = null; + + public LongitudinalSectionGenerator() { super(); annotations = new ArrayList(); @@ -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) 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; diff -r 5411a33014e0 -r c3902ff2d3bd flys-artifacts/src/main/resources/messages.properties --- 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] diff -r 5411a33014e0 -r c3902ff2d3bd flys-artifacts/src/main/resources/messages_de.properties --- 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] diff -r 5411a33014e0 -r c3902ff2d3bd flys-artifacts/src/main/resources/messages_de_DE.properties --- 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] diff -r 5411a33014e0 -r c3902ff2d3bd flys-artifacts/src/main/resources/messages_en.properties --- 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]