當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。