Fix bug where threshold lines were added twice by Rylern · Pull Request #2062 · qupath/qupath
Before this PR, calling ChartThresholdPane.addThreshold() was adding a threshold line twice, because:
addThreshold(final ObservableNumberValue d, final Color color)was adding a first line.- At the end of
addThreshold(final ObservableNumberValue d, final Color color),thresholds.add(d);is called. This triggershandleLineListChange()to be called. handleLineListChange()callsaddThreshold(ObservableNumberValue), which callsaddThreshold(final ObservableNumberValue d, final Color color): this adds the second line.
This PR fixes that by only creating the line in handleLineListChange(). The addThreshold() functions now just update thresholds (which triggers handleLineListChange()).