Mercurial > dive4elements > gnv-client
view gnv-artifacts/src/main/java/de/intevation/gnv/chart/DefaultHistogram.java @ 618:250160797195
Added histogram as output mode in configuration files.
gnv-artifacts/trunk@689 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 15 Feb 2010 11:58:47 +0000 |
parents | 3d13fa281a7e |
children | 65f09139e9b3 |
line wrap: on
line source
package de.intevation.gnv.chart; import java.util.Locale; import org.apache.log4j.Logger; import org.jfree.chart.ChartTheme; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYBarRenderer; import org.jfree.data.general.Dataset; 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 :