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.");
}
}
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="));
}
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));
}
Aggregations