comparison artifacts/src/main/java/org/dive4elements/river/exports/process/FixWQProcessor.java @ 8366:061e85212d25

s/logger/log/ or removed unused logger.
author Tom Gottfried <tom@intevation.de>
date Thu, 02 Oct 2014 11:04:14 +0200
parents abef2584c9a7
children cac60032aa7d
comparison
equal deleted inserted replaced
8365:ebf74d92be38 8366:061e85212d25
43 public class FixWQProcessor 43 public class FixWQProcessor
44 extends DefaultProcessor 44 extends DefaultProcessor
45 implements FacetTypes 45 implements FacetTypes
46 { 46 {
47 47
48 private static Logger logger = Logger.getLogger(FixWQProcessor.class); 48 private static Logger log = Logger.getLogger(FixWQProcessor.class);
49 49
50 private String I18N_AXIS_LABEL = "chart.discharge.curve.yaxis.label"; 50 private String I18N_AXIS_LABEL = "chart.discharge.curve.yaxis.label";
51 51
52 public FixWQProcessor() { 52 public FixWQProcessor() {
53 } 53 }
60 boolean visible 60 boolean visible
61 ) { 61 ) {
62 // TODO: Simplify this processor and move general facets/data to 62 // TODO: Simplify this processor and move general facets/data to
63 // MiscDischargeProcessor or something... 63 // MiscDischargeProcessor or something...
64 String facetType = bundle.getFacetName(); 64 String facetType = bundle.getFacetName();
65 logger.debug("facet: " + facetType + " name: " + bundle.getFacetDescription()); 65 log.debug("facet: " + facetType + " name: " + bundle.getFacetDescription());
66 if(facetType.startsWith(FIX_SECTOR_AVERAGE_WQ)) { 66 if(facetType.startsWith(FIX_SECTOR_AVERAGE_WQ)) {
67 doSectorAverageOut(generator, bundle, theme, visible); 67 doSectorAverageOut(generator, bundle, theme, visible);
68 } 68 }
69 else if(FIX_ANALYSIS_EVENTS_WQ.equals(facetType) 69 else if(FIX_ANALYSIS_EVENTS_WQ.equals(facetType)
70 || FIX_REFERENCE_EVENTS_WQ.equals(facetType) 70 || FIX_REFERENCE_EVENTS_WQ.equals(facetType)
97 DiagramGenerator generator, 97 DiagramGenerator generator,
98 ArtifactAndFacet bundle, 98 ArtifactAndFacet bundle,
99 ThemeDocument theme, 99 ThemeDocument theme,
100 boolean visible 100 boolean visible
101 ) { 101 ) {
102 logger.debug("doSectorAverageOut"); 102 log.debug("doSectorAverageOut");
103 QWDDateRange qwdd = (QWDDateRange)bundle.getData(generator.getCallContext()); 103 QWDDateRange qwdd = (QWDDateRange)bundle.getData(generator.getCallContext());
104 QWD qwd = qwdd != null ? qwdd.getQWD() : null; 104 QWD qwd = qwdd != null ? qwdd.getQWD() : null;
105 105
106 if(qwd != null) { 106 if(qwd != null) {
107 XYSeries series = new StyledXYSeries( 107 XYSeries series = new StyledXYSeries(
127 flysAnno.setTextAnnotations(annos); 127 flysAnno.setTextAnnotations(annos);
128 generator.addAnnotations(flysAnno); 128 generator.addAnnotations(flysAnno);
129 } 129 }
130 } 130 }
131 else { 131 else {
132 logger.debug("doSectorAverageOut: qwd == null"); 132 log.debug("doSectorAverageOut: qwd == null");
133 } 133 }
134 } 134 }
135 135
136 136
137 /** Add analysis event points to chart. */ 137 /** Add analysis event points to chart. */
139 DiagramGenerator generator, 139 DiagramGenerator generator,
140 ArtifactAndFacet bundle, 140 ArtifactAndFacet bundle,
141 ThemeDocument theme, 141 ThemeDocument theme,
142 boolean visible 142 boolean visible
143 ) { 143 ) {
144 logger.debug("doAnalysisEventsOut"); 144 log.debug("doAnalysisEventsOut");
145 145
146 QWD qwd = (QWD)bundle.getData(generator.getCallContext()); 146 QWD qwd = (QWD)bundle.getData(generator.getCallContext());
147 147
148 if (qwd == null) { 148 if (qwd == null) {
149 logger.debug("doAnalysisEventsOut: qwd == null"); 149 log.debug("doAnalysisEventsOut: qwd == null");
150 return; 150 return;
151 } 151 }
152 152
153 // Force empty symbol. 153 // Force empty symbol.
154 if (qwd.getInterpolated()) { 154 if (qwd.getInterpolated()) {
189 protected void doReferenceEventsOut( 189 protected void doReferenceEventsOut(
190 DiagramGenerator generator, 190 DiagramGenerator generator,
191 ArtifactAndFacet bundle, 191 ArtifactAndFacet bundle,
192 ThemeDocument theme, 192 ThemeDocument theme,
193 boolean visible) { 193 boolean visible) {
194 logger.debug("doReferenceEventsOut"); 194 log.debug("doReferenceEventsOut");
195 195
196 QWI qwd = (QWI)bundle.getData(generator.getCallContext()); 196 QWI qwd = (QWI)bundle.getData(generator.getCallContext());
197 if (qwd == null) { 197 if (qwd == null) {
198 logger.debug("doReferenceEventsOut: qwds == null in " + bundle.getFacetDescription()); 198 log.debug("doReferenceEventsOut: qwds == null in " + bundle.getFacetDescription());
199 return; 199 return;
200 } 200 }
201 201
202 // Force empty symbol. 202 // Force empty symbol.
203 if (qwd.getInterpolated()) { 203 if (qwd.getInterpolated()) {
237 DiagramGenerator generator, 237 DiagramGenerator generator,
238 ArtifactAndFacet bundle, 238 ArtifactAndFacet bundle,
239 ThemeDocument theme, 239 ThemeDocument theme,
240 boolean visible 240 boolean visible
241 ) { 241 ) {
242 logger.debug("doWQCurveOut"); 242 log.debug("doWQCurveOut");
243 243
244 FixWQCurveFacet facet = (FixWQCurveFacet)bundle.getFacet(); 244 FixWQCurveFacet facet = (FixWQCurveFacet)bundle.getFacet();
245 FixFunction func = (FixFunction)facet.getData( 245 FixFunction func = (FixFunction)facet.getData(
246 bundle.getArtifact(), generator.getCallContext()); 246 bundle.getArtifact(), generator.getCallContext());
247 247
248 if (func == null) { 248 if (func == null) {
249 logger.warn("doWQCurveOut: Facet does not contain FixFunction"); 249 log.warn("doWQCurveOut: Facet does not contain FixFunction");
250 return; 250 return;
251 } 251 }
252 252
253 double maxQ = func.getMaxQ(); 253 double maxQ = func.getMaxQ();
254 254
260 500, // number of samples 260 500, // number of samples
261 0.0 , // start 261 0.0 , // start
262 maxQ); // end 262 maxQ); // end
263 } 263 }
264 else { 264 else {
265 logger.warn("doWQCurveOut: maxQ <= 0"); 265 log.warn("doWQCurveOut: maxQ <= 0");
266 } 266 }
267 } 267 }
268 268
269 protected void doOutlierOut( 269 protected void doOutlierOut(
270 DiagramGenerator generator, 270 DiagramGenerator generator,
271 ArtifactAndFacet bundle, 271 ArtifactAndFacet bundle,
272 ThemeDocument theme, 272 ThemeDocument theme,
273 boolean visible 273 boolean visible
274 ) { 274 ) {
275 logger.debug("doOutlierOut"); 275 log.debug("doOutlierOut");
276 276
277 QWI[] qws = (QWI[])bundle.getData(generator.getCallContext()); 277 QWI[] qws = (QWI[])bundle.getData(generator.getCallContext());
278 if(qws != null) { 278 if(qws != null) {
279 XYSeries series = new StyledXYSeries( 279 XYSeries series = new StyledXYSeries(
280 bundle.getFacetDescription(), 280 bundle.getFacetDescription(),
302 flysAnno.setTextAnnotations(annos); 302 flysAnno.setTextAnnotations(annos);
303 generator.addAnnotations(flysAnno); 303 generator.addAnnotations(flysAnno);
304 } 304 }
305 } 305 }
306 else { 306 else {
307 logger.debug("doOutlierOut: qwd == null"); 307 log.debug("doOutlierOut: qwd == null");
308 } 308 }
309 } 309 }
310 310
311 /** Add markers for q sectors. */ 311 /** Add markers for q sectors. */
312 protected void doQSectorOut( 312 protected void doQSectorOut(
313 DiagramGenerator generator, 313 DiagramGenerator generator,
314 ArtifactAndFacet bundle, 314 ArtifactAndFacet bundle,
315 ThemeDocument theme, 315 ThemeDocument theme,
316 boolean visible 316 boolean visible
317 ) { 317 ) {
318 logger.debug("doQSectorOut"); 318 log.debug("doQSectorOut");
319 if (!visible) { 319 if (!visible) {
320 return; 320 return;
321 } 321 }
322 322
323 Object qsectorsObj = bundle.getData(generator.getCallContext()); 323 Object qsectorsObj = bundle.getData(generator.getCallContext());
324 if (qsectorsObj == null || !(qsectorsObj instanceof List)) { 324 if (qsectorsObj == null || !(qsectorsObj instanceof List)) {
325 logger.warn("No QSectors coming from data."); 325 log.warn("No QSectors coming from data.");
326 return; 326 return;
327 } 327 }
328 328
329 List<?> qsectorsList = (List<?>) qsectorsObj; 329 List<?> qsectorsList = (List<?>) qsectorsObj;
330 if (qsectorsList.size() == 0 || !(qsectorsList.get(0) instanceof NamedDouble)) { 330 if (qsectorsList.size() == 0 || !(qsectorsList.get(0) instanceof NamedDouble)) {
331 logger.warn("No QSectors coming from data."); 331 log.warn("No QSectors coming from data.");
332 return; 332 return;
333 } 333 }
334 334
335 @SuppressWarnings("unchecked") 335 @SuppressWarnings("unchecked")
336 List<NamedDouble> qsectors = (List<NamedDouble>) qsectorsList; 336 List<NamedDouble> qsectors = (List<NamedDouble>) qsectorsList;
386 boolean visible 386 boolean visible
387 ) { 387 ) {
388 Object data = bundle.getData(generator.getCallContext()); 388 Object data = bundle.getData(generator.getCallContext());
389 List<StickyAxisAnnotation> xy = new ArrayList<StickyAxisAnnotation>(); 389 List<StickyAxisAnnotation> xy = new ArrayList<StickyAxisAnnotation>();
390 if (data instanceof double[][]) { 390 if (data instanceof double[][]) {
391 logger.debug("Got double[][]"); 391 log.debug("Got double[][]");
392 double [][] values = (double [][]) data; 392 double [][] values = (double [][]) data;
393 for (int i = 0; i< values[0].length; i++) { 393 for (int i = 0; i< values[0].length; i++) {
394 xy.add(new StickyAxisAnnotation(bundle.getFacetDescription(), 394 xy.add(new StickyAxisAnnotation(bundle.getFacetDescription(),
395 (float) values[1][i], StickyAxisAnnotation.SimpleAxis.Y_AXIS)); 395 (float) values[1][i], StickyAxisAnnotation.SimpleAxis.Y_AXIS));
396 } 396 }
401 bundle.getFacetDescription(), xy, null, theme)); 401 bundle.getFacetDescription(), xy, null, theme));
402 } 402 }
403 } 403 }
404 else { 404 else {
405 // Assume its WKms. 405 // Assume its WKms.
406 logger.debug("Got WKms"); 406 log.debug("Got WKms");
407 /* TODO 407 /* TODO
408 WKms wkms = (WKms) data; 408 WKms wkms = (WKms) data;
409 409
410 Double ckm = 410 Double ckm =
411 (Double) generator.getCallContext().getContextValue(FixChartGenerator.CURRENT_KM); 411 (Double) generator.getCallContext().getContextValue(FixChartGenerator.CURRENT_KM);
439 XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme); 439 XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme);
440 Double ckm = (Double) generator.getCallContext() 440 Double ckm = (Double) generator.getCallContext()
441 .getContextValue(CURRENT_KM); 441 .getContextValue(CURRENT_KM);
442 442
443 if (wqkms == null || wqkms.getKms().length == 0 || ckm == null) { 443 if (wqkms == null || wqkms.getKms().length == 0 || ckm == null) {
444 logger.info("addPointFromWQKms: No event data to show."); 444 log.info("addPointFromWQKms: No event data to show.");
445 return; 445 return;
446 } 446 }
447 447
448 double[] kms = wqkms.getKms(); 448 double[] kms = wqkms.getKms();
449 for (int i = 0 ; i< kms.length; i++) { 449 for (int i = 0 ; i< kms.length; i++) {
465 return; 465 return;
466 } 466 }
467 } 467 }
468 } 468 }
469 else { 469 else {
470 logger.debug("FixWQCurveGenerator: doWQOut: double[][]"); 470 log.debug("FixWQCurveGenerator: doWQOut: double[][]");
471 double [][] values = (double [][]) data; 471 double [][] values = (double [][]) data;
472 472
473 XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), false, true, theme); 473 XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), false, true, theme);
474 StyledSeriesBuilder.addPoints(series, values, true); 474 StyledSeriesBuilder.addPoints(series, values, true);
475 475

http://dive4elements.wald.intevation.org