[PATCH] Outliers in fixation calculation are now shown within the other 'B' event themes and get a separate symbol (triangle)
Wald Commits
scm-commit at wald.intevation.org
Wed Aug 1 17:13:57 CEST 2018
# HG changeset patch
# User gernotbelger
# Date 1533136432 -7200
# Node ID ddcd52d239cd7a6bc2da7b8814af2f0dcf8a7a39
# Parent df6f1b5806f6917b6342785eba7f655e7f65086a
Outliers in fixation calculation are now shown within the other 'B' event themes and get a separate symbol (triangle).
Removed old outliers theme.
Also consider showpoints property.
Also consider pointsize property.
diff -r df6f1b5806f6 -r ddcd52d239cd artifacts/doc/conf/artifacts/bundu.xml
--- a/artifacts/doc/conf/artifacts/bundu.xml Wed Aug 01 13:21:34 2018 +0200
+++ b/artifacts/doc/conf/artifacts/bundu.xml Wed Aug 01 17:13:52 2018 +0200
@@ -145,7 +145,6 @@
<facet name="fix_reference_events_wq" description="Raw event values used in the calculation" />
<facet name="fix_wq_curve" description="WQ curve" />
<facet name="qsectors" description="qsectors." />
- <facet name="fix_outlier" description="The outliers" />
<facet name="other.wqkms.q" description="W-Type of data" />
<facet name="other.wqkms.w" description="W-Type of data" />
<facet name="other.wkms" description="facet.other.wkms" />
@@ -262,7 +261,6 @@
<facet name="fix_analysis_events_wq" description="Raw event values used in the calculation" />
<facet name="fix_wq_curve" description="WQ curve" />
<facet name="fix_wq_ls" description="WQ LS curve" />
- <facet name="fix_outlier" description="The outliers" />
<facet name="qsectors" description="qsectors." />
<facet name="fix_events_wqkms" description="WQKMS-Type of data" />
<facet name="other.wqkms.q" description="W-Type of data" />
diff -r df6f1b5806f6 -r ddcd52d239cd artifacts/doc/conf/artifacts/fixanalysis.xml
--- a/artifacts/doc/conf/artifacts/fixanalysis.xml Wed Aug 01 13:21:34 2018 +0200
+++ b/artifacts/doc/conf/artifacts/fixanalysis.xml Wed Aug 01 17:13:52 2018 +0200
@@ -137,7 +137,6 @@
<facet name="fix_reference_events_wq" description="Raw event values used in the calculation" />
<facet name="fix_wq_curve" description="WQ curve" />
<facet name="qsectors" description="qsectors." />
- <facet name="fix_outlier" description="The outliers" />
<facet name="other.wqkms.q" description="W-Type of data" />
<facet name="other.wqkms.w" description="W-Type of data" />
<facet name="other.wkms" description="facet.other.wkms" />
@@ -254,7 +253,6 @@
<facet name="fix_analysis_events_wq" description="Raw event values used in the calculation" />
<facet name="fix_wq_curve" description="WQ curve" />
<facet name="fix_wq_ls" description="WQ LS curve" />
- <facet name="fix_outlier" description="The outliers" />
<facet name="qsectors" description="qsectors." />
<facet name="fix_events_wqkms" description="WQKMS-Type of data" />
<facet name="other.wqkms.q" description="W-Type of data" />
diff -r df6f1b5806f6 -r ddcd52d239cd artifacts/doc/conf/themes.xml
--- a/artifacts/doc/conf/themes.xml Wed Aug 01 13:21:34 2018 +0200
+++ b/artifacts/doc/conf/themes.xml Wed Aug 01 17:13:52 2018 +0200
@@ -324,7 +324,6 @@
<mapping from="fix_sector_average_wq_2" to="FixingSectorAverageWQ2" />
<mapping from="fix_sector_average_wq_3" to="FixingSectorAverageWQ3" />
<mapping from="fix_analysis_events_wq" to="FixingAnalysisEventsWQ" />
- <mapping from="fix_outlier" to="FixingOutliers" />
<mapping from="fix_wq_curve" to="FixingWQCurve" />
<mapping from="fix_wq_ls" to="FixingCalculatedPoint" />
<mapping from="fix_reference_events_wq" to="FixingReferenceEvents" />
diff -r df6f1b5806f6 -r ddcd52d239cd artifacts/doc/conf/themes/default.xml
--- a/artifacts/doc/conf/themes/default.xml Wed Aug 01 13:21:34 2018 +0200
+++ b/artifacts/doc/conf/themes/default.xml Wed Aug 01 17:13:52 2018 +0200
@@ -1736,14 +1736,6 @@
</fields>
</theme>
- <theme name="FixingOutliers">
- <inherits>
- <inherit from="FixPoints" />
- </inherits>
- <fields>
- </fields>
- </theme>
-
<theme name="FixingDeltaWtAverage">
<inherits>
<inherit from="FixLines" />
diff -r df6f1b5806f6 -r ddcd52d239cd artifacts/doc/conf/themes/second.xml
--- a/artifacts/doc/conf/themes/second.xml Wed Aug 01 13:21:34 2018 +0200
+++ b/artifacts/doc/conf/themes/second.xml Wed Aug 01 17:13:52 2018 +0200
@@ -1736,14 +1736,6 @@
</fields>
</theme>
- <theme name="FixingOutliers">
- <inherits>
- <inherit from="FixPoints" />
- </inherits>
- <fields>
- </fields>
- </theme>
-
<theme name="FixingDeltaWtAverage">
<inherits>
<inherit from="FixLines" />
diff -r df6f1b5806f6 -r ddcd52d239cd artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstState.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstState.java Wed Aug 01 13:21:34 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstState.java Wed Aug 01 17:13:52 2018 +0200
@@ -32,9 +32,7 @@
/** The log used in this class. */
private static Logger log = Logger.getLogger(BezugswstState.class);
- public static final String I18N_WQ_CURVE = "fix.vollmer.wq.curve";
-
- public static final String I18N_WQ_OUTLIER = "fix.vollmer.wq.outliers";
+ private static final String I18N_WQ_CURVE = "fix.vollmer.wq.curve";
/**
* The default constructor that initializes an empty State object.
@@ -131,9 +129,6 @@
// facets.add(new FixWQCurveFacet(0, Resources.getMsg(meta, I18N_WQ_CURVE, I18N_WQ_CURVE) + " (" + access.getFunction()
// + ")"));
//
- // if (access.getPreprocessing()) {
- // facets.add(new FixOutlierFacet(0, FIX_OUTLIER, Resources.getMsg(meta, I18N_WQ_OUTLIER, I18N_WQ_OUTLIER)));
- // }
return compute((BUNDUArtifact) artifact, context, hash, facets, old);
}
diff -r df6f1b5806f6 -r ddcd52d239cd artifacts/src/main/java/org/dive4elements/river/artifacts/model/FacetTypes.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/FacetTypes.java Wed Aug 01 13:21:34 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/FacetTypes.java Wed Aug 01 17:13:52 2018 +0200
@@ -406,7 +406,6 @@
String FIX_WQ_CURVE = "fix_wq_curve";
String FIX_WQ_LS = "fix_wq_ls";
- String FIX_OUTLIER = "fix_outlier";
String FIX_ANALYSIS_PERIODS_DWT = "fix_analysis_periods_dwt";
String FIX_ANALYSIS_PERIODS_LS = "fix_analysis_periods_ls";
diff -r df6f1b5806f6 -r ddcd52d239cd artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/Fitting.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/Fitting.java Wed Aug 01 13:21:34 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/Fitting.java Wed Aug 01 17:13:52 2018 +0200
@@ -27,73 +27,44 @@
/** Use instance of this factory to find meta infos for outliers. */
public interface QWDFactory {
- QWD create(double q, double w, boolean isOutlier);
+ QWD create(double q, double w, double deltaW, boolean isOutlier);
}
- private final boolean checkOutliers;
-
- private final Function function;
-
- private final QWDFactory qwdFactory;
-
- private double chiSqr;
-
- private double[] parameters;
-
- private final List<QWD> removed = new ArrayList<>();
-
- private QWD[] referenced;
-
- private double standardDeviation;
+ private final double chiSqr;
- public Fitting(Function function, QWDFactory qwdFactory, boolean checkOutliers) {
- this.function = function;
- this.qwdFactory = qwdFactory;
- this.checkOutliers = checkOutliers;
- }
+ private final double[] parameters;
- public Function getFunction() {
- return function;
- }
+ private final double standardDeviation;
- public boolean getCheckOutliers() {
- return checkOutliers;
+ private final List<QWD> qwds;
+
+ public Fitting(final double[] parameters, final double standardDeviation, final double chiSqr, final List<QWD> qwds) {
+ this.parameters = parameters;
+ this.standardDeviation = standardDeviation;
+ this.chiSqr = chiSqr;
+ this.qwds = qwds;
}
public double getChiSquare() {
return chiSqr;
}
- public void reset() {
- chiSqr = 0.0;
- parameters = null;
- removed.clear();
- referenced = null;
- standardDeviation = 0.0;
- }
-
- public boolean hasOutliers() {
- return !removed.isEmpty();
- }
-
- public QWD[] outliersToArray() {
- return removed.toArray(new QWD[removed.size()]);
- }
-
- public QWD[] referencedToArray() {
- return referenced != null ? (QWD[]) referenced.clone() : null;
+ /**
+ * Returns all referenced and outliers as one array.
+ */
+ public QWD[] getFixingsArray() {
+ return qwds.toArray(new QWD[qwds.size()]);
}
public double getMaxQ() {
double maxQ = -Double.MAX_VALUE;
- if (referenced != null) {
- for (QWI qw : referenced) {
- double q = qw.getQ();
- if (q > maxQ) {
- maxQ = q;
- }
- }
+
+ for (QWD qw : qwds) {
+ final double q = qw.getQ();
+ if (!qw.isOutlier() && q > maxQ)
+ maxQ = q;
}
+
return maxQ;
}
@@ -105,10 +76,10 @@
return standardDeviation;
}
- public boolean fit(double[] qs, double[] ws) {
+ public static Fitting fit(final Function function, final QWDFactory qwdFactory, final boolean checkOutliers, final double[] qs, final double[] ws) {
- TDoubleArrayList xs = new TDoubleArrayList(qs.length);
- TDoubleArrayList ys = new TDoubleArrayList(ws.length);
+ final TDoubleArrayList xs = new TDoubleArrayList(qs.length);
+ final TDoubleArrayList ys = new TDoubleArrayList(ws.length);
for (int i = 0; i < qs.length; ++i) {
if (!Double.isNaN(qs[i]) && !Double.isNaN(ws[i])) {
@@ -119,14 +90,16 @@
if (xs.size() < 2) {
log.warn("Too less points.");
- return false;
+ return null;
}
- List<Double> inputs = new ArrayList<Double>(xs.size());
+ final List<Double> inputs = new ArrayList<>(xs.size());
+ final List<QWD> qwds = new ArrayList<>(xs.size());
+ final List<QWD> outliers = new ArrayList<>(xs.size());
org.dive4elements.river.artifacts.math.Function instance = null;
-
LevenbergMarquardtOptimizer lmo = null;
+ double[] parameters = null;
for (;;) {
parameters = null;
@@ -149,10 +122,11 @@
}
catch (MathException me) {
if (log.isDebugEnabled()) {
- log.debug("tolerance " + tolerance + " + failed.");
+ log.debug("tolerance " + tolerance + " + failed.", me);
}
}
}
+
if (parameters == null) {
/*
* log.debug("Parameters is null");
@@ -160,15 +134,14 @@
* log.debug("DATA: " + xs.getQuick(i) + " " + ys.getQuick(i));
* }
*/
- return false;
+ return null;
}
// This is the paraterized function for a given km.
instance = function.instantiate(parameters);
- if (!checkOutliers) {
+ if (!checkOutliers)
break;
- }
inputs.clear();
@@ -180,38 +153,46 @@
inputs.add(Double.valueOf(ys.getQuick(i) - y));
}
- Integer outlier = GrubbsOutlier.findOutlier(inputs);
+ final Integer outlier = GrubbsOutlier.findOutlier(inputs);
+ if (outlier == null)
+ break;
- if (outlier == null) {
- break;
- }
-
- int idx = outlier.intValue();
- removed.add(qwdFactory.create(xs.getQuick(idx), ys.getQuick(idx), true));
+ final int idx = outlier.intValue();
+ outliers.add(qwdFactory.create(xs.getQuick(idx), ys.getQuick(idx), Double.NaN, true));
xs.remove(idx);
ys.remove(idx);
}
+
+ for (QWD outlier : outliers) {
+
+ final double w = outlier.getW();
+ final double q = outlier.getQ();
+
+ final double dw = (w - instance.value(q)) * 100.0;
- StandardDeviation stdDev = new StandardDeviation();
-
- referenced = new QWD[xs.size()];
- for (int i = 0; i < referenced.length; ++i) {
- QWD qwd = qwdFactory.create(xs.getQuick(i), ys.getQuick(i), false);
-
- if (qwd == null) {
- log.warn("QW creation failed!");
- } else {
- referenced[i] = qwd;
- double dw = (qwd.getW() - instance.value(qwd.getQ())) * 100.0;
- qwd.setDeltaW(dw);
- stdDev.increment(dw);
- }
+ outlier.setDeltaW(dw);
+
+ qwds.add(outlier);
}
- standardDeviation = stdDev.getResult();
+ final StandardDeviation stdDev = new StandardDeviation();
- chiSqr = lmo.getChiSquare();
+ for (int i = 0; i < xs.size(); ++i) {
- return true;
+ final QWD qwd = qwdFactory.create(xs.getQuick(i), ys.getQuick(i), Double.NaN, false);
+
+ double dw = (qwd.getW() - instance.value(qwd.getQ())) * 100.0;
+ qwd.setDeltaW(dw);
+
+ qwds.add(qwd);
+
+ stdDev.increment(dw);
+ }
+
+ final double standardDeviation = stdDev.getResult();
+
+ final double chiSqr = lmo.getChiSquare();
+
+ return new Fitting(parameters, standardDeviation, chiSqr, qwds);
}
}
\ No newline at end of file
diff -r df6f1b5806f6 -r ddcd52d239cd artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixAnalysisCalculation.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixAnalysisCalculation.java Wed Aug 01 13:21:34 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixAnalysisCalculation.java Wed Aug 01 17:13:52 2018 +0200
@@ -97,8 +97,7 @@
FixAnalysisResult far = new FixAnalysisResult(
fitResult.getParameters(),
- fitResult.getReferenced(),
- fitResult.getOutliers(),
+ fitResult.getFixings(),
analysisPeriods);
// Workaraound to deal with same dates in data set
diff -r df6f1b5806f6 -r ddcd52d239cd artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixAnalysisResult.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixAnalysisResult.java Wed Aug 01 13:21:34 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixAnalysisResult.java Wed Aug 01 17:13:52 2018 +0200
@@ -33,11 +33,10 @@
public FixAnalysisResult(
Parameters parameters,
- KMIndex<QWD []> referenced,
- KMIndex<QWD []> outliers,
+ KMIndex<QWD []> fixings,
KMIndex<AnalysisPeriod []> analysisPeriods
) {
- super(parameters, referenced, outliers);
+ super(parameters, fixings);
this.analysisPeriods = analysisPeriods;
}
diff -r df6f1b5806f6 -r ddcd52d239cd artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixLongitudinalReferenceFacet.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixLongitudinalReferenceFacet.java Wed Aug 01 13:21:34 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixLongitudinalReferenceFacet.java Wed Aug 01 17:13:52 2018 +0200
@@ -79,7 +79,7 @@
FixAnalysisResult result = (FixAnalysisResult) res.getData();
- KMIndex<QWD []> kmReference = result.getReferenced();
+ KMIndex<QWD []> kmReference = result.getFixings();
if (kmReference == null) {
log.warn("No references found.");
@@ -87,25 +87,25 @@
}
int qwdNdx = index & 255;
- KMIndex<QWD> resReference =
- new KMIndex<QWD>();
+
+ final KMIndex<QWD> resReference = new KMIndex<>();
+
for (KMIndex.Entry<QWD[]> entry: kmReference) {
QWD[] qwds = entry.getValue();
for(int i = 0; i < qwds.length; i++) {
- if(qwds[i].getIndex() == qwdNdx) {
+ if(qwds[i].getIndex() == qwdNdx && !qwds[i].isOutlier() ) {
resReference.add(entry.getKm(), qwds[i]);
}
}
}
+
return resReference;
}
- else {
- log.warn("Artifact is no instance of D4EArtifact.");
- return null;
- }
+
+ log.warn("Artifact is no instance of D4EArtifact.");
+ return null;
}
-
/**
* Create a deep copy of this Facet.
* @return a deep copy.
@@ -117,5 +117,4 @@
copy.set(this);
return copy;
}
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
+}
\ No newline at end of file
diff -r df6f1b5806f6 -r ddcd52d239cd artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixOutlierFacet.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixOutlierFacet.java Wed Aug 01 13:21:34 2018 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,109 +0,0 @@
-/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
- * Software engineering by Intevation GmbH
- *
- * This file is Free Software under the GNU AGPL (>=v3)
- * and comes with ABSOLUTELY NO WARRANTY! Check out the
- * documentation coming with Dive4Elements River for details.
- */
-
-package org.dive4elements.river.artifacts.model.fixings;
-
-import org.apache.log4j.Logger;
-
-import org.dive4elements.artifacts.Artifact;
-import org.dive4elements.artifacts.CallContext;
-import org.dive4elements.river.artifacts.D4EArtifact;
-import org.dive4elements.river.artifacts.model.CalculationResult;
-import org.dive4elements.river.artifacts.model.FacetTypes;
-import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
-import org.dive4elements.river.utils.KMIndex;
-
-/**
- * Facet to show the outliers in a fix calculation.
- *
- * @author <a href="mailto:raimund.renkert at intevation.de">Raimund Renkert</a>
- */
-public class FixOutlierFacet
-extends FixingsFacet
-implements FacetTypes {
-
- /** House log. */
- private static Logger log = Logger.getLogger(FixOutlierFacet.class);
-
- /** Trivial Constructor. */
- public FixOutlierFacet() {
- }
-
-
- /**
- * @param name
- */
- public FixOutlierFacet(String name, String description) {
- super(0, name, description, ComputeType.ADVANCE, null, null);
- }
-
- public FixOutlierFacet(int index, String name, String description) {
- super(index, name, description, ComputeType.ADVANCE, null, null);
- }
-
-
- /**
- * Returns the data this facet requires.
- *
- * @param artifact the owner artifact; needs to be a D4EArtifact.
- * @param context the CallContext; required to retrieve the value of
- * <i>currentKm</i>.
- *
- * @return an array of QW objects or null.
- */
- @Override
- public Object getData(Artifact artifact, CallContext context) {
- log.debug("FixOutlierFacet.getData");
-
- if (artifact instanceof D4EArtifact) {
- D4EArtifact flys = (D4EArtifact)artifact;
-
- CalculationResult res =
- (CalculationResult) flys.compute(context,
- ComputeType.ADVANCE,
- false);
-
- FixResult result = (FixResult) res.getData();
- double currentKm = getCurrentKm(context);
-
- KMIndex<QWD []> kmQWs = result.getOutliers();
- KMIndex.Entry<QWD []> qwsEntry = kmQWs.binarySearch(currentKm);
-
- QWI [] qws = null;
- if (qwsEntry != null) {
- qws = qwsEntry.getValue();
-
- if (log.isDebugEnabled()) {
- log.debug("Found " + (qws != null ? qws.length : 0)
- + " KMIndex.Entry for km " + currentKm);
- }
- }
- else {
- log.debug("Found no KMIndex.Entry for km " + currentKm);
- }
-
- return qws;
- }
-
- log.warn("Not an instance of D4EArtifact.");
- return null;
- }
-
-
- /**
- * Create a deep copy of this Facet.
- * @return a deep copy.
- */
- @Override
- public FixOutlierFacet deepCopy() {
- FixOutlierFacet copy = new FixOutlierFacet();
- copy.set(this);
- return copy;
- }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r df6f1b5806f6 -r ddcd52d239cd artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixRealizingCalculation.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixRealizingCalculation.java Wed Aug 01 13:21:34 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixRealizingCalculation.java Wed Aug 01 17:13:52 2018 +0200
@@ -133,15 +133,10 @@
}
// Name the curves.
- for (int i = 0; i < results.length; ++i) {
+ for (int i = 0; i < results.length; ++i)
results[i].setName(createName(i));
- }
- FixRealizingResult frr = new FixRealizingResult(
- parameters,
- fitResult.getReferenced(),
- fitResult.getOutliers(),
- results);
+ final FixRealizingResult frr = new FixRealizingResult( parameters, fitResult.getFixings(), results);
return new CalculationResult(frr, this);
}
diff -r df6f1b5806f6 -r ddcd52d239cd artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixRealizingResult.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixRealizingResult.java Wed Aug 01 13:21:34 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixRealizingResult.java Wed Aug 01 17:13:52 2018 +0200
@@ -27,11 +27,10 @@
public FixRealizingResult(
Parameters parameters,
- KMIndex<QWD []> referenced,
- KMIndex<QWD []> outliers,
+ KMIndex<QWD []> fixings,
WQKms [] wqkms
) {
- super(parameters, referenced, outliers);
+ super(parameters, fixings);
this.wqkms = wqkms;
}
@@ -43,5 +42,4 @@
public void setWQKms(WQKms [] wqkms) {
this.wqkms = wqkms;
}
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
+}
\ No newline at end of file
diff -r df6f1b5806f6 -r ddcd52d239cd artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixReferenceEventsFacet.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixReferenceEventsFacet.java Wed Aug 01 13:21:34 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixReferenceEventsFacet.java Wed Aug 01 17:13:52 2018 +0200
@@ -61,24 +61,12 @@
final FixResult result = (FixResult) res.getData();
final double currentKm = getCurrentKm(context);
- if (log.isDebugEnabled()) {
+ if (log.isDebugEnabled())
log.debug("current km in FRE: " + currentKm);
- }
/* first search in referenced */
- final KMIndex<QWD[]> referenced = result.getReferenced();
- final QWD foundReferenced = find(referenced, currentKm);
- if (foundReferenced != null)
- return foundReferenced;
-
- // FIXME
-// /* also search in outliers, should be mutually exclusive, because outliers got removed from referenced */
-// final KMIndex<QWD[]> outliers = result.getOutliers();
-// final QWD foundOutlier = find(outliers, currentKm);
-// if (foundOutlier != null)
-// return foundOutlier;
-
- return null;
+ final KMIndex<QWD[]> referenced = result.getFixings();
+ return find(referenced, currentKm);
}
private QWD find(final KMIndex<QWD[]> kmQWs, final double currentKm) {
diff -r df6f1b5806f6 -r ddcd52d239cd artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixResult.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixResult.java Wed Aug 01 13:21:34 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixResult.java Wed Aug 01 17:13:52 2018 +0200
@@ -8,11 +8,6 @@
package org.dive4elements.river.artifacts.model.fixings;
-import org.apache.log4j.Logger;
-import org.dive4elements.river.artifacts.model.Parameters;
-
-import org.dive4elements.river.utils.KMIndex;
-
import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
@@ -20,117 +15,72 @@
import java.util.TreeMap;
import java.util.TreeSet;
-public class FixResult
-implements Serializable
+import org.dive4elements.river.artifacts.model.Parameters;
+import org.dive4elements.river.utils.KMIndex;
+
+public class FixResult implements Serializable
{
- private static Logger log =
- Logger.getLogger(FixResult.class);
+ private static final long serialVersionUID = 1L;
protected Parameters parameters;
- protected KMIndex<QWD []> referenced;
- protected KMIndex<QWD []> outliers;
+ protected KMIndex<QWD []> fixings;
public FixResult() {
}
- public FixResult(
- Parameters parameters,
- KMIndex<QWD []> referenced,
- KMIndex<QWD []> outliers
- ) {
+ public FixResult( final Parameters parameters, final KMIndex<QWD []> fixings ) {
this.parameters = parameters;
- this.referenced = referenced;
- this.outliers = outliers;
+ this.fixings = fixings;
}
- public KMIndex<QWD []> getReferenced() {
- return referenced;
+ public KMIndex<QWD []> getFixings() {
+ return fixings;
}
- public void setReferenced(KMIndex<QWD []> referenced) {
- this.referenced = referenced;
- }
-
- public void makeReferenceEventsDatesUnique() {
+ public void makeEventsDatesUnique() {
final DateUniqueMaker dum = new DateUniqueMaker();
- for (KMIndex.Entry<QWD []> entry: referenced) {
+ for (KMIndex.Entry<QWD []> entry: fixings) {
for (QWD ref: entry.getValue())
dum.makeUnique(ref);
}
-
- // FIXME
-// for (KMIndex.Entry<QWD []> entry: outliers) {
-// for (QWD ref: entry.getValue())
-// dum.makeUnique(ref);
-// }
}
- private Collection<Integer> getReferenceEventsIndices() {
+ private Collection<Integer> getEventsIndices() {
final TreeMap<Date, Integer> dates = new TreeMap<>();
- for (KMIndex.Entry<QWD []> entry: referenced) {
+ for (KMIndex.Entry<QWD []> entry: fixings) {
for (QWD value: entry.getValue())
dates.put(value.date, value.index);
}
-// FIXME
-// for (KMIndex.Entry<QWD []> entry: outliers) {
-// for (QWD value: entry.getValue())
-// dates.put(value.date, value.index);
-// }
return dates.values();
}
- public void remapReferenceIndicesToRank() {
+ public void remapEventIndicesToRank() {
final RankRemapper remapper = new RankRemapper();
- for (Integer idx: getReferenceEventsIndices())
+ for (Integer idx: getEventsIndices())
remapper.toMap(idx);
-
- for (KMIndex.Entry<QWD []> entry: referenced) {
+
+ for (KMIndex.Entry<QWD []> entry: fixings) {
for (QWD value: entry.getValue())
remapper.remap(value);
}
-// FIXME
-// for (KMIndex.Entry<QWD []> entry: outliers) {
-// for (QWD value: entry.getValue())
-// remapper.remap(value);
-// }
}
public Collection<Date> getReferenceEventsDates() {
final Set<Date> dates = new TreeSet<>();
- for (final KMIndex.Entry<QWD []> entry: referenced) {
+ for (final KMIndex.Entry<QWD []> entry: fixings) {
for (final QWD qwd: entry.getValue())
dates.add(qwd.date);
}
- // FIXME, but not always...
-// for (final KMIndex.Entry<QWD []> entry: outliers) {
-// for (final QWD qwd: entry.getValue())
-// dates.add(qwd.date);
-// }
-
return dates;
}
-
- public KMIndex<QWD []> getOutliers() {
- return outliers;
- }
-
- public void setOutliers(KMIndex<QWD []> outliers) {
- this.outliers = outliers;
- }
-
public Parameters getParameters() {
return parameters;
}
-
- public void setParameters(Parameters parameters) {
- this.parameters = parameters;
- }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
+}
\ No newline at end of file
diff -r df6f1b5806f6 -r ddcd52d239cd artifacts/src/main/java/org/dive4elements/river/artifacts/services/QWSeriesCollection.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/services/QWSeriesCollection.java Wed Aug 01 13:21:34 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/services/QWSeriesCollection.java Wed Aug 01 17:13:52 2018 +0200
@@ -101,7 +101,7 @@
final boolean interpolated = qw.getInterpolated();
- final Shape shape = FixWQCurveGenerator.getWQDShape(qw);
+ final Shape shape = FixWQCurveGenerator.getWQDShape(qw, 4);
final boolean filled = !interpolated;
return new ShapeRenderer.Entry(shape, Color.blue, filled);
diff -r df6f1b5806f6 -r ddcd52d239cd artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/FixAnalysisCompute.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/FixAnalysisCompute.java Wed Aug 01 13:21:34 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/FixAnalysisCompute.java Wed Aug 01 17:13:52 2018 +0200
@@ -36,7 +36,6 @@
import org.dive4elements.river.artifacts.model.fixings.FixLongitudinalAvSectorFacet;
import org.dive4elements.river.artifacts.model.fixings.FixLongitudinalDeviationFacet;
import org.dive4elements.river.artifacts.model.fixings.FixLongitudinalReferenceFacet;
-import org.dive4elements.river.artifacts.model.fixings.FixOutlierFacet;
import org.dive4elements.river.artifacts.model.fixings.FixReferenceEventsFacet;
import org.dive4elements.river.artifacts.model.fixings.FixWQCurveFacet;
import org.dive4elements.river.artifacts.resources.Resources;
@@ -58,8 +57,6 @@
private static final String I18N_DERIVATIVE = "fix.derivative";
- private static final String I18N_OUTLIER = "fix.outlier";
-
private static final String I18N_ANALYSIS = "fix.analysis.short";
private static final String I18N_DEVIATION = "fix.deviation";
@@ -228,16 +225,9 @@
facets.add(new FixWQCurveFacet(idg.next(), "W/Q"));
- final Boolean preprocessing = access.getPreprocessing();
-
- if (preprocessing != null && preprocessing) {
- facets.add(new FixOutlierFacet(idg.next(), FIX_OUTLIER, Resources.getMsg(context.getMeta(), I18N_OUTLIER, I18N_OUTLIER)));
- }
-
facets.add(new FixDerivateFacet(idg.next(), FIX_DERIVATE_CURVE, Resources.getMsg(context.getMeta(), I18N_DERIVATIVE, I18N_DERIVATIVE)));
facets.add(new FixDeviationFacet(idg.next(), FIX_DEVIATION_DWT, Resources.getMsg(context.getMeta(), I18N_DEVIATION, I18N_DEVIATION)));
return res;
}
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
+}
\ No newline at end of file
diff -r df6f1b5806f6 -r ddcd52d239cd artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/FixRealizingCompute.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/FixRealizingCompute.java Wed Aug 01 13:21:34 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/FixRealizingCompute.java Wed Aug 01 17:13:52 2018 +0200
@@ -26,7 +26,6 @@
import org.dive4elements.river.artifacts.model.ReportFacet;
import org.dive4elements.river.artifacts.model.WQCKms;
import org.dive4elements.river.artifacts.model.WQKms;
-import org.dive4elements.river.artifacts.model.fixings.FixOutlierFacet;
import org.dive4elements.river.artifacts.model.fixings.FixRealizingCalculation;
import org.dive4elements.river.artifacts.model.fixings.FixRealizingResult;
import org.dive4elements.river.artifacts.model.fixings.FixReferenceEventsFacet;
@@ -49,8 +48,6 @@
public static final String I18N_WQ_CURVE = "fix.vollmer.wq.curve";
- public static final String I18N_WQ_OUTLIER = "fix.vollmer.wq.outliers";
-
/**
* The default constructor that initializes an empty State object.
*/
@@ -98,29 +95,19 @@
nameQ = "Q(" + nameW + ")";
}
- final Facet wq = new FixWaterlevelFacet(i, FIX_WQ_LS, nameW, ComputeType.ADVANCE, hash, id);
-
- final Facet w = new FixWaterlevelFacet(i, LONGITUDINAL_W, nameW, ComputeType.ADVANCE, hash, id);
-
- final Facet q = new FixWaterlevelFacet(i, LONGITUDINAL_Q, nameQ, ComputeType.ADVANCE, hash, id);
- final Facet csFacet = new CrossSectionWaterLineFacet(i, nameW);
-
- facets.add(wq);
- facets.add(w);
- facets.add(q);
- facets.add(csFacet);
+ facets.add(new FixWaterlevelFacet(i, FIX_WQ_LS, nameW, ComputeType.ADVANCE, hash, id));
+ facets.add(new FixWaterlevelFacet(i, LONGITUDINAL_W, nameW, ComputeType.ADVANCE, hash, id));
+ facets.add(new FixWaterlevelFacet(i, LONGITUDINAL_Q, nameQ, ComputeType.ADVANCE, hash, id));
+ facets.add(new CrossSectionWaterLineFacet(i, nameW));
// XXX: THIS CAN NOT HAPPEN! REMOVE IT!
if (wqkms[i] instanceof WQCKms) {
final String nameC = nameW.replace("benutzerdefiniert", "benutzerdefiniert [korrigiert]");
-
- final Facet c = new FixWaterlevelFacet(i, DISCHARGE_LONGITUDINAL_C, nameC);
-
- facets.add(c);
+ facets.add(new FixWaterlevelFacet(i, DISCHARGE_LONGITUDINAL_C, nameC));
}
}
- if (wqkms.length > 0) {
+ if (fixRes != null && wqkms.length > 0) {
final DateFormat df = Formatter.getDateFormatter(context.getMeta(), "dd.MM.yyyy");
final DateFormat lf = Formatter.getDateFormatter(context.getMeta(), "dd.MM.yyyy'T'HH:mm");
@@ -145,10 +132,6 @@
if (fixRes != null)
facets.add(new FixWQCurveFacet(0, Resources.getMsg(meta, I18N_WQ_CURVE, I18N_WQ_CURVE) + " (" + access.getFunction() + ")"));
- if (access.getPreprocessing() && fixRes != null) {
- facets.add(new FixOutlierFacet(0, FIX_OUTLIER, Resources.getMsg(meta, I18N_WQ_OUTLIER, I18N_WQ_OUTLIER)));
- }
-
return res;
}
}
\ No newline at end of file
diff -r df6f1b5806f6 -r ddcd52d239cd artifacts/src/main/java/org/dive4elements/river/exports/fixings/DeltaWtExporter.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/fixings/DeltaWtExporter.java Wed Aug 01 13:21:34 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/fixings/DeltaWtExporter.java Wed Aug 01 17:13:52 2018 +0200
@@ -107,14 +107,12 @@
}
final FixAnalysisResult result = (FixAnalysisResult) data;
this.analysisPeriods.add(result.getAnalysisPeriods());
- this.referenceEvents.add(result.getReferenced());
+ this.referenceEvents.add(result.getFixings());
}
@Override
protected void writeCSVData(final CSVWriter writer) throws IOException {
- final boolean debug = log.isDebugEnabled();
-
writeCSVHeader(writer);
final TreeMap<Double, ArrayList<String[]>> sorted = getRows();
@@ -154,20 +152,18 @@
final String kmS = kmF.format(kmEntry.getKm());
for (final QWD qwd : kmEntry.getValue()) {
- final String deltaWS = dwF.format(qwd.getDeltaW());
- final String qS = qF.format(qwd.getQ());
- final String wS = wF.format(qwd.getW());
- final String dateS = dF.format(qwd.getDate());
-
- list.add(new String[] { kmS, dateS, qS, wS, referenceS, deltaWS });
+ if( !qwd.isOutlier() ) {
+ final String deltaWS = dwF.format(qwd.getDeltaW());
+ final String qS = qF.format(qwd.getQ());
+ final String wS = wF.format(qwd.getW());
+ final String dateS = dF.format(qwd.getDate());
+
+ list.add(new String[] { kmS, dateS, qS, wS, referenceS, deltaWS });
+ }
}
}
}
- // if (debug) {
- // log.debug("AnalysisPeriods: " + this.analysisPeriods.size());
- // }
-
final String analysisTemplate = getAnalysisTemplate();
for (final KMIndex<AnalysisPeriod[]> periods : this.analysisPeriods) {
diff -r df6f1b5806f6 -r ddcd52d239cd artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixDeltaWtGenerator.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixDeltaWtGenerator.java Wed Aug 01 13:21:34 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixDeltaWtGenerator.java Wed Aug 01 17:13:52 2018 +0200
@@ -25,6 +25,7 @@
import org.dive4elements.river.jfree.StyledValueMarker;
import org.dive4elements.river.themes.ThemeDocument;
+import java.awt.Shape;
import java.io.OutputStream;
import java.text.NumberFormat;
import java.util.ArrayList;
@@ -326,15 +327,16 @@
}
final ThemeDocument themeInterpolated = FixWQCurveGenerator.configureThemeInterpolated(theme, qwd);
- final String label = FixWQCurveGenerator.buildQWDSeriesLabel(qwd, desc);
-
+ final Shape shape = FixWQCurveGenerator.getWQDShape(qwd, themeInterpolated.parsePointWidth());
+ final String label = FixWQCurveGenerator.buildQWDSeriesLabel(getContext().getMeta(), qwd, desc);
+
final Map<Integer, int[]> annoIdxMap = new HashMap<>();
final long time = uniqueDate(qwd.getDate().getTime());
final RegularTimePeriod rtp = new FixedMillisecond(time);
final double value = qwd.getDeltaW();
- final TimeSeries series = new StyledTimeSeries(label, themeInterpolated);
+ final TimeSeries series = new StyledTimeSeries(label, themeInterpolated, shape);
series.addOrUpdate(rtp, value);
tsc.addSeries(series);
diff -r df6f1b5806f6 -r ddcd52d239cd artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixWQCurveGenerator.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixWQCurveGenerator.java Wed Aug 01 13:21:34 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixWQCurveGenerator.java Wed Aug 01 17:13:52 2018 +0200
@@ -30,6 +30,7 @@
import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
import org.dive4elements.artifactdatabase.state.Facet;
import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.artifacts.CallMeta;
import org.dive4elements.river.artifacts.D4EArtifact;
import org.dive4elements.river.artifacts.StaticWKmsArtifact;
import org.dive4elements.river.artifacts.WINFOArtifact;
@@ -58,7 +59,7 @@
import org.dive4elements.river.themes.ThemeDocument;
import org.dive4elements.river.utils.RiverUtils;
import org.dive4elements.river.java2d.ShapeUtils;
-
+import org.dive4elements.river.java2d.ShapeUtils.ShapeType;
import org.dive4elements.river.jfree.Bounds;
import org.dive4elements.river.jfree.DoubleBounds;
@@ -227,9 +228,6 @@
else if(FIX_WQ_CURVE.equals(name)) {
doWQCurveOut(aaf, doc, visible);
}
- else if(FIX_OUTLIER.equals(name)) {
- doOutlierOut(aaf, doc, visible);
- }
else if(QSECTOR.equals(name)) {
doQSectorOut(aaf, doc, visible);
}
@@ -302,7 +300,7 @@
}
/** Add analysis event points to chart. */
- protected void doAnalysisEventsOut(
+ private void doAnalysisEventsOut(
ArtifactAndFacet aaf,
ThemeDocument doc,
boolean visible
@@ -324,7 +322,7 @@
double w = factor*(qwd.getW()-gaugeDatum);
final ThemeDocument theme = configureThemeInterpolated(doc, qwd);
- final XYSeries series = createQWDSeries(aaf, theme, qwd, qwd.getQ(), qwd.getQ());
+ final XYSeries series = createQWDSeries(getContext().getMeta(), aaf, theme, qwd, qwd.getQ(), qwd.getQ());
addAxisSeries(series, atGauge ? YAXIS.WCm.idx : YAXIS.W.idx, visible);
@@ -347,7 +345,7 @@
/** Add reference event points to chart. */
- protected void doReferenceEventsOut(
+ private void doReferenceEventsOut(
ArtifactAndFacet aaf,
ThemeDocument doc,
boolean visible
@@ -368,7 +366,7 @@
double w = factor*(qwd.getW()-gaugeDatum);
final ThemeDocument theme = configureThemeInterpolated(doc, qwd);
- final XYSeries series = createQWDSeries(aaf, theme, qwd, qwd.getQ(), w);
+ final XYSeries series = createQWDSeries(getContext().getMeta(), aaf, theme, qwd, qwd.getQ(), w);
series.add(qwd.getQ(), w, false);
if (visible && theme.parseShowPointLabel()) {
@@ -392,31 +390,34 @@
}
- public static XYSeries createQWDSeries(final ArtifactAndFacet bundle, final ThemeDocument theme, final QWI qwd) {
- return createQWDSeries(bundle, theme, qwd, qwd.getQ(), qwd.getW());
+ public static XYSeries createQWDSeries(final CallMeta meta, final ArtifactAndFacet bundle, final ThemeDocument theme, final QWI qwd) {
+ return createQWDSeries(meta, bundle, theme, qwd, qwd.getQ(), qwd.getW());
}
- public static XYSeries createQWDSeries(final ArtifactAndFacet bundle, final ThemeDocument theme, final QWI qwd, double q, double w) {
+ public static XYSeries createQWDSeries(final CallMeta meta, final ArtifactAndFacet bundle, final ThemeDocument theme, final QWI qwd, double q, double w) {
- final String description = buildQWDSeriesLabel(qwd, bundle.getFacetDescription());
+ final String description = buildQWDSeriesLabel(meta, qwd, bundle.getFacetDescription());
- final XYSeries series = new StyledXYSeries( description, theme, FixWQCurveGenerator.getWQDShape(qwd) );
+ final int size = theme.parsePointWidth();
+ final Shape shape = FixWQCurveGenerator.getWQDShape(qwd, size);
+
+ final XYSeries series = new StyledXYSeries( description, theme, shape );
series.add(q, w, false);
return series;
}
- public static Shape getWQDShape(final QWI qwd) {
+ public static Shape getWQDShape(final QWI qwd, final float size) {
final boolean isOutlier = qwd instanceof QWD ? ((QWD) qwd).isOutlier() : false;
-// if( isOutlier)
-// return ShapeUtils.DIGITIZED_SHAPE;
-
+ if( isOutlier)
+ return ShapeUtils.getScaledShape(ShapeType.outlier, size );
+
if (qwd.getInterpolated())
- return ShapeUtils.INTERPOLATED_SHAPE;
+ return ShapeUtils.getScaledShape(ShapeType.interpolated, size);
- return ShapeUtils.MEASURED_SHAPE;
+ return ShapeUtils.getScaledShape(ShapeType.measured, size);
}
public static final ThemeDocument configureThemeInterpolated(ThemeDocument theme, QWI qwd) {
@@ -424,26 +425,20 @@
// prevent potential side effects by copying original theme
final ThemeDocument newTheme = new ThemeDocument(theme);
- // FIXME: it was like this before: points were always shown, flag had no effekt on this kind of theme, although the option is visible in the style editor
- final boolean showPoints = true;
-// final boolean showPoints = theme.parseShowPoints();
+ final boolean showPoints = theme.parseShowPoints();
final boolean doFill = showPoints && !qwd.getInterpolated();
final boolean doOutline = showPoints && qwd.getInterpolated();
- final boolean isOutlier = qwd instanceof QWD ? ((QWD) qwd).isOutlier() : false;
- if( isOutlier )
- newTheme.setValue(ThemeDocument.POINT_COLOR, "255, 0, 0");
-
newTheme.setValue(ThemeDocument.SHOW_POINTS, Boolean.toString(doFill));
newTheme.setValue(ThemeDocument.SHOW_POINTS_OUTLINE, Boolean.toString(doOutline));
return newTheme;
}
- public static String buildQWDSeriesLabel(final QWI qwd, final String facetDescription) {
+ public static String buildQWDSeriesLabel(final CallMeta meta, final QWI qwd, final String facetDescription) {
- StringBuilder buffer = new StringBuilder( facetDescription );
+ final StringBuilder buffer = new StringBuilder( facetDescription );
final boolean isOutlier = qwd instanceof QWD ? ((QWD) qwd).isOutlier() : false;
boolean isInterpolated = qwd.getInterpolated();
@@ -452,15 +447,15 @@
return buffer.toString();
buffer.append(" (");
- if( isInterpolated )
+ if( isOutlier )
{
- buffer.append("interpoliert");
- if( isOutlier )
+ buffer.append( Resources.getMsg(meta, "fix.outlier") );
+ if( isInterpolated )
buffer.append(", ");
}
- if( isOutlier )
- buffer.append("Ausreißer");
+ if( isInterpolated )
+ buffer.append( Resources.getMsg(meta, "fix.interpolated") );
buffer.append(")");
@@ -572,18 +567,6 @@
}
}
- protected void doOutlierOut(
- ArtifactAndFacet aaf,
- ThemeDocument doc,
- boolean visible
- ) {
- log.debug("doOutlierOut");
-
- QWI[] qws = (QWI[])aaf.getData(getContext());
- addQWSeries(qws, aaf, doc, visible);
- }
-
-
/** Add markers for q sectors. */
protected void doQSectorOut(
ArtifactAndFacet aaf,
diff -r df6f1b5806f6 -r ddcd52d239cd artifacts/src/main/java/org/dive4elements/river/exports/process/FixWQProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/FixWQProcessor.java Wed Aug 01 13:21:34 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/FixWQProcessor.java Wed Aug 01 17:13:52 2018 +0200
@@ -26,7 +26,6 @@
import org.dive4elements.river.artifacts.model.fixings.FixFunction;
import org.dive4elements.river.artifacts.model.fixings.FixWQCurveFacet;
import org.dive4elements.river.artifacts.model.fixings.QWD;
-import org.dive4elements.river.artifacts.model.fixings.QWI;
import org.dive4elements.river.artifacts.resources.Resources;
import org.dive4elements.river.exports.DiagramGenerator;
import org.dive4elements.river.exports.StyledSeriesBuilder;
@@ -51,12 +50,10 @@
extends DefaultProcessor
implements FacetTypes
{
-
private static Logger log = Logger.getLogger(FixWQProcessor.class);
private String I18N_AXIS_LABEL = "chart.discharge.curve.yaxis.label";
-
public FixWQProcessor() {
}
@@ -83,9 +80,6 @@
else if(FIX_WQ_CURVE.equals(facetType)) {
doWQCurveOut(generator, bundle, theme, visible);
}
- else if(FIX_OUTLIER.equals(facetType)) {
- doOutlierOut(generator, bundle, theme, visible);
- }
else if(QSECTOR.equals(facetType)) {
doQSectorOut(generator, bundle, theme, visible);
}
@@ -103,7 +97,7 @@
}
/** Add sector average points to chart. */
- protected void doSectorAverageOut(
+ private void doSectorAverageOut(
DiagramGenerator generator,
ArtifactAndFacet bundle,
ThemeDocument theme,
@@ -146,7 +140,7 @@
/** Add analysis event points to chart. */
- protected void doEventsOut(
+ private void doEventsOut(
DiagramGenerator generator,
ArtifactAndFacet bundle,
ThemeDocument theme,
@@ -163,7 +157,7 @@
// prevent potential side effects
final ThemeDocument themeInterpolated = FixWQCurveGenerator.configureThemeInterpolated(theme, qwd);
- final XYSeries series = FixWQCurveGenerator.createQWDSeries(bundle, themeInterpolated, qwd);
+ final XYSeries series = FixWQCurveGenerator.createQWDSeries(generator.getContext().getMeta(), bundle, themeInterpolated, qwd);
generator.addAxisSeries(series, axisName, visible);
@@ -185,46 +179,7 @@
}
}
- /** Add reference event points to chart. */
- protected void doReferenceEventsOut(
- DiagramGenerator generator,
- ArtifactAndFacet bundle,
- ThemeDocument theme,
- boolean visible) {
- log.debug("doReferenceEventsOut");
-
- QWI qwd = (QWI)bundle.getData(generator.getContext());
- if (qwd == null) {
- log.debug("doReferenceEventsOut: qwds == null in "
- + bundle.getFacetDescription());
- return;
- }
-
-
- final ThemeDocument themeInterpolated = FixWQCurveGenerator.configureThemeInterpolated(theme, qwd);
- final XYSeries series = FixWQCurveGenerator.createQWDSeries(bundle, themeInterpolated, qwd);
- series.add(qwd.getQ(), qwd.getW(), false);
-
- if (visible && themeInterpolated.parseShowPointLabel()) {
- DateFormat dateFormat = DateFormat.getDateInstance(
- DateFormat.SHORT);
-
- XYTextAnnotation anno = new CollisionFreeXYTextAnnotation(
- dateFormat.format(qwd.getDate()),
- qwd.getQ(),
- qwd.getW());
-
- List<XYTextAnnotation> textAnnos = new ArrayList<>();
- textAnnos.add(anno);
- RiverAnnotation flysAnno = new RiverAnnotation(null, null, null, themeInterpolated);
- flysAnno.setTextAnnotations(textAnnos);
- generator.addAnnotations(flysAnno);
- }
-
- generator.addAxisSeries(series, axisName, visible);
- }
-
- protected void doWQCurveOut(
+ private void doWQCurveOut(
DiagramGenerator generator,
ArtifactAndFacet bundle,
ThemeDocument theme,
@@ -259,48 +214,6 @@
}
}
- protected void doOutlierOut(
- DiagramGenerator generator,
- ArtifactAndFacet bundle,
- ThemeDocument theme,
- boolean visible
- ) {
- log.debug("doOutlierOut");
-
- QWI[] qws = (QWI[])bundle.getData(generator.getContext());
- if(qws != null) {
- XYSeries series = new StyledXYSeries(
- bundle.getFacetDescription(),
- false, true,
- theme);
- DateFormat dateFormat = DateFormat.getDateInstance(
- DateFormat.SHORT);
-
- List<XYTextAnnotation> annos = new ArrayList<>();
-
- for (QWI qw: qws) {
- series.add(qw.getQ(), qw.getW(), false);
-
- XYTextAnnotation anno = new CollisionFreeXYTextAnnotation(
- dateFormat.format(qw.getDate()),
- qw.getQ(),
- qw.getW());
- annos.add(anno);
- }
- generator.addAxisSeries(series, axisName, visible);
-
- if (visible && theme != null && theme.parseShowPointLabel()) {
- RiverAnnotation flysAnno =
- new RiverAnnotation(null, null, null, theme);
- flysAnno.setTextAnnotations(annos);
- generator.addAnnotations(flysAnno);
- }
- }
- else {
- log.debug("doOutlierOut: qwd == null");
- }
- }
-
/** Add markers for q sectors. */
protected void doQSectorOut(
DiagramGenerator generator,
@@ -487,7 +400,6 @@
|| FIX_REFERENCE_EVENTS_WQ.equals(facettype)
|| FIX_EVENTS.equals(facettype)
|| FIX_WQ_CURVE.equals(facettype)
- || FIX_OUTLIER.equals(facettype)
|| QSECTOR.equals(facettype)
|| STATIC_WKMS_MARKS.equals(facettype)
|| STATIC_WKMS.equals(facettype)
diff -r df6f1b5806f6 -r ddcd52d239cd artifacts/src/main/java/org/dive4elements/river/java2d/ShapeUtils.java
--- a/artifacts/src/main/java/org/dive4elements/river/java2d/ShapeUtils.java Wed Aug 01 13:21:34 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/java2d/ShapeUtils.java Wed Aug 01 17:13:52 2018 +0200
@@ -9,83 +9,81 @@
package org.dive4elements.river.java2d;
import java.awt.Shape;
-
-import java.awt.geom.AffineTransform;
+import java.awt.geom.Area;
import java.awt.geom.Ellipse2D;
import java.awt.geom.GeneralPath;
import java.awt.geom.Rectangle2D;
-
import java.util.HashMap;
import java.util.Map;
-public class ShapeUtils
-{
- // TODO: Use enum
- public static final int MEASURED = 0;
- public static final int DIGITIZED = 1;
- public static final int INTERPOLATED = 2;
+public class ShapeUtils {
- public static final boolean DIGITIZED_FILL = false;
- public static final boolean MEASURED_FILL = true;
- public static final boolean INTERPOLATED_FILL = false;
+ public static enum ShapeType {
+ measured, digitized, interpolated, outlier
+ }
- public static final Shape DIGITIZED_SHAPE =
- createCross(4f);
+ private static Map<Long, Shape> scaledShapesCache = new HashMap<>();
- public static final Shape MEASURED_SHAPE =
- new Rectangle2D.Double(-2, -2, 4, 4);
+ private static final Shape createCross(float size) {
- public static final Shape INTERPOLATED_SHAPE =
- new Ellipse2D.Double(-2, -2, 4, 4);
+ final GeneralPath p = new GeneralPath();
- protected static Map<Long, Shape> scaledShapesCache =
- new HashMap<Long, Shape>();
+ p.moveTo(-size, -size);
+ p.lineTo(size, size);
+ p.closePath();
+ p.moveTo(-size, size);
+ p.lineTo(size, -size);
+ p.closePath();
- public static final Shape createCross(float size) {
- float half = size * 0.5f;
- GeneralPath p = new GeneralPath();
- p.moveTo(-half, -half);
- p.lineTo(half, half);
- p.closePath();
- p.moveTo(-half, half);
- p.lineTo(half, -half);
- p.closePath();
return p;
}
- public static Shape scale(Shape shape, float factor) {
- if (factor == 1f) {
- return shape;
- }
- AffineTransform xform =
- AffineTransform.getScaleInstance(factor, factor);
-
- GeneralPath gp = new GeneralPath(shape);
- return gp.createTransformedShape(xform);
+ private static Shape createBox(float size) {
+ return new Rectangle2D.Double(-size, -size, size * 2, size * 2);
}
- public static synchronized Shape getScaledShape(int type, float size) {
+ private static Shape createCircle(float size) {
+ return new Ellipse2D.Float(-size, -size, size * 2, size * 2);
+ }
- Long hash = Long.valueOf(
- (((long)type) << 32) | Float.floatToIntBits(size));
+ private static final Shape createTriangle(float size) {
+ final GeneralPath p = new GeneralPath();
- Shape shape = scaledShapesCache.get(hash);
+ p.moveTo(-size, size);
+ p.lineTo(size, size);
+ p.lineTo(0, -size);
+ p.closePath();
- if (shape == null) {
- switch (type) {
- case MEASURED:
- shape = MEASURED_SHAPE;
- break;
- case DIGITIZED:
- shape = DIGITIZED_SHAPE;
- break;
- default:
- shape = INTERPOLATED_SHAPE;
- }
- scaledShapesCache.put(hash, shape = scale(shape, size));
+ return new Area(p);
+ }
+
+ public static synchronized Shape getScaledShape(final ShapeType type, float size) {
+
+ final Long hash = Long.valueOf((((long) type.ordinal()) << 32) | Float.floatToIntBits(size));
+
+ final Shape shape = scaledShapesCache.get(hash);
+ if (shape != null)
+ return shape;
+
+ final Shape newShape = createScaledShape(type, size);
+ scaledShapesCache.put(hash, newShape);
+ return newShape;
+ }
+
+ private static Shape createScaledShape(ShapeType type, float size) {
+ switch (type) {
+ case measured:
+ return createBox(size);
+
+ case digitized:
+ return createCross(size);
+
+ case outlier:
+ return createTriangle(size);
+
+ case interpolated:
+ default:
+ return createCircle(size);
}
-
- return shape;
}
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
+}
\ No newline at end of file
diff -r df6f1b5806f6 -r ddcd52d239cd artifacts/src/main/java/org/dive4elements/river/jfree/StyledTimeSeries.java
--- a/artifacts/src/main/java/org/dive4elements/river/jfree/StyledTimeSeries.java Wed Aug 01 13:21:34 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/jfree/StyledTimeSeries.java Wed Aug 01 17:13:52 2018 +0200
@@ -8,39 +8,36 @@
package org.dive4elements.river.jfree;
-import org.apache.log4j.Logger;
+import java.awt.Shape;
+
import org.dive4elements.river.themes.ThemeDocument;
import org.jfree.data.time.TimeSeries;
-
/**
* @author <a href="mailto:ingo.weinzierl at intevation.de">Ingo Weinzierl</a>
*/
public class StyledTimeSeries extends TimeSeries implements StyledSeries {
- private static final Logger log =
- Logger.getLogger(StyledTimeSeries.class);
-
-
- protected Style style;
-
+ private Style style;
public StyledTimeSeries(String key, ThemeDocument theme) {
super(key);
setStyle(new XYStyle(theme));
}
-
+
+ public StyledTimeSeries(String key, ThemeDocument theme, Shape shape) {
+ super(key);
+ setStyle(new XYStyle(theme, shape));
+ }
@Override
public void setStyle(Style style) {
this.style = style;
}
-
@Override
public Style getStyle() {
return style;
}
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
+}
\ No newline at end of file
diff -r df6f1b5806f6 -r ddcd52d239cd artifacts/src/main/java/org/dive4elements/river/jfree/XYStyle.java
--- a/artifacts/src/main/java/org/dive4elements/river/jfree/XYStyle.java Wed Aug 01 13:21:34 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/jfree/XYStyle.java Wed Aug 01 17:13:52 2018 +0200
@@ -179,11 +179,6 @@
r.setUseOutlinePaint(c != null);
r.setSeriesShapesVisible(idx, show || showOutline);
-
- // applyShowPoints(r, idx);
- // applyPointColor(r, idx);
-
- // applyUseFillPaint(r);
}
private void applyPointSize(final XYLineAndShapeRenderer r, final int idx) {
@@ -193,46 +188,6 @@
r.setSeriesShape(idx, new Ellipse2D.Double(-size, -size, dim, dim));
}
- private void applyPointColor(final XYLineAndShapeRenderer r, final int idx) {
- final Color c = this.theme.parsePointColor();
-
- boolean alt = false;
- if (alt) {
-
- if (c != null) {
- r.setSeriesFillPaint(idx, c);
-
- r.setUseFillPaint(true);
- r.setDrawOutlines(false);
- }
- } else {
- // if (c != null) {
- r.setSeriesFillPaint(idx, c);
- r.setUseFillPaint(c != null);
-
- r.setSeriesOutlinePaint(idx, c);
- r.setDrawOutlines(c != null);
- // }
- }
- }
-
- /**
- * Sets form and visibility of points.
- */
- private void applyShowPoints(final XYLineAndShapeRenderer r, final int idx) {
- final boolean show = this.theme.parseShowPoints();
-
- r.setSeriesShapesVisible(idx, show);
- r.setDrawOutlines(true);
- }
-
- // private void applyUseFillPaint(final XYLineAndShapeRenderer r) {
- // final Boolean use = this.theme.parseUseFillPaint();
- // if (use != null) {
- // r.setUseFillPaint(use);
- // }
- // }
-
private void applyShowLine(final XYLineAndShapeRenderer r, final int idx) {
final boolean show = this.theme.parseShowLine();
r.setSeriesLinesVisible(idx, show);
diff -r df6f1b5806f6 -r ddcd52d239cd artifacts/src/main/java/org/dive4elements/river/utils/KMIndex.java
--- a/artifacts/src/main/java/org/dive4elements/river/utils/KMIndex.java Wed Aug 01 13:21:34 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/utils/KMIndex.java Wed Aug 01 17:13:52 2018 +0200
@@ -69,11 +69,11 @@
}
public KMIndex(int capacity) {
- entries = new ArrayList<Entry<A>>(capacity);
+ entries = new ArrayList<>(capacity);
}
public void add(double km, A value) {
- entries.add(new Entry<A>(km, value));
+ entries.add(new Entry<>(km, value));
}
public void sort() {
diff -r df6f1b5806f6 -r ddcd52d239cd artifacts/src/main/resources/messages.properties
--- a/artifacts/src/main/resources/messages.properties Wed Aug 01 13:21:34 2018 +0200
+++ b/artifacts/src/main/resources/messages.properties Wed Aug 01 17:13:52 2018 +0200
@@ -665,11 +665,11 @@
fix.analysis.periods=Analysis periods
fix.derivative=Derivative
fix.outlier=Outlier
+fix.interpolated = interpolated
fix.analysis=Analysis event
fix.deviation=Standard deviation
fix.reference.deviation=Reference deviation
fix.vollmer.wq.curve=Adjusted function
-fix.vollmer.wq.outliers=Outliers
fix.vollmer.wq.events=Events
qsectors=Discharge Sectors
fix.mnq=arround MNQ
diff -r df6f1b5806f6 -r ddcd52d239cd artifacts/src/main/resources/messages_de.properties
--- a/artifacts/src/main/resources/messages_de.properties Wed Aug 01 13:21:34 2018 +0200
+++ b/artifacts/src/main/resources/messages_de.properties Wed Aug 01 17:13:52 2018 +0200
@@ -665,11 +665,11 @@
fix.analysis.periods=Analysezeitr\u00e4ume
fix.derivative=Ableitung
fix.outlier=Ausrei\u00dfer
+fix.interpolated = interpoliert
fix.analysis=Analyseereignis
fix.deviation=Standardabweichung
fix.reference.deviation=Standardabweichung Bezugszeitraum
fix.vollmer.wq.curve=Angepasste Funktion
-fix.vollmer.wq.outliers=Ausrei\u00dfer
fix.vollmer.wq.events=Ereignisse
qsectors=Abfluss-Sektoren
fix.mnq=um MNQ
More information about the Dive4Elements-commits
mailing list