comparison flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java @ 1769:bbe12d77710d

Prepare rendering of added other (static) WKms and Differences in LongitudinalSection Diagrams. flys-artifacts/trunk@3090 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 26 Oct 2011 12:54:22 +0000
parents 62983d0ced51
children 205eb6f124a5
comparison
equal deleted inserted replaced
1768:41ba2276d785 1769:bbe12d77710d
19 import de.intevation.artifactdatabase.state.Facet; 19 import de.intevation.artifactdatabase.state.Facet;
20 20
21 import de.intevation.flys.artifacts.FLYSArtifact; 21 import de.intevation.flys.artifacts.FLYSArtifact;
22 22
23 import de.intevation.flys.artifacts.model.FacetTypes; 23 import de.intevation.flys.artifacts.model.FacetTypes;
24 import de.intevation.flys.artifacts.model.WKms;
24 import de.intevation.flys.artifacts.model.WQKms; 25 import de.intevation.flys.artifacts.model.WQKms;
25 26
26 import de.intevation.flys.jfree.FLYSAnnotation; 27 import de.intevation.flys.jfree.FLYSAnnotation;
27 28
28 import de.intevation.flys.utils.FLYSUtils; 29 import de.intevation.flys.utils.FLYSUtils;
202 * Create a range that includes 0 (for the Q axis). 203 * Create a range that includes 0 (for the Q axis).
203 * @param range range with which to look up upper bound. 204 * @param range range with which to look up upper bound.
204 * @return range with 0 included. 205 * @return range with 0 included.
205 */ 206 */
206 protected Range createSecondAxisRange(Range range) { 207 protected Range createSecondAxisRange(Range range) {
207 return new Range(0d, range.getUpperBound()); 208 if (range == null) {
209 return null;
210 }
211 return new Range(0d, range.getUpperBound());
208 } 212 }
209 213
210 214
211 /** 215 /**
212 * This method overrides the XYChartGenerators zoomY method to be able to 216 * This method overrides the XYChartGenerators zoomY method to be able to
237 xaxis.setInverted(true); 241 xaxis.setInverted(true);
238 } 242 }
239 } 243 }
240 244
241 245
246 /**
247 * Produce output.
248 * @param facet current facet.
249 * @param attr theme for facet
250 */
242 public void doOut( 251 public void doOut(
243 Artifact artifact, 252 Artifact artifact,
244 Facet facet, 253 Facet facet,
245 Document attr, 254 Document attr,
246 boolean visible 255 boolean visible
267 else if (name.equals(LONGITUDINAL_Q)) { 276 else if (name.equals(LONGITUDINAL_Q)) {
268 doQOut((WQKms) f.getData(artifact, context), facet, attr, visible); 277 doQOut((WQKms) f.getData(artifact, context), facet, attr, visible);
269 } 278 }
270 else if (name.equals(LONGITUDINAL_ANNOTATION)) { 279 else if (name.equals(LONGITUDINAL_ANNOTATION)) {
271 doAnnotationsOut(f.getData(artifact, context), facet, attr, visible); 280 doAnnotationsOut(f.getData(artifact, context), facet, attr, visible);
281 }
282 // TODO -> type, and merge with WDifferencesCurveGenerator
283 else if (name.equals("other.wkms")) {
284 doWOut((WKms) f.getData(artifact, context), facet, attr, visible);
285 }
286 else if (name.equals(W_DIFFERENCES)) {
287 doWDifferencesOut(
288 (WKms) f.getData(artifact, context),
289 facet,
290 attr,
291 visible);
272 } 292 }
273 else { 293 else {
274 logger.warn("Unknown facet name: " + name); 294 logger.warn("Unknown facet name: " + name);
275 return; 295 return;
276 } 296 }
313 * data. 333 * data.
314 * @param theme The theme that contains styling information. 334 * @param theme The theme that contains styling information.
315 * @param visible The visibility of the curve. 335 * @param visible The visibility of the curve.
316 */ 336 */
317 protected void doWOut( 337 protected void doWOut(
318 WQKms wqkms, 338 WKms wkms,
319 Facet facet, 339 Facet facet,
320 Document theme, 340 Document theme,
321 boolean visible 341 boolean visible
322 ) { 342 ) {
323 logger.debug("LongitudinalSectionGenerator.doWOut"); 343 logger.debug("LongitudinalSectionGenerator.doWOut");
324 344
325 XYSeries series = new StyledXYSeries(facet.getDescription(), theme); 345 XYSeries series = new StyledXYSeries(facet.getDescription(), theme);
326 346
327 int size = wqkms.size(); 347 int size = wkms.size();
328 348
329 for (int i = 0; i < size; i++) { 349 for (int i = 0; i < size; i++) {
330 series.add(wqkms.getKm(i), wqkms.getW(i), false); 350 series.add(wkms.getKm(i), wkms.getW(i), false);
331 } 351 }
332 352
333 addFirstAxisSeries(series, visible); 353 addFirstAxisSeries(series, visible);
334 354
335 if (needInvertAxis(wqkms)) { 355 if (wkms instanceof WQKms) {
356 if (needInvertAxis((WQKms) wkms)) {
357 setInverted(true);
358 }
359 }
360 }
361
362
363 /**
364 * Add items to dataseries which describes the differences.
365 */
366 protected void doWDifferencesOut(
367 WKms wkms,
368 Facet facet,
369 Document theme,
370 boolean visible
371 ) {
372 logger.debug("WDifferencesCurveGenerator.doWDifferencesOut");
373 if (wkms == null) {
374 logger.warn("No data to add to WDifferencesChart.");
375 return;
376 }
377
378 int size = wkms.size();
379 XYSeries series = new StyledXYSeries(facet.getDescription(), theme);
380
381 if (logger.isDebugEnabled()) {
382 if (wkms.size() > 0) {
383 logger.debug("Generate series: " + series.getKey());
384 logger.debug("Start km: " + wkms.getKm(0));
385 logger.debug("End km: " + wkms.getKm(size-1));
386 logger.debug("Values : " + size);
387 }
388 }
389
390 for (int i = 0; i < size; i++) {
391 series.add(wkms.getKm(i), wkms.getW(i));
392 }
393
394 addSecondAxisSeries(series, visible);
395 if (DataUtil.guessWaterIncreasing(wkms.allWs())) {
336 setInverted(true); 396 setInverted(true);
337 } 397 }
338 } 398 }
399
339 400
340 401
341 /** 402 /**
342 * Process the output for Q facets in a longitudinal section curve. 403 * Process the output for Q facets in a longitudinal section curve.
343 * 404 *

http://dive4elements.wald.intevation.org