Example usage for org.jfree.data.general DefaultKeyedValueDataset DefaultKeyedValueDataset

List of usage examples for org.jfree.data.general DefaultKeyedValueDataset DefaultKeyedValueDataset

Introduction

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

Prototype

public DefaultKeyedValueDataset(Comparable key, Number value) 

Source Link

Document

Creates a new dataset with the specified initial value.

Usage

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

/**
 * Confirm that the equals method can distinguish all the required fields.
 *///from w w  w  .j a va  2 s .c om
@Test
public void testEquals() {

    DefaultKeyedValueDataset d1 = new DefaultKeyedValueDataset("Test", new Double(45.5));
    DefaultKeyedValueDataset d2 = new DefaultKeyedValueDataset("Test", new Double(45.5));
    assertTrue(d1.equals(d2));
    assertTrue(d2.equals(d1));

    d1 = new DefaultKeyedValueDataset("Test 1", new Double(45.5));
    d2 = new DefaultKeyedValueDataset("Test 2", new Double(45.5));
    assertFalse(d1.equals(d2));

    d1 = new DefaultKeyedValueDataset("Test", new Double(45.5));
    d2 = new DefaultKeyedValueDataset("Test", new Double(45.6));
    assertFalse(d1.equals(d2));

}

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

/**
 * Confirm that cloning works.//from w  ww.  ja v  a  2s.  com
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    DefaultKeyedValueDataset d1 = new DefaultKeyedValueDataset("Test", new Double(45.5));
    DefaultKeyedValueDataset d2 = (DefaultKeyedValueDataset) d1.clone();
    assertTrue(d1 != d2);
    assertTrue(d1.getClass() == d2.getClass());
    assertTrue(d1.equals(d2));
}

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

/**
 * Confirm that the clone is independent of the original.
 *//*  w ww  .java2 s . c o m*/
@Test
public void testCloneIndependence() throws CloneNotSupportedException {
    DefaultKeyedValueDataset d1 = new DefaultKeyedValueDataset("Key", new Double(10.0));
    DefaultKeyedValueDataset d2 = (DefaultKeyedValueDataset) d1.clone();
    assertTrue(d1.equals(d2));
    d2.updateValue(new Double(99.9));
    assertFalse(d1.equals(d2));
    d2.updateValue(new Double(10.0));
    assertTrue(d1.equals(d2));
}

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

/**
 * Serialize an instance, restore it, and check for equality.
 *//*ww w.j  a  v  a  2  s  . c o m*/
@Test
public void testSerialization() {
    DefaultKeyedValueDataset d1 = new DefaultKeyedValueDataset("Test", new Double(25.3));
    DefaultKeyedValueDataset d2 = (DefaultKeyedValueDataset) TestUtilities.serialised(d1);
    assertEquals(d1, d2);
}