/** * @param series * @param rendererClass * @return The {@link SeriesAndFormatter} that matches the series and rendererClass params, or * null if one is not found. */ protected SeriesAndFormatter<SeriesType, FormatterType> getSeries( SeriesType series, Class<? extends RendererType> rendererClass) { for (SeriesAndFormatter<SeriesType, FormatterType> thisPair : getSeriesRegistry()) { if (thisPair.getSeries() == series && thisPair.getFormatter().getRendererClass() == rendererClass) { return thisPair; } } return null; }
/** * Remove a series for a specific Renderer only. Use {@link #removeSeries(Series)} to remove the * series from the plot completely. * * @param series * @param rendererClass * @return The SeriesAndFormatterPair that was removed or null if nothing was removed. */ public synchronized SeriesAndFormatter<SeriesType, FormatterType> removeSeries( SeriesType series, Class<? extends RendererType> rendererClass) { List<SeriesAndFormatter<SeriesType, FormatterType>> results = getSeries(series); SeriesAndFormatter<SeriesType, FormatterType> result = null; for (SeriesAndFormatter<SeriesType, FormatterType> thisPair : results) { if (thisPair.getFormatter().getRendererClass() == rendererClass) { result = thisPair; getSeriesRegistry().remove(result); break; } } // if series implements PlotListener and is not assigned to any other renderers remove it as a // listener: if (series instanceof PlotListener && results.size() == 1) { removeListener((PlotListener) series); } return result; }