Search in sources :

Example 11 with DefaultTableXYDataset

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

the class RendererXYPackageUtils method createTestTableXYDataset.

/**
 * Creates and returns a sample dataset for testing purposes.
 *
 * @return A sample dataset.
 */
public static TableXYDataset createTestTableXYDataset() {
    DefaultTableXYDataset result = new DefaultTableXYDataset();
    XYSeries series1 = new XYSeries("Series 1", false, false);
    series1.add(1.0, 2.0);
    series1.add(2.0, 5.0);
    XYSeries series2 = new XYSeries("Series 2", false, false);
    series2.add(1.0, 4.0);
    series2.add(2.0, 3.0);
    result.addSeries(series1);
    result.addSeries(series2);
    return result;
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) DefaultTableXYDataset(org.jfree.data.xy.DefaultTableXYDataset)

Example 12 with DefaultTableXYDataset

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

the class StackedXYAreaRenderer2Test method testDrawWithEmptyDataset.

/**
 * Test chart drawing with an empty dataset to ensure that this special
 * case doesn't cause any exceptions.
 */
@Test
public void testDrawWithEmptyDataset() {
    boolean success = false;
    JFreeChart chart = ChartFactory.createStackedXYAreaChart("title", "x", "y", new DefaultTableXYDataset(), PlotOrientation.VERTICAL, true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StackedXYAreaRenderer2());
    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, null);
        g2.dispose();
        success = true;
    } catch (Exception e) {
        success = false;
    }
    assertTrue(success);
}
Also used : DefaultTableXYDataset(org.jfree.data.xy.DefaultTableXYDataset) XYPlot(org.jfree.chart.plot.XYPlot) Rectangle2D(java.awt.geom.Rectangle2D) JFreeChart(org.jfree.chart.JFreeChart) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D) Test(org.junit.Test)

Example 13 with DefaultTableXYDataset

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

the class XYStepRendererTest 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 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)

Example 14 with DefaultTableXYDataset

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

the class DatasetUtilitiesTest method testFindStackedRangeBoundsForTableXYDataset2.

/**
 * Some checks for the findStackedRangeBounds() method.
 */
@Test
public void testFindStackedRangeBoundsForTableXYDataset2() {
    DefaultTableXYDataset d = new DefaultTableXYDataset();
    Range r = DatasetUtilities.findStackedRangeBounds(d);
    assertEquals(r, new Range(0.0, 0.0));
}
Also used : DefaultTableXYDataset(org.jfree.data.xy.DefaultTableXYDataset) Range(org.jfree.data.Range) Test(org.junit.Test)

Example 15 with DefaultTableXYDataset

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

the class DatasetUtilitiesTest method createTableXYDataset1.

/**
 * Creates a sample dataset for testing purposes.
 *
 * @return A sample dataset.
 */
private TableXYDataset createTableXYDataset1() {
    DefaultTableXYDataset dataset = new DefaultTableXYDataset();
    XYSeries s1 = new XYSeries("Series 1", true, false);
    s1.add(1.0, 1.0);
    s1.add(2.0, 2.0);
    dataset.addSeries(s1);
    XYSeries s2 = new XYSeries("Series 2", true, false);
    s2.add(1.0, -2.0);
    s2.add(2.0, -1.0);
    dataset.addSeries(s2);
    return dataset;
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) DefaultTableXYDataset(org.jfree.data.xy.DefaultTableXYDataset)

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