Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ReferenceCurveFacet.java @ 2756:ba15eb120a02
Expose reference curve parameters via blackboard.
flys-artifacts/trunk@4491 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 24 May 2012 04:36:53 +0000 |
parents | dce0cc856357 |
children | 5642a83420f2 |
comparison
equal
deleted
inserted
replaced
2755:d972c4cf5898 | 2756:ba15eb120a02 |
---|---|
1 package de.intevation.flys.artifacts.model; | 1 package de.intevation.flys.artifacts.model; |
2 | 2 |
3 import java.util.ArrayList; | |
3 import java.util.List; | 4 import java.util.List; |
4 import java.util.Collections; | 5 import java.util.Collections; |
5 | 6 |
6 import de.intevation.artifactdatabase.state.Facet; | 7 import de.intevation.artifactdatabase.state.Facet; |
7 | 8 |
8 import de.intevation.artifacts.Artifact; | 9 import de.intevation.artifacts.Artifact; |
9 import de.intevation.artifacts.CallContext; | 10 import de.intevation.artifacts.CallContext; |
10 | 11 |
11 import de.intevation.flys.artifacts.FLYSArtifact; | 12 import de.intevation.flys.artifacts.FLYSArtifact; |
13 import de.intevation.flys.artifacts.WINFOArtifact; | |
12 | 14 |
13 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; | 15 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; |
14 | 16 |
15 import org.apache.log4j.Logger; | 17 import org.apache.log4j.Logger; |
18 | |
16 | 19 |
17 /** Facet for W-over-Ws. */ | 20 /** Facet for W-over-Ws. */ |
18 public class ReferenceCurveFacet | 21 public class ReferenceCurveFacet |
19 extends DataFacet | 22 extends DataFacet |
20 { | 23 { |
21 private static Logger log = Logger.getLogger(ReferenceCurveFacet.class); | 24 private static Logger log = Logger.getLogger(ReferenceCurveFacet.class); |
22 | 25 |
23 public static final String CONTEXT_KEY = "reference.curve.axis.scale"; | 26 public static final String CONTEXT_KEY = "reference.curve.axis.scale"; |
24 | 27 |
28 /** Blackboard data provider key for reference curves start km. */ | |
29 public static final String BB_REFERENCECURVE_STARTKM = | |
30 "reference_curve.startkm"; | |
31 | |
32 /** Blackboard data provider key for reference curves end kms. */ | |
33 public static final String BB_REFERENCECURVE_ENDKMS = | |
34 "reference_curve.endkms"; | |
35 | |
36 | |
25 public ReferenceCurveFacet() { | 37 public ReferenceCurveFacet() { |
26 } | 38 } |
39 | |
27 | 40 |
28 public ReferenceCurveFacet(int index, String name, String description) { | 41 public ReferenceCurveFacet(int index, String name, String description) { |
29 super(index, name, description, ComputeType.ADVANCE, null, null); | 42 super(index, name, description, ComputeType.ADVANCE, null, null); |
30 } | 43 } |
44 | |
31 | 45 |
32 public ReferenceCurveFacet( | 46 public ReferenceCurveFacet( |
33 int index, | 47 int index, |
34 String name, | 48 String name, |
35 String description, | 49 String description, |
38 String hash | 52 String hash |
39 ) { | 53 ) { |
40 super(index, name, description, type, hash, stateID); | 54 super(index, name, description, type, hash, stateID); |
41 } | 55 } |
42 | 56 |
57 | |
43 public Object getData(Artifact artifact, CallContext context) { | 58 public Object getData(Artifact artifact, CallContext context) { |
44 | 59 |
45 if (log.isDebugEnabled()) { | 60 if (log.isDebugEnabled()) { |
46 log.debug("Get data for reference curve at index: " + index + | 61 log.debug("Get data for reference curve at index: " + index + |
47 " /stateId: " + stateId); | 62 " /stateId: " + stateId); |
48 } | 63 } |
49 | 64 |
50 return getWWQQ(artifact, context); | 65 return getWWQQ(artifact, context); |
51 } | 66 } |
52 | 67 |
68 | |
69 /** | |
70 * Can provide parameters of reference curve | |
71 * @param key will respond on BB_REFERENCECURVE START/ENDKMS | |
72 * @param param ignored | |
73 * @param context ignored | |
74 * @return whatever parameters for reference curve | |
75 */ | |
76 @Override | |
77 public Object provideBlackboardData(Artifact artifact, | |
78 Object key, | |
79 Object param, | |
80 CallContext context | |
81 ) { | |
82 WINFOArtifact winfo = (WINFOArtifact) artifact; | |
83 if (key.equals(BB_REFERENCECURVE_STARTKM)) { | |
84 return winfo.getReferenceStartKm(); | |
85 } | |
86 else if (key.equals(BB_REFERENCECURVE_ENDKMS)) { | |
87 return winfo.getReferenceEndKms(); | |
88 } | |
89 else { | |
90 return null; | |
91 } | |
92 } | |
93 | |
94 | |
53 protected WWQQ getWWQQ(Artifact artifact, CallContext context) { | 95 protected WWQQ getWWQQ(Artifact artifact, CallContext context) { |
54 FLYSArtifact winfo = (FLYSArtifact)artifact; | 96 FLYSArtifact winfo = (FLYSArtifact)artifact; |
55 | 97 |
56 CalculationResult res = (CalculationResult) | 98 CalculationResult res = (CalculationResult) |
57 winfo.compute(context, hash, stateId, type, false); | 99 winfo.compute(context, hash, stateId, type, false); |
58 | 100 |
59 return ((WWQQ [])res.getData())[index]; | 101 return ((WWQQ [])res.getData())[index]; |
60 } | 102 } |
103 | |
61 | 104 |
62 @Override | 105 @Override |
63 public void set(Facet other) { | 106 public void set(Facet other) { |
64 super.set(other); | 107 super.set(other); |
65 ReferenceCurveFacet o = (ReferenceCurveFacet)other; | 108 ReferenceCurveFacet o = (ReferenceCurveFacet)other; |
66 type = o.type; | 109 type = o.type; |
67 hash = o.hash; | 110 hash = o.hash; |
68 stateId = o.stateId; | 111 stateId = o.stateId; |
69 } | 112 } |
70 | 113 |
114 | |
71 /** Copy deeply. */ | 115 /** Copy deeply. */ |
72 @Override | 116 @Override |
73 public Facet deepCopy() { | 117 public Facet deepCopy() { |
74 ReferenceCurveFacet copy = new ReferenceCurveFacet(); | 118 ReferenceCurveFacet copy = new ReferenceCurveFacet(); |
75 copy.set(this); | 119 copy.set(this); |
76 return copy; | 120 return copy; |
77 } | 121 } |
122 | |
123 | |
124 @Override | |
125 public List getStaticDataProviderKeys(Artifact art) { | |
126 List list = new ArrayList(); | |
127 list.add(BB_REFERENCECURVE_STARTKM); | |
128 list.add(BB_REFERENCECURVE_ENDKMS); | |
129 return list; | |
130 } | |
131 | |
78 | 132 |
79 @Override | 133 @Override |
80 public List getDataProviderKeys(Artifact art, CallContext context) { | 134 public List getDataProviderKeys(Artifact art, CallContext context) { |
81 | 135 |
82 // compute / get data | 136 // compute / get data |
88 } | 142 } |
89 else { | 143 else { |
90 ((WWAxisTypes)obj).classify(getWWQQ(art, context)); | 144 ((WWAxisTypes)obj).classify(getWWQQ(art, context)); |
91 } | 145 } |
92 | 146 |
93 return Collections.emptyList(); | 147 return getStaticDataProviderKeys(art);//Collections.emptyList(); |
94 } | 148 } |
95 } | 149 } |
96 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 150 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |