BoxPlot extends XYPlot { @Override public void add(int index, DataSource source, boolean visible) { if (getData().size() > 0) { throw new IllegalArgumentException( "This plot type only supports a single data source."); } BoxWhiskerRenderer renderer = new BoxWhiskerRenderer(); setPointRenderers(source, renderer); super.add(index, source, visible); setLineRenderers(source, null); setPointRenderers(source, renderer); } BoxPlot(DataSource data); @SuppressWarnings("unchecked") static DataSource createBoxData(DataSource data); @Override void add(int index, DataSource source, boolean visible); @Override void autoscaleAxis(String axisName);  }
@Test public void testAddRemoveData() { plot.remove(data); assertEquals(0, plot.getData().size()); plot.add(data); assertEquals(1, plot.getData().size()); try { plot.add(data); fail(); } catch (IllegalArgumentException e) { } }