/** * 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). */ protected void delete(int start, int end) { for (int i = start; i <= end; i++) { this.data.remove(start); } 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). */ protected void delete(int start, int end) { for (int i = start; i <= end; i++) { this.data.remove(start); } fireSeriesChanged(); }
/** * Removes the item at the specified index and sends a * {@link SeriesChangeEvent} to all registered listeners. * * @param index the index. * * @return The item removed. */ protected ComparableObjectItem remove(int index) { ComparableObjectItem result = (ComparableObjectItem) this.data.remove( index); fireSeriesChanged(); return result; }
/** * Removes the item at the specified index and sends a * {@link SeriesChangeEvent} to all registered listeners. * * @param index the index. * * @return The item removed. */ protected ComparableObjectItem remove(int index) { ComparableObjectItem result = (ComparableObjectItem) this.data.remove( index); fireSeriesChanged(); return result; }
/** * Removes all data items from the series and, unless the series is * already empty, sends a {@link SeriesChangeEvent} to all registered * listeners. */ public void clear() { if (this.data.size() > 0) { this.data.clear(); fireSeriesChanged(); } }
/** * Removes all data items from the series and, unless the series is * already empty, sends a {@link SeriesChangeEvent} to all registered * listeners. */ public void clear() { if (this.data.size() > 0) { this.data.clear(); 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; boolean dataRemoved = false; while (this.data.size() > maximum) { this.data.remove(0); dataRemoved = true; } if (dataRemoved) { 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; boolean dataRemoved = false; while (this.data.size() > maximum) { this.data.remove(0); dataRemoved = true; } if (dataRemoved) { 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). */ protected void updateByIndex(int index, Object y) { ComparableObjectItem item = getDataItem(index); item.setObject(y); 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). */ protected void updateByIndex(int index, Object y) { ComparableObjectItem item = getDataItem(index); item.setObject(y); fireSeriesChanged(); }
/** * Updates an item in the series. * * @param x the x-value ({@code null} not permitted). * @param y the y-value ({@code null} permitted). * * @throws SeriesException if there is no existing item with the specified * x-value. */ protected void update(Comparable x, Object y) { int index = indexOf(x); if (index < 0) { throw new SeriesException("No observation for x = " + x); } else { ComparableObjectItem item = getDataItem(index); item.setObject(y); fireSeriesChanged(); } }
/** * Updates an item in the series. * * @param x the x-value (<code>null</code> not permitted). * @param y the y-value (<code>null</code> permitted). * * @throws SeriesException if there is no existing item with the specified * x-value. */ protected void update(Comparable x, Object y) { int index = indexOf(x); if (index < 0) { throw new SeriesException("No observation for x = " + x); } else { ComparableObjectItem item = getDataItem(index); item.setObject(y); fireSeriesChanged(); } }