view gnv-artifacts/src/main/java/de/intevation/gnv/chart/DefaultHistogram.java @ 628:bfe33e658576

Added XSLT sheet to transform palette xml files into a style definition template used for mapfile generation. gnv-artifacts/trunk@703 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 23 Feb 2010 15:50:15 +0000
parents 65f09139e9b3
children d08b9ba148c5
line wrap: on
line source
package de.intevation.gnv.chart;

import org.apache.log4j.Logger;

import org.jfree.chart.ChartTheme;

import org.jfree.chart.plot.XYPlot;

import org.jfree.data.statistics.HistogramDataset;

/**
 * @author Ingo Weinzierl (ingo.weinzierl@intevation.de)
 */
public class DefaultHistogram
extends      AbstractHistogram
{
    // TODO take a better default value
    public static final int DEFAULT_BINS = 15;

    private static Logger logger = Logger.getLogger(DefaultHistogram.class);


    public DefaultHistogram(
        ChartLabels labels, Object[] data, ChartTheme theme
    ) {
        super(labels, data, theme);
    }


    protected void applyDatasets() {
        XYPlot plot = (XYPlot) chart.getPlot();

        // prepare data and create add them to histogram dataset
        String   name   = (String)   data[0];
        double[] values = toDouble((Double[]) data[1]);

        HistogramDataset dataset = new HistogramDataset();
        dataset.addSeries(name, values, DEFAULT_BINS);

        plot.setDataset(0, dataset);
    }


    protected double[] toDouble(Double[] array) {
        int length      = array.length;
        double[] values = new double[length];

        for(int i = 0; i < length; i++) {
            values[i] = array[i].doubleValue();
        }

        return values;
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org