Search in sources :

Example 26 with DefaultXYDataset

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

the class XYPlotTest method test1654215.

/**
 * A test for bug 1654215 (where a renderer is added to the plot without
 * a corresponding dataset and it throws an exception at drawing time).
 */
@Test
public void test1654215() {
    DefaultXYDataset dataset = new DefaultXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y", dataset, PlotOrientation.VERTICAL, true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(1, new XYLineAndShapeRenderer());
    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();
    } catch (Exception e) {
        fail("No exception should be thrown.");
    }
}
Also used : DefaultXYDataset(org.jfree.data.xy.DefaultXYDataset) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) Rectangle2D(java.awt.geom.Rectangle2D) JFreeChart(org.jfree.chart.JFreeChart) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D) Test(org.junit.Test)

Example 27 with DefaultXYDataset

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

the class TimeSeriesURLGeneratorTest method testGenerateURL.

/**
 * A basic check for the generateURL() method.
 */
@Test
public void testGenerateURL() {
    TimeSeriesURLGenerator g = new TimeSeriesURLGenerator();
    DefaultXYDataset dataset = new DefaultXYDataset();
    dataset.addSeries("Series '1'", new double[][] { { 1.0, 2.0 }, { 3.0, 4.0 } });
    String s = g.generateURL(dataset, 0, 0);
    assertTrue(s.startsWith("index.html?series=Series+%271%27&item="));
}
Also used : DefaultXYDataset(org.jfree.data.xy.DefaultXYDataset) Test(org.junit.Test)

Example 28 with DefaultXYDataset

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

the class RendererUtilitiesTest method testFindLiveItemsUpperBound_Ascending.

/**
 * Some checks for the findLiveItemsUpperBound() method when the dataset is
 * ASCENDING.
 */
@Test
public void testFindLiveItemsUpperBound_Ascending() {
    DefaultXYDataset d = new DefaultXYDataset() {

        @Override
        public DomainOrder getDomainOrder() {
            // only add data in ascending order by x-value
            return DomainOrder.ASCENDING;
        }
    };
    // check a series with no items
    d.addSeries("S1", new double[][] { {}, {} });
    assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 0, 10.0, 11.1));
    // check a series with one item
    d.addSeries("S2", new double[][] { { 1.0 }, { 9.9 } });
    assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 0.0, 1.1));
    assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 2.0, 2.2));
    // check a series with two items
    d.addSeries("S3", new double[][] { { 1.0, 2.0 }, { 9.9, 9.9 } });
    assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 2, 0.0, 1.0));
    assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 1.0, 2.2));
    assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 2.0, 3.3));
    assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 3.0, 4.4));
    // check a series with three items
    d.addSeries("S4", new double[][] { { 1.0, 2.0, 3.0 }, { 9.9, 9.9, 9.9 } });
    assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 3, 0.0, 1.1));
    assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 3, 1.0, 2.2));
    assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 2.0, 3.3));
    assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 3.0, 4.4));
    // check a series with four items
    d.addSeries("S5", new double[][] { { 1.0, 2.0, 3.0, 4.0 }, { 9.9, 9.9, 9.9, 9.9 } });
    assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0, 1.1));
    assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 4, 1.0, 2.2));
    assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 4, 2.0, 3.3));
    assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 3.0, 4.4));
    assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 4.0, 5.5));
    // check a series with repeating items
    d.addSeries("S5", new double[][] { { 1.0, 2.0, 2.0, 2.0, 3.0 }, { 9.9, 9.9, 9.9, 9.9, 9.9 } });
    assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0, 1.0));
    assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0, 2.0));
    assertEquals(4, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0, 3.0));
    assertEquals(4, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0, 4.0));
}
Also used : DefaultXYDataset(org.jfree.data.xy.DefaultXYDataset) Test(org.junit.Test)

Aggregations

DefaultXYDataset (org.jfree.data.xy.DefaultXYDataset)28 Test (org.junit.Test)24 JFreeChart (org.jfree.chart.JFreeChart)8 NumberAxis (org.jfree.chart.axis.NumberAxis)7 XYPlot (org.jfree.chart.plot.XYPlot)7 Rectangle2D (java.awt.geom.Rectangle2D)4 BufferedImage (java.awt.image.BufferedImage)4 Graphics2D (java.awt.Graphics2D)3 Range (org.jfree.data.Range)3 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 OutputStream (java.io.OutputStream)2 List (java.util.List)2 JFrame (javax.swing.JFrame)2 ChartPanel (org.jfree.chart.ChartPanel)2 XYSplineRenderer (org.jfree.chart.renderer.xy.XYSplineRenderer)2 VCellHelper (org.vcell.imagej.helper.VCellHelper)2 IJDataList (org.vcell.imagej.helper.VCellHelper.IJDataList)2 IJTimeSeriesJobResults (org.vcell.imagej.helper.VCellHelper.IJTimeSeriesJobResults)2 IJVarInfos (org.vcell.imagej.helper.VCellHelper.IJVarInfos)2