comparison flys-artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedQualityGenerator.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/minfo/BedQualityGenerator.java@55d6c5cac9d1
children
comparison
equal deleted inserted replaced
5830:160f53ee0870 5831:bd047b71ab37
1 package org.dive4elements.river.exports.minfo;
2
3 import org.apache.log4j.Logger;
4 import org.jfree.data.xy.XYSeries;
5 import org.w3c.dom.Document;
6
7 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
8 import org.dive4elements.artifactdatabase.state.Facet;
9 import org.dive4elements.river.artifacts.model.FacetTypes;
10 import org.dive4elements.river.artifacts.model.minfo.BedDiameterResult;
11 import org.dive4elements.river.artifacts.model.minfo.BedParametersResult;
12 import org.dive4elements.river.artifacts.model.minfo.BedloadDiameterResult;
13 import org.dive4elements.river.exports.StyledSeriesBuilder;
14 import org.dive4elements.river.exports.XYChartGenerator;
15 import org.dive4elements.river.jfree.FLYSAnnotation;
16 import org.dive4elements.river.jfree.StyledXYSeries;
17
18
19 /**
20 * An OutGenerator that generates bed quality charts.
21 *
22 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
23 */
24 public class BedQualityGenerator extends XYChartGenerator implements FacetTypes {
25
26 public enum YAXIS {
27 W(0), P(1), D(2);
28
29 protected int idx;
30
31 private YAXIS(int c) {
32 idx = c;
33 }
34 }
35
36 /** The logger that is used in this generator. */
37 private static Logger logger = Logger.getLogger(BedQualityGenerator.class);
38
39 public static final String I18N_CHART_TITLE = "chart.bedquality.title";
40 public static final String I18N_XAXIS_LABEL = "chart.bedquality.xaxis.label";
41 public static final String I18N_YAXIS_LABEL = "chart.bedquality.yaxis.label";
42 public static final String I18N_SECOND_YAXIS_LABEL = "chart.bedquality.yaxis.label.porosity";
43 public static final String I18N_THIRD_YAXIS_LABEL = "chart.bedquality.yaxis.label.diameter";
44
45 public static final String I18N_CHART_TITLE_DEFAULT = "Sohlen Längsschnitt";
46 public static final String I18N_XAXIS_LABEL_DEFAULT = "Fluss-Km";
47 public static final String I18N_YAXIS_LABEL_DEFAULT = "Durchmesser [mm]";
48 public static final String I18N_SECOND_YAXIS_LABEL_DEFAULT = "Porosität [%]";
49 public static final String I18N_THIRD_YAXIS_LABEL_DEFAULT = "Dichte [t/m^3]";
50
51 @Override
52 protected YAxisWalker getYAxisWalker() {
53 return new YAxisWalker() {
54
55 @Override
56 public int length() {
57 return YAXIS.values().length;
58 }
59
60 @Override
61 public String getId(int idx) {
62 YAXIS[] yaxes = YAXIS.values();
63 return yaxes[idx].toString();
64 }
65 };
66 }
67
68 /**
69 * Returns the default title for this chart.
70 *
71 * @return the default title for this chart.
72 */
73 @Override
74 public String getDefaultChartTitle() {
75 return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT);
76 }
77
78 /**
79 * Get internationalized label for the x axis.
80 */
81 @Override
82 protected String getDefaultXAxisLabel() {
83 return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT);
84 }
85
86 @Override
87 protected String getDefaultYAxisLabel(int index) {
88 String label = "default";
89
90 if (index == YAXIS.W.idx) {
91 label = getWAxisLabel();
92 }
93 else if (index == YAXIS.P.idx) {
94 label = getPAxisLabel();
95 }
96 else if (index == YAXIS.D.idx) {
97 label = getDAxisLabel();
98 }
99
100 return label;
101 }
102
103 /**
104 * Get internationalized label for the y axis displaying the diameter.
105 */
106 protected String getWAxisLabel() {
107 return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT);
108 }
109
110 /**
111 * Get internationalized label for the y axis displaying the porosity.
112 */
113 protected String getPAxisLabel() {
114 return msg(I18N_SECOND_YAXIS_LABEL, I18N_SECOND_YAXIS_LABEL_DEFAULT);
115 }
116
117 /**
118 * Get internationalized label for the y axis displaying the density.
119 */
120 protected String getDAxisLabel() {
121 return msg(I18N_THIRD_YAXIS_LABEL, I18N_THIRD_YAXIS_LABEL_DEFAULT);
122 }
123
124 /**
125 * Produce output.
126 *
127 * @param artifactAndFacet
128 * current facet.
129 * @param attr
130 * theme for facet
131 */
132 public void doOut(ArtifactAndFacet artifactAndFacet, Document attr,
133 boolean visible) {
134 String name = artifactAndFacet.getFacetName();
135
136 logger.debug("BedQualityGenerator.doOut: " + name);
137
138 if (name == null) {
139 logger.error("No facet name for doOut(). No output generated!");
140 return;
141 }
142
143 Facet facet = artifactAndFacet.getFacet();
144
145 if (facet == null) {
146 return;
147 }
148
149 // TODO BED_QUALITY_BED_DIAMETER_TOPLAYER
150 if (name.equals(BED_QUALITY_BED_DIAMETER_TOPLAYER)) {
151 doBedDiameterTopLayerOut(
152 (BedDiameterResult) artifactAndFacet.getData(context),
153 artifactAndFacet, attr, visible);
154 }
155 else if (name.equals(BED_QUALITY_BED_DIAMETER_SUBLAYER)) {
156 doBedDiameterSubLayerOut(
157 (BedDiameterResult) artifactAndFacet.getData(context),
158 artifactAndFacet, attr, visible);
159 }
160 // TODO BED_QUALITY_BED_DIAMETER_SUBLAYER
161 else if (name.equals(BED_QUALITY_BEDLOAD_DIAMETER)) {
162 doBedLoadDiameterOut(
163 (BedloadDiameterResult) artifactAndFacet.getData(context),
164 artifactAndFacet, attr, visible);
165 }
166 else if (name.equals(BED_QUALITY_POROSITY_TOPLAYER)) {
167 doPorosityTopLayerOut(
168 (BedParametersResult) artifactAndFacet.getData(context),
169 artifactAndFacet, attr, visible);
170 }
171 else if (name.equals(BED_QUALITY_POROSITY_SUBLAYER)) {
172 doPorositySubLayerOut(
173 (BedParametersResult) artifactAndFacet.getData(context),
174 artifactAndFacet, attr, visible);
175 }
176 else if (name.equals(BED_QUALITY_SEDIMENT_DENSITY_TOPLAYER)) {
177 doDensityTopLayerOut(
178 (BedParametersResult) artifactAndFacet.getData(context),
179 artifactAndFacet, attr, visible);
180 }
181 else if (name.equals(BED_QUALITY_SEDIMENT_DENSITY_SUBLAYER)) {
182 doDensitySubLayerOut(
183 (BedParametersResult) artifactAndFacet.getData(context),
184 artifactAndFacet, attr, visible);
185 }
186 else if (name.equals(LONGITUDINAL_ANNOTATION)) {
187 doAnnotations(
188 (FLYSAnnotation) artifactAndFacet.getData(context),
189 artifactAndFacet,
190 attr,
191 visible);
192 }
193 else if (FacetTypes.IS.MANUALPOINTS(name)) {
194 doPoints(artifactAndFacet.getData(context), artifactAndFacet, attr,
195 visible, YAXIS.W.idx);
196 }
197 else {
198 logger.warn("Unknown facet name: " + name);
199 return;
200 }
201 }
202
203 protected void doBedDiameterTopLayerOut(BedDiameterResult data,
204 ArtifactAndFacet aandf, Document theme, boolean visible) {
205 logger.debug("BedQuality.doBedDiameterTopLayerOut");
206
207 XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
208 StyledSeriesBuilder.addPoints(series, data.getDiameterCapData(), true);
209
210 addAxisSeries(series, YAXIS.W.idx, visible);
211 }
212
213 protected void doBedDiameterSubLayerOut(BedDiameterResult data,
214 ArtifactAndFacet aandf, Document theme, boolean visible) {
215 logger.debug("BedQuality.doBedDiameterSubLayerOut");
216
217 XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
218 StyledSeriesBuilder.addPoints(series, data.getDiameterSubData(), true);
219
220 addAxisSeries(series, YAXIS.W.idx, visible);
221 }
222
223 protected void doBedLoadDiameterOut(BedloadDiameterResult data,
224 ArtifactAndFacet aandf, Document theme, boolean visible) {
225 logger.debug("BedQuality.doBedLoadDiameterOut");
226
227 XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
228 StyledSeriesBuilder.addPoints(series, data.getDiameterData(), true);
229
230 addAxisSeries(series, YAXIS.W.idx, visible);
231 }
232
233 protected void doPorosityTopLayerOut(BedParametersResult data,
234 ArtifactAndFacet aandf, Document theme, boolean visible) {
235 logger.debug("BedQuality.doPorosityTopLayerOut");
236
237 XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
238
239 StyledSeriesBuilder.addPoints(series, data.getPorosityCapData(),
240 true);
241
242 addAxisSeries(series, YAXIS.P.idx, visible);
243 }
244
245 protected void doPorositySubLayerOut(BedParametersResult data,
246 ArtifactAndFacet aandf, Document theme, boolean visible) {
247 logger.debug("BedQuality.doPorositySubLayerOut");
248
249 XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
250
251 StyledSeriesBuilder.addPoints(series, data.getPorositySubData(),
252 true);
253
254 addAxisSeries(series, YAXIS.P.idx, visible);
255 }
256
257 protected void doDensityTopLayerOut(BedParametersResult data,
258 ArtifactAndFacet aandf, Document theme, boolean visible) {
259 logger.debug("BedQuality.doDensityOut");
260
261 XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
262
263 StyledSeriesBuilder.addPoints(series, data.getDensityCapData(),
264 true);
265
266 addAxisSeries(series, YAXIS.D.idx, visible);
267 }
268
269 protected void doDensitySubLayerOut(BedParametersResult data,
270 ArtifactAndFacet aandf, Document theme, boolean visible) {
271 logger.debug("BedQuality.doDensityOut");
272
273 XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
274
275 StyledSeriesBuilder.addPoints(series, data.getDensitySubData(),
276 true);
277
278 addAxisSeries(series, YAXIS.D.idx, visible);
279 }
280 }
281 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org