/**
  * Initialize this actor, which in this case, does nothing. The initialization of the submodel is
  * accomplished in fire(). The subclass of this can set the
  * <i>_isSubclassOfExecuteCompositeActor</i> to be true to call the initialize method of the
  * superclass of this.
  *
  * @exception IllegalActionException Not thrown in this base class, but declared so the subclasses
  *     can throw it.
  */
 public void initialize() throws IllegalActionException {
   super.initialize();
   if (_debugging) {
     _debug("Called initialize(), which does nothing.");
   }
   _iteration = 0;
 }
  /**
   * Run a complete execution of the contained model. A complete execution consists of invocation of
   * super.initialize(), repeated invocations of super.prefire(), super.fire(), and
   * super.postfire(), followed by super.wrapup(). The invocations of prefire(), fire(), and
   * postfire() are repeated until either the model indicates it is not ready to execute (prefire()
   * returns false), or it requests a stop (postfire() returns false or stop() is called). Before
   * running the complete execution, this method calls the director's transferInputs() method to
   * read any available inputs. After running the complete execution, it calls transferOutputs().
   * The subclass of this can set the <i>_isSubclassOfExecuteCompositeActor</i> to be true to call
   * the fire method of the superclass of this.
   *
   * @exception IllegalActionException If there is no director, or if the director's action methods
   *     throw it.
   */
  public void fire() throws IllegalActionException {
    super.fire();
    if (_debugging) {
      _debug("---- calling fire(), which will execute a subsystem.");
    }

    _executeInsideModel();
  }
  /**
   * Override the base class to set type constraints between the output ports and parameters of this
   * actor whose name matches the output port. If there is no such parameter, then create an
   * instance of Variable with a matching name and set up the type constraints to that instance. The
   * type of the output port is constrained to be at least that of the parameter or variable.
   *
   * @exception IllegalActionException If there is no director, or if the director's preinitialize()
   *     method throws it, or if this actor is not opaque.
   */
  public void preinitialize() throws IllegalActionException {
    super.preinitialize();

    Iterator ports = outputPortList().iterator();

    while (ports.hasNext()) {
      TypedIOPort port = (TypedIOPort) ports.next();

      // Ensure that the production rate is one.
      // FIXME: This may not be right if there is no
      // actual source of data for this port (e.g. no
      // SetVariable actor).
      Variable rate = (Variable) port.getAttribute("tokenProductionRate");

      if (rate == null) {
        try {
          rate = new Variable(port, "tokenProductionRate");
        } catch (NameDuplicationException e) {
          throw new InternalErrorException(e);
        }
      }

      rate.setToken(new IntToken(1));

      String portName = port.getName();
      Attribute attribute = getAttribute(portName);

      if (attribute == null) {
        try {
          workspace().getWriteAccess();
          attribute = new Variable(this, portName);
        } catch (NameDuplicationException ex) {
          throw new InternalErrorException(ex);
        } finally {
          workspace().doneWriting();
        }
      }

      // attribute is now assured to be non-null.
      if (attribute instanceof Variable) {
        port.setTypeAtLeast((Variable) attribute);
      } else {
        // Assume the port type must be a string.
        port.setTypeEquals(BaseType.STRING);
      }
    }
  }
  /**
   * Creates a new Panel according to the mimeType. It is called by the Plugin when NPP_SetWindow is
   * called.
   *
   * @param isBeans Is JavaBeans
   * @param k Array of param names.
   * @param v Array of param values.
   * @param instance Plugin instance.
   * @return New Java Plugin object.
   */
  public static MNetscapePluginObject createPluginObject(
      boolean isBeans, String[] k, String[] v, int instance) {
    MNetscapePluginObject p =
        new MNetscapePluginObject(instance, isBeans, LifeCycleManager.getIdentifier(k, v));

    // Put all elements in the parameter list
    for (int i = 0; i < k.length; i++) {
      if (k[i] != null && !PLUGIN_UNIQUE_ID.equals(k[i])) p.setParameter(k[i], v[i]);
    }

    /*
     * Set background/foreground and progress bar color for the applet viewer.
     * Do it here - after passing all HTML params to applet viewer.
     */
    p.setBoxColors();

    return p;
  }