Search in sources :

Example 11 with DefaultXYDataset

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

the class ChartPanelTest method test2502355_zoomInBoth.

/**
 * Checks that a call to the zoomInBoth() method generates just one
 * ChartChangeEvent.
 */
@Test
public void test2502355_zoomInBoth() {
    DefaultXYDataset dataset = new DefaultXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false);
    ChartPanel panel = new ChartPanel(chart);
    chart.addChangeListener(this);
    this.chartChangeEvents.clear();
    panel.zoomInBoth(1.0, 2.0);
    assertEquals(1, this.chartChangeEvents.size());
}
Also used : DefaultXYDataset(org.jfree.data.xy.DefaultXYDataset) Test(org.junit.Test)

Example 12 with DefaultXYDataset

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

the class ChartPanelTest method test2502355_zoom.

/**
 * Checks that a call to the zoom() method generates just one
 * ChartChangeEvent.
 */
@Test
public void test2502355_zoom() {
    DefaultXYDataset dataset = new DefaultXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false);
    ChartPanel panel = new ChartPanel(chart);
    chart.addChangeListener(this);
    this.chartChangeEvents.clear();
    panel.zoom(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    assertEquals(1, this.chartChangeEvents.size());
}
Also used : DefaultXYDataset(org.jfree.data.xy.DefaultXYDataset) Rectangle2D(java.awt.geom.Rectangle2D) Test(org.junit.Test)

Example 13 with DefaultXYDataset

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

the class DatasetUtilitiesTest method testIterateDomainBounds_NaN.

/**
 * Check that NaN values in the dataset are ignored.
 */
@Test
public void testIterateDomainBounds_NaN() {
    DefaultXYDataset dataset = new DefaultXYDataset();
    double[] x = new double[] { 1.0, 2.0, Double.NaN, 3.0 };
    double[] y = new double[] { 9.0, 8.0, 7.0, 6.0 };
    dataset.addSeries("S1", new double[][] { x, y });
    Range r = DatasetUtilities.iterateDomainBounds(dataset);
    assertEquals(1.0, r.getLowerBound(), EPSILON);
    assertEquals(3.0, r.getUpperBound(), EPSILON);
}
Also used : DefaultXYDataset(org.jfree.data.xy.DefaultXYDataset) Range(org.jfree.data.Range) Test(org.junit.Test)

Example 14 with DefaultXYDataset

use of org.jfree.data.xy.DefaultXYDataset in project dkpro-lab by dkpro.

the class ChartUtilTest method testPDF.

@Test
public void testPDF() throws Exception {
    double[][] data = new double[2][10];
    for (int n = 1; n < 10; n++) {
        data[0][n] = 1.0 / n;
        data[1][n] = 1.0 - (1.0 / n);
    }
    DefaultXYDataset dataset = new DefaultXYDataset();
    dataset.addSeries("data", data);
    JFreeChart chart = ChartFactory.createXYLineChart(null, "Recall", "Precision", dataset, PlotOrientation.VERTICAL, false, false, false);
    chart.getXYPlot().setRenderer(new XYSplineRenderer());
    chart.getXYPlot().getRangeAxis().setRange(0.0, 1.0);
    chart.getXYPlot().getDomainAxis().setRange(0.0, 1.0);
    File tmp = File.createTempFile("testfile", ".pdf");
    try (OutputStream os = new FileOutputStream(tmp)) {
        ChartUtil.writeChartAsPDF(os, chart, 400, 400);
    }
// Do not have an assert here because the creation date encoded in the PDF changes
// String ref = FileUtils.readFileToString(new File("src/test/resources/chart/test.pdf"),
// "UTF-8");
// String actual = FileUtils.readFileToString(tmp, "UTF-8");
// assertEquals(ref, actual);
}
Also used : DefaultXYDataset(org.jfree.data.xy.DefaultXYDataset) XYSplineRenderer(org.jfree.chart.renderer.xy.XYSplineRenderer) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) File(java.io.File) JFreeChart(org.jfree.chart.JFreeChart) Test(org.junit.Test)

Example 15 with DefaultXYDataset

use of org.jfree.data.xy.DefaultXYDataset in project dkpro-lab by dkpro.

the class ChartUtilTest method testSvg.

@Test
public void testSvg() throws Exception {
    double[][] data = new double[2][10];
    for (int n = 1; n < 10; n++) {
        data[0][n] = 1.0 / n;
        data[1][n] = 1.0 - (1.0 / n);
    }
    DefaultXYDataset dataset = new DefaultXYDataset();
    dataset.addSeries("data", data);
    JFreeChart chart = ChartFactory.createXYLineChart(null, "Recall", "Precision", dataset, PlotOrientation.VERTICAL, false, false, false);
    chart.getXYPlot().setRenderer(new XYSplineRenderer());
    chart.getXYPlot().getRangeAxis().setRange(0.0, 1.0);
    chart.getXYPlot().getDomainAxis().setRange(0.0, 1.0);
    File tmp = File.createTempFile("testfile", ".svg");
    try (OutputStream os = new FileOutputStream(tmp)) {
        ChartUtil.writeChartAsSVG(os, chart, 400, 400);
    }
// String ref = FileUtils.readFileToString(new File("src/test/resources/chart/test.svg"),
// "UTF-8");
// String actual = FileUtils.readFileToString(tmp, "UTF-8");
// assertEquals(ref, actual);
}
Also used : DefaultXYDataset(org.jfree.data.xy.DefaultXYDataset) XYSplineRenderer(org.jfree.chart.renderer.xy.XYSplineRenderer) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) File(java.io.File) JFreeChart(org.jfree.chart.JFreeChart) 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