[PATCH] Minor refactoring to use processor and later use processor in WINFO-Diagrams
Wald Commits
scm-commit at wald.intevation.org
Mon Jul 15 12:14:49 CEST 2013
# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1373883865 -7200
# Node ID 88b9b666872e9f0d601ec8310e269c3b11cab15c
# Parent 7facf38edc61ff59ef9e20a56bec01c4ab609567
Minor refactoring to use processor and later use processor in WINFO-Diagrams.
diff -r 7facf38edc61 -r 88b9b666872e artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDiffHeightYearGenerator.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDiffHeightYearGenerator.java Mon Jul 15 06:33:51 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDiffHeightYearGenerator.java Mon Jul 15 12:24:25 2013 +0200
@@ -19,6 +19,7 @@
import org.dive4elements.river.artifacts.model.minfo.BedDifferencesResult;
import org.dive4elements.river.exports.StyledSeriesBuilder;
import org.dive4elements.river.exports.fixings.FixChartGenerator;
+import org.dive4elements.river.exports.process.BedDiffYearProcessor;
import org.dive4elements.river.exports.process.KMIndexProcessor;
import org.dive4elements.river.exports.process.Processor;
import org.dive4elements.river.jfree.Bounds;
@@ -95,17 +96,8 @@
}
Processor processor = new KMIndexProcessor();
- if (name.equals(BED_DIFFERENCE_HEIGHT_YEAR)) {
- doBedDifferenceYearOut(
- (BedDiffYearResult) bundle.getData(context),
- bundle, attr, visible);
- }
- else if (name.equals(BED_DIFFERENCE_HEIGHT_YEAR_FILTERED)) {
- doBedDifferenceYearOut(
- (BedDiffYearResult) bundle.getData(context),
- bundle, attr, visible);
- }
- else if (name.equals(LONGITUDINAL_ANNOTATION)) {
+ Processor bdyProcessor = new BedDiffYearProcessor();
+ if (name.equals(LONGITUDINAL_ANNOTATION)) {
doAnnotations(
(RiverAnnotation) bundle.getData(context),
bundle,
@@ -115,6 +107,9 @@
else if (processor.canHandle(name)) {
processor.doOut(this, bundle, attr, visible, YAXIS.dW.idx);
}
+ else if (bdyProcessor.canHandle(name)) {
+ bdyProcessor.doOut(this, bundle, attr, visible, YAXIS.D.idx);
+ }
else {
logger.warn("Unknown facet name " + name);
}
@@ -143,13 +138,4 @@
}
return "default";
}
-
- protected void doBedDifferenceYearOut(BedDiffYearResult data,
- ArtifactAndFacet aandf, Document theme, boolean visible) {
-
- XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
- StyledSeriesBuilder.addPoints(series, data.getHeightPerYearData(), true);
-
- addAxisSeries(series, YAXIS.D.idx, visible);
- }
}
diff -r 7facf38edc61 -r 88b9b666872e artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffYearProcessor.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffYearProcessor.java Mon Jul 15 12:24:25 2013 +0200
@@ -0,0 +1,71 @@
+/* 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.exports.process;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.jfree.data.xy.XYSeries;
+import org.w3c.dom.Document;
+
+import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
+import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.river.artifacts.model.FacetTypes;
+import org.dive4elements.river.artifacts.model.minfo.BedHeightSingle;
+import org.dive4elements.river.artifacts.model.minfo.BedDiffYearResult;
+import org.dive4elements.river.exports.StyledSeriesBuilder;
+import org.dive4elements.river.exports.XYChartGenerator;
+import org.dive4elements.river.jfree.StyledXYSeries;
+import org.dive4elements.river.model.BedHeightSingleValue;
+
+
+public class BedDiffYearProcessor implements Processor, FacetTypes {
+
+ private final static Logger logger =
+ Logger.getLogger(BedDiffYearProcessor.class);
+
+ @Override
+ public void doOut(
+ XYChartGenerator generator,
+ ArtifactAndFacet aandf,
+ Document theme,
+ boolean visible,
+ int index
+ ) {
+ CallContext context = generator.getCallContext();
+ Object data = aandf.getData(context);
+ if (data instanceof BedDiffYearResult) {
+ doBedDifferenceYearOut(
+ generator,
+ (BedDiffYearResult) data,
+ aandf, theme, visible, index);
+ return;
+ }
+ logger.error("Can't process " + data.getClass().getName() + " objects");
+ }
+
+ @Override
+ public boolean canHandle(String facetType) {
+ return BED_DIFFERENCE_HEIGHT_YEAR.equals(facetType)
+ || BED_DIFFERENCE_HEIGHT_YEAR_FILTERED.equals(facetType);
+ }
+
+ protected void doBedDifferenceYearOut(XYChartGenerator generator,
+ BedDiffYearResult data,
+ ArtifactAndFacet aandf,
+ Document theme,
+ boolean visible,
+ int axidx) {
+
+ XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
+ StyledSeriesBuilder.addPoints(series, data.getHeightPerYearData(), true);
+
+ generator.addAxisSeries(series, axidx, visible);
+ }
+}
More information about the Dive4elements-commits
mailing list