<commit_before>package de.christianscheb.partyprojector.controller;

import de.christianscheb.partyprojector.model.*;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

import java.io.IOException;

public class MainController implements SettingsEventListener {
    private final Settings settings;
    private final MessageStorage messageStorage;
    private final PictureStorage pictureStorage;
    private SettingsController settingsController;
    private ProjectorController projectorController;
    private Stage projectorStage;

    public MainController(SettingsModel settingsModel, MessageStorage messageStorage, PictureStorage pictureStorage) {
        settings = settingsModel.getSettings();
        this.messageStorage = messageStorage;
        this.pictureStorage = pictureStorage;
        settingsController = new SettingsController(settingsModel.getSettings());
        settingsController.addEventListener(this);
    }

    public SettingsController getSettingsController() {
        return settingsController;
    }

    @Override
    public void onToggleProjector(boolean projectorActive) {
        if (projectorStage != null) {
            closeProjectorWindow();
        }
        if (projectorActive) {
            showProjectorWindow();
        }
    }

    private void showProjectorWindow() {
        Stage projectorStage = new Stage();
        projectorStage.initStyle(StageStyle.TRANSPARENT);

        FXMLLoader loader = new FXMLLoader(getClass().getResource("/Projector.fxml"));
        projectorController = new ProjectorController(settings, messageStorage, pictureStorage);
        loader.setController(projectorController);
        Parent root;
        try {
            root = loader.load();
        } catch (IOException e) {
            e.printStackTrace();
            return;
        }

        Scene scene = new Scene(root, 300, 250);
        scene.setFill(new Color(1, 0, 0, 0.2));
        this.projectorStage = projectorStage;
        this.projectorStage.setScene(scene);
        this.projectorStage.setResizable(false);
        this.projectorStage.setAlwaysOnTop(true);
        updateProjectorSettings(settings.getProjectorSettings());
        this.projectorStage.setTitle("Projector");
        this.projectorStage.getIcons().add(new Image(getClass().getResourceAsStream("/application.png")));
        this.projectorStage.show();
        projectorController.start();
    }

    private void updateProjectorSettings(ProjectorSettings projectorSettings) {
        projectorStage.setWidth(projectorSettings.getWidth());
        projectorStage.setHeight(projectorSettings.getHeight());
        projectorStage.setX(projectorSettings.getPosX());
        projectorStage.setY(projectorSettings.getPosY());
    }<commit_msg>Use constant<commit_after>package de.christianscheb.partyprojector.controller;

import de.christianscheb.partyprojector.PartyProjector;
import de.christianscheb.partyprojector.model.*;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

import java.io.IOException;

public class MainController implements SettingsEventListener {
    private final Settings settings;
    private final MessageStorage messageStorage;
    private final PictureStorage pictureStorage;
    private SettingsController settingsController;
    private ProjectorController projectorController;
    private Stage projectorStage;

    public MainController(SettingsModel settingsModel, MessageStorage messageStorage, PictureStorage pictureStorage) {
        settings = settingsModel.getSettings();
        this.messageStorage = messageStorage;
        this.pictureStorage = pictureStorage;
        settingsController = new SettingsController(settingsModel.getSettings());
        settingsController.addEventListener(this);
    }

    public SettingsController getSettingsController() {
        return settingsController;
    }

    @Override
    public void onToggleProjector(boolean projectorActive) {
        if (projectorStage != null) {
            closeProjectorWindow();
        }
        if (projectorActive) {
            showProjectorWindow();
        }
    }

    private void showProjectorWindow() {
        Stage projectorStage = new Stage();
        projectorStage.initStyle(StageStyle.TRANSPARENT);

        FXMLLoader loader = new FXMLLoader(getClass().getResource("/Projector.fxml"));
        projectorController = new ProjectorController(settings, messageStorage, pictureStorage);
        loader.setController(projectorController);
        Parent root;
        try {
            root = loader.load();
        } catch (IOException e) {
            e.printStackTrace();
            return;
        }

        Scene scene = new Scene(root, 300, 250);
        scene.setFill(new Color(1, 0, 0, 0.2));
        this.projectorStage = projectorStage;
        this.projectorStage.setScene(scene);
        this.projectorStage.setResizable(false);
        this.projectorStage.setAlwaysOnTop(true);
        updateProjectorSettings(settings.getProjectorSettings());
        this.projectorStage.setTitle("Projector");
        this.projectorStage.getIcons().add(new Image(getClass().getResourceAsStream(PartyProjector.APPLICATION_ICON)));
        this.projectorStage.show();
        projectorController.start();
    }

    private void updateProjectorSettings(ProjectorSettings projectorSettings) {
        projectorStage.setWidth(projectorSettings.getWidth());
        projectorStage.setHeight(projectorSettings.getHeight());
        projectorStage.setX(projectorSettings.getPosX());
        projectorStage.setY(projectorSettings.getPosY());
    }
{'fraction_non_alphanumeric': 0.08839497794367153, 'fraction_numerical': 0.0037326094333220224, 'mean_word_length': 3.55564142194745, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2279684', 'n_tokens_mistral': 1511, 'n_tokens_neox': 1468, 'n_words': 279}