Mercurial > dive4elements > river
changeset 7298:5b2126d21c2e
Polish SQ Datacage and Facets
The starting point is now taken from the blackboard
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Fri, 11 Oct 2013 15:35:25 +0200 |
parents | 257d72524249 |
children | cde863b2dae3 |
files | artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/SQCurveFacet.java artifacts/src/main/java/org/dive4elements/river/artifacts/states/sq/StaticSQRelationFacet.java gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties |
diffstat | 4 files changed, 62 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/SQCurveFacet.java Fri Oct 11 12:44:25 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/SQCurveFacet.java Fri Oct 11 15:35:25 2013 +0200 @@ -10,6 +10,8 @@ import org.apache.log4j.Logger; +import java.util.List; + import org.dive4elements.artifacts.Artifact; import org.dive4elements.artifacts.CallContext; @@ -107,5 +109,27 @@ return copy; } + + + @Override + public List getStaticDataProviderKeys(Artifact art) { + List list = super.getStaticDataProviderKeys(art); + list.add(name); + return list; + } + + @Override + public Object provideBlackboardData(Artifact artifact, + Object key, + Object param, + CallContext context + ) { + log.debug("I should provide date for key: " + key +" name " + name); + if (key.equals(name)) { + return getData(artifact, context); + } + return super.provideBlackboardData(artifact, key, + param, context); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/sq/StaticSQRelationFacet.java Fri Oct 11 12:44:25 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/sq/StaticSQRelationFacet.java Fri Oct 11 15:35:25 2013 +0200 @@ -8,10 +8,15 @@ package org.dive4elements.river.artifacts.states.sq; +import java.util.List; + +import org.apache.log4j.Logger; + import org.dive4elements.artifactdatabase.state.DefaultFacet; import org.dive4elements.artifactdatabase.state.Facet; import org.dive4elements.artifacts.Artifact; import org.dive4elements.artifacts.CallContext; +import org.dive4elements.artifacts.DataProvider; import org.dive4elements.river.artifacts.math.fitting.Function; import org.dive4elements.river.artifacts.math.fitting.FunctionFactory; import org.dive4elements.river.artifacts.model.sq.SQFunction; @@ -26,6 +31,8 @@ private StaticSQRelation relation; + private static final Logger logger = + Logger.getLogger(StaticSQRelationFacet.class); public StaticSQRelationFacet( int ndx, @@ -43,7 +50,34 @@ Function func = FunctionFactory.getInstance().getFunction(FUNCTION); org.dive4elements.river.artifacts.math.Function function = func.instantiate(coeffs); - SQFunction sqf = new SQFunction(function, 0, qmax); + + /* Figure out a good starting point by checking for calculated + * SQ Curves and using their starting point */ + + // this is ok because we are a DefaultFacet and not a DataFacet + // and so we are not registred with Mr. Blackboard + List<DataProvider> providers = context.getDataProvider(name); + + double startingPoint = Double.MAX_VALUE; + + for (DataProvider dp: providers) { + SQFunction other = (SQFunction) dp.provideData( + name, + null, + context); + if (other == null) { + // name is not really unique here but it's our only key + // should not happen anyhow. + logger.error("Did not get data from: " + name); + continue; + } + startingPoint = Math.min(other.getMinQ(), startingPoint); + } + if (startingPoint == Double.MAX_VALUE) { + startingPoint = 0; + } + + SQFunction sqf = new SQFunction(function, startingPoint, qmax); return sqf; }
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java Fri Oct 11 12:44:25 2013 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java Fri Oct 11 15:35:25 2013 +0200 @@ -588,6 +588,8 @@ String sq_relation_export(); + String sq_relations(); + String exportATTooltip(); String load_diameter();
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties Fri Oct 11 12:44:25 2013 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties Fri Oct 11 15:35:25 2013 +0200 @@ -645,6 +645,7 @@ fix_parameters = CSV sq_overview=Overview +sq_relations=SQ Relations gauge_zero = GZG gauge_q_unit = m\u00b3/s