Error handling in Color settings is inconsistent

Issue #414 resolved
Anastasia Baryshnikova created an issue

USE CASE: WHAT DO YOU WANT TO DO?

Adjust colors

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

Load test_dataset3.txt, go to View > Colors. Set the left handle to 0 and try to set the right handle to 0 as well.

CURRENT BEHAVIOR

An error that says "Cannot be smaller than min." is displayed by the input field.

Screen Shot 2016-05-23 at 5.48.27 PM.png

This is inconsistent for a few reasons:

a) the min value is -6.95 and seems to have nothing to do with 0 (the -6.95 value is likely to be a bug too because there should not be any values < 0 in this matrix -- the min, center, max etc. values seem to be inherited from the previous matrix I loaded)

b) this is not the reason why you can't set the right handle to 0.

c) when you try to set the middle handle to 0, the correct error is displayed ("value already has a handle") and the setting is not allowed. However, you can manually drag a handle to have the same value as another handle and that's allowed.

d) when you set the right handle to the same value as the middle handle, no error is displayed and the middle handle disappears.

EXPECTED BEHAVIOR

I think it should work like this:

1) The only restriction is that the right-most handle can't be smaller than the left-most handle. But they can be equal.

2) When a handle is set to a value that is smaller or equal to a handle located to its left, the left handle is eliminated (as currently happens in case d above)

3) The error should be below the input field (not next to it, replacing the field label) and should wrap around and not push the input field out of the window.

DEVELOPERS ONLY SECTION

SUGGESTED CHANGE (Pseudocode optional)

e.g. Add a color selection class

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

e.g. selectColor.java & settingsPanel.java

LEVEL OF EFFORT - developers only

trivial/minor/medium/major/overhaul (choose one)

COMMENTS

Comments (8)

  1. Christopher Keil repo owner

    @abarysh There is a bit of a problem with the gradient code we use (it's a native Java object). It does not allow for multiple equal values. All values have to be strictly increasing otherwise an exception is thrown. Documentation: https://docs.oracle.com/javase/7/docs/api/java/awt/LinearGradientPaint.html

    "IllegalArgumentException - if start and end points are the same points, or fractions.length != colors.length, or colors is less than 2 in size, or a fractions value is less than 0.0 or greater than 1.0, or the fractions are not provided in strictly increasing order".

    From your expected behavior: 1) The only restriction is that the right-most handle can't be smaller than the left-most handle. But they can be equal.

    What is the use case for this? Binary colors to the left and right of the value, where the boundary handles meet? If the boundary handles (left- and right-most handles) are equal how do you decide what color is displayed at the value where these handles meet? If the dataset is binary, then choosing the colors for the two boundary handles and removing all other thumbs in between should already suffice.

  2. Anastasia Baryshnikova reporter

    If the gradient code doesn't allow equal handles, that's ok. There is really no real use case for it, I just thought it would be better for consistency. We should just make sure the right error is displayed (e.g., like in case (c) -- "value already has a handle"). Something like:

    1) for the left-most and the right-most handles:

    a) when trying to set one to the same value as the other -> error "This value is already assigned to another handle.".
    
    b) when trying to set one to a value more extreme than min or max of the matrix -> error "This value has to be greater or equal to Min and less or equal to Max."
    

    2) for all other handles:

    a) when trying to set one to the same value as the left-most or the right-most handles -> error "This value is already assigned to another handle".

    b) when trying to set one to the same value as another middle handle -> no error, the previous handle with the same value disappears.

    c) when trying to set one to a value more extreme than min or max of the matrix -> error "This value has to be greater or equal to Min and less or equal to Max."

    d) when trying to set one to a value more extreme than the left-most or the right-most handles -> error "This value has to be greater than the left-most handle and less than the right-most handle."

  3. Log in to comment