Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeCurveGenerator.java @ 369:2ce7b473620e
Implemented the chart creation of a longitudinal section chart - W and Q facets.
flys-artifacts/trunk@1778 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 29 Apr 2011 10:13:24 +0000 |
parents | 8830eecad69e |
children | 60f63539d004 |
comparison
equal
deleted
inserted
replaced
368:3e66a5705c39 | 369:2ce7b473620e |
---|---|
1 package de.intevation.flys.exports; | 1 package de.intevation.flys.exports; |
2 | 2 |
3 import java.awt.Color; | |
4 import java.io.IOException; | |
5 import java.util.ArrayList; | 3 import java.util.ArrayList; |
6 import java.util.List; | 4 import java.util.List; |
7 import java.util.Map; | 5 import java.util.Map; |
8 | 6 |
9 import org.apache.log4j.Logger; | 7 import org.apache.log4j.Logger; |
10 | 8 |
11 import org.w3c.dom.Document; | 9 import org.w3c.dom.Document; |
12 | 10 |
13 import org.jfree.data.xy.DefaultXYDataset; | 11 import org.jfree.data.xy.DefaultXYDataset; |
14 | 12 import org.jfree.data.xy.XYDataset; |
15 import org.jfree.chart.ChartFactory; | |
16 import org.jfree.chart.JFreeChart; | |
17 import org.jfree.chart.plot.PlotOrientation; | |
18 | 13 |
19 import de.intevation.artifacts.Artifact; | 14 import de.intevation.artifacts.Artifact; |
20 | 15 |
21 import de.intevation.flys.model.Gauge; | 16 import de.intevation.flys.model.Gauge; |
22 | 17 |
23 import de.intevation.flys.artifacts.FLYSArtifact; | 18 import de.intevation.flys.artifacts.FLYSArtifact; |
24 import de.intevation.flys.artifacts.model.DischargeTables; | 19 import de.intevation.flys.artifacts.model.DischargeTables; |
25 import de.intevation.flys.artifacts.model.GaugesFactory; | 20 import de.intevation.flys.artifacts.model.GaugesFactory; |
26 import de.intevation.flys.exports.ChartExportHelper; | |
27 | 21 |
28 | 22 |
29 /** | 23 /** |
30 * An OutGenerator that generates discharge curves. | 24 * An OutGenerator that generates discharge curves. |
31 * | 25 * |
32 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 26 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
33 */ | 27 */ |
34 public class DischargeCurveGenerator extends ChartGenerator { | 28 public class DischargeCurveGenerator extends XYChartGenerator { |
35 | 29 |
36 /** The logger used in this generator.*/ | 30 /** The logger used in this generator.*/ |
37 private static Logger logger = | 31 private static Logger logger = |
38 Logger.getLogger(DischargeCurveGenerator.class); | 32 Logger.getLogger(DischargeCurveGenerator.class); |
39 | 33 |
44 | 38 |
45 public DischargeCurveGenerator() { | 39 public DischargeCurveGenerator() { |
46 super(); | 40 super(); |
47 | 41 |
48 this.dataset = new DefaultXYDataset(); | 42 this.dataset = new DefaultXYDataset(); |
43 } | |
44 | |
45 | |
46 protected String getChartTitle() { | |
47 return "Abflusskurven"; | |
48 } | |
49 | |
50 | |
51 protected String getXAxisLabel() { | |
52 return "Q[m³/s]"; | |
53 } | |
54 | |
55 | |
56 protected String getYAxisLabel() { | |
57 return "W[cm]"; | |
58 } | |
59 | |
60 | |
61 protected XYDataset getXYDataset() { | |
62 return dataset; | |
49 } | 63 } |
50 | 64 |
51 | 65 |
52 public void doOut(Artifact artifact, String facet, Document attr) { | 66 public void doOut(Artifact artifact, String facet, Document attr) { |
53 logger.debug("DischargeCurveGenerator.doOut: " + facet); | 67 logger.debug("DischargeCurveGenerator.doOut: " + facet); |
96 | 110 |
97 for (String gauge: gaugeNames) { | 111 for (String gauge: gaugeNames) { |
98 double[][] values = gaugeValues.get(gauge); | 112 double[][] values = gaugeValues.get(gauge); |
99 dataset.addSeries(gauge, values); | 113 dataset.addSeries(gauge, values); |
100 } | 114 } |
101 | |
102 } | |
103 | |
104 | |
105 public void generate() | |
106 throws IOException | |
107 { | |
108 logger.debug("DischargeCurveGenerator.generate"); | |
109 | |
110 JFreeChart chart = ChartFactory.createXYLineChart( | |
111 "Abflusskurven", | |
112 "Q", "W", | |
113 dataset, | |
114 PlotOrientation.VERTICAL, | |
115 true, | |
116 false, | |
117 false); | |
118 | |
119 chart.setBackgroundPaint(Color.WHITE); | |
120 chart.getPlot().setBackgroundPaint(Color.WHITE); | |
121 | |
122 ChartExportHelper.exportImage( | |
123 out, | |
124 chart, | |
125 "png", | |
126 600, 400); | |
127 } | 115 } |
128 } | 116 } |
129 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 117 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |