Package com.positive.charts.common

Examples of com.positive.charts.common.SeriesException


            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
        final int index = this.indexOf(item.getX());
        if (index >= 0) {
          throw new SeriesException("X-value already exists.");
        }
      }
      this.data.add(item);
    }
    if (this.getItemCount() > this.maximumItemCount) {
View Full Code Here


    if (index >= 0) {
      final XYDataItem existing = (XYDataItem) this.data.get(index);
      try {
        overwritten = (XYDataItem) existing.clone();
      } catch (final CloneNotSupportedException e) {
        throw new SeriesException("Couldn't clone XYDataItem!");
      }
      existing.setY(y);
    } else {
      // if the series is sorted, the negative index is a result from
      // Collections.binarySearch() and tells us where to insert the
View Full Code Here

   *             if there is no existing item with the specified x-value.
   */
  public void update(final Number x, final Number y) {
    final int index = this.indexOf(x);
    if (index < 0) {
      throw new SeriesException("No observation for x = " + x);
    } else {
      final XYDataItem item = this.getDataItem(index);
      item.setY(y);
      this.fireSeriesChanged();
    }
View Full Code Here

      b.append("is ");
      b.append(item.getPeriod().getClass().getName());
      b.append(", but the TimeSeries is expecting an instance of ");
      b.append(this.timePeriodClass.getName());
      b.append(".");
      throw new SeriesException(b.toString());
    }

    // make the change (if it's not a duplicate time period)...
    boolean added = false;
    final int count = this.getItemCount();
    if (count == 0) {
      this.data.add(item);
      added = true;
    } else {
      final RegularTimePeriod last = this.getTimePeriod(this
          .getItemCount() - 1);
      if (item.getPeriod().compareTo(last) > 0) {
        this.data.add(item);
        added = true;
      } else {
        final int index = Collections.binarySearch(this.data, item);
        if (index < 0) {
          this.data.add(-index - 1, item);
          added = true;
        } else {
          final StringBuffer b = new StringBuffer();
          b.append("You are attempting to add an observation for ");
          b.append("the time period ");
          b.append(item.getPeriod().toString());
          b.append(" but the series already contains an observation");
          b.append(" for that time period. Duplicates are not ");
          b.append("permitted.  Try using the addOrUpdate() method.");
          throw new SeriesException(b.toString());
        }
      }
    }
    if (added) {
      // check if this addition will exceed the maximum item count...
View Full Code Here

      final TimeSeriesDataItem pair = (TimeSeriesDataItem) this.data
          .get(index);
      pair.setValue(value);
      this.fireSeriesChanged();
    } else {
      throw new SeriesException(
          "TimeSeries.update(TimePeriod, Number):  period does not exist.");
    }

  }
View Full Code Here

TOP

Related Classes of com.positive.charts.common.SeriesException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.