<commit_before>package gui;

import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.EventHandler;
import javafx.geometry.*;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.control.Label;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.*;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Text;
import lombok.Getter;
import org.w3c.dom.css.Rect;

/**
 * Class that resembles a draggable, resiable block inside the timetable.
 * Highly volatile. Do not poke too much.
 */
public class TimetableBlock extends Region {

    public enum DraggingTypes { Move, Resize_Top, Resize_Right, Resize_Bottom, Resize_Left }

    /*
        Styling variables.
        For styling and displayable content.
     */

    private String normalStyle;
    private String dragStyle;

    private String title = "dummyTitle with some extension";

    /*
        Misc variables.
        For dragging, interaction, etc.
     */

    private TimetableBlock thisBlock;
    private Pane dummyPane;
    private Pane feedbackPane;

    private double dragXOffset;
    private double dragYOffset;

    private RootCenterArea pane;
    private boolean dragging;
    private DraggingTypes draggingType;
    private double margin;

    private double mouseCurrentXPosition;
    private double mouseCurrentYPosition;
    private double mouseCurrentXMovement;
    private double mouseCurrentYMovement;

    private Point2D scrollMouse;

    @Getter
    private ShotBlock parentBlock;

    private double startingY;

    /**
     * Constructor for TimetableBlock class.
     * @param pane - the parent pane.
     * @param parent - the parent node
     */
    TimetableBlock(RootCenterArea pane, ShotBlock parent) {
        this.dragging = false;
        this.thisBlock = this;
        this.parentBlock = parent;

        feedbackPane = new Pane();
        //feedbackPane.setPrefHeight(100);
        //feedbackPane.setPrefWidth(200);
        feedbackPane.setStyle("-fx-background-color: red");
        feedbackPane.setVisible(false);

        dummyPane = new Pane();
        dummyPane.setPrefHeight(100);
        dummyPane.setPrefWidth(200);
        dummyPane.setStyle("-fx-background-color: green");
        dummyPane.setVisible(false);

        pane.getParentPane().getChildren().add(dummyPane);
        pane.getGrid().add(feedbackPane, 0, 0);

        this.normalStyle = "-fx-border-style: solid inside;"
                + "-fx-border-width: 3;"
                + "-fx-border-color: yellow;"
                + "-fx-background-color: orange;";
        this.dragStyle = "-fx-border-style: solid inside;"
                + "-fx-border-width: 3;"
                + "-fx-border-color: red;"
                + "-fx-background-color: orange;";

        this.pane = pane;
        setStyle(normalStyle);

        VBox contentPane = new VBox(); // content pane for our block.
        Rectangle clipRegion = new Rectangle(); // clip region to restrict content from exiting content pane.
        clipRegion.widthProperty().bind(widthProperty());
        clipRegion.heightProperty().bind(heightProperty());
        contentPane.setClip(clipRegion);
        getChildren().add(contentPane);

        VBox dummyContentPane = new VBox(); // content pane for dummy block
        Rectangle dummyClipRegion = new Rectangle();// clip region to restrict content from exiting dummy pane.
        dummyClipRegion.widthProperty().bind(dummyPane.widthProperty());
        dummyClipRegion.heightProperty().bind(dummyPane.heightProperty());
        dummyContentPane.setClip(dummyClipRegion);
        dummyPane.getChildren().add(dummyContentPane);

        // test labels, please ignore.
        for (int i = 0; i < 6; i++) {
            Label label = new Label(title);
            label.setPrefWidth(pane.getGrid().getTimelineWidth());
            label.setPadding(new Insets(5,5,5,5));
            contentPane.getChildren().add(label);
        }
        for (int i = 0; i < 6; i++) {
            Label label = new Label(title);
            label.setPrefWidth(pane.getGrid().getTimelineWidth());
            label.setPadding(new Insets(5,5,5,5));
            dummyContentPane.getChildren().add(label);
        }

        this.margin = 15;

        // mouse event handlers
        setOnMousePressed(getOnPressedHandler());
        setOnMouseDragged(getOnDraggedHandler());
        setOnMouseReleased(getOnreleaseHandler());
    }

    /**
     * Event handler for on mouse pressed.
     * @return - the eventhandler
     */
    private EventHandler<MouseEvent> getOnPressedHandler() {<commit_msg>Fixed remaining checkstyle errors.<commit_after>package gui;

import javafx.event.EventHandler;
import javafx.geometry.Bounds;
import javafx.geometry.Insets;
import javafx.geometry.Point2D;
import javafx.scene.Parent;
import javafx.scene.control.Label;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
import javafx.scene.shape.Rectangle;
import lombok.Getter;

/**
 * Class that resembles a draggable, resiable block inside the timetable.
 * Highly volatile. Do not poke too much.
 */
public class TimetableBlock extends Pane {

    public enum DraggingTypes { Move, Resize_Top, Resize_Right, Resize_Bottom, Resize_Left }

    /*
        Styling variables.
        For styling and displayable content.
     */

    private String normalStyle = "-fx-border-style: solid inside;"
            + "-fx-border-width: 3;"
            + "-fx-border-color: yellow;"
            + "-fx-background-color: orange;";
    private String dragStyle = "-fx-border-style: solid inside;"
            + "-fx-border-width: 3;"
            + "-fx-border-color: red;"
            + "-fx-background-color: orange;";

    private String title = "dummyTitle with some extension";

    /*
        Misc variables.
        For dragging, interaction, etc.
     */

    private TimetableBlock thisBlock;
    private Pane dummyPane;
    private Pane feedbackPane;

    private VBox contentPane;
    private VBox dummyContentPane;

    private double dragXOffset;
    private double dragYOffset;

    private RootCenterArea pane;
    private boolean dragging;
    private DraggingTypes draggingType;
    private double margin;

    private double mouseCurrentXPosition;
    private double mouseCurrentYPosition;
    private double mouseCurrentXMovement;
    private double mouseCurrentYMovement;

    private Point2D scrollMouse;

    @Getter
    private ShotBlock parentBlock;

    private double startingY;

    /**
     * Constructor for TimetableBlock class.
     * @param pane - the parent pane.
     * @param parent - the parent node
     */
    TimetableBlock(RootCenterArea pane, ShotBlock parent) {
        this.dragging = false;
        this.thisBlock = this;
        this.parentBlock = parent;

        feedbackPane = new Pane();
        feedbackPane.setStyle("-fx-background-color: red");
        feedbackPane.setVisible(false);

        dummyPane = new Pane();
        dummyPane.setStyle("-fx-background-color: green");
        dummyPane.setVisible(false);

        pane.getParentPane().getChildren().add(dummyPane);
        pane.getGrid().add(feedbackPane, 0, 0);

        this.pane = pane;
        setStyle(normalStyle);

        // content pane for our pane, and our dummy pane
        contentPane = new VBox();
        addClipRegion(contentPane, this);
        dummyContentPane = new VBox();
        addClipRegion(dummyContentPane, dummyPane);

        // test labels, please ignore.
        addTestLabels(contentPane);
        addTestLabels((dummyContentPane));

        this.margin = 15;

        // mouse event handlers
        setOnMousePressed(getOnPressedHandler());
        setOnMouseDragged(getOnDraggedHandler());
        setOnMouseReleased(getOnreleaseHandler());
    }

    /**
     * Add clip region to pane (pane0 and its content (vbox).
     * @param vbox the VBox in which content is located.
     * @param pane the Pane in which the vbox is located.
     */
    private void addClipRegion(VBox vbox, Pane pane) {
        Rectangle clipRegion = new Rectangle(); // clip region to restrict content
        clipRegion.widthProperty().bind(pane.widthProperty());
        clipRegion.heightProperty().bind(pane.heightProperty());
        vbox.setClip(clipRegion);
        pane.getChildren().add(vbox);
    }

    /**
     * Temporary helper function to add test labels to panes.
     * @param vbox pane to add to
     */
    private void addTestLabels(VBox vbox) {
        for (int i = 0; i < 6; i++) {
            Label label = new Label(title);
            label.setPrefWidth(pane.getGrid().getTimelineWidth());
            label.setPadding(new Insets(5,5,5,5));
            vbox.getChildren().add(label);
        }
    }

    /**
     * Event handler for on mouse pressed.
     * @return - the eventhandler
     */
    private EventHandler<MouseEvent> getOnPressedHandler() {
{'fraction_non_alphanumeric': 0.10260083755785762, 'fraction_numerical': 0.0051796341194621995, 'mean_word_length': 2.6860276198212834, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '7043116', 'n_tokens_mistral': 2603, 'n_tokens_neox': 2474, 'n_words': 638}