/** * Deletes a range of items from the series and sends a * {@link SeriesChangeEvent} to all registered listeners. * * @param start the start index (zero-based). * @param end the end index (zero-based). */ public void delete(int start, int end) { this.data.subList(start, end + 1).clear(); findBoundsByIteration(); fireSeriesChanged(); }
/** * Deletes a range of items from the series and sends a * {@link SeriesChangeEvent} to all registered listeners. * * @param start the start index (zero-based). * @param end the end index (zero-based). */ public void delete(int start, int end) { this.data.subList(start, end + 1).clear(); findBoundsByIteration(); fireSeriesChanged(); }
/** * Sets the maximum number of items that will be retained in the series. * If you add a new item to the series such that the number of items will * exceed the maximum item count, then the first element in the series is * automatically removed, ensuring that the maximum item count is not * exceeded. * <p> * Typically this value is set before the series is populated with data, * but if it is applied later, it may cause some items to be removed from * the series (in which case a {@link SeriesChangeEvent} will be sent to * all registered listeners). * * @param maximum the maximum number of items for the series. */ public void setMaximumItemCount(int maximum) { this.maximumItemCount = maximum; int remove = this.data.size() - maximum; if (remove > 0) { this.data.subList(0, remove).clear(); findBoundsByIteration(); fireSeriesChanged(); } }
/** * Sets the maximum number of items that will be retained in the series. * If you add a new item to the series such that the number of items will * exceed the maximum item count, then the first element in the series is * automatically removed, ensuring that the maximum item count is not * exceeded. * <p> * Typically this value is set before the series is populated with data, * but if it is applied later, it may cause some items to be removed from * the series (in which case a {@link SeriesChangeEvent} will be sent to * all registered listeners). * * @param maximum the maximum number of items for the series. */ public void setMaximumItemCount(int maximum) { this.maximumItemCount = maximum; int remove = this.data.size() - maximum; if (remove > 0) { this.data.subList(0, remove).clear(); findBoundsByIteration(); fireSeriesChanged(); } }
/** * Updates the value of an item in the series and sends a * {@link SeriesChangeEvent} to all registered listeners. * * @param index the item (zero based index). * @param y the new value ({@code null} permitted). * * @since 1.0.1 */ public void updateByIndex(int index, Number y) { XYDataItem item = getRawDataItem(index); // figure out if we need to iterate through all the y-values boolean iterate = false; double oldY = item.getYValue(); if (!Double.isNaN(oldY)) { iterate = oldY <= this.minY || oldY >= this.maxY; } item.setY(y); if (iterate) { findBoundsByIteration(); } else if (y != null) { double yy = y.doubleValue(); this.minY = minIgnoreNaN(this.minY, yy); this.maxY = maxIgnoreNaN(this.maxY, yy); } fireSeriesChanged(); }
/** * Updates the value of an item in the series and sends a * {@link SeriesChangeEvent} to all registered listeners. * * @param index the item (zero based index). * @param y the new value (<code>null</code> permitted). * * @deprecated Renamed {@link #updateByIndex(int, Number)} to avoid * confusion with the {@link #update(Number, Number)} method. */ public void update(int index, Number y) { XYDataItem item = getRawDataItem(index); // figure out if we need to iterate through all the y-values boolean iterate = false; double oldY = item.getYValue(); if (!Double.isNaN(oldY)) { iterate = oldY <= this.minY || oldY >= this.maxY; } item.setY(y); if (iterate) { findBoundsByIteration(); } else if (y != null) { double yy = y.doubleValue(); this.minY = minIgnoreNaN(this.minY, yy); this.maxY = maxIgnoreNaN(this.maxY, yy); } fireSeriesChanged(); }