Out of bounds issue with BufferedImage when zooming with the mouse wheel

Issue #324 duplicate
Christopher Keil repo owner created an issue

USE CASE: WHAT DO YOU WANT TO DO?

Zoom out of the matrix using the mouse wheel.

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

1) Open a matrix. 2) Zoom into the matrix using the mouse wheel or any other means. 3) Zoom out of the matrix using Alt + mouse wheel 4) Repeat steps 2 + 3 until issue occurs (~10 - 20% of the time)

CURRENT BEHAVIOR

Zooming out of the matrix using a mouse wheel works as expected but 10-20% of the time a messed up version of the subImage is shown, appearing as tiny image in the top left corner with the rest of the canvas being white. This is due to some index out of bounds problem and BufferedImage.subImage() somehow gets parameters that do not match the internal state of the BufferedImage object.

EXPECTED BEHAVIOR

Zooming out of the matrix with the mouse wheel should never lead to BufferedImage problems and any white canvas should never appear. This can be achieved by guaranteeing that the zoom methods always return or set the important index variables (such as firstVisible).

DEVELOPERS ONLY SECTION

SUGGESTED CHANGE (Pseudocode optional)

Debug zoom functions. Implement thorough unit testing cases for affected zoom functions (let me know if there are questions about JUnit, it's actually pretty simple to use). This guarantees they set or return values as expected (also for the future) and will likely reveal problematic areas of the code.

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

MatrixViewController.java, InteractiveMatrixView.java, MapContainer.java

LEVEL OF EFFORT - developers only

medium

COMMENTS

This issue is extremely similar to #299 and I have a very big hunch that in some circumstances the zoom code ends up setting firstVisible or numVisible (or associated variables) in MapContainer off by 1.

Comments (5)

  1. Log in to comment