本文整理匯總了Java中org.jfree.data.general.DefaultPieDataset類的典型用法代碼示例。如果您正苦於以下問題:Java DefaultPieDataset類的具體用法?Java DefaultPieDataset怎麽用?Java DefaultPieDataset使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DefaultPieDataset類屬於org.jfree.data.general包,在下文中一共展示了DefaultPieDataset類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setUp
import org.jfree.data.general.DefaultPieDataset; //導入依賴的package包/類
/**
* Common test setup.
*/
protected void setUp() {
// create a dataset...
DefaultPieDataset data = new DefaultPieDataset();
data.setValue("Java", new Double(43.2));
data.setValue("Visual Basic", new Double(0.0));
data.setValue("C/C++", new Double(17.5));
// create the chart...
this.pieChart = ChartFactory.createPieChart(
"Pie Chart", // chart title
data, // data
true, // include legend
true,
false
);
}
示例2: piePlt
import org.jfree.data.general.DefaultPieDataset; //導入依賴的package包/類
public piePlt(String title, String Categories) throws Exception{
super("");
DefaultPieDataset dataset = new DefaultPieDataset();
String[] ct = Categories.split(";");
for(String bf: ct){
// if(bf.startsWith("("))
// bf=bf.substring(1);
// if(bf.endsWith(")"))
// bf=bf.substring(0,bf.length()-1);
dataset.setValue(bf.substring(0,bf.indexOf(',')),
new Double(jc.eval("2dbl("+jc.eval(bf.substring(bf.indexOf(',')+1))+")")));
}
if(title==null)
title = "Pie Chart";
chart = ChartFactory.createPieChart(
title,
dataset,
true, // include legend
true, // tooltips?
false // URLs?
);
}
示例3: PieChart
import org.jfree.data.general.DefaultPieDataset; //導入依賴的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: createChart
import org.jfree.data.general.DefaultPieDataset; //導入依賴的package包/類
@Override
public JFreeChart createChart(Element element, ChartSource source) {
Attribute key = source.getAttributeProperty(PIE_ATTRIBUTE_KEY);
Attribute value = source.getAttributeProperty(PIE_ATTRIBUTE_VALUE);
if ((key == null) || (value == null))
throw new ChartNotSetupedException();
DefaultPieDataset dataset = new DefaultPieDataset();
for (Element element2 : source.getElements()) {
Object v1 = engine.getAttribute(element2, key);
Object v2 = engine.getAttribute(element2, value);
if ((v1 != null) && (v2 != null))
dataset.setValue(toString(v1), toDouble(v2));
}
return ChartFactory.createPieChart(element.getName(), dataset, true,
true, false);
}
示例5: getChart
import org.jfree.data.general.DefaultPieDataset; //導入依賴的package包/類
/**
* Creates 3D pie chart with OS usage statistics.
*
* @return Filled 3D pie chart.
*/
public JFreeChart getChart() {
DefaultPieDataset data = new DefaultPieDataset();
data.setValue("Mac", 29);
data.setValue("Windows", 51);
data.setValue("Linux", 20);
JFreeChart chart = ChartFactory.createPieChart3D("", data);
PiePlot3D plot = (PiePlot3D) chart.getPlot();
plot.setStartAngle(290);
plot.setDirection(Rotation.CLOCKWISE);
plot.setForegroundAlpha(0.5f);
return chart;
}
示例6: testEquals
import org.jfree.data.general.DefaultPieDataset; //導入依賴的package包/類
/**
* Confirm that the equals method can distinguish all the required fields.
*/
public void testEquals() {
PieSectionEntity e1 = new PieSectionEntity(
new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new DefaultPieDataset(),
0, 1, "Key", "ToolTip", "URL"
);
StandardEntityCollection c1 = new StandardEntityCollection();
c1.addEntity(e1);
PieSectionEntity e2 = new PieSectionEntity(
new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new DefaultPieDataset(),
0, 1, "Key", "ToolTip", "URL"
);
StandardEntityCollection c2 = new StandardEntityCollection();
c2.addEntity(e2);
assertTrue(c1.equals(c2));
}
示例7: createPieChart
import org.jfree.data.general.DefaultPieDataset; //導入依賴的package包/類
/**
* Creates a pie chart.
*
* @return the pie chart.
*/
private static JFreeChart createPieChart() {
// create a dataset...
DefaultPieDataset data = new DefaultPieDataset();
data.setValue("Java", new Double(43.2));
data.setValue("Visual Basic", new Double(0.0));
data.setValue("C/C++", new Double(17.5));
// create the chart...
return ChartFactory.createPieChart("Pie Chart", // chart title
data, // data
true, // include legend
true,
false
);
}
示例8: testNullValueInDataset
import org.jfree.data.general.DefaultPieDataset; //導入依賴的package包/類
/**
* Tests that no exceptions are thrown when there is a <code>null</code> value in the dataset.
*/
public void testNullValueInDataset() {
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("Section 1", 10.0);
dataset.setValue("Section 2", 11.0);
dataset.setValue("Section 3", null);
JFreeChart chart = createPieChart3D(dataset);
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 (Throwable t) {
success = false;
}
assertTrue(success);
}
示例9: startElement
import org.jfree.data.general.DefaultPieDataset; //導入依賴的package包/類
/**
* Starts an element.
*
* @param namespaceURI the namespace.
* @param localName the element name.
* @param qName the element name.
* @param atts the element attributes.
*
* @throws SAXException for errors.
*/
public void startElement(final String namespaceURI,
final String localName,
final String qName,
final Attributes atts) throws SAXException {
final DefaultHandler current = getCurrentHandler();
if (current != this) {
current.startElement(namespaceURI, localName, qName, atts);
}
else if (qName.equals(PIEDATASET_TAG)) {
this.dataset = new DefaultPieDataset();
}
else if (qName.equals(ITEM_TAG)) {
final ItemHandler subhandler = new ItemHandler(this, this);
getSubHandlers().push(subhandler);
subhandler.startElement(namespaceURI, localName, qName, atts);
}
}
示例10: testEquals
import org.jfree.data.general.DefaultPieDataset; //導入依賴的package包/類
/**
* Confirm that the equals method can distinguish all the required fields.
*/
public void testEquals() {
StandardEntityCollection c1 = new StandardEntityCollection();
StandardEntityCollection c2 = new StandardEntityCollection();
assertTrue(c1.equals(c2));
PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0,
2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key",
"ToolTip", "URL");
c1.add(e1);
assertFalse(c1.equals(c2));
PieSectionEntity e2 = new PieSectionEntity(new Rectangle2D.Double(1.0,
2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key",
"ToolTip", "URL");
c2.add(e2);
assertTrue(c1.equals(c2));
}
示例11: createPieChart
import org.jfree.data.general.DefaultPieDataset; //導入依賴的package包/類
/**
* Creates a pie chart.
*
* @return The pie chart.
*/
private static JFreeChart createPieChart() {
// create a dataset...
DefaultPieDataset data = new DefaultPieDataset();
data.setValue("Java", new Double(43.2));
data.setValue("Visual Basic", new Double(0.0));
data.setValue("C/C++", new Double(17.5));
// create the chart...
return ChartFactory.createPieChart("Pie Chart", // chart title
data, // data
true, // include legend
true,
false
);
}
示例12: testNullValueInDataset
import org.jfree.data.general.DefaultPieDataset; //導入依賴的package包/類
/**
* Tests that no exceptions are thrown when there is a <code>null</code>
* value in the dataset.
*/
public void testNullValueInDataset() {
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("Section 1", 10.0);
dataset.setValue("Section 2", 11.0);
dataset.setValue("Section 3", null);
JFreeChart chart = createPieChart3D(dataset);
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 (Throwable t) {
success = false;
}
assertTrue(success);
}
示例13: testGetIndex
import org.jfree.data.general.DefaultPieDataset; //導入依賴的package包/類
/**
* Some checks for the getIndex() method.
*/
public void testGetIndex() {
DefaultPieDataset d = new DefaultPieDataset();
d.setValue("A", 1.0);
d.setValue("B", 2.0);
assertEquals(0, d.getIndex("A"));
assertEquals(1, d.getIndex("B"));
assertEquals(-1, d.getIndex("XX"));
boolean pass = false;
try {
d.getIndex(null);
}
catch (IllegalArgumentException e) {
pass = true;
}
assertTrue(pass);
}
示例14: startElement
import org.jfree.data.general.DefaultPieDataset; //導入依賴的package包/類
/**
* Starts an element.
*
* @param namespaceURI the namespace.
* @param localName the element name.
* @param qName the element name.
* @param atts the element attributes.
*
* @throws SAXException for errors.
*/
public void startElement(String namespaceURI,
String localName,
String qName,
Attributes atts) throws SAXException {
DefaultHandler current = getCurrentHandler();
if (current != this) {
current.startElement(namespaceURI, localName, qName, atts);
}
else if (qName.equals(PIEDATASET_TAG)) {
this.dataset = new DefaultPieDataset();
}
else if (qName.equals(ITEM_TAG)) {
ItemHandler subhandler = new ItemHandler(this, this);
getSubHandlers().push(subhandler);
subhandler.startElement(namespaceURI, localName, qName, atts);
}
}
示例15: testEquals
import org.jfree.data.general.DefaultPieDataset; //導入依賴的package包/類
/**
* Confirm that the equals method can distinguish all the required fields.
*/
@Test
public void testEquals() {
StandardEntityCollection c1 = new StandardEntityCollection();
StandardEntityCollection c2 = new StandardEntityCollection();
assertTrue(c1.equals(c2));
PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0,
2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key",
"ToolTip", "URL");
c1.add(e1);
assertFalse(c1.equals(c2));
PieSectionEntity e2 = new PieSectionEntity(new Rectangle2D.Double(1.0,
2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key",
"ToolTip", "URL");
c2.add(e2);
assertTrue(c1.equals(c2));
}