Example usage for org.jfree.data.category DefaultCategoryDataset removeValue

List of usage examples for org.jfree.data.category DefaultCategoryDataset removeValue

Introduction

In this page you can find the example usage for org.jfree.data.category DefaultCategoryDataset removeValue.

Prototype

public void removeValue(Comparable rowKey, Comparable columnKey) 

Source Link

Document

Removes a value from the dataset and sends a DatasetChangeEvent to all registered listeners.

Usage

From source file:org.jfree.data.category.DefaultCategoryDatasetTest.java

/**
 * Some basic checks for the removeValue() method.
 *//* w  w  w.jav  a 2 s .c  om*/
public void testRemoveValue() {
    DefaultCategoryDataset d = new DefaultCategoryDataset();
    d.removeValue("R1", "C1");
    d.addValue(new Double(1.0), "R1", "C1");
    d.removeValue("R1", "C1");
    assertEquals(0, d.getRowCount());
    assertEquals(0, d.getColumnCount());

    d.addValue(new Double(1.0), "R1", "C1");
    d.addValue(new Double(2.0), "R2", "C1");
    d.removeValue("R1", "C1");
    assertEquals(new Double(2.0), d.getValue(0, 0));

    boolean pass = false;
    try {
        d.removeValue(null, "C1");
    } catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);

    pass = false;
    try {
        d.removeValue("R1", null);
    } catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);
}

From source file:org.jfree.data.category.junit.DefaultCategoryDatasetTests.java

/**
 * Some basic checks for the removeValue() method.
 *///from w  w  w. ja  v a2 s.  c  o m
public void testRemoveValue() {
    DefaultCategoryDataset d = new DefaultCategoryDataset();

    // if we try removing with unknown keys, we expect an exception
    boolean pass = false;
    try {
        d.removeValue("R1", "C1");
    } catch (UnknownKeyException e) {
        pass = true;
    }
    assertTrue(pass);

    d.addValue(new Double(1.0), "R1", "C1");
    d.removeValue("R1", "C1");
    assertEquals(0, d.getRowCount());
    assertEquals(0, d.getColumnCount());

    d.addValue(new Double(1.0), "R1", "C1");
    d.addValue(new Double(2.0), "R2", "C1");
    d.removeValue("R1", "C1");
    assertEquals(new Double(2.0), d.getValue(0, 0));

    pass = false;
    try {
        d.removeValue(null, "C1");
    } catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);

    pass = false;
    try {
        d.removeValue("R1", null);
    } catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);
}