Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/states/WDifferencesState.java @ 7792:6451970e0562 minfo-opt
Add the new difference facet and set facets active/inactive.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Thu, 06 Mar 2014 14:07:24 +0100 |
parents | 640342d9ab8a |
children | a1ceacf15d3a |
comparison
equal
deleted
inserted
replaced
7791:8b95f9c4f341 | 7792:6451970e0562 |
---|---|
12 import java.util.List; | 12 import java.util.List; |
13 | 13 |
14 import org.apache.log4j.Logger; | 14 import org.apache.log4j.Logger; |
15 | 15 |
16 import org.dive4elements.artifactdatabase.state.Facet; | 16 import org.dive4elements.artifactdatabase.state.Facet; |
17 import org.dive4elements.artifactdatabase.state.FacetActivity; | |
17 import org.dive4elements.artifactdatabase.data.StateData; | 18 import org.dive4elements.artifactdatabase.data.StateData; |
18 | 19 |
19 import org.dive4elements.artifacts.CallContext; | 20 import org.dive4elements.artifacts.CallContext; |
20 import org.dive4elements.artifacts.Artifact; | 21 import org.dive4elements.artifacts.Artifact; |
21 import org.dive4elements.river.artifacts.ChartArtifact; | 22 import org.dive4elements.river.artifacts.ChartArtifact; |
28 import org.dive4elements.river.artifacts.math.WKmsOperation; | 29 import org.dive4elements.river.artifacts.math.WKmsOperation; |
29 | 30 |
30 import org.dive4elements.river.artifacts.model.CalculationResult; | 31 import org.dive4elements.river.artifacts.model.CalculationResult; |
31 import org.dive4elements.river.artifacts.model.DataFacet; | 32 import org.dive4elements.river.artifacts.model.DataFacet; |
32 import org.dive4elements.river.artifacts.model.DifferenceCurveFacet; | 33 import org.dive4elements.river.artifacts.model.DifferenceCurveFacet; |
34 import org.dive4elements.river.artifacts.model.DifferenceCurveFilterFacet; | |
33 import org.dive4elements.river.artifacts.model.EmptyFacet; | 35 import org.dive4elements.river.artifacts.model.EmptyFacet; |
34 import org.dive4elements.river.artifacts.model.FacetTypes; | 36 import org.dive4elements.river.artifacts.model.FacetTypes; |
35 import org.dive4elements.river.artifacts.model.WKms; | 37 import org.dive4elements.river.artifacts.model.WKms; |
36 import org.dive4elements.river.artifacts.model.WQKms; | 38 import org.dive4elements.river.artifacts.model.WQKms; |
37 | 39 |
38 import org.dive4elements.river.artifacts.model.fixings.FixRealizingResult; | 40 import org.dive4elements.river.artifacts.model.fixings.FixRealizingResult; |
41 import org.dive4elements.river.artifacts.resources.Resources; | |
39 | 42 |
40 import org.dive4elements.river.utils.RiverUtils; | 43 import org.dive4elements.river.utils.RiverUtils; |
41 import org.dive4elements.river.utils.StringUtil; | 44 import org.dive4elements.river.utils.StringUtil; |
42 | 45 |
43 /** State of a WINFOArtifact to get differences of data of other artifacts. */ | 46 /** State of a WINFOArtifact to get differences of data of other artifacts. */ |
46 implements FacetTypes | 49 implements FacetTypes |
47 { | 50 { |
48 /** The logger that is used in this state. */ | 51 /** The logger that is used in this state. */ |
49 private static Logger logger = Logger.getLogger(WDifferencesState.class); | 52 private static Logger logger = Logger.getLogger(WDifferencesState.class); |
50 | 53 |
54 private static final String I18N_DIFFERENCES_FACET_NAME = | |
55 "facet.w_differences"; | |
56 private static final String I18N_DIFFERENCES_FACET_NAME_RAW = | |
57 "facet.w_differences.raw"; | |
58 | |
59 static { | |
60 // Active/deactivate facets. | |
61 FacetActivity.Registry.getInstance().register( | |
62 "winfo", | |
63 new FacetActivity() { | |
64 @Override | |
65 public Boolean isInitialActive( | |
66 Artifact artifact, | |
67 Facet facet, | |
68 String output | |
69 ) { | |
70 String name = facet.getName(); | |
71 | |
72 if (name.equals(FacetTypes.W_DIFFERENCES)) { | |
73 return Boolean.FALSE; | |
74 } | |
75 return Boolean.TRUE; | |
76 } | |
77 }); | |
78 } | |
51 | 79 |
52 /** Specify to display nothing (this is kind of a "final" state). */ | 80 /** Specify to display nothing (this is kind of a "final" state). */ |
53 @Override | 81 @Override |
54 protected String getUIProvider() { | 82 protected String getUIProvider() { |
55 return "noinput"; | 83 return "noinput"; |
188 context); | 216 context); |
189 WKms subtrahendWKms = getWKms(StringUtil.unbracket(datas[i+1]), | 217 WKms subtrahendWKms = getWKms(StringUtil.unbracket(datas[i+1]), |
190 context); | 218 context); |
191 | 219 |
192 String facetName = "diff ()"; | 220 String facetName = "diff ()"; |
221 String minName = "min"; | |
222 String subName = "sub"; | |
193 | 223 |
194 if (minuendWKms != null && subtrahendWKms != null) { | 224 if (minuendWKms != null && subtrahendWKms != null) { |
195 facetName = StringUtil.wWrap(minuendWKms.getName()) | 225 minName = StringUtil.wWrap(minuendWKms.getName()); |
196 + " - " + StringUtil.wWrap(subtrahendWKms.getName()); | 226 subName = StringUtil.wWrap(subtrahendWKms.getName()); |
227 facetName = minName + " - " + subName; | |
197 WKms wkms = WKmsOperation.SUBTRACTION.operate(minuendWKms, | 228 WKms wkms = WKmsOperation.SUBTRACTION.operate(minuendWKms, |
198 subtrahendWKms); | 229 subtrahendWKms); |
199 wkms.setName(facetName); | 230 wkms.setName(facetName); |
200 wkmss.add(wkms); | 231 wkmss.add(wkms); |
201 logger.debug("WKMSSubtraction happened"); | 232 logger.debug("WKMSSubtraction happened"); |
202 } | 233 } |
203 if (facets != null) { | 234 if (facets != null) { |
204 facets.add(new DifferenceCurveFacet(i/2, W_DIFFERENCES, facetName, | 235 facets.add(new DifferenceCurveFacet( |
205 ComputeType.ADVANCE, id, hash)); | 236 i/2, |
237 W_DIFFERENCES, | |
238 Resources.getMsg( | |
239 context.getMeta(), | |
240 I18N_DIFFERENCES_FACET_NAME_RAW, | |
241 facetName, | |
242 new Object[] { minName, subName }), | |
243 ComputeType.ADVANCE, | |
244 id, | |
245 hash)); | |
246 facets.add(new DifferenceCurveFilterFacet(i/2, | |
247 W_DIFFERENCES_FILTERED, | |
248 Resources.getMsg( | |
249 context.getMeta(), | |
250 I18N_DIFFERENCES_FACET_NAME, | |
251 facetName, | |
252 new Object[] { minName, subName }), | |
253 ComputeType.ADVANCE, | |
254 id, | |
255 hash)); | |
206 } | 256 } |
207 } | 257 } |
208 | 258 |
209 if (facets != null) { | 259 if (facets != null) { |
210 facets.add(new DataFacet(CSV, "CSV data")); | 260 facets.add(new DataFacet(CSV, "CSV data")); |