[[#variable1aa9d220]]void add( [[#variable1aa9d180]] item, boolean notify) {
if (item == null) {
throw new IllegalArgumentException("Null \'item\' argument.");
}
if (this.autoSort) {
int index = Collections.binarySearch(this.data, item);
if (index < 0) {
this.data.add(-index - 1, item);
}
else {
if (this.allowDuplicateXValues) {
// need to make sure we are adding *after* any duplicates
int size = this.data.size();
while (index < size && item.compareTo(this.data.get(index)) == 0) {
index++;
}
if (index < this.data.size()) {
this.data.add(index, item);
}
else {
this.data.add(item);
}
}
else {
throw new SeriesException("X-value already exists.");
}
}
}
else {
if ( !this.allowDuplicateXValues) {
// can't allow duplicate values, so we need to check whether
// there is an item with the given x-value already
int index = indexOf(item. [[#variable1aa9d140]]());
if (index >= 0) {
throw new SeriesException("X-value already exists.");
}
}
this.data.add(item);
}
if (getItemCount() > this.maximumItemCount) {
this.data.remove(0);
}
if (notify) {
fireSeriesChanged();
}
}
|