Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/ReferenceCurveGenerator.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 |
---|---|
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.model.FacetTypes; | 13 import org.dive4elements.river.artifacts.model.FacetTypes; |
13 import org.dive4elements.river.artifacts.model.WW; | 14 import org.dive4elements.river.artifacts.model.WW; |
14 import org.dive4elements.river.artifacts.model.WW.ApplyFunctionIterator; | 15 import org.dive4elements.river.artifacts.model.WW.ApplyFunctionIterator; |
15 import org.dive4elements.river.artifacts.model.WWAxisTypes; | 16 import org.dive4elements.river.artifacts.model.WWAxisTypes; |
16 import org.dive4elements.river.jfree.RiverAnnotation; | 17 import org.dive4elements.river.jfree.RiverAnnotation; |
84 } | 85 } |
85 | 86 |
86 | 87 |
87 /** Get default chart title. */ | 88 /** Get default chart title. */ |
88 @Override | 89 @Override |
89 protected String getDefaultChartTitle() { | 90 protected String getDefaultChartTitle(final CallContext context) { |
90 return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); | 91 return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); |
91 } | 92 } |
92 | 93 |
93 @Override | 94 @Override |
94 protected String getDefaultChartSubtitle() { | 95 protected String getDefaultChartSubtitle(final CallContext context) { |
95 Object[] args = new Object[] { | 96 Object[] args = new Object[] { |
96 getRiverName(), | 97 getRiverName(), |
97 }; | 98 }; |
98 | 99 |
99 return msg(I18N_CHART_SUBTITLE, "", args); | 100 return msg(I18N_CHART_SUBTITLE, "", args); |
100 } | 101 } |
101 | 102 |
102 | 103 |
103 /** True if axis is in cm (because at gauge). */ | 104 /** True if axis is in cm (because at gauge). */ |
104 protected boolean getInCm(int index) { | 105 protected boolean getInCm(int index) { |
105 Object obj = context.getContextValue("reference.curve.axis.scale"); | 106 Object obj = getContext().getContextValue("reference.curve.axis.scale"); |
106 return obj instanceof WWAxisTypes && ((WWAxisTypes)obj).getInCm(index); | 107 return obj instanceof WWAxisTypes && ((WWAxisTypes)obj).getInCm(index); |
107 } | 108 } |
108 | 109 |
109 | 110 |
110 /** Get Label for X-axis (W). */ | 111 /** Get Label for X-axis (W). */ |
111 @Override | 112 @Override |
112 protected String getDefaultXAxisLabel() { | 113 protected String getDefaultXAxisLabel(final CallContext context) { |
113 return msg(getInCm(0) ? I18N_X_AXIS_IN_CM : I18N_X_AXIS_IN_M); | 114 return msg(getInCm(0) ? I18N_X_AXIS_IN_CM : I18N_X_AXIS_IN_M); |
114 } | 115 } |
115 | 116 |
116 | 117 |
117 /** | 118 /** |
147 if (name == null || name.length() == 0) { | 148 if (name == null || name.length() == 0) { |
148 log.error("No facet given. Cannot create dataset."); | 149 log.error("No facet given. Cannot create dataset."); |
149 return; | 150 return; |
150 } | 151 } |
151 | 152 |
153 final CallContext context = getContext(); | |
154 | |
152 if (name.equals(facetName())) { | 155 if (name.equals(facetName())) { |
153 doReferenceOut(artifactFacet.getData(context), theme, visible); | 156 doReferenceOut(artifactFacet.getData(context), theme, visible); |
154 } | 157 } |
155 else if (FacetTypes.IS.MANUALPOINTS(name)) { | 158 else if (FacetTypes.IS.MANUALPOINTS(name)) { |
156 doPoints( | 159 doPoints( |
192 ThemeDocument theme, | 195 ThemeDocument theme, |
193 boolean visible | 196 boolean visible |
194 ) { | 197 ) { |
195 WW ww = (WW)data; | 198 WW ww = (WW)data; |
196 | 199 |
197 Object obj = context.getContextValue("reference.curve.axis.scale"); | 200 Object obj = getContext().getContextValue("reference.curve.axis.scale"); |
198 | 201 |
199 WWAxisTypes wwat = obj instanceof WWAxisTypes | 202 WWAxisTypes wwat = obj instanceof WWAxisTypes |
200 ? (WWAxisTypes)obj | 203 ? (WWAxisTypes)obj |
201 : new WWAxisTypes(ww); | 204 : new WWAxisTypes(ww); |
202 | 205 |
234 | 237 |
235 | 238 |
236 /** Set the tick units for given axis. */ | 239 /** Set the tick units for given axis. */ |
237 protected void setAxisTickUnit(double tick, ValueAxis axis) { | 240 protected void setAxisTickUnit(double tick, ValueAxis axis) { |
238 TickUnits units = new TickUnits(); | 241 TickUnits units = new TickUnits(); |
239 units.add(new NumberTickUnit(tick, Formatter.getWaterlevelW(context))); | 242 units.add(new NumberTickUnit(tick, Formatter.getWaterlevelW(getContext()))); |
240 axis.setStandardTickUnits(units); | 243 axis.setStandardTickUnits(units); |
241 axis.setAutoTickUnitSelection(true); | 244 axis.setAutoTickUnitSelection(true); |
242 } | 245 } |
243 | 246 |
244 @Override | 247 @Override |