[PATCH 02 of 13] BedHeightSoundingProcessor: refactored to avoid drifting behavior when using
Wald Commits
scm-commit at wald.intevation.org
Mon Oct 21 11:29:36 CEST 2013
# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1381999804 -7200
# Node ID c4a03db671981c53e71133bfc65d32d2397264fb
# Parent cfac25ad6b3e8669a1a5ec657784f1862c9af1e0
BedHeightSoundingProcessor: refactored to avoid drifting behavior when using
old/new style diagram generators.
diff -r cfac25ad6b3e -r c4a03db67198 artifacts/src/main/java/org/dive4elements/river/exports/process/BedHeightSoundingProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/BedHeightSoundingProcessor.java Thu Oct 17 09:40:12 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/BedHeightSoundingProcessor.java Thu Oct 17 10:50:04 2013 +0200
@@ -40,7 +40,25 @@
ArtifactAndFacet bundle,
ThemeDocument theme,
boolean visible) {
- CallContext context = generator.getCallContext();
+ XYSeries series = prepareSeries(bundle, theme, generator.getCallContext());
+ generator.addAxisSeries(series, axisName, visible);
+ }
+
+ @Override
+ public void doOut(
+ XYChartGenerator generator,
+ ArtifactAndFacet bundle,
+ ThemeDocument theme,
+ boolean visible,
+ int index
+ ) {
+ XYSeries series = prepareSeries(bundle, theme, generator.getCallContext());
+ generator.addAxisSeries(series, index, visible);
+ }
+
+ /** Prepare an series, independent of axis. */
+ private XYSeries prepareSeries(ArtifactAndFacet bundle,
+ ThemeDocument theme, CallContext context) {
Object data = bundle.getData(context);
XYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
theme);
@@ -63,42 +81,9 @@
series.add(bvalue.getStation(), bvalue.getSoundingWidth());
}
}
- generator.addAxisSeries(series, axisName, visible);
+ return series;
}
- @Override
- public void doOut(
- XYChartGenerator generator,
- ArtifactAndFacet bundle,
- ThemeDocument theme,
- boolean visible,
- int index
- ) {
- CallContext context = generator.getCallContext();
- Object data = bundle.getData(context);
- XYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
- theme);
- if (data instanceof BedHeightSingle) {
- BedHeightSingle bData = (BedHeightSingle)data;
- double[] width = bData.getMorphWidths();
- double[] stations = bData.getStations().toNativeArray();
-
- logger.debug("doBedheightSingleOut");
-
- for (int i = 0; i < width.length; i++) {
- series.add(stations[i], width[i], false);
- }
- } else if (data instanceof List<?>) {
- List<BedHeightSingleValue> bData = (List<BedHeightSingleValue>)data;
-
- logger.debug("doBedheightSingleValueOut");
-
- for(BedHeightSingleValue bvalue: bData) {
- series.add(bvalue.getStation(), bvalue.getSoundingWidth());
- }
- }
- generator.addAxisSeries(series, index, visible);
- }
@Override
public boolean canHandle(String facettype) {
More information about the Dive4elements-commits
mailing list