[PATCH 2 of 2] merged
Wald Commits
scm-commit at wald.intevation.org
Thu Sep 4 15:49:16 CEST 2014
# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1409838528 -7200
# Node ID 0a70cf74e58d62231e9b52e7d0fd2f1c6e0d66b6
# Parent fcc1ffbc2ea6495ce7c238999b6f9d4136fe6ed9
# Parent 096a7a710500a5f103422c639d7f95eca4a24d8c
merged
diff -r fcc1ffbc2ea6 -r 0a70cf74e58d artifacts/doc/conf/generators/discharge-diagram-defaults.xml
--- a/artifacts/doc/conf/generators/discharge-diagram-defaults.xml Thu Sep 04 15:43:13 2014 +0200
+++ b/artifacts/doc/conf/generators/discharge-diagram-defaults.xml Thu Sep 04 15:48:48 2014 +0200
@@ -9,4 +9,5 @@
<processor class="org.dive4elements.river.exports.process.DischargeProcessor" axis="W"/>
<processor class="org.dive4elements.river.exports.process.MiscDischargeProcessor" axis="W"/>
<processor class="org.dive4elements.river.exports.process.ComputedDischargeProcessor" axis="W"/>
+ <processor class="org.dive4elements.river.exports.process.HistoricalDischargeProcessor" axis="W"/>
</discharge-defaults>
diff -r fcc1ffbc2ea6 -r 0a70cf74e58d artifacts/src/main/java/org/dive4elements/river/exports/process/HistoricalDischargeProcessor.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/HistoricalDischargeProcessor.java Thu Sep 04 15:48:48 2014 +0200
@@ -0,0 +1,90 @@
+package org.dive4elements.river.exports.process;
+
+import org.apache.log4j.Logger;
+import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
+import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.river.artifacts.model.FacetTypes;
+import org.dive4elements.river.artifacts.model.WQKms;
+import org.dive4elements.river.exports.DiagramGenerator;
+import org.dive4elements.river.exports.StyledSeriesBuilder;
+import org.dive4elements.river.jfree.StyledXYSeries;
+import org.dive4elements.river.themes.ThemeDocument;
+import org.jfree.data.xy.XYSeries;
+
+
+public class HistoricalDischargeProcessor
+extends DefaultProcessor
+implements FacetTypes
+{
+
+ private final static Logger logger =
+ Logger.getLogger(HistoricalDischargeProcessor.class);
+
+ /** Station for which the diagram is shown. */
+ private double km;
+
+ /** Tolerance for comparison of kilometers. */
+ public static final double KM_EPSILON = 0.001d;
+
+
+ /** This processor needs to be constructed with a given km. */
+ public HistoricalDischargeProcessor() {
+ km = Double.NaN;
+ }
+
+
+ public HistoricalDischargeProcessor(double km) {
+ this.km = km;
+ }
+
+
+ /** Process data, add it to plot. */
+ @Override
+ public void doOut(
+ DiagramGenerator generator,
+ ArtifactAndFacet bundle,
+ ThemeDocument theme,
+ boolean visible
+ ) {
+ logger.debug("do out: " + bundle.getFacetName());
+ CallContext context = generator.getCallContext();
+ Object data = bundle.getData(context);
+ if (data instanceof WQKms) {
+ doDischargeOut(generator, bundle, theme, visible);
+ }
+ }
+
+ /** True if this processor knows how to deal with facetType. */
+ @Override
+ public boolean canHandle(String facetType) {
+ return HISTORICAL_DISCHARGE_WQ_CURVE.equals(facetType);
+ }
+
+
+ /** The station of the current calculation/view. */
+ protected double getKm() {
+ return km;
+ }
+
+ /**
+ * Add series with discharge curve to diagram.
+ */
+ protected void doDischargeOut(
+ DiagramGenerator generator,
+ ArtifactAndFacet bundle,
+ ThemeDocument theme,
+ boolean visible
+ ) {
+ CallContext context = generator.getCallContext();
+ WQKms data = (WQKms)bundle.getData(context);
+ XYSeries series = new StyledXYSeries(bundle.getFacetName(), theme);
+ double[][] wqData = new double[2][data.size()];
+ for (int i = 0; i < data.size(); i++) {
+ wqData[0][i] = data.getQ(i);
+ wqData[1][i] = data.getW(i);
+ }
+ StyledSeriesBuilder.addPoints(series, wqData, false);
+
+ generator.addAxisSeries(series, axisName, visible);
+ }
+}
diff -r fcc1ffbc2ea6 -r 0a70cf74e58d artifacts/src/main/java/org/dive4elements/river/exports/process/MiscDischargeProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/MiscDischargeProcessor.java Thu Sep 04 15:43:13 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/MiscDischargeProcessor.java Thu Sep 04 15:48:48 2014 +0200
@@ -25,6 +25,7 @@
import org.dive4elements.river.jfree.CollisionFreeXYTextAnnotation;
import org.dive4elements.river.jfree.RiverAnnotation;
import org.dive4elements.river.jfree.StickyAxisAnnotation;
+import org.dive4elements.river.jfree.StyledValueMarker;
import org.dive4elements.river.jfree.StyledXYSeries;
import org.dive4elements.river.themes.ThemeDocument;
@@ -62,7 +63,13 @@
boolean visible) {
CallContext context = generator.getCallContext();
Object data = bundle.getData(context);
- if (data instanceof WQKms) {
+ if (HISTORICAL_DISCHARGE_WQ_Q.equals(bundle.getFacetName())) {
+ doHistoricalDischargeOutQ(generator, bundle, theme, visible);
+ }
+ else if (HISTORICAL_DISCHARGE_WQ_W.equals(bundle.getFacetName())) {
+ doHistoricalDischargeOutW(generator, bundle, theme, visible);
+ }
+ else if (data instanceof WQKms) {
doWQKmsPointOut(
generator, (WQKms) data, bundle, theme, visible);
return;
@@ -241,7 +248,11 @@
|| MAINVALUES_W.equals(facetType)
|| STATIC_W_INTERPOL.equals(facetType)
|| STATIC_WQ.equals(facetType)
- || STATIC_WQ_ANNOTATIONS.equals(facetType);
+ || STATIC_WQ_ANNOTATIONS.equals(facetType)
+ || HISTORICAL_DISCHARGE_MAINVALUES_Q.equals(facetType)
+ || HISTORICAL_DISCHARGE_MAINVALUES_W.equals(facetType)
+ || HISTORICAL_DISCHARGE_WQ_W.equals(facetType)
+ || HISTORICAL_DISCHARGE_WQ_Q.equals(facetType);
}
@@ -250,6 +261,28 @@
return km;
}
+ protected void doHistoricalDischargeOutQ(
+ DiagramGenerator generator,
+ ArtifactAndFacet bundle,
+ ThemeDocument theme,
+ boolean visible
+ ) {
+ double value = Double.valueOf(
+ bundle.getData(generator.getCallContext()).toString());
+ generator.addDomainMarker(new StyledValueMarker(value, theme), visible);
+ }
+
+ protected void doHistoricalDischargeOutW(
+ DiagramGenerator generator,
+ ArtifactAndFacet bundle,
+ ThemeDocument theme,
+ boolean visible
+ ) {
+ double value = Double.valueOf(
+ bundle.getData(generator.getCallContext()).toString());
+ generator.addValueMarker(new StyledValueMarker(value, theme), visible);
+ }
+
private void doPointsOut(
DiagramGenerator generator,
double[][] data,
More information about the Dive4Elements-commits
mailing list