/**
   * Update the Flash animation. This generates the flash code and writes it to the temporary file.
   */
  public void update(View view) {

    // Create a new network.
    Network network = null;
    Module module = null;
    if (view.getElement() instanceof Connector) {
      Connector connector = (Connector) view.getElement();
      network = new Network(connector);
      module = connector.getModule();
    }
    if (view.getElement() instanceof Component) {
      Component component = (Component) view.getElement();
      network = new Network(component);
      module = component.getModule();
    }

    if (module == null || network == null) {
      return; // Abort.
    }

    // Module scope?
    if (ReoPreferences.useModuleScope()) {
      network = new Network(module);
    }

    // Check if all component ends are connected.
    for (Component component : network.getAllComponents()) {
      for (PrimitiveEnd end : component.getAllEnds()) {
        if (end.getNode() == null) return; // Abort.
      }
    }

    // Do the actual job.
    update(network, null);
  }
  /**
   * Compute the animation table for a network.
   *
   * @param network Network.
   * @param engine Colouring engine.
   * @param cache Colouring cache.
   * @param monitor Monitor.
   * @return The compiled animation table.
   */
  public static AnimationTable computeAnimations(
      Network network, ColouringEngine engine, ColouringCache cache, IProgressMonitor monitor) {

    List<Colourable> elements = new ArrayList<Colourable>();
    elements.addAll(network.getAllPrimitives());
    elements.addAll(network.getAllNodes());

    return computeAnimations(elements, null, engine, cache, monitor);
  }