<commit_before>package com.queen.counter.domain;

import javafx.animation.Animation;
import javafx.animation.TranslateTransition;
import javafx.beans.binding.When;
import javafx.beans.property.*;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import org.reactfx.EventSource;
import org.reactfx.EventStream;
import org.reactfx.EventStreams;
import org.reactfx.util.Tuple2;

import java.time.LocalTime;

public class Cell {

    private VBox rectangle;
    private Location location;
    private Text label;
    private TranslateTransition translateTransition;
    private BooleanProperty edgeTopRectangle = new SimpleBooleanProperty(false);
    private BooleanProperty hasTextRectangle = new SimpleBooleanProperty(false);
    private IntegerProperty currentDelta = new SimpleIntegerProperty(0);
    private EventSource deltaStream;

    public Cell(VBox rectangle, Location location, Text label, TranslateTransition translateTransition, EventSource<Tuple2<Integer, ColumnType>> deltaStream) {
        this.rectangle = rectangle;
        this.location = location;
        this.label = label;
        this.translateTransition = translateTransition;
        this.deltaStream = deltaStream;
        this.edgeTopRectangle.bind(new When(rectangle.translateYProperty().isEqualTo(0)).then(true).otherwise(false));
        this.hasTextRectangle.bind(new When(rectangle.translateYProperty().greaterThan(180).and(rectangle.translateYProperty().lessThan(240)).and(currentDelta.lessThan(0))).then(true).otherwise(
                new When(rectangle.translateYProperty().greaterThan(0).and(rectangle.translateYProperty().lessThan(60)).and(currentDelta.greaterThan(0))).then(true).otherwise(false)
        ));
        EventStream<Number> translateY = EventStreams.valuesOf(rectangle.translateYProperty());
        currentDelta.bind(deltaStream.map(Tuple2::get1).toBinding(0));

        EventStream<Tuple2<Tuple2<Integer, ColumnType>, Double>> combo = EventStreams.combine(
                this.deltaStream, translateY
        );

        combo.map(change -> {
            Integer currDelta = change.get1().get1();
            Double transY = change.get2();

            if (currDelta == 0 || currDelta < 0) {
                if (transY == 0) {
                    return 240;
                } else {
                    return transY;
                }
            } else {
                if (transY == 240) {
                    return 0;
                } else {
                    return transY;
                }
            }
        }).feedTo(translateTransition.fromYProperty());

        combo.map(change -> {
            Integer currDelta = change.get1().get1();
            Double transY = change.get2();

            if (currDelta == 0 || currDelta < 0) {
                if (transY == 0) {
                    return 180;
                } else {
                    return transY - 60;
                }
            } else {
                if (transY == 240) {
                    return 60;
                } else {
                    return transY + 60;
                }
            }
        }).feedTo(translateTransition.toYProperty());
    }


    public void animate() {
        translateTransition.play();
    }

    public BooleanProperty hasTopEdgeRectangle() {
        return this.edgeTopRectangle;
    }

    public BooleanProperty hasChangeTextRectangle() {
        return this.hasTextRectangle;
    }

    public void setLabel(String newLabel) {
        if (rectangle.getId().equals(label.getId())) {
            this.label.setText(newLabel);
        }
    }

    public void setLabel(boolean topEdgeExists, LocalTime clock, ColumnType columnType) {
        if (columnType.equals(ColumnType.SECONDS)) {
            if (topEdgeExists) {
                if (rectangle.translateYProperty().get() == 0) {
                    label.setText(Integer.toString(clock.plusSeconds(2).getSecond()));
                }

                if (rectangle.translateYProperty().get() == 60) {
                    label.setText(Integer.toString(clock.plusSeconds(1).getSecond()));
                }

                if (rectangle.translateYProperty().get() == 120) {
                    label.setText(Integer.toString(clock.getSecond()));
                }

                if (rectangle.translateYProperty().get() == 180) {
                    label.setText(Integer.toString(clock.minusSeconds(1).getSecond()));
                }
            }

            if (!topEdgeExists) {
                if (rectangle.translateYProperty().get() == 60) {
                    label.setText(Integer.toString(clock.plusSeconds(2).getSecond()));
                }

                if (rectangle.translateYProperty().get() == 120) {
                    label.setText(Integer.toString(clock.plusSeconds(1).getSecond()));
                }

                if (rectangle.translateYProperty().get() == 180) {
                    label.setText(Integer.toString(clock.getSecond()));
                }

                if (rectangle.translateYProperty().get() == 240) {
                    label.setText(Integer.toString(clock.minusSeconds(1).getSecond()));
                }
            }
        }

        if (columnType.equals(ColumnType.MINUTES)) {
            if (topEdgeExists) {
                if (rectangle.translateYProperty().get() == 0) {
                    label.setText(Integer.toString(clock.plusMinutes(2).getMinute()));
                }

                if (rectangle.translateYProperty().get() == 60) {
                    label.setText(Integer.toString(clock.plusMinutes(1).getMinute()));
                }

                if (rectangle.translateYProperty().get() == 120) {
                    label.setText(Integer.toString(clock.getMinute()));
                }

                if (rectangle.translateYProperty().get() == 180) {
                    label.setText(Integer.toString(clock.minusMinutes(1).getMinute()));
                }
            }

            if (!topEdgeExists) {
                if (rectangle.translateYProperty().get() == 60) {
                    label.setText(Integer.toString(clock.plusMinutes(2).getMinute()));
                }

                if (rectangle.translateYProperty().get() == 120) {
                    label.setText(Integer.toString(clock.plusMinutes(1).getMinute()));
                }

                if (rectangle.translateYProperty().get() == 180) {
                    label.setText(Integer.toString(clock.getMinute()));
                }

                if (rectangle.translateYProperty().get() == 240) {
                    label.setText(Integer.toString(clock.minusMinutes(1).getMinute()));
                }
            }
        }
    }

    public ReadOnlyObjectProperty<Animation.Status> isRunning() {
        return translateTransition.statusProperty();
    }

    public int getDelta() {<commit_msg>Fixed issue with hours column and labels not being set.<commit_after>package com.queen.counter.domain;

import javafx.animation.Animation;
import javafx.animation.TranslateTransition;
import javafx.beans.binding.When;
import javafx.beans.property.*;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import org.reactfx.EventSource;
import org.reactfx.EventStream;
import org.reactfx.EventStreams;
import org.reactfx.util.Tuple2;

import java.time.LocalTime;

public class Cell {

    private VBox rectangle;
    private Location location;
    private Text label;
    private TranslateTransition translateTransition;
    private BooleanProperty edgeTopRectangle = new SimpleBooleanProperty(false);
    private BooleanProperty hasTextRectangle = new SimpleBooleanProperty(false);
    private IntegerProperty currentDelta = new SimpleIntegerProperty(0);
    private EventSource deltaStream;

    public Cell(VBox rectangle, Location location, Text label, TranslateTransition translateTransition, EventSource<Tuple2<Integer, ColumnType>> deltaStream) {
        this.rectangle = rectangle;
        this.location = location;
        this.label = label;
        this.translateTransition = translateTransition;
        this.deltaStream = deltaStream;
        this.edgeTopRectangle.bind(new When(rectangle.translateYProperty().isEqualTo(0)).then(true).otherwise(false));
        this.hasTextRectangle.bind(new When(rectangle.translateYProperty().greaterThan(180).and(rectangle.translateYProperty().lessThan(240)).and(currentDelta.lessThan(0))).then(true).otherwise(
                new When(rectangle.translateYProperty().greaterThan(0).and(rectangle.translateYProperty().lessThan(60)).and(currentDelta.greaterThan(0))).then(true).otherwise(false)
        ));
        EventStream<Number> translateY = EventStreams.valuesOf(rectangle.translateYProperty());
        currentDelta.bind(deltaStream.map(Tuple2::get1).toBinding(0));

        EventStream<Tuple2<Tuple2<Integer, ColumnType>, Double>> combo = EventStreams.combine(
                this.deltaStream, translateY
        );

        combo.map(change -> {
            Integer currDelta = change.get1().get1();
            Double transY = change.get2();

            if (currDelta == 0 || currDelta < 0) {
                if (transY == 0) {
                    return 240;
                } else {
                    return transY;
                }
            } else {
                if (transY == 240) {
                    return 0;
                } else {
                    return transY;
                }
            }
        }).feedTo(translateTransition.fromYProperty());

        combo.map(change -> {
            Integer currDelta = change.get1().get1();
            Double transY = change.get2();

            if (currDelta == 0 || currDelta < 0) {
                if (transY == 0) {
                    return 180;
                } else {
                    return transY - 60;
                }
            } else {
                if (transY == 240) {
                    return 60;
                } else {
                    return transY + 60;
                }
            }
        }).feedTo(translateTransition.toYProperty());
    }


    public void animate() {
        translateTransition.play();
    }

    public BooleanProperty hasTopEdgeRectangle() {
        return this.edgeTopRectangle;
    }

    public BooleanProperty hasChangeTextRectangle() {
        return this.hasTextRectangle;
    }

    public void setLabel(String newLabel) {
        if (label.getId().contains(rectangle.getId())) {
            this.label.setText(newLabel);
        }
    }

    public void setLabel(boolean topEdgeExists, LocalTime clock, ColumnType columnType) {
        if (columnType.equals(ColumnType.SECONDS)) {
            if (topEdgeExists) {
                if (rectangle.translateYProperty().get() == 0) {
                    label.setText(Integer.toString(clock.plusSeconds(2).getSecond()));
                }

                if (rectangle.translateYProperty().get() == 60) {
                    label.setText(Integer.toString(clock.plusSeconds(1).getSecond()));
                }

                if (rectangle.translateYProperty().get() == 120) {
                    label.setText(Integer.toString(clock.getSecond()));
                }

                if (rectangle.translateYProperty().get() == 180) {
                    label.setText(Integer.toString(clock.minusSeconds(1).getSecond()));
                }
            }

            if (!topEdgeExists) {
                if (rectangle.translateYProperty().get() == 60) {
                    label.setText(Integer.toString(clock.plusSeconds(2).getSecond()));
                }

                if (rectangle.translateYProperty().get() == 120) {
                    label.setText(Integer.toString(clock.plusSeconds(1).getSecond()));
                }

                if (rectangle.translateYProperty().get() == 180) {
                    label.setText(Integer.toString(clock.getSecond()));
                }

                if (rectangle.translateYProperty().get() == 240) {
                    label.setText(Integer.toString(clock.minusSeconds(1).getSecond()));
                }
            }
        }

        if (columnType.equals(ColumnType.MINUTES)) {
            if (topEdgeExists) {
                if (rectangle.translateYProperty().get() == 0) {
                    label.setText(Integer.toString(clock.plusMinutes(2).getMinute()));
                }

                if (rectangle.translateYProperty().get() == 60) {
                    label.setText(Integer.toString(clock.plusMinutes(1).getMinute()));
                }

                if (rectangle.translateYProperty().get() == 120) {
                    label.setText(Integer.toString(clock.getMinute()));
                }

                if (rectangle.translateYProperty().get() == 180) {
                    label.setText(Integer.toString(clock.minusMinutes(1).getMinute()));
                }
            }

            if (!topEdgeExists) {
                if (rectangle.translateYProperty().get() == 60) {
                    label.setText(Integer.toString(clock.plusMinutes(2).getMinute()));
                }

                if (rectangle.translateYProperty().get() == 120) {
                    label.setText(Integer.toString(clock.plusMinutes(1).getMinute()));
                }

                if (rectangle.translateYProperty().get() == 180) {
                    label.setText(Integer.toString(clock.getMinute()));
                }

                if (rectangle.translateYProperty().get() == 240) {
                    label.setText(Integer.toString(clock.minusMinutes(1).getMinute()));
                }
            }
        }

        if (columnType.equals(ColumnType.HOURS)) {
            if (topEdgeExists) {
                if (rectangle.translateYProperty().get() == 0) {
                    label.setText(Integer.toString(clock.plusHours(2).getHour()));
                }

                if (rectangle.translateYProperty().get() == 60) {
                    label.setText(Integer.toString(clock.plusHours(1).getHour()));
                }

                if (rectangle.translateYProperty().get() == 120) {
                    label.setText(Integer.toString(clock.getHour()));
                }

                if (rectangle.translateYProperty().get() == 180) {
                    label.setText(Integer.toString(clock.minusHours(1).getHour()));
                }
            }

            if (!topEdgeExists) {
                if (rectangle.translateYProperty().get() == 60) {
                    label.setText(Integer.toString(clock.plusHours(2).getHour()));
                }

                if (rectangle.translateYProperty().get() == 120) {
                    label.setText(Integer.toString(clock.plusHours(1).getHour()));
                }

                if (rectangle.translateYProperty().get() == 180) {
                    label.setText(Integer.toString(clock.getHour()));
                }

                if (rectangle.translateYProperty().get() == 240) {
                    label.setText(Integer.toString(clock.minusHours(1).getHour()));
                }
            }
        }
    }

    public ReadOnlyObjectProperty<Animation.Status> isRunning() {
        return translateTransition.statusProperty();
    }

    public int getDelta() {
{'fraction_non_alphanumeric': 0.12035096909376637, 'fraction_numerical': 0.015191199580932426, 'mean_word_length': 1.8521008403361345, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '7313657', 'n_tokens_mistral': 4180, 'n_tokens_neox': 3780, 'n_words': 589}