comparison flys-artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDifferenceEpochGenerator.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/BedDifferenceEpochGenerator.java@aa06e25528ae
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.FLYSArtifact;
10 import org.dive4elements.river.artifacts.access.FlowVelocityAccess;
11 import org.dive4elements.river.artifacts.model.FacetTypes;
12 import org.dive4elements.river.artifacts.model.WKms;
13 import org.dive4elements.river.artifacts.model.minfo.BedDiffEpochResult;
14 import org.dive4elements.river.exports.StyledSeriesBuilder;
15 import org.dive4elements.river.exports.fixings.FixChartGenerator;
16 import org.dive4elements.river.exports.process.KMIndexProcessor;
17 import org.dive4elements.river.exports.process.Processor;
18 import org.dive4elements.river.exports.process.WOutProcessor;
19 import org.dive4elements.river.jfree.Bounds;
20 import org.dive4elements.river.jfree.DoubleBounds;
21 import org.dive4elements.river.jfree.FLYSAnnotation;
22 import org.dive4elements.river.jfree.StyledXYSeries;
23 import org.dive4elements.river.utils.DataUtil;
24
25
26 public class BedDifferenceEpochGenerator
27 extends FixChartGenerator
28 implements FacetTypes
29 {
30 public enum YAXIS {
31 D(0), H(1), dW(2), W(3);
32
33 protected int idx;
34
35 private YAXIS(int c) {
36 idx = c;
37 }
38 }
39
40 /** The logger that is used in this generator. */
41 private static Logger logger = Logger.getLogger(BedQualityGenerator.class);
42
43 public static final String I18N_CHART_TITLE = "chart.beddifference.epoch.title";
44 public static final String I18N_XAXIS_LABEL = "chart.beddifference.xaxis.label";
45 public static final String I18N_YAXIS_LABEL = "chart.beddifference.yaxis.label.diff";
46 public static final String I18N_SECOND_YAXIS_LABEL = "chart.beddifference.yaxis.label.height";
47
48 public static final String I18N_CHART_TITLE_DEFAULT = "Sohlenhöhen Differenz";
49 public static final String I18N_XAXIS_LABEL_DEFAULT = "Fluss-Km";
50 public static final String I18N_YAXIS_LABEL_DEFAULT = "delta S [m]";
51 public static final String I18N_SECOND_YAXIS_LABEL_DEFAULT = "Höhe [m]";
52 public static final String I18N_DW_YAXIS_LABEL_DEFAULT =
53 "delta W [cm]";
54 public static final String I18N_DW_YAXIS_LABEL =
55 "chart.fixings.longitudinalsection.yaxis.label";
56
57 private static final String I18N_W_YAXIS_LABEL =
58 "chart.longitudinal.section.yaxis.label";
59 private static final String I18N_W_YAXIS_LABEL_DEFAULT = "W [NN + m]";
60
61
62 @Override
63 protected YAxisWalker getYAxisWalker() {
64 return new YAxisWalker() {
65
66 @Override
67 public int length() {
68 return YAXIS.values().length;
69 }
70
71 @Override
72 public String getId(int idx) {
73 YAXIS[] yaxes = YAXIS.values();
74 return yaxes[idx].toString();
75 }
76 };
77 }
78
79 @Override
80 public void doOut(ArtifactAndFacet bundle, Document attr, boolean visible) {
81 String name = bundle.getFacetName();
82
83 logger.debug("doOut: " + name);
84
85 if (name == null) {
86 logger.error("No facet name for doOut(). No output generated!");
87 return;
88 }
89
90 Facet facet = bundle.getFacet();
91
92 if (facet == null) {
93 return;
94 }
95
96 if (getXBounds(0) != null && getDomainAxisRange() != null) {
97 Bounds bounds =
98 calculateZoom(getXBounds(0), getDomainAxisRange());
99 context.putContextValue("startkm", bounds.getLower());
100 context.putContextValue("endkm", bounds.getUpper());
101 }
102 else if (getXBounds(0) != null && getDomainAxisRange() == null) {
103 context.putContextValue("startkm", getXBounds(0).getLower());
104 context.putContextValue("endkm", getXBounds(0).getUpper());
105 }
106 else if (getXBounds(0) == null && getDomainAxisRange() == null) {
107 FLYSArtifact artifact = (FLYSArtifact)bundle.getArtifact();
108 FlowVelocityAccess access = new FlowVelocityAccess(artifact, context);
109 context.putContextValue("startkm", access.getLowerKM());
110 context.putContextValue("endkm", access.getUpperKM());
111 }
112 else if (getXBounds(0) == null && getDomainAxisRange() != null){
113 FLYSArtifact artifact = (FLYSArtifact)bundle.getArtifact();
114 FlowVelocityAccess access = new FlowVelocityAccess(artifact, context);
115 Bounds b = new DoubleBounds(access.getLowerKM(), access.getUpperKM());
116 Bounds bounds =
117 calculateZoom(b, getDomainAxisRange());
118 context.putContextValue("startkm", bounds.getLower());
119 context.putContextValue("endkm", bounds.getUpper());
120 }
121 Processor processor = new KMIndexProcessor();
122 Processor woutp = new WOutProcessor();
123 if (name.equals(BED_DIFFERENCE_EPOCH)) {
124 doBedDifferenceEpochOut(
125 (BedDiffEpochResult) bundle.getData(context),
126 bundle, attr, visible);
127 }
128 else if (name.equals(BED_DIFFERENCE_EPOCH_HEIGHT1)) {
129 doBedDifferenceHeightsOut((BedDiffEpochResult)bundle.getData(context),
130 bundle, attr, visible, 0);
131 }
132 else if (name.equals(BED_DIFFERENCE_EPOCH_HEIGHT2)) {
133 doBedDifferenceHeightsOut((BedDiffEpochResult)bundle.getData(context),
134 bundle, attr, visible, 1);
135 }
136 else if (name.equals(BED_DIFFERENCE_EPOCH_FILTERED)) {
137 doBedDifferenceEpochOut(
138 (BedDiffEpochResult) bundle.getData(context),
139 bundle, attr, visible);
140 }
141 else if (name.equals(BED_DIFFERENCE_EPOCH_HEIGHT1_FILTERED)) {
142 doBedDifferenceHeightsOut((BedDiffEpochResult)bundle.getData(context),
143 bundle, attr, visible, 0);
144 }
145 else if (name.equals(BED_DIFFERENCE_EPOCH_HEIGHT2_FILTERED)) {
146 doBedDifferenceHeightsOut((BedDiffEpochResult)bundle.getData(context),
147 bundle, attr, visible, 1);
148 }
149 else if (processor.canHandle(name)) {
150 processor.doOut(this, bundle, attr, visible, YAXIS.dW.idx);
151 }
152 else if (woutp.canHandle(name)) {
153 woutp.doOut(this, bundle, attr, visible, YAXIS.W.idx);
154 }
155 else if (name.equals(W_DIFFERENCES)) {
156 doWDifferencesOut(
157 (WKms) bundle.getData(context),
158 bundle,
159 attr,
160 visible);
161 }
162 else if (name.equals(LONGITUDINAL_ANNOTATION)) {
163 doAnnotations(
164 (FLYSAnnotation) bundle.getData(context),
165 bundle,
166 attr,
167 visible);
168 }
169 else {
170 logger.warn("Unknown facet name " + name);
171 }
172 }
173
174 @Override
175 protected String getDefaultChartTitle() {
176 return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT);
177 }
178
179 @Override
180 protected String getDefaultXAxisLabel() {
181 return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT);
182 }
183
184 @Override
185 protected String getDefaultYAxisLabel(int pos) {
186 String label = "default";
187 if (pos == YAXIS.D.idx) {
188 label = msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT);
189 }
190 else if (pos == YAXIS.H.idx) {
191 label = msg(I18N_SECOND_YAXIS_LABEL, I18N_SECOND_YAXIS_LABEL_DEFAULT);
192 }
193 else if (pos == YAXIS.dW.idx) {
194 return msg(I18N_DW_YAXIS_LABEL, I18N_DW_YAXIS_LABEL_DEFAULT);
195 }
196 else if (pos == YAXIS.W.idx) {
197 return msg(I18N_W_YAXIS_LABEL, I18N_W_YAXIS_LABEL_DEFAULT);
198 }
199 return label;
200 }
201
202 protected void doBedDifferenceEpochOut(BedDiffEpochResult data,
203 ArtifactAndFacet aandf, Document theme, boolean visible) {
204
205 XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
206 StyledSeriesBuilder.addPoints(series, data.getDifferencesData(), true);
207
208 addAxisSeries(series, YAXIS.D.idx, visible);
209 }
210
211 private void doBedDifferenceHeightsOut(
212 BedDiffEpochResult data,
213 ArtifactAndFacet bundle,
214 Document attr,
215 boolean visible,
216 int idx) {
217 logger.debug("doBedDifferenceHeightOut()");
218
219 XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), attr);
220 if (idx == 0) {
221 StyledSeriesBuilder.addPoints(series, data.getHeights1Data(), true);
222 }
223 else {
224 StyledSeriesBuilder.addPoints(series, data.getHeights2Data(), true);
225 }
226
227 addAxisSeries(series, YAXIS.H.idx, visible);
228 }
229
230 protected void doWDifferencesOut(
231 WKms wkms,
232 ArtifactAndFacet aandf,
233 Document theme,
234 boolean visible
235 ) {
236 if (wkms == null) {
237 logger.warn("No data to add to WDifferencesChart.");
238 return;
239 }
240
241 XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
242 StyledSeriesBuilder.addPoints(series, wkms);
243
244 addAxisSeries(series, YAXIS.D.idx, visible);
245 if (DataUtil.guessWaterIncreasing(wkms.allWs())) {
246 setInverted(true);
247 }
248 }
249 }

http://dive4elements.wald.intevation.org