view artifacts/src/main/java/org/dive4elements/river/exports/LongitudinalSectionGenerator.java @ 6798:7089f338138a longitudinal-symmetry

Move Funcionality related to bed quality from FlowVelocityGenerator to LongitudinalSectionGenerator (previously left over).
author Tom Gottfried <tom.gottfried@intevation.de>
date Fri, 09 Aug 2013 13:32:47 +0200
parents 23ab795f2f0e
children a1ff1b7e2dee
line wrap: on
line source
/* 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;

import java.util.Arrays;

import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
import org.dive4elements.artifactdatabase.state.Facet;
import org.dive4elements.river.artifacts.D4EArtifact;
import org.dive4elements.river.artifacts.geom.Lines;
import org.dive4elements.river.artifacts.model.AreaFacet;
import org.dive4elements.river.artifacts.model.FacetTypes;
import org.dive4elements.river.artifacts.model.WKms;
import org.dive4elements.river.artifacts.model.WQKms;

import org.dive4elements.river.exports.process.Processor;
import org.dive4elements.river.exports.process.BedDiffHeightYearProcessor;
import org.dive4elements.river.exports.process.BedDiffYearProcessor;
import org.dive4elements.river.exports.process.BedheightProcessor;
import org.dive4elements.river.exports.process.WOutProcessor;

import org.dive4elements.river.artifacts.access.FlowVelocityAccess;
import org.dive4elements.river.artifacts.model.FlowVelocityData;
import org.dive4elements.river.model.FlowVelocityMeasurementValue;
import org.dive4elements.river.artifacts.model.minfo.BedDiameterResult;
import org.dive4elements.river.artifacts.model.minfo.BedloadDiameterResult;

import org.dive4elements.river.jfree.Bounds;
import org.dive4elements.river.jfree.DoubleBounds;
import org.dive4elements.river.jfree.RiverAnnotation;
import org.dive4elements.river.jfree.StyledAreaSeriesCollection;
import org.dive4elements.river.jfree.StyledXYSeries;
import org.dive4elements.river.utils.DataUtil;
import org.dive4elements.river.utils.RiverUtils;
import org.apache.log4j.Logger;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.plot.XYPlot;
import org.jfree.data.xy.XYSeries;
import org.w3c.dom.Document;


/**
 * An OutGenerator that generates longitudinal section curves.
 *
 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
 */
public class LongitudinalSectionGenerator
extends      XYChartGenerator
implements   FacetTypes
{
    public enum YAXIS {
        W(0), // waterlevel
        D(1), // waterlevel-difference
        Q(2), // discharge
        V(3), // flow velocity
        T(4), // tau (shear stress)
        O(3); // diameter
        protected int idx;
        private YAXIS(int c) {
            idx = c;
        }
    }

    /** The logger that is used in this generator. */
    private static Logger logger =
        Logger.getLogger(LongitudinalSectionGenerator.class);

    /** Key to look up internationalized String for annotations label. */
    public static final String I18N_ANNOTATIONS_LABEL =
        "chart.longitudinal.annotations.label";

    /**
     * Key to look up internationalized String for LongitudinalSection diagrams
     * titles.
     */
    /** TODO:
     * create a class which extends this one to avoid following definition here 
     */
    public static final String I18N_CHART_TITLE =
        "chart.longitudinal.section.title";
    public static final String I18N_CHART_TITLE_DEFAULT  = 
	"L\u00e4ngsschnitt";

    /**
     * Key to look up internationalized String for LongitudinalSection diagrams
     * subtitles.
     */
    public static final String I18N_CHART_SUBTITLE =
        "chart.longitudinal.section.subtitle";

    /**
     * Key to look up internationalized String for LongitudinalSection diagrams
     * short subtitles.
     */
    public static final String I18N_CHART_SHORT_SUBTITLE =
        "chart.longitudinal.section.shortsubtitle";

    /**
     * Key to look up internationalized String for LongitudinalSection diagrams
     * X-axis title.
     */
    public static final String I18N_XAXIS_LABEL =
        "chart.longitudinal.section.xaxis.label";
    public static final String I18N_XAXIS_LABEL_DEFAULT  = 
	"km";

    /**
     * Key to look up internationalized String for LongitudinalSection diagrams
     * Y-axis titles.
     */
    public static final String I18N_YAXIS_LABEL_W =
        "chart.longitudinal.section.yaxis.label.w";
    public static final String I18N_YAXIS_LABEL_Q =
        "chart.longitudinal.section.yaxis.label.q";
    public static final String I18N_YAXIS_LABEL_D =
        "chart.w_differences.yaxis.label";
    public static final String I18N_YAXIS_LABEL_V =
        "chart.flow_velocity.section.yaxis.label";
    public static final String I18N_YAXIS_LABEL_T =
        "chart.flow_velocity.section.yaxis.second.label";
    public static final String I18N_YAXIS_LABEL_DEFAULT  = 
	"Y-axis";


    public LongitudinalSectionGenerator() {
        super();
    }


    @Override
    protected YAxisWalker getYAxisWalker() {
        return new YAxisWalker() {
            @Override
            public int length() {
                return YAXIS.values().length;
            }

            @Override
            public String getId(int idx) {
                YAXIS[] yaxes = YAXIS.values();
                return yaxes[idx].toString();
            }
        };
    }


    /**
     * Return left most data points x value (on first axis).
     * Overridden because axis could be inverted.
     */
    @Override
    protected double getLeftX() {
        if (isInverted()) {
            return (Double)getXBounds(0).getUpper();
        }
        return (Double)getXBounds(0).getLower();
    }


    /**
     * Return right most data points x value (on first axis).
     * Overridden because axis could be inverted.
     */
    @Override
    protected double getRightX() {
        if (isInverted()) {
            return (Double)getXBounds(0).getLower();
        }
        return (Double)getXBounds(0).getUpper();
    }


    /**
     * Returns the default title for this chart.
     *
     * @return the default title for this chart.
     */
    @Override
    protected String getDefaultChartTitle() {
        return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT);
    }


    /**
     * Returns the default subtitle for this chart.
     *
     * @return the default subtitle for this chart.
     */
    @Override
    protected String getDefaultChartSubtitle() {
        double[] dist = getRange();

        Object[] args = null;
        if (dist == null) {
            args = new Object[] {getRiverName()};
            return msg(getChartShortSubtitleKey(), "", args);
        }
        args = new Object[] {
            getRiverName(),
            dist[0],
            dist[1]
        };
        return msg(getChartSubtitleKey(), "", args);
    }


    /**
     * Gets key to look up internationalized String for the charts subtitle.
     * @return key to look up translated subtitle.
     */
    protected String getChartSubtitleKey() {
        return I18N_CHART_SUBTITLE;
    }


    /**
     * Gets key to look up internationalized String for the charts short
     * subtitle.
     * @return key to look up translated subtitle.
     */
    protected String getChartShortSubtitleKey() {
        return I18N_CHART_SHORT_SUBTITLE;
    }


    /**
     * Get internationalized label for the x axis.
     */
    @Override
    protected String getDefaultXAxisLabel() {
        D4EArtifact flys = (D4EArtifact) master;

        return msg(
            I18N_XAXIS_LABEL,
            I18N_XAXIS_LABEL_DEFAULT,
            new Object[] { RiverUtils.getRiver(flys).getName() });
    }


    /**
     * Get internationalized label for the y axis.
     */
    @Override
    protected String getDefaultYAxisLabel(int index) {

        D4EArtifact flys = (D4EArtifact) master;
        String unit = RiverUtils.getRiver(flys).getWstUnit().getName();

        if (index == YAXIS.W.idx) {
	    return msg(
	        I18N_YAXIS_LABEL_W,
		I18N_YAXIS_LABEL_DEFAULT,
		new Object[] { unit });
        }
        if (index == YAXIS.Q.idx) {
            return msg(
	        I18N_YAXIS_LABEL_Q,
		I18N_YAXIS_LABEL_DEFAULT);
        }
        if (index == YAXIS.D.idx) {
            return msg(
                I18N_YAXIS_LABEL_D, 
		I18N_YAXIS_LABEL_DEFAULT);
        }
        if (index == YAXIS.V.idx) {
            return msg(
                I18N_YAXIS_LABEL_V, 
		I18N_YAXIS_LABEL_DEFAULT);
        }
        if (index == YAXIS.T.idx) {
            return msg(
                I18N_YAXIS_LABEL_T, 
		I18N_YAXIS_LABEL_DEFAULT);
        }

        return "default";
    }


    /**
     * Create Axis for given index.
     * @return axis with according internationalized label.
     */
    @Override
    protected NumberAxis createYAxis(int index) {
        NumberAxis axis = super.createYAxis(index);

        // "Q" Axis shall include 0.
        if (index == YAXIS.Q.idx) {
            axis.setAutoRangeIncludesZero(true);
        }
        else {
            axis.setAutoRangeIncludesZero(false);
        }

        return axis;
    }


    /**
     * Trigger inversion.
     */
    @Override
    protected void adjustAxes(XYPlot plot) {
        super.adjustAxes(plot);
        invertXAxis(plot.getDomainAxis());
    }


    /**
     * This method inverts the x-axis based on the kilometer information of the
     * selected river. If the head of the river is at kilometer 0, the axis is
     * not inverted, otherwise it is.
     *
     * @param xaxis The domain axis.
     */
    protected void invertXAxis(ValueAxis xaxis) {
        if (isInverted()) {
            logger.debug("X-Axis.setInverted(true)");
            xaxis.setInverted(true);
        }
    }


    /**
     * Produce output.
     * @param artifactAndFacet current facet and artifact.
     * @param attr  theme for facet
     */
    @Override
    public void doOut(
        ArtifactAndFacet artifactAndFacet,
        Document         attr,
        boolean          visible
    ) {
        String name = artifactAndFacet.getFacetName();

        logger.debug("LongitudinalSectionGenerator.doOut: " + name);

        if (name == null) {
            logger.error("No facet name for doOut(). No output generated!");
            return;
        }

        Facet facet = artifactAndFacet.getFacet();

        if (facet == null) {
            return;
        }

        WOutProcessor wProcessor = new WOutProcessor();
        Processor bedp = new BedheightProcessor();
        Processor bdyProcessor = new BedDiffYearProcessor();
        Processor bdhyProcessor = new BedDiffHeightYearProcessor();

        if (wProcessor.canHandle(name)) {
            wProcessor.doOut(this, artifactAndFacet, attr, visible, YAXIS.W.idx);
        }
        else if (bedp.canHandle(name)) {
           bedp.doOut(this, artifactAndFacet, attr, visible, YAXIS.W.idx);
        }
        else if (bdyProcessor.canHandle(name)) {
           bdyProcessor.doOut(this, artifactAndFacet, attr, visible, YAXIS.W.idx);
        }
        else if (bdhyProcessor.canHandle(name)) {
           bdhyProcessor.doOut(this, artifactAndFacet, attr, visible, YAXIS.W.idx);
        }
        else if (name.equals(LONGITUDINAL_Q)) {
            doQOut(
                (WQKms) artifactAndFacet.getData(context),
                artifactAndFacet,
                attr,
                visible);
        }
        else if (name.equals(LONGITUDINAL_ANNOTATION)) {
            doAnnotations(
                (RiverAnnotation) artifactAndFacet.getData(context),
                 artifactAndFacet,
                 attr,
                 visible);
        }
        else if (name.equals(STATIC_WQKMS_Q)) {
            doQOut(
                (WQKms) artifactAndFacet.getData(context),
                artifactAndFacet,
                attr,
                visible);
        }
        else if (name.equals(W_DIFFERENCES)) {
            doWDifferencesOut(
                (WKms) artifactAndFacet.getData(context),
                artifactAndFacet,
                attr,
                visible);
        }
        else if (FacetTypes.IS.AREA(name)) {
            doArea(
                artifactAndFacet.getData(context),
                artifactAndFacet,
                attr,
                visible);
        }
        else if (FacetTypes.IS.MANUALPOINTS(name)) {
            doPoints(
                artifactAndFacet.getData(context),
                artifactAndFacet,
                attr,
                visible,
                YAXIS.W.idx);
        }

	/* output for flow velocity */
        if (getXBounds(0) != null && getDomainAxisRange() != null) {
            logger.debug(Arrays.toString(getDomainAxisRangeFromRequest()));
            Bounds bounds =
                calculateZoom(getXBounds(0), getDomainAxisRange());
            context.putContextValue("startkm", bounds.getLower());
            context.putContextValue("endkm", bounds.getUpper());
        }
        else if (getXBounds(0) != null && getDomainAxisRange() == null) {
            context.putContextValue("startkm", getXBounds(0).getLower());
            context.putContextValue("endkm", getXBounds(0).getUpper());
        }
        else if (getXBounds(0) == null && getDomainAxisRange() == null) {
            D4EArtifact artifact = (D4EArtifact)artifactAndFacet.getArtifact();
            FlowVelocityAccess access = new FlowVelocityAccess(artifact);
            context.putContextValue("startkm", access.getLowerKM());
            context.putContextValue("endkm", access.getUpperKM());
        }
        else if (getXBounds(0) == null && getDomainAxisRange() != null){
            D4EArtifact artifact = (D4EArtifact)artifactAndFacet.getArtifact();
            FlowVelocityAccess access = new FlowVelocityAccess(artifact);
            Bounds b = new DoubleBounds(access.getLowerKM(), access.getUpperKM());
            Bounds bounds =
                calculateZoom(b, getDomainAxisRange());
            context.putContextValue("startkm", bounds.getLower());
            context.putContextValue("endkm", bounds.getUpper());
        }
        if (name.equals(FLOW_VELOCITY_MAINCHANNEL)) {
            doMainChannelOut(
                (FlowVelocityData) artifactAndFacet.getData(context),
                artifactAndFacet,
                attr,
                visible);
        }
        else if (name.equals(FLOW_VELOCITY_TOTALCHANNEL)) {
            doTotalChannelOut(
                (FlowVelocityData) artifactAndFacet.getData(context),
                artifactAndFacet,
                attr,
                visible);
        }
        else if (name.equals(FLOW_VELOCITY_MAINCHANNEL_FILTERED)) {
            doMainChannelOut(
                (FlowVelocityData) artifactAndFacet.getData(context),
                artifactAndFacet,
                attr,
                visible);
        }
        else if (name.equals(FLOW_VELOCITY_TOTALCHANNEL_FILTERED)) {
            doTotalChannelOut(
                (FlowVelocityData) artifactAndFacet.getData(context),
                artifactAndFacet,
                attr,
                visible);
        }
        else if (name.equals(FLOW_VELOCITY_DISCHARGE)) {
            doQOut(
                (FlowVelocityData) artifactAndFacet.getData(context),
                artifactAndFacet,
                attr,
                visible);
        }
        else if (name.equals(FLOW_VELOCITY_TAU)) {
            doTauOut(
                (FlowVelocityData) artifactAndFacet.getData(context),
                artifactAndFacet,
                attr,
                visible);
        }
        else if (name.equals(FLOW_VELOCITY_TAU_FILTERED)) {
            doTauOut(
                (FlowVelocityData) artifactAndFacet.getData(context),
                artifactAndFacet,
                attr,
                visible);
        }
        else if (name.equals(FLOW_VELOCITY_MEASUREMENT)) {
            doVPointOut(
                 artifactAndFacet.getData(context),
                 artifactAndFacet,
                 attr,
                 visible);
        }
	else if (name.equals(BED_QUALITY_BED_DIAMETER_SUBLAYER)) {
	    doBedQualitySubLayerOut(
                (BedDiameterResult)artifactAndFacet.getData(context),
		artifactAndFacet,
		attr,
		visible);
	}
	else if (name.equals(BED_QUALITY_BED_DIAMETER_TOPLAYER)) {
	    doBedQualityTopLayerOut(
	        (BedDiameterResult)artifactAndFacet.getData(context),
		artifactAndFacet,
		attr,
		visible);
	}
	else if (name.equals(BED_QUALITY_BEDLOAD_DIAMETER)) {
	    doBedQualityLoadDiameter(
		(BedloadDiameterResult)artifactAndFacet.getData(context),
		artifactAndFacet,
		attr,
		visible);
	}

        else {
            logger.warn("Unknown facet name: " + name);
            return;
        }
    }

    /**
     * Add items to dataseries which describes the differences.
     */
    protected void doWDifferencesOut(
        WKms       wkms,
        ArtifactAndFacet aandf,
        Document   theme,
        boolean    visible
    ) {
        logger.debug("WDifferencesCurveGenerator.doWDifferencesOut");
        if (wkms == null) {
            logger.warn("No data to add to WDifferencesChart.");
            return;
         }

        XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);

        if (logger.isDebugEnabled()) {
            if (wkms.size() > 0) {
                logger.debug("Generate series: " + series.getKey());
                logger.debug("Start km: " + wkms.getKm(0));
                logger.debug("End   km: " + wkms.getKm(wkms.size() - 1));
                logger.debug("Values  : " + wkms.size());
            }
        }

        StyledSeriesBuilder.addPoints(series, wkms);

        addAxisSeries(series, YAXIS.D.idx, visible);
        if (DataUtil.guessWaterIncreasing(wkms.allWs())) {
            setInverted(true);
        }
    }


    /**
     * Process the output for Q facets in a longitudinal section curve.
     *
     * @param wqkms An array of WQKms values.
     * @param aandf The facet and artifact. This facet does NOT support any data objects. Use
     * D4EArtifact.getNativeFacet() instead to retrieve a Facet which supports
     * data.
     * @param theme The theme that contains styling information.
     * @param visible The visibility of the curve.
     */
    protected void doQOut(
        WQKms    wqkms,
        ArtifactAndFacet aandf,
        Document theme,
        boolean  visible
    ) {
        logger.debug("LongitudinalSectionGenerator.doQOut");

        XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);

        StyledSeriesBuilder.addStepPointsKmQ(series, wqkms);

        addAxisSeries(series, YAXIS.Q.idx, visible);

        if (needInvertAxis(wqkms)) {
            setInverted(true);
        }
    }

    /**
     * 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 boolean needInvertAxis(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);
        }

        return inv;
    }


    /**
     * Get name of series (displayed in legend).
     * @return name of the series.
     */
    protected String getSeriesName(WQKms wqkms, String mode) {
        String name   = wqkms.getName();
        String prefix = name != null && name.indexOf(mode) >= 0 ? null : mode;

        return prefix != null && prefix.length() > 0
            ? prefix + "(" + name +")"
            : name;
    }


    /** Look up the axis identifier for a given facet type. */
    public int axisIdxForFacet(String facetName) {
        if (FacetTypes.IS.W(facetName)) {
            return YAXIS.W.idx;
        }
        else if (FacetTypes.IS.Q(facetName)) {
            return YAXIS.Q.idx;
        }
        else if (FacetTypes.IS.V(facetName)) {
            return YAXIS.V.idx;
        }
        else if (FacetTypes.IS.T(facetName)) {
            return YAXIS.T.idx;
        }
        else {
            logger.warn("Could not find axis for facet " + facetName);
            return YAXIS.W.idx;
        }
    }


    /**
     * Do Area out.
     * @param theme styling information.
     * @param visible whether or not visible.
     */
    protected void doArea(
        Object     o,
        ArtifactAndFacet aandf,
        Document   theme,
        boolean    visible
    ) {
        logger.debug("LongitudinalSectionGenerator.doArea");
        StyledAreaSeriesCollection area = new StyledAreaSeriesCollection(theme);

        String seriesName = aandf.getFacetDescription();

        AreaFacet.Data data = (AreaFacet.Data) o;

        XYSeries up   = null;
        XYSeries down = null;

        if (data.getUpperData() != null) {
            up = new StyledXYSeries(seriesName, false, theme);
            if (data.getUpperData() instanceof WQKms) {
                if (FacetTypes.IS.Q(data.getRootFacetName())) {
                    StyledSeriesBuilder.addPointsKmQ(up, (WQKms) data.getUpperData());
                }
                else {
                    StyledSeriesBuilder.addPoints(up, (WKms) data.getUpperData());
                }
            }
            else if (data.getUpperData() instanceof double[][]) {
                StyledSeriesBuilder.addPoints(up, (double [][]) data.getUpperData(), false);
            }
            else if (data.getUpperData() instanceof WKms) {
                StyledSeriesBuilder.addPoints(up, (WKms) data.getUpperData());
            }
            else if (data.getUpperData() instanceof Lines.LineData) {
                StyledSeriesBuilder.addPoints(up, ((Lines.LineData) data.getUpperData()).points, false);
            }
            else {
                logger.error("Do not know how to deal with (up) area info from: "
                    + data.getUpperData());
            }
        }

        // TODO Depending on style, the area (e.g. 20m^2) should be added as annotation.

        if (data.getLowerData() != null) {
            // TODO: Sort this out: when the two series have the same name,
            // the renderer (or anything in between) will not work correctly.
            down = new StyledXYSeries(seriesName + " ", false, theme);
            if (data.getLowerData() instanceof WQKms) {
                if (FacetTypes.IS.Q(data.getRootFacetName())) {
                    StyledSeriesBuilder.addPointsKmQ(down, (WQKms) data.getLowerData());
                }
                else {
                    StyledSeriesBuilder.addPoints(down, (WQKms) data.getLowerData());
                }
            }
            else if (data.getLowerData() instanceof double[][]) {
                StyledSeriesBuilder.addPoints(down, (double[][]) data.getLowerData(), false);
            }
            else if (data.getLowerData() instanceof WKms) {
                StyledSeriesBuilder.addPoints(down, (WKms) data.getLowerData());
            }
            else if (data.getLowerData() instanceof Lines.LineData) {
                StyledSeriesBuilder.addPoints(down, ((Lines.LineData) data.getLowerData()).points, false);
            }
            else {
                logger.error("Do not know how to deal with (down) area info from: "
                    + data.getLowerData());
            }
        }

        if (up == null && down != null) {
            area.setMode(StyledAreaSeriesCollection.FILL_MODE.ABOVE);
            down.setKey(seriesName);
            area.addSeries(down);
            area.addSeries(StyledSeriesBuilder.createGroundAtInfinity(down));
        }
        else if (up != null && down == null) {
            area.setMode(StyledAreaSeriesCollection.FILL_MODE.UNDER);
            area.addSeries(up);
            area.addSeries(StyledSeriesBuilder.createGroundAtInfinity(up));
        }
        else if (up != null && down != null) {
            if (data.doPaintBetween()) {
                area.setMode(StyledAreaSeriesCollection.FILL_MODE.BETWEEN);
            }
            else {
                area.setMode(StyledAreaSeriesCollection.FILL_MODE.ABOVE);
            }
            area.addSeries(up);
            area.addSeries(down);
        }
        // Add area to the respective axis.
        addAreaSeries(area, axisIdxForFacet(data.getRootFacetName()), visible);
    }


    /**
     * flow velocity specific outs
     */

    /**
     * Process the output for flow velocity in main channel in a longitudinal section curve.
     *
     * @param data A FlowVelocityData object
     * @param aandf The facet. This facet does NOT support any data objects. Use
     * D4EArtifact.getNativeFacet() instead to retrieve a Facet which supports
     * data.
     * @param theme The theme that contains styling information.
     * @param visible The visibility of the curve.
     */
    protected void doMainChannelOut(
        FlowVelocityData data,
        ArtifactAndFacet aandf,
        Document         theme,
        boolean          visible
    ) {
        logger.debug("FlowVelocityGenerator.doMainChannelOut");

        XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);

        StyledSeriesBuilder.addPoints(series, data.getMainChannelPoints(), true);

        addAxisSeries(series, YAXIS.V.idx, visible);
    }

    /**
     * Process the output for flow velocity in total channel in a longitudinal section curve.
     */
    protected void doTotalChannelOut(
        FlowVelocityData data,
        ArtifactAndFacet aandf,
        Document         theme,
        boolean          visible
    ) {
        logger.debug("FlowVelocityGenerator.doTotalChannelOut");

        if (data == null) {
            logger.warn("No data to add to FlowVelocity chart.");
            return;
         }

        XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);

        StyledSeriesBuilder.addPoints(series, data.getTotalChannelPoints(), true);

        addAxisSeries(series, YAXIS.V.idx, visible);
    }

    /**
     * @param data A FlowVelocityData object
     * @param aandf The facet. This facet does NOT support any data objects. Use
     * D4EArtifact.getNativeFacet() instead to retrieve a Facet which supports
     * data.
     * @param theme The theme that contains styling information.
     * @param visible The visibility of the curve.
     */
    protected void doTauOut(
        FlowVelocityData data,
        ArtifactAndFacet aandf,
        Document         theme,
        boolean          visible
    ) {
        logger.debug("FlowVelocityGenerator.doTauOut");

        XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);

        StyledSeriesBuilder.addPoints(series, data.getTauPoints(), true);

        addAxisSeries(series, YAXIS.T.idx, visible);
    }

    protected void doVPointOut (
        Object data,
        ArtifactAndFacet aandf,
        Document         theme,
        boolean          visible
    ) {
        logger.debug("FlowVelocityGenerator.doVPointOut");

        XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);

        FlowVelocityMeasurementValue.FastFlowVelocityMeasurementValue
            value = (FlowVelocityMeasurementValue.FastFlowVelocityMeasurementValue)
                data;

        StyledSeriesBuilder.addPoints(series, new double[][] {{value.getStation()},{value.getV()}}, true);

        addAxisSeries(series, YAXIS.V.idx, visible);
    }

    /**
     * @param data A FlowVelocityData object
     * @param aandf The facet. This facet does NOT support any data objects. Use
     * D4EArtifact.getNativeFacet() instead to retrieve a Facet which supports
     * data.
     * @param theme The theme that contains styling information.
     * @param visible The visibility of the curve.
     */
    protected void doQOut(
        FlowVelocityData data,
	ArtifactAndFacet aandf,
	Document         theme,
        boolean          visible
	) {
	logger.debug("FlowVelocityGenerator.doTauOut");

	XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
	
	StyledSeriesBuilder.addPoints(series, data.getQPoints(), true);

	addAxisSeries(series, YAXIS.Q.idx, visible);
	}

    private void doBedQualityLoadDiameter(
        BedloadDiameterResult data,
        ArtifactAndFacet aandf,
        Document attr,
        boolean visible) {
        XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), attr);
        StyledSeriesBuilder.addPoints(series, data.getDiameterData(), true);

        addAxisSeries(series, YAXIS.D.idx, visible);
    }


    private void doBedQualityTopLayerOut(
        BedDiameterResult data,
        ArtifactAndFacet aandf,
        Document attr,
        boolean visible) {
        XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), attr);
        StyledSeriesBuilder.addPoints(series, data.getDiameterSubData(), true);
        addAxisSeries(series, YAXIS.D.idx, visible);
    }


    private void doBedQualitySubLayerOut(
        BedDiameterResult data,
        ArtifactAndFacet aandf,
        Document attr,
        boolean visible
    ) {
        logger.debug("Do beddiametersubout");
        XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), attr);
        StyledSeriesBuilder.addPoints(series, data.getDiameterSubData(), true);
        addAxisSeries(series, YAXIS.D.idx, visible);
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org