Search in sources :

Example 31 with PiePlot

use of org.jfree.chart.plot.PiePlot 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 32 with PiePlot

use of org.jfree.chart.plot.PiePlot 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)

Example 33 with PiePlot

use of org.jfree.chart.plot.PiePlot in project eclipse-cs by checkstyle.

the class GraphStatsView method createChart.

/**
 * Crée le graphe JFreeChart.
 *
 * @param piedataset
 *          : la source de données à afficher
 * @return le diagramme
 */
private JFreeChart createChart(GraphPieDataset piedataset) {
    JFreeChart jfreechart = ChartFactory.createPieChart3D(null, piedataset, false, true, false);
    jfreechart.setAntiAlias(true);
    jfreechart.setTextAntiAlias(true);
    PiePlot pieplot3d = (PiePlot) jfreechart.getPlot();
    pieplot3d.setInsets(new RectangleInsets(0, 0, 0, 0));
    final double angle = 290D;
    pieplot3d.setStartAngle(angle);
    pieplot3d.setDirection(Rotation.CLOCKWISE);
    final float foreground = 0.5F;
    pieplot3d.setForegroundAlpha(foreground);
    pieplot3d.setNoDataMessage(Messages.GraphStatsView_noDataToDisplay);
    pieplot3d.setCircular(true);
    pieplot3d.setOutlinePaint(null);
    pieplot3d.setLabelFont(new Font("SansSerif", Font.PLAIN, 10));
    pieplot3d.setLabelGap(0.02);
    pieplot3d.setLabelOutlinePaint(null);
    pieplot3d.setLabelShadowPaint(null);
    pieplot3d.setLabelBackgroundPaint(Color.WHITE);
    pieplot3d.setBackgroundPaint(Color.WHITE);
    pieplot3d.setInteriorGap(0.02);
    pieplot3d.setMaximumLabelWidth(0.20);
    return jfreechart;
}
Also used : PiePlot(org.jfree.chart.plot.PiePlot) RectangleInsets(org.jfree.ui.RectangleInsets) JFreeChart(org.jfree.chart.JFreeChart) Font(java.awt.Font)

Example 34 with PiePlot

use of org.jfree.chart.plot.PiePlot in project MassBank-web by MassBank.

the class Contents method drawDataset.

private static JFreeChart drawDataset(PieDataset dataset, String title) {
    // JFreeChartオブジェクト生成
    JFreeChart chart = ChartFactory.createPieChart(title, dataset, true, true, false);
    // グラフ全体背景色設定
    chart.setBackgroundPaint(new ChartColor(242, 246, 255));
    // グラフ全体境界線設定
    chart.setBorderVisible(true);
    // グラフエリアパディング設定
    chart.setPadding(new RectangleInsets(10, 10, 10, 10));
    // グラフタイトルフォント設定
    chart.getTitle().setFont(new Font("Arial", Font.BOLD, 22));
    // 凡例の表示位置設定
    LegendTitle legend = chart.getLegend();
    legend.setPosition(RectangleEdge.RIGHT);
    // 凡例パディング設定
    legend.setPadding(10, 10, 10, 10);
    // 凡例マージン設定
    legend.setMargin(0, 10, 0, 5);
    // 凡例表示位置上寄せ
    legend.setVerticalAlignment(VerticalAlignment.TOP);
    // グラフの描画領域を取得
    PiePlot plot = (PiePlot) chart.getPlot();
    // グラフの楕円表示を許可する
    plot.setCircular(true);
    // グラフ境界線色設定
    plot.setDefaultSectionOutlinePaint(ChartColor.BLACK);
    // グラフラベル背景色設定
    plot.setLabelBackgroundPaint(new Color(240, 255, 255));
    // グラフラベルフォント設定
    plot.setLabelFont(new Font("Arial", Font.PLAIN, 12));
    // グラフラベル幅設定
    plot.setMaximumLabelWidth(0.3);
    // グラフラベル間距離設定
    plot.setLabelGap(0.05);
    // グラフ前景色透明度設定
    plot.setForegroundAlpha(0.9f);
    return chart;
}
Also used : ChartColor(org.jfree.chart.ChartColor) Color(java.awt.Color) ChartColor(org.jfree.chart.ChartColor) RectangleInsets(org.jfree.chart.ui.RectangleInsets) PiePlot(org.jfree.chart.plot.PiePlot) LegendTitle(org.jfree.chart.title.LegendTitle) JFreeChart(org.jfree.chart.JFreeChart) Font(java.awt.Font)

Example 35 with PiePlot

use of org.jfree.chart.plot.PiePlot in project SIMVA-SoS by SESoS.

the class JFreeChartTest method testEquals2.

/**
 * A test to make sure that the legend is being picked up in the
 * equals() testing.
 */
@Test
public void testEquals2() {
    JFreeChart chart1 = new JFreeChart("Title", new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), true);
    JFreeChart chart2 = new JFreeChart("Title", new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), false);
    assertFalse(chart1.equals(chart2));
    assertFalse(chart2.equals(chart1));
}
Also used : PiePlot(org.jfree.chart.plot.PiePlot) Font(java.awt.Font) Test(org.junit.Test)

Aggregations

PiePlot (org.jfree.chart.plot.PiePlot)40 JFreeChart (org.jfree.chart.JFreeChart)22 StandardPieSectionLabelGenerator (org.jfree.chart.labels.StandardPieSectionLabelGenerator)16 Font (java.awt.Font)14 TextTitle (org.jfree.chart.title.TextTitle)11 MultiplePiePlot (org.jfree.chart.plot.MultiplePiePlot)10 DefaultPieDataset (org.jfree.data.general.DefaultPieDataset)9 RectangleInsets (org.jfree.ui.RectangleInsets)9 Color (java.awt.Color)8 StandardPieToolTipGenerator (org.jfree.chart.labels.StandardPieToolTipGenerator)8 DecimalFormat (java.text.DecimalFormat)6 PieDataset (org.jfree.data.general.PieDataset)6 BasicStroke (java.awt.BasicStroke)5 Plot (org.jfree.chart.plot.Plot)5 StandardPieURLGenerator (org.jfree.chart.urls.StandardPieURLGenerator)5 ChartPanel (org.jfree.chart.ChartPanel)4 Test (org.junit.Test)4 GradientPaint (java.awt.GradientPaint)3 Paint (java.awt.Paint)3 Iterator (java.util.Iterator)3