Search in sources :

Example 11 with StandardPieSectionLabelGenerator

use of org.jfree.chart.labels.StandardPieSectionLabelGenerator in project tdq-studio-se by Talend.

the class ChartDecorator method decoratePiePlot.

/**
 * DOC qiongli Comment method "decoratePiePlot".
 *
 * @param chart
 */
private static void decoratePiePlot(JFreeChart chart) {
    // $NON-NLS-1$
    Font font = new Font("sans-serif", Font.BOLD, BASE_TITLE_LABEL_SIZE);
    TextTitle textTitle = chart.getTitle();
    // MOD msjian TDQ-5213 2012-5-7: fixed NPE
    if (textTitle != null) {
        textTitle.setFont(font);
    }
    setLegendFont(chart);
    // TDQ-5213~
    PiePlot plot = (PiePlot) chart.getPlot();
    // $NON-NLS-1$
    font = new Font("Monospaced", Font.PLAIN, 10);
    plot.setLabelFont(font);
    // $NON-NLS-1$
    plot.setNoDataMessage("No data available");
    StandardPieSectionLabelGenerator standardPieSectionLabelGenerator = new // $NON-NLS-1$
    StandardPieSectionLabelGenerator(// $NON-NLS-1$
    ("{0}:{2}"), NumberFormat.getNumberInstance(), new DecimalFormat(PERCENT_FORMAT));
    plot.setLabelGenerator(standardPieSectionLabelGenerator);
    plot.setLabelLinkPaint(Color.GRAY);
    plot.setLabelOutlinePaint(Color.WHITE);
    plot.setLabelGap(0.02D);
    plot.setOutlineVisible(false);
    plot.setMaximumLabelWidth(0.2D);
    plot.setCircular(false);
    // remove the shadow of the pie chart
    plot.setShadowXOffset(0);
    plot.setShadowYOffset(0);
}
Also used : TextTitle(org.jfree.chart.title.TextTitle) DecimalFormat(java.text.DecimalFormat) PiePlot(org.jfree.chart.plot.PiePlot) StandardPieSectionLabelGenerator(org.jfree.chart.labels.StandardPieSectionLabelGenerator) Font(java.awt.Font)

Example 12 with StandardPieSectionLabelGenerator

use of org.jfree.chart.labels.StandardPieSectionLabelGenerator in project MtgDesktopCompanion by nicho92.

the class RarityRepartitionPanel method refresh.

private void refresh() {
    this.removeAll();
    JFreeChart chart = ChartFactory.createPieChart3D(// chart title
    "Rarity repartition", // data
    getRarityRepartitionDataSet(), // include legend
    false, true, true);
    pane = new ChartPanel(chart);
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setSectionPaint("Uncommon", Color.GRAY);
    plot.setSectionPaint("Common", Color.WHITE);
    plot.setSectionPaint("Rare", Color.YELLOW);
    plot.setSectionPaint("Mythic Rare", Color.ORANGE);
    PieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator("{0} = {1}", new DecimalFormat("0"), new DecimalFormat("0.00%"));
    plot.setLabelGenerator(generator);
    this.add(pane, BorderLayout.CENTER);
}
Also used : ChartPanel(org.jfree.chart.ChartPanel) StandardPieSectionLabelGenerator(org.jfree.chart.labels.StandardPieSectionLabelGenerator) PieSectionLabelGenerator(org.jfree.chart.labels.PieSectionLabelGenerator) DecimalFormat(java.text.DecimalFormat) PiePlot(org.jfree.chart.plot.PiePlot) StandardPieSectionLabelGenerator(org.jfree.chart.labels.StandardPieSectionLabelGenerator) JFreeChart(org.jfree.chart.JFreeChart)

Example 13 with StandardPieSectionLabelGenerator

use of org.jfree.chart.labels.StandardPieSectionLabelGenerator in project MtgDesktopCompanion by nicho92.

the class TypeRepartitionPanel method refresh.

private void refresh() {
    this.removeAll();
    JFreeChart chart = ChartFactory.createPieChart3D(// chart title
    "Type repartition", // data
    getTypeRepartitionDataSet(), // include legend
    false, true, true);
    pane = new ChartPanel(chart);
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setSectionPaint("B", Color.BLACK);
    plot.setSectionPaint("W", Color.WHITE);
    plot.setSectionPaint("U", Color.BLUE);
    plot.setSectionPaint("G", Color.GREEN);
    plot.setSectionPaint("R", Color.RED);
    plot.setSectionPaint("multi", Color.YELLOW);
    plot.setSectionPaint("uncolor", Color.GRAY);
    PieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator("{0} = {1}", new DecimalFormat("0"), new DecimalFormat("0.00%"));
    plot.setLabelGenerator(generator);
    this.add(pane, BorderLayout.CENTER);
}
Also used : ChartPanel(org.jfree.chart.ChartPanel) StandardPieSectionLabelGenerator(org.jfree.chart.labels.StandardPieSectionLabelGenerator) PieSectionLabelGenerator(org.jfree.chart.labels.PieSectionLabelGenerator) DecimalFormat(java.text.DecimalFormat) PiePlot(org.jfree.chart.plot.PiePlot) StandardPieSectionLabelGenerator(org.jfree.chart.labels.StandardPieSectionLabelGenerator) JFreeChart(org.jfree.chart.JFreeChart)

Aggregations

StandardPieSectionLabelGenerator (org.jfree.chart.labels.StandardPieSectionLabelGenerator)13 PiePlot (org.jfree.chart.plot.PiePlot)12 JFreeChart (org.jfree.chart.JFreeChart)10 DecimalFormat (java.text.DecimalFormat)6 DefaultPieDataset (org.jfree.data.general.DefaultPieDataset)4 ChartPanel (org.jfree.chart.ChartPanel)3 PieSectionLabelGenerator (org.jfree.chart.labels.PieSectionLabelGenerator)3 TextTitle (org.jfree.chart.title.TextTitle)3 Font (java.awt.Font)2 BigDecimal (java.math.BigDecimal)2 NumberFormat (java.text.NumberFormat)2 MultiplePiePlot (org.jfree.chart.plot.MultiplePiePlot)2 PieDataset (org.jfree.data.general.PieDataset)2 Color (java.awt.Color)1 Paint (java.awt.Paint)1 Iterator (java.util.Iterator)1 List (java.util.List)1 CurrencyNode (jgnash.engine.CurrencyNode)1 Engine (jgnash.engine.Engine)1 EMDataSet (org.baderlab.csplugins.enrichmentmap.model.EMDataSet)1