<commit_before>package gui.subControllers;

import javafx.scene.control.*;
import java.util.prefs.Preferences;

/**
 * Created by Jip on 17-5-2017.
 * A BookmarkController class moving some logic from the MenuController into a different class.
 */
public class BookmarkController {

    private static Preferences prefs;
    private String stringFile;
    private Button bookmark1, bookmark2;

    /**
     * Constructor of the bookmark controller to handle the bookmarks.
     * @param bm1 The button with the first bookmark.
     * @param bm2 The button with the second bookmark.
     */
    public BookmarkController(Button bm1, Button bm2) {
        bookmark1 = bm1;
        bookmark2 = bm2;

        stringFile = "";
        prefs = Preferences.userRoot();
    }

    /**
     * Loads the bookmarks of the specific file stringFile.
     * @param stringOfFile The file that is being loaded whose bookmarks should be loaded.
     */
    public void loadBookmarks(String stringOfFile) {
        stringFile = stringOfFile;

        if (prefs.getInt("bookmarkNum" + stringFile, -1) == -1) {
            prefs.putInt("bookmarkNum" + stringFile, 0);
        }

        int largestIndex = prefs.getInt("bookmarkNum" + stringFile, -1);
        int i = -1;

        while (i <= largestIndex) {
            int newIndex = i;
            String realBM = prefs.get(stringFile + newIndex, "-");
            updateBookmarks(realBM);
            i++;
        }
    }

    /**
     * Saves the bookmarks when the user presses save.
     * @param nodes The centre node
     * @param radius The radius of nodes we should save/show
     */
    public void saving(int nodes, int radius) {

        String stringFile = prefs.get("file", "def");
        int newIndex = prefs.getInt("bookmarkNum" + stringFile, -1);
        newIndex++;<commit_msg>Added documentation for magic number as requested.<commit_after>package gui.subControllers;

import javafx.scene.control.*;
import java.util.prefs.Preferences;

/**
 * Created by Jip on 17-5-2017.
 * A BookmarkController class moving some logic from the MenuController into a different class.
 */
public class BookmarkController {

    private static Preferences prefs;
    private String stringFile;
    private Button bookmark1, bookmark2;

    /**
     * Constructor of the bookmark controller to handle the bookmarks.
     * @param bm1 The button with the first bookmark.
     * @param bm2 The button with the second bookmark.
     */
    public BookmarkController(Button bm1, Button bm2) {
        bookmark1 = bm1;
        bookmark2 = bm2;

        stringFile = "";
        prefs = Preferences.userRoot();
    }

    /**
     * Loads the bookmarks of the specific file stringFile.
     * @param stringOfFile The file that is being loaded whose bookmarks should be loaded.
     */
    public void loadBookmarks(String stringOfFile) {
        stringFile = stringOfFile;

        if (prefs.getInt("bookmarkNum" + stringFile, -1) == -1) {
            prefs.putInt("bookmarkNum" + stringFile, 0);
        }

        int largestIndex = prefs.getInt("bookmarkNum" + stringFile, -1);
        //As a user,
        // When viewing a file with bookmarks,
        // And choosing a new file to view
        // And that file has no bookmarks
        // I want to not see the old bookmarks.
        // Initializing this number as -2 ensures the above user story.
        int i = -2;

        while (i <= largestIndex) {
            int newIndex = i;
            String realBM = prefs.get(stringFile + newIndex, "-");
            updateBookmarks(realBM);
            i++;
        }
    }

    /**
     * Saves the bookmarks when the user presses save.
     * @param nodes The centre node
     * @param radius The radius of nodes we should save/show
     */
    public void saving(int nodes, int radius) {

        String stringFile = prefs.get("file", "def");
        int newIndex = prefs.getInt("bookmarkNum" + stringFile, -1);
        newIndex++;
{'fraction_non_alphanumeric': 0.09329299041855774, 'fraction_numerical': 0.011850731215330307, 'mean_word_length': 2.3224455611390287, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2557180', 'n_tokens_mistral': 1142, 'n_tokens_neox': 1117, 'n_words': 381}