Search in sources :

Example 41 with StandardPieSectionLabelGenerator

use of org.jfree.chart.labels.StandardPieSectionLabelGenerator in project oshi by oshi.

the class MemoryPanel method configurePlot.

private static void configurePlot(JFreeChart chart) {
    @SuppressWarnings("unchecked") PiePlot<String> plot = (PiePlot<String>) chart.getPlot();
    plot.setSectionPaint(USED, Color.red);
    plot.setSectionPaint(AVAILABLE, Color.green);
    plot.setExplodePercent(USED, 0.10);
    plot.setSimpleLabels(true);
    PieSectionLabelGenerator labelGenerator = new StandardPieSectionLabelGenerator("{0}: {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0%"));
    plot.setLabelGenerator(labelGenerator);
}
Also used : 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)

Example 42 with StandardPieSectionLabelGenerator

use of org.jfree.chart.labels.StandardPieSectionLabelGenerator in project oshi by oshi.

the class FileStorePanel method configurePlot.

private static void configurePlot(JFreeChart chart) {
    @SuppressWarnings("unchecked") PiePlot<String> plot = (PiePlot<String>) chart.getPlot();
    plot.setSectionPaint(USED, Color.red);
    plot.setSectionPaint(AVAILABLE, Color.green);
    plot.setExplodePercent(USED, 0.10);
    plot.setSimpleLabels(true);
    PieSectionLabelGenerator labelGenerator = new StandardPieSectionLabelGenerator("{0}: {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0%"));
    plot.setLabelGenerator(labelGenerator);
}
Also used : 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)

Example 43 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 44 with StandardPieSectionLabelGenerator

use of org.jfree.chart.labels.StandardPieSectionLabelGenerator in project demo by changlongmao.

the class JFreeChartUtils method createValidityComparePimChar.

/**
 * 饼状图
 *
 * @param dataset    数据集
 * @param chartTitle 图标题
 * @param charName   生成图的名字
 * @param pieKeys    分饼的名字集
 * @return
 */
private InputStream createValidityComparePimChar(PieDataset dataset, String chartTitle, String charName, String[] pieKeys) {
    JFreeChart chart = // chart
    ChartFactory.createPieChart3D(// chart
    chartTitle, // data
    dataset, // include legend
    true, true, false);
    // 使下说明标签字体清晰,去锯齿类似于
    // chart.getRenderingHints().put(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);的效果
    chart.setTextAntiAlias(false);
    // 图片背景色
    chart.setBackgroundPaint(Color.white);
    // 设置图标题的字体重新设置title
    Font font = new Font("隶书", Font.BOLD, 25);
    TextTitle title = new TextTitle(chartTitle);
    title.setFont(font);
    chart.setTitle(title);
    PiePlot3D plot = (PiePlot3D) chart.getPlot();
    // 图片中显示百分比:默认方式
    // 指定饼图轮廓线的颜色
    // plot.setBaseSectionOutlinePaint(Color.BLACK);
    // plot.setBaseSectionPaint(Color.BLACK);
    // 设置无数据时的信息
    plot.setNoDataMessage("无对应的数据,请重新查询。");
    // 设置无数据时的信息显示颜色
    plot.setNoDataMessagePaint(Color.red);
    // 图片中显示百分比:自定义方式,{0} 表示选项, {1} 表示数值, {2} 表示所占比例 ,小数点后两位
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}={1}({2})", NumberFormat.getNumberInstance(), new DecimalFormat("0.00%")));
    // 图例显示百分比:自定义方式, {0} 表示选项, {1} 表示数值, {2} 表示所占比例
    plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}={1}({2})"));
    plot.setLabelFont(new Font("SansSerif", Font.TRUETYPE_FONT, 12));
    // 指定图片的透明度(0.0-1.0)
    plot.setForegroundAlpha(0.65f);
    // 指定显示的饼图上圆形(false)还椭圆形(true)
    plot.setCircular(false, true);
    // 设置第一个 饼块section 的开始位置,默认是12点钟方向
    plot.setStartAngle(90);
    // // 设置分饼颜色
    plot.setSectionPaint(pieKeys[0], new Color(244, 194, 144));
    plot.setSectionPaint(pieKeys[1], new Color(144, 233, 144));
    return getChartStream(chart, 500, 500);
}
Also used : TextTitle(org.jfree.chart.title.TextTitle) DecimalFormat(java.text.DecimalFormat) StandardPieSectionLabelGenerator(org.jfree.chart.labels.StandardPieSectionLabelGenerator)

Example 45 with StandardPieSectionLabelGenerator

use of org.jfree.chart.labels.StandardPieSectionLabelGenerator in project DevKits by qmjy.

the class MemoryPanel method configurePlot.

private static void configurePlot(JFreeChart chart) {
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setSectionPaint(USED, Color.red);
    plot.setSectionPaint(AVAILABLE, Color.green);
    plot.setExplodePercent(USED, 0.10);
    plot.setSimpleLabels(true);
    PieSectionLabelGenerator labelGenerator = new StandardPieSectionLabelGenerator("{0}: {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0%"));
    plot.setLabelGenerator(labelGenerator);
}
Also used : 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)

Aggregations

StandardPieSectionLabelGenerator (org.jfree.chart.labels.StandardPieSectionLabelGenerator)72 PiePlot (org.jfree.chart.plot.PiePlot)47 JFreeChart (org.jfree.chart.JFreeChart)31 DecimalFormat (java.text.DecimalFormat)30 DefaultPieDataset (org.jfree.data.general.DefaultPieDataset)30 StandardPieToolTipGenerator (org.jfree.chart.labels.StandardPieToolTipGenerator)26 PieSectionLabelGenerator (org.jfree.chart.labels.PieSectionLabelGenerator)24 MultiplePiePlot (org.jfree.chart.plot.MultiplePiePlot)21 File (java.io.File)17 IOException (java.io.IOException)17 Connection (java.sql.Connection)16 ResultSet (java.sql.ResultSet)16 SQLException (java.sql.SQLException)16 Statement (java.sql.Statement)16 DateFormat (java.text.DateFormat)16 SimpleDateFormat (java.text.SimpleDateFormat)16 ImageIcon (javax.swing.ImageIcon)16 BlueSeerUtils.currformatDouble (com.blueseer.utl.BlueSeerUtils.currformatDouble)13 RectangleInsets (org.jfree.ui.RectangleInsets)13 Font (java.awt.Font)12