Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/states/DischargeLongitudinalSection.java @ 5838:5aa05a7a34b7
Rename modules to more fitting names.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 15:23:37 +0200 |
parents | flys-artifacts/src/main/java/org/dive4elements/river/artifacts/states/DischargeLongitudinalSection.java@bd047b71ab37 |
children | 4897a58c8746 |
comparison
equal
deleted
inserted
replaced
5837:d9901a08d0a6 | 5838:5aa05a7a34b7 |
---|---|
1 package org.dive4elements.river.artifacts.states; | |
2 | |
3 import org.dive4elements.artifactdatabase.state.Facet; | |
4 import org.dive4elements.artifactdatabase.state.FacetActivity; | |
5 | |
6 import org.dive4elements.artifacts.Artifact; | |
7 import org.dive4elements.artifacts.CallContext; | |
8 | |
9 import org.dive4elements.river.artifacts.ChartArtifact; | |
10 import org.dive4elements.river.artifacts.FLYSArtifact; | |
11 | |
12 import org.dive4elements.river.artifacts.access.Calculation4Access; | |
13 | |
14 import org.dive4elements.river.artifacts.model.Calculation4; | |
15 import org.dive4elements.river.artifacts.model.CalculationResult; | |
16 import org.dive4elements.river.artifacts.model.ConstantWQKms; | |
17 import org.dive4elements.river.artifacts.model.CrossSectionWaterLineFacet; | |
18 import org.dive4elements.river.artifacts.model.DataFacet; | |
19 import org.dive4elements.river.artifacts.model.EmptyFacet; | |
20 import org.dive4elements.river.artifacts.model.FacetTypes; | |
21 import org.dive4elements.river.artifacts.model.ReportFacet; | |
22 import org.dive4elements.river.artifacts.model.WQCKms; | |
23 import org.dive4elements.river.artifacts.model.WQKms; | |
24 import org.dive4elements.river.artifacts.model.WaterlevelFacet; | |
25 | |
26 import java.util.List; | |
27 | |
28 import org.apache.log4j.Logger; | |
29 | |
30 public class DischargeLongitudinalSection | |
31 extends DefaultState | |
32 implements FacetTypes | |
33 { | |
34 private static Logger log = | |
35 Logger.getLogger(DischargeLongitudinalSection.class); | |
36 | |
37 static { | |
38 // Active/deactivate facets. | |
39 FacetActivity.Registry.getInstance().register( | |
40 "winfo", | |
41 new FacetActivity() { | |
42 @Override | |
43 public Boolean isInitialActive( | |
44 Artifact artifact, | |
45 Facet facet, | |
46 String output | |
47 ) { | |
48 String name = facet.getName(); | |
49 if (name.equals(DISCHARGE_LONGITUDINAL_Q_INFOLD_CUT)) { | |
50 return Boolean.FALSE; | |
51 } | |
52 return Boolean.TRUE; | |
53 } | |
54 }); | |
55 } | |
56 | |
57 @Override | |
58 public Object computeAdvance( | |
59 FLYSArtifact artifact, | |
60 String hash, | |
61 CallContext context, | |
62 List<Facet> facets, | |
63 Object old | |
64 ) { | |
65 if (artifact instanceof ChartArtifact) { | |
66 ChartArtifact chart = (ChartArtifact)artifact; | |
67 facets.add(new EmptyFacet()); | |
68 return null; | |
69 } | |
70 | |
71 Calculation4Access access = new Calculation4Access(artifact); | |
72 | |
73 CalculationResult res = old instanceof CalculationResult | |
74 ? (CalculationResult)old | |
75 : new Calculation4(access).calculate(); | |
76 | |
77 if (facets == null) { | |
78 return res; | |
79 } | |
80 | |
81 WQKms [] wqkms = (WQKms [])res.getData(); | |
82 | |
83 for (int i = 0; i < wqkms.length; i++) { | |
84 String nameW = null; | |
85 String nameQ = null; | |
86 | |
87 if (access.isQ()) { | |
88 nameQ = wqkms[i].getName(); | |
89 nameW = "W(" + nameQ + ")"; | |
90 } | |
91 else { | |
92 nameW = wqkms[i].getName(); | |
93 nameQ = "Q(" + nameW + ")"; | |
94 } | |
95 | |
96 // Do not generate Waterlevel/Waterline facets | |
97 // for Q only curves. | |
98 if (!(wqkms[i] instanceof ConstantWQKms)) { | |
99 | |
100 Facet w = new WaterlevelFacet( | |
101 i, DISCHARGE_LONGITUDINAL_W, nameW); | |
102 | |
103 Facet s = new CrossSectionWaterLineFacet(i, nameW); | |
104 | |
105 Facet q = new WaterlevelFacet( | |
106 i, DISCHARGE_LONGITUDINAL_Q, nameQ); | |
107 facets.add(s); | |
108 facets.add(w); | |
109 facets.add(q); | |
110 } | |
111 else { | |
112 Facet q; | |
113 if (nameQ.contains("geschnitten")) { | |
114 q = new WaterlevelFacet( | |
115 i, DISCHARGE_LONGITUDINAL_Q_INFOLD_CUT, nameQ); | |
116 } | |
117 else { | |
118 q = new WaterlevelFacet( | |
119 i, DISCHARGE_LONGITUDINAL_Q_INFOLD, nameQ); | |
120 } | |
121 facets.add(q); | |
122 } | |
123 | |
124 if (wqkms[i] instanceof WQCKms) { | |
125 // TODO DO i18n | |
126 | |
127 String nameC = nameW.replace( | |
128 "benutzerdefiniert", | |
129 "benutzerdefiniert [korrigiert]"); | |
130 | |
131 Facet c = new WaterlevelFacet( | |
132 i, DISCHARGE_LONGITUDINAL_C, nameC); | |
133 | |
134 // Here, avoid index clash with Facet "s" above and | |
135 // signal the WINFO later that we want to access Cs. | |
136 Facet r = new CrossSectionWaterLineFacet(i + 1, nameC); | |
137 | |
138 facets.add(c); | |
139 facets.add(r); | |
140 } | |
141 } | |
142 | |
143 if (wqkms.length > 0) { | |
144 facets.add(new DataFacet(CSV, "CSV data")); | |
145 facets.add(new DataFacet(WST, "WST data")); | |
146 } | |
147 | |
148 if (res.getReport().hasProblems()) { | |
149 facets.add(new ReportFacet()); | |
150 } | |
151 | |
152 return res; | |
153 } | |
154 } | |
155 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |