<commit_before>package org.helioviewer.viewmodel.view.jp2view.image;

import java.awt.Rectangle;

import org.helioviewer.base.math.Interval;

/**
 * A very simple region of interest class. Basically just an immutable (for
 * thread safety) rectangle class with less functionality. At the moment the
 * information contained in this class is just x,y,width, and height. This data
 * is actually kept in two separate formats... int's and range/domain
 * Interval's. The intervals are probably the better choice, but I have gone
 * through and eliminated the direct calls to the member variables yet.
 *
 * @author caplins
 *
 */
public class SubImage {

    /** Holds the domain of the ROI */
    public final Interval<Integer> domain;

    /** Holds the range of the ROI */
    public final Interval<Integer> range;

    /** The same data as in the range and domain */
    public int x;

    public int y;

    public int width;

    public int height;

    /**
     * Constructor taking primitive ints.
     *
     * @param _x
     * @param _y
     * @param _width
     * @param _height
     */
    public SubImage(int _x, int _y, int _width, int _height) {
        x = _x;
        y = _y;
        width = _width;
        height = _height;

        domain = new Interval<Integer>(x, x + width);
        range = new Interval<Integer>(y, y + height);
    }

    /**
     * Constructor taking Intervals.
     *
     * @param _domain
     * @param _range
     */
    public SubImage(Interval<Integer> _domain, Interval<Integer> _range) {
        domain = _domain;
        range = _range;
        x = domain.getStart();
        width = domain.getEnd() - domain.getStart();
        y = range.getStart();
        height = range.getEnd() - range.getStart();
    }

    /**
     * Constructor taking a Rectangle
     *
     * @param _rect
     */
    public SubImage(Rectangle _rect) {
        this(_rect.x, _rect.y, _rect.width, _rect.height);
    }<commit_msg>Fix occasional "jumps" in the images(negative roi)<commit_after>package org.helioviewer.viewmodel.view.jp2view.image;

import java.awt.Rectangle;

import org.helioviewer.base.math.Interval;

/**
 * A very simple region of interest class. Basically just an immutable (for
 * thread safety) rectangle class with less functionality. At the moment the
 * information contained in this class is just x,y,width, and height. This data
 * is actually kept in two separate formats... int's and range/domain
 * Interval's. The intervals are probably the better choice, but I have gone
 * through and eliminated the direct calls to the member variables yet.
 *
 * @author caplins
 *
 */
public class SubImage {

    /** Holds the domain of the ROI */
    public final Interval<Integer> domain;

    /** Holds the range of the ROI */
    public final Interval<Integer> range;

    /** The same data as in the range and domain */
    public int x;

    public int y;

    public int width;

    public int height;

    /**
     * Constructor taking primitive ints.
     *
     * @param _x
     * @param _y
     * @param _width
     * @param _height
     */
    public SubImage(int _x, int _y, int _width, int _height) {
        x = _x;
        if (x < 0) {
            x = 0;
        }
        y = _y;
        if (y < 0) {
            y = 0;
        }
        width = _width;
        height = _height;

        domain = new Interval<Integer>(x, x + width);
        range = new Interval<Integer>(y, y + height);
    }

    /**
     * Constructor taking Intervals.
     *
     * @param _domain
     * @param _range
     */
    public SubImage(Interval<Integer> _domain, Interval<Integer> _range) {
        domain = _domain;
        range = _range;
        x = domain.getStart();
        width = domain.getEnd() - domain.getStart();
        y = range.getStart();
        height = range.getEnd() - range.getStart();
    }

    /**
     * Constructor taking a Rectangle
     *
     * @param _rect
     */
    public SubImage(Rectangle _rect) {
        this(_rect.x, _rect.y, _rect.width, _rect.height);
    }
{'fraction_non_alphanumeric': 0.10239920850853326, 'fraction_numerical': 0.0014840465001236705, 'mean_word_length': 2.242983159582999, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, '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': '6650138', 'n_tokens_mistral': 1231, 'n_tokens_neox': 1193, 'n_words': 412}