# HG changeset patch # User Felix Wolfsteller # Date 1337834213 0 # Node ID ba15eb120a02c671ac68b36986adc82f881a8e74 # Parent d972c4cf5898a3220ca67649b06d39ef0cfc0c14 Expose reference curve parameters via blackboard. flys-artifacts/trunk@4491 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r d972c4cf5898 -r ba15eb120a02 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Thu May 24 04:33:52 2012 +0000 +++ b/flys-artifacts/ChangeLog Thu May 24 04:36:53 2012 +0000 @@ -1,4 +1,9 @@ -2012-05-23 Felix Wolfsteller +2012-05-24 Felix Wolfsteller + + * src/main/java/de/intevation/flys/artifacts/model/ReferenceCurveFacet.java: + Expose data via blackboard. + +2012-05-24 Felix Wolfsteller * doc/conf/meta-data.xml: Serve fixations with relative points for reference curves. diff -r d972c4cf5898 -r ba15eb120a02 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ReferenceCurveFacet.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ReferenceCurveFacet.java Thu May 24 04:33:52 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ReferenceCurveFacet.java Thu May 24 04:36:53 2012 +0000 @@ -1,5 +1,6 @@ package de.intevation.flys.artifacts.model; +import java.util.ArrayList; import java.util.List; import java.util.Collections; @@ -9,11 +10,13 @@ import de.intevation.artifacts.CallContext; import de.intevation.flys.artifacts.FLYSArtifact; +import de.intevation.flys.artifacts.WINFOArtifact; import de.intevation.flys.artifacts.states.DefaultState.ComputeType; import org.apache.log4j.Logger; + /** Facet for W-over-Ws. */ public class ReferenceCurveFacet extends DataFacet @@ -22,13 +25,24 @@ public static final String CONTEXT_KEY = "reference.curve.axis.scale"; + /** Blackboard data provider key for reference curves start km. */ + public static final String BB_REFERENCECURVE_STARTKM = + "reference_curve.startkm"; + + /** Blackboard data provider key for reference curves end kms. */ + public static final String BB_REFERENCECURVE_ENDKMS = + "reference_curve.endkms"; + + public ReferenceCurveFacet() { } + public ReferenceCurveFacet(int index, String name, String description) { super(index, name, description, ComputeType.ADVANCE, null, null); } + public ReferenceCurveFacet( int index, String name, @@ -40,6 +54,7 @@ super(index, name, description, type, hash, stateID); } + public Object getData(Artifact artifact, CallContext context) { if (log.isDebugEnabled()) { @@ -50,6 +65,33 @@ return getWWQQ(artifact, context); } + + /** + * Can provide parameters of reference curve + * @param key will respond on BB_REFERENCECURVE START/ENDKMS + * @param param ignored + * @param context ignored + * @return whatever parameters for reference curve + */ + @Override + public Object provideBlackboardData(Artifact artifact, + Object key, + Object param, + CallContext context + ) { + WINFOArtifact winfo = (WINFOArtifact) artifact; + if (key.equals(BB_REFERENCECURVE_STARTKM)) { + return winfo.getReferenceStartKm(); + } + else if (key.equals(BB_REFERENCECURVE_ENDKMS)) { + return winfo.getReferenceEndKms(); + } + else { + return null; + } + } + + protected WWQQ getWWQQ(Artifact artifact, CallContext context) { FLYSArtifact winfo = (FLYSArtifact)artifact; @@ -59,6 +101,7 @@ return ((WWQQ [])res.getData())[index]; } + @Override public void set(Facet other) { super.set(other); @@ -68,6 +111,7 @@ stateId = o.stateId; } + /** Copy deeply. */ @Override public Facet deepCopy() { @@ -76,6 +120,16 @@ return copy; } + + @Override + public List getStaticDataProviderKeys(Artifact art) { + List list = new ArrayList(); + list.add(BB_REFERENCECURVE_STARTKM); + list.add(BB_REFERENCECURVE_ENDKMS); + return list; + } + + @Override public List getDataProviderKeys(Artifact art, CallContext context) { @@ -90,7 +144,7 @@ ((WWAxisTypes)obj).classify(getWWQQ(art, context)); } - return Collections.emptyList(); + return getStaticDataProviderKeys(art);//Collections.emptyList(); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :