comparison flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionGenerator.java @ 696:708b270dfd30 facets-slt

OutGenerators use now facets to fetch necessary data. flys-artifacts/branches/facets-slt@2140 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 17 Jun 2011 09:19:43 +0000
parents 45cd58a2a2bb
children 035c0095b427
comparison
equal deleted inserted replaced
695:45cd58a2a2bb 696:708b270dfd30
14 14
15 import de.intevation.artifacts.Artifact; 15 import de.intevation.artifacts.Artifact;
16 16
17 import de.intevation.artifactdatabase.state.Facet; 17 import de.intevation.artifactdatabase.state.Facet;
18 18
19 import de.intevation.flys.artifacts.WINFOArtifact; 19 import de.intevation.flys.artifacts.FLYSArtifact;
20 import de.intevation.flys.artifacts.model.WQCKms; 20 import de.intevation.flys.artifacts.model.WQCKms;
21 import de.intevation.flys.artifacts.model.WQKms; 21 import de.intevation.flys.artifacts.model.WQKms;
22 22
23 23
24 /** 24 /**
29 public class DischargeLongitudinalSectionGenerator 29 public class DischargeLongitudinalSectionGenerator
30 extends LongitudinalSectionGenerator 30 extends LongitudinalSectionGenerator
31 { 31 {
32 private static Logger logger = 32 private static Logger logger =
33 Logger.getLogger(DischargeLongitudinalSectionGenerator.class); 33 Logger.getLogger(DischargeLongitudinalSectionGenerator.class);
34
35
36 /** The facet for Ws.*/
37 public static final String FACET_W = "discharge_longitudinal_section.w";
38
39 /** The facet for Qs.*/
40 public static final String FACET_Q = "discharge_longitudinal_section.q";
41 34
42 35
43 /** The storage for the corrected W series to be drawn in this chart.*/ 36 /** The storage for the corrected W series to be drawn in this chart.*/
44 protected XYSeriesCollection cw; 37 protected XYSeriesCollection cw;
45 38
95 88
96 @Override 89 @Override
97 public void doOut(Artifact artifact, Facet facet, Document attr) { 90 public void doOut(Artifact artifact, Facet facet, Document attr) {
98 logger.debug("DischargeLongitudinalSectionGenerator.doOut"); 91 logger.debug("DischargeLongitudinalSectionGenerator.doOut");
99 92
100 if (facet != null && facet.equals(FACET_W)) { 93 String name = facet != null ? facet.getName() : null;
101 doWOut(getDischargeLongitudinalSectionData(artifact)); 94
95 FLYSArtifact flys = (FLYSArtifact) artifact;
96 Facet f = flys.getNativeFacet(facet);
97
98 if (name != null && name.equals(DISCHARGE_LONGITUDINAL_W)) {
99 doWOut((WQKms) f.getData(artifact, context));
102 } 100 }
103 else if (facet != null && facet.equals(FACET_Q)) { 101 else if (name != null && name.equals(DISCHARGE_LONGITUDINAL_Q)) {
104 doQOut(getDischargeLongitudinalSectionData(artifact)); 102 doQOut((WQKms) f.getData(artifact, context));
103 }
104 else if (name != null && name.equals(DISCHARGE_LONGITUDINAL_C)) {
105 doCorrectedWOut((WQCKms) f.getData(artifact, context));
105 } 106 }
106 else { 107 else {
107 logger.warn("Unknown facet name: " + facet); 108 logger.warn("Unknown facet name: " + name);
108 return; 109 return;
109 } 110 }
110 }
111
112
113 protected WQKms[] getDischargeLongitudinalSectionData(Artifact artifact) {
114 WINFOArtifact winfoArtifact = (WINFOArtifact) artifact;
115 return winfoArtifact.getDischargeLongitudinalSectionData();
116 }
117
118
119 /**
120 * This method adds new Series for the wqkms objects. If there are instances
121 * of WQCKms in this array, there is a further curve that displays the
122 * corrected W values.
123 *
124 * @param wqkms An array of WQKms objects to be displayed.
125 */
126 protected void doWOut(WQKms[] wqkms) {
127 logger.debug("LongitudinalSectionGenerator.doWOut");
128
129 int idx = 0;
130 for (WQKms tmp: wqkms) {
131 if (tmp instanceof WQCKms) {
132 doCorrectedWOut((WQCKms) tmp);
133 }
134
135 doWOut(tmp);
136 }
137 }
138
139
140 /**
141 * Adds a new series for the W curve.
142 *
143 * @param wqkms The object that contains the W values.
144 */
145 protected void doWOut(WQKms wqkms) {
146 logger.debug("DischargeLongitudinalSectionGenerator.doWOut");
147
148 XYSeries series = new XYSeries(getSeriesName(wqkms, "W"));
149
150 double[] target = new double[4];
151 int size = wqkms.size();
152
153 for (int i = 0; i < size; i++) {
154 target = wqkms.get(i, target);
155
156 series.add(target[2], target[0]);
157 }
158
159 w.addSeries(series);
160 } 111 }
161 112
162 113
163 /** 114 /**
164 * Adds a new series for the corrected W curve. 115 * Adds a new series for the corrected W curve.

http://dive4elements.wald.intevation.org