Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.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 | 0cb1a70b8b92 |
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.apache.log4j.Logger; | 3 import org.apache.log4j.Logger; |
6 | 4 |
7 import org.jfree.chart.JFreeChart; | 5 import org.jfree.chart.JFreeChart; |
8 import org.jfree.chart.axis.NumberAxis; | 6 import org.jfree.chart.axis.NumberAxis; |
9 import org.jfree.chart.axis.ValueAxis; | 7 import org.jfree.chart.axis.ValueAxis; |
10 import org.jfree.chart.plot.XYPlot; | 8 import org.jfree.chart.plot.XYPlot; |
11 import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; | |
12 import org.jfree.chart.title.TextTitle; | 9 import org.jfree.chart.title.TextTitle; |
13 import org.jfree.data.Range; | 10 import org.jfree.data.Range; |
14 import org.jfree.data.xy.XYSeries; | 11 import org.jfree.data.xy.XYSeries; |
15 | 12 |
16 import org.w3c.dom.Document; | 13 import org.w3c.dom.Document; |
102 protected String getYAxisLabel() { | 99 protected String getYAxisLabel() { |
103 return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT); | 100 return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT); |
104 } | 101 } |
105 | 102 |
106 | 103 |
107 protected void adjustPlot(XYPlot plot) { | |
108 super.adjustPlot(plot); | |
109 | |
110 //// TODO REMOVE THIS CODE, IF WE HAVE INTRODUCED THEMES! | |
111 //XYLineAndShapeRenderer rw = (XYLineAndShapeRenderer) | |
112 // plot.getRendererForDataset(w); | |
113 | |
114 //XYLineAndShapeRenderer rq = null; | |
115 //try { | |
116 // rq = (XYLineAndShapeRenderer) rw.clone(); | |
117 //} | |
118 //catch (Exception e) { | |
119 // logger.error(e, e); | |
120 //} | |
121 | |
122 //int wNum = w.getSeriesCount(); | |
123 //int qNum = q.getSeriesCount(); | |
124 | |
125 //for (int i = 0; i < wNum; i++) { | |
126 // rw.setSeriesPaint(i, Color.BLUE); | |
127 //} | |
128 | |
129 //for (int i = 0; i < qNum; i++) { | |
130 // rq.setSeriesPaint(i, Color.GREEN); | |
131 //} | |
132 | |
133 //plot.setRenderer(0, rw); | |
134 //plot.setRenderer(1, rq); | |
135 } | |
136 | |
137 | |
138 protected void adjustAxes(XYPlot plot) { | 104 protected void adjustAxes(XYPlot plot) { |
139 super.adjustAxes(plot); | 105 super.adjustAxes(plot); |
140 | 106 |
141 NumberAxis qAxis = new NumberAxis( | 107 NumberAxis qAxis = new NumberAxis( |
142 msg(I18N_2YAXIS_LABEL, I18N_2YAXIS_LABEL_DEFAULT)); | 108 msg(I18N_2YAXIS_LABEL, I18N_2YAXIS_LABEL_DEFAULT)); |
194 if (f == null) { | 160 if (f == null) { |
195 return; | 161 return; |
196 } | 162 } |
197 | 163 |
198 if (name.equals(LONGITUDINAL_W)) { | 164 if (name.equals(LONGITUDINAL_W)) { |
199 doWOut((WQKms) f.getData(artifact, context)); | 165 doWOut((WQKms) f.getData(artifact, context), attr); |
200 } | 166 } |
201 else if (name.equals(LONGITUDINAL_Q)) { | 167 else if (name.equals(LONGITUDINAL_Q)) { |
202 doQOut((WQKms) f.getData(artifact, context)); | 168 doQOut((WQKms) f.getData(artifact, context), attr); |
203 } | 169 } |
204 else { | 170 else { |
205 logger.warn("Unknown facet name: " + name); | 171 logger.warn("Unknown facet name: " + name); |
206 return; | 172 return; |
207 } | 173 } |
210 | 176 |
211 /** | 177 /** |
212 * Process the output for W facets in a longitudinal section curve. | 178 * Process the output for W facets in a longitudinal section curve. |
213 * | 179 * |
214 * @param wqkms An array of WQKms values. | 180 * @param wqkms An array of WQKms values. |
215 */ | 181 * @param theme The theme that contains styling information. |
216 protected void doWOut(WQKms wqkms) { | 182 */ |
183 protected void doWOut(WQKms wqkms, Document theme) { | |
217 logger.debug("LongitudinalSectionGenerator.doWOut"); | 184 logger.debug("LongitudinalSectionGenerator.doWOut"); |
218 | 185 |
219 XYSeries series = new XYSeries(getSeriesName(wqkms, "W")); | 186 XYSeries series = new StyledXYSeries(getSeriesName(wqkms, "W"), theme); |
220 | 187 |
221 int size = wqkms.size(); | 188 int size = wqkms.size(); |
222 | 189 |
223 if (logger.isDebugEnabled()) { | 190 if (logger.isDebugEnabled()) { |
224 if (wqkms.size() > 0) { | 191 if (wqkms.size() > 0) { |
243 | 210 |
244 /** | 211 /** |
245 * Process the output for Q facets in a longitudinal section curve. | 212 * Process the output for Q facets in a longitudinal section curve. |
246 * | 213 * |
247 * @param wqkms An array of WQKms values. | 214 * @param wqkms An array of WQKms values. |
248 */ | 215 * @param theme The theme that contains styling information. |
249 protected void doQOut(WQKms wqkms) { | 216 */ |
217 protected void doQOut(WQKms wqkms, Document theme) { | |
250 logger.debug("LongitudinalSectionGenerator.doQOut"); | 218 logger.debug("LongitudinalSectionGenerator.doQOut"); |
251 | 219 |
252 XYSeries series = new XYSeries(getSeriesName(wqkms, "Q")); | 220 XYSeries series = new StyledXYSeries(getSeriesName(wqkms, "Q"), theme); |
253 | 221 |
254 int size = wqkms.size(); | 222 int size = wqkms.size(); |
255 | 223 |
256 if (logger.isDebugEnabled()) { | 224 if (logger.isDebugEnabled()) { |
257 if (wqkms.size() > 0) { | 225 if (wqkms.size() > 0) { |