Example usage for org.jfree.data.general DefaultKeyedValuesDataset setValue

List of usage examples for org.jfree.data.general DefaultKeyedValuesDataset setValue

Introduction

In this page you can find the example usage for org.jfree.data.general DefaultKeyedValuesDataset setValue.

Prototype

public void setValue(Comparable key, Number value) 

Source Link

Document

Sets the data value for a key and sends a DatasetChangeEvent to all registered listeners.

Usage

From source file:org.jfree.data.general.DefaultKeyedValuesDatasetTest.java

/**
 * Serialize an instance, restore it, and check for equality.
 *///  ww  w  .  ja v  a 2s . c o  m
public void testSerialization() {
    DefaultKeyedValuesDataset d1 = new DefaultKeyedValuesDataset();
    d1.setValue("C1", new Double(234.2));
    d1.setValue("C2", null);
    d1.setValue("C3", new Double(345.9));
    d1.setValue("C4", new Double(452.7));

    KeyedValuesDataset d2 = (KeyedValuesDataset) TestUtilities.serialised(d1);
    assertEquals(d1, d2);
}

From source file:org.jfree.data.general.DefaultKeyedValuesDatasetTest.java

/**
 * Confirm that cloning works./* ww w  . j ava2 s  .  c  o  m*/
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    DefaultKeyedValuesDataset d1 = new DefaultKeyedValuesDataset();
    d1.setValue("V1", new Integer(1));
    d1.setValue("V2", null);
    d1.setValue("V3", new Integer(3));
    DefaultKeyedValuesDataset d2 = (DefaultKeyedValuesDataset) d1.clone();
    assertTrue(d1 != d2);
    assertTrue(d1.getClass() == d2.getClass());
    assertTrue(d1.equals(d2));
}

From source file:org.sipfoundry.sipxconfig.site.cdr.CdrReports.java

private Image createCallDirectionCallsPieImage(List<CdrGraphBean> beans) {
    // Create a dataset
    DefaultKeyedValuesDataset data = new DefaultKeyedValuesDataset();

    // Fill dataset with beans data
    for (CdrGraphBean directionCall : beans) {
        data.setValue(directionCall.getKey(), directionCall.getCount());
    }/*from w  w w  .j  a  v  a  2s  .  c o  m*/

    // Create a chart with the dataset
    JFreeChart chart = ChartFactory.createPieChart(EMPTY_TITLE, data, true, true, false);
    chart.setBackgroundPaint(Color.lightGray);
    chart.setTitle("Summary - " + getMessages().getMessage(TITLE_CALLDIRECTION_REPORT_KEY));
    chart.getTitle().setPaint(Color.BLACK);

    PiePlot chartplot = (PiePlot) chart.getPlot();
    chartplot.setCircular(true);
    chartplot.setLabelGenerator(new StandardPieSectionLabelGenerator(PIECHART_SECTIONLABEL_FORMAT));

    // Create and return the image
    return chart.createBufferedImage(500, 220, BufferedImage.TYPE_INT_RGB, null);
}