[Dive4elements-commits] [PATCH 11 of 13] Add processor to be able to generate curves for WKms values
Wald Commits
scm-commit at wald.intevation.org
Wed Nov 7 15:58:45 CET 2012
# HG changeset patch
# User Björn Ricks <bjoern.ricks at intevation.de>
# Date 1352299945 -3600
# Node ID a5993b69439bcae04f40c064fab3e7213bf0fa6f
# Parent 05a54b4d579d32d81a45c2e0a20dee9a6313f6e5
Add processor to be able to generate curves for WKms values
diff -r 05a54b4d579d -r a5993b69439b flys-artifacts/src/main/java/de/intevation/flys/exports/process/WOutProcessor.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/process/WOutProcessor.java Wed Nov 07 15:52:25 2012 +0100
@@ -0,0 +1,113 @@
+package de.intevation.flys.exports.process;
+
+import org.apache.log4j.Logger;
+import org.jfree.data.xy.XYSeries;
+import org.w3c.dom.Document;
+
+import de.intevation.artifactdatabase.state.ArtifactAndFacet;
+import de.intevation.artifacts.CallContext;
+import de.intevation.flys.artifacts.model.FacetTypes;
+import de.intevation.flys.artifacts.model.WKms;
+import de.intevation.flys.exports.StyledSeriesBuilder;
+import de.intevation.flys.exports.XYChartGenerator;
+import de.intevation.flys.jfree.StyledAreaSeriesCollection;
+import de.intevation.flys.jfree.StyledXYSeries;
+import de.intevation.flys.utils.DataUtil;
+import de.intevation.flys.utils.ThemeUtil;
+
+/**
+ * @author <a href="mailto:bjoern.ricks at intevation.de">Björn Ricks</a>
+ */
+public class WOutProcessor implements Processor {
+
+ private static final Logger logger =
+ Logger.getLogger(WOutProcessor.class);
+
+ @Override
+ public void doOut(
+ XYChartGenerator generator,
+ ArtifactAndFacet aaf,
+ Document theme,
+ boolean visible,
+ int index)
+ {
+ CallContext context = generator.getCallContext();
+ WKms wkms = (WKms) aaf.getData(context);
+
+ logger.debug("doOut");
+
+ XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme);
+
+ StyledSeriesBuilder.addPoints(series, wkms);
+ generator.addAxisSeries(series, index, visible);
+
+ // If a "band around the curve shall be drawn, add according area.
+ double bandWidth = ThemeUtil.parseBandWidth(theme);
+ if (bandWidth > 0 ) {
+ XYSeries seriesDown = new StyledXYSeries(
+ "band " + aaf.getFacetDescription(), false, theme);
+ XYSeries seriesUp = new StyledXYSeries(
+ aaf.getFacetDescription()+"+/-"+bandWidth, false, theme);
+ StyledSeriesBuilder.addUpperBand(seriesUp, wkms, bandWidth);
+ StyledSeriesBuilder.addLowerBand(seriesDown, wkms, bandWidth);
+
+ StyledAreaSeriesCollection area = new StyledAreaSeriesCollection(theme);
+ area.addSeries(seriesUp);
+ area.addSeries(seriesDown);
+ area.setMode(StyledAreaSeriesCollection.FILL_MODE.BETWEEN);
+ generator.addAreaSeries(area, index, visible);
+ }
+
+ invertAxis(generator, wkms);
+ }
+
+ /**
+ * Returns true if facettype is longitutinal_section.w
+ */
+ @Override
+ public boolean canHandle(String facettype) {
+ if (facettype == null) {
+ return false;
+ }
+
+ if (facettype.equals(FacetTypes.LONGITUDINAL_W)
+ || facettype.equals(FacetTypes.STATIC_WKMS)
+ || facettype.equals(FacetTypes.HEIGHTMARKS_POINTS)
+ || facettype.equals(FacetTypes.STATIC_WQKMS)
+ || facettype.equals(FacetTypes.STATIC_WQKMS_W)
+ || facettype.equals(FacetTypes.DISCHARGE_LONGITUDINAL_W))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * This method determines - taking JFreeCharts auto x value ordering into
+ * account - if the x axis need to be inverted. Waterlines in these charts
+ * should decrease.
+ *
+ * @param wkms The data object that stores the x and y values used for this
+ * chart.
+ */
+ public void invertAxis(XYChartGenerator generator, WKms wkms) {
+ boolean wsUp = wkms.guessWaterIncreasing();
+ boolean kmUp = DataUtil.guessWaterIncreasing(wkms.allKms());
+ boolean inv = (wsUp && kmUp) || (!wsUp && !kmUp);
+
+ int size = wkms.size();
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("(Wkms)Values : " + size);
+ if (size > 0) {
+ logger.debug("Start km: " + wkms.getKm(0));
+ logger.debug("End km: " + wkms.getKm(size-1));
+ }
+ logger.debug("wsUp: " + wsUp);
+ logger.debug("kmUp: " + kmUp);
+ logger.debug("inv: " + inv);
+ }
+ generator.setInverted(inv);
+ }
+
+}
More information about the Dive4elements-commits
mailing list