<commit_before>//@@author A0139392X
package seedu.typed.ui;

import java.util.ArrayList;

import com.google.common.eventbus.Subscribe;

import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Region;
import javafx.scene.text.Text;
import seedu.typed.commons.events.model.TaskManagerChangedEvent;
import seedu.typed.commons.events.ui.NewResultAvailableEvent;
import seedu.typed.commons.util.StringPairUtil;

public class Quotes extends UiPart<Region> {

    private static final String FXML = "Quotes.fxml";
    private static final int QUOTES_DATABASE_SIZE = 7;
    private final Image quotationLogo = new Image("/images/quotation.png");

    @FXML
    private AnchorPane mainPane;

    @FXML
    private Label quote;

    @FXML
    private Text author;

    @FXML
    private ImageView quotationHolder;

    private ArrayList<StringPairUtil> quotesDatabase;

    public Quotes(AnchorPane placeholder) {
        super(FXML);
        placeholder.getChildren().add(quote);
        placeholder.getChildren().add(author);
        placeholder.getChildren().add(quotationHolder);
        placeholder.getChildren().add(mainPane);

        quotationHolder.setImage(quotationLogo);

        quotesDatabase = new ArrayList<StringPairUtil>();
        initializeDatabase();

        int randomNumber = randomizedNumber();

        quote.setText(quotesDatabase.get(3).getElem1());
        author.setText("~ " + quotesDatabase.get(3).getElem2());

        registerAsAnEventHandler(this);
    }

    @Subscribe
    private void handleNewResultAvailableEvent(TaskManagerChangedEvent event) {
        quote.setText("");
        author.setText("");
        quotationHolder.setImage(null);
    }

    @Subscribe
    private void handleNewResultAvailableEvent(NewResultAvailableEvent event) {
        quote.setText("");
        author.setText("");
        quotationHolder.setImage(null);
    }

    private int randomizedNumber() {
        return (int) ((Math.random() * 10) % QUOTES_DATABASE_SIZE);
    }

    private void initializeDatabase() {
        String first = "Productivity is being able to do things that "
                + "you were never able to do before.";
        String firstAuthor = "<NAME>";

        String second = "If you spend too much time thinking about a thing, you'll never get it done.";<commit_msg>Forgot to reset back to default randomNumber<commit_after>//@@author A0139392X
package seedu.typed.ui;

import java.util.ArrayList;

import com.google.common.eventbus.Subscribe;

import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Region;
import javafx.scene.text.Text;
import seedu.typed.commons.events.model.TaskManagerChangedEvent;
import seedu.typed.commons.events.ui.NewResultAvailableEvent;
import seedu.typed.commons.util.StringPairUtil;

public class Quotes extends UiPart<Region> {

    private static final String FXML = "Quotes.fxml";
    private static final int QUOTES_DATABASE_SIZE = 7;
    private final Image quotationLogo = new Image("/images/quotation.png");

    @FXML
    private AnchorPane mainPane;

    @FXML
    private Label quote;

    @FXML
    private Text author;

    @FXML
    private ImageView quotationHolder;

    private ArrayList<StringPairUtil> quotesDatabase;

    public Quotes(AnchorPane placeholder) {
        super(FXML);
        placeholder.getChildren().add(quote);
        placeholder.getChildren().add(author);
        placeholder.getChildren().add(quotationHolder);
        placeholder.getChildren().add(mainPane);

        quotationHolder.setImage(quotationLogo);

        quotesDatabase = new ArrayList<StringPairUtil>();
        initializeDatabase();

        int randomNumber = randomizedNumber();

        quote.setText(quotesDatabase.get(randomNumber).getElem1());
        author.setText("~ " + quotesDatabase.get(randomNumber).getElem2());

        registerAsAnEventHandler(this);
    }

    @Subscribe
    private void handleNewResultAvailableEvent(TaskManagerChangedEvent event) {
        quote.setText("");
        author.setText("");
        quotationHolder.setImage(null);
    }

    @Subscribe
    private void handleNewResultAvailableEvent(NewResultAvailableEvent event) {
        quote.setText("");
        author.setText("");
        quotationHolder.setImage(null);
    }

    private int randomizedNumber() {
        return (int) ((Math.random() * 10) % QUOTES_DATABASE_SIZE);
    }

    private void initializeDatabase() {
        String first = "Productivity is being able to do things that "
                + "you were never able to do before.";
        String firstAuthor = "<NAME>";

        String second = "If you spend too much time thinking about a thing, you'll never get it done.";
{'fraction_non_alphanumeric': 0.10224287734895939, 'fraction_numerical': 0.005253586583148111, 'mean_word_length': 3.4394618834080717, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '1547324', 'n_tokens_mistral': 1412, 'n_tokens_neox': 1350, 'n_words': 313}