Example usage for org.jfree.chart.plot RingPlot setBackgroundPaint

List of usage examples for org.jfree.chart.plot RingPlot setBackgroundPaint

Introduction

In this page you can find the example usage for org.jfree.chart.plot RingPlot setBackgroundPaint.

Prototype

public void setBackgroundPaint(Paint paint) 

Source Link

Document

Sets the background color of the plot area and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:Visuals.RingChart.java

public ChartPanel drawRingChart() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    if (riskCount == 0) {
        dataset.setValue(noVulnerabilities, new Integer(1));
    } else {// ww w.  ja v a2s  . c o m
        if (critical > 0)
            dataset.setValue(criticalValue, new Integer(critical));
        if (low > 0)
            dataset.setValue(lowValue, new Integer(low));
        if (medium > 0)
            dataset.setValue(mediumValue, new Integer(medium));
        if (high > 0)
            dataset.setValue(highValue, new Integer(high));

    }

    RingPlot plot = new RingPlot(dataset);
    //plot.setLabelGenerator(new StandardPieSectionLabelGenerator(locale));
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    //        if (tooltips) {
    //            plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale));
    //        }
    if (riskCount == 0) {
        plot.setSectionPaint(noVulnerabilities, new Color(47, 196, 6));
    } else {
        plot.setSectionPaint(criticalValue, new Color(230, 27, 27));
        plot.setSectionPaint(highValue, new Color(230, 90, 27));
        plot.setSectionPaint(mediumValue, new Color(85, 144, 176));
        if (lowValue.equals("Updated (" + low + ")")) {
            plot.setSectionPaint(lowValue, new Color(47, 196, 6));
        } else
            plot.setSectionPaint(lowValue, new Color(230, 219, 27));
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    CategoryItemRenderer renderer = new CustomRenderer();
    renderer.setItemLabelsVisible(false);
    plot.setLabelLinksVisible(false);
    plot.setLabelGenerator(null);
    plot.setBackgroundPaint(new Color(210, 234, 243));
    ChartPanel chartPanel = new ChartPanel(chart);
    return chartPanel;

    //        if(isMain)
    //        {
    //            piechart.removeLegend();
    //        }
}