X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbin%2FHiDPISetting.java;h=e14c032b61930cb94b4b958826c38db60591b2c5;hb=e93bc0a7b2def06392a2f6b0f563c1e07fb917a1;hp=7a22607a60147e53ff83679f23ab59e5e790abdd;hpb=07d425923a64af71ce7d41a11061abd537e99276;p=jalview.git diff --git a/src/jalview/bin/HiDPISetting.java b/src/jalview/bin/HiDPISetting.java index 7a22607..e14c032 100644 --- a/src/jalview/bin/HiDPISetting.java +++ b/src/jalview/bin/HiDPISetting.java @@ -1,6 +1,27 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ package jalview.bin; import java.awt.HeadlessException; +import java.util.Locale; public class HiDPISetting { @@ -45,7 +66,7 @@ public class HiDPISetting static { String system = System.getProperty("os.name") == null ? null - : System.getProperty("os.name").toLowerCase(); + : System.getProperty("os.name").toLowerCase(Locale.ROOT); if (system != null) { isLinux = system.indexOf("linux") > -1; @@ -68,8 +89,17 @@ public class HiDPISetting // get and use command line property values first String setHiDPIProperty = System.getProperty(setHiDPIPropertyName); - setHiDPI = setHiDPIProperty != null - && setHiDPIProperty.equalsIgnoreCase("true"); + boolean setHiDPIPropertyBool = Boolean.parseBoolean(setHiDPIProperty); + + // allow -DsetHiDPI=false to turn off HiDPI scaling + if (setHiDPIProperty != null && !setHiDPIPropertyBool) + { + clear(); + doneInit = true; + return; + } + + setHiDPI = setHiDPIProperty != null && setHiDPIPropertyBool; String setHiDPIScaleProperty = System .getProperty(setHiDPIScalePropertyName); @@ -78,10 +108,17 @@ public class HiDPISetting try { setHiDPIScale = Integer.parseInt(setHiDPIScaleProperty); + // if setHiDPIScale property is validly set and setHiDPI property wasn't + // attempted to be set we assume setHiDPIScale to be true + if (setHiDPIProperty == null) + { + setHiDPI = true; + } } catch (NumberFormatException e) { - System.err.println(setHiDPIScalePropertyName + " property give (" - + setHiDPIScaleProperty + ") but not parseable as integer"); + jalview.bin.Console.errPrintln(setHiDPIScalePropertyName + + " property give (" + setHiDPIScaleProperty + + ") but not parseable as integer"); } } if (setHiDPI && setHiDPIScale > 0) @@ -98,8 +135,8 @@ public class HiDPISetting try { int existingPropertyVal = Integer.parseInt(existingProperty); - System.out.println("Existing " + scalePropertyName + " is " - + existingPropertyVal); + jalview.bin.Console.outPrintln("Existing " + scalePropertyName + + " is " + existingPropertyVal); if (existingPropertyVal > 1) { setHiDPIScale(existingPropertyVal); @@ -107,8 +144,9 @@ public class HiDPISetting } } catch (NumberFormatException e) { - System.out.println("Could not convert property " + scalePropertyName - + " vale '" + existingProperty + "' to number"); + jalview.bin.Console.outPrintln( + "Could not convert property " + scalePropertyName + + " vale '" + existingProperty + "' to number"); } } @@ -122,7 +160,11 @@ public class HiDPISetting dpi = screenInfo.getScreenResolution(); } catch (HeadlessException e) { - System.err.println("Cannot get screen resolution: " + e.getMessage()); + if (isLinux) + { + jalview.bin.Console.errPrintln( + "Cannot get screen resolution: " + e.getMessage()); + } } // try and get screen size height and width @@ -134,8 +176,12 @@ public class HiDPISetting mindimension = Math.min(height, width); } catch (HeadlessException e) { - System.err.println( - "Cannot get screen size height and width:" + e.getMessage()); + if (isLinux) + { + jalview.bin.Console + .errPrintln("Cannot get screen size height and width:" + + e.getMessage()); + } } // attempt at a formula for scaling based on screen dpi and mindimension. @@ -152,10 +198,12 @@ public class HiDPISetting int dimensionScale = 1 + (mindimension / bigScreenThreshold); // reject outrageous values -- dpiScale in particular could be mistaken - if (dpiScale > MAX_SCALE) { + if (dpiScale > MAX_SCALE) + { dpiScale = 1; } - if (dimensionScale > MAX_SCALE) { + if (dimensionScale > MAX_SCALE) + { dimensionScale = 1; }