Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crosshair labels are not anti-aliased #187

Open
ebourg opened this issue Nov 10, 2020 · 9 comments
Open

Crosshair labels are not anti-aliased #187

ebourg opened this issue Nov 10, 2020 · 9 comments

Comments

@ebourg
Copy link
Contributor

ebourg commented Nov 10, 2020

The label of a crosshair overlay is not anti-aliased, it would probably make sense to use the text anti-aliasing hint set on the chart when drawing it.

@jfree
Copy link
Owner

jfree commented Nov 10, 2020

I see the issue - the rendering hints are applied to the Graphics2D instance that the JFreeChart instance draws onto. Without chart buffering, the same Graphics2D instance is used for the overlays (so no problem) but, when chart buffering is enabled, the rendering hints are set on the Graphics2D instance from the buffer image, and don't get applied to the ChartPanel's Graphics2D instance. This should be easy to fix.

@jfree
Copy link
Owner

jfree commented Nov 10, 2020

The fix will be included in the v1.5.2 release.

@ebourg
Copy link
Contributor Author

ebourg commented Nov 10, 2020

Thank you but I'm not sure propagating all the hints unconditionally to the overlays is a good idea, because now the lines of the crosshair are blurred. Maybe the CrosshairOverlay should at least disable the anti-aliasing when drawing the vertical and horizontal lines (and maybe the outlines too).

@jfree
Copy link
Owner

jfree commented Nov 10, 2020

Another option would be to add a set of default hints to the AbstractOverlay class, allow for overriding the defaults, and then apply hints independently between the chart and each overlay instance.

@jfree jfree reopened this Nov 10, 2020
@ebourg
Copy link
Contributor Author

ebourg commented Nov 12, 2020

There is also a similar issue with the markers, the label of a ValueMarker isn't painted with subpixel anti-aliasing (but the default anti-aliasing is applied at least).

@ebourg
Copy link
Contributor Author

ebourg commented Nov 12, 2020

For the marker it's actually a consequence of the default alpha of 0.8. Disabling the transparency (with marker.setAlpha(1)) fixes the anti-aliasing.

@WilliamTan778
Copy link

chart.getRenderingHints().put(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
    chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);

@WilliamTan778
Copy link

另一种选择是向 AbstractOverlay 类添加一组默认提示,允许覆盖默认值,然后在图表和每个叠加实例之间独立应用提示。

   chart.getRenderingHints().put(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
    chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);

ok ok ,thanks

@WilliamTan778
Copy link

对于标记,它实际上是默认 alpha 0.8 的结果。禁用透明度(使用marker.setAlpha(1))可修复抗锯齿。

   chart.getRenderingHints().put(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
    chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);

ok ok thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants