Mercurial > hg > Members > riono > TreeVNC_ja_comment
view src/main/java/jp/ac/u_ryukyu/treevnc/test/IsRetina.java @ 409:0aab561a8cf4
Return retina scale
author | innparusu |
---|---|
date | Thu, 19 Nov 2015 14:43:30 +0900 |
parents | b6665f7f18d1 |
children | effba48b76f3 |
line wrap: on
line source
package jp.ac.u_ryukyu.treevnc.test; import java.awt.*; import java.awt.image.BufferedImage; import java.lang.reflect.Field; /** * Created by one on 15/08/18. */ public class IsRetina { public static final int isRetina = getRetinaScale(); private static int getRetinaScale() { //other OS and JVM specific checks... int scale = 1; GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); final GraphicsDevice device = env.getDefaultScreenDevice(); try { Field field = device.getClass().getDeclaredField("scale"); if (field != null) { field.setAccessible(true); Object retinaScale = field.get(device); if (retinaScale instanceof Integer) { scale = ((Integer)retinaScale).intValue(); return scale; } } } catch (Exception ignore) {} //... return scale; } public static void main(String args[]) { System.out.println(isRetina); } }