Search in sources :

Example 1 with DefaultBoxAndWhiskerXYDataset

use of org.jfree.data.statistics.DefaultBoxAndWhiskerXYDataset in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.

the class XYBoxAndWhiskerRendererTest method test2909215.

/**
 * A test for bug report 2909215.
 */
@Test
public void test2909215() {
    DefaultBoxAndWhiskerXYDataset<String> d1 = new DefaultBoxAndWhiskerXYDataset<>("Series");
    d1.add(new Date(1L), new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 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.jupiter.api.Test)

Example 2 with DefaultBoxAndWhiskerXYDataset

use of org.jfree.data.statistics.DefaultBoxAndWhiskerXYDataset in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.

the class DatasetUtilsTest method testIterateToFindRangeBounds_BoxAndWhiskerXYDataset.

/**
 * Some checks for the iterateToFindRangeBounds() method when applied to
 * a BoxAndWhiskerXYDataset.
 */
@Test
public void testIterateToFindRangeBounds_BoxAndWhiskerXYDataset() {
    DefaultBoxAndWhiskerXYDataset<String> dataset = new DefaultBoxAndWhiskerXYDataset<>("Series 1");
    List<String> visibleSeriesKeys = new ArrayList<>();
    visibleSeriesKeys.add("Series 1");
    Range xRange = new Range(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
    assertNull(DatasetUtils.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), DatasetUtils.iterateToFindRangeBounds(dataset, visibleSeriesKeys, xRange, false));
    assertEquals(new Range(1.0, 9.0), DatasetUtils.iterateToFindRangeBounds(dataset, visibleSeriesKeys, xRange, true));
}
Also used : DefaultBoxAndWhiskerXYDataset(org.jfree.data.statistics.DefaultBoxAndWhiskerXYDataset) ArrayList(java.util.ArrayList) Range(org.jfree.data.Range) Date(java.util.Date) BoxAndWhiskerItem(org.jfree.data.statistics.BoxAndWhiskerItem) Test(org.junit.jupiter.api.Test)

Example 3 with DefaultBoxAndWhiskerXYDataset

use of org.jfree.data.statistics.DefaultBoxAndWhiskerXYDataset 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)

Example 4 with DefaultBoxAndWhiskerXYDataset

use of org.jfree.data.statistics.DefaultBoxAndWhiskerXYDataset 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)

Aggregations

Date (java.util.Date)4 BoxAndWhiskerItem (org.jfree.data.statistics.BoxAndWhiskerItem)4 DefaultBoxAndWhiskerXYDataset (org.jfree.data.statistics.DefaultBoxAndWhiskerXYDataset)4 Graphics2D (java.awt.Graphics2D)2 Rectangle2D (java.awt.geom.Rectangle2D)2 BufferedImage (java.awt.image.BufferedImage)2 ArrayList (java.util.ArrayList)2 JFreeChart (org.jfree.chart.JFreeChart)2 Range (org.jfree.data.Range)2 Test (org.junit.Test)2 Test (org.junit.jupiter.api.Test)2 List (java.util.List)1