[PATCH] Polish SQ Datacage and Facets
Wald Commits
scm-commit at wald.intevation.org
Fri Oct 11 15:35:41 CEST 2013
# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1381498525 -7200
# Node ID 5b2126d21c2e07ab914d835f259e38560ac3b341
# Parent 257d7252424907bfd4583bb5c0b50d9859b40520
Polish SQ Datacage and Facets
The starting point is now taken from the blackboard
diff -r 257d72524249 -r 5b2126d21c2e artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/SQCurveFacet.java
--- 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 :
diff -r 257d72524249 -r 5b2126d21c2e artifacts/src/main/java/org/dive4elements/river/artifacts/states/sq/StaticSQRelationFacet.java
--- 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;
}
diff -r 257d72524249 -r 5b2126d21c2e gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java
--- 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();
diff -r 257d72524249 -r 5b2126d21c2e gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties
--- 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
More information about the Dive4elements-commits
mailing list