How to know, whether HiDPI is supported?

Robert Krüger krueger at lesspain.de
Sat Nov 30 04:04:38 PST 2013


Don't the scale factors depend on the individual user's retina
settings? Of course, your approach will also work if that is the case,
it will just require some more checks.

On Fri, Nov 29, 2013 at 11:26 PM, Eirik Bakke <ebakke at mit.edu> wrote:
> This did the trick for me:
>
> // g is the Graphics2D object fed to the paint() or paintComponent()
> method of your Swing component.
> g.getFontRenderContext().getTransform().equals(AffineTransform.getScaleInst
> ance(2.0, 2.0))
>
>
> It uses no private APIs, and has the advantage that it lets you make the
> retina-or-not decision on a component-to-component basis (or in practice,
> on a window-to-window basis, as all components in the same window have the
> same FontRenderContext). This means if your user has one window on their
> retina laptop screen and another on their non-retina external monitor,
> both will render appropriately for their respective devices (I've
> confirmed this to work on Java 1.7.0_45 for MacOS X 10.8.5).
>
> -- Eirik
>
> On 11/29/13, 7:36 AM, "Hendrik Schreiber" <hs at tagtraum.com> wrote:
>
>>Hey..
>>
>>with some of the Retina work appearing in 1.7.0_60, what is the
>>recommended way for the developer to find out, whether images are/can be
>>scaled, i.e., whether we are dealing with a HiDPI display.
>>
>>In the past, on the Apple JVM, we used:
>>
>>       final Float scaleFactor = (Float)
>>Toolkit.getDefaultToolkit().getDesktopProperty("apple.awt.contentScaleFact
>>or");
>>
>>Is there an equivalent?
>>
>>I very much appreciate that you are pushing some of the work down to
>>1.7.0_60. Can you say what parts should now/soon work and how to use them?
>>
>>Thank you,
>>
>>-hendrik
>


More information about the macosx-port-dev mailing list