view flys-artifacts/src/main/java/de/intevation/flys/exports/HistoricalDischargeCurveGenerator.java @ 2215:ebbb18ed78c4

Added new classes and stubs used to calculate data for historical discharge curve charts. flys-artifacts/trunk@3854 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 01 Feb 2012 11:14:24 +0000
parents
children 958a10e2e246
line wrap: on
line source
package de.intevation.flys.exports;

import java.awt.Font;

import org.w3c.dom.Document;

import org.apache.log4j.Logger;

import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;

import de.intevation.artifactdatabase.state.ArtifactAndFacet;

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


/**
 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
 */
public class HistoricalDischargeCurveGenerator
extends      XYChartGenerator
implements   FacetTypes
{
    private static Logger logger =
        Logger.getLogger(HistoricalDischargeCurveGenerator.class);


    public static enum YAXIS {
        Q(0);
        protected int idx;
        private YAXIS(int c) {
            idx = c;
        }
    }


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


    @Override
    protected String getDefaultChartTitle() {
        return "TODO: CHART TITLE";
    }


    /**
     * Empty (suppress subtitle).
     */
    @Override
    protected void addSubtitles(JFreeChart chart) {
        // this chart has no subtitle
    }


    @Override
    protected String getDefaultXAxisLabel() {
        return "TODO: DEFAULT X AXIS LABEL";
    }

    @Override
    protected String getDefaultYAxisLabel(int pos) {
        return "TODO: DEFAULT Y AXIS LABEL FOR: " + pos;
    }


    /**
     * Creates a new Y-Axis.
     *
     * @param index the index of the Y axis.
     *
     * @return an new NumberAxis with label from <i>getYAxisLabel()</i>.
     */
    @Override
    protected NumberAxis createYAxis(int index) {
        Font labelFont = new Font("Tahoma", Font.BOLD, 14);
        String label   = "default";

        if (index == YAXIS.Q.idx) {
            label = getYAxisLabel(0);
        }

        NumberAxis axis = createNumberAxis(index, label);
        axis.setLabelFont(labelFont);
        axis.setAutoRangeIncludesZero(false);

        return axis;
    }


    public void doOut(
        ArtifactAndFacet artifactFacet,
        Document         theme,
        boolean          visible
    ) {
        String name = artifactFacet.getFacetName();
        logger.debug("HistoricalDischargeCurveGenerator.doOut: " + name);


        if (name.equals(HISTORICAL_DISCHARGE_Q)) {
            doHistoricalDischargeOut(
                (FLYSArtifact) artifactFacet.getArtifact(),
                artifactFacet.getData(context),
                artifactFacet.getFacetDescription(),
                theme,
                visible);
        }
        else {
           logger.warn("doOut(): unknown facet name: " + name);
           return;
        }
    }


    protected void doHistoricalDischargeOut(
        FLYSArtifact artifact,
        Object       data,
        String       desc,
        Document     theme,
        boolean      visible)
    {
        logger.debug("doHistoricalDischargeOut(): description = " + desc);
        logger.warn("TODO IMPLEMENT ME");
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org