示例#1
0
  private void destroyWorld() {
    if (simStarted) {
      simStarted = false;

      // reset safety thread
      safety.interrupt();

      // destroy elevator system
      controller.interrupt();
      controller.destroy();

      // stop random events
      randomEventGen.interrupt();

      // reset logs
      Log.printStatusReport();
      Log.cleanLogs();

      // reset MsgBox
      deleteAllMsgs();

      // reset tabs, passenger table
      for (int i = ElevatorPane.getTabCount() - 1; i > 0; i--) ElevatorPane.remove(i);
      elevatorTabs = null;
      floorDropDownList.removeAllItems();
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              passengerTable.setModel(new PassengerTableModel());
              FloorPassengerTable.setModel(new PassengerTableModel());
            }
          });

      // clean up simulation view
      view.cleanup();
      view.restart();

      // reset timer
      simTimeLabel.setText("00:00:00");

      // recreate objects
      controller = new Controller();
      safety = new Safety(controller);
      try {
        randomEventGen = new RandomEventGenerator(controller, safety, 0.0f, 0.0f, 0.0f);
      } catch (ProbabilityOutofBoundsException e) {
        displayError(e.getMessage());
      }
    }
  }
示例#2
0
 protected void file_quitActionPerformed(ActionEvent evt) {
   view.cleanup();
   Log.printStatusReport();
   System.exit(0);
 }