本文整理匯總了Java中org.jfree.chart.plot.PiePlot.setExplodePercent方法的典型用法代碼示例。如果您正苦於以下問題:Java PiePlot.setExplodePercent方法的具體用法?Java PiePlot.setExplodePercent怎麽用?Java PiePlot.setExplodePercent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jfree.chart.plot.PiePlot
的用法示例。
在下文中一共展示了PiePlot.setExplodePercent方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createNewSerie
import org.jfree.chart.plot.PiePlot; //導入方法依賴的package包/類
@Override
protected void createNewSerie(final IScope scope, final String serieid) {
// final ChartDataSeries dataserie = chartdataset.getDataSeries(scope,
// serieid);
final PiePlot plot = (PiePlot) this.chart.getPlot();
// final DefaultPieDataset firstdataset = (DefaultPieDataset)
// plot.getDataset();
nbseries++;
IdPosition.put(serieid, nbseries - 1);
if (getStyle().equals(IKeyword.EXPLODED)) {
plot.setExplodePercent(serieid, 0.20);
}
// System.out.println("new serie"+serieid+" at
// "+IdPosition.get(serieid)+" jfds "+jfreedataset.size()+" datasc "+"
// nbse "+nbseries);
}
示例2: addDiskUsageObservation
import org.jfree.chart.plot.PiePlot; //導入方法依賴的package包/類
private void addDiskUsageObservation(long usedSize, long availableSize) {
String usedLabel = "已使用"+usedSize/(1024*1024)+"GB";
String avaiLabel = "未使用"+availableSize/(1024*1024)+"GB";
dataset.clear();
dataset.setValue(avaiLabel, availableSize);
dataset.setValue(usedLabel, usedSize);
PiePlot plot = (PiePlot)chart.getPlot();
plot.setExplodePercent(avaiLabel, 0.05);
plot.setExplodePercent(usedLabel, 0.05);
plot.setSectionPaint(avaiLabel, Color.BLUE);
plot.setSectionPaint(usedLabel, Color.RED);
}
示例3: createChart
import org.jfree.chart.plot.PiePlot; //導入方法依賴的package包/類
/**
* Creates a demo chart.
*
* @param dataset the dataset.
*
* @return A chart.
*/
protected JFreeChart createChart(PieDataset dataset) {
dataset = null;
JFreeChart chart = ChartFactory.createPieChart(
chartTitle, // chart title
dataset, // data
!legendPanelOn, // include legend
true,
false
);
PiePlot plot = (PiePlot) chart.getPlot();
plot.setNoDataMessage(
"No data available so we go into this really "
+ "long spiel about what that means and it runs off the end of the "
+ "line but what can you do about that!"
);
plot.setNoDataMessageFont(new Font("Serif", Font.ITALIC, 10));
plot.setNoDataMessagePaint(Color.red);
for (int i=0; i<pulloutFlag.length; i++){
//System.out.println("\""+pulloutFlag[i]+"\"");
if (isPullout(i)){
Comparable key = dataset.getKey(i);
plot.setExplodePercent(key, 0.30);
}
}
if(rotateOn){
Rotator rotator = new Rotator(plot);
rotator.start();
}
setCategorySummary(dataset);
return chart;
}
示例4: createChart
import org.jfree.chart.plot.PiePlot; //導入方法依賴的package包/類
protected JFreeChart createChart(PieDataset dataset) {
// create the chart...
JFreeChart chart = ChartFactory.createPieChart(
chartTitle, // chart title
dataset, // dataset
!legendPanelOn, // include legend
true,
false
);
// set the background color for the chart...
chart.setBackgroundPaint(new Color(222, 222, 255));
PiePlot plot = (PiePlot) chart.getPlot();
plot.setBackgroundPaint(Color.white);
plot.setCircular(true);
for (int i=0; i<pulloutFlag.length; i++){
//System.out.println("\""+pulloutFlag[i]+"\"");
if (isPullout(i)){
Comparable key = dataset.getKey(i);
plot.setExplodePercent(key, 0.30);
}
}
plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} = {2}",
NumberFormat.getNumberInstance(),
NumberFormat.getPercentInstance()));
plot.setNoDataMessage("No data available");
if(rotateOn){
Rotator rotator = new Rotator(plot);
rotator.start();
}
setCategorySummary(dataset);
return chart;
}
示例5: createChart
import org.jfree.chart.plot.PiePlot; //導入方法依賴的package包/類
/**
* Creates a chart
*
* @param dataset the dataset.
*
* @return a chart.
*/
protected JFreeChart createChart(PieDataset dataset) {
JFreeChart chart = ChartFactory.createPieChart(
chartTitle, // chart title
dataset, // data
!legendPanelOn, // include legend
true,
false
);
TextTitle title = chart.getTitle();
title.setToolTipText("A title tooltip!");
PiePlot plot = (PiePlot)chart.getPlot();
for (int i=0; i<pulloutFlag.length; i++){
//System.out.println("\""+pulloutFlag[i]+"\"");
if (isPullout(i)){
Comparable key = dataset.getKey(i);
plot.setExplodePercent(key, 0.30);
}
}
plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
plot.setNoDataMessage("No data available");
plot.setCircular(false);
plot.setLabelGap(0.02);
setCategorySummary(dataset);
if(rotateOn){
Rotator rotator = new Rotator(plot);
rotator.start();
}
return chart;
}
示例6: createChart
import org.jfree.chart.plot.PiePlot; //導入方法依賴的package包/類
/**
* Creates a sample chart.
*
* @param dataset the dataset.
*
* @return A chart.
*/
protected JFreeChart createChart(PieDataset dataset) {
JFreeChart chart = ChartFactory.createPieChart(
chartTitle, // chart title
dataset, // dataset
!legendPanelOn, // include legend
true,
false
);
PiePlot plot = (PiePlot) chart.getPlot();
plot.setNoDataMessage("No data available");
for (int i=0; i<pulloutFlag.length; i++){
//System.out.println("\""+pulloutFlag[i]+"\"");
if (isPullout(i)){
Comparable key = dataset.getKey(i);
plot.setExplodePercent(key, 0.30);
}
}
plot.setLegendLabelToolTipGenerator(
new StandardPieSectionLabelGenerator("Tooltip for legend item {0}")
);
if(rotateOn){
Rotator rotator = new Rotator(plot);
rotator.start();
}
setCategorySummary(dataset);
return chart;
}
示例7: createChart
import org.jfree.chart.plot.PiePlot; //導入方法依賴的package包/類
/**
* Creates a chart.
*
* @param dataset the dataset.
*
* @return a chart.
*/
protected JFreeChart createChart(PieDataset dataset) {
JFreeChart chart = ChartFactory.createPieChart(
chartTitle, // chart title
dataset, // data
!legendPanelOn, // include legend
true,
false
);
TextTitle title = chart.getTitle();
title.setToolTipText("A title tooltip!");
PiePlot plot = (PiePlot) chart.getPlot();
if (!ThreeDPie){
for (int i=0; i<pulloutFlag.length; i++){
//System.out.println("SuperPieChart\""+pulloutFlag[i]+"\"");
if (pulloutFlag[i].equals("1")){
Comparable key = dataset.getKey(i);
plot.setExplodePercent(key, 0.30);
}
}
}
plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
plot.setNoDataMessage("No data available");
plot.setCircular(false);
plot.setLabelGap(0.02);
return chart;
}
示例8: createAndShow
import org.jfree.chart.plot.PiePlot; //導入方法依賴的package包/類
/**
*
* @throws Exception
*/
@Override
public void createAndShow() throws Exception{
piePlt frameToShow;
//toShow = toShow.replace(" ","");
if(!toShow.startsWith("piePlt")||toShow.length()<7)
return;
String tt = jc.getInside(toShow.substring(7),'(',')');
String title=null,exploded=null,bf="";
if(tt.indexOf('{')==-1)
throw new Exception("piePlot is not defined correctly!");
String txt=tt.substring(0,tt.indexOf('{'));
for(int i = 0;i<txt.length();i++){
if(txt.charAt(i) == ','){
if(bf.contentEquals(""))
throw new Exception("piePlot is not defined correctly!");
if(bf.indexOf('=')!= -1){
switch (bf.substring(0,bf.indexOf('=')).toLowerCase().trim()) {
case "title":
if(title != null)
throw new Exception("piePlot is not defined correctly!");
title=bf.substring(bf.indexOf('=')+1);
bf="";
break;
default:
if(exploded != null)
throw new Exception("piePlot is not defined correctly!");
exploded=bf;
bf="";
break;
}
}
else{
if(title == null){
title=bf;
bf="";
}else
throw new Exception("piePlot is not defined correctly!");
}
}
else
bf=bf+txt.charAt(i);
}
if(tt.endsWith("{"))
throw new Exception("barPlot is not defined correctly!");
txt = tt.substring(tt.indexOf('{')+1);
frameToShow = new piePlt(title,jc.getInside(txt,'{','}'));
ChartPanel chartP = new ChartPanel(frameToShow.getChart());
chartP.setPreferredSize(new java.awt.Dimension(500, 500));
chartP.setEnforceFileExtensions(false);
if(exploded != null){
PiePlot plot = (PiePlot) frameToShow.getChart().getPlot();
plot.setExplodePercent(exploded.substring(0,exploded.indexOf('=')),
new Double(jc.eval("2dbl("+jc.eval(exploded.substring(exploded.indexOf('=')+1))+")")) );
}
frameToShow.setContentPane(chartP);
frameToShow.setJMenuBar(barPlt.getMenu(frameToShow.getChart(),frameToShow));
frameToShow.pack();
RefineryUtilities.centerFrameOnScreen(frameToShow);
frameToShow.setVisible(true);
}
示例9: createPieChart
import org.jfree.chart.plot.PiePlot; //導入方法依賴的package包/類
public static JFreeChart createPieChart(DefaultPieDataset dataset, String title, boolean is3D) {
JFreeChart chart = null;
if (is3D) {
chart = ChartFactory.createPieChart3D(title, // 圖表標題
dataset, // 數據集
true, // 是否顯示圖例
true, // 是否顯示工具提示
true // 是否生成URL
);
} else {
chart = ChartFactory.createPieChart(title, // 圖表標題
dataset, // 數據集
true, // 是否顯示圖例
true, // 是否顯示工具提示
true // 是否生成URL
);
}
// 設置標題字體==為了防止中文亂碼:必須設置字體
chart.setTitle(new TextTitle(title, new Font("黑體", Font.ITALIC, 22)));
// 設置圖例的字體==為了防止中文亂碼:必須設置字體
chart.getLegend().setItemFont(new Font("黑體", Font.BOLD, 12));
// 獲取餅圖的Plot對象(實際圖表)
PiePlot plot = (PiePlot) chart.getPlot();
// 圖形邊框顏色
plot.setBaseSectionOutlinePaint(Color.GRAY);
// 圖形邊框粗細
plot.setBaseSectionOutlineStroke(new BasicStroke(0.0f));
// 設置餅狀圖的繪製方向,可以按順時針方向繪製,也可以按逆時針方向繪製
plot.setDirection(Rotation.ANTICLOCKWISE);
// 設置繪製角度(圖形旋轉角度)
plot.setStartAngle(70);
// 設置突出顯示的數據塊
// plot.setExplodePercent("One", 0.1D);
// 設置背景色透明度
plot.setBackgroundAlpha(0.7F);
// 設置前景色透明度
plot.setForegroundAlpha(0.65F);
// 設置區塊標簽的字體==為了防止中文亂碼:必須設置字體
plot.setLabelFont(new Font("宋體", Font.PLAIN, 12));
// 扇區分離顯示,對3D圖不起效
if (is3D)
plot.setExplodePercent(dataset.getKey(3), 0.1D);
// 圖例顯示百分比:自定義方式,{0} 表示選項, {1} 表示數值, {2} 表示所占比例 ,小數點後兩位
plot.setLabelGenerator(new StandardPieSectionLabelGenerator(
"{0}:{1}\r\n({2})", NumberFormat.getNumberInstance(),
new DecimalFormat("0.00%")));
// 圖例顯示百分比
// plot.setLegendLabelGenerator(new
// StandardPieSectionLabelGenerator("{0}={1}({2})"));
// 指定顯示的餅圖為:圓形(true) 還是橢圓形(false)
plot.setCircular(true);
// 沒有數據的時候顯示的內容
plot.setNoDataMessage("找不到可用數據...");
// 設置鼠標懸停提示
plot.setToolTipGenerator(new StandardPieToolTipGenerator());
// 設置熱點鏈接
// plot.setURLGenerator(new StandardPieURLGenerator("detail.jsp"));
return chart;
}
示例10: 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);
}
示例11: updatePlotter
import org.jfree.chart.plot.PiePlot; //導入方法依賴的package包/類
public void updatePlotter() {
int categoryCount = prepareData();
String maxClassesProperty = ParameterService.getParameterValue(MainFrame.PROPERTY_RAPIDMINER_GUI_PLOTTER_LEGEND_CLASSLIMIT);
int maxClasses = 20;
try {
if (maxClassesProperty != null)
maxClasses = Integer.parseInt(maxClassesProperty);
} catch (NumberFormatException e) {
//LogService.getGlobal().log("Pie Chart plotter: cannot parse property 'rapidminer.gui.plotter.colors.classlimit', using maximal 20 different classes.", LogService.WARNING);
LogService.getRoot().log(Level.WARNING, "com.rapidminer.gui.plotter.charts.AbstractPieChartPlotter.pie_chart_plotter_parsing_error");
}
boolean createLegend = categoryCount > 0 && categoryCount < maxClasses;
if (categoryCount <= MAX_CATEGORIES) {
JFreeChart chart = createChart(pieDataSet, createLegend);
// set the background color for the chart...
chart.setBackgroundPaint(Color.white);
PiePlot plot = (PiePlot) chart.getPlot();
plot.setBackgroundPaint(Color.WHITE);
plot.setSectionOutlinesVisible(true);
plot.setShadowPaint(new Color(104, 104, 104, 100));
int size = pieDataSet.getKeys().size();
for (int i = 0; i < size; i++) {
Comparable key = pieDataSet.getKey(i);
plot.setSectionPaint(key, getColorProvider().getPointColor(i / (double) (size - 1)));
boolean explode = false;
for (String explosionGroup : explodingGroups) {
if (key.toString().startsWith(explosionGroup) || explosionGroup.startsWith(key.toString())) {
explode = true;
break;
}
}
if (explode) {
plot.setExplodePercent(key, this.explodingAmount);
}
}
plot.setLabelFont(LABEL_FONT);
plot.setNoDataMessage("No data available");
plot.setCircular(false);
plot.setLabelGap(0.02);
plot.setOutlinePaint(Color.WHITE);
// legend settings
LegendTitle legend = chart.getLegend();
if (legend != null) {
legend.setPosition(RectangleEdge.TOP);
legend.setFrame(BlockBorder.NONE);
legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
legend.setItemFont(LABEL_FONT);
}
if (panel instanceof AbstractChartPanel) {
panel.setChart(chart);
} else {
panel = new AbstractChartPanel(chart, getWidth(), getHeight() - MARGIN);
final ChartPanelShiftController controller = new ChartPanelShiftController(panel);
panel.addMouseListener(controller);
panel.addMouseMotionListener(controller);
}
// ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!!
panel.getChartRenderingInfo().setEntityCollection(null);
} else {
//LogService.getGlobal().logNote("Too many columns (" + categoryCount + "), this chart is only able to plot up to " + MAX_CATEGORIES + " different categories.");
LogService.getRoot().log(Level.INFO, "com.rapidminer.gui.plotter.charts.AbstractPieChartPlotter.too_many_columns",
new Object[] {categoryCount, MAX_CATEGORIES});
}
}