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

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

Introduction

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

Prototype

public void setCircular(boolean flag) 

Source Link

Document

A flag indicating whether the pie chart is circular, or stretched into an elliptical shape.

Usage

From source file:userinterface.CountryNetworkAdminRole.CountryReportsJPanel.java

public JFreeChart createDonorsReportsChart(PieDataset dataSet, String chartTitle) {

    JFreeChart chart = ChartFactory.createPieChart(chartTitle, dataSet, true, true, false);
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setStartAngle(0);/*from   w ww. ja  v a 2  s .co  m*/
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setNoDataMessage("No data available");
    plot.setCircular(false);
    plot.setLabelGap(0.02);
    return chart;
}

From source file:canreg.client.analysis.TopNChartTableBuilder.java

@Override
public JFreeChart[] getCharts() {

    // set the plots circular before returning them if we have a pie chart
    if (chartType == ChartType.PIE) {
        for (JFreeChart chart : charts) {
            PiePlot plot = (PiePlot) chart.getPlot();
            plot.setCircular(true);
        }//  www. j a v a2  s  .c  om
    }

    return charts;
}

From source file:com.opensourcestrategies.activities.reports.ActivitiesChartsService.java

private String createPieChart(DefaultPieDataset dataset, String title)
        throws InfrastructureException, IOException {
    Debug.logInfo("Charting dashboard [" + title + "]", MODULE);
    // set up the chart
    JFreeChart chart = ChartFactory.createPieChart(title, dataset, true, // include legend
            true, // tooltips
            false // urls
    );//from w ww. j a  v a2  s  . c om
    chart.setBackgroundPaint(Color.white);
    chart.setBorderVisible(true);
    chart.setPadding(new RectangleInsets(5.0, 5.0, 5.0, 5.0));

    // get a reference to the plot for further customization...
    final PiePlot plot = (PiePlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setCircular(true);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}: {1} / {2}",
            NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance()));
    plot.setNoDataMessage("No data available");

    Color[] colors = {
            Color.decode("#" + infrastructure.getConfigurationValue(
                    OpentapsConfigurationTypeConstants.ACTIVITIES_DASHBOARD_LEADS_NEW_COLOR)),
            Color.decode("#" + infrastructure.getConfigurationValue(
                    OpentapsConfigurationTypeConstants.ACTIVITIES_DASHBOARD_LEADS_OLD_COLOR)),
            Color.decode("#" + infrastructure.getConfigurationValue(
                    OpentapsConfigurationTypeConstants.ACTIVITIES_DASHBOARD_LEADS_NO_ACTIVITY_COLOR)) };
    for (int i = 0; i < dataset.getItemCount(); i++) {
        Comparable<?> key = dataset.getKey(i);
        plot.setSectionPaint(key, colors[i]);
    }

    // save as a png and return the file name
    return ServletUtilities.saveChartAsPNG(chart, chartWidth, chartHeight, null);
}

From source file:userinterface.CountryNetworkAdminRole.CountryReportsJPanel.java

public JFreeChart createPatientReportsChart(PieDataset dataSet, String chartTitle) {
    //ChartFactory.createPieChart(chartTitle, dataSet, true, true, false);
    JFreeChart chart = ChartFactory.createPieChart(chartTitle, dataSet, true, true, false);
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setStartAngle(0);//ww w  . ja  va 2 s.c  o m
    plot.setDirection(Rotation.CLOCKWISE);
    //plot.setForegroundAlpha(0.8f);
    plot.setNoDataMessage("No data available");
    plot.setCircular(false);
    plot.setLabelGap(0.02);
    return chart;
}

From source file:org.gephi.desktop.context.ContextPieChart.java

public ContextPieChart() {
    data = new DefaultPieDataset();
    final JFreeChart chart = ChartFactory.createPieChart("Employee Survey", data, false, false, false);
    chart.setTitle(new TextTitle());
    chart.setBackgroundPaint(null);/*from   ww w .jav  a 2s .c o m*/
    chart.setPadding(new RectangleInsets(0, 0, 0, 0));
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setShadowPaint(null);
    plot.setSimpleLabels(true);
    plot.setLabelBackgroundPaint(null);
    plot.setLabelOutlineStroke(null);
    plot.setLabelShadowPaint(null);
    plot.setOutlineVisible(false);
    plot.setLabelFont(new java.awt.Font("Tahoma", 0, 10));
    plot.setLabelPaint(Color.WHITE);
    plot.setLabelGap(0.5);
    plot.setCircular(true);
    plot.setInteriorGap(0);
    plot.setBackgroundPaint(null);
    plot.setBackgroundAlpha(1f);
    plot.setSectionPaint(NbBundle.getMessage(getClass(), "ContextPieChart.visible"), new Color(0x222222));
    plot.setSectionPaint(NbBundle.getMessage(getClass(), "ContextPieChart.notVisible"), new Color(0xDDDDDD));
    chartPanel = new ChartPanel(chart, 100, 100, 10, 10, 300, 300, true, false, false, false, false, false);
    ((FlowLayout) chartPanel.getLayout()).setHgap(0);
    ((FlowLayout) chartPanel.getLayout()).setVgap(0);
    chartPanel.setOpaque(false);
    chartPanel.setPopupMenu(null);
}

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

private void setupPiePlot(PiePlot plot) {
    plot.setMaximumLabelWidth(0.0);//from  ww w.  j a v  a 2  s .c  o m
    plot.setLabelGap(0.0);
    plot.setInteriorGap(0.0);
    //piePlot.setLabelLinkMargin(0.0);
    plot.setCircular(true);
    plot.setLabelGenerator(new PieSectionLabelGenerator() {
        public String generateSectionLabel(PieDataset arg0, Comparable arg1) {
            return null;
        }

        public AttributedString generateAttributedSectionLabel(PieDataset arg0, Comparable arg1) {
            return null;
        }
    });
    //piePlot.setForegroundAlpha(0.5f);

    plot.setSectionPaint(Localization.get(LC.STATUS_LEARNED), ColorConstants.LEARNED_CARDS);
    plot.setSectionPaint(Localization.get(LC.STATUS_PARTIAL), ColorConstants.PARTIAL_LEARNED_CARDS);
    plot.setSectionPaint(Localization.get(LC.STATUS_UNLEARNED), ColorConstants.UNLEARNED_CARDS);
}

From source file:org.gephi.desktop.partition.PartitionPie.java

public void setup(Partition partition) {
    data = new DefaultPieDataset();
    for (Part p : partition.getParts()) {
        data.setValue(p.getDisplayName(), p.getPercentage());
    }//from w w w  . j a va  2  s  .co  m
    final JFreeChart chart = ChartFactory.createPieChart("test", data, false, false, false);
    chart.setTitle(new TextTitle());
    chart.setBackgroundPaint(null);
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setShadowPaint(null);
    //plot.setSimpleLabels(true);
    plot.setLabelBackgroundPaint(Color.WHITE);
    plot.setLabelOutlineStroke(null);
    plot.setLabelShadowPaint(null);
    plot.setOutlineVisible(false);
    plot.setLabelFont(new java.awt.Font("Tahoma", 0, 10));
    plot.setLabelPaint(Color.BLACK);
    //plot.setLabelGap(0.05);
    plot.setCircular(true);
    plot.setBackgroundPaint(null);
    plot.setBackgroundAlpha(1f);
    for (Part p : partition.getParts()) {
        plot.setSectionPaint(p.getDisplayName(), p.getColor());
    }
    chartPanel = new ChartPanel(chart, true);
    chartPanel.setOpaque(false);
    chartPanel.setPopupMenu(null);
    add(chartPanel, BorderLayout.CENTER);
}

From source file:de.dekarlab.moneybuilder.view.AnalyticsView.java

/**
 * Create pie chart./*from   w w w . j  a  v  a2  s  . com*/
 * 
 * @param dataset
 * @param title
 * @return
 */
protected JFreeChart createPieChart(final PieDataset dataset, final String title) {
    final JFreeChart chart = ChartFactory.createPieChart(title, dataset, true, true, false);
    final PiePlot plot = (PiePlot) chart.getPlot();
    plot.setNoDataMessage(App.getGuiProp("report.nodata.msg"));
    plot.setCircular(true);
    // plot.set
    plot.setLabelGap(0.02);
    plot.setBackgroundPaint(Color.white);
    chart.removeLegend();
    plot.setBackgroundPaint(Color.white);
    Iterator<?> it = dataset.getKeys().iterator();
    int color = 0;
    while (it.hasNext()) {
        plot.setSectionPaint((String) it.next(), COLORS[color]);
        color++;
        if (COLORS.length == color) {
            color = 0;
        }
    }
    plot.setLabelBackgroundPaint(Color.white);
    StandardPieSectionLabelGenerator slbl = new StandardPieSectionLabelGenerator("{0} {2} ({1})",
            new DecimalFormat("#,##0"), new DecimalFormat("0%"));
    plot.setLabelGenerator(slbl);
    plot.setLabelFont(new Font("Helvetica", Font.PLAIN, 14));
    plot.setLabelOutlinePaint(Color.white);
    plot.setLabelShadowPaint(Color.white);
    plot.setShadowPaint(Color.white);
    plot.setIgnoreZeroValues(true);
    return chart;
}

From source file:edu.ucla.stat.SOCR.chart.demo.PieChartDemo1.java

/**
 * Creates a chart/*w ww  . j  av  a 2  s  .c  o  m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return a chart.
 */
protected JFreeChart createChart(PieDataset dataset) {
    JFreeChart chart = ChartFactory.createPieChart(chartTitle, // chart title
            dataset, // data
            !legendPanelOn, // include legend
            true, false);
    TextTitle title = chart.getTitle();
    title.setToolTipText("A title tooltip!");

    PiePlot plot = (PiePlot) chart.getPlot();
    for (int i = 0; i < pulloutFlag.length; i++) {
        //System.out.println("\""+pulloutFlag[i]+"\"");
        if (isPullout(i)) {
            Comparable key = dataset.getKey(i);
            plot.setExplodePercent(key, 0.30);
        }
    }
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.setNoDataMessage("No data available");
    plot.setCircular(false);
    plot.setLabelGap(0.02);

    setCategorySummary(dataset);

    if (rotateOn) {
        Rotator rotator = new Rotator(plot);
        rotator.start();
    }
    return chart;
}

From source file:org.sipfoundry.sipxconfig.site.cdr.CdrReports.java

private Image createCallDirectionCallsPieImage(List<CdrGraphBean> beans) {
    // Create a dataset
    DefaultKeyedValuesDataset data = new DefaultKeyedValuesDataset();

    // Fill dataset with beans data
    for (CdrGraphBean directionCall : beans) {
        data.setValue(directionCall.getKey(), directionCall.getCount());
    }//  w w  w  .ja v a2  s  .com

    // Create a chart with the dataset
    JFreeChart chart = ChartFactory.createPieChart(EMPTY_TITLE, data, true, true, false);
    chart.setBackgroundPaint(Color.lightGray);
    chart.setTitle("Summary - " + getMessages().getMessage(TITLE_CALLDIRECTION_REPORT_KEY));
    chart.getTitle().setPaint(Color.BLACK);

    PiePlot chartplot = (PiePlot) chart.getPlot();
    chartplot.setCircular(true);
    chartplot.setLabelGenerator(new StandardPieSectionLabelGenerator(PIECHART_SECTIONLABEL_FORMAT));

    // Create and return the image
    return chart.createBufferedImage(500, 220, BufferedImage.TYPE_INT_RGB, null);
}