示例#1
0
  /**
   * Starts the interpolation process.
   *
   * <p>A timer is started with an {@link #interpolationPeriod()} period that updates the {@link
   * #frame()}'s position, orientation and magnitude. {@link #interpolationStarted()} will return
   * {@code true} until {@link #stopInterpolation()} or {@link #toggleInterpolation()} is called.
   *
   * <p>If {@code period} is positive, it is set as the new {@link #interpolationPeriod()}. The
   * previous {@link #interpolationPeriod()} is used otherwise (default).
   *
   * <p>If {@link #interpolationTime()} is larger than {@link #lastTime()}, {@link
   * #interpolationTime()} is reset to {@link #firstTime()} before interpolation starts (and
   * inversely for negative {@link #interpolationSpeed()}.
   *
   * <p>Use {@link #setInterpolationTime(float)} before calling this method to change the starting
   * {@link #interpolationTime()}.
   *
   * <p><b>Attention:</b> The keyFrames must be defined (see {@link #addKeyFrame(GenericFrame,
   * float)}) before you startInterpolation(), or else the interpolation will naturally immediately
   * stop.
   */
  public void startInterpolation(int myPeriod) {
    if (myPeriod >= 0) setInterpolationPeriod(myPeriod);

    if (!keyFrameList.isEmpty()) {
      if ((interpolationSpeed() > 0.0)
          && (interpolationTime() >= keyFrameList.get(keyFrameList.size() - 1).time()))
        setInterpolationTime(keyFrameList.get(0).time());
      if ((interpolationSpeed() < 0.0) && (interpolationTime() <= keyFrameList.get(0).time()))
        setInterpolationTime(keyFrameList.get(keyFrameList.size() - 1).time());
      if (keyFrameList.size() > 1) interpolationTimerTask.run(interpolationPeriod());
      interpolationStrt = true;
      update();
    }
  }
示例#2
0
 /**
  * Stops an interpolation started with {@link #startInterpolation()}. See {@link
  * #interpolationStarted()} and {@link #toggleInterpolation()}.
  */
 public void stopInterpolation() {
   interpolationTimerTask.stop();
   interpolationStrt = false;
 }