How will resolution independence be handled in jdk8?

Stephan Aßmus superstippi at gmx.de
Mon Apr 29 03:53:01 PDT 2013


On 29.04.2013 12:15, Artem Ananiev wrote:
> As you wrote above, @2x looks like a hack. Although we can support
> something like this in JDK7/8, I would prefer to have clear API to
> handle different scale factors. For example, API to listen for Window's
> graphics configuration changes and getter for the current scale factor
> value. In this case, application will be able to load a new image for
> the new scale factor and assign it to the button. A little piece of
> trivial code vs magic NSImage:// images.
>
> Of course, if we decide to provide any new public APIs, it can only be
> done in JDK8 or later. JDK7 API is frozen.

 From what I read about the Swing and Graphics2D APIs, it would appear 
to me that all that is already supported since ages. There is a virtual, 
point-based coordinate system in which all drawing commands are 
interpreted, and there is API to get to the current scaling factor and 
actual device resolution. I.e. a way to convert between virtual 
coordinates and pixels.

There are two problems:

1) This stuff doesn't actually appear to be used. The documentation says 
that unit to pixel conversion is 1:1 for monitors which have a 
resolution close to 72 dpi. This simply isn't true, I never saw anything 
else besides 1:1, even though I have monitors well above 72 dpi.

2) There is a certain appeal to being able to specify multiple 
resultions for a bitmap based graphics resource, and have the system 
choose the appropriate resource depending on the needs - automatically. 
I think this what the JButton use-case would need.

Best regards,
-Stephan





More information about the macosx-port-dev mailing list