scrollBy() in MapContainer sets out of bounds scrollbar position indexes.

Issue #299 closed
Christopher Keil repo owner created an issue

USE CASE: WHAT DO YOU WANT TO DO?

Scroll the matrix, either manually or by using a button / keyboard input.

STEPS TO REPRODUCE AN ISSUE (OR TRIGGER A NEW FEATURE)

  1. Zoom into matrix.

  2. Scroll to right or bottom edge.

CURRENT BEHAVIOR

Scrolling works by setting the scroll bar value in specific steps relative to the current scroll bar position. At the mentioned edge positions these steps will overshoot and the results are indexes that do not exist. For example for a 133x133 matrix, the maximum index is 132 but if the scrollbar already is at 131 further scrolling will attempt to add 3 indexes (step-size) and go to index 134.

The BufferedImage subImage() method will be affected by this, as scrolling also creates a new subImage.

The fault is in MapContainer.scrollBy()

EXPECTED BEHAVIOR

Scrolling will never lead to out-of-bound index calculation. The scrollBy method can never attempt to set anything beyond maxIndex.

DEVELOPERS ONLY SECTION

SUGGESTED CHANGE (Pseudocode optional)

Implement JUnit testing for scrollby(). Create viable bounds for scrollBy using maxIndex() and minIndex().

FILES AFFECTED (where the changes will be implemented) - developers only

MapContainer.java

LEVEL OF EFFORT - developers only

trivial

COMMENTS Very likely causes #290 - test if this issue is resolved once the scrollBy() function is fixed.

Comments (11)

  1. Christopher Keil reporter

    Yes, the recording pretty much matches the description and I have verified that it is caused by scrolling issues which end up leading to out of bounds behavior when selecting the sub-image from the main BufferedImage object. Aside from #290, there might also be a relationship to #270.

  2. Christopher Keil reporter
    • changed status to open

    Beginning work on this issue which we have talked about in previous CCB meetings.

  3. Christopher Keil reporter

    Final scrollBy() clean-ups and addition of JavaDoc

    JavaDoc has been added to scrollBy(), some lines have been cleaned up to reduce clutter.

    Resolves: #299

    See also: #270

    → <<cset 1a66315eca72>>

  4. Christopher Keil reporter

    Final scrollBy() clean-ups and addition of JavaDoc

    JavaDoc has been added to scrollBy(), some lines have been cleaned up to reduce clutter.

    Resolves: #299

    See also: #270

    → <<cset 1a66315eca72>>

  5. Log in to comment