当前位置: 首页>>代码示例>>Java>>正文


Java PiePlot.setLabelGenerator方法代码示例

本文整理汇总了Java中org.jfree.chart.plot.PiePlot.setLabelGenerator方法的典型用法代码示例。如果您正苦于以下问题:Java PiePlot.setLabelGenerator方法的具体用法?Java PiePlot.setLabelGenerator怎么用?Java PiePlot.setLabelGenerator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jfree.chart.plot.PiePlot的用法示例。


在下文中一共展示了PiePlot.setLabelGenerator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setPieRender

import org.jfree.chart.plot.PiePlot; //导入方法依赖的package包/类
public static void setPieRender(Plot plot) {

        plot.setNoDataMessage(NO_DATA_MSG);
        plot.setInsets(new RectangleInsets(10, 10, 5, 10));
        PiePlot piePlot = (PiePlot) plot;
        piePlot.setInsets(new RectangleInsets(0, 0, 0, 0));
        piePlot.setCircular(true);

        piePlot.setLabelGap(0.01);
        piePlot.setInteriorGap(0.05D);
        piePlot.setLegendItemShape(new Rectangle(10, 10));
        piePlot.setIgnoreNullValues(true);
        piePlot.setLabelBackgroundPaint(null);
        piePlot.setLabelShadowPaint(null);
        piePlot.setLabelOutlinePaint(null);
        piePlot.setShadowPaint(null);
        // 0:category 1:value:2 :percentage
        piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}:{2}"));
    }
 
开发者ID:Fanping,项目名称:iveely.ml,代码行数:20,代码来源:ChartUtils.java

示例2: PieChart

import org.jfree.chart.plot.PiePlot; //导入方法依赖的package包/类
public PieChart() {
    DefaultPieDataset data = getDataSet();
    JFreeChart chart = ChartFactory.createPieChart3D("水果产量", data, true, false, false);
    //设置百分比
    PiePlot pieplot = (PiePlot) chart.getPlot();
    DecimalFormat df = new DecimalFormat("0.00%");//获得一个DecimalFormat对象,主要是设置小数问题
    NumberFormat nf = NumberFormat.getNumberInstance();//获得一个NumberFormat对象
    StandardPieSectionLabelGenerator sp1 = new StandardPieSectionLabelGenerator("{0}  {2}", nf, df);//获得StandardPieSectionLabelGenerator对象
    pieplot.setLabelGenerator(sp1);//设置饼图显示百分比

    //没有数据的时候显示的内容
    pieplot.setNoDataMessage("无数据显示");
    pieplot.setCircular(false);
    pieplot.setLabelGap(0.02D);

    pieplot.setIgnoreNullValues(true);//设置不显示空值
    pieplot.setIgnoreZeroValues(true);//设置不显示负值
    frame1 = new ChartPanel(chart, true);
    chart.getTitle().setFont(new Font("宋体", Font.BOLD, 20));//设置标题字体
    PiePlot piePlot = (PiePlot) chart.getPlot();//获取图表区域对象
    piePlot.setLabelFont(new Font("宋体", Font.BOLD, 10));//解决乱码
    chart.getLegend().setItemFont(new Font("黑体", Font.BOLD, 10));
}
 
开发者ID:leon66666,项目名称:financehelper,代码行数:24,代码来源:PieChart.java

示例3: createPieChart

import org.jfree.chart.plot.PiePlot; //导入方法依赖的package包/类
/**
 * Creates a pie chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link PiePlot} instance as the
 * plot.

 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A pie chart.
 */
public static JFreeChart createPieChart(String title,
                                        PieDataset dataset,
                                        boolean legend,
                                        boolean tooltips,
                                        boolean urls) {

    PiePlot plot = new PiePlot(dataset);
    plot.setLabelGenerator(new StandardPieItemLabelGenerator());
    plot.setInsets(new Insets(0, 5, 5, 5));
    if (tooltips) {
        plot.setToolTipGenerator(
            new StandardPieItemLabelGenerator(
                StandardPieItemLabelGenerator.DEFAULT_SECTION_LABEL_FORMAT
            )
        );
    }
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:37,代码来源:ChartFactory.java

示例4: createPieChart

import org.jfree.chart.plot.PiePlot; //导入方法依赖的package包/类
/**
 * Creates a pie chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link PiePlot} instance 
 * as the plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A pie chart.
 */
public static JFreeChart createPieChart(String title,
                                        PieDataset dataset,
                                        boolean legend,
                                        boolean tooltips,
                                        boolean urls) {

    PiePlot plot = new PiePlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator(
                StandardPieToolTipGenerator.DEFAULT_SECTION_LABEL_FORMAT));
    }
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, 
            legend);

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:35,代码来源:ChartFactory.java

示例5: createPieChart

import org.jfree.chart.plot.PiePlot; //导入方法依赖的package包/类
/**
 * Creates a pie chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link PiePlot} instance
 * as the plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A pie chart.
 */
public static JFreeChart createPieChart(String title, PieDataset dataset,
        boolean legend, boolean tooltips, boolean urls) {

    PiePlot plot = new PiePlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator());
    }
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;
}
 
开发者ID:mdzio,项目名称:ccu-historian,代码行数:32,代码来源:ChartFactory.java

示例6: createPieChart

import org.jfree.chart.plot.PiePlot; //导入方法依赖的package包/类
/**
 * Creates a pie chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link PiePlot} instance
 * as the plot.
 *
 * @param title  the chart title ({@code null} permitted).
 * @param dataset  the dataset for the chart ({@code null} permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A pie chart.
 */
public static JFreeChart createPieChart(String title, PieDataset dataset,
        boolean legend, boolean tooltips, boolean urls) {

    PiePlot plot = new PiePlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator());
    }
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;
}
 
开发者ID:jfree,项目名称:jfreechart,代码行数:32,代码来源:ChartFactory.java

示例7: setPlotStyle

import org.jfree.chart.plot.PiePlot; //导入方法依赖的package包/类
private void setPlotStyle(JFreeChart chart) throws ChartException {
	if (chart == null)
		throw new ChartException("chart未正确创建,设置图表样式时异常!");
	// 获得饼图的Plot对象
	PiePlot plot = (PiePlot) chart.getPlot();
	// 设置饼图各部分的标签字体
	plot.setLabelFont(this.getLabelFont());
	// 设置透明度(0-1.0之间)
	plot.setBackgroundAlpha(this.getAlpha());
	// 忽略无值的分类
	plot.setIgnoreNullValues(true);
	// 分类标签的格式,设置成null则整个标签包括连接线都不显示
	if (this.isGuide()) {

	} else {
		plot.setLabelGenerator(null);
	}
	
}
 
开发者ID:fanqinghui,项目名称:TaskExcute,代码行数:20,代码来源:PieCharts.java

示例8: createPieChart

import org.jfree.chart.plot.PiePlot; //导入方法依赖的package包/类
/**
 * Creates a pie chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link PiePlot} instance
 * as the plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A pie chart.
 */
public static JFreeChart createPieChart(String title,
                                        PieDataset dataset,
                                        boolean legend,
                                        boolean tooltips,
                                        boolean urls) {

    PiePlot plot = new PiePlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator());
    }
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;
}
 
开发者ID:SOCR,项目名称:HTML5_WebSite,代码行数:35,代码来源:ChartFactory.java

示例9: generatePieChart

import org.jfree.chart.plot.PiePlot; //导入方法依赖的package包/类
public static JFreeChart generatePieChart()
{
    DefaultPieDataset dataSet = new DefaultPieDataset();
    dataSet.setValue("China", 30);
    dataSet.setValue("India", 30);
    dataSet.setValue("United States", 40);

    JFreeChart chart = ChartFactory.createPieChart("", dataSet, false, true, false);
    PiePlot piePlot = (PiePlot) chart.getPlot();
    piePlot.setBackgroundPaint(Color.WHITE); // set background color white
    piePlot.setOutlineVisible(false); // remove background border
    piePlot.setLabelGenerator(null); // remove pie section labels
    piePlot.setSectionPaint("China", Color.GRAY);
    piePlot.setSectionPaint("India", Color.GREEN);
    piePlot.setSectionPaint("United States", Color.BLUE);
    piePlot.setShadowPaint(Color.WHITE);

    return chart;
}
 
开发者ID:mkl-public,项目名称:testarea-itext5,代码行数:20,代码来源:JFreeChartTest.java

示例10: makeChartByMap

import org.jfree.chart.plot.PiePlot; //导入方法依赖的package包/类
public void makeChartByMap(Map<String, Object> map,String title) {
    DefaultPieDataset dpd = new DefaultPieDataset(); //建立一个默认的饼图
    System.out.println(map);

    dpd.setValue("优", Integer.parseInt(map.get("优").toString()));
    dpd.setValue("良", Integer.parseInt(map.get("良").toString()));
    dpd.setValue("中", Integer.parseInt(map.get("中").toString()));
    dpd.setValue("差", Integer.parseInt(map.get("差").toString()));
    dpd.setValue("不及格", Integer.parseInt(map.get("不及格").toString()));

    JFreeChart chart = ChartFactory.createPieChart(title, dpd, true, true, false);
    PiePlot piePlot = (PiePlot) chart.getPlot();
    piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator(("{0}:({2})"), NumberFormat.getNumberInstance(), new DecimalFormat("0.00%")));
    //可以查具体的API文档,第一个参数是标题,第二个参数是一个数据集,第三个参数表示是否显示Legend,第四个参数表示是否显示提示,第五个参数表示图中是否存在URL
    ChartFrame chartFrame = new ChartFrame(title, chart);
    //chart要放在Java容器组件中,ChartFrame继承自java的Jframe类。该第一个参数的数据是放在窗口左上角的,不是正中间的标题。
    chartFrame.pack(); //以合适的大小展现图形
    chartFrame.setVisible(true);//图形是否可见
}
 
开发者ID:leftjs,项目名称:StudentGradesManageSystem,代码行数:20,代码来源:HomeAdmin.java

示例11: createPieChart

import org.jfree.chart.plot.PiePlot; //导入方法依赖的package包/类
private static JFreeChart createPieChart(PieDataset piedataset, GraphDataItem item) {
	JFreeChart jfreechart = ChartFactory.createPieChart(item.getTitle(), piedataset, true, true, false);
	Font font = new Font("宋体", Font.PLAIN, 13);
	jfreechart.getTitle().setFont(font);
	jfreechart.getLegend().setItemFont(font);
	PiePlot pieplot = (PiePlot) jfreechart.getPlot();
	pieplot.setBackgroundPaint(ChartColor.WHITE);
	pieplot.setLabelFont(font);
	pieplot.setLabelGenerator(new StandardPieSectionLabelGenerator(("{0}: ({2})"),
			NumberFormat.getNumberInstance(), new DecimalFormat("0.00%")));
	pieplot.setLabelBackgroundPaint(new Color(220, 220, 220));
	pieplot.setSimpleLabels(true);
	pieplot.setInteriorGap(0.0D);

	int index = 0;
	for (Object name : item.getDatas().keySet()) {
		pieplot.setSectionPaint((String) name, COLORS[index % COLORS.length]);
		index++;

	}
	return jfreechart;
}
 
开发者ID:jdepend,项目名称:cooper,代码行数:23,代码来源:PieChartCreater.java

示例12: ChartWidget

import org.jfree.chart.plot.PiePlot; //导入方法依赖的package包/类
public ChartWidget() {		
	
	rightLabel = new JLabel();
	Font rightFont = new Font("Verdana", Font.PLAIN, 12);
	rightLabel.setHorizontalAlignment(JLabel.LEFT);
	rightLabel.setVerticalAlignment(JLabel.TOP);
	rightLabel.setFont(rightFont);
	this.add(rightLabel);		
	
	
	myColoredPieChart = new DefaultPieDataset();
	myColoredChart = ChartFactory.createPieChart3D("", myColoredPieChart,
			false, false, false);
	myColoredChart.setBorderVisible(false);
	myColoredChart.setBackgroundPaint(new Color(0, 0, 0, 0)); // transparent
																// black
	PiePlot configurator = (PiePlot) myColoredChart.getPlot();
	configurator.setBackgroundPaint(new Color(0, 0, 0, 0));
	configurator.setLabelGenerator(null);
	configurator.setOutlineVisible(false);
	ChartPanel chartPanel = new ChartPanel(myColoredChart, 150, 150, 150,
			150, 250, 250, true, false, false, false, false, false);
	this.add(chartPanel);
}
 
开发者ID:burningrain,项目名称:planetBot,代码行数:25,代码来源:ChartWidget.java

示例13: customize

import org.jfree.chart.plot.PiePlot; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void customize(JFreeChart chart, JRChart jasperChart) {
	
	PiePlot plot = (PiePlot) chart.getPlot();
	plot.setSectionPaint(4, new Color(0, 70, 120));
	plot.setSectionPaint(3, new Color(0, 70, 120));
	plot.setSectionPaint(2, new Color(189, 216, 77));
	plot.setSectionPaint(1, new Color(253, 224, 94));
	plot.setSectionPaint(0, new Color(219, 109, 29));
	
	PieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator("{0}: {1} ({2})");
	plot.setLabelGenerator(generator);
	
	plot.setLabelBackgroundPaint(new Color(255,255,255));
	
	Font font = new Font(Font.SANS_SERIF, Font.PLAIN, 12);
	plot.setLabelFont(font);
}
 
开发者ID:jqxin2006,项目名称:threadfixRack,代码行数:20,代码来源:PointInTimeChartCustomizer.java

示例14: makePlot

import org.jfree.chart.plot.PiePlot; //导入方法依赖的package包/类
@Override
protected Plot makePlot(final JFreeChartBuilder.PlotParameters parameters) {

    final KeyedValuesDataset tmpDataset = this.getDataset();

    final PiePlot retVal = new PiePlot(tmpDataset);

    retVal.setShadowXOffset(0);
    retVal.setShadowYOffset(0);

    retVal.setBackgroundPaint(parameters.getBackground());
    retVal.setOutlinePaint(parameters.getOutline());

    retVal.setLabelGenerator(new StandardPieSectionLabelGenerator());

    if (this.isTooltips()) {
        retVal.setToolTipGenerator(new StandardPieToolTipGenerator());
    }
    if (this.isUrls()) {
        retVal.setURLGenerator(new StandardPieURLGenerator());
    }

    for (final Entry<Comparable<?>, Paint> tmpEntry : this.getColourSet()) {
        retVal.setSectionPaint(tmpEntry.getKey(), tmpEntry.getValue());
    }

    return retVal;
}
 
开发者ID:optimatika,项目名称:ojAlgo-extensions,代码行数:29,代码来源:PieChartBuilder.java

示例15: CountryAllocationPane

import org.jfree.chart.plot.PiePlot; //导入方法依赖的package包/类
public CountryAllocationPane(Portfolio portfolio ) {
	this.dataset = new DefaultPieDataset();
	Set<Entry<String, Double>> bookEntries = portfolio.getCountryAllocations();
	double totalValue = portfolio.getPortfolioValue();
	
	for (Entry<String, Double> entry : bookEntries) {
		double percentage = (Double) entry.getValue()/totalValue * 100.0 ;
		dataset.setValue(entry.getKey(), new Double(percentage) );
	}

	this.chart = ChartFactory.createPieChart(
			"Maantieteellinen jakauma", // The chart title
			dataset,         // The dataset for the chart
			false,          // Is a legend required?
			true,          // Use tooltips
			false          // Configure chart to generate URLs?
			);
	/* Creating a pieplot so as to customize the chart  generated */
	final PiePlot plot = (PiePlot)chart.getPlot( ); 

	/* Customizing Label using an inner class */

	plot.setLabelGenerator(new StandardPieSectionLabelGenerator(
			"{0} = {2}", NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance()
			));
	// Create this panel
	this.setLayout( new GridLayout( 1, 1 ) );
	this.panel = new ChartPanel( chart );

	this.add( panel );
}
 
开发者ID:skarna1,项目名称:javaportfolio,代码行数:32,代码来源:CountryAllocationPane.java


注:本文中的org.jfree.chart.plot.PiePlot.setLabelGenerator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。