Mercurial > dive4elements > river
changeset 3146:1edc17b0d79d
FixA: Draw domain markers for borders of Q sectors in helper diagram.
flys-artifacts/trunk@4754 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 22 Jun 2012 11:26:01 +0000 |
parents | be612065993e |
children | d9fb3a178be4 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/FixingsKMChartService.java |
diffstat | 2 files changed, 69 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Fri Jun 22 09:59:12 2012 +0000 +++ b/flys-artifacts/ChangeLog Fri Jun 22 11:26:01 2012 +0000 @@ -1,3 +1,11 @@ +2012-06-22 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/services/FixingsKMChartService.java: + Draw domain markers for borders of Q sectors. There is some kind of glitch + in in the Q sector classifaction code or the db data is strange. + + Because of the common code basis this affects the fixings calculations, too. :-( + 2012-06-22 Sascha L. Teichmann <sascha.teichmann@intevation.de> * src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/FixingsKMChartService.java Fri Jun 22 09:59:12 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/FixingsKMChartService.java Fri Jun 22 11:26:01 2012 +0000 @@ -14,6 +14,9 @@ import de.intevation.flys.artifacts.model.FixingsOverview; import de.intevation.flys.artifacts.model.FixingsOverviewFactory; +import de.intevation.flys.artifacts.model.GaugeFinder; +import de.intevation.flys.artifacts.model.GaugeFinderFactory; +import de.intevation.flys.artifacts.model.GaugeRange; import de.intevation.flys.backend.SessionHolder; @@ -21,6 +24,8 @@ import gnu.trove.TDoubleArrayList; +import java.awt.BasicStroke; +import java.awt.Color; import java.awt.Dimension; import java.awt.Transparency; @@ -40,11 +45,16 @@ import org.jfree.chart.ChartUtilities; import org.jfree.chart.JFreeChart; +import org.jfree.chart.plot.Marker; import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.ValueMarker; import org.jfree.chart.plot.XYPlot; import org.jfree.data.xy.DefaultXYDataset; +import org.jfree.ui.RectangleAnchor; +import org.jfree.ui.TextAnchor; + import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; @@ -58,6 +68,13 @@ public static final int DEFAULT_WIDTH = 240; public static final int DEFAULT_HEIGHT = 180; + // TODO: i18n + public static final String [] Q_SECTOR_LABELS = { + "(MNQ + MQ)/2", + "(MQ + MHQ)/2", + "HQ5" + }; + public static final String DEFAULT_FORMAT = "png"; // TODO: Load fancy image from resources. @@ -225,15 +242,56 @@ false, false); - //XYPlot plot = chart.getXYPlot(); - - //plot.setDataset(dataset); + applyQSectorMarkers(chart.getXYPlot(), river, km); ChartUtilities.applyCurrentTheme(chart); return chart; } + protected static void applyQSectorMarkers( + XYPlot plot, + String river, + double km + ) { + GaugeFinderFactory ggf = GaugeFinderFactory.getInstance(); + GaugeFinder gf = ggf.getGaugeFinder(river); + + if (gf == null) { + log.warn("No gauge finder found for river '" + river + "'"); + return; + } + + GaugeRange gr = gf.find(km); + if (gr == null) { + log.debug("No gauge range found for km " + + km + " on river " + river + "."); + return; + } + + for (int i = 0; i < Q_SECTOR_LABELS.length; ++i) { + Marker m = createQSectorMarker( + gr.getSectorBorder(i), + Q_SECTOR_LABELS[i]); + if (m != null) { + plot.addDomainMarker(m); + } + } + } + + protected static Marker createQSectorMarker(double value, String label) { + if (Double.isNaN(value)) { + return null; + } + Marker m = new ValueMarker(value); + m.setPaint(Color.black); + m.setStroke(new BasicStroke()); + m.setLabel(label); + m.setLabelAnchor(RectangleAnchor.TOP_LEFT); + m.setLabelTextAnchor(TextAnchor.TOP_LEFT); + return m; + } + protected static String getRiverName(Document input) { NodeList rivers = input.getElementsByTagName("river");