On Wed, 16 Mar 2022 05:36:04 GMT, Sergey Bylokhov <s...@openjdk.org> wrote:
>>> This might be a rookie question: >>> >>> When it comes to modifying and restoring a Graphics, I've seen two common >>> patterns: A. Call `newG = g.create()` and later `newG.dispose()` B. Call >>> `g.setX(newValue)` and then call `g.setX(oldValue)` later >>> >>> Is there guidance on when to use which? Or is one always preferred? >> >> Usually i follow the rule of minimal action. When i need to set a lot of >> hints that needs to be later unrolled such as changing graphics coordinates >> and such - i'm creating a new Graphics. When i only need to manipulate a >> single hint and it can easily be unrolled - i am using the same object. In >> this case i'm changing just a single hint. > > I am not sure that this is the right place to change the hints. > If we want to always scale the icon using the bicubic interpolation then it > is better to do it where we call the paintIcon() method in some > jcomponent(this probably may be configured by some option - similar to the > text antialisaing). But it will affect performance since the bicubic is much > slower. > > But before discussing this shared code change could you please provide some > info on why it worked fine before? Why we try to downscale the image and do > not get an exact size from the native. I suggest to recheck the issues described above, updating the shared implementation of `ImageIcon.java` seems wrong ------------- PR: https://git.openjdk.java.net/jdk/pull/7805