view flys-artifacts/src/main/java/de/intevation/flys/exports/WDifferencesCurveGenerator.java @ 4282:8b4988815974

Added marker for Ws and Qs in Historical Discharge WQ charts. Therefore, the XYChartGenerator got two new methods addDomainMarker(Marker, boolean) and addValueMarker(Marker, boolean). The boolean parameters determine, if the marker should be visible or not. This is analogous to addAxisSeries(XYSeries, int, boolean).
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 29 Oct 2012 05:59:27 +0100
parents 3dc26ec2558d
children
line wrap: on
line source
package de.intevation.flys.exports;

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

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


/**
 * 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;
        }
    }

    /** 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";


    @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();
            }
        };
    }


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


    @Override
    protected String getDefaultChartSubtitle() {
        return getRiverName();
    }


    /**
     * 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;
    }


    /**
     *
     */
    @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