Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java @ 924:f7761914f745
An initial implementation to render chart series based on the XML configuration in themes.xml.
flys-artifacts/trunk@2276 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 01 Jul 2011 14:46:13 +0000 |
parents | 7ca4a287cd0e |
children | bdb05dc9b763 |
comparison
equal
deleted
inserted
replaced
923:7ca4a287cd0e | 924:f7761914f745 |
---|---|
1 package de.intevation.flys.exports; | 1 package de.intevation.flys.exports; |
2 | |
3 import java.awt.Color; | |
4 | 2 |
5 import org.w3c.dom.Document; | 3 import org.w3c.dom.Document; |
6 | 4 |
7 import org.apache.log4j.Logger; | 5 import org.apache.log4j.Logger; |
8 | 6 |
9 import org.jfree.chart.JFreeChart; | 7 import org.jfree.chart.JFreeChart; |
10 import org.jfree.chart.axis.NumberAxis; | 8 import org.jfree.chart.axis.NumberAxis; |
11 import org.jfree.chart.axis.ValueAxis; | 9 import org.jfree.chart.axis.ValueAxis; |
12 import org.jfree.chart.plot.XYPlot; | 10 import org.jfree.chart.plot.XYPlot; |
13 import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; | |
14 import org.jfree.chart.title.TextTitle; | 11 import org.jfree.chart.title.TextTitle; |
15 import org.jfree.data.Range; | 12 import org.jfree.data.Range; |
16 import org.jfree.data.xy.XYSeries; | 13 import org.jfree.data.xy.XYSeries; |
17 | 14 |
18 import de.intevation.artifacts.Artifact; | 15 import de.intevation.artifacts.Artifact; |
110 | 107 |
111 return zoomin; | 108 return zoomin; |
112 } | 109 } |
113 | 110 |
114 | 111 |
115 protected void adjustPlot(XYPlot plot) { | |
116 super.adjustPlot(plot); | |
117 | |
118 // TODO REMOVE THIS CODE, IF WE HAVE INTRODUCED THEMES! | |
119 //XYLineAndShapeRenderer rw = (XYLineAndShapeRenderer) | |
120 // plot.getRendererForDataset(w); | |
121 | |
122 //XYLineAndShapeRenderer rq = null; | |
123 //try { | |
124 // rq = (XYLineAndShapeRenderer) rw.clone(); | |
125 //} | |
126 //catch (Exception e) { | |
127 // logger.error(e, e); | |
128 //} | |
129 | |
130 //int wNum = w.getSeriesCount(); | |
131 //int qNum = q.getSeriesCount(); | |
132 | |
133 //for (int i = 0; i < wNum; i++) { | |
134 // rw.setSeriesPaint(i, Color.BLUE); | |
135 //} | |
136 | |
137 //for (int i = 0; i < qNum; i++) { | |
138 // rq.setSeriesPaint(i, Color.GREEN); | |
139 //} | |
140 | |
141 //plot.setRenderer(0, rw); | |
142 //plot.setRenderer(1, rq); | |
143 } | |
144 | |
145 | |
146 protected void adjustAxes(XYPlot plot) { | 112 protected void adjustAxes(XYPlot plot) { |
147 super.adjustAxes(plot); | 113 super.adjustAxes(plot); |
148 | 114 |
149 NumberAxis qAxis = new NumberAxis("Q [m\u00b3/s]"); | 115 NumberAxis qAxis = new NumberAxis("Q [m\u00b3/s]"); |
150 | 116 |
165 | 131 |
166 FLYSArtifact flys = (FLYSArtifact) artifact; | 132 FLYSArtifact flys = (FLYSArtifact) artifact; |
167 Facet f = flys.getNativeFacet(facet); | 133 Facet f = flys.getNativeFacet(facet); |
168 | 134 |
169 if (name.equals(DURATION_W)) { | 135 if (name.equals(DURATION_W)) { |
170 doWOut((WQDay) f.getData(artifact, context)); | 136 doWOut((WQDay) f.getData(artifact, context), attr); |
171 } | 137 } |
172 else if (name.equals(DURATION_Q)) { | 138 else if (name.equals(DURATION_Q)) { |
173 doQOut((WQDay) f.getData(artifact, context)); | 139 doQOut((WQDay) f.getData(artifact, context), attr); |
174 } | 140 } |
175 else { | 141 else { |
176 logger.warn("Unknown facet name: " + name); | 142 logger.warn("Unknown facet name: " + name); |
177 return; | 143 return; |
178 } | 144 } |
181 | 147 |
182 /** | 148 /** |
183 * Creates the series for a duration curve's W facet. | 149 * Creates the series for a duration curve's W facet. |
184 * | 150 * |
185 * @param wqdays The WQDay store that contains the Ws. | 151 * @param wqdays The WQDay store that contains the Ws. |
186 * @param river The name of the river. | 152 * @param theme |
187 */ | 153 */ |
188 protected void doWOut(WQDay wqdays) { | 154 protected void doWOut(WQDay wqdays, Document theme) { |
189 logger.debug("DurationCurveGenerator.doWOut"); | 155 logger.debug("DurationCurveGenerator.doWOut"); |
190 | 156 |
191 // TODO find the correct series name | 157 // TODO find the correct series name |
192 XYSeries series = new XYSeries( | 158 XYSeries series = new StyledXYSeries( |
193 getSeriesName(getRiverName(), DURATION_W)); | 159 getSeriesName(getRiverName(), DURATION_W), theme); |
194 | 160 |
195 int size = wqdays.size(); | 161 int size = wqdays.size(); |
196 for (int i = 0; i < size; i++) { | 162 for (int i = 0; i < size; i++) { |
197 int day = wqdays.getDay(i); | 163 int day = wqdays.getDay(i); |
198 double w = wqdays.getW(i); | 164 double w = wqdays.getW(i); |
206 | 172 |
207 /** | 173 /** |
208 * Creates the series for a duration curve's Q facet. | 174 * Creates the series for a duration curve's Q facet. |
209 * | 175 * |
210 * @param wqdays The WQDay store that contains the Qs. | 176 * @param wqdays The WQDay store that contains the Qs. |
211 * @param river The name of the river. | 177 * @param theme |
212 */ | 178 */ |
213 protected void doQOut(WQDay wqdays) { | 179 protected void doQOut(WQDay wqdays, Document theme) { |
214 logger.debug("DurationCurveGenerator.doQOut"); | 180 logger.debug("DurationCurveGenerator.doQOut"); |
215 | 181 |
216 // TODO find the correct series name | 182 // TODO find the correct series name |
217 XYSeries series = new XYSeries( | 183 XYSeries series = new StyledXYSeries( |
218 getSeriesName(getRiverName(), DURATION_Q)); | 184 getSeriesName(getRiverName(), DURATION_Q), theme); |
219 | 185 |
220 int size = wqdays.size(); | 186 int size = wqdays.size(); |
221 for (int i = 0; i < size; i++) { | 187 for (int i = 0; i < size; i++) { |
222 int day = wqdays.getDay(i); | 188 int day = wqdays.getDay(i); |
223 double q = wqdays.getQ(i); | 189 double q = wqdays.getQ(i); |