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

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

Introduction

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

Prototype

public void setLabelGap(double gap) 

Source Link

Document

Sets the gap between the edge of the pie and the labels (expressed as a percentage of the plot width) and sends a PlotChangeEvent to all registered listeners.

Usage

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);//  w  w  w . ja  v a2 s. 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: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 ww w.  j a v a2 s  . c o  m
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setNoDataMessage("No data available");
    plot.setCircular(false);
    plot.setLabelGap(0.02);
    return chart;
}

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);//from w w w.j  ava 2  s  . com
    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:edu.ucla.stat.SOCR.chart.demo.PieChartDemo1.java

/**
 * Creates a chart//from www .ja  v  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:de.dekarlab.moneybuilder.view.AnalyticsView.java

/**
 * Create pie chart./*from   w  w  w .j  a  v  a  2  s .  co m*/
 * 
 * @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:it.eng.spagobi.engines.chart.bo.charttypes.piecharts.LinkablePie.java

public JFreeChart createChart(DatasetMap datasets) {
    Dataset dataset = (Dataset) datasets.getDatasets().get("1");

    boolean document_composition = false;
    if (mode.equalsIgnoreCase(SpagoBIConstants.DOCUMENT_COMPOSITION))
        document_composition = true;//from   ww w  . ja va  2 s .c o m

    JFreeChart chart = null;

    if (!threeD) {
        chart = ChartFactory.createPieChart(name, (PieDataset) dataset, // data
                legend, // include legend
                true, false);

        chart.setBackgroundPaint(color);

        TextTitle title = chart.getTitle();
        title.setToolTipText("A title tooltip!");

        PiePlot plot = (PiePlot) chart.getPlot();
        plot.setLabelFont(new Font(defaultLabelsStyle.getFontName(), Font.PLAIN, defaultLabelsStyle.getSize()));
        plot.setCircular(false);
        plot.setLabelGap(0.02);
        plot.setNoDataMessage("No data available");

        if (percentage == false) {
            plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({1})"));
        } else {
            plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2})"));
        }

        MyPieUrlGenerator pieUrl = new MyPieUrlGenerator(rootUrl);
        pieUrl.setDocument_composition(document_composition);
        pieUrl.setCategoryUrlLabel(categoryUrlName);
        pieUrl.setDrillDocTitle(drillDocTitle);
        pieUrl.setTarget(target);

        plot.setURLGenerator(pieUrl);

    } else {
        chart = ChartFactory.createPieChart3D(name, (PieDataset) dataset, // data
                true, // include legend
                true, false);

        chart.setBackgroundPaint(color);

        TextTitle title = chart.getTitle();
        title.setToolTipText("A title tooltip!");

        PiePlot3D plot = (PiePlot3D) chart.getPlot();

        plot.setDarkerSides(true);
        plot.setStartAngle(290);
        plot.setDirection(Rotation.CLOCKWISE);
        plot.setForegroundAlpha(1.0f);
        plot.setDepthFactor(0.2);

        plot.setLabelFont(new Font(defaultLabelsStyle.getFontName(), Font.PLAIN, defaultLabelsStyle.getSize()));
        plot.setCircular(false);
        plot.setLabelGap(0.02);
        plot.setNoDataMessage("No data available");

        //org.jfree.chart.renderer.category.BarRenderer renderer = new org.jfree.chart.renderer.category.AreaRenderer);

        MyPieUrlGenerator pieUrl = new MyPieUrlGenerator(rootUrl);
        pieUrl.setDocument_composition(document_composition);
        pieUrl.setCategoryUrlLabel(categoryUrlName);
        pieUrl.setDrillDocTitle(drillDocTitle);
        pieUrl.setTarget(target);

        plot.setURLGenerator(pieUrl);

        if (percentage == false) {
            plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({1})"));
        } else {
            plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2})"));
        }
    }

    TextTitle title = setStyleTitle(name, styleTitle);
    chart.setTitle(title);
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        chart.addSubtitle(subTitle);
    }

    return chart;

}

From source file:edu.ucla.stat.SOCR.applications.demo.BinomialTradingApplication.java

protected JFreeChart createEmptyChart(PieDataset dataset) {

    JFreeChart chart = ChartFactory.createPieChart("SOCR Chart", // chart title
            null, // data
            true, // include legend
            true, false);/*from  w ww.  ja va2 s  . c  o  m*/

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.setNoDataMessage("No data available");
    plot.setCircular(false);
    plot.setLabelGap(0.02);
    return chart;
}

From source file:ar.edu.uns.cs.vyglab.arq.rockar.gui.JFrameControlPanel.java

private void initCustomGUI() {
    // Crear un pie chart vacio
    pieChartDataset = new DefaultPieDataset();
    chart = ChartFactory.createPieChart("Rock.AR Pie Chart", // chart title
            pieChartDataset, // data
            false, // include legend
            true, false);// w  w  w. j a v  a2  s. c om
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setNoDataMessage("No data available");
    plot.setCircular(false);
    plot.setLabelGap(0.02);
    jPanelPieChart = new ChartPanel(this.chart);
    jPanelTop.add(jPanelPieChart, BorderLayout.CENTER);
    // TODO
    // hacer que los colores del pie chart se correspondan con la tabla
}

From source file:hr.restart.util.chart.ChartXY.java

/**
 * Creates a PIE CHART/*from   www .j av a  2 s.  c o m*/
 * @param dataset The org.jfree.data.PieDataset
 * @param title The title
 * @return org.jfree.chart.JFreeChart
 */
private JFreeChart createPieChart(final PieDataset dataset, String title) {

    final JFreeChart chart = ChartFactory.createPieChart(title, // chart title
            dataset, // data
            false, // include legend
            true, false);

    chart.setBackgroundPaint(Color.white);

    Plot plot = chart.getPlot();

    // the subtitle from the combobox        
    if (jcb != null)
        chart.addSubtitle(new TextTitle(jcb.getSelectedItem().toString()));

    //subtitles setted by the user.
    if (getSubtitles() != null)
        for (int i = 0; i < getSubtitles().size(); i++) {
            chart.addSubtitle(new TextTitle(getSubtitles().get(i).toString()));
        }

    final PiePlot piePlot = (PiePlot) plot;
    piePlot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    piePlot.setNoDataMessage("NO DATA!");
    piePlot.setCircular(false);
    piePlot.setLabelLinkPaint(Color.red);
    piePlot.setLabelGap(0.02);

    return chart;
}

From source file:jgnash.ui.report.compiled.IncomeExpensePieChart.java

private JFreeChart createPieChart(final Account a) {
    final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
    Objects.requireNonNull(engine);
    Objects.requireNonNull(a);//  ww  w.  jav  a2s  . c  om

    PieDataset data = createPieDataSet(a);
    PiePlot plot = new PiePlot(data);

    // rebuilt each time because they're based on the account's commodity
    CurrencyNode defaultCurrency = engine.getDefaultCurrency();
    NumberFormat valueFormat = CommodityFormat.getFullNumberFormat(a.getCurrencyNode());
    NumberFormat percentFormat = new DecimalFormat("0.0#%");
    defaultLabels = new StandardPieSectionLabelGenerator("{0} = {1}", valueFormat, percentFormat);
    percentLabels = new StandardPieSectionLabelGenerator("{0} = {1}\n{2}", valueFormat, percentFormat);

    plot.setLabelGenerator(showPercentCheck.isSelected() ? percentLabels : defaultLabels);

    plot.setLabelGap(.02);
    plot.setInteriorGap(.1);

    // if we had to add a section for the account (because it has it's
    // own transactions, not just child accounts), separate it from children.
    if (data.getIndex(a) != -1) {
        plot.setExplodePercent(a, .10);
    }

    String title;

    // pick an appropriate title
    if (a.getAccountType() == AccountType.EXPENSE) {
        title = rb.getString("Title.PercentExpense");
    } else if (a.getAccountType() == AccountType.INCOME) {
        title = rb.getString("Title.PercentIncome");
    } else {
        title = rb.getString("Title.PercentDist");
    }

    title = title + " - " + a.getPathName();

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);

    BigDecimal total = a.getTreeBalance(startField.getLocalDate(), endField.getLocalDate()).abs();

    String subtitle = valueFormat.format(total);
    if (!defaultCurrency.equals(a.getCurrencyNode())) {
        BigDecimal totalDefaultCurrency = total.multiply(a.getCurrencyNode().getExchangeRate(defaultCurrency));
        NumberFormat defaultValueFormat = CommodityFormat.getFullNumberFormat(defaultCurrency);
        subtitle += "  -  " + defaultValueFormat.format(totalDefaultCurrency);
    }
    chart.addSubtitle(new TextTitle(subtitle));
    chart.setBackgroundPaint(null);

    return chart;
}