view flys-artifacts/src/main/java/de/intevation/flys/exports/WDifferencesCurveGenerator.java @ 3809:cc83b8e42dbe

Picked rev3347-rev3351 from trunk. flys-artifacts/tags/pre2.6-2011-12-05@3352 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 05 Dec 2011 09:48:44 +0000
parents 65f9d707caff
children 156304542edf
line wrap: on
line source
package de.intevation.flys.exports;

import org.apache.log4j.Logger;

import org.jfree.chart.title.TextTitle;

import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.XYPlot;

import de.intevation.flys.artifacts.model.FacetTypes;
import de.intevation.flys.artifacts.model.WKms;


/**
 * An OutGenerator that generates w differences curves.
 */
public class WDifferencesCurveGenerator
extends      LongitudinalSectionGenerator
implements   FacetTypes
{
    public enum YAXIS {
        W(0),
        D(1),
        Q(2);
        protected int idx;
        private YAXIS(int c) {
           idx = c;
        }
    }

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

    /** Key for internationalized title of WDiff charts. */
    public final static String I18N_WDIFF_TITLE = "chart.w_differences.title";

    /** Default for internationalized title (when no translation found). */
    public final static String I18N_WDIFF_TITLE_DEFAULT = "Differences";

    public final static String I18N_WDIFF_SUBTITLE =
        "chart.w_differences.subtitle";


    /**
     * Get internationalized title for chart.
     * @return internationalized Chart title.
     */
    @Override
    public String getChartTitle() {
        return msg(I18N_WDIFF_TITLE, I18N_WDIFF_TITLE_DEFAULT);
    }


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


    /**
     * Add (internationalized) subtitle to chart.
     * Overridden to avoid trying to access the range of masterartifact.
     * @see getChartSubtitleKey
     */
    @Override
    protected void addSubtitles(JFreeChart chart) {

        // TODO i18n
        /*
        Object[] args = new Object[] {
            getRiverName()
        };
        */
        String subtitle = getRiverName();
        chart.addSubtitle(new TextTitle(subtitle));
    }


    /**
     * 
     */
    @Override
    public JFreeChart generateChart() {
        JFreeChart chart = super.generateChart();
        if (chart != null && chart.getPlot() != null) {
            XYPlot plot = (XYPlot) chart.getPlot();
            plot.setRangeZeroBaselineVisible(true);
        }
        return chart;
    }


    /**
     * Get name of series (displayed in legend).
     * @return name of the series.
     */
    protected String getSeriesName(WKms 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;
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org