Example usage for org.jfree.chart.renderer.category CategoryItemRenderer getLegendItems

List of usage examples for org.jfree.chart.renderer.category CategoryItemRenderer getLegendItems

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.category CategoryItemRenderer getLegendItems.

Prototype

public LegendItemCollection getLegendItems();

Source Link

Document

Returns a (possibly empty) collection of legend items.

Usage

From source file:de.fub.maps.project.plugins.tasks.eval.Barchart.java

public Barchart() {
    setLayout(new BorderLayout());
    plot = new CategoryPlot() {
        private static final long serialVersionUID = 1L;

        @Override/*from  w ww .ja  v  a2s .  c o  m*/
        public LegendItemCollection getLegendItems() {

            CategoryItemRenderer renderer = getRenderer(0);
            return renderer.getLegendItems();
        }
    };
    plot.setRangeAxis(new NumberAxis());
    plot.setDomainAxis(new CategoryAxis());
    plot.getDomainAxis().setMaximumCategoryLabelLines(3);
    plot.getDomainAxis().setCategoryLabelPositionOffset(5);
    plot.setDataset(dataset);
    plot.setOrientation(PlotOrientation.VERTICAL);
    chart = new JFreeChart(null, null, plot, true);
    chart.setBackgroundPaint(Color.white);
    BarRenderer renderer = new BarRenderer();
    renderer.setBarPainter(new StandardBarPainter());
    renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    renderer.setAutoPopulateSeriesFillPaint(true);
    renderer.setAutoPopulateSeriesPaint(true);
    renderer.setShadowVisible(false);
    renderer.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator());
    plot.setRenderer(renderer);
    plot.setBackgroundPaint(Color.white);
    chartPanel = new ChartPanel(chart, false);
    chartPanel.setBackground(Color.white);
    add(chartPanel, BorderLayout.CENTER);
}