<commit_before>package com.valkryst.VTerminal.misc;

import java.awt.Dimension;
import java.awt.Point;
import java.util.LinkedList;
import java.util.List;

public final class ShapeAlgorithms {
    // Prevent users from creating an instance.
    private ShapeAlgorithms() {}

    /**
     * Constructs a list, containing the outline, of an ellipse's points by using
     * the Bresenham algorithm,
     *
     * @param position
     *        The x/y-axis (column/row) coordinates of the top-left character.
     *
     * @param dimension
     *        The width/height.
     *
     * @return
     *        The list of points.
     */
    public static List<Point> getEllipse(final Point position, final Dimension dimension) {
        final List<Point> points = new LinkedList<>();

        final int x = position.x;
        final int y = position.y;
        final int width = dimension.width;
        final int height = dimension.height;

        int a2 = width * width;
        int b2 = height * height;
        int fa2 = 4 * a2;
        int fb2 = 4 * b2;

        int dx = 0;
        int dy = height;
        int sigma = 2 * b2 + a2 * (1 - 2 * height);

        while (b2 * dx <= a2 * dy) {
            points.add(new Point(x + dx, y + dy));
            points.add(new Point(x - dx, y + dy));
            points.add(new Point(x + dx, y - dy));
            points.add(new Point(x - dx, y - dy));

            if (sigma >= 0) {
                sigma += fa2 * (1 - dy);
                dy--;
            }

            sigma += b2 * ((4 * dx) + 6);
            dx++;
        }


        dx = width;
        dy = 0;
        sigma = 2 * a2 + b2 * (1 - 2 * width);

        while (a2 * dy <= b2 * dx) {
            points.add(new Point(x + dx, y + dy));
            points.add(new Point(x - dx, y + dy));
            points.add(new Point(x + dx, y - dy));
            points.add(new Point(x - dx, y - dy));

            if (sigma >= 0) {
                sigma += fb2 * (1 - dx);
                dx--;
            }

            sigma += a2 * ((4 * dy) + 6);
            dy++;
        }

        return points;
    }

    /**
     * Constructs a list, containing the outline and fill, of an ellipse's points.
     *
     * @param position
     *        The x/y-axis (column/row) coordinates of the top-left character.
     *
     * @param dimension
     *        The width/height.
     *
     * @return
     *        The list of points.
     */
    public static List<Point> getFilledEllipse(final Point position, final Dimension dimension) {
        final List<Point> points = getEllipse(position, dimension);

        final int xCenter = position.x + (dimension.width / 2);
        final int yCenter = position.y + (dimension.height / 2);
        position.setLocation(xCenter, yCenter);

        return recursiveFill(points, position);
    }

    /**
     * Constructs a list, containing the path, of a line's points by using the
     * Bresenham algorithm,
     *
     * @param fromX
     *         The x-axis (column) coordinate of the start point of the line.
     *
     * @param fromY
     *         The y-axis (row) coordinate of the start point of the line.
     *
     * @param toX
     *         The x-axis (column) coordinate of the end point of the line.
     *
     * @param toY
     *         The y-axis (row) coordinate of the end point of the line.
     *
     * @return
     *        The list of points.
     */
    public static List<Point> getLine(int fromX, int fromY, final int toX, final int toY) {
        final List<Point> points = new LinkedList<>();

        int d = 0;

        int dx = Math.abs(toX - fromX);
        int dy = Math.abs(toY - fromY);

        int dx2 = dx << 1;
        int dy2 = dy << 1;

        int ix = fromX < toX ? 1 : -1;
        int iy = fromY < toY ? 1 : -1;

        if (dy <= dx) {
            while(true) {
                points.add(new Point(fromX, fromY));

                if (fromX == toX) {<commit_msg>Sets method vars to final, where appropriate.<commit_after>package com.valkryst.VTerminal.misc;

import java.awt.Dimension;
import java.awt.Point;
import java.util.LinkedList;
import java.util.List;

public final class ShapeAlgorithms {
    // Prevent users from creating an instance.
    private ShapeAlgorithms() {}

    /**
     * Constructs a list, containing the outline, of an ellipse's points by using
     * the Bresenham algorithm,
     *
     * @param position
     *        The x/y-axis (column/row) coordinates of the top-left character.
     *
     * @param dimension
     *        The width/height.
     *
     * @return
     *        The list of points.
     */
    public static List<Point> getEllipse(final Point position, final Dimension dimension) {
        final List<Point> points = new LinkedList<>();

        final int x = position.x;
        final int y = position.y;
        final int width = dimension.width;
        final int height = dimension.height;

        final int a2 = width * width;
        final int b2 = height * height;
        final int fa2 = 4 * a2;
        final int fb2 = 4 * b2;

        int dx = 0;
        int dy = height;
        int sigma = 2 * b2 + a2 * (1 - 2 * height);

        while (b2 * dx <= a2 * dy) {
            points.add(new Point(x + dx, y + dy));
            points.add(new Point(x - dx, y + dy));
            points.add(new Point(x + dx, y - dy));
            points.add(new Point(x - dx, y - dy));

            if (sigma >= 0) {
                sigma += fa2 * (1 - dy);
                dy--;
            }

            sigma += b2 * ((4 * dx) + 6);
            dx++;
        }


        dx = width;
        dy = 0;
        sigma = 2 * a2 + b2 * (1 - 2 * width);

        while (a2 * dy <= b2 * dx) {
            points.add(new Point(x + dx, y + dy));
            points.add(new Point(x - dx, y + dy));
            points.add(new Point(x + dx, y - dy));
            points.add(new Point(x - dx, y - dy));

            if (sigma >= 0) {
                sigma += fb2 * (1 - dx);
                dx--;
            }

            sigma += a2 * ((4 * dy) + 6);
            dy++;
        }

        return points;
    }

    /**
     * Constructs a list, containing the outline and fill, of an ellipse's points.
     *
     * @param position
     *        The x/y-axis (column/row) coordinates of the top-left character.
     *
     * @param dimension
     *        The width/height.
     *
     * @return
     *        The list of points.
     */
    public static List<Point> getFilledEllipse(final Point position, final Dimension dimension) {
        final List<Point> points = getEllipse(position, dimension);

        final int xCenter = position.x + (dimension.width / 2);
        final int yCenter = position.y + (dimension.height / 2);
        position.setLocation(xCenter, yCenter);

        return recursiveFill(points, position);
    }

    /**
     * Constructs a list, containing the path, of a line's points by using the
     * Bresenham algorithm,
     *
     * @param fromX
     *         The x-axis (column) coordinate of the start point of the line.
     *
     * @param fromY
     *         The y-axis (row) coordinate of the start point of the line.
     *
     * @param toX
     *         The x-axis (column) coordinate of the end point of the line.
     *
     * @param toY
     *         The y-axis (row) coordinate of the end point of the line.
     *
     * @return
     *        The list of points.
     */
    public static List<Point> getLine(int fromX, int fromY, final int toX, final int toY) {
        final List<Point> points = new LinkedList<>();

        int d = 0;

        final int dx = Math.abs(toX - fromX);
        final int dy = Math.abs(toY - fromY);

        final int dx2 = dx << 1;
        final int dy2 = dy << 1;

        final int ix = fromX < toX ? 1 : -1;
        final int iy = fromY < toY ? 1 : -1;

        if (dy <= dx) {
            while(true) {
                points.add(new Point(fromX, fromY));

                if (fromX == toX) {
{'fraction_non_alphanumeric': 0.11538461538461539, 'fraction_numerical': 0.011738261738261738, 'mean_word_length': 1.5409263959390862, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 23, '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': '4436256', 'n_tokens_mistral': 2540, 'n_tokens_neox': 2395, 'n_words': 816}