Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DurationCurveState.java @ 3468:f37e7e8907cb
merged flys-artifacts/2.8.1
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:39 +0200 |
parents | 9ea3ac23bd9d |
children | 7887112c37cc |
comparison
equal
deleted
inserted
replaced
3387:5ffad8bde8ad | 3468:f37e7e8907cb |
---|---|
1 package de.intevation.flys.artifacts.states; | |
2 | |
3 import java.util.List; | |
4 | |
5 import org.apache.log4j.Logger; | |
6 | |
7 import de.intevation.artifacts.CallContext; | |
8 | |
9 import de.intevation.artifactdatabase.state.Facet; | |
10 | |
11 import de.intevation.flys.artifacts.FLYSArtifact; | |
12 import de.intevation.flys.artifacts.WINFOArtifact; | |
13 import de.intevation.flys.artifacts.ChartArtifact; | |
14 | |
15 import de.intevation.flys.artifacts.model.DurationCurveFacet; | |
16 import de.intevation.flys.artifacts.model.FacetTypes; | |
17 import de.intevation.flys.artifacts.model.WQDay; | |
18 | |
19 import de.intevation.flys.artifacts.model.DataFacet; | |
20 import de.intevation.flys.artifacts.model.ReportFacet; | |
21 import de.intevation.flys.artifacts.model.EmptyFacet; | |
22 import de.intevation.flys.artifacts.model.CalculationResult; | |
23 | |
24 import de.intevation.flys.artifacts.resources.Resources; | |
25 | |
26 import de.intevation.flys.utils.FLYSUtils; | |
27 | |
28 | |
29 /** | |
30 * The final state that will be reached after the duration curve calculation | |
31 * mode has been chosen. | |
32 * | |
33 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | |
34 */ | |
35 public class DurationCurveState | |
36 extends DefaultState | |
37 implements FacetTypes | |
38 { | |
39 /** The logger that is used in this state. */ | |
40 private static Logger logger = Logger.getLogger(DurationCurveState.class); | |
41 | |
42 public DurationCurveState() { | |
43 } | |
44 | |
45 | |
46 @Override | |
47 public Object computeAdvance( | |
48 FLYSArtifact artifact, | |
49 String hash, | |
50 CallContext context, | |
51 List<Facet> facets, | |
52 Object old | |
53 ) { | |
54 if (artifact instanceof WINFOArtifact) { | |
55 WINFOArtifact winfo = (WINFOArtifact)artifact; | |
56 | |
57 CalculationResult res; | |
58 | |
59 if (old instanceof CalculationResult) { | |
60 res = (CalculationResult)old; | |
61 } | |
62 else { | |
63 res = winfo.getDurationCurveData(); | |
64 } | |
65 | |
66 WQDay wqday = (WQDay)res.getData(); | |
67 | |
68 if (wqday != null && facets != null) { | |
69 // Create an i18ed name for a (w or q) duration curve facet. | |
70 Object[] args = new Object[] { | |
71 FLYSUtils.getRiver(winfo).getName(), | |
72 FLYSUtils.getLocations(winfo)[0] | |
73 }; | |
74 | |
75 String nameW = Resources.getMsg( | |
76 context.getMeta(), | |
77 "chart.duration.curve.curve.w", | |
78 "", | |
79 args); | |
80 | |
81 String nameQ = Resources.getMsg( | |
82 context.getMeta(), | |
83 "chart.duration.curve.curve.q", | |
84 "", | |
85 args); | |
86 | |
87 Facet w = new DurationCurveFacet(DURATION_W, nameW); | |
88 Facet q = new DurationCurveFacet(DURATION_Q, nameQ); | |
89 | |
90 facets.add(w); | |
91 facets.add(q); | |
92 | |
93 facets.add(new DataFacet(CSV, "CSV data")); | |
94 facets.add(new DataFacet(PDF, "PDF data")); | |
95 | |
96 if (res.getReport().hasProblems()) { | |
97 facets.add(new ReportFacet()); | |
98 } | |
99 } | |
100 | |
101 return res; | |
102 } | |
103 else if (artifact instanceof ChartArtifact) { | |
104 ChartArtifact chart = (ChartArtifact)artifact; | |
105 facets.add(new EmptyFacet()); | |
106 return null; | |
107 } | |
108 return null; | |
109 } | |
110 } | |
111 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |