/*
  * (non-Javadoc)
  * @see org.ect.reo.animation.animators.AbstractViewAnimator#dispose()
  */
 @Override
 public void dispose() {
   if (animateJob != null) {
     animateJob.cancel();
   }
   ReoUIPlugin.getInstance().getPreferenceStore().removePropertyChangeListener(this);
   super.dispose();
 }
  /**
   * Update the Flash animation. This generates the flash code and writes it to the temporary file.
   */
  public void update(Network network, Firing trace) {

    // Is it a new network?
    boolean isNewNetwork = (networkView == null || networkView.getNetwork() != network);

    // Initialize animation job.
    if (animateJob == null) {
      animateJob = new GenerateAnimationsJob();
      isRunning = false;
    }

    if (isRunning) {
      // Cancel only if it is a new network.
      if (isNewNetwork) {
        animateJob.cancel();
      }
    } else {
      isRunning = true;
      try {
        // Initialize the animation generation.
        networkView = new NetworkView(network);
        initGeneration(networkView, trace, isNewNetwork);
      } catch (Throwable e) {
        openError("Error initializing animation generation: " + e);
        Reo.logError("Error initializing animation generation", e);
        isRunning = false;
        return;
      }

      // Now schedule the actual job.
      animateJob.setNetworkView(networkView);
      animateJob.setFiring(trace);
      animateJob.schedule();
    }

    notifyAnimationUpdate();
  }
 /*
  * (non-Javadoc)
  * @see org.ect.reo.animation.animators.IViewAnimator#cancel()
  */
 public void cancel() {
   if (animateJob != null && isRunning) {
     animateJob.cancel();
   }
 }