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

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

Introduction

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

Prototype

public void setSectionPaint(Comparable key, Paint paint) 

Source Link

Document

Sets the paint associated with the specified key, and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:i2p.bote.web.PeerInfoTag.java

private String createRelayChart(RelayPeer[] relayPeers) throws IOException {
    RingPlot plot;
    if (relayPeers.length == 0) {
        DefaultPieDataset dataset = new DefaultPieDataset();
        dataset.setValue("", 100);

        plot = new RingPlot(dataset);
        plot.setSectionPaint("", Color.gray);
    } else {/*  w w  w .  ja v  a 2 s .c  o  m*/
        int good = 0;
        int untested = 0;
        for (RelayPeer relayPeer : relayPeers) {
            int reachability = relayPeer.getReachability();
            if (reachability == 0)
                untested += 1;
            else if (reachability > 80)
                good += 1;
        }
        int bad = relayPeers.length - good - untested;

        DefaultPieDataset dataset = new DefaultPieDataset();
        if (good > 0)
            dataset.setValue(_t("Good"), good);
        if (bad > 0)
            dataset.setValue(_t("Unreliable"), bad);
        if (untested > 0)
            dataset.setValue(_t("Untested"), untested);

        plot = new RingPlot(dataset);
        plot.setSectionPaint(_t("Good"), Color.green);
        plot.setSectionPaint(_t("Unreliable"), Color.red);
        plot.setSectionPaint(_t("Untested"), Color.orange);
    }
    plot.setLabelGenerator(null);
    plot.setShadowGenerator(null);

    JFreeChart chart = new JFreeChart(_t("Relay Peers:"), JFreeChart.DEFAULT_TITLE_FONT, plot,
            relayPeers.length == 0 ? false : true);
    return ServletUtilities.saveChartAsPNG(chart, 400, 300, null);
}

From source file:i2p.bote.web.PeerInfoTag.java

private String createDhtChart(DhtPeerStats dhtStats) throws IOException {
    RingPlot plot;
    int numDhtPeers = dhtStats.getData().size();
    if (numDhtPeers == 0) {
        DefaultPieDataset dataset = new DefaultPieDataset();
        dataset.setValue("", 100);

        plot = new RingPlot(dataset);
        plot.setSectionPaint("", Color.gray);
    } else {/*from  www .  ja v  a 2s.  c om*/
        int reachable = 0;
        for (List<String> row : dhtStats.getData()) {
            if (_t("No").equals(row.get(4)))
                reachable += 1;
        }
        int unreachable = numDhtPeers - reachable;

        DefaultPieDataset dataset = new DefaultPieDataset();
        if (reachable > 0)
            dataset.setValue(_t("Reachable"), reachable);
        if (unreachable > 0)
            dataset.setValue(_t("Unreachable"), unreachable);

        plot = new RingPlot(dataset);
        plot.setSectionPaint(_t("Reachable"), Color.green);
        plot.setSectionPaint(_t("Unreachable"), Color.red);
    }
    plot.setLabelGenerator(null);
    plot.setShadowGenerator(null);

    JFreeChart dhtChart = new JFreeChart(_t("Kademlia Peers:"), JFreeChart.DEFAULT_TITLE_FONT, plot,
            numDhtPeers == 0 ? false : true);
    return ServletUtilities.saveChartAsPNG(dhtChart, 400, 300, null);
}

From source file:Visuals.RingChart.java

public ChartPanel drawRingChart() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    if (riskCount == 0) {
        dataset.setValue(noVulnerabilities, new Integer(1));
    } else {// w w  w . ja  v  a2s .c  om
        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();
    //        }
}