Issue #1004: fix AnnotationImage screen-space vertical centering (width vs height)#1005
Merged
timmolter merged 1 commit intoJul 16, 2026
Merged
Conversation
The screen-space branch of AnnotationImage.paint() centered the image vertically using image.getWidth() instead of image.getHeight(), so a non-square image placed with isValueInScreenSpace=true was mis-centered vertically by (width - height) / 2 pixels. Square images were unaffected. Add TestForIssue1004 demo showing a tall image against a crosshair marking the intended center (before: image center sits 50px below the crosshair; after: it lines up). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.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.
Summary
Fixes #1004.
AnnotationImage.paint()centered the image vertically usingimage.getWidth()instead ofimage.getHeight()in the screen-space branch. A non-square image placed withisValueInScreenSpace = truewas therefore mis-centered vertically by(width - height) / 2pixels. The data-space branch already usedgetHeight()correctly, and square images were unaffected — which is why it went unnoticed.if (isValueInScreenSpace) { xOffset = (int) x - image.getWidth() / 2; - yOffset = chart.getHeight() - (int) y - image.getWidth() / 2; + yOffset = chart.getHeight() - (int) y - image.getHeight() / 2;Demo
Adds
TestForIssue1004, which places a tall (40×140) image in screen space at a fixed point marked by a crosshair; the image has a red line across its true center.Origin
Found while triaging #506 (which is resolved on
develop— the oldChartImage/addPlotPartAPI is nowAnnotationImage/addAnnotation).🤖 Generated with Claude Code