Search in sources :

Example 1 with DefaultBoxAndWhiskerCategoryDataset

use of org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset in project tdq-studio-se by Talend.

the class TOPChartService method createDefaultBoxAndWhiskerCategoryDataset.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.service.ITOPChartService#createDefaultBoxAndWhiskerCategoryDataset(java.lang.Double,
     * java.lang.Double, java.lang.Double, java.lang.Double, java.lang.Double, java.lang.Double)
     */
@Override
public Object createDefaultBoxAndWhiskerCategoryDataset(Double mean, Double median, Double q1, Double q3, Double minRegularValue, Double maxRegularValue) {
    DefaultBoxAndWhiskerCategoryDataset dataset = ChartDatasetUtils.createBoxAndWhiskerDataset();
    BoxAndWhiskerItem item = ChartDatasetUtils.createBoxAndWhiskerItem(mean, median, q1, q3, minRegularValue, maxRegularValue, null);
    // $NON-NLS-1$ //$NON-NLS-2$
    dataset.add(item, "0", "");
    @SuppressWarnings("rawtypes") List zerolist = new ArrayList();
    // $NON-NLS-1$ //$NON-NLS-2$
    dataset.add(zerolist, "1", "");
    // $NON-NLS-1$ //$NON-NLS-2$
    dataset.add(zerolist, "2", "");
    // $NON-NLS-1$ //$NON-NLS-2$
    dataset.add(zerolist, "3", "");
    // $NON-NLS-1$ //$NON-NLS-2$
    dataset.add(zerolist, "4", "");
    // $NON-NLS-1$ //$NON-NLS-2$
    dataset.add(zerolist, "5", "");
    // $NON-NLS-1$ //$NON-NLS-2$
    dataset.add(zerolist, "6", "");
    return dataset;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) DefaultBoxAndWhiskerCategoryDataset(org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset) BoxAndWhiskerItem(org.jfree.data.statistics.BoxAndWhiskerItem)

Example 2 with DefaultBoxAndWhiskerCategoryDataset

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

the class BoxAndWhiskerRendererTest method testDrawWithNullQ1.

/**
 * Draws a chart where the dataset contains a null Q1 value.
 */
@Test
public void testDrawWithNullQ1() {
    boolean success;
    try {
        DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
        dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), null, 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 3 with DefaultBoxAndWhiskerCategoryDataset

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

the class BoxAndWhiskerRendererTest method testDrawWithNullMedian.

/**
 * Draws a chart where the dataset contains a null median value.
 */
@Test
public void testDrawWithNullMedian() {
    boolean success;
    try {
        DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
        dataset.add(new BoxAndWhiskerItem(new Double(1.0), null, 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 4 with DefaultBoxAndWhiskerCategoryDataset

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

the class BoxAndWhiskerRendererTest method testDrawWithNullQ3.

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

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

the class BoxAndWhiskerRendererTest method testDrawWithNullInfo.

/**
 * Draws the chart with a <code>null</code> info object to make sure that
 * no exceptions are thrown (particularly by code in the renderer).
 */
@Test
public void testDrawWithNullInfo() {
    try {
        DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
        dataset.add(new BoxAndWhiskerItem(new Double(1.0), 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());
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */
        chart.createBufferedImage(300, 200, null);
    } catch (NullPointerException e) {
        fail("No exception should be thrown.");
    }
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) CategoryAxis(org.jfree.chart.axis.CategoryAxis) 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