Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/extreme/ExtremeWQCurveGenerator.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 | 5e38e2924c07 |
children | 9b8e8fc1f408 |
comparison
equal
deleted
inserted
replaced
9122:b8e7f6becf78 | 9123:1cc7653ca84f |
---|---|
17 import org.jfree.chart.plot.XYPlot; | 17 import org.jfree.chart.plot.XYPlot; |
18 import org.jfree.chart.title.TextTitle; | 18 import org.jfree.chart.title.TextTitle; |
19 import org.jfree.data.xy.XYSeries; | 19 import org.jfree.data.xy.XYSeries; |
20 | 20 |
21 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; | 21 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; |
22 import org.dive4elements.artifacts.CallContext; | |
22 import org.dive4elements.river.artifacts.access.FixAnalysisAccess; | 23 import org.dive4elements.river.artifacts.access.FixAnalysisAccess; |
23 import org.dive4elements.river.artifacts.D4EArtifact; | 24 import org.dive4elements.river.artifacts.D4EArtifact; |
24 import org.dive4elements.river.artifacts.model.DateRange; | 25 import org.dive4elements.river.artifacts.model.DateRange; |
25 import org.dive4elements.river.artifacts.model.FacetTypes; | 26 import org.dive4elements.river.artifacts.model.FacetTypes; |
26 import org.dive4elements.river.artifacts.model.extreme.Curve; | 27 import org.dive4elements.river.artifacts.model.extreme.Curve; |
112 ThemeDocument theme, | 113 ThemeDocument theme, |
113 boolean visible | 114 boolean visible |
114 ) { | 115 ) { |
115 log.debug("doExtremeCurveBaseOut"); | 116 log.debug("doExtremeCurveBaseOut"); |
116 ExtremeCurveFacet facet = (ExtremeCurveFacet) aaf.getFacet(); | 117 ExtremeCurveFacet facet = (ExtremeCurveFacet) aaf.getFacet(); |
117 Curve curve = (Curve) facet.getData(aaf.getArtifact(), context); | 118 Curve curve = (Curve) facet.getData(aaf.getArtifact(), getContext()); |
118 if (curve == null) { | 119 if (curve == null) { |
119 log.warn("doExtremeCurveBaseOut: Facet does not contain Curve"); | 120 log.warn("doExtremeCurveBaseOut: Facet does not contain Curve"); |
120 return; | 121 return; |
121 } | 122 } |
122 | 123 |
153 ThemeDocument theme, | 154 ThemeDocument theme, |
154 boolean visible | 155 boolean visible |
155 ) { | 156 ) { |
156 log.debug("doExtremeCurveOut"); | 157 log.debug("doExtremeCurveOut"); |
157 ExtremeCurveFacet facet = (ExtremeCurveFacet) aaf.getFacet(); | 158 ExtremeCurveFacet facet = (ExtremeCurveFacet) aaf.getFacet(); |
158 Curve curve = (Curve) facet.getData(aaf.getArtifact(), context); | 159 Curve curve = (Curve) facet.getData(aaf.getArtifact(), getContext()); |
159 if (curve == null) { | 160 if (curve == null) { |
160 log.warn("doExtremeCurveOut: Facet does not contain Curve"); | 161 log.warn("doExtremeCurveOut: Facet does not contain Curve"); |
161 return; | 162 return; |
162 } | 163 } |
163 | 164 |
187 addAxisSeries(series, YAXIS.W.idx, visible); | 188 addAxisSeries(series, YAXIS.W.idx, visible); |
188 } | 189 } |
189 | 190 |
190 | 191 |
191 @Override | 192 @Override |
192 protected String getChartTitle() { | 193 protected String getChartTitle(final CallContext context) { |
193 return Resources.format( | 194 return Resources.format( |
194 context.getMeta(), | 195 getContext().getMeta(), |
195 I18N_CHART_TITLE, | 196 I18N_CHART_TITLE, |
196 I18N_CHART_TITLE_DEFAULT, | 197 I18N_CHART_TITLE_DEFAULT, |
197 context.getContextValue(CURRENT_KM)); | 198 getContext().getContextValue(CURRENT_KM)); |
198 } | 199 } |
199 | 200 |
200 | 201 |
201 @Override | 202 @Override |
202 protected String getDefaultChartTitle() { | 203 protected String getDefaultChartTitle(final CallContext context) { |
203 return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); | 204 return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); |
204 } | 205 } |
205 | 206 |
206 @Override | 207 @Override |
207 protected String getDefaultChartSubtitle() { | 208 protected String getDefaultChartSubtitle(final CallContext context) { |
208 FixAnalysisAccess access = new FixAnalysisAccess(artifact); | 209 FixAnalysisAccess access = new FixAnalysisAccess(artifact); |
209 DateRange dateRange = access.getDateRange(); | 210 DateRange dateRange = access.getDateRange(); |
210 DateRange refRange = access.getReferencePeriod(); | 211 DateRange refRange = access.getReferencePeriod(); |
211 | 212 |
212 if (dateRange != null && refRange != null) { | 213 if (dateRange != null && refRange != null) { |
213 return Resources.format( | 214 return Resources.format( |
214 context.getMeta(), | 215 getContext().getMeta(), |
215 I18N_CHART_SUBTITLE, | 216 I18N_CHART_SUBTITLE, |
216 "", | 217 "", |
217 access.getRiverName(), | 218 access.getRiverName(), |
218 dateRange.getFrom(), | 219 dateRange.getFrom(), |
219 dateRange.getTo(), | 220 dateRange.getTo(), |
223 | 224 |
224 return null; | 225 return null; |
225 } | 226 } |
226 | 227 |
227 @Override | 228 @Override |
228 protected void addSubtitles(JFreeChart chart) { | 229 protected void addSubtitles(final CallContext context, JFreeChart chart) { |
229 String defaultSubtitle = getDefaultChartSubtitle(); | 230 String defaultSubtitle = getDefaultChartSubtitle(context); |
230 | 231 |
231 if (defaultSubtitle == null || defaultSubtitle.length() == 0) { | 232 if (defaultSubtitle == null || defaultSubtitle.length() == 0) { |
232 return; | 233 return; |
233 } | 234 } |
234 | 235 |
235 chart.addSubtitle(new TextTitle(defaultSubtitle)); | 236 chart.addSubtitle(new TextTitle(defaultSubtitle)); |
236 } | 237 } |
237 | 238 |
238 @Override | 239 @Override |
239 protected String getDefaultXAxisLabel() { | 240 protected String getDefaultXAxisLabel(final CallContext context) { |
240 return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT); | 241 return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT); |
241 } | 242 } |
242 | 243 |
243 @Override | 244 @Override |
244 protected String getDefaultYAxisLabel(int pos) { | 245 protected String getDefaultYAxisLabel(int pos) { |
245 D4EArtifact flys = (D4EArtifact) master; | 246 D4EArtifact flys = getArtifact(); |
246 | 247 |
247 String unit = RiverUtils.getRiver(flys).getWstUnit().getName(); | 248 String unit = RiverUtils.getRiver(flys).getWstUnit().getName(); |
248 if (pos == 0) { | 249 if (pos == 0) { |
249 unit = "cm"; | 250 unit = "cm"; |
250 } | 251 } |