Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/minfo/SedimentLoadLSGenerator.java @ 4374:e596b2cc9f38
Added chart generator for sediment load output.
The generator builds a longitudinal section chart containing sediment loads.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Fri, 02 Nov 2012 14:58:51 +0100 |
parents | |
children | 532272d9f2e0 |
comparison
equal
deleted
inserted
replaced
4373:1fb224bb2c6b | 4374:e596b2cc9f38 |
---|---|
1 package de.intevation.flys.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 de.intevation.artifactdatabase.state.ArtifactAndFacet; | |
8 import de.intevation.artifactdatabase.state.Facet; | |
9 import de.intevation.flys.artifacts.model.FacetTypes; | |
10 import de.intevation.flys.artifacts.model.minfo.SedimentLoadResult; | |
11 import de.intevation.flys.exports.StyledSeriesBuilder; | |
12 import de.intevation.flys.exports.XYChartGenerator; | |
13 import de.intevation.flys.jfree.FLYSAnnotation; | |
14 import de.intevation.flys.jfree.StyledXYSeries; | |
15 | |
16 | |
17 public class SedimentLoadLSGenerator | |
18 extends XYChartGenerator | |
19 implements FacetTypes | |
20 { | |
21 public enum YAXIS { | |
22 L(0); | |
23 | |
24 protected int idx; | |
25 | |
26 private YAXIS(int c) { | |
27 idx = c; | |
28 } | |
29 } | |
30 /** The logger that is used in this generator. */ | |
31 private static Logger logger = Logger.getLogger(BedQualityGenerator.class); | |
32 | |
33 public static final String I18N_CHART_TITLE = "chart.beddifference.epoch.title"; | |
34 public static final String I18N_XAXIS_LABEL = "chart.beddifference.xaxis.label"; | |
35 public static final String I18N_YAXIS_LABEL = "chart.beddifference.yaxis.label.diff"; | |
36 public static final String I18N_SECOND_YAXIS_LABEL = "chart.beddifference.yaxis.label.height"; | |
37 | |
38 public static final String I18N_CHART_TITLE_DEFAULT = "Sohlenhöhen Differenz"; | |
39 public static final String I18N_XAXIS_LABEL_DEFAULT = "Fluss-Km"; | |
40 public static final String I18N_YAXIS_LABEL_DEFAULT = "delta S [m]"; | |
41 public static final String I18N_SECOND_YAXIS_LABEL_DEFAULT = "Höhe [m]"; | |
42 | |
43 @Override | |
44 protected YAxisWalker getYAxisWalker() { | |
45 return new YAxisWalker() { | |
46 | |
47 @Override | |
48 public int length() { | |
49 return YAXIS.values().length; | |
50 } | |
51 | |
52 @Override | |
53 public String getId(int idx) { | |
54 YAXIS[] yaxes = YAXIS.values(); | |
55 return yaxes[idx].toString(); | |
56 } | |
57 }; | |
58 } | |
59 | |
60 @Override | |
61 public void doOut(ArtifactAndFacet bundle, Document attr, boolean visible) { | |
62 String name = bundle.getFacetName(); | |
63 | |
64 logger.debug("doOut: " + name); | |
65 | |
66 if (name == null) { | |
67 logger.error("No facet name for doOut(). No output generated!"); | |
68 return; | |
69 } | |
70 | |
71 Facet facet = bundle.getFacet(); | |
72 | |
73 if (facet == null) { | |
74 return; | |
75 } | |
76 | |
77 if (name.equals(SEDIMENT_LOAD_COARSE)) { | |
78 doSedimentLoadCoarseOut( | |
79 (SedimentLoadResult) bundle.getData(context), | |
80 bundle, | |
81 attr, | |
82 visible); | |
83 } | |
84 else if (name.equals(SEDIMENT_LOAD_SAND)) { | |
85 doSedimentLoadSandOut( | |
86 (SedimentLoadResult) bundle.getData(context), | |
87 bundle, | |
88 attr, | |
89 visible); | |
90 } | |
91 else if (name.equals(SEDIMENT_LOAD_FINEMIDDLE)) { | |
92 doSedimentLoadFineMiddleOut( | |
93 (SedimentLoadResult) bundle.getData(context), | |
94 bundle, | |
95 attr, | |
96 visible); | |
97 } | |
98 else if (name.equals(SEDIMENT_LOAD_SUSP_SAND)) { | |
99 doSedimentLoadSandOut( | |
100 (SedimentLoadResult) bundle.getData(context), | |
101 bundle, | |
102 attr, | |
103 visible); | |
104 } | |
105 else if (name.equals(SEDIMENT_LOAD_SUSP_SAND_BED)) { | |
106 doSedimentLoadSuspSandBedOut( | |
107 (SedimentLoadResult) bundle.getData(context), | |
108 bundle, | |
109 attr, | |
110 visible); | |
111 } | |
112 else if (name.equals(SEDIMENT_LOAD_SUSP_SEDIMENT)) { | |
113 doSedimentLoadSuspSedimentOut( | |
114 (SedimentLoadResult) bundle.getData(context), | |
115 bundle, | |
116 attr, | |
117 visible); | |
118 } | |
119 else if (name.equals(SEDIMENT_LOAD_TOTAL)) { | |
120 doSedimentLoadTotalOut( | |
121 (SedimentLoadResult) bundle.getData(context), | |
122 bundle, | |
123 attr, | |
124 visible); | |
125 } | |
126 else if (name.equals(LONGITUDINAL_ANNOTATION)) { | |
127 doAnnotations( | |
128 (FLYSAnnotation) bundle.getData(context), | |
129 bundle, | |
130 attr, | |
131 visible); | |
132 } | |
133 } | |
134 | |
135 @Override | |
136 protected String getDefaultChartTitle() { | |
137 return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); | |
138 } | |
139 | |
140 @Override | |
141 protected String getDefaultXAxisLabel() { | |
142 return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT); | |
143 } | |
144 | |
145 @Override | |
146 protected String getDefaultYAxisLabel(int pos) { | |
147 String label = "default"; | |
148 if (pos == YAXIS.L.idx) { | |
149 label = msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT); | |
150 } | |
151 return label; | |
152 } | |
153 | |
154 protected void doSedimentLoadCoarseOut(SedimentLoadResult data, | |
155 ArtifactAndFacet aandf, Document theme, boolean visible) { | |
156 | |
157 XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme); | |
158 StyledSeriesBuilder.addPoints(series, data.getCoarseData(), true); | |
159 | |
160 addAxisSeries(series, YAXIS.L.idx, visible); | |
161 } | |
162 | |
163 protected void doSedimentLoadSandOut(SedimentLoadResult data, | |
164 ArtifactAndFacet aandf, Document theme, boolean visible) { | |
165 | |
166 XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme); | |
167 StyledSeriesBuilder.addPoints(series, data.getSandData(), true); | |
168 | |
169 addAxisSeries(series, YAXIS.L.idx, visible); | |
170 } | |
171 | |
172 protected void doSedimentLoadFineMiddleOut(SedimentLoadResult data, | |
173 ArtifactAndFacet aandf, Document theme, boolean visible) { | |
174 | |
175 XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme); | |
176 StyledSeriesBuilder.addPoints(series, data.getFineMiddleData(), true); | |
177 | |
178 addAxisSeries(series, YAXIS.L.idx, visible); | |
179 } | |
180 | |
181 protected void doSedimentLoadSuspSandOut(SedimentLoadResult data, | |
182 ArtifactAndFacet aandf, Document theme, boolean visible) { | |
183 | |
184 XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme); | |
185 StyledSeriesBuilder.addPoints(series, data.getSuspSandData(), true); | |
186 | |
187 addAxisSeries(series, YAXIS.L.idx, visible); | |
188 } | |
189 | |
190 protected void doSedimentLoadSuspSandBedOut(SedimentLoadResult data, | |
191 ArtifactAndFacet aandf, Document theme, boolean visible) { | |
192 | |
193 XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme); | |
194 StyledSeriesBuilder.addPoints(series, data.getSuspSandBedData(), true); | |
195 | |
196 addAxisSeries(series, YAXIS.L.idx, visible); | |
197 } | |
198 | |
199 protected void doSedimentLoadSuspSedimentOut(SedimentLoadResult data, | |
200 ArtifactAndFacet aandf, Document theme, boolean visible) { | |
201 | |
202 XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme); | |
203 StyledSeriesBuilder.addPoints(series, data.getSuspSedimentData(), true); | |
204 | |
205 addAxisSeries(series, YAXIS.L.idx, visible); | |
206 } | |
207 | |
208 protected void doSedimentLoadTotalOut(SedimentLoadResult data, | |
209 ArtifactAndFacet aandf, Document theme, boolean visible) { | |
210 | |
211 XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme); | |
212 StyledSeriesBuilder.addPoints(series, data.getTotalData(), true); | |
213 | |
214 addAxisSeries(series, YAXIS.L.idx, visible); | |
215 } | |
216 | |
217 } |