comparison flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionGenerator.java @ 403:1ed48e2ddc1b

Added an OutGenerator to create discharge longitudinal section charts. flys-artifacts/trunk@1844 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 06 May 2011 14:20:26 +0000
parents
children a0afdda4d4b9
comparison
equal deleted inserted replaced
402:eb22ffe4d74c 403:1ed48e2ddc1b
1 package de.intevation.flys.exports;
2
3 import org.apache.log4j.Logger;
4
5 import org.jfree.data.xy.XYSeries;
6
7 import org.w3c.dom.Document;
8
9 import de.intevation.artifacts.Artifact;
10
11 import de.intevation.flys.artifacts.WINFOArtifact;
12 import de.intevation.flys.artifacts.model.WQCKms;
13 import de.intevation.flys.artifacts.model.WQKms;
14
15
16 /**
17 * An OutGenerator that generates discharge longitudinal section curves.
18 *
19 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
20 */
21 public class DischargeLongitudinalSectionGenerator
22 extends LongitudinalSectionGenerator
23 {
24 private static Logger logger =
25 Logger.getLogger(DischargeLongitudinalSectionGenerator.class);
26
27
28 /** The facet for Ws.*/
29 public static final String FACET_W = "discharge_longitudinal_section.w";
30
31 /** The facet for Qs.*/
32 public static final String FACET_Q = "discharge_longitudinal_section.q";
33
34
35
36 @Override
37 public void doOut(Artifact artifact, String facet, Document attr) {
38 logger.debug("DischargeLongitudinalSectionGenerator.doOut");
39
40 if (facet != null && facet.equals(FACET_W)) {
41 doWOut(getDischargeLongitudinalSectionData(artifact));
42 }
43 else if (facet != null && facet.equals(FACET_Q)) {
44 doQOut(getDischargeLongitudinalSectionData(artifact));
45 }
46 else {
47 logger.warn("Unknown facet name: " + facet);
48 return;
49 }
50 }
51
52
53 protected WQKms[] getDischargeLongitudinalSectionData(Artifact artifact) {
54 WINFOArtifact winfoArtifact = (WINFOArtifact) artifact;
55 return winfoArtifact.getDischargeLongitudinalSectionData();
56 }
57
58
59 /**
60 * This method adds new Series for the wqkms objects. If there are instances
61 * of WQCKms in this array, there is a further curve that displays the
62 * corrected W values.
63 *
64 * @param wqkms An array of WQKms objects to be displayed.
65 */
66 protected void doWOut(WQKms[] wqkms) {
67 logger.debug("LongitudinalSectionGenerator.doWOut");
68
69 int idx = 0;
70 for (WQKms tmp: wqkms) {
71 if (tmp instanceof WQCKms) {
72 doCorrectedWOut((WQCKms) tmp);
73 }
74
75 doWOut(tmp);
76 }
77 }
78
79
80 /**
81 * Adds a new series for the W curve.
82 *
83 * @param wqkms The object that contains the W values.
84 */
85 protected void doWOut(WQKms wqkms) {
86 logger.debug("DischargeLongitudinalSectionGenerator.doWOut");
87
88 // TODO CREATE CORRECT SERIES NAME
89 XYSeries series = new XYSeries("W");
90
91 double[] target = new double[4];
92 int size = wqkms.size();
93
94 for (int i = 0; i < size; i++) {
95 target = wqkms.get(i, target);
96
97 series.add(target[2], target[0]);
98 }
99
100 w.addSeries(series);
101 }
102
103
104 /**
105 * Adds a new series for the corrected W curve.
106 *
107 * @param wqckms The object that contains the corrected W values.
108 */
109 protected void doCorrectedWOut(WQCKms wqckms) {
110 logger.debug("DischargeLongitudinalSectionGenerator.doCorrectedWOut");
111
112 // TODO CREATE CORRECT SERIES NAME
113 XYSeries series = new XYSeries("Korrigiert");
114
115 double[] target = new double[4];
116 int size = wqckms.size();
117
118 for (int i = 0; i < size; i++) {
119 target = wqckms.get(i, target);
120
121 series.add(target[2], target[3]);
122 }
123
124 if (series.getItemCount() > 0) {
125 w.addSeries(series);
126 }
127 }
128 }
129 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org