<commit_before>/**
 * Copyright (C) 2014 <NAME> and <NAME>.
 */
package dk.itu.bookie.controller;

// General utilities
import java.awt.*;
import java.util.HashSet;
import java.util.Set;
import java.util.ResourceBundle;

// Net utilities
import java.net.URL;

// JavaFX layouts
import javafx.scene.layout.GridPane;

// JavaFX controls
import javafx.scene.control.Label;
import javafx.scene.control.TableView;
import javafx.scene.control.TableColumn;

// FXML utilities
import javafx.fxml.FXML;
import javafx.fxml.Initializable;

// Components
import dk.itu.bookie.component.Seat;

// Models
import dk.itu.bookie.model.Showtime;

/**
 * Showtime controller class.
 *
 * @version 1.0.0
 */
public class ShowtimeController implements Initializable {
  private static ShowtimeController instance;

  private char[] alphabet = new char[]{
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
    'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
  };

  @FXML
  private TableView<Showtime> showtimes;

  @FXML
  private TableColumn movieColumn;

  @FXML
  private TableColumn auditoriumColumn;

  @FXML
  private TableColumn dateColumn;

  @FXML
  private TableColumn timeColumn;

  @FXML
  private GridPane auditorium;

  public ShowtimeController getInstance() {
    return ShowtimeController.instance;
  }

  public void initialize(final URL url, final ResourceBundle resourceBundle) {
    ShowtimeController.instance = this;

    this.bindTableColumnWidths();

    int rows = 10;
    int seats = 15;

    Set<Seat> selectedSeats = new HashSet<>();

    for (int row = 1; row <= (rows + 1); row++) {
      for (int seat = 1; seat <= (seats + 1); seat++) {
        if ((row > 1) && (seat > 1) || (seat == row)) {
          continue;
        }

        String text;

        if (row == 1) {
          text = String.format("%s", seat - 1);
        }
        else {
          text = String.format("%s", this.alphabet[row - 2]);
        }

        Label label = new Label(text);

        this.auditorium.add(label, seat, row);
      }
    }

    for (int row = 2; row <= (rows + 1); row++) {
      for (int seat = 2; seat <= (seats + 1); seat++) {
        Seat auditoriumSeat = new Seat(row, seat);

	this.bindSeatWidth(auditoriumSeat);

        auditoriumSeat.getState().addListener((e, ov, nv) -> {
          if (nv) {
            selectedSeats.add(auditoriumSeat);
          }
          else {
            selectedSeats.remove(auditoriumSeat);
          }
        });

        this.auditorium.add(auditoriumSeat, seat, row);
      }
    }
  }

  public void bindTableColumnWidths() {
    this.movieColumn.prefWidthProperty().bind(
      this.showtimes.widthProperty().multiply(0.30)
    );

    this.auditoriumColumn.prefWidthProperty().bind(
      this.showtimes.widthProperty().multiply(0.30)
    );

    this.dateColumn.prefWidthProperty().bind(
      this.showtimes.widthProperty().multiply(0.20)
    );

    this.timeColumn.prefWidthProperty().bind(
      this.showtimes.widthProperty().multiply(0.20)
    );
  }

  public void bindSeatWidth(final Seat seat) {
    int rows = 10;
    int seats = 15;

    seat.widthProperty().bind(
      this.showtimes.widthProperty().divide(seats)
    );

    seat.heightProperty().bind(
      this.showtimes.widthProperty().divide(seats)
    );
  }
}<commit_msg>Fix grid pane cell alignment.<commit_after>/**
 * Copyright (C) 2014 <NAME> and <NAME>.
 */
package dk.itu.bookie.controller;

// General utilities
import java.awt.*;
import java.util.HashSet;
import java.util.Set;
import java.util.ResourceBundle;

// Net utilities
import java.net.URL;

// JavaFX layouts
import javafx.scene.layout.GridPane;

// JavaFX controls
import javafx.scene.control.Label;
import javafx.scene.control.TableView;
import javafx.scene.control.TableColumn;

// JavaFX geometry
import javafx.geometry.HPos;
import javafx.geometry.VPos;

// FXML utilities
import javafx.fxml.FXML;
import javafx.fxml.Initializable;

// Components
import dk.itu.bookie.component.Seat;

// Models
import dk.itu.bookie.model.Showtime;

/**
 * Showtime controller class.
 *
 * @version 1.0.0
 */
public class ShowtimeController implements Initializable {
  private static ShowtimeController instance;

  private char[] alphabet = new char[]{
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
    'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
  };

  @FXML
  private TableView<Showtime> showtimes;

  @FXML
  private TableColumn movieColumn;

  @FXML
  private TableColumn auditoriumColumn;

  @FXML
  private TableColumn dateColumn;

  @FXML
  private TableColumn timeColumn;

  @FXML
  private GridPane auditorium;

  public ShowtimeController getInstance() {
    return ShowtimeController.instance;
  }

  public void initialize(final URL url, final ResourceBundle resourceBundle) {
    ShowtimeController.instance = this;

    this.bindTableColumnWidths();

    int rows = 10;
    int seats = 15;

    Set<Seat> selectedSeats = new HashSet<>();

    for (int row = 1; row <= (rows + 1); row++) {
      for (int seat = 1; seat <= (seats + 1); seat++) {
        if ((row > 1) && (seat > 1) || (seat == row)) {
          continue;
        }

        String text;

        if (row == 1) {
          text = String.format("%s", seat - 1);
        }
        else {
          text = String.format("%s", this.alphabet[row - 2]);
        }

        Label label = new Label(text);

        this.auditorium.add(label, seat, row);

        // Center alignment the label within its column.
        this.auditorium.setHalignment(label, HPos.CENTER);
        this.auditorium.setValignment(label, VPos.CENTER);
      }
    }

    for (int row = 2; row <= (rows + 1); row++) {
      for (int seat = 2; seat <= (seats + 1); seat++) {
        Seat auditoriumSeat = new Seat(row, seat);

        this.bindSeatWidth(auditoriumSeat, seats);

        auditoriumSeat.getState().addListener((e, ov, nv) -> {
          if (nv) {
            selectedSeats.add(auditoriumSeat);
          }
          else {
            selectedSeats.remove(auditoriumSeat);
          }
        });

        this.auditorium.add(auditoriumSeat, seat, row);
      }
    }
  }

  public void bindTableColumnWidths() {
    this.movieColumn.prefWidthProperty().bind(
      this.showtimes.widthProperty().multiply(0.30)
    );

    this.auditoriumColumn.prefWidthProperty().bind(
      this.showtimes.widthProperty().multiply(0.30)
    );

    this.dateColumn.prefWidthProperty().bind(
      this.showtimes.widthProperty().multiply(0.20)
    );

    this.timeColumn.prefWidthProperty().bind(
      this.showtimes.widthProperty().multiply(0.20)
    );
  }

  public void bindSeatWidth(final Seat seat, final int seats) {
    seat.widthProperty().bind(
      this.showtimes.widthProperty().divide(seats)
    );

    seat.heightProperty().bind(
      this.showtimes.widthProperty().divide(seats)
    );
  }
}
{'fraction_non_alphanumeric': 0.1459748518572048, 'fraction_numerical': 0.010984246278363925, 'mean_word_length': 2.7445887445887447, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2013733', 'n_tokens_mistral': 2382, 'n_tokens_neox': 2248, 'n_words': 511}