comparison flys-artifacts/src/main/java/org/dive4elements/river/exports/MiddleBedHeightGenerator.java @ 5831:bd047b71ab37

Repaired internal references
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 12:06:39 +0200
parents flys-artifacts/src/main/java/de/intevation/flys/exports/MiddleBedHeightGenerator.java@5fca0d0d8aac
children
comparison
equal deleted inserted replaced
5830:160f53ee0870 5831:bd047b71ab37
1 package org.dive4elements.river.exports;
2
3 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
4 import org.dive4elements.artifactdatabase.state.Facet;
5 import org.dive4elements.river.artifacts.FLYSArtifact;
6 import org.dive4elements.river.artifacts.model.FacetTypes;
7 import org.dive4elements.river.artifacts.model.MiddleBedHeightData;
8 import org.dive4elements.river.exports.process.BedheightProcessor;
9 import org.dive4elements.river.exports.process.Processor;
10 import org.dive4elements.river.exports.process.WOutProcessor;
11 import org.dive4elements.river.jfree.FLYSAnnotation;
12 import org.dive4elements.river.jfree.StyledXYSeries;
13 import org.dive4elements.river.utils.FLYSUtils;
14
15 import org.apache.log4j.Logger;
16 import org.jfree.data.xy.XYSeries;
17 import org.w3c.dom.Document;
18
19 // TODO Move class to org.dive4elements.river.exports.minfo
20 /**
21 * An OutGenerator that generates middle bed height charts.
22 *
23 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
24 */
25 public class MiddleBedHeightGenerator
26 extends XYChartGenerator
27 implements FacetTypes
28 {
29 public enum YAXIS {
30 H(0), W(1), P(2);
31 protected int idx;
32 private YAXIS(int c) {
33 idx = c;
34 }
35 }
36
37 /** The logger that is used in this generator. */
38 private static Logger logger = Logger.getLogger(MiddleBedHeightGenerator.class);
39
40 /** Key to look up internationalized String for annotations label. */
41 public static final String I18N_ANNOTATIONS_LABEL =
42 "chart.bedheight_middle.annotations.label";
43
44 public static final String I18N_CHART_TITLE =
45 "chart.bedheight_middle.section.title";
46
47 public static final String I18N_CHART_SUBTITLE =
48 "chart.bedheight_middle.section.subtitle";
49
50 public static final String I18N_CHART_SHORT_SUBTITLE =
51 "chart.bedheight_middle.section.shortsubtitle";
52
53 public static final String I18N_XAXIS_LABEL =
54 "chart.bedheight_middle.section.xaxis.label";
55
56 public static final String I18N_YAXIS_LABEL =
57 "chart.bedheight_middle.section.yaxis.label";
58
59 public static final String I18N_CHART_TITLE_DEFAULT = "Mittlere Sohlhöhe";
60 public static final String I18N_XAXIS_LABEL_DEFAULT = "km";
61 public static final String I18N_YAXIS_LABEL_DEFAULT = "mittlere Sohlhöhen [müNN]";
62 public static final String I18N_W_YAXIS_LABEL =
63 "chart.longitudinal.section.yaxis.label";
64 public static final String I18N_W_YAXIS_LABEL_DEFAULT = "W [NN + m]";
65 public static final String I18N_P_YAXIS_LABEL_DEFAULT = "Gepeilte Breite [m]";
66 public static final String I18N_P_YAXIS_LABEL =
67 "chart.bedheight_middle.sounding.yaxis.label";
68
69 @Override
70 protected YAxisWalker getYAxisWalker() {
71 return new YAxisWalker() {
72 @Override
73 public int length() {
74 return YAXIS.values().length;
75 }
76
77 @Override
78 public String getId(int idx) {
79 YAXIS[] yaxes = YAXIS.values();
80 return yaxes[idx].toString();
81 }
82 };
83 }
84
85
86 /**
87 * Returns the default title for this chart.
88 *
89 * @return the default title for this chart.
90 */
91 @Override
92 public String getDefaultChartTitle() {
93 Object[] args = new Object[] {
94 getRiverName()
95 };
96
97 return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT, args);
98 }
99
100
101 /**
102 * Get internationalized label for the x axis.
103 */
104 @Override
105 protected String getDefaultXAxisLabel() {
106 FLYSArtifact flys = (FLYSArtifact) master;
107
108 return msg(
109 I18N_XAXIS_LABEL,
110 I18N_XAXIS_LABEL_DEFAULT,
111 new Object[] { FLYSUtils.getRiver(flys).getName() });
112 }
113
114
115 @Override
116 protected String getDefaultYAxisLabel(int index) {
117 String label = "default";
118
119 if (index == YAXIS.H.idx) {
120 label = getHAxisLabel();
121 }
122 else if (index == YAXIS.W.idx) {
123 FLYSArtifact flys = (FLYSArtifact) master;
124 String unit = FLYSUtils.getRiver(flys).getWstUnit().getName();
125
126 label = msg(
127 I18N_W_YAXIS_LABEL,
128 I18N_W_YAXIS_LABEL_DEFAULT,
129 new Object[] { unit });
130 }
131 else if (index == YAXIS.P.idx) {
132 label = msg(I18N_P_YAXIS_LABEL, I18N_P_YAXIS_LABEL_DEFAULT);
133 }
134
135 return label;
136 }
137
138
139 /**
140 * Get internationalized label for the y axis.
141 */
142 protected String getHAxisLabel() {
143 return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT);
144 }
145
146
147 /**
148 * Produce output.
149 * @param artifactAndFacet current facet.
150 * @param attr theme for facet
151 */
152 @Override
153 public void doOut(
154 ArtifactAndFacet artifactAndFacet,
155 Document attr,
156 boolean visible
157 ) {
158 String name = artifactAndFacet.getFacetName();
159
160 logger.debug("MiddleBedHeightGenerator.doOut: " + name);
161
162 if (name == null) {
163 logger.error("No facet name for doOut(). No output generated!");
164 return;
165 }
166
167 Facet facet = artifactAndFacet.getFacet();
168
169 if (facet == null) {
170 return;
171 }
172
173 Processor woutp = new WOutProcessor();
174 Processor bedp = new BedheightProcessor();
175 WOutProcessor processor = new WOutProcessor();
176 if (processor.canHandle(name)) {
177 processor.doOut(this, artifactAndFacet, attr, visible, YAXIS.W.idx);
178 }
179 if (name.equals(MIDDLE_BED_HEIGHT_SINGLE) || name.equals(MIDDLE_BED_HEIGHT_EPOCH)) {
180 doHeightOut(
181 (MiddleBedHeightData) artifactAndFacet.getData(context),
182 artifactAndFacet,
183 attr,
184 visible);
185 }
186 else if (name.equals(MIDDLE_BED_HEIGHT_ANNOTATION)) {
187 doAnnotations(
188 (FLYSAnnotation) artifactAndFacet.getData(context),
189 artifactAndFacet,
190 attr,
191 visible);
192 }
193 else if (FacetTypes.IS.AREA(name)) {
194 doArea(
195 artifactAndFacet.getData(context),
196 artifactAndFacet,
197 attr,
198 visible);
199 }
200 else if (FacetTypes.IS.MANUALPOINTS(name)) {
201 doPoints(
202 artifactAndFacet.getData(context),
203 artifactAndFacet,
204 attr,
205 visible,
206 YAXIS.H.idx);
207 }
208 else if (bedp.canHandle(name)) {
209 bedp.doOut(this, artifactAndFacet, attr, visible, YAXIS.P.idx);
210 }
211 else if (woutp.canHandle(name)) {
212 woutp.doOut(this, artifactAndFacet, attr, visible, YAXIS.W.idx);
213 }
214 else {
215 logger.warn("Unknown facet name: " + name);
216 }
217 }
218
219
220 /**
221 * @param data A data object
222 * @param aandf The artifact and facet. This facet does NOT support any data objects. Use
223 * FLYSArtifact.getNativeFacet() instead to retrieve a Facet which supports
224 * data.
225 * @param theme The theme that contains styling information.
226 * @param visible The visibility of the curve.
227 */
228 protected void doHeightOut(
229 MiddleBedHeightData data,
230 ArtifactAndFacet aandf,
231 Document theme,
232 boolean visible
233 ) {
234 logger.debug("MiddleBedHeightGenerator.doMainChannelOut");
235
236 XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
237
238 StyledSeriesBuilder.addPoints(series, data.getMiddleHeightsPoints(), false);
239
240 addAxisSeries(series, YAXIS.H.idx, visible);
241 }
242
243
244 /** Look up the axis identifier for a given facet type. */
245 public int axisIdxForFacet(String facetName) {
246 if (FacetTypes.IS.H(facetName)) {
247 return YAXIS.H.idx;
248 }
249 else if (FacetTypes.IS.W(facetName)) {
250 return YAXIS.W.idx;
251 }
252 else {
253 logger.warn("Could not find axis for facet " + facetName);
254 return YAXIS.H.idx;
255 }
256 }
257
258
259 /**
260 * Do Area out.
261 * @param theme styling information.
262 * @param visible whether or not visible.
263 */
264 protected void doArea(
265 Object o,
266 ArtifactAndFacet aandf,
267 Document theme,
268 boolean visible
269 ) {
270 logger.debug("FlowVelocityGenerator.doArea");
271 logger.warn("TODO: Implement FlowVelocityGenerator.doArea");
272 }
273 }
274 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org