Search in sources :

Example 1 with DefaultTableXYDataset

use of org.jfree.data.xy.DefaultTableXYDataset in project SIMVA-SoS by SESoS.

the class XYTitleAnnotationTest method testDrawWithNullInfo.

/**
 * Draws the chart with a <code>null</code> info object to make sure that
 * no exceptions are thrown.
 */
@Test
public void testDrawWithNullInfo() {
    try {
        DefaultTableXYDataset dataset = new DefaultTableXYDataset();
        XYSeries s1 = new XYSeries("Series 1", true, false);
        s1.add(5.0, 5.0);
        s1.add(10.0, 15.5);
        s1.add(15.0, 9.5);
        s1.add(20.0, 7.5);
        dataset.addSeries(s1);
        XYSeries s2 = new XYSeries("Series 2", true, false);
        s2.add(5.0, 5.0);
        s2.add(10.0, 15.5);
        s2.add(15.0, 9.5);
        s2.add(20.0, 3.5);
        dataset.addSeries(s2);
        XYPlot plot = new XYPlot(dataset, new NumberAxis("X"), new NumberAxis("Y"), new XYLineAndShapeRenderer());
        plot.addAnnotation(new XYTitleAnnotation(5.0, 6.0, new TextTitle("Hello World!")));
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */
        chart.createBufferedImage(300, 200, null);
    } catch (NullPointerException e) {
        fail("There should be no exception.");
    }
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) DefaultTableXYDataset(org.jfree.data.xy.DefaultTableXYDataset) TextTitle(org.jfree.chart.title.TextTitle) NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) JFreeChart(org.jfree.chart.JFreeChart) Test(org.junit.Test)

Example 2 with DefaultTableXYDataset

use of org.jfree.data.xy.DefaultTableXYDataset in project SIMVA-SoS by SESoS.

the class XYAreaRenderer2Test 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 {
        DefaultTableXYDataset dataset = new DefaultTableXYDataset();
        XYSeries s1 = new XYSeries("Series 1", true, false);
        s1.add(5.0, 5.0);
        s1.add(10.0, 15.5);
        s1.add(15.0, 9.5);
        s1.add(20.0, 7.5);
        dataset.addSeries(s1);
        XYSeries s2 = new XYSeries("Series 2", true, false);
        s2.add(5.0, 5.0);
        s2.add(10.0, 15.5);
        s2.add(15.0, 9.5);
        s2.add(20.0, 3.5);
        dataset.addSeries(s2);
        XYPlot plot = new XYPlot(dataset, new NumberAxis("X"), new NumberAxis("Y"), new XYAreaRenderer2());
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */
        chart.createBufferedImage(300, 200, null);
    } catch (NullPointerException e) {
        fail("No exception should be thrown.");
    }
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) DefaultTableXYDataset(org.jfree.data.xy.DefaultTableXYDataset) NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) JFreeChart(org.jfree.chart.JFreeChart) Test(org.junit.Test)

Example 3 with DefaultTableXYDataset

use of org.jfree.data.xy.DefaultTableXYDataset in project SIMVA-SoS by SESoS.

the class StackedXYAreaRenderer2Test method testFindRangeBounds.

/**
 * Check that the renderer is calculating the range bounds correctly.
 */
@Test
public void testFindRangeBounds() {
    TableXYDataset dataset = RendererXYPackageUtils.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart("Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
    plot.setRenderer(renderer);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    Range bounds = rangeAxis.getRange();
    assertTrue(bounds.contains(6.0));
    assertTrue(bounds.contains(8.0));
    // try null argument
    assertNull(renderer.findRangeBounds(null));
    // try empty dataset
    assertNull(renderer.findRangeBounds(new DefaultTableXYDataset()));
}
Also used : DefaultTableXYDataset(org.jfree.data.xy.DefaultTableXYDataset) NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) TableXYDataset(org.jfree.data.xy.TableXYDataset) DefaultTableXYDataset(org.jfree.data.xy.DefaultTableXYDataset) Range(org.jfree.data.Range) JFreeChart(org.jfree.chart.JFreeChart) Test(org.junit.Test)

Example 4 with DefaultTableXYDataset

use of org.jfree.data.xy.DefaultTableXYDataset in project SIMVA-SoS by SESoS.

the class XYAreaRendererTest 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 {
        DefaultTableXYDataset dataset = new DefaultTableXYDataset();
        XYSeries s1 = new XYSeries("Series 1", true, false);
        s1.add(5.0, 5.0);
        s1.add(10.0, 15.5);
        s1.add(15.0, 9.5);
        s1.add(20.0, 7.5);
        dataset.addSeries(s1);
        XYSeries s2 = new XYSeries("Series 2", true, false);
        s2.add(5.0, 5.0);
        s2.add(10.0, 15.5);
        s2.add(15.0, 9.5);
        s2.add(20.0, 3.5);
        dataset.addSeries(s2);
        XYPlot plot = new XYPlot(dataset, new NumberAxis("X"), new NumberAxis("Y"), new XYAreaRenderer());
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */
        chart.createBufferedImage(300, 200, null);
    } catch (NullPointerException e) {
        fail("No exception should be thrown.");
    }
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) DefaultTableXYDataset(org.jfree.data.xy.DefaultTableXYDataset) NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) JFreeChart(org.jfree.chart.JFreeChart) Test(org.junit.Test)

Example 5 with DefaultTableXYDataset

use of org.jfree.data.xy.DefaultTableXYDataset in project SIMVA-SoS by SESoS.

the class XYStepRendererTest method testDrawWithNullValue.

/**
 * Draws the chart with a <code>null</code> value in the dataset to make
 * sure that no exceptions are thrown.
 */
@Test
public void testDrawWithNullValue() {
    try {
        DefaultTableXYDataset dataset = new DefaultTableXYDataset();
        XYSeries s1 = new XYSeries("Series 1", true, false);
        s1.add(5.0, 5.0);
        s1.add(10.0, null);
        s1.add(15.0, 9.5);
        s1.add(20.0, 7.5);
        dataset.addSeries(s1);
        XYSeries s2 = new XYSeries("Series 2", true, false);
        s2.add(5.0, 5.0);
        s2.add(10.0, 15.5);
        s2.add(15.0, null);
        s2.add(20.0, null);
        dataset.addSeries(s2);
        XYPlot plot = new XYPlot(dataset, new NumberAxis("X"), new NumberAxis("Y"), new XYStepRenderer());
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */
        chart.createBufferedImage(300, 200, null);
    } catch (NullPointerException e) {
        fail("No exception should be thrown.");
    }
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) DefaultTableXYDataset(org.jfree.data.xy.DefaultTableXYDataset) NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) JFreeChart(org.jfree.chart.JFreeChart) Test(org.junit.Test)

Aggregations

DefaultTableXYDataset (org.jfree.data.xy.DefaultTableXYDataset)15 XYSeries (org.jfree.data.xy.XYSeries)12 JFreeChart (org.jfree.chart.JFreeChart)11 XYPlot (org.jfree.chart.plot.XYPlot)11 Test (org.junit.Test)11 NumberAxis (org.jfree.chart.axis.NumberAxis)10 XYLineAndShapeRenderer (org.jfree.chart.renderer.xy.XYLineAndShapeRenderer)2 Range (org.jfree.data.Range)2 GenerateException (com.xpn.xwiki.plugin.charts.exceptions.GenerateException)1 BasicStroke (java.awt.BasicStroke)1 Graphics2D (java.awt.Graphics2D)1 Rectangle2D (java.awt.geom.Rectangle2D)1 BufferedImage (java.awt.image.BufferedImage)1 TextTitle (org.jfree.chart.title.TextTitle)1 TableXYDataset (org.jfree.data.xy.TableXYDataset)1