comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ReferenceCurveFacet.java @ 3818:dc18457b1cef

merged flys-artifacts/pre2.7-2012-03-16
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:59 +0200
parents dce0cc856357
children ba15eb120a02
comparison
equal deleted inserted replaced
2456:60ab1054069d 3818:dc18457b1cef
1 package de.intevation.flys.artifacts.model;
2
3 import java.util.List;
4 import java.util.Collections;
5
6 import de.intevation.artifactdatabase.state.Facet;
7
8 import de.intevation.artifacts.Artifact;
9 import de.intevation.artifacts.CallContext;
10
11 import de.intevation.flys.artifacts.FLYSArtifact;
12
13 import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
14
15 import org.apache.log4j.Logger;
16
17 /** Facet for W-over-Ws. */
18 public class ReferenceCurveFacet
19 extends DataFacet
20 {
21 private static Logger log = Logger.getLogger(ReferenceCurveFacet.class);
22
23 public static final String CONTEXT_KEY = "reference.curve.axis.scale";
24
25 public ReferenceCurveFacet() {
26 }
27
28 public ReferenceCurveFacet(int index, String name, String description) {
29 super(index, name, description, ComputeType.ADVANCE, null, null);
30 }
31
32 public ReferenceCurveFacet(
33 int index,
34 String name,
35 String description,
36 ComputeType type,
37 String stateID,
38 String hash
39 ) {
40 super(index, name, description, type, hash, stateID);
41 }
42
43 public Object getData(Artifact artifact, CallContext context) {
44
45 if (log.isDebugEnabled()) {
46 log.debug("Get data for reference curve at index: " + index +
47 " /stateId: " + stateId);
48 }
49
50 return getWWQQ(artifact, context);
51 }
52
53 protected WWQQ getWWQQ(Artifact artifact, CallContext context) {
54 FLYSArtifact winfo = (FLYSArtifact)artifact;
55
56 CalculationResult res = (CalculationResult)
57 winfo.compute(context, hash, stateId, type, false);
58
59 return ((WWQQ [])res.getData())[index];
60 }
61
62 @Override
63 public void set(Facet other) {
64 super.set(other);
65 ReferenceCurveFacet o = (ReferenceCurveFacet)other;
66 type = o.type;
67 hash = o.hash;
68 stateId = o.stateId;
69 }
70
71 /** Copy deeply. */
72 @Override
73 public Facet deepCopy() {
74 ReferenceCurveFacet copy = new ReferenceCurveFacet();
75 copy.set(this);
76 return copy;
77 }
78
79 @Override
80 public List getDataProviderKeys(Artifact art, CallContext context) {
81
82 // compute / get data
83 Object obj = context.getContextValue(CONTEXT_KEY);
84
85 if (!(obj instanceof WWAxisTypes)) {
86 obj = new WWAxisTypes(getWWQQ(art, context));
87 context.putContextValue(CONTEXT_KEY, obj);
88 }
89 else {
90 ((WWAxisTypes)obj).classify(getWWQQ(art, context));
91 }
92
93 return Collections.emptyList();
94 }
95 }
96 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org