/**
   * Sets the activity state depending on the time. This method (1) checks to see if the node has
   * gone active or inactive, (2) determines if this node needs to be serviced by the time clock,
   * and (3) registers or unregisters for time callbacks accordingly.
   *
   * @param time The current clock time
   */
  private void resetTimeListener(double time) {
    // time, start and stop times may have changed

    // 1: determine if active state changes
    if (vfIsActive) {
      // consider stopping if stopTime < time
      if ((vfStopTime > vfStartTime) && (time >= vfStopTime)) {
        setIsActive(false);
      }
    } else {
      // consider starting if startTime <= time < stopTime
      if (vfStartTime <= time && (vfStopTime < vfStartTime || vfStopTime > time)) {
        setIsActive(true);
      }
    }

    // 2: determine new listening state
    boolean newListening = false; // should I listen?

    if (vfIsActive) {
      // listen if now active and stop time is set
      if (vfStopTime > vfStartTime) {
        newListening = true;
      }
    } else {
      // listen if inactive and start time is in the future
      if (vfStartTime >= time) {
        newListening = true;
      }
    }

    // 3: change listening state if necessary
    if (vrmlClock != null) {
      if (newListening != isTimeListening) {
        if (isTimeListening) {
          // stop listening to ticks
          vrmlClock.removeTimeListener(this);
        } else {
          // start listening to ticks
          vrmlClock.addTimeListener(this);
        }
        isTimeListening = newListening;
      }
    }
  }
 /**
  * Set a new value for the stop time. If the sensor is active and the stop time is less than the
  * current start time, it is ignored. If the stop time is less that now, it is set to now.
  *
  * @param newStopTime The new stop time
  */
 public void setStopTime(double newStopTime) {
   // Debug.trace();
   if (vfIsActive && (newStopTime < vfStartTime)) {
     // ignore stoptime if active and new time is less than start time.
   } else {
     // superclass will fire the fieldChanged events
     super.setStopTime(newStopTime);
     if (vrmlClock == null) resetTimeListener(0);
     else resetTimeListener(vrmlClock.getTime());
   }
 }
  /**
   * Set a new value for the start time. If the sensor is active then it is ignored (as per the
   * spec).
   *
   * @param newStartTime The new start time
   */
  public void setStartTime(double newStartTime) {
    // Debug.trace();
    if (vfIsActive) {
      // ignore starttime while active
    } else {
      // superclass will fire the fieldChanged events
      super.setStartTime(newStartTime);

      if (vrmlClock != null) {
        resetTimeListener(vrmlClock.getTime());
      }
    }
  }
 /**
  * Set the vrmlClock that this time dependent node will be running with.
  *
  * @param clk The vrmlClock to use for this node
  */
 public void setVRMLClock(VRMLClock clk) {
   vrmlClock = clk;
   resetTimeListener(vrmlClock.getTime());
 }