Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FlowVelocityState.java @ 2706:d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
flys-artifacts/trunk@4424 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 16 May 2012 12:39:13 +0000 |
parents | 4c00cf83fff1 |
children | b888c5eb65b3 |
comparison
equal
deleted
inserted
replaced
2705:71f072d8b3d8 | 2706:d8444fcb4e44 |
---|---|
14 import de.intevation.flys.artifacts.model.CalculationResult; | 14 import de.intevation.flys.artifacts.model.CalculationResult; |
15 import de.intevation.flys.artifacts.model.DataFacet; | 15 import de.intevation.flys.artifacts.model.DataFacet; |
16 import de.intevation.flys.artifacts.model.FacetTypes; | 16 import de.intevation.flys.artifacts.model.FacetTypes; |
17 import de.intevation.flys.artifacts.model.FlowVelocityCalculation; | 17 import de.intevation.flys.artifacts.model.FlowVelocityCalculation; |
18 import de.intevation.flys.artifacts.model.FlowVelocityData; | 18 import de.intevation.flys.artifacts.model.FlowVelocityData; |
19 import de.intevation.flys.artifacts.model.FlowVelocityFacet; | |
20 import de.intevation.flys.artifacts.resources.Resources; | |
19 | 21 |
20 | 22 |
21 public class FlowVelocityState extends DefaultState implements FacetTypes { | 23 public class FlowVelocityState extends DefaultState implements FacetTypes { |
22 | 24 |
23 private static Logger logger = Logger.getLogger(FlowVelocityState.class); | 25 private static Logger logger = Logger.getLogger(FlowVelocityState.class); |
26 | |
27 | |
28 public static final String I18N_MAINCHANNEL_FACET = | |
29 "facet.flow_velocity.mainchannel"; | |
30 | |
31 public static final String I18N_TOTALCHANNEL_FACET = | |
32 "facet.flow_velocity.totalchannel"; | |
33 | |
34 public static final String I18N_TAU_FACET = | |
35 "facet.flow_velocity.tauchannel"; | |
24 | 36 |
25 | 37 |
26 @Override | 38 @Override |
27 public Object computeAdvance( | 39 public Object computeAdvance( |
28 FLYSArtifact artifact, | 40 FLYSArtifact artifact, |
45 | 57 |
46 FlowVelocityData[] data = (FlowVelocityData[]) res.getData(); | 58 FlowVelocityData[] data = (FlowVelocityData[]) res.getData(); |
47 | 59 |
48 logger.debug("Calculated " + data.length + " FlowVelocityData objects"); | 60 logger.debug("Calculated " + data.length + " FlowVelocityData objects"); |
49 | 61 |
50 String id = getID(); | 62 String id = getID(); |
63 int idx = 0; | |
51 | 64 |
52 for (FlowVelocityData d: data) { | 65 for (FlowVelocityData d: data) { |
53 logger.error("TODO: Implement Facet creation for chart!"); | 66 logger.error("TODO: Implement Facet creation for chart!"); |
54 | 67 |
68 newFacets.add(new FlowVelocityFacet( | |
69 idx, | |
70 FLOW_VELOCITY_MAINCHANNEL, | |
71 buildMainChannelName(artifact, context, d), | |
72 ComputeType.ADVANCE, | |
73 id, | |
74 hash | |
75 )); | |
76 | |
77 newFacets.add(new FlowVelocityFacet( | |
78 idx, | |
79 FLOW_VELOCITY_TOTALCHANNEL, | |
80 buildTotalChannelName(artifact, context, d), | |
81 ComputeType.ADVANCE, | |
82 id, | |
83 hash | |
84 )); | |
85 | |
86 newFacets.add(new FlowVelocityFacet( | |
87 idx, | |
88 FLOW_VELOCITY_TAU, | |
89 buildTauName(artifact, context, d), | |
90 ComputeType.ADVANCE, | |
91 id, | |
92 hash | |
93 )); | |
94 | |
95 idx++; | |
55 } | 96 } |
56 | 97 |
57 Facet csv = new DataFacet( | 98 Facet csv = new DataFacet( |
58 CSV, "CSV data", ComputeType.ADVANCE, hash, id); | 99 CSV, "CSV data", ComputeType.ADVANCE, hash, id); |
59 | 100 |
65 | 106 |
66 facets.addAll(newFacets); | 107 facets.addAll(newFacets); |
67 | 108 |
68 return res; | 109 return res; |
69 } | 110 } |
111 | |
112 | |
113 protected String buildFacetName( | |
114 FLYSArtifact flys, | |
115 CallContext cc, | |
116 FlowVelocityData data, | |
117 String resourceId | |
118 ) { | |
119 Object[] args = new Object[] { | |
120 data.getZone() | |
121 }; | |
122 | |
123 return Resources.getMsg( | |
124 cc.getMeta(), | |
125 resourceId, | |
126 resourceId, | |
127 args); | |
128 } | |
129 | |
130 | |
131 protected String buildMainChannelName( | |
132 FLYSArtifact flys, | |
133 CallContext cc, | |
134 FlowVelocityData data | |
135 ) { | |
136 return buildFacetName(flys, cc, data, I18N_MAINCHANNEL_FACET); | |
137 } | |
138 | |
139 | |
140 protected String buildTotalChannelName( | |
141 FLYSArtifact flys, | |
142 CallContext cc, | |
143 FlowVelocityData data | |
144 ) { | |
145 return buildFacetName(flys, cc, data, I18N_TOTALCHANNEL_FACET); | |
146 } | |
147 | |
148 | |
149 protected String buildTauName( | |
150 FLYSArtifact flys, | |
151 CallContext cc, | |
152 FlowVelocityData data | |
153 ) { | |
154 return buildFacetName(flys, cc, data, I18N_TAU_FACET); | |
155 } | |
70 } | 156 } |
71 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : | 157 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |