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());
}
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());
}
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);
}
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);
}
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);
}
Aggregations