Fix HeatMap legend gradient asymmetry (issue #585) + cleanup#966
Merged
Conversation
- Legend_HeatMap: align LinearGradientPaint start point to the actual bottom of the gradient rectangle (was fontSize pixels short, causing the min-color band to appear wider than the max-color band) - HeatMapSeries: fix calculateMinMax() initialising max = Double.MIN_VALUE (~0) instead of -Double.MAX_VALUE, which broke all-negative datasets - HeatMapStyler: add missing else in setRangeColors() so the single-color workaround array is not immediately overwritten by the original array - Styler: promote setTheme(Theme) to a non-deprecated base-class method; remove redundant @deprecated overrides from all 9 subclass stylers; keep BoxStyler override (@OverRide) because it resets boxplotCalCulationMethod - Styler: fix broken Javadoc @link to XChartPanel#setToolTipsEnabled - Demo: add TestForIssue585 reproducing the asymmetric gradient legend Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
The HeatMap gradient legend bar was visually asymmetric even when the colormap and data range were perfectly symmetric. The
LinearGradientPaintstart point (fraction=0, min colour) was placed atstarty + gradientColumnHeight, but the rectangle it filled extendedfontSizepixels further down tostarty + fontSize + gradientColumnHeight. That extra strip at the bottom was always clamped torangeColors[0], making the min-colour band appear disproportionately wide.Fixes
Legend_HeatMap- align the gradientstartpoint to the actual bottom of the rectangle:HeatMapSeries-calculateMinMax()initialisedmax = Double.MIN_VALUE(~4.9E-324, not the minimum double). Changed to-Double.MAX_VALUEso datasets with all-negative values compute the correct max.HeatMapStyler-setRangeColors()was missing anelse, so the single-colour workaround array was immediately overwritten by the original 1-element array.Styler/ all subclass stylers -setTheme(Theme)was@Deprecatedin each of the 10 concrete stylers, yet every chart's(width, height, Theme)constructor called it internally, producing deprecation warnings on every build. Fixed by promoting a single non-deprecatedsetTheme(Theme)toStyler, removing the redundant overrides from 9 subclasses, and convertingBoxStyler's override to a proper@Override(it has extraboxplotCalCulationMethodreset logic). Build is now warning-free.Styler- fixed a broken Javadoc{@link XChartPanel#setToolTipsEnabled(boolean)}reference (class is in a different package; added fully-qualified name).Demo
TestForIssue585inxchart-demo/.../standalone/issues/opens two windows (vertical and horizontal legend) with a symmetric blue colormap over a -5 to +5 range, making the pre-fix asymmetry immediately obvious.Closes #585