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


Java PiePlot.setLegendLabelGenerator方法代码示例

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


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

示例1: testDrawWithNullLegendLabels

import org.jfree.chart.plot.PiePlot; //导入方法依赖的package包/类
/**
 * Draws a pie chart where the label generator returns null.
 */
public void testDrawWithNullLegendLabels() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("L1", 12.0);
    dataset.setValue("L2", 11.0);
    JFreeChart chart = ChartFactory.createPieChart("Test", dataset, true);
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setLegendLabelGenerator(new NullLegendLabelGenerator());
    boolean success = false;
    try {
        BufferedImage image = new BufferedImage(200 , 100,
                BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = image.createGraphics();
        chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
        g2.dispose();
        success = true;
    }
    catch (Exception e) {
      success = false;
    }
    assertTrue(success);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:25,代码来源:PiePlotTests.java

示例2: createPieChart

import org.jfree.chart.plot.PiePlot; //导入方法依赖的package包/类
private JFreeChart createPieChart() throws QueryException {		
	pieDataset = new DefaultPieDataset();
	String chartTitle = replaceParameters(chart.getTitle().getTitle());
	chartTitle = StringUtil.getI18nString(chartTitle, I18nUtil.getLanguageByName(chart, language));
	JFreeChart jfreechart = ChartFactory.createPieChart(
			    chartTitle,
                pieDataset, 
                true, 
                true, 
                false);
	
	// hide border
	jfreechart.setBorderVisible(false);
	
	// title
	setTitle(jfreechart);
	
	PiePlot plot = (PiePlot)jfreechart.getPlot();
	plot.setForegroundAlpha(transparency);
	// a start angle used to create similarities between flash chart and this jfreechart
	plot.setStartAngle(330);	
	// legend label will contain the text and the value
	plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0} = {1}"));
	
	// no shadow
	plot.setShadowXOffset(0);
	plot.setShadowYOffset(0);
	
	DecimalFormat decimalformat;
	DecimalFormat percentageFormat;
	if (chart.getYTooltipPattern() == null) {
       	decimalformat = new DecimalFormat("#");
       	percentageFormat = new DecimalFormat("0.00%");
	} else {
		decimalformat = new DecimalFormat(chart.getYTooltipPattern());
		percentageFormat = decimalformat;
	}
	boolean showValues = (chart.getShowYValuesOnChart() == null) ? false : chart.getShowYValuesOnChart();
	if (showValues) {
		// label will contain also the percentage formatted with two decimals
		plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2})", decimalformat, percentageFormat));
	}
	
	// chart background
       plot.setBackgroundPaint(chart.getBackground());
                                                     
       createChart(null, new Object[1]);   
       
       // after chart creation we can set slices colors
       List <Comparable> keys = pieDataset.getKeys();
       List<Color> colors = chart.getForegrounds();
       for (int i = 0, size = colors.size(); i < keys.size(); i++) {            	
           plot.setSectionPaint(keys.get(i), colors.get(i % size));
           plot.setLabelFont(chart.getFont());
       }
	
	return jfreechart;
}
 
开发者ID:nextreports,项目名称:nextreports-engine,代码行数:59,代码来源:JFreeChartExporter.java

示例3: renderChartInfo

import org.jfree.chart.plot.PiePlot; //导入方法依赖的package包/类
private void renderChartInfo() {
    Hashtable<Object, Marker> marks = new Hashtable<>();
    DefaultPieDataset dataset = buildDataset(marks);

    JFreeChart chart = ChartFactory.createPieChart(
            null, // chart title
            dataset, // data
            true, // include legend
            true,
            false);
    chart.setBackgroundPaint(null);
    //chart.setBorderStroke(null);
    chart.setBorderVisible(false);
    final PiePlot plot = (PiePlot) chart.getPlot();
    // plot.setBackgroundPaint(null);
    //  plot.setShadowPaint(null);

    Enumeration<Object> markKeys = marks.keys();


    while (markKeys.hasMoreElements()) {
        if (iCurrentView == ID_ALLY_CHART) {
            Ally a = (Ally) markKeys.nextElement();
            plot.setSectionPaint(a.getTag(), marks.get(a).getMarkerColor());
        } else {
            Tribe t = (Tribe) markKeys.nextElement();
            plot.setSectionPaint(t.getName(), marks.get(t).getMarkerColor());
        }
    }
    //plot.setCircular(true);
    //  plot.setMaximumLabelWidth(30.0);
 /*
     * plot.setLabelGenerator(new StandardPieSectionLabelGenerator( "{0} = {2}", NumberFormat.getNumberInstance(),
     * NumberFormat.getPercentInstance()));
     */
    //   chart.getLegend().setVerticalAlignment(VerticalAlignment.CENTER);
    //  chart.getLegend().setPosition(RectangleEdge.RIGHT);
    // plot.setMaximumLabelWidth(20.0);
    plot.setLabelGenerator(null);
    plot.setBackgroundPaint(Constants.DS_BACK);
    /*
     * plot.setInteriorGap(0.0); plot.setLabelGap(0.0);
     */
    plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator(
            "{0} = {2}", NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance()));

    /*
     * plot.getL plot.setLabelFont(g2d.getFont().deriveFont(10.0f));
     */


    //plot.setLabelGenerator(null);

    //plot.setMaximumLabelWidth(30.0);
    //plot.getLabelDistributor().distributeLabels(10.0, 20.0);
    //chart.draw(g2d, new Rectangle2D.Float(20, 20, 100, 100));

    //  g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
    plot.setOutlineVisible(false);
    mChartImage = chart.createBufferedImage(getWidth(), getHeight());
    //chart.draw(g2d, new Rectangle2D.Float(50, 50, 400, 400));
    //g2d.drawImage(bi, 30, 30, null);

    //  g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));

    //bi = chart.createBufferedImage(240, 240);
    // g2d.drawImage(bi, 30, 30, null);
}
 
开发者ID:Torridity,项目名称:dsworkbench,代码行数:69,代码来源:MinimapPanel.java

示例4: chartPie

import org.jfree.chart.plot.PiePlot; //导入方法依赖的package包/类
private void chartPie() throws PageException, IOException {
	// do dataset
	DefaultPieDataset dataset = new DefaultPieDataset();
	ChartSeriesBean csb =  _series.get(0);
       
	ChartDataBean cdb;
       
	List datas=csb.getDatas();
	if(sortxaxis)Collections.sort(datas);
       Iterator itt = datas.iterator();
   	while(itt.hasNext()) {
   		cdb=(ChartDataBean) itt.next();
   		dataset.setValue(cdb.getItemAsString(), cdb.getValue());
   	}	
	
   	
       JFreeChart chart = show3d?
       		ChartFactory.createPieChart3D	(title, dataset, false, true, true):
       		ChartFactory.createPieChart		(title, dataset, false, true, true);
       
       Plot p = chart.getPlot();
	PiePlot pp = (PiePlot)p;
       
	Font _font = getFont();
       pp.setLegendLabelGenerator(new PieSectionLegendLabelGeneratorImpl(_font,chartwidth));
       pp.setBaseSectionOutlinePaint(Color.GRAY); // border
       pp.setLegendItemShape(new Rectangle(7,7));
       pp.setLabelFont(new Font(font,0,11));
       pp.setLabelLinkPaint(COLOR_333333);
       pp.setLabelLinkMargin(-0.05);
       pp.setInteriorGap(0.123);
       pp.setLabelGenerator(new PieSectionLabelGeneratorImpl(labelFormat));
       
       
       
       
       databackgroundcolor=backgroundcolor;
       
       setBackground(chart,p);
	setBorder(chart,p);
	setLegend(chart,p,_font);
	set3d(p);
	setFont(chart, _font);
       setTooltip(chart);
       setScale(chart);
       
       // Slice Type and colors
       boolean doSclice=pieslicestyle==PIE_SLICE_STYLE_SLICED;
       Color[] colors = csb.getColorlist();
       Iterator it = csb.getDatas().iterator();
       int count=0;
   	while(it.hasNext()) {
   		cdb=(ChartDataBean) it.next();
           if(doSclice)pp.setExplodePercent(cdb.getItemAsString(), 0.13);
           
           if(count<colors.length){
           	pp.setSectionPaint(cdb.getItemAsString(), colors[count]);
           }
           count++;
   	}
       
       writeOut(chart);
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:64,代码来源:Chart.java

示例5: getPieChart

import org.jfree.chart.plot.PiePlot; //导入方法依赖的package包/类
/**
 * Creates a Pie Chart based on map.
 *
 * @return the Pie Chart generated.
 */
public JFreeChart getPieChart(Map<String, Double> pieValues) {
    DefaultPieDataset dataset = new DefaultPieDataset();

    for (String key : pieValues.keySet()) {
        dataset.setValue(key, pieValues.get(key));
    }

    JFreeChart chart = ChartFactory.createPieChart3D(
            null,  // chart title
            dataset, // data
            true,    // include legend
            true,
            false
    );

    chart.setBackgroundPaint(Color.white);
    chart.setBorderVisible(false);
    chart.setBorderPaint(null);


    PiePlot plot = (PiePlot)chart.getPlot();
    plot.setSectionOutlinesVisible(false);
    plot.setLabelFont(new Font("SansSerif", Font.BOLD, 12));
    plot.setNoDataMessage("No data available");
    plot.setCircular(true);
    plot.setLabelGap(0.02);
    plot.setOutlinePaint(null);
    plot.setLabelLinksVisible(false);

    plot.setLabelGenerator(null);

    plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}"));


    plot.setStartAngle(270);
    plot.setDirection(Rotation.ANTICLOCKWISE);
    plot.setForegroundAlpha(0.60f);
    plot.setInteriorGap(0.33);

    return chart;
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:47,代码来源:GraphEngine.java


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