comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoResultFacet.java @ 8916:5d5d0051723f

Working on outputmodes of tkh calculation
author gernotbelger
date Wed, 28 Feb 2018 18:55:39 +0100
parents artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthFacet.java@f431aec10d2c
children a4f1ac81f26d
comparison
equal deleted inserted replaced
8915:d9dbf0b74bc2 8916:5d5d0051723f
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
9 package org.dive4elements.river.artifacts.sinfo.common;
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;
16 import org.dive4elements.river.artifacts.model.CalculationResult;
17 import org.dive4elements.river.artifacts.model.DataFacet;
18 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
19
20 /**
21 * Facet of a FlowDepth curve.
22 */
23 public final class SInfoResultFacet extends DataFacet {
24
25 private static final long serialVersionUID = 1L;
26
27 private static Logger log = Logger.getLogger(SInfoResultFacet.class);
28
29 public SInfoResultFacet() {
30 // required for clone operation deepCopy()
31 }
32
33 public SInfoResultFacet(final int idx, final String name, final String description, final String yAxisLabelKey, final ComputeType type, final String stateId,
34 final String hash) {
35 super(idx, name, description, type, hash, stateId);
36 this.metaData.put("X", "sinfo.chart.km.xaxis.label");
37 this.metaData.put("Y", yAxisLabelKey);
38 }
39
40 @Override
41 public Object getData(final Artifact artifact, final CallContext context) {
42 log.debug("Get data for result at index: " + this.index);
43
44 final D4EArtifact flys = (D4EArtifact) artifact;
45
46 final CalculationResult res = (CalculationResult) flys.compute(context, this.hash, this.stateId, this.type, false);
47
48 final AbstractSInfoCalculationResults<?, ?> data = (AbstractSInfoCalculationResults<?, ?>) res.getData();
49
50 return data.getResults().get(this.index);
51 }
52
53 /** Copy deeply. */
54 @Override
55 public Facet deepCopy() {
56 // FIXME: why not simply use the full constructor instead?
57 final SInfoResultFacet copy = new SInfoResultFacet();
58 // FIXME: why does DataFacet does not override set? Bad access to variables of parent!
59 copy.set(this);
60 copy.type = this.type;
61 copy.hash = this.hash;
62 copy.stateId = this.stateId;
63 return copy;
64 }
65 }

http://dive4elements.wald.intevation.org