Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/TimeseriesChartGenerator.java @ 9123:1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
author | gernotbelger |
---|---|
date | Tue, 05 Jun 2018 19:21:16 +0200 |
parents | 07d51fd4864c |
children | 7c7f73e5e01e |
comparison
equal
deleted
inserted
replaced
9122:b8e7f6becf78 | 9123:1cc7653ca84f |
---|---|
7 */ | 7 */ |
8 | 8 |
9 package org.dive4elements.river.exports; | 9 package org.dive4elements.river.exports; |
10 | 10 |
11 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; | 11 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; |
12 import org.dive4elements.artifacts.CallContext; | |
12 import org.dive4elements.river.artifacts.resources.Resources; | 13 import org.dive4elements.river.artifacts.resources.Resources; |
13 import org.dive4elements.river.jfree.Bounds; | 14 import org.dive4elements.river.jfree.Bounds; |
14 import org.dive4elements.river.jfree.CollisionFreeXYTextAnnotation; | 15 import org.dive4elements.river.jfree.CollisionFreeXYTextAnnotation; |
15 import org.dive4elements.river.jfree.DoubleBounds; | 16 import org.dive4elements.river.jfree.DoubleBounds; |
16 import org.dive4elements.river.jfree.RiverAnnotation; | 17 import org.dive4elements.river.jfree.RiverAnnotation; |
17 import org.dive4elements.river.jfree.AnnotationHelper; | |
18 import org.dive4elements.river.jfree.StyledTimeSeries; | 18 import org.dive4elements.river.jfree.StyledTimeSeries; |
19 import org.dive4elements.river.jfree.TimeBounds; | 19 import org.dive4elements.river.jfree.TimeBounds; |
20 import org.dive4elements.river.jfree.AxisDataset; | 20 import org.dive4elements.river.jfree.AxisDataset; |
21 import org.dive4elements.river.themes.ThemeDocument; | 21 import org.dive4elements.river.themes.ThemeDocument; |
22 | 22 |
91 domainMarker = new ArrayList<Marker>(); | 91 domainMarker = new ArrayList<Marker>(); |
92 valueMarker = new ArrayList<Marker>(); | 92 valueMarker = new ArrayList<Marker>(); |
93 attributes = new HashMap<String, String>(); | 93 attributes = new HashMap<String, String>(); |
94 } | 94 } |
95 | 95 |
96 | 96 @Override |
97 | 97 protected JFreeChart generateChart(CallContext context) { |
98 @Override | |
99 public JFreeChart generateChart() { | |
100 log.info("Generate Timeseries Chart."); | 98 log.info("Generate Timeseries Chart."); |
101 | 99 |
102 JFreeChart chart = ChartFactory.createTimeSeriesChart( | 100 JFreeChart chart = ChartFactory.createTimeSeriesChart( |
103 getChartTitle(), | 101 getChartTitle(context), |
104 getXAxisLabel(), | 102 getXAxisLabel(), |
105 getYAxisLabel(0), | 103 getYAxisLabel(0), |
106 null, | 104 null, |
107 isLegendVisible(), | 105 isLegendVisible(), |
108 false, | 106 false, |
111 XYPlot plot = (XYPlot) chart.getPlot(); | 109 XYPlot plot = (XYPlot) chart.getPlot(); |
112 | 110 |
113 chart.setBackgroundPaint(Color.WHITE); | 111 chart.setBackgroundPaint(Color.WHITE); |
114 plot.setBackgroundPaint(Color.WHITE); | 112 plot.setBackgroundPaint(Color.WHITE); |
115 | 113 |
116 addSubtitles(chart); | 114 addSubtitles(context, chart); |
117 addMetadataSubtitle( chart ); | 115 addMetadataSubtitle( context, chart ); |
118 adjustPlot(plot); | 116 adjustPlot(plot); |
119 addDatasets(plot); | 117 addDatasets(plot); |
120 adjustAxes(plot); | 118 adjustAxes(plot); |
121 addDomainAxisMarker(plot); | 119 addDomainAxisMarker(plot); |
122 addValueAxisMarker(plot); | 120 addValueAxisMarker(plot); |
124 | 122 |
125 applySeriesAttributes(plot); | 123 applySeriesAttributes(plot); |
126 | 124 |
127 consumeAxisSettings(plot); | 125 consumeAxisSettings(plot); |
128 | 126 |
129 AnnotationHelper.addAnnotationsToRenderer( | 127 addAnnotationsToRenderer(plot); |
130 annotations, | 128 |
131 plot, | |
132 getChartSettings(), | |
133 datasets); | |
134 addLogo(plot); | 129 addLogo(plot); |
135 aggregateLegendEntries(plot); | 130 aggregateLegendEntries(plot); |
136 return chart; | 131 return chart; |
137 } | 132 } |
138 | 133 |
627 return new Date(l); | 622 return new Date(l); |
628 } | 623 } |
629 catch(JSONException ex) { | 624 catch(JSONException ex) { |
630 String str = array.getString(0); | 625 String str = array.getString(0); |
631 DateFormat df = DateFormat.getDateInstance( | 626 DateFormat df = DateFormat.getDateInstance( |
632 DateFormat.MEDIUM, Resources.getLocale(context.getMeta())); | 627 DateFormat.MEDIUM, Resources.getLocale(getContext().getMeta())); |
633 return df.parse(str); | 628 return df.parse(str); |
634 } | 629 } |
635 } | 630 } |
636 | 631 |
637 /** | 632 /** |
854 | 849 |
855 /* Create an axis section with setUpperTimeRange and | 850 /* Create an axis section with setUpperTimeRange and |
856 * setLowerTimeRange */ | 851 * setLowerTimeRange */ |
857 @Override | 852 @Override |
858 protected List<AxisSection> buildXAxisSections() { | 853 protected List<AxisSection> buildXAxisSections() { |
859 List<AxisSection> axisSections = new ArrayList<AxisSection>(); | 854 List<AxisSection> axisSections = new ArrayList<>(); |
860 | 855 |
861 String identifier = "X"; | 856 String identifier = "X"; |
862 | 857 |
863 AxisSection axisSection = new AxisSection(); | 858 AxisSection axisSection = new AxisSection(); |
864 axisSection.setIdentifier(identifier); | 859 axisSection.setIdentifier(identifier); |