MCPcopy Create free account
hub / github.com/ArtifexSoftware/mupdf / getRetinaScale

Method getRetinaScale

platform/java/example/Viewer.java:1912–1939  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1910 }
1911
1912 public float getRetinaScale() {
1913 // first try Oracle's VM (we should also test for 1.7.0_40 or higher)
1914 final String vendor = System.getProperty("java.vm.vendor");
1915 boolean isOracle = vendor != null && vendor.toLowerCase().contains("Oracle".toLowerCase());
1916 if (isOracle) {
1917 GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
1918 final GraphicsDevice device = env.getDefaultScreenDevice();
1919 try {
1920 Field field = device.getClass().getDeclaredField("scale");
1921 if (field != null) {
1922 field.setAccessible(true);
1923 Object scale = field.get(device);
1924 if (scale instanceof Integer && ((Integer)scale).intValue() == 2)
1925 return 2.0f;
1926 }
1927 }
1928 catch (Exception ignore) {
1929 }
1930 return 1.0f;
1931 }
1932
1933 // try Apple VM
1934 final Float scaleFactor = (Float)Toolkit.getDefaultToolkit().getDesktopProperty("apple.awt.contentScaleFactor");
1935 if (scaleFactor != null && scaleFactor.intValue() == 2)
1936 return 2.0f;
1937
1938 return 1.0f;
1939 }
1940
1941 public int getScreenDPI() {
1942 try {

Callers 1

ViewerMethod · 0.95

Calls 2

containsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected