Search in sources :

Example 11 with BoxAndWhiskerItem

use of org.jfree.data.statistics.BoxAndWhiskerItem in project SIMVA-SoS by SESoS.

the class BoxAndWhiskerRendererTest method testDrawWithNullMean.

/**
 * Draws a chart where the dataset contains a null mean value.
 */
@Test
public void testDrawWithNullMean() {
    boolean success;
    try {
        DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
        dataset.add(new BoxAndWhiskerItem(null, new Double(2.0), new Double(0.0), new Double(4.0), new Double(0.5), new Double(4.5), new Double(-0.5), new Double(5.5), null), "S1", "C1");
        CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new BoxAndWhiskerRenderer());
        ChartRenderingInfo info = new ChartRenderingInfo();
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */
        chart.createBufferedImage(300, 200, info);
        success = true;
    } catch (Exception e) {
        success = false;
    }
    assertTrue(success);
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) CategoryAxis(org.jfree.chart.axis.CategoryAxis) ChartRenderingInfo(org.jfree.chart.ChartRenderingInfo) DefaultBoxAndWhiskerCategoryDataset(org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset) BoxAndWhiskerItem(org.jfree.data.statistics.BoxAndWhiskerItem) CategoryPlot(org.jfree.chart.plot.CategoryPlot) JFreeChart(org.jfree.chart.JFreeChart) Test(org.junit.Test)

Example 12 with BoxAndWhiskerItem

use of org.jfree.data.statistics.BoxAndWhiskerItem in project SIMVA-SoS by SESoS.

the class XYBoxAndWhiskerRendererTest method test2909215.

/**
 * A test for bug report 2909215.
 */
@Test
public void test2909215() {
    DefaultBoxAndWhiskerXYDataset d1 = new DefaultBoxAndWhiskerXYDataset("Series");
    d1.add(new Date(1L), 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), null, null, null));
    JFreeChart chart = ChartFactory.createBoxAndWhiskerChart("Title", "X", "Y", d1, true);
    try {
        BufferedImage image = new BufferedImage(400, 200, BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = image.createGraphics();
        chart.draw(g2, new Rectangle2D.Double(0, 0, 400, 200), null, null);
        g2.dispose();
    } catch (Exception e) {
        fail("No exception should be thrown.");
    }
}
Also used : DefaultBoxAndWhiskerXYDataset(org.jfree.data.statistics.DefaultBoxAndWhiskerXYDataset) Rectangle2D(java.awt.geom.Rectangle2D) Date(java.util.Date) BoxAndWhiskerItem(org.jfree.data.statistics.BoxAndWhiskerItem) JFreeChart(org.jfree.chart.JFreeChart) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D) Test(org.junit.Test)

Example 13 with BoxAndWhiskerItem

use of org.jfree.data.statistics.BoxAndWhiskerItem in project SIMVA-SoS by SESoS.

the class DatasetUtilitiesTest method testIterateToFindRangeBounds_BoxAndWhiskerXYDataset.

/**
 * Some checks for the iterateToFindRangeBounds() method when applied to
 * a BoxAndWhiskerXYDataset.
 */
@Test
public void testIterateToFindRangeBounds_BoxAndWhiskerXYDataset() {
    DefaultBoxAndWhiskerXYDataset dataset = new DefaultBoxAndWhiskerXYDataset("Series 1");
    List visibleSeriesKeys = new ArrayList();
    visibleSeriesKeys.add("Series 1");
    Range xRange = new Range(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
    assertNull(DatasetUtilities.iterateToFindRangeBounds(dataset, visibleSeriesKeys, xRange, false));
    dataset.add(new Date(50L), new BoxAndWhiskerItem(5.0, 4.9, 2.0, 8.0, 1.0, 9.0, 0.0, 10.0, new ArrayList()));
    assertEquals(new Range(5.0, 5.0), DatasetUtilities.iterateToFindRangeBounds(dataset, visibleSeriesKeys, xRange, false));
    assertEquals(new Range(1.0, 9.0), DatasetUtilities.iterateToFindRangeBounds(dataset, visibleSeriesKeys, xRange, true));
}
Also used : DefaultBoxAndWhiskerXYDataset(org.jfree.data.statistics.DefaultBoxAndWhiskerXYDataset) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Range(org.jfree.data.Range) Date(java.util.Date) BoxAndWhiskerItem(org.jfree.data.statistics.BoxAndWhiskerItem) Test(org.junit.Test)

Aggregations

BoxAndWhiskerItem (org.jfree.data.statistics.BoxAndWhiskerItem)13 Test (org.junit.Test)11 JFreeChart (org.jfree.chart.JFreeChart)10 DefaultBoxAndWhiskerCategoryDataset (org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset)10 CategoryAxis (org.jfree.chart.axis.CategoryAxis)9 NumberAxis (org.jfree.chart.axis.NumberAxis)9 CategoryPlot (org.jfree.chart.plot.CategoryPlot)9 ChartRenderingInfo (org.jfree.chart.ChartRenderingInfo)8 ArrayList (java.util.ArrayList)3 Date (java.util.Date)2 List (java.util.List)2 DefaultBoxAndWhiskerXYDataset (org.jfree.data.statistics.DefaultBoxAndWhiskerXYDataset)2 Graphics2D (java.awt.Graphics2D)1 Rectangle2D (java.awt.geom.Rectangle2D)1 BufferedImage (java.awt.image.BufferedImage)1 Range (org.jfree.data.Range)1