+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.bin;
-import java.awt.HeadlessException;
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;
// 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);
*/
package jalview.bin;
+import java.util.Locale;
+
/**
* Methods to decide on appropriate memory setting for Jalview based on two
* optionally provided values: jvmmempc - the maximum percentage of total
* @author bsoares
*
*/
-import java.util.Locale;
-
public class MemorySetting
{
public static final String MAX_HEAPSIZE_PERCENT_PROPERTY_NAME = "jvmmempc";
public static String memoryLongToString(long mem)
{
- return memoryLongToString(mem, "%.1f");
+ return memoryLongToString(mem, "%.3f");
}
public static String memoryLongToString(long mem, String format)
return ADJUSTMENT_MESSAGE;
}
-}
\ No newline at end of file
+}
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.bin;
import java.awt.Toolkit;
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.util;
import java.awt.Image;
defaultProps.put("default_appbase",
"https://www.jalview.org/getdown/release/1.8");
defaultProps.put("preferences.filename", ".jalview_properties");
+ defaultProps.put("channel", "none");
// load channel_properties
Properties tryChannelProps = new Properties();
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.Properties;
public class LaunchUtils
{
return Boolean.parseBoolean(getUserPreference(key));
}
+
+ public static int JAVA_COMPILE_VERSION = 0;
+
+ public static int getJavaCompileVersion()
+ {
+ if (JAVA_COMPILE_VERSION > 0)
+ {
+ return JAVA_COMPILE_VERSION;
+ }
+ String buildDetails = "jar:".concat(LaunchUtils.class
+ .getProtectionDomain().getCodeSource().getLocation().toString()
+ .concat("!" + "/.build_properties"));
+ try
+ {
+ URL localFileURL = new URL(buildDetails);
+ InputStream in = localFileURL.openStream();
+ Properties buildProperties = new Properties();
+ buildProperties.load(in);
+ in.close();
+ String JCV = buildProperties.getProperty("JAVA_COMPILE_VERSION",
+ null);
+ if (JCV == null)
+ {
+ System.out.println(
+ "Could not obtain JAVA_COMPILE_VERSION for comparison");
+ return -2;
+ }
+ JAVA_COMPILE_VERSION = Integer.parseInt(JCV);
+ } catch (MalformedURLException e)
+ {
+ System.err.println("Could not find " + buildDetails);
+ return -3;
+ } catch (IOException e)
+ {
+ System.err.println("Could not load " + buildDetails);
+ return -4;
+ } catch (NumberFormatException e)
+ {
+ System.err.println("Could not parse JAVA_COMPILE_VERSION");
+ return -5;
+ }
+
+ return JAVA_COMPILE_VERSION;
+ }
+
+ public static int JAVA_VERSION = 0;
+
+ public static int getJavaVersion()
+ {
+ if (JAVA_VERSION > 0)
+ {
+ return JAVA_VERSION;
+ }
+ try
+ {
+ String JV = System.getProperty("java.version");
+ if (JV == null)
+ {
+ System.out.println("Could not obtain java.version for comparison");
+ return -2;
+ }
+ if (JV.startsWith("1."))
+ {
+ JV = JV.substring(2);
+ }
+ JAVA_VERSION = JV.indexOf(".") == -1 ? Integer.parseInt(JV)
+ : Integer.parseInt(JV.substring(0, JV.indexOf(".")));
+ } catch (NumberFormatException e)
+ {
+ System.err.println("Could not parse java.version");
+ return -3;
+ }
+ return JAVA_VERSION;
+ }
+
+ public static boolean checkJavaVersion()
+ {
+ String buildDetails = "jar:".concat(LaunchUtils.class
+ .getProtectionDomain().getCodeSource().getLocation().toString()
+ .concat("!" + "/.build_properties"));
+
+ int java_compile_version = getJavaCompileVersion();
+ int java_version = getJavaVersion();
+
+ if (java_compile_version <= 0 || java_version <= 0)
+ {
+ System.out.println("Could not make Java version check");
+ return true;
+ }
+ // Warn if these java.version and JAVA_COMPILE_VERSION conditions exist
+ // Usually this means a Java 11 compiled JAR being run by a Java 11 JVM
+ if (java_version >= 11 && java_compile_version < 11)
+ {
+ return false;
+ }
+
+ return true;
+ }
}
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
+import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class StringUtils
{
return s.toUpperCase(Locale.ROOT);
}
- return s.substring(0, 1).toUpperCase(Locale.ROOT) + s.substring(1).toLowerCase(Locale.ROOT);
+ return s.substring(0, 1).toUpperCase(Locale.ROOT)
+ + s.substring(1).toLowerCase(Locale.ROOT);
}
/**
}
return min < text.length() + 1 ? min : -1;
}
+
+ public static int indexOfFirstWhitespace(String text)
+ {
+ int index = -1;
+ Pattern pat = Pattern.compile("\\s");
+ Matcher m = pat.matcher(text);
+ if (m.find())
+ {
+ index = m.start();
+ }
+ return index;
+ }
+
+ /*
+ * implementation of String.replaceLast.
+ * Replaces only the last occurrence of toReplace in string with replacement.
+ */
+ public static String replaceLast(String string, String toReplace,
+ String replacement)
+ {
+ int pos = string.lastIndexOf(toReplace);
+ if (pos > -1)
+ {
+ return new StringBuilder().append(string.substring(0, pos))
+ .append(replacement)
+ .append(string.substring(pos + toReplace.length()))
+ .toString();
+ }
+ else
+ {
+ return string;
+ }
+
+ }
+
+ /*
+ * return the maximum length of a List of Strings
+ */
+ public static int maxLength(List<String> l)
+ {
+ int max = 0;
+ for (String s : l)
+ {
+ if (s == null)
+ continue;
+ if (s.length() > max)
+ max = s.length();
+ }
+ return max;
+ }
}
{
private final static String startClass = "jalview.bin.Jalview";
- private final static String dockIconPath = ChannelProperties
- .getProperty("logo.512");
-
private static boolean checkJVMSymlink(String testBin)
{
File testBinFile = new File(testBin);
{
if (!dockIcon)
{
+ String dockIconPath = System.getProperty("getdownappdir", ".")
+ + File.separator + "resource/jalview_logo.png";
command.add("-Xdock:icon=" + dockIconPath);
}
if (!dockName)
# quote the args and the command (in case of spaces) with escape chars (`) and precede with & to indicate command not string
if ( $myArgs.count -eq 0 ) {
- Invoke-Expression -Command "& `"${JAVA}`" `"-DCONSOLEWIDTH=${CONSOLEWIDTH}`" -cp `"${CLASSPATH}`" jalview.bin.Launcher"
+ Invoke-Expression -Command "& `"${JAVA}`" `"-DCONSOLEWIDTH=${CONSOLEWIDTH}`" `"-Dgetdownappdir=${APPDIR}`" -cp `"${CLASSPATH}`" jalview.bin.Launcher"
} else {
$myArgsString = '"' + $($myArgs -join '" "') + '"'
- Invoke-Expression -Command "& `"${JAVA}`" `"-DCONSOLEWIDTH=${CONSOLEWIDTH}`" -cp `"${CLASSPATH}`" jalview.bin.Launcher ${myArgsString}"
+ Invoke-Expression -Command "& `"${JAVA}`" `"-DCONSOLEWIDTH=${CONSOLEWIDTH}`" `"-Dgetdownappdir=${APPDIR}`" -cp `"${CLASSPATH}`" jalview.bin.Launcher ${myArgsString}"
}
declare -a JARPATHS=()
if [ -e "${GETDOWNTXT}" ]; then
# always check grep and sed regexes on macos -- they're not the same
- for JAR in $(grep -e '^code\s*=\s*' "${GETDOWNTXT}" | sed -e 's/^code\s*=\s*//;'); do
+for JAR in $(grep -e '^code[[:space:]]*=[[:space:]]*' "${GETDOWNTXT}" | while read -r line; do echo $line | sed -E -e 's/code[[:space:]]*=[[:space:]]*//;'; done);
+ do
[ -n "${CLASSPATH}" ] && CLASSPATH="${CLASSPATH}:"
CLASSPATH="${CLASSPATH}${APPDIR}/${JAR}"
JARPATHS=( "${JARPATHS[@]}" "${APPDIR}/${JAR}" )
COLUMNS=$(resize -u | grep COLUMNS= | sed -e 's/.*=//;s/;//') 2>/dev/null
fi
JVMARGS=( "${JVMARGS[@]}" "-DCONSOLEWIDTH=${COLUMNS}" )
+JVMARGS=( "${JVMARGS[@]}" "-Dgetdownappdir=${APPDIR}" )
# Is there a bundled Java? If not just try one in the PATH (do need .exe in WSL)
if [ \! -e "${JAVA}" ]; then
<file name="${compiler:JALVIEW_APPLICATION_NAME}.app/Contents/Resources/Jalview-File.icns" file="${compiler:JALVIEW_DIR}/${compiler:INSTALL4J_UTILS_DIR}/Jalview-File.icns" />
<file name="${compiler:JALVIEW_APPLICATION_NAME}.app/Contents/Resources/jvl_file.icns" file="${compiler:JALVIEW_DIR}/${compiler:INSTALL4J_UTILS_DIR}/jvl_file.icns" />
<symlink name="${compiler:JALVIEW_APPLICATION_NAME}.app/Contents/MacOS/${compiler:WRAPPER_LINK}" target="../Resources/app/${compiler:WRAPPER_SCRIPT_BIN_DIR}/${compiler:BASH_WRAPPER_SCRIPT}" />
+ <symlink name="${compiler:JALVIEW_APPLICATION_NAME}.app/Contents/Resources/app/jre/Contents/Home/bin/${compiler:JALVIEW_APPLICATION_NAME}" target="java" />
+ <symlink name="${compiler:JALVIEW_APPLICATION_NAME}.app/Contents/Resources/app/jre/Contents/Home/bin/Jalview" target="java" />
</topLevelFiles>
</macosArchive>
<macosArchive name="macOS aarch64 Disk Image" id="2796" customizedId="MACOS-AARCH64-DMG" mediaFileName="${compiler:APPLICATION_FOLDER}-${compiler:JALVIEW_VERSION}-${compiler:sys.platform}-aarch64-java_${compiler:JAVA_INTEGER_VERSION}" volumeName="${compiler:INSTALLER_NAME}" architecture="aarch64" launcherId="737" setupAppId="2746">
<file name="${compiler:JALVIEW_APPLICATION_NAME}.app/Contents/Resources/Jalview-File.icns" file="${compiler:JALVIEW_DIR}/${compiler:INSTALL4J_UTILS_DIR}/Jalview-File.icns" />
<file name="${compiler:JALVIEW_APPLICATION_NAME}.app/Contents/Resources/jvl_file.icns" file="${compiler:JALVIEW_DIR}/${compiler:INSTALL4J_UTILS_DIR}/jvl_file.icns" />
<symlink name="${compiler:JALVIEW_APPLICATION_NAME}.app/Contents/MacOS/${compiler:WRAPPER_LINK}" target="../Resources/app/${compiler:WRAPPER_SCRIPT_BIN_DIR}/${compiler:BASH_WRAPPER_SCRIPT}" />
+ <symlink name="${compiler:JALVIEW_APPLICATION_NAME}.app/Contents/Resources/app/jre/Contents/Home/bin/${compiler:JALVIEW_APPLICATION_NAME}" target="java" />
+ <symlink name="${compiler:JALVIEW_APPLICATION_NAME}.app/Contents/Resources/app/jre/Contents/Home/bin/Jalview" target="java" />
</topLevelFiles>
</macosArchive>
<unixInstaller name="Linux x64 Shell Installer" id="1595" customizedId="LINUX-X64-SH" mediaFileName="${compiler:UNIX_APPLICATION_FOLDER}-${compiler:JALVIEW_VERSION}-linux-x64-java_${compiler:JAVA_INTEGER_VERSION}" installDir="${compiler:UNIX_APPLICATION_FOLDER}" customInstallBaseDir="~/opt/">