本文整理匯總了Java中org.jfree.chart.plot.PiePlot.setForegroundAlpha方法的典型用法代碼示例。如果您正苦於以下問題:Java PiePlot.setForegroundAlpha方法的具體用法?Java PiePlot.setForegroundAlpha怎麽用?Java PiePlot.setForegroundAlpha使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jfree.chart.plot.PiePlot
的用法示例。
在下文中一共展示了PiePlot.setForegroundAlpha方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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) ) );
}
示例2: 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");
}
示例3: setResults
import org.jfree.chart.plot.PiePlot; //導入方法依賴的package包/類
/**
* Sets the new results for display.
*
* @param prediction Float array corresponding to the classifier prediction.
* @param classifierName String that is the classifier name.
* @param classColors Color array representing the class color.
* @param classNames String array representing the class names.
*/
public void setResults(float[] prediction, String classifierName,
Color[] classColors, String[] classNames) {
int numClasses = classNames.length;
DefaultPieDataset pieData = new DefaultPieDataset();
for (int cIndex = 0; cIndex < numClasses; cIndex++) {
pieData.setValue(classNames[cIndex], prediction[cIndex]);
}
JFreeChart chart = ChartFactory.createPieChart3D(classifierName
+ " prediction", pieData, true, true, false);
PiePlot plot = (PiePlot) chart.getPlot();
plot.setDirection(Rotation.CLOCKWISE);
plot.setForegroundAlpha(0.5f);
PieRenderer prend = new PieRenderer(classColors);
prend.setColor(plot, pieData);
ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new Dimension(140, 140));
resultChartPanel.removeAll();
resultChartPanel.add(chartPanel);
resultChartPanel.revalidate();
resultChartPanel.repaint();
}
示例4: doFrame
import org.jfree.chart.plot.PiePlot; //導入方法依賴的package包/類
@Override
protected void doFrame(int frame, double pct) {
JFreeChart pieChart = mpplot.getPieChart();
PiePlot plot = (PiePlot) pieChart.getPlot();
plot.setStartAngle(spinInterpolator.value(initialAngle, finalAngle, pct));
plot.setForegroundAlpha((float) alphaInterpolator.value(0.0, 1.0, pct));
// need to trigger a repaint, because the pie plot is just a stamper
mpplot.datasetChanged(new DatasetChangeEvent(pieChart, mpplot.getDataset()));
}
示例5: 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;
}
示例6: 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;
}
示例7: generatePieChart
import org.jfree.chart.plot.PiePlot; //導入方法依賴的package包/類
private byte[] generatePieChart(
String siteId, PieDataset dataset, int width, int height,
boolean render3d, float transparency,
boolean smallFontInDomainAxis) {
JFreeChart chart = null;
if(render3d)
chart = ChartFactory.createPieChart3D(null, dataset, false, false, false);
else
chart = ChartFactory.createPieChart(null, dataset, false, false, false);
PiePlot plot = (PiePlot) chart.getPlot();
// set start angle (135 or 150 deg so minor data has more space on the left)
plot.setStartAngle(150D);
// set transparency
plot.setForegroundAlpha(transparency);
// set background
chart.setBackgroundPaint(parseColor(M_sm.getChartBackgroundColor()));
plot.setBackgroundPaint(parseColor(M_sm.getChartBackgroundColor()));
// fix border offset
chart.setPadding(new RectangleInsets(5,5,5,5));
plot.setInsets(new RectangleInsets(1,1,1,1));
// set chart border
plot.setOutlinePaint(null);
chart.setBorderVisible(true);
chart.setBorderPaint(parseColor("#cccccc"));
// set antialias
chart.setAntiAlias(true);
BufferedImage img = chart.createBufferedImage(width, height);
final ByteArrayOutputStream out = new ByteArrayOutputStream();
try{
ImageIO.write(img, "png", out);
}catch(IOException e){
log.warn("Error occurred while generating SiteStats chart image data", e);
}
return out.toByteArray();
}
示例8: setResults
import org.jfree.chart.plot.PiePlot; //導入方法依賴的package包/類
/**
* Sets the data to be shown.
*
* @param occurrenceProfile Double array that is the neighbor occurrence
* profile of this visual word.
* @param codebookIndex Integer that is the index of this visual word.
* @param classColors Color[] of class colors.
* @param classNames String[] of class names.
*/
public void setResults(double[] occurrenceProfile, int codebookIndex,
Color[] classColors, String[] classNames) {
int numClasses = Math.min(classNames.length, occurrenceProfile.length);
this.codebookIndex = codebookIndex;
this.occurrenceProfile = occurrenceProfile;
DefaultPieDataset pieData = new DefaultPieDataset();
for (int cIndex = 0; cIndex < numClasses; cIndex++) {
pieData.setValue(classNames[cIndex], occurrenceProfile[cIndex]);
}
JFreeChart chart = ChartFactory.createPieChart3D("codebook vect "
+ codebookIndex, pieData, true, true, false);
PiePlot plot = (PiePlot) chart.getPlot();
plot.setDirection(Rotation.CLOCKWISE);
plot.setForegroundAlpha(0.5f);
PieRenderer prend = new PieRenderer(classColors);
prend.setColor(plot, pieData);
ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new Dimension(140, 140));
chartPanel.setVisible(true);
chartPanel.revalidate();
chartPanel.repaint();
JPanel jp = new JPanel();
jp.setPreferredSize(new Dimension(140, 140));
jp.setMinimumSize(new Dimension(140, 140));
jp.setMaximumSize(new Dimension(140, 140));
jp.setSize(new Dimension(140, 140));
jp.setLayout(new FlowLayout());
jp.add(chartPanel);
jp.setVisible(true);
jp.validate();
jp.repaint();
JFrame frame = new JFrame();
frame.setBackground(Color.WHITE);
frame.setUndecorated(true);
frame.getContentPane().add(jp);
frame.pack();
BufferedImage bi = new BufferedImage(jp.getWidth(), jp.getHeight(),
BufferedImage.TYPE_INT_ARGB);
Graphics2D graphics = bi.createGraphics();
jp.print(graphics);
graphics.dispose();
frame.dispose();
imPanel.removeAll();
imPanel.setImage(bi);
imPanel.setVisible(true);
imPanel.revalidate();
imPanel.repaint();
}
示例9: 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;
}
示例10: getPieChart
import org.jfree.chart.plot.PiePlot; //導入方法依賴的package包/類
public String getPieChart(String type , String title , Map hashMap , Date startDate , Date endDate) {
CHARTS_PATH = "C://" + type + startDate.getTime()+endDate.getTime()+".jpg";
File file = new File(CHARTS_PATH);
if(file.exists()){
file.delete();
}
try {
DefaultPieDataset dataset = new DefaultPieDataset();
for(Object o : hashMap.keySet()){
dataset.setValue(String.valueOf(o), Integer.parseInt((String) hashMap.get(o)));
}
JFreeChart chart = ChartFactory.createPieChart3D( title, // 圖表標題
dataset, // 繪圖數據集
false, // 設定是否顯示圖例
false, // 設定是否顯示圖例名稱
false); // 設定是否生成鏈接
chart.setAntiAlias(false);
PiePlot pieplot = (PiePlot)chart.getPlot();
pieplot.setLabelFont(new Font("宋體", 0, 15));
pieplot.setNoDataMessage("NO DATA!");
pieplot.setCircular(true);
pieplot.setLabelGap(0.02D);
pieplot.setBackgroundPaint(new Color(199,237,204));
pieplot.setLabelGenerator(new StandardPieSectionLabelGenerator(
"{0} {2}",
NumberFormat.getNumberInstance(),
new DecimalFormat("0.00%")));
pieplot.setForegroundAlpha(0.6f);
LegendTitle legendtitle = new LegendTitle(chart.getPlot());
legendtitle.setWidth(100D);
BlockContainer blockcontainer = new BlockContainer(new BorderArrangement());
blockcontainer.setBorder(new BlockBorder(1.0D, 1.0D, 1.0D, 1.0D));
LabelBlock labelblock = new LabelBlock("Percent:", new Font("宋體", 1, 16));
labelblock.setPadding(5D, 5D, 5D, 5D);
blockcontainer.add(labelblock, RectangleEdge.TOP);
BlockContainer blockcontainer1 = legendtitle.getItemContainer();
blockcontainer1.setPadding(2D, 10D, 5D, 2D);
blockcontainer.add(blockcontainer1);
legendtitle.setWrapper(blockcontainer);
legendtitle.setPosition(RectangleEdge.RIGHT);
legendtitle.setHorizontalAlignment(HorizontalAlignment.LEFT);
chart.addSubtitle(legendtitle);
chart.setBackgroundPaint(new Color(199,237,204));
TextTitle pcTitle = chart.getTitle();
pcTitle.setFont(new Font("漢真廣標", Font.BOLD, 21));
pcTitle.setPaint(Color.RED);
ChartUtilities.saveChartAsJPEG(file, chart, CHARTS_WIDTH, CHARTS_HEIGHT);
} catch (Exception e) {
e.printStackTrace();
}
return CHARTS_PATH;
}