ingo@617: package de.intevation.gnv.chart; ingo@617: ingo@617: import java.util.Locale; ingo@617: ingo@617: import org.apache.log4j.Logger; ingo@617: ingo@617: import org.jfree.chart.ChartFactory; ingo@617: import org.jfree.chart.ChartTheme; ingo@617: import org.jfree.chart.JFreeChart; ingo@617: ingo@617: import org.jfree.chart.plot.PlotOrientation; ingo@617: import org.jfree.chart.plot.XYPlot; ingo@617: sascha@623: import org.jfree.chart.renderer.xy.XYBarRenderer; ingo@617: ingo@617: /** ingo@617: * @author Ingo Weinzierl (ingo.weinzierl@intevation.de) ingo@617: */ ingo@617: public abstract class AbstractHistogram ingo@617: implements Chart ingo@617: { ingo@617: private Logger logger = Logger.getLogger(AbstractHistogram.class); ingo@617: ingo@617: protected JFreeChart chart; ingo@617: protected ChartLabels labels; ingo@617: protected ChartTheme theme; ingo@617: protected Object[] data; ingo@617: ingo@617: protected Locale locale; ingo@617: ingo@617: ingo@617: public AbstractHistogram( ingo@617: ChartLabels labels, Object[] data, ChartTheme theme ingo@617: ) { ingo@617: this.labels = labels; ingo@617: this.data = data; ingo@617: this.theme = theme; ingo@617: } ingo@617: ingo@617: ingo@617: public JFreeChart generateChart() { ingo@617: ingo@617: if (chart != null) ingo@617: return chart; ingo@617: ingo@617: chart = ChartFactory.createHistogram( ingo@617: labels.getTitle(), ingo@617: labels.getDomainAxisLabel(), ingo@617: labels.getRangeAxisLabel(), ingo@617: null, ingo@617: PlotOrientation.VERTICAL, ingo@617: true, ingo@617: false, ingo@617: false); ingo@617: ingo@617: applyDatasets(); ingo@617: ingo@617: theme.apply(chart); ingo@617: adjustPlot(); ingo@617: ingo@617: return chart; ingo@617: } ingo@617: ingo@617: ingo@617: protected void adjustPlot() { ingo@617: XYPlot plot = (XYPlot) chart.getPlot(); ingo@617: XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); ingo@617: ingo@617: renderer.setShadowVisible(false); ingo@617: renderer.setSeriesVisibleInLegend(0, false); ingo@617: } ingo@617: ingo@617: ingo@617: protected abstract void applyDatasets(); ingo@617: } ingo@617: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :