Search in sources :

Example 11 with DefaultBoxAndWhiskerCategoryDataset

use of org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset in project cytoscape-impl by cytoscape.

the class BoxLayer method createDataset.

// ==[ PRIVATE METHODS ]============================================================================================
@Override
protected BoxAndWhiskerCategoryDataset createDataset() {
    final DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
    for (String series : data.keySet()) {
        final List<Double> values = data.get(series);
        // switch series and category name so labels are displayed for series
        dataset.add(values, series, "1");
    }
    return dataset;
}
Also used : DefaultBoxAndWhiskerCategoryDataset(org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset)

Example 12 with DefaultBoxAndWhiskerCategoryDataset

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

the class BoxAndWhiskerRendererTest method testBug1572478Vertical.

/**
 * A check for bug 1572478 (for the vertical orientation).
 */
@Test
public void testBug1572478Vertical() {
    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset() {

        @Override
        public Number getQ1Value(int row, int column) {
            return null;
        }

        @Override
        public Number getQ1Value(Comparable rowKey, Comparable columnKey) {
            return null;
        }
    };
    List values = new ArrayList();
    values.add(new Double(1.0));
    values.add(new Double(10.0));
    values.add(new Double(100.0));
    dataset.add(values, "row", "column");
    CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("x"), new NumberAxis("y"), new BoxAndWhiskerRenderer());
    JFreeChart chart = new JFreeChart(plot);
    boolean success;
    try {
        BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = image.createGraphics();
        chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, new ChartRenderingInfo());
        g2.dispose();
        success = true;
    } catch (Exception e) {
        success = false;
    }
    assertTrue(success);
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) ArrayList(java.util.ArrayList) Rectangle2D(java.awt.geom.Rectangle2D) DefaultBoxAndWhiskerCategoryDataset(org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset) CategoryPlot(org.jfree.chart.plot.CategoryPlot) JFreeChart(org.jfree.chart.JFreeChart) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D) CategoryAxis(org.jfree.chart.axis.CategoryAxis) ChartRenderingInfo(org.jfree.chart.ChartRenderingInfo) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 13 with DefaultBoxAndWhiskerCategoryDataset

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

the class BoxAndWhiskerRendererTest method testDrawWithNullMinOutlier.

/**
 * Draws a chart where the dataset contains a null min outlier value.
 */
@Test
public void testDrawWithNullMinOutlier() {
    boolean success;
    try {
        DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
        dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0), new Double(0.5), new Double(4.5), null, 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 14 with DefaultBoxAndWhiskerCategoryDataset

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

the class BoxAndWhiskerRendererTest method testBug1572478Horizontal.

/**
 * A check for bug 1572478 (for the horizontal orientation).
 */
@Test
public void testBug1572478Horizontal() {
    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset() {

        @Override
        public Number getQ1Value(int row, int column) {
            return null;
        }

        @Override
        public Number getQ1Value(Comparable rowKey, Comparable columnKey) {
            return null;
        }
    };
    List values = new ArrayList();
    values.add(new Double(1.0));
    values.add(new Double(10.0));
    values.add(new Double(100.0));
    dataset.add(values, "row", "column");
    CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("x"), new NumberAxis("y"), new BoxAndWhiskerRenderer());
    plot.setOrientation(PlotOrientation.HORIZONTAL);
    JFreeChart chart = new JFreeChart(plot);
    boolean success;
    try {
        BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = image.createGraphics();
        chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, new ChartRenderingInfo());
        g2.dispose();
        success = true;
    } catch (Exception e) {
        success = false;
    }
    assertTrue(success);
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) ArrayList(java.util.ArrayList) Rectangle2D(java.awt.geom.Rectangle2D) DefaultBoxAndWhiskerCategoryDataset(org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset) CategoryPlot(org.jfree.chart.plot.CategoryPlot) JFreeChart(org.jfree.chart.JFreeChart) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D) CategoryAxis(org.jfree.chart.axis.CategoryAxis) ChartRenderingInfo(org.jfree.chart.ChartRenderingInfo) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 15 with DefaultBoxAndWhiskerCategoryDataset

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

Aggregations

DefaultBoxAndWhiskerCategoryDataset (org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset)15 JFreeChart (org.jfree.chart.JFreeChart)13 CategoryAxis (org.jfree.chart.axis.CategoryAxis)13 NumberAxis (org.jfree.chart.axis.NumberAxis)13 CategoryPlot (org.jfree.chart.plot.CategoryPlot)13 Test (org.junit.Test)12 ChartRenderingInfo (org.jfree.chart.ChartRenderingInfo)10 BoxAndWhiskerItem (org.jfree.data.statistics.BoxAndWhiskerItem)10 ArrayList (java.util.ArrayList)6 List (java.util.List)4 Graphics2D (java.awt.Graphics2D)2 Rectangle2D (java.awt.geom.Rectangle2D)2 BufferedImage (java.awt.image.BufferedImage)2 LegendItem (org.jfree.chart.LegendItem)1 BoxAndWhiskerToolTipGenerator (org.jfree.chart.labels.BoxAndWhiskerToolTipGenerator)1 BoxAndWhiskerRenderer (org.jfree.chart.renderer.category.BoxAndWhiskerRenderer)1