comparison artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java @ 8935:3ac9cb0029b2

Introduced new hook for chart tweaking. Also consider area-themes when calculating zoom-bounds
author gernotbelger
date Tue, 06 Mar 2018 17:06:47 +0100
parents 87a242425467
children 07d51fd4864c
comparison
equal deleted inserted replaced
8934:cef37cc093f2 8935:3ac9cb0029b2
507 return; 507 return;
508 } 508 }
509 509
510 AxisDataset axisDataset = (AxisDataset) getAxisDataset(index); 510 AxisDataset axisDataset = (AxisDataset) getAxisDataset(index);
511 511
512 Bounds[] xyBounds = ChartHelper.getBounds(area);
513
514 if (xyBounds == null) {
515 log.warn("Skip XYDataset for Axis (invalid ranges): " + index);
516 return;
517 }
518
519
512 if (visible) { 520 if (visible) {
521 if (log.isDebugEnabled()) {
522 log.debug("Add new AxisDataset at index: " + index);
523 log.debug("X extent: " + xyBounds[0]);
524 log.debug("Y extent: " + xyBounds[1]);
525 }
526
513 axisDataset.addArea(area); 527 axisDataset.addArea(area);
514 } 528 }
515 else { 529
516 /* No range merging, for areas extending to infinity this 530 /* No range merging, for areas extending to infinity this causes problems. */
517 * causes problems. */ 531 /* No range merging, for areas extending to infinity this causes problems. */
518 } 532 if( StyledSeriesBuilder.isBigDoubleValue( xyBounds[1].getLower() ) || StyledSeriesBuilder.isBigDoubleValue( xyBounds[1].getLower() ) )
533 return;
534
535 combineXBounds(xyBounds[0], 0);
536 combineYBounds(xyBounds[1], index);
519 } 537 }
520 538
521 /** 539 /**
522 * Add given series if visible, if not visible adjust ranges (such that 540 * Add given series if visible, if not visible adjust ranges (such that
523 * all points in data would be plotted once visible). 541 * all points in data would be plotted once visible).
717 * @param plot The XYPlot. 735 * @param plot The XYPlot.
718 */ 736 */
719 protected void autoZoom(XYPlot plot) { 737 protected void autoZoom(XYPlot plot) {
720 log.debug("Zoom to specified ranges."); 738 log.debug("Zoom to specified ranges.");
721 739
740 /* allow chart extenders to tweak zoom behavior */
741 final Collection<ChartExtender> extenders = this.diagramAttributes.getExtenders();
742 for (final ChartExtender extender : extenders) {
743 extender.beforeAutoZoom(this);
744 }
745
722 Range xrange = getDomainAxisRange(); 746 Range xrange = getDomainAxisRange();
723 Range yrange = getValueAxisRange(); 747 Range yrange = getValueAxisRange();
724 748
725 ValueAxis xAxis = plot.getDomainAxis(); 749 ValueAxis xAxis = plot.getDomainAxis();
726 750
752 776
753 log.debug("Prepare zoom settings for y axis at index: " + i); 777 log.debug("Prepare zoom settings for y axis at index: " + i);
754 zoom(plot, yaxis, getYBounds(Integer.valueOf(i)), yrange); 778 zoom(plot, yaxis, getYBounds(Integer.valueOf(i)), yrange);
755 } 779 }
756 780
757 /* allow chart extenders to tweak zoom behaviour */
758 final Collection<ChartExtender> extenders = this.diagramAttributes.getExtenders();
759 for (final ChartExtender extender : extenders) { 781 for (final ChartExtender extender : extenders) {
760 extender.afterAutoZoom(this); 782 extender.afterAutoZoom(this);
761 } 783 }
762 } 784 }
763 785

http://dive4elements.wald.intevation.org