Example usage for org.jfree.chart.plot PiePlot setLabelFont

List of usage examples for org.jfree.chart.plot PiePlot setLabelFont

Introduction

In this page you can find the example usage for org.jfree.chart.plot PiePlot setLabelFont.

Prototype

public void setLabelFont(Font font) 

Source Link

Document

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

Usage

From source file:com.thalesgroup.hudson.plugins.klocwork.graph.KloPieChart.java

protected JFreeChart createGraph() {

    JFreeChart chart = ChartFactory.createPieChart(null, dataset, true, true, false);
    chart.setBackgroundPaint(Color.white);

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setDataset(dataset);//  w  w w . j a  v  a  2 s .c o  m
    plot.setOutlinePaint(null);
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.setNoDataMessage("No Klocwork data found.");
    plot.setCircular(false);
    plot.setLabelGap(0.02);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{1}"));

    // Set colours
    //plot.setOutlinePaint("New", new Color(200, 0, 0));
    int i = 0;
    if (kloConfig.getBuildGraph().isNeww() && kloReport.getNeww() > 0) {
        plot.setSectionPaint(plot.getDataset().getKey(i), new Color(200, 0, 0));
        i++;
    }
    if (kloConfig.getBuildGraph().isExisting() && kloReport.getExisting() > 0) {
        plot.setSectionPaint(plot.getDataset().getKey(i), new Color(0, 0, 200));
        i++;
    }
    if (kloConfig.getBuildGraph().isFixed() && kloReport.getFixed() > 0) {
        plot.setSectionPaint(plot.getDataset().getKey(i), new Color(0, 200, 0));
    }

    //plot.setOutlinePaint("Existing", new Color(0, 0, 200));
    //plot.setOutlinePaint("Fixed", new Color(0, 200, 0));

    return chart;

}

From source file:jmemorize.gui.swing.panels.SessionChartPanel.java

private JFreeChart createChart(String title, SessionSummary summary) {
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue(Localization.get(LC.LEARNED), (int) summary.getPassed());
    dataset.setValue(Localization.get(LC.FAILED), (int) summary.getFailed());
    dataset.setValue(Localization.get(LC.SKIPPED), (int) summary.getSkipped());
    dataset.setValue(Localization.get(LC.RELEARNED), (int) summary.getRelearned());

    JFreeChart chart = ChartFactory.createPieChart3D(title, dataset, true, true, false);

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setForegroundAlpha(0.5f);/*from   w ww.java 2 s. c  o m*/
    plot.setIgnoreZeroValues(true);

    plot.setLabelFont(plot.getLabelFont().deriveFont(11f));
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{1} ({2})"));

    plot.setSectionPaint(Localization.get(LC.LEARNED), ColorConstants.LEARNED_CARDS);
    plot.setSectionPaint(Localization.get(LC.FAILED), ColorConstants.EXPIRED_CARDS);
    plot.setSectionPaint(Localization.get(LC.SKIPPED), ColorConstants.UNLEARNED_CARDS);
    plot.setSectionPaint(Localization.get(LC.RELEARNED), ColorConstants.RELEARNED_CARDS);

    return chart;
}

From source file:org.jfree.chart.demo.ImageMapDemo6.java

/**
 * Creates a sample chart with the given dataset.
 * //from   w w w.j ava 2 s .c om
 * @param dataset  the dataset.
 * 
 * @return A sample chart.
 */
private JFreeChart createChart(final CategoryDataset dataset) {
    final JFreeChart chart = ChartFactory.createMultiplePieChart("Multiple Pie Chart", // chart title
            dataset, // dataset
            TableOrder.BY_ROW, true, // include legend
            true, true);
    final MultiplePiePlot plot = (MultiplePiePlot) chart.getPlot();
    final JFreeChart subchart = plot.getPieChart();
    final PiePlot p = (PiePlot) subchart.getPlot();
    p.setLabelGenerator(new StandardPieItemLabelGenerator("{0}"));
    p.setLabelFont(new Font("SansSerif", Font.PLAIN, 8));
    p.setInteriorGap(0.30);

    return chart;
}

From source file:com.ohalo.cn.awt.JFreeChartTest.java

public List<JFreeChart> printHardDiskCharts() throws SigarException {
    Sigar sigar = new Sigar();
    FileSystem fslist[] = sigar.getFileSystemList();
    ArrayList<JFreeChart> charts = new ArrayList<JFreeChart>();

    for (int i = 0; i < fslist.length; i++) {
        FileSystem fs = fslist[i];

        String diskName = fs.getDevName();

        FileSystemUsage usage = null;//  w w w.j  ava  2 s.c  om
        try {
            usage = sigar.getFileSystemUsage(fs.getDirName());
        } catch (SigarException e) {
            if (fs.getType() == 2)
                throw e;
            continue;
        }

        DefaultPieDataset dpd = new DefaultPieDataset(); // 

        if (fs.getType() == 2) {
            dpd.setValue("??(" + usage.getAvail() / 1024 / 1024 + "GB)",
                    usage.getAvail());
            dpd.setValue("?(" + usage.getUsed() / 1024 / 1024 + "GB)", usage.getUsed());
        }
        JFreeChart chart = ChartFactory.createPieChart("???", dpd, true, true,
                false);

        chart.setTitle(":" + diskName);
        Font font2 = new Font("", Font.BOLD, 12);
        chart.getTitle().setFont(font2);
        PiePlot pieplot = (PiePlot) chart.getPlot();
        pieplot.setLabelFont(font2);
        chart.getLegend().setItemFont(font2);
        charts.add(chart);
    }

    return charts;
}

From source file:edu.ku.brc.af.tasks.subpane.PieChartPane.java

public synchronized void allResultsBack(final QueryResultsContainerIFace qrc) {
    // create a dataset...
    DefaultPieDataset dataset = new DefaultPieDataset();

    java.util.List<Object> list = handler.getDataObjects();
    for (int i = 0; i < list.size(); i++) {
        Object descObj = list.get(i++);
        Object valObj = list.get(i);
        dataset.setValue(getString(descObj), getInt(valObj));
    }/*www  . j  a va2s.  c o  m*/
    list.clear();

    // create a chart...
    JFreeChart chart = ChartFactory.createPieChart(title, dataset, false, // legend?
            true, // tooltips?
            false // URLs?
    );

    //chart.getCategoryPlot().setRenderer(new CustomColorBarChartRenderer());

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 11)); //$NON-NLS-1$

    /*
    PiePlot3D plot = (PiePlot3D) chart.getPlot();
    //plot.setSectionOutlinesVisible(false);
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 11));
    plot.setNoDataMessage("No data available");
    plot.setCircular(true);
    plot.setLabelGap(0.02);
    //plot.setBackgroundAlpha(0.5f);
    plot.setForegroundAlpha(0.5f);
    plot.setDepthFactor(0.05);
    */

    removeAll(); // remove progress bar

    ChartPanel panel = new ChartPanel(chart, true, true, true, true, true);

    add(panel, BorderLayout.CENTER);

    doLayout();
    repaint();

}

From source file:RMOS.PieChart.java

/**
 * Creates a chart./*  ww w .j a  v  a 2 s.co  m*/
 *
 * @param dataset  the dataset.
 *
 * @return A chart.
 */
private static JFreeChart createChart(PieDataset dataset) {

    JFreeChart chart = ChartFactory.createPieChart("Eco Systems Statistics", // chart title
            dataset, // data
            false, // no legend
            true, // tooltips
            false // no URL generation
    );

    // set a custom background for the chart
    chart.setBackgroundPaint(
            new GradientPaint(new Point(0, 0), new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY));

    // customise the title position and font
    TextTitle t = chart.getTitle();
    t.setHorizontalAlignment(HorizontalAlignment.LEFT);
    t.setPaint(new Color(240, 240, 240));
    t.setFont(new Font("Arial", Font.BOLD, 26));

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setBackgroundPaint(null);
    plot.setInteriorGap(0.04);
    plot.setOutlineVisible(false);

    plot.setSectionPaint(f1.getStationInGroup().get(1), Color.blue);
    plot.setSectionPaint(f1.getStationInGroup().get(1), Color.GREEN);

    // use gradients and white borders for the section colours
    /*plot.setSectionPaint("Others", createGradientPaint(new Color(200, 200, 255), Color.BLUE));
    plot.setSectionPaint("Samsung", createGradientPaint(new Color(255, 200, 200), Color.RED));
    plot.setSectionPaint("Apple", createGradientPaint(new Color(200, 255, 200), Color.GREEN));
    plot.setSectionPaint("Nokia", createGradientPaint(new Color(200, 255, 200), Color.YELLOW));*/
    plot.setBaseSectionOutlinePaint(Color.WHITE);
    plot.setSectionOutlinesVisible(true);
    plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f));

    // customise the section label appearance
    plot.setLabelFont(new Font("Courier New", Font.BOLD, 20));
    plot.setLabelLinkPaint(Color.WHITE);
    plot.setLabelLinkStroke(new BasicStroke(2.0f));
    plot.setLabelOutlineStroke(null);
    plot.setLabelPaint(Color.WHITE);
    plot.setLabelBackgroundPaint(null);

    // add a subtitle giving the data source
    TextTitle source = new TextTitle("Source: Eco Recycle Station", new Font("Courier New", Font.PLAIN, 12));
    source.setPaint(Color.WHITE);
    source.setPosition(RectangleEdge.BOTTOM);
    source.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    chart.addSubtitle(source);
    return chart;

}

From source file:org.jfree.chart.demo.MultiplePieChartDemo4.java

/**
 * Creates a sample chart for the given dataset.
 * //from  ww  w.  j  a  v a  2  s .  c  o  m
 * @param dataset  the dataset.
 * 
 * @return A sample chart.
 */
private JFreeChart createChart(final CategoryDataset dataset) {
    final JFreeChart chart = ChartFactory.createMultiplePieChart3D("Multiple Pie Chart Demo 4", dataset,
            TableOrder.BY_COLUMN, false, true, false);
    chart.setBackgroundPaint(new Color(216, 255, 216));
    final MultiplePiePlot plot = (MultiplePiePlot) chart.getPlot();
    final JFreeChart subchart = plot.getPieChart();
    //        final StandardLegend legend = new StandardLegend();
    //      legend.setItemFont(new Font("SansSerif", Font.PLAIN, 8));
    //    legend.setAnchor(Legend.SOUTH);
    //  subchart.setLegend(legend);
    plot.setLimit(0.10);
    final PiePlot p = (PiePlot) subchart.getPlot();
    p.setLabelGenerator(new StandardPieItemLabelGenerator("{0}"));
    p.setLabelFont(new Font("SansSerif", Font.PLAIN, 8));
    p.setInteriorGap(0.30);

    return chart;
}

From source file:charts.PieChart3D.java

/**
 * Creates a chart./* w ww. ja  va  2  s. c  o  m*/
 *
 * @param dataset
 *            the dataset.
 *
 * @return A chart.
 */
private static JFreeChart createChart(PieDataset dataset, PieChartModel model) {

    JFreeChart chart = ChartFactory.createPieChart(model.getTitle(), // chart
            // title
            dataset, // data
            false, // no legend
            true, // tooltips
            false // no URL generation
    );

    // set a custom background for the chart
    chart.setBackgroundPaint(
            new GradientPaint(new Point(0, 0), new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY));

    // customise the title position and font
    TextTitle t = chart.getTitle();
    t.setHorizontalAlignment(HorizontalAlignment.LEFT);
    t.setPaint(new Color(240, 240, 240));
    t.setFont(new Font("Arial", Font.BOLD, 26));

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setBackgroundPaint(null);
    plot.setInteriorGap(0.04);
    plot.setOutlineVisible(false);

    // use gradients and white borders for the section colours
    plot.setSectionPaint("FCA", createGradientPaint(new Color(200, 200, 255), Color.BLUE));
    plot.setSectionPaint("FCH", createGradientPaint(new Color(255, 200, 200), Color.RED));
    plot.setSectionPaint("FCS", createGradientPaint(new Color(200, 255, 200), Color.GREEN));
    plot.setSectionPaint("FCG", createGradientPaint(new Color(200, 255, 200), Color.YELLOW));
    plot.setSectionPaint("FCJ", createGradientPaint(new Color(200, 255, 200), Color.BLACK));
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} {1} ({2}) "));
    plot.setBaseSectionOutlinePaint(Color.WHITE);
    plot.setSectionOutlinesVisible(true);
    plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f));

    // customise the section label appearance
    plot.setLabelFont(new Font("Courier New", Font.BOLD, 20));
    plot.setLabelLinkPaint(Color.WHITE);
    plot.setLabelLinkStroke(new BasicStroke(2.0f));
    plot.setLabelOutlineStroke(null);
    plot.setLabelPaint(Color.WHITE);
    plot.setLabelBackgroundPaint(null);

    // add a subtitle giving the data source
    TextTitle source = new TextTitle(model.getSubTitle(), new Font("Courier New", Font.PLAIN, 12));
    source.setPaint(Color.WHITE);
    source.setPosition(RectangleEdge.BOTTOM);
    source.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    chart.addSubtitle(source);
    return chart;

}

From source file:org.openmrs.module.usagestatistics.web.view.chart.FoundByChartView.java

@Override
protected JFreeChart createChart(Map<String, Object> model, HttpServletRequest request) {
    UsageStatisticsService svc = Context.getService(UsageStatisticsService.class);
    int[] stats = svc.getFoundByStats(getFromDate(), getUntilInclusiveDate(), getLocation(), getUsageFilter());

    String labelLink = ContextProvider.getMessage("usagestatistics.foundBy.directLink");
    String labelId = ContextProvider.getMessage("usagestatistics.foundBy.idSearch");
    String labelName = ContextProvider.getMessage("usagestatistics.foundBy.nameSearch");

    double total = stats[0];
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue(labelLink, 100.0 * stats[1] / total);
    dataset.setValue(labelId, 100.0 * stats[2] / total);
    dataset.setValue(labelName, 100.0 * stats[3] / total);

    JFreeChart chart = ChartFactory.createPieChart(null, dataset, false, false, false);

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setInteriorGap(0.0);/*from  w w  w .jav  a  2s  .c  o m*/
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2})"));
    plot.setLabelFont(getFont());

    return chart;
}

From source file:view.GerarGrafico.java

private JFreeChart createChart(PieDataset dataset) {

    JFreeChart chart = ChartFactory.createPieChart("Grfico de Transaes", // chart title
            dataset, // data
            true, // include legend
            true, false/*from   w w w. ja va  2 s.  com*/

    );

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setSectionPaint("Provento", new Color(68, 157, 68));
    plot.setSectionPaint("Despesa", new Color(217, 83, 79));
    plot.setLabelFont(new Font("Segoue UI", Font.PLAIN, 12));
    plot.setNoDataMessage("No data available");
    plot.setCircular(false);
    plot.setLabelGap(0.02);
    return chart;

}