Example usage for org.jfree.chart.util TableOrder BY_COLUMN

List of usage examples for org.jfree.chart.util TableOrder BY_COLUMN

Introduction

In this page you can find the example usage for org.jfree.chart.util TableOrder BY_COLUMN.

Prototype

TableOrder BY_COLUMN

To view the source code for org.jfree.chart.util TableOrder BY_COLUMN.

Click Source Link

Document

By column.

Usage

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

/**
 * Some tests for the constructor./*from   w w  w .  j  a  va2  s  .  c  om*/
 */
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 checks for the getValue() method.
 *///from w  w w .j  a  va2 s .  com
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 getKey(int) method.
 *///ww w .jav  a  2s . co m
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

/**
 * For datasets, the equals() method just checks keys and values.
 *///www .jav a2s.c om
public void testEquals() {
    DefaultCategoryDataset underlying = new DefaultCategoryDataset();
    underlying.addValue(1.1, "R1", "C1");
    underlying.addValue(2.2, "R1", "C2");
    CategoryToPieDataset d1 = new CategoryToPieDataset(underlying, TableOrder.BY_COLUMN, 1);
    DefaultPieDataset d2 = new DefaultPieDataset();
    d2.setValue("R1", 2.2);
    assertTrue(d1.equals(d2));
}

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

/**
 * Serialize an instance, restore it, and check for equality.
 *//* w w w  .j  av a  2 s .c o  m*/
public void testSerialization() {
    DefaultCategoryDataset underlying = new DefaultCategoryDataset();
    underlying.addValue(1.1, "R1", "C1");
    underlying.addValue(2.2, "R1", "C2");
    CategoryToPieDataset d1 = new CategoryToPieDataset(underlying, TableOrder.BY_COLUMN, 1);
    CategoryToPieDataset d2 = null;

    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(d1);
        out.close();

        ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
        d2 = (CategoryToPieDataset) in.readObject();
        in.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(d1, d2);

    // regular equality for the datasets doesn't check the fields, just
    // the data values...so let's check some more things...
    assertEquals(d1.getUnderlyingDataset(), d2.getUnderlyingDataset());
    assertEquals(d1.getExtractType(), d2.getExtractType());
    assertEquals(d1.getExtractIndex(), d2.getExtractIndex());
}