Example usage for org.jfree.data KeyedObjects2D removeRow

List of usage examples for org.jfree.data KeyedObjects2D removeRow

Introduction

In this page you can find the example usage for org.jfree.data KeyedObjects2D removeRow.

Prototype

public void removeRow(Comparable rowKey) 

Source Link

Document

Removes an entire row from the table.

Usage

From source file:org.jfree.data.KeyedObjects2DTest.java

/**
 * Some checks for the removeRow(int) method.
 *//*from w w  w. j  av a2 s  .  c o  m*/
@Test
public void testRemoveRowByIndex() {
    KeyedObjects2D data = new KeyedObjects2D();
    data.setObject("Obj1", "R1", "C1");
    data.setObject("Obj2", "R2", "C2");
    data.removeRow(0);
    assertEquals(1, data.getRowCount());
    assertEquals("Obj2", data.getObject(0, 1));

    // try negative row index
    boolean pass = false;
    try {
        data.removeRow(-1);
    } catch (IndexOutOfBoundsException e) {
        pass = true;
    }
    assertTrue(pass);

    // try row index too high
    pass = false;
    try {
        data.removeRow(data.getRowCount());
    } catch (IndexOutOfBoundsException e) {
        pass = true;
    }
    assertTrue(pass);
}

From source file:org.jfree.data.KeyedObjects2DTest.java

/**
 * Some checks for the removeRow(Comparable) method.
 *//*from  w  w  w  . j  av  a2  s.com*/
@Test
public void testRemoveRowByKey() {
    KeyedObjects2D data = new KeyedObjects2D();
    data.setObject("Obj1", "R1", "C1");
    data.setObject("Obj2", "R2", "C2");
    data.removeRow("R2");
    assertEquals(1, data.getRowCount());
    assertEquals("Obj1", data.getObject(0, 0));

    // try unknown row key
    boolean pass = false;
    try {
        data.removeRow("XXX");
    } catch (UnknownKeyException e) {
        pass = true;
    }
    assertTrue(pass);

    // try null row key
    pass = false;
    try {
        data.removeRow(null);
    } catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);
}