package eu.oschl.gui;

import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.scene.text.TextFlow;

public class Output {
    private static TextFlow outputElement;

    public static void setOutputElement(TextFlow outputElement) {
        Output.outputElement = outputElement;
    }

    /**
     * Prints a message to the output with the specified JavaFX color.
     *
     * @param message the message to print
     * @param color the color in which to print the message
     */
    public static void print(String message, Color color) {
        var text = new Text(message);
        text.setFill(color);
        outputElement.getChildren().add(text);
    }

    /**
     * Prints a message to the output in the default color.
     *
     * @param message the message to print
     */
    public static void print(String message) {
        print(message, Color.WHITE);
    }

    /**
     * Prints a line break to the console.
     */
    public static void printLine() {
        print("\n");
    }

    /**
     * Clears the output element.
     */
    public static void clear() {
        outputElement.getChildren().clear();
    }
}
