Пример #1
0
  private void setupCutoffTimers() {
    Logger cutoffLogger = sessionLogger();
    Random random = new Random();
    int cutoffIfSimultaneous = (int) (random.nextDouble() * (latestCutoff - earliestCutoff));
    if (simultaneousCutoff) {
      cutoffLogger.info("using a simultaneous cutoff of " + cutoffIfSimultaneous + " seconds.");
    }
    Iterator<String> nameIterator = playerNameIterator();
    while (nameIterator.hasNext()) {
      Judge judge = getJudgeOrNull(nameIterator.next());
      if (judge == null) {
        continue;
      }

      int cutoff;
      if (simultaneousCutoff) {
        cutoff = cutoffIfSimultaneous;
      } else {
        cutoff = earliestCutoff + (int) (random.nextDouble() * (latestCutoff - earliestCutoff));
        cutoffLogger.info(
            "using a cutoff for judge '" + judge.getName() + "' of " + cutoff + " seconds.");
        int roundDuration = timeLimit();
        if (cutoff > roundDuration + 10) {
          cutoff = roundDuration + 10;
          cutoffLogger.info(
              "reducing timeout to " + cutoff + " (10 seconds after round finishes).");
        }
      }
      TimerTask task = judge.getCutoffTimer();
      timer.schedule(task, 1000 * cutoff);
    }
  }
Пример #2
0
  // --------------------------------------------------------------------------
  // Constructor. If judge is null, it's to create a new judge.
  // --------------------------------------------------------------------------
  CreateJudgeScreen(JudgesPanel panel, Tournament t, Judge j) {
    jp = panel;
    tournament = t;
    judge = j;

    ScSS = new SchoolStrikesScreen(judge, tournament, this);
    StSS = new StudentStrikesScreen(judge, tournament, this);

    gbc = new GridBagConstraints();

    JLabel nameLabel = new JLabel("Last name:");
    nameField = new JTextField();
    nameField.setColumns(15);

    if (judge != null) nameField.setText(judge.getName());

    JLabel priorityLabel = new JLabel("Default priority:");
    priorityBox = new JComboBox(Priority.PriorityLevel.values());

    if (judge == null) priorityBox.setSelectedItem(Priority.PriorityLevel.Normal);
    else priorityBox.setSelectedItem(judge.getDefaultPriority());

    JButton schoolStrikes = new JButton("School strikes:");
    schoolStrikes.addActionListener(new SchoolStrikesListener());
    schoolStrikesLabel = new JLabel();
    resetSchoolStrikesLabel();

    JButton studentStrikes = new JButton("Student strikes:");
    studentStrikes.addActionListener(new StudentStrikesListener());
    studentStrikesLabel = new JLabel();
    resetStudentStrikesLabel();

    topPanel = new JPanel();
    topPanel.setLayout(new GridLayout(4, 2));

    topPanel.add(nameLabel);
    topPanel.add(nameField);
    topPanel.add(priorityLabel);
    topPanel.add(priorityBox);
    topPanel.add(schoolStrikes);
    topPanel.add(schoolStrikesLabel);
    topPanel.add(studentStrikes);
    topPanel.add(studentStrikesLabel);

    saveButton = new JButton("Save");
    saveButton.addActionListener(new SaveListener());
    cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(new CancelListener());
    deleteButton = new JButton("Delete");
    deleteButton.addActionListener(new DeleteListener());

    bottomPanel = new JPanel();
    bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.X_AXIS));

    bottomPanel.add(saveButton);
    bottomPanel.add(cancelButton);
    bottomPanel.add(deleteButton);

    mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanel.add(topPanel);
    mainPanel.add(bottomPanel);

    scrollPane = new JScrollPane(mainPanel);
    add(scrollPane);
  }