<commit_before>package nl.tudelft.lifetiles.core.controller;

import java.net.URL;
import java.util.ResourceBundle;

import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.stage.Stage;
import javafx.stage.Window;
import nl.tudelft.lifetiles.core.util.Message;

/**
 * The controller of the window controls.
 *
 * @author <NAME>
 *
 */
public class WindowControlController extends AbstractController {

    /**
     * The minimize window shout message.
     */
    public static final Message MINIMIZE = Message.create("minimize");

    /**
     * The resize window shout message.
     */
    public static final Message RESIZE = Message.create("resize");

    /**
     * The window close button.
     */
    @FXML
    private Button windowClose;

    /**
     * The window minimize button.
     */
    @FXML
    private Button windowMinimize;

    /**
     * The window resize button.
     */
    @FXML
    private Button windowResize;

    /**
     * Close the window.
     */
    @FXML
    private void closeWindowAction() {
        Window window = windowClose.getScene().getWindow();
        if (window instanceof Stage) {
            Stage stage = (Stage) window;
            stage.close();
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public final void initialize(final URL location,
            final ResourceBundle resources) {
        // noop
    }

    /**
     * Minimize the window.
     */
    @FXML
    public final void minimizeWindowAction() {
        Window window = windowMinimize.getScene().getWindow();
        if (window instanceof Stage) {
            Stage stage = (Stage) window;
            stage.toBack();
        }

        shout(MINIMIZE);
    }

    /**
     * Resize the window.
     */
    @FXML
    private void resizeWindowAction() {
        Window window = windowResize.getScene().getWindow();
        if (window instanceof Stage) {
            Stage stage = (Stage) window;
            stage.setMaximized(!stage.isMaximized());
        }

        shout(RESIZE);
    }
}<commit_msg>Seperate casting of Window to Stage into private method.<commit_after>package nl.tudelft.lifetiles.core.controller;

import java.net.URL;
import java.util.ResourceBundle;

import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.stage.Stage;
import javafx.stage.Window;
import nl.tudelft.lifetiles.core.util.Message;

/**
 * The controller of the window controls.
 *
 * @author <NAME>
 *
 */
public class WindowControlController extends AbstractController {

    /**
     * The minimize window shout message.
     */
    public static final Message MINIMIZE = Message.create("minimize");

    /**
     * The resize window shout message.
     */
    public static final Message RESIZE = Message.create("resize");

    /**
     * The window close button.
     */
    @FXML
    private Button windowClose;

    /**
     * The window minimize button.
     */
    @FXML
    private Button windowMinimize;

    /**
     * The window resize button.
     */
    @FXML
    private Button windowResize;

    /**
     * Close the window.
     */
    @FXML
    private void closeWindowAction() {
        getStage(windowClose.getScene().getWindow()).close();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public final void initialize(final URL location,
            final ResourceBundle resources) {
        // noop
    }

    /**
     * Minimize the window.
     */
    @FXML
    public final void minimizeWindowAction() {
        getStage(windowMinimize.getScene().getWindow()).toBack();
        shout(MINIMIZE);
    }

    /**
     * @param window
     *            The window to cast.
     * @return The old Window as a Stage.
     */
    private Stage getStage(final Window window) {
        if (window instanceof Stage) {
            return (Stage) window;
        } else {
            throw new IllegalStateException("The window was not a Stage");
        }
    }

    /**
     * Resize the window.
     */
    @FXML
    private void resizeWindowAction() {
        Stage stage = getStage(windowResize.getScene().getWindow());
        stage.setMaximized(!stage.isMaximized());
        shout(RESIZE);
    }
}
{'fraction_non_alphanumeric': 0.10986653956148713, 'fraction_numerical': 0.0, 'mean_word_length': 2.122767857142857, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '6821377', 'n_tokens_mistral': 1209, 'n_tokens_neox': 1177, 'n_words': 306}