Example usage for org.jfree.data.category CategoryToPieDataset getItemCount

List of usage examples for org.jfree.data.category CategoryToPieDataset getItemCount

Introduction

In this page you can find the example usage for org.jfree.data.category CategoryToPieDataset getItemCount.

Prototype

@Override
public int getItemCount() 

Source Link

Document

Returns the number of items (values) in the collection.

Usage

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

/**
 * Some tests for the constructor./*from  w ww.j  a v a 2s .c  om*/
 */
@Test
public void testConstructor() {
    // try a null source
    CategoryToPieDataset p1 = new CategoryToPieDataset(null, TableOrder.BY_COLUMN, 0);
    assertNull(p1.getUnderlyingDataset());
    assertEquals(p1.getItemCount(), 0);
    assertTrue(p1.getKeys().isEmpty());
    assertNull(p1.getValue("R1"));
}

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

/**
 * Some tests for the constructor.// w  w w . ja va  2 s  .c  o  m
 */
public void testConstructor() {
    // try a null source
    CategoryToPieDataset p1 = new CategoryToPieDataset(null, TableOrder.BY_COLUMN, 0);
    assertNull(p1.getUnderlyingDataset());
    assertEquals(p1.getItemCount(), 0);
    assertTrue(p1.getKeys().isEmpty());
    assertNull(p1.getValue("R1"));
}

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

/**
 * Some checks for the getKey(int) method.
 *//*www . ja  va 2  s .co m*/
@Test
public void testGetKey() {
    DefaultCategoryDataset underlying = new DefaultCategoryDataset();
    underlying.addValue(1.1, "R1", "C1");
    underlying.addValue(2.2, "R1", "C2");
    CategoryToPieDataset d1 = new CategoryToPieDataset(underlying, TableOrder.BY_ROW, 0);
    assertEquals(d1.getKey(0), "C1");
    assertEquals(d1.getKey(1), "C2");

    // check negative index throws exception
    try {
        /* Number n = */ d1.getKey(-1);
        fail("Expected IndexOutOfBoundsException.");
    } catch (IndexOutOfBoundsException e) {
        // this is expected
    }

    // check index == getItemCount() throws exception
    try {
        /* Number n = */ d1.getKey(d1.getItemCount());
        fail("Expected IndexOutOfBoundsException.");
    } catch (IndexOutOfBoundsException e) {
        // this is expected
    }

    // test null source
    CategoryToPieDataset p1 = new CategoryToPieDataset(null, TableOrder.BY_COLUMN, 0);
    try {
        /* Number n = */ p1.getKey(0);
        fail("Expected IndexOutOfBoundsException.");
    } catch (IndexOutOfBoundsException e) {
        // this is expected
    }
}

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

/**
 * Some checks for the getKey(int) method.
 *///w  w  w.  j  av  a2  s.com
public void testGetKey() {
    DefaultCategoryDataset underlying = new DefaultCategoryDataset();
    underlying.addValue(1.1, "R1", "C1");
    underlying.addValue(2.2, "R1", "C2");
    CategoryToPieDataset d1 = new CategoryToPieDataset(underlying, TableOrder.BY_ROW, 0);
    assertEquals(d1.getKey(0), "C1");
    assertEquals(d1.getKey(1), "C2");

    // check negative index throws exception
    try {
        /* Number n = */ d1.getKey(-1);
        fail("Expected IndexOutOfBoundsException.");
    } catch (IndexOutOfBoundsException e) {
        // this is expected
    }

    // check index == getItemCount() throws exception
    try {
        /* Number n = */ d1.getKey(d1.getItemCount());
        fail("Expected IndexOutOfBoundsException.");
    } catch (IndexOutOfBoundsException e) {
        // this is expected
    }

    // test null source
    CategoryToPieDataset p1 = new CategoryToPieDataset(null, TableOrder.BY_COLUMN, 0);
    try {
        /* Number n = */ p1.getKey(0);
        fail("Expected IndexOutOfBoundsException.");
    } catch (IndexOutOfBoundsException e) {
        // this is expected
    }
}

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

/**
 * Some checks for the getValue() method.
 *///from w  ww.  j a va  2  s.c o m
@Test
public void testGetValue() {
    DefaultCategoryDataset underlying = new DefaultCategoryDataset();
    underlying.addValue(1.1, "R1", "C1");
    underlying.addValue(2.2, "R1", "C2");
    CategoryToPieDataset d1 = new CategoryToPieDataset(underlying, TableOrder.BY_ROW, 0);
    assertEquals(d1.getValue("C1"), new Double(1.1));
    assertEquals(d1.getValue("C2"), new Double(2.2));

    // check negative index throws exception
    try {
        /* Number n = */ d1.getValue(-1);
        fail("Expected IndexOutOfBoundsException.");
    } catch (IndexOutOfBoundsException e) {
        // this is expected
    }

    // check index == getItemCount() throws exception
    try {
        /* Number n = */ d1.getValue(d1.getItemCount());
        fail("Expected IndexOutOfBoundsException.");
    } catch (IndexOutOfBoundsException e) {
        // this is expected
    }

    // test null source
    CategoryToPieDataset p1 = new CategoryToPieDataset(null, TableOrder.BY_COLUMN, 0);
    try {
        /* Number n = */ p1.getValue(0);
        fail("Expected IndexOutOfBoundsException.");
    } catch (IndexOutOfBoundsException e) {
        // this is expected
    }
}

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

/**
 * Some checks for the getValue() method.
 *///from   ww w  .  j a v  a 2 s  .  co  m
public void testGetValue() {
    DefaultCategoryDataset underlying = new DefaultCategoryDataset();
    underlying.addValue(1.1, "R1", "C1");
    underlying.addValue(2.2, "R1", "C2");
    CategoryToPieDataset d1 = new CategoryToPieDataset(underlying, TableOrder.BY_ROW, 0);
    assertEquals(d1.getValue("C1"), new Double(1.1));
    assertEquals(d1.getValue("C2"), new Double(2.2));

    // check negative index throws exception
    try {
        /* Number n = */ d1.getValue(-1);
        fail("Expected IndexOutOfBoundsException.");
    } catch (IndexOutOfBoundsException e) {
        // this is expected
    }

    // check index == getItemCount() throws exception
    try {
        /* Number n = */ d1.getValue(d1.getItemCount());
        fail("Expected IndexOutOfBoundsException.");
    } catch (IndexOutOfBoundsException e) {
        // this is expected
    }

    // test null source
    CategoryToPieDataset p1 = new CategoryToPieDataset(null, TableOrder.BY_COLUMN, 0);
    try {
        /* Number n = */ p1.getValue(0);
        fail("Expected IndexOutOfBoundsException.");
    } catch (IndexOutOfBoundsException e) {
        // this is expected
    }
}