Add ImageUtilities methods to help migrating away from "new ImageIcon" (SVG icon related)#8114
Conversation
platform/openide.util.ui/src/org/openide/util/ImageUtilities.java
Outdated
Show resolved
Hide resolved
platform/openide.util.ui/src/org/openide/util/ImageUtilities.java
Outdated
Show resolved
Hide resolved
|
There is one more method I could add which might be useful, which is a mergeIcons(Icon,Icon,int,int) which works like mergeImages(Image,Image,int,int) but takes and returns Icon instances instead of Image. It could simplify some of the cases in #8109. |
4ffa602 to
04ca39c
Compare
|
I pushed a revision to the two commits in this PR. Changes since your previous review:
|
04ca39c to
ce87d72
Compare
|
(Latest push was just a rebase on master.) |
mbien
left a comment
There was a problem hiding this comment.
looks good to me. Please check the comment I added.
platform/openide.util.ui/src/org/openide/util/ImageUtilities.java
Outdated
Show resolved
Hide resolved
|
don't forget to squash, looks like this could be 1-2 commits. |
…ding methods used throughout the codebase easier. (Additive API change.) Edit Javadoc to avoid repeating semantics that are common to many methods. Some other Javadoc cleanup.
e58bba7 to
46e8409
Compare
…mageUtilities.loadImage(URI), to make SVG icons work in these cases.
|
Squashed so that two commits remain: The API change in isolation, and the call sites that make use of it. |
This is a follow-up on apache#8114 and apache#8109 . To render at full HiDPI resolution, Icon/Image instances must be created via the methods in ImageUtilities rather than, in particular, the constructors of ImageIcon. This PR, combined with the previously mentioned PRs, handles most of the remaining cases. Specifically: * Search for 'new ImageIcon(' and rewrite each case to use ImageUtilities to load icons instead. * Search for 'instanceof ImageIcon' and generalize to 'instanceof Icon' when appropriate. * Search for 'getLookAndFeel*getDisabledIcon' and switch to ImageUtilities.createDisabledIcon.
This is a follow-up on apache#8114 and apache#8109 . To render at full HiDPI resolution, Icon/Image instances must be created via the methods in ImageUtilities rather than, in particular, the constructors of ImageIcon. This PR, combined with the previously mentioned PRs, handles most of the remaining cases. Specifically: * Search for 'new ImageIcon(' and rewrite each case to use ImageUtilities to load icons instead. * Search for 'instanceof ImageIcon' and generalize to 'instanceof Icon' when appropriate. * Search for 'getLookAndFeel*getDisabledIcon' and switch to ImageUtilities.createDisabledIcon.
|
i give it a 75% chance that someone will complain that the light bulbs are too large - but I think i like them after running RC1 for ~2 days :) |
|
@mbien Yeah the old ones were scaled down a bit relative to the lightbulb-only icon. I might adjust it the next time I do a round of editing on these.
|
|
its fine - they are now using LEDs and were no longer available in the same size |
This is a follow-up on apache#8114 and apache#8109 . To render at full HiDPI resolution, Icon/Image instances must be created via the methods in ImageUtilities rather than, in particular, the constructors of ImageIcon. This PR, combined with the previously mentioned PRs, handles most of the remaining cases. Specifically: * Search for 'new ImageIcon(' and rewrite each case to use ImageUtilities to load icons instead. * Search for 'instanceof ImageIcon' and generalize to 'instanceof Icon' when appropriate. * Search for 'getLookAndFeel*getDisabledIcon' and switch to ImageUtilities.createDisabledIcon.
This is a follow-up on #8114 and #8109 . To render at full HiDPI resolution, Icon/Image instances must be created via the methods in ImageUtilities rather than, in particular, the constructors of ImageIcon. This PR, combined with the previously mentioned PRs, handles most of the remaining cases. Specifically: * Search for 'new ImageIcon(' and rewrite each case to use ImageUtilities to load icons instead. * Search for 'instanceof ImageIcon' and generalize to 'instanceof Icon' when appropriate. * Search for 'getLookAndFeel*getDisabledIcon' and switch to ImageUtilities.createDisabledIcon.

Background: To ensure that SVG icons are loaded and drawn at full resolution, direct use of ImageIcon constructors should be avoided in the NetBeans codebase. The ImageIcon instances returned from methods in ImageUtilities, by contrast, are instances of a special subclass of ImageIcon that support vector graphics painting.
During work to remove uses of "new ImageIcon" constructors in the codebase (including #8109), I see that a few new utility methods would be useful in ImageUtilities. This PR proposes adding the following methods to ImageUtilities:
This PR also contains, in a separate commit, migration away from the Toolkit.getDefaultToolkit().createImage() method, using the new loadImage(URL) method. This makes, for instance, the "lightbulb" icons in the editor gutter show up properly with their new SVG icons: