Пример #1
0
 /**
  * Sets the value of the existing point (abscissa, value) at index index to y. If the index is
  * negative, does not do anything. If the index equals the index of the last element of the signal
  * plus one, adds an element (index, y) to the signal at the index index. If the index is greateur
  * than the index of the last element of the signal plus one, does not do anything.
  *
  * @param index index of the exsisting point. If the point does not exists, adds it
  * @param y value to be given to the corresponding point (abscissa, value).
  */
 public void setValueOf(int index, double y) {
   if (index == this.getNbSamples()) {
     data.add(index, y);
   } else if ((index >= 0) && (index < this.getNbSamples())) {
     data.updateByIndex(index, y);
   }
 }
 /**
  * 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.
  */
 public void update(Number x, Number y) {
   int index = indexOf(x);
   if (index < 0) {
     throw new SeriesException("No observation for x = " + x);
   }
   updateByIndex(index, y);
 }
Пример #3
0
 /**
  * Looks for the element of the given abscissa and sets its value to ordiante. If there is no
  * points existing with the given abcisssa, adds a point (abscissa, ordinate) to the signal.
  * (actually, this method does the exact same thing as addElement).
  *
  * @param abscissa abscissa of the considered point
  * @param ordinate value to add or update in the signal
  */
 public void setElement(double abscissa, double ordinate) {
   int index = data.indexOf(abscissa);
   if (index < 0) {
     data.add(abscissa, ordinate);
   } else {
     data.updateByIndex(index, ordinate);
   }
 }