+ try
+ {
+ setHiDPIScale = Integer.parseInt(setHiDPIScaleProperty);
+ } catch (NumberFormatException e)
+ {
+ System.err.println(setHiDPIScalePropertyName + " property give ("
+ + setHiDPIScaleProperty + ") but not parseable as integer");
+ }
+ }
+
+ // try and get screen resolution
+ try
+ {
+ dpi = Toolkit.getDefaultToolkit().getScreenResolution();
+ } catch (Throwable t)
+ {
+ System.err.println("Cannot get screen resolution");
+ }
+
+ // try and get screen size height and width
+ try
+ {
+ int height = Toolkit.getDefaultToolkit().getScreenSize().height;
+ int width = Toolkit.getDefaultToolkit().getScreenSize().width;
+ // using maxdimension in case of portrait screens
+ maxdimension = Math.max(height, width);
+ } catch (Throwable t)
+ {
+ System.err.println("Cannot get screen size height and width");
+ }
+
+ if (setHiDPI && setHiDPIScale > 0)
+ {
+ scale = setHiDPIScale;
+ }
+ else
+ {
+ // attempt at a formula for scaling based on screen dpi and maxdimension.
+ // scale
+ // will be an integer >=1
+ if (dpi > 0 && maxdimension > 0)
+ {
+ scale = Math.min(dpi / hidpiThreshold,
+ maxdimension / tallScreenThreshold) + 1;
+ }
+ else if (dpi == 0 && maxdimension > tallScreenThreshold)
+ {
+ // dpi couldn't be found but the screen has a large vertical pixel count
+ scale = maxdimension / tallScreenThreshold + 1;
+ }
+ /* do nothing if maxdimension == 0 -- might be just a small HD screen (e.g. Gemini PDA)
+ else if (maxdimension == 0 && dpi > hidpiThreshold)
+ {
+ }
+ */
+ }
+
+ // only make a change if scale is changed and other conditions (OS is linux)
+ // apply, or if setHiDPI has been specified
+ allowScalePropertyArg = (scale > 1 && isLinux) || setHiDPI;
+
+ if (allowScalePropertyArg)
+ {
+ System.out.println("boolean setHiDPI=" + setHiDPI);