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

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

Introduction

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

Prototype

public void setLabelGenerator(PieSectionLabelGenerator generator) 

Source Link

Document

Sets the section label generator and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:eu.delving.sip.base.ReportChartHelper.java

public static JComponent createLinkChart(DataSet dataSet, String prefix,
        Map<RecDef.Check, LinkFile.LinkStats> linkStatsMap) {
    JPanel p = new JPanel(new GridLayout(0, 1));
    for (Map.Entry<RecDef.Check, LinkFile.LinkStats> entry : linkStatsMap.entrySet()) {
        JPanel pp = new JPanel(new GridLayout(1, 0));
        pp.setBorder(BorderFactory.createTitledBorder(entry.getKey().toString()));
        for (Map.Entry<String, PieDataset> datasetEntry : entry.getValue().createPies().entrySet()) {
            JFreeChart chart = ChartFactory.createRingChart(datasetEntry.getKey(), datasetEntry.getValue(),
                    true, false, Locale.getDefault());
            RingPlot plot = (RingPlot) chart.getPlot();
            plot.setLabelGenerator(null);
            plot.setNoDataMessage("No data available");
            plot.setSectionDepth(0.34999999999999998D);
            plot.setCircular(true);// w ww  . ja  v a2s .com
            plot.setLabelGap(0.02D);
            pp.add(new ChartPanel(chart));
        }
        p.add(pp);
    }
    return p;
}

From source file:org.hxzon.demo.jfreechart.PieDatasetDemo2.java

private static JFreeChart createRingChart(PieDataset dataset) {

    RingPlot plot = new RingPlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator());
    }/* w w  w. j  a  va2  s.  c  o  m*/
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    JFreeChart chart = new JFreeChart("Ring Chart Demo 1", JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    plot.setSectionOutlinesVisible(false);
    plot.setNoDataMessage("No data available");

    return chart;

}

From source file:unikn.dbis.univis.visualization.chart.RingChart.java

/**
 * Makes the plot./*from w  ww . j  a  v a 2 s  .com*/
 */
protected void plot() {
    RingPlot plot = (RingPlot) getChart().getPlot();
    plot.setStartAngle(290);
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setForegroundAlpha(0.5f);
    plot.setNoDataMessage("No data available");
    plot.setLabelGenerator(null);
    plot.setLegendLabelGenerator(new LabelGenerator(createTotal()));
}

From source file:edu.dlnu.liuwenpeng.ChartFactory.ChartFactory.java

/**    
* Creates a ring chart with default settings.    
* <P>    /*from  www.  j  a v  a  2 s . co m*/
* The chart object returned by this method uses a {@link RingPlot}     
* instance as the plot.    
*    
* @param title  the chart title (<code>null</code> permitted).    
* @param dataset  the dataset for the chart (<code>null</code> permitted).    
* @param legend  a flag specifying whether or not a legend is required.    
* @param tooltips  configure chart to generate tool tips?    
* @param locale  the locale (<code>null</code> not permitted).    
*    
* @return A ring chart.    
*     
* @since 1.0.7    
*/
public static JFreeChart createRingChart(String title, PieDataset dataset, boolean legend, boolean tooltips,
        Locale locale) {

    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));
    }
    return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);

}

From source file:edu.dlnu.liuwenpeng.ChartFactory.ChartFactory.java

/**    
* Creates a ring chart with default settings.    
* <P>    /* w ww .  ja v a  2  s .co  m*/
* The chart object returned by this method uses a {@link RingPlot}     
* instance as the plot.    
*    
* @param title  the chart title (<code>null</code> permitted).    
* @param dataset  the dataset for the chart (<code>null</code> permitted).    
* @param legend  a flag specifying whether or not a legend is required.    
* @param tooltips  configure chart to generate tool tips?    
* @param urls  configure chart to generate URLs?    
*    
* @return A ring chart.    
*/
public static JFreeChart createRingChart(String title, PieDataset dataset, boolean legend, boolean tooltips,
        boolean urls) {

    RingPlot plot = new RingPlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator());
    }
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);

}

From source file:KIDLYFactory.java

/**
 * Creates a ring chart with default settings.
 * <P>//from   w ww  .  jav  a2s .  com
 * The chart object returned by this method uses a {@link RingPlot}
 * instance as the plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param locale  the locale (<code>null</code> not permitted).
 *
 * @return A ring chart.
 *
 * @since 1.0.7
 */
public static JFreeChart createRingChart(String title, PieDataset dataset, boolean legend, boolean tooltips,
        Locale locale) {

    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));
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    currentTheme.apply(chart);
    return chart;
}

From source file:KIDLYFactory.java

/**
 * Creates a ring chart with default settings.
 * <P>//from   w  w w . jav  a2  s . co  m
 * The chart object returned by this method uses a {@link RingPlot}
 * instance as the plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A ring chart.
 */
public static JFreeChart createRingChart(String title, PieDataset dataset, boolean legend, boolean tooltips,
        boolean urls) {

    RingPlot plot = new RingPlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator());
    }
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    currentTheme.apply(chart);
    return chart;

}

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   ww w  .  j a  va 2s .  c  o  m*/
        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 {//from   ww  w  .  jav a2 s.  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();
    //        }
}

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 {//from   w  w  w .j  a  va 2s.  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);
}