/** A special classname that means 'use -jar code.jar' instead of a classname. */
public static final String MANIFEST_CLASS = "manifest";
+ /** Set this if SHIFT key is down -- reverts to the BACKUP_CONFIG_DIR ("install") */
+ private static boolean shiftKeyPressed = false;
+
/** Used to communicate information about the UI displayed when updating the application. */
public static final class UpdateInterface
{
} catch (Exception e) {
log.warning("Failure reading config file", "file", _config, e);
}
- if (config == null || config.getString("appbase") == null || config.getString("appbase").isEmpty()) {
+
+System.out.println("3 SHIFT key"+(getShiftKeyPressed()?"":" not")+" pressed");
+ if (getShiftKeyPressed() || config == null || config.getString("appbase") == null || config.getString("appbase").isEmpty()) {
+System.out.println("4 SHIFT key"+(getShiftKeyPressed()?"":" not")+" pressed");
try {
Config backupConfig = Config.parseConfig(_backupConfig, opts);
config = backupConfig;
public String getAppbase() {
return _appbase;
}
+
+ public static boolean getShiftKeyPressed() {
+ return shiftKeyPressed;
+ }
+
+ public static void setShiftKeyPressed(boolean down) {
+ shiftKeyPressed |= down;
+ }
+ public boolean isInstallationAppbase() {
+ // if not on the installation appbase, give half a second for SHIFT key to be pressed
+ Config.ParseOpts opts = null;
+ Config config = null;
+ try {
+ Config backupConfig = Config.parseConfig(_backupConfig, opts);
+System.out.println("1 SHIFT key"+(getShiftKeyPressed()?"":" not")+" pressed");
+ Thread.sleep(2000);
+System.out.println("2 SHIFT key"+(getShiftKeyPressed()?"":" not")+" pressed");
+ return (true || (config != null && backupConfig != null && backupConfig.getString("appbase") != null && (!backupConfig.getString("appbase").equals(config.getString("appbase")))));
+
+ } catch (NullPointerException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
protected final EnvConfig _envc;
protected File _config;
protected File _backupConfig;
package jalview.bin;
+import java.util.Locale;
+
import java.awt.HeadlessException;
public class HiDPISetting
public static int scale = 0;
+ public final static int MAX_SCALE = 8;
+
private static boolean doneInit = false;
private static boolean allowScalePropertyArg = false;
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;
// 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);
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 ("
int dimensionScale = 1 + (mindimension / bigScreenThreshold);
+ // reject outrageous values -- dpiScale in particular could be mistaken
+ if (dpiScale > MAX_SCALE) {
+ dpiScale = 1;
+ }
+ if (dimensionScale > MAX_SCALE) {
+ dimensionScale = 1;
+ }
+
// choose larger of dimensionScale or dpiScale (most likely dimensionScale
// as dpiScale often misreported)
int autoScale = Math.max(dpiScale, dimensionScale);
return allowScalePropertyArg ? getScalePropertyArg(scale) : null;
}
+ public static void setScaleProperty(int s)
+ {
+ System.setProperty(scalePropertyName, String.valueOf(s));
+ }
+
+ public static void setScaleProperty()
+ {
+ init();
+ if (allowScalePropertyArg)
+ {
+ setScaleProperty(scale);
+ }
+ }
+
public static void clear()
{
setHiDPI = false;
* @author bsoares
*
*/
+import java.util.Locale;
+
public class MemorySetting
{
public static final String MAX_HEAPSIZE_PERCENT_PROPERTY_NAME = "jvmmempc";
if (jvmmemmax != null && jvmmemmax.length() > 0)
{
long multiplier = 1;
- switch (jvmmemmax.toLowerCase().substring(jvmmemmax.length() - 1))
+ switch (jvmmemmax.toLowerCase(Locale.ROOT).substring(jvmmemmax.length() - 1))
{
case "t":
multiplier = 1099511627776L; // 2^40
import java.awt.Container;
import java.awt.Image;
import java.awt.event.ActionEvent;
+import java.awt.event.KeyListener;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import com.threerings.getdown.util.StringUtil;
import static com.threerings.getdown.Log.log;
import jalview.bin.StartupNotificationListener;
+import jalview.bin.HiDPISetting;
/**
* The main application entry point for Getdown.
*/
public class GetdownApp
{
+ // try and set HiDPISetting property immediately
+ static {
+ HiDPISetting.setScaleProperty();
+ }
+
public static String startupFilesParameterString = "";
/**
* The main entry point of the Getdown launcher application.
Getdown app = new Getdown(envc) {
@Override
protected Container createContainer () {
+System.out.println("0 Creating Container");
// create our user interface, and display it
if (_frame == null) {
_frame = new JFrame("");
handleWindowClose();
}
});
+
+ // look for SHIFT key presses and set flag in Application
+ _frame.addKeyListener(
+ new KeyListener() {
+ @Override
+ public void keyPressed(KeyEvent e) {
+ if (e.getKeyCode() == KeyEvent.VK_SHIFT) {
+ Application.setShiftKeyPressed(true);
+ //_app.
+ }
+ }
+ @Override
+ public void keyReleased(KeyEvent e) {
+ }
+ @Override
+ public void keyTyped(KeyEvent e) {
+ }
+ }
+ );
+
// this cannot be called in configureContainer as it is only allowed before the
// frame has been displayed for the first time
_frame.setUndecorated(_ifc.hideDecorations);
if [ x$JVLVERSION != x ]; then
export VERSION=$JVLVERSION
else
- export VERSION=1.8.3-1.2.10_JVL
+ export VERSION=1.8.3-1.3.0_JVL
fi
if [ x${VERSION%_JVL} = x$VERSION ]; then
return allowScalePropertyArg ? getScalePropertyArg(scale) : null;
}
+ public static void setScaleProperty(int s)
+ {
+ System.setProperty(scalePropertyName, String.valueOf(s));
+ }
+
+ public static void setScaleProperty()
+ {
+ init();
+ if (allowScalePropertyArg)
+ {
+ setScaleProperty(scale);
+ }
+ }
+
public static void clear()
{
setHiDPI = false;