public void saveToFile(String filename, boolean append) {
    try {
      PrintStream out = new PrintStream(new FileOutputStream(filename, append));

      out.println(DateFormat.getDateTimeInstance().format(new Date()));

      out.println(getTitle());

      for (int col = 0; col < getColumnCount(); col++) {
        if (col > 0) {
          out.print(',');
        }
        out.print(getColumnName(col));
      }

      out.println();

      for (int row = 0; row < getRowCount(); row++) {
        for (int col = 0; col < getColumnCount(); col++) {
          if (col > 0) {
            out.print(',');
          }
          out.print(getValueAt(row, col));
        }
        out.println();
      }

      out.println("$");

      out.close();

    } catch (IOException e) {
      Logger.logError(e);
    }
  }
Esempio n. 2
0
  public JPanel initialize(String selected_robots) {
    try {
      manager = new RobocodeManager(false, null);

      Thread.currentThread().setName("Application Thread");

      BattleProperties battleProperties = manager.getBattleManager().getBattleProperties();
      // battleProperties.setSelectedRobots("test.mtest12,test.mtest14");
      battleProperties.setSelectedRobots(selected_robots);
      manager.getBattleManager().startNewBattle(battleProperties, true, false);
      manager.getBattleManager().getBattle().setDesiredTPS(20);

      JPanel panel = manager.getWindowManager().getRobocodeFrame().getRobocodeContentPane();
      panel.setBounds(100, 100, 500, 600);
      panel.setOpaque(true);
      return panel;
    } catch (Throwable e) {
      Logger.log(e);
      return null;
    }
  }