comparison artifacts/src/main/java/org/dive4elements/river/exports/TimeseriesChartGenerator.java @ 9325:094ed9d1f2ad

Fixed: change of point style of interpolated data did not change in WQ chart of fixanalysis Fixed: change of point style of interpolated data did not change in dWt chart of fixanalysis; also had duplicate legend entries
author gernotbelger
date Fri, 27 Jul 2018 14:33:41 +0200
parents 7c7f73e5e01e
children ef5754ba5573
comparison
equal deleted inserted replaced
9324:058701d91552 9325:094ed9d1f2ad
64 64
65 protected List<Marker> domainMarker; 65 protected List<Marker> domainMarker;
66 66
67 protected List<Marker> valueMarker; 67 protected List<Marker> valueMarker;
68 68
69 protected Map<String, String> attributes;
70
71 protected boolean domainZeroLineVisible; 69 protected boolean domainZeroLineVisible;
72 70
73 private static final Logger log = 71 private static final Logger log =
74 Logger.getLogger(TimeseriesChartGenerator.class); 72 Logger.getLogger(TimeseriesChartGenerator.class);
75 73
88 86
89 xBounds = new HashMap<Integer, Bounds>(); 87 xBounds = new HashMap<Integer, Bounds>();
90 yBounds = new HashMap<Integer, Bounds>(); 88 yBounds = new HashMap<Integer, Bounds>();
91 domainMarker = new ArrayList<Marker>(); 89 domainMarker = new ArrayList<Marker>();
92 valueMarker = new ArrayList<Marker>(); 90 valueMarker = new ArrayList<Marker>();
93 attributes = new HashMap<String, String>();
94 } 91 }
95 92
96 @Override 93 @Override
97 protected JFreeChart generateChart(CallContext context) { 94 protected JFreeChart generateChart(CallContext context) {
98 log.info("Generate Timeseries Chart."); 95 log.info("Generate Timeseries Chart.");
117 addDatasets(plot); 114 addDatasets(plot);
118 adjustAxes(plot); 115 adjustAxes(plot);
119 addDomainAxisMarker(plot); 116 addDomainAxisMarker(plot);
120 addValueAxisMarker(plot); 117 addValueAxisMarker(plot);
121 adaptZoom(plot); 118 adaptZoom(plot);
122
123 applySeriesAttributes(plot);
124 119
125 consumeAxisSettings(plot); 120 consumeAxisSettings(plot);
126 121
127 addAnnotationsToRenderer(plot); 122 addAnnotationsToRenderer(plot);
128 123
713 plot.addRangeMarker(marker, Layer.BACKGROUND); 708 plot.addRangeMarker(marker, Layer.BACKGROUND);
714 } 709 }
715 valueMarker.clear(); 710 valueMarker.clear();
716 } 711 }
717 712
718 public void addAttribute(String seriesKey, String name) {
719 attributes.put(seriesKey, name);
720 }
721
722 private LegendItem getLegendItemFor(XYPlot plot, String interSeriesKey) {
723 LegendItemCollection litems = plot.getLegendItems();
724 Iterator<LegendItem> iter = litems.iterator();
725 while(iter.hasNext()) {
726 LegendItem item = iter.next();
727 if(interSeriesKey.startsWith(item.getSeriesKey().toString())) {
728 return item;
729 }
730 }
731 return null;
732 }
733
734 protected void applySeriesAttributes(XYPlot plot) {
735 int count = plot.getDatasetCount();
736 for (int i = 0; i < count; i++) {
737 XYDataset data = plot.getDataset(i);
738 if (data == null) {
739 continue;
740 }
741
742 int seriesCount = data.getSeriesCount();
743 for (int j = 0; j < seriesCount; j++) {
744 StyledTimeSeries series =
745 (StyledTimeSeries)getSeriesOf(data, j);
746 String key = series.getKey().toString();
747
748 if (attributes.containsKey(key)) {
749 // Interpolated points are drawn unfilled
750 if (attributes.get(key).equals("interpolate")) {
751 XYLineAndShapeRenderer renderer =
752 series.getStyle().getRenderer();
753 renderer.setSeriesPaint(
754 j,
755 renderer.getSeriesFillPaint(j));
756 renderer.setSeriesShapesFilled(j, false);
757
758 LegendItem legendItem = getLegendItemFor(plot, key);
759 if(legendItem != null) {
760 LegendItem interLegend = new LegendItem(
761 legendItem.getLabel(),
762 legendItem.getDescription(),
763 legendItem.getToolTipText(),
764 legendItem.getURLText(),
765 legendItem.isShapeVisible(),
766 legendItem.getShape(),
767 false, // shapeFilled?
768 legendItem.getFillPaint(),
769 true, // shapeOutlineVisible?
770 renderer.getSeriesFillPaint(j),
771 legendItem.getOutlineStroke(),
772 legendItem.isLineVisible(),
773 legendItem.getLine(),
774 legendItem.getLineStroke(),
775 legendItem.getLinePaint()
776 );
777 interLegend.setSeriesKey(series.getKey());
778 log.debug("applySeriesAttributes: "
779 + "draw unfilled legend item");
780 plot.getLegendItems().add(interLegend);
781 }
782 }
783 }
784
785 if (attributes.containsKey(key)) {
786 if(attributes.get(key).equals("outline")) {
787 XYLineAndShapeRenderer renderer =
788 series.getStyle().getRenderer();
789 renderer.setSeriesPaint(
790 j,
791 renderer.getSeriesFillPaint(j));
792 renderer.setDrawOutlines(true);
793 }
794 }
795 }
796 }
797 }
798
799 /** Two Ranges that span a rectangular area. */ 713 /** Two Ranges that span a rectangular area. */
800 public static class Area { 714 public static class Area {
801 protected Range xRange; 715 protected Range xRange;
802 protected Range yRange; 716 protected Range yRange;
803 717

http://dive4elements.wald.intevation.org