Пример #1
0
 /**
  * @param series
  * @return A List of {@link SeriesAndFormatter} instances that reference series.
  */
 protected List<SeriesAndFormatter<SeriesType, FormatterType>> getSeries(SeriesType series) {
   List<SeriesAndFormatter<SeriesType, FormatterType>> results =
       new ArrayList<SeriesAndFormatter<SeriesType, FormatterType>>();
   for (SeriesAndFormatter<SeriesType, FormatterType> thisPair : getSeriesRegistry()) {
     if (thisPair.getSeries() == series) {
       results.add(thisPair);
     }
   }
   return results;
 }
Пример #2
0
 /**
  * @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;
 }
Пример #3
0
  /**
   * 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;
  }