Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoResultFacet.java @ 9215:0fc9c82e744e
work on collison, flood_duration
author | gernotbelger |
---|---|
date | Tue, 03 Jul 2018 17:00:48 +0200 |
parents | 3dae6b78e1da |
children |
rev | line source |
---|---|
8854 | 1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU AGPL (>=v3) | |
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
6 * documentation coming with Dive4Elements River for details. | |
7 */ | |
8 | |
8916 | 9 package org.dive4elements.river.artifacts.sinfo.common; |
8854 | 10 |
11 import org.apache.log4j.Logger; | |
12 import org.dive4elements.artifactdatabase.state.Facet; | |
13 import org.dive4elements.artifacts.Artifact; | |
14 import org.dive4elements.artifacts.CallContext; | |
15 import org.dive4elements.river.artifacts.D4EArtifact; | |
9166 | 16 import org.dive4elements.river.artifacts.common.AbstractCalculationResult; |
9170 | 17 import org.dive4elements.river.artifacts.common.AbstractCalculationResults; |
8854 | 18 import org.dive4elements.river.artifacts.model.CalculationResult; |
19 import org.dive4elements.river.artifacts.model.DataFacet; | |
20 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; | |
21 | |
22 /** | |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9170
diff
changeset
|
23 * Facet of one of the S-Info curves. |
8854 | 24 */ |
9215 | 25 public class SInfoResultFacet extends DataFacet { |
8854 | 26 |
8884 | 27 private static final long serialVersionUID = 1L; |
8854 | 28 |
8916 | 29 private static Logger log = Logger.getLogger(SInfoResultFacet.class); |
8884 | 30 |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
31 private int resultIndex; |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
32 |
8916 | 33 public SInfoResultFacet() { |
8854 | 34 // required for clone operation deepCopy() |
35 } | |
36 | |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
37 public SInfoResultFacet(final int resultIndex, final String name, final String description, final String yAxisLabelKey, final ComputeType type, |
9170 | 38 final String stateId, final String hash) { |
9215 | 39 this(resultIndex, resultIndex, name, description, yAxisLabelKey, type, stateId, hash); |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
40 } |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
41 |
9215 | 42 public SInfoResultFacet(final int facetIndex, final int resultIndex, final String name, final String description, final String yAxisLabelKey, |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
43 final ComputeType type, final String stateId, final String hash) { |
9215 | 44 // REMARK: in some cases, we have several data-lines for the same result (which normally determines the facet index) and |
45 // facet name. But index and name are used by the client side as unique keys for the chart themes... | |
46 // So we might have different facet index and result index. | |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
47 super(facetIndex, name, description, type, hash, stateId); |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
48 this.resultIndex = resultIndex; |
9215 | 49 |
8916 | 50 this.metaData.put("X", "sinfo.chart.km.xaxis.label"); |
8884 | 51 this.metaData.put("Y", yAxisLabelKey); |
8854 | 52 } |
53 | |
54 @Override | |
9215 | 55 public final Object getData(final Artifact artifact, final CallContext context) { |
56 log.debug("Get data for result at index: " + this.resultIndex); | |
8854 | 57 |
58 final D4EArtifact flys = (D4EArtifact) artifact; | |
59 | |
8884 | 60 final CalculationResult res = (CalculationResult) flys.compute(context, this.hash, this.stateId, this.type, false); |
8854 | 61 |
9170 | 62 final AbstractCalculationResults<AbstractCalculationResult> data = (AbstractCalculationResults<AbstractCalculationResult>) res.getData(); |
8884 | 63 |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
64 return data.getResults().get(this.resultIndex); |
8854 | 65 } |
66 | |
67 /** Copy deeply. */ | |
68 @Override | |
69 public Facet deepCopy() { | |
8891 | 70 // FIXME: why not simply use the full constructor instead? |
8916 | 71 final SInfoResultFacet copy = new SInfoResultFacet(); |
8854 | 72 // FIXME: why does DataFacet does not override set? Bad access to variables of parent! |
73 copy.set(this); | |
8884 | 74 copy.type = this.type; |
75 copy.hash = this.hash; | |
76 copy.stateId = this.stateId; | |
8854 | 77 return copy; |
78 } | |
79 } |