XYSeries s1 = new XYSeries("S1");
s1.add(1.0, 21.0);
s1.add(2.0, 22.0);
s1.add(3.0, 23.0);
dataset.addSeries(s1);
XYDatasetSelectionExtension ext = new XYDatasetSelectionExtension(
dataset);
XYCursor cursor = new XYCursor(0, 2);
assertFalse(ext.isSelected(cursor));
ext.setSelected(cursor, true);
assertTrue(ext.isSelected(cursor));
cursor.setPosition(0, 0);
assertFalse(ext.isSelected(cursor));
s1.remove(0);
assertFalse(ext.isSelected(cursor));
cursor.setPosition(1, 99);
// fetching the value for a key that does not exist
try {
ext.isSelected(cursor);
fail("Expected an ArrayIndexOutOfBoundsException.");
} catch (ArrayIndexOutOfBoundsException e) {
// expected in this case
}
}