本文整理汇总了Java中org.jfree.chart.plot.PiePlot类的典型用法代码示例。如果您正苦于以下问题:Java PiePlot类的具体用法?Java PiePlot怎么用?Java PiePlot使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PiePlot类属于org.jfree.chart.plot包,在下文中一共展示了PiePlot类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createChartCategory
import org.jfree.chart.plot.PiePlot; //导入依赖的package包/类
/**
* Creates a sample chart for the given dataset.
*
* @param dataset
* the dataset.
*
* @return A sample chart.
*/
private JFreeChart createChartCategory(final CategoryDataset dataset) {
final JFreeChart chart = ChartFactory.createMultiplePieChart3D("Multiple Pie Chart Demo 4", dataset,
TableOrder.BY_COLUMN, false, true, false);
chart.setBackgroundPaint(new Color(216, 255, 216));
final MultiplePiePlot plot = (MultiplePiePlot) chart.getPlot();
final JFreeChart subchart = plot.getPieChart();
// final StandardLegend legend = new StandardLegend();
// legend.setItemFont(new Font("SansSerif", Font.PLAIN, 8));
// legend.setAnchor(Legend.SOUTH);
// subchart.setLegend(legend);
plot.setLimit(0.10);
final PiePlot p = (PiePlot) subchart.getPlot();
// p.setLabelGenerator(new StandardPieItemLabelGenerator("{0}"));
p.setLabelFont(new Font("SansSerif", Font.PLAIN, 8));
p.setInteriorGap(0.30);
return chart;
}
示例2: 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}"));
}
示例3: 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));
}
示例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 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);
}
示例5: createChart
import org.jfree.chart.plot.PiePlot; //导入依赖的package包/类
/**
* Creates a chart.
*
* @param dataset the dataset.
*
* @return A chart.
*/
private static JFreeChart createChart(PieDataset dataset) {
JFreeChart chart = ChartFactory.createPieChart(
"Pie Chart Demo 1", // chart title
dataset, // data
true, // include legend
true,
false
);
PiePlot plot = (PiePlot) chart.getPlot();
plot.setSectionOutlinesVisible(false);
plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
plot.setNoDataMessage("No data available");
plot.setCircular(false);
plot.setLabelGap(0.02);
return chart;
}
示例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</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);
}
示例7: 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;
}
示例8: applyToPiePlot
import org.jfree.chart.plot.PiePlot; //导入依赖的package包/类
/**
* Applies the attributes of this theme to a {@link PiePlot} instance.
* This method also clears any set values for the section paint, outline
* etc, so that the theme's {@link DrawingSupplier} will be used.
*
* @param plot the plot (<code>null</code> not permitted).
*/
protected void applyToPiePlot(PiePlot plot) {
plot.setLabelLinkPaint(this.labelLinkPaint);
plot.setLabelLinkStyle(this.labelLinkStyle);
plot.setLabelFont(this.regularFont);
plot.setShadowGenerator(this.shadowGenerator);
// clear the section attributes so that the theme's DrawingSupplier
// will be used
if (plot.getAutoPopulateSectionPaint()) {
plot.clearSectionPaints(false);
}
if (plot.getAutoPopulateSectionOutlinePaint()) {
plot.clearSectionOutlinePaints(false);
}
if (plot.getAutoPopulateSectionOutlineStroke()) {
plot.clearSectionOutlineStrokes(false);
}
}
示例9: mouseWheelMoved
import org.jfree.chart.plot.PiePlot; //导入依赖的package包/类
/**
* Handles a mouse wheel event from the underlying chart panel.
*
* @param e the event.
*/
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
JFreeChart chart = this.chartPanel.getChart();
if (chart == null) {
return;
}
Plot plot = chart.getPlot();
if (plot instanceof Zoomable) {
Zoomable zoomable = (Zoomable) plot;
handleZoomable(zoomable, e);
}
else if (plot instanceof PiePlot) {
PiePlot pp = (PiePlot) plot;
pp.handleMouseWheelRotation(e.getWheelRotation());
}
}
示例10: 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;
}
示例11: applyToPiePlot
import org.jfree.chart.plot.PiePlot; //导入依赖的package包/类
/**
* Applies the attributes of this theme to a {@link PiePlot} instance.
* This method also clears any set values for the section paint, outline
* etc, so that the theme's {@link DrawingSupplier} will be used.
*
* @param plot the plot ({@code null} not permitted).
*/
protected void applyToPiePlot(PiePlot plot) {
plot.setLabelLinkPaint(this.labelLinkPaint);
plot.setLabelLinkStyle(this.labelLinkStyle);
plot.setLabelFont(this.regularFont);
plot.setShadowGenerator(this.shadowGenerator);
// clear the section attributes so that the theme's DrawingSupplier
// will be used
if (plot.getAutoPopulateSectionPaint()) {
plot.clearSectionPaints(false);
}
if (plot.getAutoPopulateSectionOutlinePaint()) {
plot.clearSectionOutlinePaints(false);
}
if (plot.getAutoPopulateSectionOutlineStroke()) {
plot.clearSectionOutlineStrokes(false);
}
}
示例12: fillChart
import org.jfree.chart.plot.PiePlot; //导入依赖的package包/类
private void fillChart(String title, List<String> names,
List<String> colors, List<Float> values) throws Exception {
DefaultPieDataset data=new DefaultPieDataset();
for (int ix=0; ix<names.size(); ix++) {
data.setValue( names.get(ix), values.get(ix) );
}
this.chart=ChartFactory.createPieChart3D(
title,
data,
true,
true,
false);
LegendTitle legend=this.chart.getLegend();
legend.setItemFont(new Font("", Font.TRUETYPE_FONT, 9) );
PiePlot plot=(PiePlot)this.chart.getPlot();
plot.setCircular(true);
plot.setBackgroundAlpha(0.9f);
plot.setForegroundAlpha(0.5f);
plot.setLabelFont(new Font("", Font.TRUETYPE_FONT, 9) );
this.setPlotColor( plot, names, colors );
this.chart.setTitle(new TextTitle(title, new Font("", Font.TRUETYPE_FONT, 9) ) );
}
示例13: PieChart
import org.jfree.chart.plot.PiePlot; //导入依赖的package包/类
public PieChart(DefaultPieDataset dataset, String title, String hostIP){
Font titleFont = new Font("微软雅黑", Font.BOLD, 14);
Font legendFont = new Font("微软雅黑", Font.PLAIN, 10);
Font plotFont = new Font("微软雅黑", Font.PLAIN, 12);
this.dataset = dataset;
this.title = title;
this.hostIP = hostIP;
// create a chart...
chart = ChartFactory.createPieChart(this.title,dataset,true, // legend?
true, // tooltips?
false // URLs?
);
chart.getLegend().setItemFont(legendFont);//设置图例字体
chart.getTitle().setFont(titleFont);//设置标题字体
PiePlot plot = (PiePlot)chart.getPlot();//设置字体
plot.setLabelFont(plotFont);
}
示例14: 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);
}
}
示例15: createPieChartPage
import org.jfree.chart.plot.PiePlot; //导入依赖的package包/类
/**
* Creates the PieChart page.
*/
void createPieChartPage() {
result = new DefaultPieDataset();
JFreeChart chart = ChartFactory.createPieChart("Design Decisions", result, true, true, false);
PiePlot plot = (PiePlot) chart.getPlot();
plot.setStartAngle(290);
plot.setDirection(Rotation.CLOCKWISE);
plot.setForegroundAlpha(0.5f);
Composite composite = new Composite(getContainer(), SWT.NONE);
FillLayout layout = new FillLayout();
composite.setLayout(layout);
new ChartComposite(composite, SWT.NONE, chart, true);
int index = addPage(composite);
setPageText(index, "Graph");
}