<commit_before>package gui;

import java.util.ArrayList;
import javafx.geometry.Bounds;
import javafx.geometry.Insets;
import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.RowConstraints;
import lombok.Getter;


/**
 * Created by Bart.
 */
public class TimelinesGridPane extends GridPane {

    // The number of timelines in this custom gridpane
    @Getter
    private int numberOfTimelines;

    // The number of counts in this custom gridpane
    @Getter
    private int numberOfCounts;

    private ArrayList<SnappingPane> panes;

    // Height and width of count and timelines. Note that timelineWidth is a minimum.
    @Getter
    private double countHeight = 10;
    @Getter
    private double timelineWidth = 100;
    @Getter
    private int gridLineSkips = 4;

    /**
     * Constructor.
     * @param numberOfTimelines - The number of timelines in this gridpane
     * @param numberOfCounts - The number of counts in this gridpane
     * @param width - The width of this gridpane
     * @param height - the height of this gridpane
     * @param offsetFromLeft - how much offset from the left due to coverage by directortimeline.
     */
    public TimelinesGridPane(int numberOfTimelines, int numberOfCounts,
                             double width, double height, int offsetFromLeft) {
        this.numberOfTimelines = numberOfTimelines;
        this.numberOfCounts = numberOfCounts;
        this.panes = new ArrayList<>();
        this.setMinWidth(width);
        this.setMinHeight(countHeight * numberOfCounts);
        this.setMaxHeight(countHeight * numberOfCounts);

        addPanes();

        this.setGridLinesVisible(false);
        // offset to the left
        this.setPadding(new Insets(0, 0, 0, offsetFromLeft));

        // set constraints, with minimum size 100x100, and maximum size infinite.
        for (int i = 0; i < numberOfTimelines; i++) {
            ColumnConstraints rc = new ColumnConstraints();
            rc.setMinWidth(100.0);
            rc.setPercentWidth(100.0 / numberOfTimelines);
            rc.setHgrow(Priority.ALWAYS);
            this.getColumnConstraints().add(rc);
        }
        for (int i = 0; i < numberOfCounts; i++) {
            RowConstraints rc = new RowConstraints();
            rc.setMinHeight(100.0);
            rc.setPercentHeight(100.0 / numberOfCounts);
            rc.setVgrow(Priority.ALWAYS);
            this.getRowConstraints().add(rc);
        }
    }

    /**
     * Add a camerashotblock to this gridpane.
     * @param block - the block to add
     */
    public void addCameraShotBlock(CameraShotBlock block) {
        this.add(block.getTimetableBlock(), block.getTimetableNumber(),
                (int) Math.round(block.getBeginCount()), 1,
                (int) Math.round(block.getEndCount() - block.getBeginCount()));
    }

    /**
     * Remove a CameraShotBlock from this gridpane.
     * @param block the block to remove
     */
    public void removeCameraShotBlock(CameraShotBlock block) {
        this.getChildren().remove(block.getTimetableBlock());
    }

    /**
     * Add snapping panes to grid.
     */
    private void addPanes() {
        panes = new ArrayList<>();
        int c;
        for (int i = 0; i < numberOfTimelines; i++) {
            c = 1;
            for (int j = 0; j < numberOfCounts; j++) {
                SnappingPane pane = new SnappingPane(j, i, 200, countHeight);
                this.add(pane, i, j);
                panes.add(pane);
                if (c > gridLineSkips) {
                    pane.getStyleClass().add("timeline_Background_Lines");
                    c = 2;
                } else {
                    pane.getStyleClass().add("timeline_Background_Empty");
                    c++;
                }
            }
        }
    }

    /**
     * Get the pane in which the scene coordinates lie.
     * @param x - the x coordinate<commit_msg>Added some extra comments<commit_after>package gui;

import java.util.ArrayList;
import javafx.geometry.Bounds;
import javafx.geometry.Insets;
import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.RowConstraints;
import lombok.Getter;


/**
 * Created by Bart.
 */
public class TimelinesGridPane extends GridPane {

    // The number of timelines in this custom gridpane
    @Getter
    private int numberOfTimelines;

    // The number of counts in this custom gridpane
    @Getter
    private int numberOfCounts;

    private ArrayList<SnappingPane> panes;

    // Height and width of count and timelines. Note that timelineWidth is a minimum.
    @Getter
    private double countHeight = 10;
    @Getter
    private double timelineWidth = 100;
    @Getter
    private int gridLineSkips = 4;

    /**
     * Constructor.
     * @param numberOfTimelines - The number of timelines in this gridpane
     * @param numberOfCounts - The number of counts in this gridpane
     * @param width - The width of this gridpane
     * @param height - the height of this gridpane
     * @param offsetFromLeft - how much offset from the left due to coverage by directortimeline.
     */
    public TimelinesGridPane(int numberOfTimelines, int numberOfCounts,
                             double width, double height, int offsetFromLeft) {
        this.numberOfTimelines = numberOfTimelines;
        this.numberOfCounts = numberOfCounts;
        this.panes = new ArrayList<>();
        this.setMinWidth(width);
        this.setMinHeight(countHeight * numberOfCounts);
        this.setMaxHeight(countHeight * numberOfCounts);

        addPanes();

        this.setGridLinesVisible(false);
        // offset to the left
        this.setPadding(new Insets(0, 0, 0, offsetFromLeft));

        // set constraints, with minimum size 100x100, and maximum size infinite.
        for (int i = 0; i < numberOfTimelines; i++) {
            ColumnConstraints rc = new ColumnConstraints();
            rc.setMinWidth(100.0);
            rc.setPercentWidth(100.0 / numberOfTimelines);
            rc.setHgrow(Priority.ALWAYS);
            this.getColumnConstraints().add(rc);
        }
        for (int i = 0; i < numberOfCounts; i++) {
            RowConstraints rc = new RowConstraints();
            rc.setMinHeight(100.0);
            rc.setPercentHeight(100.0 / numberOfCounts);
            rc.setVgrow(Priority.ALWAYS);
            this.getRowConstraints().add(rc);
        }
    }

    /**
     * Add a camerashotblock to this gridpane.
     * @param block - the block to add
     */
    public void addCameraShotBlock(CameraShotBlock block) {
        this.add(block.getTimetableBlock(), block.getTimetableNumber(),
                (int) Math.round(block.getBeginCount()), 1,
                (int) Math.round(block.getEndCount() - block.getBeginCount()));
    }

    /**
     * Remove a CameraShotBlock from this gridpane.
     * @param block the block to remove
     */
    public void removeCameraShotBlock(CameraShotBlock block) {
        this.getChildren().remove(block.getTimetableBlock());
    }

    /**
     * Add snapping panes to grid. Also apply line separators to grid, once every few skips.
     */
    private void addPanes() {
        panes = new ArrayList<>();
        int c;
        for (int i = 0; i < numberOfTimelines; i++) {
            c = 1;
            for (int j = 0; j < numberOfCounts; j++) {
                SnappingPane pane = new SnappingPane(j, i, 200, countHeight);
                this.add(pane, i, j);
                panes.add(pane);
                if (c > gridLineSkips) {
                    pane.getStyleClass().add("timeline_Background_Lines");
                    c = 2;
                } else {
                    pane.getStyleClass().add("timeline_Background_Empty");
                    c++;
                }
            }
        }
    }

    /**
     * Get the pane in which the scene coordinates lie.
     * @param x - the x coordinate
{'fraction_non_alphanumeric': 0.09577114427860696, 'fraction_numerical': 0.010199004975124378, 'mean_word_length': 2.166994879873966, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 11, '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': '1775251', 'n_tokens_mistral': 2362, 'n_tokens_neox': 2241, 'n_words': 626}