comparison artifacts/src/main/java/org/dive4elements/river/exports/process/FixWQProcessor.java @ 8856:5e38e2924c07 3.2.x

Fix code style.
author Tom Gottfried <tom@intevation.de>
date Thu, 18 Jan 2018 20:12:01 +0100
parents 07df414d5d88
children a805211690f7
comparison
equal deleted inserted replaced
8855:d7c005e12af0 8856:5e38e2924c07
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 log.debug("facet: " + facetType + " name: " + bundle.getFacetDescription()); 65 log.debug("facet: " + facetType
66 + " name: " + bundle.getFacetDescription());
66 if(facetType.startsWith(FIX_SECTOR_AVERAGE_WQ)) { 67 if(facetType.startsWith(FIX_SECTOR_AVERAGE_WQ)) {
67 doSectorAverageOut(generator, bundle, theme, visible); 68 doSectorAverageOut(generator, bundle, theme, visible);
68 } 69 }
69 else if(FIX_ANALYSIS_EVENTS_WQ.equals(facetType) 70 else if(FIX_ANALYSIS_EVENTS_WQ.equals(facetType)
70 || FIX_REFERENCE_EVENTS_WQ.equals(facetType) 71 || FIX_REFERENCE_EVENTS_WQ.equals(facetType)
99 ArtifactAndFacet bundle, 100 ArtifactAndFacet bundle,
100 ThemeDocument theme, 101 ThemeDocument theme,
101 boolean visible 102 boolean visible
102 ) { 103 ) {
103 log.debug("doSectorAverageOut"); 104 log.debug("doSectorAverageOut");
104 QWDDateRange qwdd = (QWDDateRange)bundle.getData(generator.getCallContext()); 105 QWDDateRange qwdd = (QWDDateRange)bundle.getData(
106 generator.getCallContext());
105 QWD qwd = qwdd != null ? qwdd.getQWD() : null; 107 QWD qwd = qwdd != null ? qwdd.getQWD() : null;
106 108
107 if(qwd != null) { 109 if(qwd != null) {
108 XYSeries series = new StyledXYSeries( 110 XYSeries series = new StyledXYSeries(
109 bundle.getFacetDescription(), 111 bundle.getFacetDescription(),
151 return; 153 return;
152 } 154 }
153 155
154 // Force empty symbol. 156 // Force empty symbol.
155 if (qwd.getInterpolated()) { 157 if (qwd.getInterpolated()) {
156 theme = new ThemeDocument(theme); // prevent potential side effects. 158 theme = new ThemeDocument(theme); // prevent potential side effects
157 theme.setValue(ThemeDocument.USE_FILL_PAINT, "true"); 159 theme.setValue(ThemeDocument.USE_FILL_PAINT, "true");
158 } 160 }
159 161
160 XYSeries series = new StyledXYSeries( 162 XYSeries series = new StyledXYSeries(
161 bundle.getFacetDescription(), 163 bundle.getFacetDescription(),
168 170
169 generator.addAxisSeries(series, axisName, visible); 171 generator.addAxisSeries(series, axisName, visible);
170 172
171 if (visible && theme.parseShowPointLabel()) { 173 if (visible && theme.parseShowPointLabel()) {
172 174
173 List<XYTextAnnotation> textAnnos = new ArrayList<XYTextAnnotation>(); 175 List<XYTextAnnotation> textAnnos =
176 new ArrayList<XYTextAnnotation>();
174 177
175 DateFormat dateFormat = DateFormat.getDateInstance( 178 DateFormat dateFormat = DateFormat.getDateInstance(
176 DateFormat.SHORT); 179 DateFormat.SHORT);
177 XYTextAnnotation anno = new CollisionFreeXYTextAnnotation( 180 XYTextAnnotation anno = new CollisionFreeXYTextAnnotation(
178 dateFormat.format(qwd.getDate()), 181 dateFormat.format(qwd.getDate()),
179 qwd.getQ(), 182 qwd.getQ(),
180 qwd.getW()); 183 qwd.getW());
181 textAnnos.add(anno); 184 textAnnos.add(anno);
182 185
183 RiverAnnotation flysAnno = new RiverAnnotation(null, null, null, theme); 186 RiverAnnotation flysAnno =
187 new RiverAnnotation(null, null, null, theme);
184 flysAnno.setTextAnnotations(textAnnos); 188 flysAnno.setTextAnnotations(textAnnos);
185 generator.addAnnotations(flysAnno); 189 generator.addAnnotations(flysAnno);
186 } 190 }
187 } 191 }
188 192
194 boolean visible) { 198 boolean visible) {
195 log.debug("doReferenceEventsOut"); 199 log.debug("doReferenceEventsOut");
196 200
197 QWI qwd = (QWI)bundle.getData(generator.getCallContext()); 201 QWI qwd = (QWI)bundle.getData(generator.getCallContext());
198 if (qwd == null) { 202 if (qwd == null) {
199 log.debug("doReferenceEventsOut: qwds == null in " + bundle.getFacetDescription()); 203 log.debug("doReferenceEventsOut: qwds == null in "
204 + bundle.getFacetDescription());
200 return; 205 return;
201 } 206 }
202 207
203 // Force empty symbol. 208 // Force empty symbol.
204 if (qwd.getInterpolated()) { 209 if (qwd.getInterpolated()) {
205 theme = new ThemeDocument(theme); // prevent potential side effects. 210 theme = new ThemeDocument(theme); // prevent potential side effects
206 theme.setValue(ThemeDocument.USE_FILL_PAINT, "true"); 211 theme.setValue(ThemeDocument.USE_FILL_PAINT, "true");
207 } 212 }
208 213
209 XYSeries series = new StyledXYSeries( 214 XYSeries series = new StyledXYSeries(
210 bundle.getFacetDescription(), 215 bundle.getFacetDescription(),
222 XYTextAnnotation anno = new CollisionFreeXYTextAnnotation( 227 XYTextAnnotation anno = new CollisionFreeXYTextAnnotation(
223 dateFormat.format(qwd.getDate()), 228 dateFormat.format(qwd.getDate()),
224 qwd.getQ(), 229 qwd.getQ(),
225 qwd.getW()); 230 qwd.getW());
226 231
227 List<XYTextAnnotation> textAnnos = new ArrayList<XYTextAnnotation>(); 232 List<XYTextAnnotation> textAnnos =
233 new ArrayList<XYTextAnnotation>();
228 textAnnos.add(anno); 234 textAnnos.add(anno);
229 RiverAnnotation flysAnno = new RiverAnnotation(null, null, null, theme); 235 RiverAnnotation flysAnno =
236 new RiverAnnotation(null, null, null, theme);
230 flysAnno.setTextAnnotations(textAnnos); 237 flysAnno.setTextAnnotations(textAnnos);
231 generator.addAnnotations(flysAnno); 238 generator.addAnnotations(flysAnno);
232 } 239 }
233 240
234 generator.addAxisSeries(series, axisName, visible); 241 generator.addAxisSeries(series, axisName, visible);
328 log.warn("No QSectors coming from data."); 335 log.warn("No QSectors coming from data.");
329 return; 336 return;
330 } 337 }
331 338
332 List<?> qsectorsList = (List<?>) qsectorsObj; 339 List<?> qsectorsList = (List<?>) qsectorsObj;
333 if (qsectorsList.size() == 0 || !(qsectorsList.get(0) instanceof NamedDouble)) { 340 if (qsectorsList.size() == 0
341 || !(qsectorsList.get(0) instanceof NamedDouble)
342 ) {
334 log.warn("No QSectors coming from data."); 343 log.warn("No QSectors coming from data.");
335 return; 344 return;
336 } 345 }
337 346
338 @SuppressWarnings("unchecked") 347 @SuppressWarnings("unchecked")
392 List<StickyAxisAnnotation> xy = new ArrayList<StickyAxisAnnotation>(); 401 List<StickyAxisAnnotation> xy = new ArrayList<StickyAxisAnnotation>();
393 if (data instanceof double[][]) { 402 if (data instanceof double[][]) {
394 log.debug("Got double[][]"); 403 log.debug("Got double[][]");
395 double [][] values = (double [][]) data; 404 double [][] values = (double [][]) data;
396 for (int i = 0; i< values[0].length; i++) { 405 for (int i = 0; i< values[0].length; i++) {
397 xy.add(new StickyAxisAnnotation(bundle.getFacetDescription(), 406 xy.add(new StickyAxisAnnotation(
398 (float) values[1][i], StickyAxisAnnotation.SimpleAxis.Y_AXIS)); 407 bundle.getFacetDescription(),
408 (float) values[1][i],
409 StickyAxisAnnotation.SimpleAxis.Y_AXIS));
399 } 410 }
400 411
401 if (visible) { 412 if (visible) {
402 generator.addAnnotations( 413 generator.addAnnotations(
403 new RiverAnnotation( 414 new RiverAnnotation(
409 log.debug("Got WKms"); 420 log.debug("Got WKms");
410 /* TODO 421 /* TODO
411 WKms wkms = (WKms) data; 422 WKms wkms = (WKms) data;
412 423
413 Double ckm = 424 Double ckm =
414 (Double) generator.getCallContext().getContextValue(FixChartGenerator.CURRENT_KM); 425 (Double)generator.getCallContext().getContextValue(
426 FixChartGenerator.CURRENT_KM);
415 double location = (ckm != null) 427 double location = (ckm != null)
416 ? ckm.doubleValue() 428 ? ckm.doubleValue()
417 : getRange()[0]; 429 : getRange()[0];
418 double w = StaticWKmsArtifact.getWAtKmLin(data, location); 430 double w = StaticWKmsArtifact.getWAtKmLin(data, location);
419 xy.add(new StickyAxisAnnotation(aandf.getFacetDescription(), 431 xy.add(new StickyAxisAnnotation(aandf.getFacetDescription(),
437 Object data = bundle.getData(generator.getCallContext()); 449 Object data = bundle.getData(generator.getCallContext());
438 if (data instanceof WQKms) { 450 if (data instanceof WQKms) {
439 WQKms wqkms = (WQKms)data; 451 WQKms wqkms = (WQKms)data;
440 // TODO As in doEventsOut, the value-searching should 452 // TODO As in doEventsOut, the value-searching should
441 // be delivered by the facet already 453 // be delivered by the facet already
442 XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme); 454 XYSeries series = new StyledXYSeries(
455 bundle.getFacetDescription(), theme);
443 Double ckm = (Double) generator.getCallContext() 456 Double ckm = (Double) generator.getCallContext()
444 .getContextValue(CURRENT_KM); 457 .getContextValue(CURRENT_KM);
445 458
446 if (wqkms == null || wqkms.getKms().length == 0 || ckm == null) { 459 if (wqkms == null || wqkms.getKms().length == 0 || ckm == null) {
447 log.info("addPointFromWQKms: No event data to show."); 460 log.info("addPointFromWQKms: No event data to show.");
454 * Probably to avoid some rounding errors. */ 467 * Probably to avoid some rounding errors. */
455 if (Math.abs(kms[i] - ckm) <= 0.001) { 468 if (Math.abs(kms[i] - ckm) <= 0.001) {
456 series.add(wqkms.getQ(i), wqkms.getW(i), false); 469 series.add(wqkms.getQ(i), wqkms.getW(i), false);
457 generator.addAxisSeries(series, axisName, visible); 470 generator.addAxisSeries(series, axisName, visible);
458 if(visible && theme.parseShowPointLabel()) { 471 if(visible && theme.parseShowPointLabel()) {
459 List<XYTextAnnotation> textAnnos = new ArrayList<XYTextAnnotation>(); 472 List<XYTextAnnotation> textAnnos =
460 XYTextAnnotation anno = new CollisionFreeXYTextAnnotation( 473 new ArrayList<XYTextAnnotation>();
461 bundle.getFacetDescription(), 474 XYTextAnnotation anno =
462 wqkms.getQ(i), 475 new CollisionFreeXYTextAnnotation(
463 wqkms.getW(i)); 476 bundle.getFacetDescription(),
477 wqkms.getQ(i),
478 wqkms.getW(i));
464 textAnnos.add(anno); 479 textAnnos.add(anno);
465 RiverAnnotation flysAnno = new RiverAnnotation(null, null, null, theme); 480 RiverAnnotation flysAnno =
481 new RiverAnnotation(null, null, null, theme);
466 flysAnno.setTextAnnotations(textAnnos); 482 flysAnno.setTextAnnotations(textAnnos);
467 generator.addAnnotations(flysAnno); 483 generator.addAnnotations(flysAnno);
468 } 484 }
469 return; 485 return;
470 } 486 }
472 } 488 }
473 else { 489 else {
474 log.debug("FixWQCurveGenerator: doWQOut: double[][]"); 490 log.debug("FixWQCurveGenerator: doWQOut: double[][]");
475 double [][] values = (double [][]) data; 491 double [][] values = (double [][]) data;
476 492
477 XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), false, true, theme); 493 XYSeries series = new StyledXYSeries(
494 bundle.getFacetDescription(), false, true, theme);
478 StyledSeriesBuilder.addPoints(series, values, true); 495 StyledSeriesBuilder.addPoints(series, values, true);
479 496
480 generator.addAxisSeries(series, axisName, visible); 497 generator.addAxisSeries(series, axisName, visible);
481 } 498 }
482 } 499 }
500 517
501 @Override 518 @Override
502 public String getAxisLabel(DiagramGenerator generator) { 519 public String getAxisLabel(DiagramGenerator generator) {
503 CallMeta meta = generator.getCallContext().getMeta(); 520 CallMeta meta = generator.getCallContext().getMeta();
504 521
505 RiverAccess access = new RiverAccess((D4EArtifact)generator.getMaster()); 522 RiverAccess access = new RiverAccess((D4EArtifact)generator
523 .getMaster());
506 String unit = access.getRiver().getWstUnit().getName(); 524 String unit = access.getRiver().getWstUnit().getName();
507 return Resources.getMsg( 525 return Resources.getMsg(
508 meta, 526 meta,
509 I18N_AXIS_LABEL, 527 I18N_AXIS_LABEL,
510 new Object[] { unit }); 528 new Object[] { unit });

http://dive4elements.wald.intevation.org