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

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

Introduction

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

Prototype

public BoxAndWhiskerItem(double mean, double median, double q1, double q3, double minRegularValue,
        double maxRegularValue, double minOutlier, double maxOutlier, List outliers) 

Source Link

Document

Creates a new box-and-whisker item.

Usage

From source file:edu.msu.cme.rdp.classifier.train.validation.distance.BoxPlotUtils.java

public static void readData(String inFile, File outdir, String xAxisLabel, String yAxisLabel)
        throws IOException {
    XYSeriesCollection dataset = new XYSeriesCollection();
    DefaultBoxAndWhiskerCategoryDataset scatterDataset = new DefaultBoxAndWhiskerCategoryDataset();

    BufferedReader reader = new BufferedReader(new FileReader(inFile));
    String line = reader.readLine();

    while ((line = reader.readLine()) != null) {
        String[] values = line.split("\\t");
        XYSeries series = new XYSeries(values[2]);
        dataset.addSeries(series);/* w  w w .  java2s .  c  o m*/

        double average = Double.parseDouble(values[4]);
        int Q1 = Integer.parseInt(values[6]);
        ;
        int median = Integer.parseInt(values[7]);
        int Q3 = Integer.parseInt(values[8]);
        int pct_98 = Integer.parseInt(values[9]);
        int pct_2 = Integer.parseInt(values[10]);
        int minOutlier = 0; // we don't care about the outliers
        int maxOutlier = 0; //

        BoxAndWhiskerItem item = new BoxAndWhiskerItem(average, median, Q1, Q3, pct_2, pct_98, minOutlier,
                maxOutlier, new ArrayList());
        scatterDataset.add(item, values[2], "");
    }

    String title = new File(inFile).getName();
    int index = title.indexOf(".");
    if (index != -1) {
        title = title.substring(0, index);
    }

    Font lableFont = new Font("Helvetica", Font.BOLD, 28);
    createBoxplot(scatterDataset, new PrintStream(new File(outdir, title + ".boxchart.png")), title, xAxisLabel,
            yAxisLabel, lableFont);

}

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

/**
 * Confirm that the equals method can distinguish all the required fields.
 *//*from w  ww. j av  a  2  s  .  c  o  m*/
@Test
public void testEquals() {

    BoxAndWhiskerItem i1 = new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0),
            new Double(4.0), new Double(5.0), new Double(6.0), new Double(7.0), new Double(8.0),
            new ArrayList());
    BoxAndWhiskerItem i2 = new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0),
            new Double(4.0), new Double(5.0), new Double(6.0), new Double(7.0), new Double(8.0),
            new ArrayList());
    assertTrue(i1.equals(i2));
    assertTrue(i2.equals(i1));
}

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

/**
 * Confirm that the equals method can distinguish all the required fields.
 *//*ww  w .ja  va2  s  .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.DefaultBoxAndWhiskerCategoryDatasetTest.java

/**
 * Confirm that the equals method can distinguish all the required fields.
 *///  ww w. jav  a 2  s.com
@Test
public void testEquals() {
    DefaultBoxAndWhiskerCategoryDataset d1 = new DefaultBoxAndWhiskerCategoryDataset();
    d1.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0),
            new Double(5.0), new Double(6.0), new Double(7.0), new Double(8.0), new ArrayList()), "ROW1",
            "COLUMN1");
    DefaultBoxAndWhiskerCategoryDataset d2 = new DefaultBoxAndWhiskerCategoryDataset();
    d2.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0),
            new Double(5.0), new Double(6.0), new Double(7.0), new Double(8.0), new ArrayList()), "ROW1",
            "COLUMN1");
    assertTrue(d1.equals(d2));
    assertTrue(d2.equals(d1));
}

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

/**
 * Serialize an instance, restore it, and check for equality.
 *//*from w  w  w  . j  a  va  2  s.  c om*/
@Test
public void testSerialization() {
    BoxAndWhiskerItem i1 = new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0),
            new Double(4.0), new Double(5.0), new Double(6.0), new Double(7.0), new Double(8.0),
            new ArrayList());
    BoxAndWhiskerItem i2 = (BoxAndWhiskerItem) TestUtilities.serialised(i1);
    assertEquals(i1, i2);
}

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

/**
 * Serialize an instance, restore it, and check for equality.
 *///  w ww.  j  a v a 2  s .  c o 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.DefaultBoxAndWhiskerCategoryDatasetTest.java

/**
 * Serialize an instance, restore it, and check for equality.
 *//* w w  w .ja v a2 s . c o  m*/
@Test
public void testSerialization() {
    DefaultBoxAndWhiskerCategoryDataset d1 = new DefaultBoxAndWhiskerCategoryDataset();
    d1.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0),
            new Double(5.0), new Double(6.0), new Double(7.0), new Double(8.0), new ArrayList()), "ROW1",
            "COLUMN1");
    DefaultBoxAndWhiskerCategoryDataset d2 = (DefaultBoxAndWhiskerCategoryDataset) TestUtilities.serialised(d1);
    assertEquals(d1, d2);
}

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

/**
 * Confirm that cloning works./*from  w ww.ja v  a  2s. c o  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:de.hs.mannheim.modUro.controller.diagram.BoxAndWhiskerPlotController.java

/**
 * Creates dataset for BoxWhiskerPlot./*from  w  w  w . j  ava2  s  .c  o m*/
 *
 * @return
 */
private BoxAndWhiskerCategoryDataset createDataset() {

    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();

    List<String> sortedModels = new ArrayList<>(models);
    sortedModels.sort(String::compareTo);
    for (String model : sortedModels) {
        StatisticValues stat = stats.get(model);
        BoxAndWhiskerItem item = new BoxAndWhiskerItem(stat.getMean(), stat.getSecondPercentile(),
                stat.getFirstPercentile(), stat.getLastPercentile(), stat.getMin(), stat.getMax(),
                stat.getMin(), stat.getMax(), new ArrayList<>());
        // Second parameter is the row key (?), using always the same works:
        dataset.add(item, "", model);
    }
    return dataset;
}

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

/**
 * Confirm that cloning works.//from   w w  w  .ja  v  a 2s .co  m
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    DefaultBoxAndWhiskerCategoryDataset d1 = new DefaultBoxAndWhiskerCategoryDataset();
    d1.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0),
            new Double(5.0), new Double(6.0), new Double(7.0), new Double(8.0), new ArrayList()), "ROW1",
            "COLUMN1");
    DefaultBoxAndWhiskerCategoryDataset d2 = (DefaultBoxAndWhiskerCategoryDataset) d1.clone();
    assertTrue(d1 != d2);
    assertTrue(d1.getClass() == d2.getClass());
    assertTrue(d1.equals(d2));

    // test independence
    d1.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0),
            new Double(5.0), new Double(6.0), new Double(7.0), new Double(8.0), new ArrayList()), "ROW2",
            "COLUMN1");
    assertFalse(d1.equals(d2));
}