Example usage for org.jfree.data.statistics DefaultBoxAndWhiskerXYDataset DefaultBoxAndWhiskerXYDataset

List of usage examples for org.jfree.data.statistics DefaultBoxAndWhiskerXYDataset DefaultBoxAndWhiskerXYDataset

Introduction

In this page you can find the example usage for org.jfree.data.statistics DefaultBoxAndWhiskerXYDataset DefaultBoxAndWhiskerXYDataset.

Prototype

public DefaultBoxAndWhiskerXYDataset(Comparable seriesKey) 

Source Link

Document

Constructs a new box and whisker dataset.

Usage

From source file:org.jfree.chart.demo.BoxAndWhiskerChartDemo2.java

private static BoxAndWhiskerXYDataset createDataset() {
    DefaultBoxAndWhiskerXYDataset defaultboxandwhiskerxydataset = new DefaultBoxAndWhiskerXYDataset(
            "Series Name");
    Object obj = new Day();
    for (int i = 0; i < 10; i++) {
        @SuppressWarnings("rawtypes")
        List list = createValueList(0.0D, 20D, 20);
        defaultboxandwhiskerxydataset.add(((RegularTimePeriod) (obj)).getStart(),
                BoxAndWhiskerCalculator.calculateBoxAndWhiskerStatistics(list));
        obj = ((RegularTimePeriod) (obj)).next();
    }/*w  w w  .  j a v a2 s  . c  o  m*/

    return defaultboxandwhiskerxydataset;
}

From source file:org.jfree.data.statistics.DefaultBoxAndWhiskerXYDatasetTest.java

/**
 * Confirm that the equals method can distinguish all the required fields.
 *//*from w ww  . j  a  v  a  2s .co  m*/
@Test
public void testEquals() {
    DefaultBoxAndWhiskerXYDataset d1 = new DefaultBoxAndWhiskerXYDataset("Series");
    DefaultBoxAndWhiskerXYDataset d2 = new DefaultBoxAndWhiskerXYDataset("Series");
    assertTrue(d1.equals(d2));

    d1.add(new Date(1L), new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, new ArrayList()));
    assertFalse(d1.equals(d2));
    d2.add(new Date(1L), new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, new ArrayList()));
    assertTrue(d1.equals(d2));
}

From source file:org.jfree.data.statistics.DefaultBoxAndWhiskerXYDatasetTest.java

/**
 * Serialize an instance, restore it, and check for equality.
 *///from w ww. java2s .  co  m
@Test
public void testSerialization() {
    DefaultBoxAndWhiskerXYDataset d1 = new DefaultBoxAndWhiskerXYDataset("Series");
    d1.add(new Date(1L), new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, new ArrayList()));
    DefaultBoxAndWhiskerXYDataset d2 = (DefaultBoxAndWhiskerXYDataset) TestUtilities.serialised(d1);
    assertEquals(d1, d2);

    // test independence
    d1.add(new Date(2L), new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, new ArrayList()));
    assertFalse(d1.equals(d2));
}

From source file:org.jfree.data.statistics.DefaultBoxAndWhiskerXYDatasetTest.java

/**
 * Confirm that cloning works./*from  w  w  w.j a  va  2  s .co  m*/
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    DefaultBoxAndWhiskerXYDataset d1 = new DefaultBoxAndWhiskerXYDataset("Series");
    d1.add(new Date(1L), new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, new ArrayList()));
    DefaultBoxAndWhiskerXYDataset d2 = (DefaultBoxAndWhiskerXYDataset) d1.clone();
    assertTrue(d1 != d2);
    assertTrue(d1.getClass() == d2.getClass());
    assertTrue(d1.equals(d2));

    // test independence
    d1.add(new Date(2L), new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, new ArrayList()));
    assertFalse(d1.equals(d2));
}

From source file:org.jfree.chart.demo.XYBoxAndWhiskerDemo.java

/**
 * Creates a sample {@link BoxAndWhiskerXYDataset}.
 *
 * @return A sample dataset.// w w w .  j ava2 s. com
 */
public static BoxAndWhiskerXYDataset createSampleDataset() {

    final int entityCount = 14;

    final DefaultBoxAndWhiskerXYDataset dataset = new DefaultBoxAndWhiskerXYDataset("Test");
    for (int i = 0; i < entityCount; i++) {
        final Date date = DateUtilities.createDate(2003, 7, i + 1, 12, 0);
        final List values = new ArrayList();
        for (int j = 0; j < 10; j++) {
            values.add(new Double(10.0 + Math.random() * 10.0));
            values.add(new Double(13.0 + Math.random() * 4.0));
        }
        dataset.add(date, BoxAndWhiskerCalculator.calculateBoxAndWhiskerStatistics(values));

    }

    return dataset;
}

From source file:org.webcat.grader.graphs.BoxAndWhiskerChart.java

@Override
public XYDataset dataset() {
    BoxAndWhiskerXYDataset dataset = (BoxAndWhiskerXYDataset) super.dataset();

    if (dataset == null) {
        DefaultBoxAndWhiskerXYDataset newDataset = new DefaultBoxAndWhiskerXYDataset("Submissions");

        if (submissionStats.allScores().size() > 0) {
            newDataset.add(new Date(),
                    BoxAndWhiskerCalculator.calculateBoxAndWhiskerStatistics(submissionStats.allScores()));
        }/*from  www  . j av  a  2  s.c o  m*/

        dataset = newDataset;
        super.setDataset(dataset);
    }

    return dataset;
}

From source file:org.jfree.data.statistics.DefaultBoxAndWhiskerXYDatasetTest.java

/**
 * Some checks for the add() method./*from w  ww .j a  v a 2s  .com*/
 */
@Test
public void testAdd() {
    DefaultBoxAndWhiskerXYDataset dataset = new DefaultBoxAndWhiskerXYDataset("S1");
    BoxAndWhiskerItem item1 = new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, new ArrayList());
    dataset.add(new Date(33L), item1);

    assertEquals(1.0, dataset.getY(0, 0).doubleValue(), EPSILON);
    assertEquals(1.0, dataset.getMeanValue(0, 0).doubleValue(), EPSILON);
    assertEquals(2.0, dataset.getMedianValue(0, 0).doubleValue(), EPSILON);
    assertEquals(3.0, dataset.getQ1Value(0, 0).doubleValue(), EPSILON);
    assertEquals(4.0, dataset.getQ3Value(0, 0).doubleValue(), EPSILON);
    assertEquals(5.0, dataset.getMinRegularValue(0, 0).doubleValue(), EPSILON);
    assertEquals(6.0, dataset.getMaxRegularValue(0, 0).doubleValue(), EPSILON);
    assertEquals(7.0, dataset.getMinOutlier(0, 0).doubleValue(), EPSILON);
    assertEquals(8.0, dataset.getMaxOutlier(0, 0).doubleValue(), EPSILON);
    assertEquals(new Range(5.0, 6.0), dataset.getRangeBounds(false));
}

From source file:org.jfree.data.statistics.DefaultBoxAndWhiskerXYDatasetTest.java

/**
 * Some basic checks for the constructor.
 *//*from w w  w .  ja v  a  2  s .c  o m*/
@Test
public void testConstructor() {
    DefaultBoxAndWhiskerXYDataset dataset = new DefaultBoxAndWhiskerXYDataset("S1");
    assertEquals(1, dataset.getSeriesCount());
    assertEquals(0, dataset.getItemCount(0));
    assertTrue(Double.isNaN(dataset.getRangeLowerBound(false)));
    assertTrue(Double.isNaN(dataset.getRangeUpperBound(false)));
}

From source file:org.jfree.data.statistics.DefaultBoxAndWhiskerXYDatasetTest.java

/**
 * Some checks for the getRangeBounds() method.
 *//* w  ww . j  a  v a 2 s .c  o m*/
@Test
public void testGetRangeBounds() {
    DefaultBoxAndWhiskerXYDataset d1 = new DefaultBoxAndWhiskerXYDataset("S");
    d1.add(new Date(1L), new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, new ArrayList()));
    assertEquals(new Range(5.0, 6.0), d1.getRangeBounds(false));
    assertEquals(new Range(5.0, 6.0), d1.getRangeBounds(true));

    d1.add(new Date(1L), new BoxAndWhiskerItem(1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, new ArrayList()));
    assertEquals(new Range(5.0, 6.5), d1.getRangeBounds(false));
    assertEquals(new Range(5.0, 6.5), d1.getRangeBounds(true));

    d1.add(new Date(2L), new BoxAndWhiskerItem(2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, new ArrayList()));
    assertEquals(new Range(5.0, 7.5), d1.getRangeBounds(false));
    assertEquals(new Range(5.0, 7.5), d1.getRangeBounds(true));
}

From source file:org.hxzon.demo.jfreechart.OtherDatasetDemo.java

private static BoxAndWhiskerXYDataset createBoxAndWhiskerXYDataset() {
    int VALUE_COUNT = 10;
    DefaultBoxAndWhiskerXYDataset dataset = new DefaultBoxAndWhiskerXYDataset("series 1");
    long time = new Date().getTime();
    List<Double> values = createValueList(0, 20.0, VALUE_COUNT);
    BoxAndWhiskerItem item = BoxAndWhiskerCalculator.calculateBoxAndWhiskerStatistics(values);
    dataset.add(new Date(time + 10000), item);
    values = createValueList(0, 20.0, VALUE_COUNT);
    item = BoxAndWhiskerCalculator.calculateBoxAndWhiskerStatistics(values);
    dataset.add(new Date(time + 30000), item);
    values = createValueList(0, 20.0, VALUE_COUNT);
    item = BoxAndWhiskerCalculator.calculateBoxAndWhiskerStatistics(values);
    dataset.add(new Date(time + 60000), item);
    return dataset;
}