<commit_before>
/*
 * File: NameSurferGraph.java
 * ---------------------------
 * This class represents the canvas on which the graph of
 * names is drawn. This class is responsible for updating
 * (redrawing) the graphs whenever the list of entries changes or the window is resized.
 */

import javafx.scene.layout.Pane;
import javafx.scene.shape.Line;

public class NameSurferGraph extends Pane implements NameSurferConstants {
    public NameSurferGraph() {
        super();

        setWhiteBackground();
        drawDecadeLines();
    }

    private void setWhiteBackground() {
        this.setStyle("-fx-background-color: white");
    }

    private void drawDecadeLines() {
        for (int i = 0; i < NDECADES; i++) {
            drawVerticalLine(i);
        }
    }

    private void drawVerticalLine(int decadeIndex) {
        Line line = new Line();
        line.setStartY(0);
        line.endYProperty().bind(heightProperty());
        line.startXProperty().bind(widthProperty().divide(NDECADES).multiply(decadeIndex));
        line.endXProperty().bind(line.startXProperty());

        this.getChildren().add(line);
    }<commit_msg>Implement assignment 6 milestone 4<commit_after>
/*
 * File: NameSurferGraph.java
 * ---------------------------
 * This class represents the canvas on which the graph of
 * names is drawn. This class is responsible for updating
 * (redrawing) the graphs whenever the list of entries changes or the window is resized.
 */

import javafx.scene.control.Label;
import javafx.scene.layout.Pane;
import javafx.scene.shape.Line;

public class NameSurferGraph extends Pane implements NameSurferConstants {
    private static final int LABEL_PADDING = 2;

    public NameSurferGraph() {
        super();

        setWhiteBackground();
        drawVerticalGridLines();
        drawHorizontalGridLines();
        drawDecadeLabels();
    }

    private void setWhiteBackground() {
        this.setStyle("-fx-background-color: white");
    }

    private void drawVerticalGridLines() {
        for (int i = 0; i < NDECADES; i++) {
            drawVerticalLine(i);
        }
    }

    private void drawVerticalLine(int decadeIndex) {
        Line line = new Line();
        line.startXProperty().bind(widthProperty().divide(NDECADES).multiply(decadeIndex));
        line.endXProperty().bind(line.startXProperty());
        line.setStartY(0);
        line.endYProperty().bind(heightProperty());

        this.getChildren().add(line);
    }

    private void drawHorizontalGridLines() {
        drawTopLine();
        drawBottomLine();
    }

    private void drawTopLine() {
        Line line = new Line();
        line.setStartX(0);
        line.endXProperty().bind(widthProperty());
        line.setStartY(GRAPH_MARGIN_SIZE);
        line.setEndY(GRAPH_MARGIN_SIZE);

        this.getChildren().add(line);
    }

    private void drawBottomLine() {
        Line line = new Line();
        line.setStartX(0);
        line.endXProperty().bind(widthProperty());
        line.startYProperty().bind(heightProperty().subtract(GRAPH_MARGIN_SIZE));
        line.endYProperty().bind(line.startYProperty());

        this.getChildren().add(line);
    }

    private void drawDecadeLabels() {
        for (int i = 0; i < NDECADES; i++) {
            drawDecadeLabel(i);
        }
    }

    private void drawDecadeLabel(int decadeIndex) {
        Label label = new Label(Integer.toString(START_DECADE + decadeIndex * 10));
        // TODO: can we remove duplication here?
        label.layoutXProperty().bind(widthProperty().divide(NDECADES).multiply(decadeIndex).add(LABEL_PADDING));
        label.layoutYProperty().bind(heightProperty().subtract(GRAPH_MARGIN_SIZE).add(LABEL_PADDING));

        this.getChildren().add(label);
    }
{'fraction_non_alphanumeric': 0.12882619110992813, 'fraction_numerical': 0.0031940377961139207, 'mean_word_length': 2.769307923771314, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 3, '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': '7384208', 'n_tokens_mistral': 1092, 'n_tokens_neox': 1050, 'n_words': 235}