-
Notifications
You must be signed in to change notification settings - Fork 865
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
Avoid remaining trivial uses of new ImageIcon(Image), for HiDPI icons #8109
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks sane to me. Only eyeballed though. There is more cleanup possible, but that is a different task.
Thanks! I will run with this in my working IDE for a few days before merging. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got confused at the end so excuse if anything I commented on makes no sense ;)
some notes:
- i think this PR would have benefited from 2 commits, one which refactors loading, the other which refactors conversion/wrapping problems
- nitpick but most of the
, false)
postfixes could be probably removed, since most of the original code did also use the overloaded variants which set it to false by default.
ide/xml.text/src/org/netbeans/modules/xml/text/navigator/NavigatorTreeCellRenderer.java
Outdated
Show resolved
Hide resolved
java/refactoring.java/src/org/netbeans/modules/refactoring/java/WhereUsedBinaryElement.java
Outdated
Show resolved
Hide resolved
java/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/tree/FileTreeElement.java
Outdated
Show resolved
Hide resolved
.../org/netbeans/modules/javaee/project/api/ant/ui/logicalview/AbstractLogicalViewProvider.java
Outdated
Show resolved
Hide resolved
.../org/netbeans/modules/javaee/project/api/ant/ui/logicalview/AbstractLogicalViewProvider.java
Outdated
Show resolved
Hide resolved
...rc/org/netbeans/modules/java/api/common/project/ui/customizer/ClassPathListCellRenderer.java
Outdated
Show resolved
Hide resolved
php/php.project/src/org/netbeans/modules/php/project/ui/PathUiSupport.java
Outdated
Show resolved
Hide resolved
Thanks for useful reviews!
I see now that the changes around mergeImages can probably be removed, since mergeImages is smart enough to pick up the special implementations of Image and Icon by itself.
ImageUtilities has loadImage(String) and loadImage(String,boolean) but no loadIconImage(String), only loadIconImage(String,boolean). I think I will make a separate PR with some proposed new methods in ImageUtilities that can simplify some of these changes:
|
I proposed some new utility methods for ImageUtilities in #8114. One of these will let me change "loadImageIcon(path, false)" to just "loadIcon(path)" in most of the cases here. |
a27b089
to
8f8b150
Compare
…. (Commit 1: The simplest/most localized changes.) Replace most of the remaining trivial uses of the ImageIcon(Image) constructor, replacing these with ImageUtilities.image2Icon or ImageUtilities.loadImageIcon. This allows SVG icons, when/once present, to render in full resolution on HiDPI/Retina displays. Bitmap icons also benefit from the improved scaling hints applied by ImageUtilities. Similar work was done, for the platform module only, in apache#7472 . This commit covers most of the remaining trivial cases; I grepped the codebase for 'new ImageIcon' and adjusted the code to avoid ImageIcon whenever this could be done easily (not changing APIs, requiring only a visual code review).
…. (Commit 2: Slightly more complex cases, and mergeImages cases, separated out for ease of review.)
I have revised this PR now. Changes:
For those who reviewed a previous version of this PR, the changes that might need another look are in the second commit. The first commit was just edited mechanically from the patch file itself, to switch loadImageIcon to loadIcon and remove the ", false" second argument which is the default for loadIcon anyway. |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good. Left one question.
.../netbeans/modules/refactoring/java/ui/scope/CurrentJavaProjectDependenciesScopeProvider.java
Outdated
Show resolved
Hide resolved
btw @eirikbakke it might be better to wait a bit with merge, lets say until RC 2-3 - project wide refactoring can make it hard to sync changes back from delivery cc @ebarboni |
@mbien Yes, this can wait until the whole release is done, no hurry. Good to get it tested in dev builds first. |
…an be used instead of mergeImages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice simplifications
In previous PRs, e.g. #7463 and #8083, SVG versions of various NetBeans icons were added to look better on Retina/HiDPI monitors. ImageUtilities has supported automatic loading of SVG versions of icons since #1278 .
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. Uses of the latter must be replaced with e.g. ImageUtilities.image2Icon and ImageUtilities.loadImageIcon. Some such replacements were done in #7472 .
This PR replaces most of the remaining trivial uses of the ImageIcon(Image) constructor. This allows SVG icons, when/once present, to render in full resolution on HiDPI/Retina displays. Bitmap icons also benefit from the improved scaling hints applied by ImageUtilities.
While this PR touches many lines, the changes should be simple enough that they can be reviewed by simply reading over the diffs (rather than by opening every dialog, UI panel etc. in a running IDE). I will also run my working IDE with these changes for a while to see if I bump into any observable problems. It's not necessary to have a HiDPI screen to test this patch; merely seeing that there are no new exceptions etc. when running the IDE should be sufficient.
There are still many uses of the "new ImageIcon(String)" and "new ImageIcon(URL)" variations of the ImageIcon constructors. Removing these is left for future work.