comparison artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.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 bbf6cf555e89
children e5f688820951 0a5239a1e46e
comparison
equal deleted inserted replaced
8855:d7c005e12af0 8856:5e38e2924c07
289 flys-artifacts/src/main/resources/images/ 289 flys-artifacts/src/main/resources/images/
290 flys-client/src/main/webapp/images/ 290 flys-client/src/main/webapp/images/
291 */ 291 */
292 java.net.URL imageURL; 292 java.net.URL imageURL;
293 if (logo.equals("Intevation")) { 293 if (logo.equals("Intevation")) {
294 imageURL = DiagramGenerator.class.getResource("/images/intevation.png"); 294 imageURL = DiagramGenerator.class.getResource(
295 "/images/intevation.png");
295 } 296 }
296 else { // TODO else if ... 297 else { // TODO else if ...
297 imageURL = DiagramGenerator.class.getResource("/images/bfg_logo.gif"); 298 imageURL = DiagramGenerator.class.getResource(
299 "/images/bfg_logo.gif");
298 } 300 }
299 imageIcon = new ImageIcon(imageURL); 301 imageIcon = new ImageIcon(imageURL);
300 302
301 303
302 double xPos = 0d, yPos = 0d; 304 double xPos = 0d, yPos = 0d;
312 } 314 }
313 else if (placev.equals("bottom")) { 315 else if (placev.equals("bottom")) {
314 yPos = (Double)getYBounds(0).getLower(); 316 yPos = (Double)getYBounds(0).getLower();
315 } 317 }
316 else if (placev.equals("center")) { 318 else if (placev.equals("center")) {
317 yPos = ((Double)getYBounds(0).getUpper() + (Double)getYBounds(0).getLower())/2d; 319 yPos = ((Double)getYBounds(0).getUpper()
320 + (Double)getYBounds(0).getLower())/2d;
318 } 321 }
319 else { 322 else {
320 log.debug("Unknown place-v value: " + placev); 323 log.debug("Unknown place-v value: " + placev);
321 } 324 }
322 325
328 } 331 }
329 else if (placeh.equals("right")) { 332 else if (placeh.equals("right")) {
330 xPos = getRightX(); 333 xPos = getRightX();
331 } 334 }
332 else if (placeh.equals("center")) { 335 else if (placeh.equals("center")) {
333 xPos = ((Double)getXBounds(0).getUpper() + (Double)getXBounds(0).getLower())/2d; 336 xPos = ((Double)getXBounds(0).getUpper()
337 + (Double)getXBounds(0).getLower())/2d;
334 } 338 }
335 else { 339 else {
336 log.debug("Unknown place-h value: " + placeh); 340 log.debug("Unknown place-h value: " + placeh);
337 } 341 }
338 342
374 } 378 }
375 } 379 }
376 380
377 XYAnnotation xyannotation = 381 XYAnnotation xyannotation =
378 new XYImageAnnotation(xPos, yPos, imageIcon.getImage(), anchor); 382 new XYImageAnnotation(xPos, yPos, imageIcon.getImage(), anchor);
379 plot.getRenderer().addAnnotation(xyannotation, org.jfree.ui.Layer.BACKGROUND); 383 plot.getRenderer().addAnnotation(
384 xyannotation, org.jfree.ui.Layer.BACKGROUND);
380 } 385 }
381 386
382 387
383 protected NumberAxis createXAxis(String label) { 388 protected NumberAxis createXAxis(String label) {
384 boolean logarithmic = (Boolean)diagramAttributes.getDomainAxis(). 389 boolean logarithmic = (Boolean)diagramAttributes.getDomainAxis().
454 459
455 /** 460 /**
456 * Registers an area to be drawn. 461 * Registers an area to be drawn.
457 * @param area Area to be drawn. 462 * @param area Area to be drawn.
458 * @param axisName Name of the axis. 463 * @param axisName Name of the axis.
459 * @param visible Whether or not to be visible (important for range calculations). 464 * @param visible Whether or not to be visible
460 */ 465 * (important for range calculations).
461 public void addAreaSeries(StyledAreaSeriesCollection area, String axisName, boolean visible) { 466 */
467 public void addAreaSeries(
468 StyledAreaSeriesCollection area,
469 String axisName,
470 boolean visible
471 ) {
462 addAreaSeries(area, diagramAttributes.getAxisIndex(axisName), visible); 472 addAreaSeries(area, diagramAttributes.getAxisIndex(axisName), visible);
463 } 473 }
464 474
465 /** 475 /**
466 * Registers an area to be drawn. 476 * Registers an area to be drawn.
467 * @param area Area to be drawn. 477 * @param area Area to be drawn.
468 * @param index 'axis index' 478 * @param index 'axis index'
469 * @param visible Whether or not to be visible (important for range calculations). 479 * @param visible Whether or not to be visible
470 */ 480 * (important for range calculations).
471 public void addAreaSeries(StyledAreaSeriesCollection area, int index, boolean visible) { 481 */
482 public void addAreaSeries(
483 StyledAreaSeriesCollection area,
484 int index,
485 boolean visible
486 ) {
472 if (area == null) { 487 if (area == null) {
473 log.warn("Cannot yet render above/under curve."); 488 log.warn("Cannot yet render above/under curve.");
474 return; 489 return;
475 } 490 }
476 491
508 * all points in data would be plotted once visible). 523 * all points in data would be plotted once visible).
509 * @param series the data series to include in plot. 524 * @param series the data series to include in plot.
510 * @param axisName name of the axis. 525 * @param axisName name of the axis.
511 * @param visible whether or not the data should be plotted. 526 * @param visible whether or not the data should be plotted.
512 */ 527 */
513 public void addAxisSeries(XYSeries series, String axisName, boolean visible) { 528 public void addAxisSeries(
514 addAxisSeries(series, diagramAttributes.getAxisIndex(axisName), visible); 529 XYSeries series,
515 } 530 String axisName,
516 531 boolean visible
517 public void addAxisDataset(XYDataset dataset, String axisName, boolean visible) { 532 ) {
518 addAxisDataset(dataset, diagramAttributes.getAxisIndex(axisName), visible); 533 addAxisSeries(
534 series, diagramAttributes.getAxisIndex(axisName), visible);
535 }
536
537 public void addAxisDataset(
538 XYDataset dataset,
539 String axisName,
540 boolean visible
541 ) {
542 addAxisDataset(
543 dataset, diagramAttributes.getAxisIndex(axisName), visible);
519 } 544 }
520 545
521 /** 546 /**
522 * Add the given vertical marker to the chart. 547 * Add the given vertical marker to the chart.
523 */ 548 */
654 Integer key = Integer.valueOf(i); 679 Integer key = Integer.valueOf(i);
655 Bounds b = getXBounds(key); 680 Bounds b = getXBounds(key);
656 681
657 682
658 if (b != null && b.getLower().equals(b.getUpper())) { 683 if (b != null && b.getLower().equals(b.getUpper())) {
659 log.debug("Check whether to expand a x axis.i ("+b.getLower() + "-" + b.getUpper()+")"); 684 log.debug("Check whether to expand a x axis.i ("
685 + b.getLower() + "-" + b.getUpper() + ")");
660 setXBounds(key, ChartHelper.expandBounds(b, 5)); 686 setXBounds(key, ChartHelper.expandBounds(b, 5));
661 } 687 }
662 } 688 }
663 } 689 }
664 690
786 * @param bounds The whole range specified by a dataset. 812 * @param bounds The whole range specified by a dataset.
787 * @param x A user defined range (null permitted). 813 * @param x A user defined range (null permitted).
788 * 814 *
789 * @return true, if a zoom range was specified, otherwise false. 815 * @return true, if a zoom range was specified, otherwise false.
790 */ 816 */
791 protected boolean zoom(XYPlot plot, ValueAxis axis, Bounds bounds, Range x) { 817 protected boolean zoom(
792 818 XYPlot plot,
819 ValueAxis axis,
820 Bounds bounds,
821 Range x
822 ) {
793 if (bounds == null) { 823 if (bounds == null) {
794 return false; 824 return false;
795 } 825 }
796 826
797 if (x != null) { 827 if (x != null) {
988 * Create a hash from a legenditem. 1018 * Create a hash from a legenditem.
989 * This hash can then be used to merge legend items labels. 1019 * This hash can then be used to merge legend items labels.
990 * @return hash for given legenditem to identify mergeables. 1020 * @return hash for given legenditem to identify mergeables.
991 */ 1021 */
992 public static String legendItemHash(LegendItem li) { 1022 public static String legendItemHash(LegendItem li) {
993 // TODO Do proper implementation. Ensure that only mergable sets are created. 1023 // TODO Do proper implementation.
1024 // Ensure that only mergable sets are created.
994 // getFillPaint() 1025 // getFillPaint()
995 // getFillPaintTransformer() 1026 // getFillPaintTransformer()
996 // getLabel() 1027 // getLabel()
997 // getLine() 1028 // getLine()
998 // getLinePaint() 1029 // getLinePaint()
1102 label = units.replaceAll(""); 1133 label = units.replaceAll("");
1103 label += firstUnit; 1134 label += firstUnit;
1104 } 1135 }
1105 return label; 1136 return label;
1106 } 1137 }
1107 for (Processor pr: diagramAttributes.getProcessorsForAxisName(axisName)) { 1138 for (
1139 Processor pr: diagramAttributes.getProcessorsForAxisName(axisName)
1140 ) {
1108 String label = pr.getAxisLabel(this); 1141 String label = pr.getAxisLabel(this);
1109 if (label != null) { 1142 if (label != null) {
1110 return label; 1143 return label;
1111 } 1144 }
1112 } 1145 }
1120 * @return a list of Y axis sections. 1153 * @return a list of Y axis sections.
1121 */ 1154 */
1122 protected List<AxisSection> buildYAxisSections() { 1155 protected List<AxisSection> buildYAxisSections() {
1123 List<AxisSection> axisSections = new ArrayList<AxisSection>(); 1156 List<AxisSection> axisSections = new ArrayList<AxisSection>();
1124 1157
1125 List<DiagramAttributes.AxisAttributes> axesAttrs = diagramAttributes.getAxesAttributes(); 1158 List<DiagramAttributes.AxisAttributes> axesAttrs =
1159 diagramAttributes.getAxesAttributes();
1126 1160
1127 for (int i = 0, n = axesAttrs.size(); i < n; i++) { 1161 for (int i = 0, n = axesAttrs.size(); i < n; i++) {
1128 AxisSection ySection = new AxisSection(); 1162 AxisSection ySection = new AxisSection();
1129 String axisName = diagramAttributes.getAxisName(i); 1163 String axisName = diagramAttributes.getAxisName(i);
1130 ySection.setIdentifier(axisName); 1164 ySection.setIdentifier(axisName);
1206 found = true; 1240 found = true;
1207 pr.doOut(this, bundle, theme, visible); 1241 pr.doOut(this, bundle, theme, visible);
1208 1242
1209 if (visible) { 1243 if (visible) {
1210 // Save the label that should be added for this processor 1244 // Save the label that should be added for this processor
1211 int axisIdx = diagramAttributes.getAxisIndex(pr.getAxisName()); 1245 int axisIdx = diagramAttributes.getAxisIndex(
1246 pr.getAxisName());
1212 LinkedHashSet<String> curLabels = axesLabels.get(axisIdx); 1247 LinkedHashSet<String> curLabels = axesLabels.get(axisIdx);
1213 if (curLabels == null) { 1248 if (curLabels == null) {
1214 curLabels = new LinkedHashSet<String>(5); 1249 curLabels = new LinkedHashSet<String>(5);
1215 } 1250 }
1216 curLabels.add(pr.getAxisLabel(this)); 1251 curLabels.add(pr.getAxisLabel(this));

http://dive4elements.wald.intevation.org