LineAndPointRenderer extends XYSeriesRenderer<XYSeries, FormatterType> { protected void cullPointsCache() { for(XYSeries series : pointsCaches.keySet()) { if(!getPlot().getRegistry().contains(series, LineAndPointFormatter.class)) { pointsCaches.remove(series); } } } LineAndPointRenderer(XYPlot plot); @Override void onRender(Canvas canvas, RectF plotArea, XYSeries series, FormatterType formatter, RenderStack stack); @Override void doDrawLegendIcon(Canvas canvas, RectF rect, LineAndPointFormatter formatter);  }
@Test public void testCullPointsCache() throws Exception { LineAndPointFormatter formatter = new LineAndPointFormatter(0, 0, 0, null); SimpleXYSeries series = new SimpleXYSeries( SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "some data", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); xyPlot.addSeries(series, formatter); LineAndPointRenderer renderer = xyPlot.getRenderer(LineAndPointRenderer.class); assertEquals(0, renderer.pointsCaches.size()); renderer.getPointsCache(series); assertEquals(1, renderer.pointsCaches.size()); renderer.getPointsCache(series); assertEquals(1, renderer.pointsCaches.size()); renderer.cullPointsCache(); assertEquals(1, renderer.pointsCaches.size()); xyPlot.removeSeries(series); renderer.cullPointsCache(); assertEquals(0, renderer.pointsCaches.size()); }