<Swing Dev> [9] Review request for 6302464 Allow programmatic enabling of subpixel anti-aliasing in Swing
Alexander Scherbatiy
alexandr.scherbatiy at oracle.com
Thu Aug 13 12:07:15 UTC 2015
Hello,
Could you review the fix:
bug: https://bugs.openjdk.java.net/browse/JDK-6302464
webrev: http://cr.openjdk.java.net/~alexsch/6302464/webrev.00
Swing uses internal API to set antialiasing settings for L&Fs and
components.
SwingUtilities2.AATextInfo aaTextInfo = new SwingUtilities2.AATextInfo(
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB, 140);
UIManager.getDefaults().put(SwingUtilities2.AA_TEXT_PROPERTY_KEY,
aaTextInfo); // set aa hints globally
component.putClientProperty(SwingUtilities2.AA_TEXT_PROPERTY_KEY,
aaTextInfo); // set aa hints for a JComponent
There are some ways to provide a public mechanism for antialiasing
enabling in Swing:
1. Setting antialiasing rendering hints into UI defaults and component
client properties:
UIManager.getDefaults().put(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
component.putClientProperty(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
2. Setting a map which contains antialiasing hints:
Map<RenderingHints.Key, Object> aaHintsMap = new HashMap<>();
aaHintsMap.put(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
UIManager.getDefaults().put(AA_TEXT_PROPERTY_KEY, aaHintsMap);
component.putClientProperty(AA_TEXT_PROPERTY_KEY, aaHintsMap);
3. Information about antialiasing hints can be stored in a public class
AATextInfo aaTextInfo = new
AATextInfo(RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB, 140);
UIManager.getDefaults().put(AA_TEXT_PROPERTY_KEY, aaTextInfo);
component.putClientProperty(AA_TEXT_PROPERTY_KEY, aaTextInfo);
The proposed fix used the first approach.
Thanks,
Alexandr.
More information about the swing-dev
mailing list