Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeCurveGenerator.java @ 923:7ca4a287cd0e
#135 Modified the way to store datasets for different chart axes.
flys-artifacts/trunk@2275 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 01 Jul 2011 11:16:11 +0000 |
parents | e95e6df97e55 |
children | f7761914f745 |
comparison
equal
deleted
inserted
replaced
922:95356252c309 | 923:7ca4a287cd0e |
---|---|
9 | 9 |
10 import org.jfree.chart.JFreeChart; | 10 import org.jfree.chart.JFreeChart; |
11 import org.jfree.chart.axis.ValueAxis; | 11 import org.jfree.chart.axis.ValueAxis; |
12 import org.jfree.chart.plot.XYPlot; | 12 import org.jfree.chart.plot.XYPlot; |
13 import org.jfree.data.Range; | 13 import org.jfree.data.Range; |
14 import org.jfree.data.xy.DefaultXYDataset; | 14 import org.jfree.data.xy.XYSeries; |
15 | 15 |
16 import de.intevation.artifacts.Artifact; | 16 import de.intevation.artifacts.Artifact; |
17 | 17 |
18 import de.intevation.artifactdatabase.state.Facet; | 18 import de.intevation.artifactdatabase.state.Facet; |
19 | 19 |
53 public static final String I18N_CHART_TITLE_DEFAULT = "Abflusskurven"; | 53 public static final String I18N_CHART_TITLE_DEFAULT = "Abflusskurven"; |
54 public static final String I18N_XAXIS_LABEL_DEFAULT = "Q [m\u00b3/s]"; | 54 public static final String I18N_XAXIS_LABEL_DEFAULT = "Q [m\u00b3/s]"; |
55 public static final String I18N_YAXIS_LABEL_DEFAULT = "W [cm]"; | 55 public static final String I18N_YAXIS_LABEL_DEFAULT = "W [cm]"; |
56 | 56 |
57 | 57 |
58 /** The Dataset that contains the data for the chart.*/ | |
59 protected DefaultXYDataset dataset; | |
60 | |
61 | 58 |
62 public DischargeCurveGenerator() { | 59 public DischargeCurveGenerator() { |
63 super(); | 60 super(); |
64 | |
65 this.dataset = new DefaultXYDataset(); | |
66 } | 61 } |
67 | 62 |
68 | 63 |
69 protected String getChartTitle() { | 64 protected String getChartTitle() { |
70 return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); | 65 return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); |
94 if (!zoomin) { | 89 if (!zoomin) { |
95 axis.setLowerBound(0d); | 90 axis.setLowerBound(0d); |
96 } | 91 } |
97 | 92 |
98 return zoomin; | 93 return zoomin; |
99 } | |
100 | |
101 | |
102 protected void addDatasets(JFreeChart chart) { | |
103 XYPlot plot = (XYPlot) chart.getPlot(); | |
104 plot.setDataset(0, dataset); | |
105 } | 94 } |
106 | 95 |
107 | 96 |
108 public void doOut(Artifact artifact, Facet facet, Document attr) { | 97 public void doOut(Artifact artifact, Facet facet, Document attr) { |
109 logger.debug("DischargeCurveGenerator.doOut: " + facet.getName()); | 98 logger.debug("DischargeCurveGenerator.doOut: " + facet.getName()); |
143 String seriesName = getSeriesName(gauge); | 132 String seriesName = getSeriesName(gauge); |
144 | 133 |
145 double [][] values = new double [][] { | 134 double [][] values = new double [][] { |
146 wqkms.getQs(), wqkms.getWs() }; | 135 wqkms.getQs(), wqkms.getWs() }; |
147 | 136 |
148 dataset.addSeries(seriesName, values); | 137 int size = values != null ? values[0].length : 0; |
138 | |
139 XYSeries series = new XYSeries(seriesName); | |
140 | |
141 for (int i = 0; i < size; i++) { | |
142 series.add(values[0][i], values[1][i]); | |
143 } | |
144 | |
145 addFirstAxisSeries(series); | |
149 } | 146 } |
150 | 147 |
151 | 148 |
152 protected String getSeriesName(Gauge gauge) { | 149 protected String getSeriesName(Gauge gauge) { |
153 // XXX The following code stops the artifact server accepting new HTTP | 150 // XXX The following code stops the artifact server accepting new HTTP |