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


Java DefaultPieDataset类代码示例

本文整理汇总了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
    );

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:22,代码来源:JFreeChartTests.java

示例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?
                    );
      
}
 
开发者ID:mathhobbit,项目名称:EditCalculateAndChart,代码行数:26,代码来源:piePlt.java

示例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));
}
 
开发者ID:leon66666,项目名称:financehelper,代码行数:24,代码来源:PieChart.java

示例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);
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:17,代码来源:PieChartDataPlugin.java

示例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;
}
 
开发者ID:fgulan,项目名称:java-course,代码行数:21,代码来源:ReportImageServlet.java

示例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));        
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:20,代码来源:StandardEntityCollectionTests.java

示例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
                                       );
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:21,代码来源:PieChartTests.java

示例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);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:23,代码来源:PieChart3DTests.java

示例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);
    }

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:30,代码来源:PieDatasetHandler.java

示例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));        
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:20,代码来源:StandardEntityCollectionTests.java

示例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
                                       );
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:21,代码来源:PieChartTests.java

示例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);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:25,代码来源:PieChart3DTests.java

示例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);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:21,代码来源:DefaultPieDatasetTests.java

示例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);
    }

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:30,代码来源:PieDatasetHandler.java

示例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));
}
 
开发者ID:mdzio,项目名称:ccu-historian,代码行数:21,代码来源:StandardEntityCollectionTest.java


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