Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/artifacts/model/MainValuesWFacet.java @ 8331:27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
author | "Tom Gottfried <tom@intevation.de>" |
---|---|
date | Fri, 26 Sep 2014 09:44:48 +0200 |
parents | e4606eae8ea5 |
children | 5e38e2924c07 |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/MainValuesWFacet.java Fri Sep 26 08:40:20 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/MainValuesWFacet.java Fri Sep 26 09:44:48 2014 +0200 @@ -24,6 +24,7 @@ import org.dive4elements.river.jfree.StickyAxisAnnotation; import org.dive4elements.river.exports.fixings.FixChartGenerator; +import static org.dive4elements.river.exports.injector.InjectorConstants.PNP; /** * Facet to show Main W Values. @@ -35,15 +36,11 @@ /** Own log. */ private static Logger log = Logger.getLogger(MainValuesWFacet.class); - /** Do we want MainValues at Gauge (not interpolated)? */ - protected boolean isAtGauge; - /** Trivial Constructor. */ - public MainValuesWFacet(String name, String description, boolean atGauge) { + public MainValuesWFacet(String name, String description) { this.description = description; this.name = name; this.index = 0; - this.isAtGauge = atGauge; } @@ -79,7 +76,8 @@ public Object getData(Artifact artifact, CallContext context) { MainValuesArtifact mvArtifact = (MainValuesArtifact) artifact; - List<NamedDouble> ws = mvArtifact.getMainValuesW(isAtGauge); + List<NamedDouble> ws = mvArtifact.getMainValuesW( + context.getContextValue(PNP)); List<StickyAxisAnnotation> xy = new ArrayList<StickyAxisAnnotation>(); // Find whether a duration curve is on the blackboard. @@ -87,16 +85,18 @@ List<DataProvider> providers = context. getDataProvider(DurationCurveFacet.BB_DURATIONCURVE); if (providers.size() < 1) { - log.warn("Could not find durationcurve data provider."); // Do we have a current km in context? // If so, we are likely fetching data for a navigable // diagram (i.e. in fixation branch). Object xkm = context.getContextValue(FixChartGenerator.CURRENT_KM); if (xkm != null) { Double ckm = (Double)xkm; - // Return linearly interpolated values, in m if not at gauge, - // in cm over datum if at gauge. - ws = mvArtifact.getMainValuesW(new double[] {ckm}); + // Return linearly interpolated values. Always in m, as + // cm over datum ist represented by a second axis. + ws = mvArtifact.getMainValuesW( + new double[] {ckm}, + context.getContextValue(PNP) + ); } } else { @@ -107,7 +107,6 @@ } for (NamedDouble w: ws) { - log.debug("W Annotation at " + w.getValue() + " ("+w.getName()+")"+ wqdays); if (Double.isNaN(w.getValue())) { log.warn("NaN MainValue " + w.getName()); continue; @@ -134,7 +133,7 @@ @Override public MainValuesWFacet deepCopy() { MainValuesWFacet copy = new MainValuesWFacet(this.name, - description, this.isAtGauge); + description); copy.set(this); return copy; }