JAL-3130 JAL-3007 Added gradle build for Java 11 and additional taskbar icon change...
authorBen Soares <bsoares@dundee.ac.uk>
Mon, 1 Apr 2019 08:53:21 +0000 (09:53 +0100)
committerBen Soares <bsoares@dundee.ac.uk>
Mon, 1 Apr 2019 08:53:21 +0000 (09:53 +0100)
.gitignore
getdown/lib/getdown-core-1.8.3-SNAPSHOT.jar [new file with mode: 0644]
getdown/lib/getdown-launcher.jar [new file with mode: 0644]
resources/images/jalview_logo_background_fade-640x480.png [new file with mode: 0644]
resources/images/jalview_logos.ico [new file with mode: 0644]
resources/install4j/DS_Store [new file with mode: 0644]
resources/install4j/jalview_dmg_background.png [new file with mode: 0644]
resources/install4j/jalview_dmg_background.xcf [new file with mode: 0644]
src/jalview/bin/Jalview.java
src/jalview/bin/Launcher.java [new file with mode: 0644]

index 211ddc9..eea1c5e 100644 (file)
@@ -17,3 +17,12 @@ TESTNG
 /benchmarking/lib
 *.class
 /site
+/gradle/jalview/build
+/gradle/jalview/.gradle
+/.gradle
+/utils/HelpLinksChecker.out
+/.settings
+/getdown/website
+/getdown/full_app
+/getdown/files
+/.classpath
diff --git a/getdown/lib/getdown-core-1.8.3-SNAPSHOT.jar b/getdown/lib/getdown-core-1.8.3-SNAPSHOT.jar
new file mode 100644 (file)
index 0000000..ed61abf
Binary files /dev/null and b/getdown/lib/getdown-core-1.8.3-SNAPSHOT.jar differ
diff --git a/getdown/lib/getdown-launcher.jar b/getdown/lib/getdown-launcher.jar
new file mode 100644 (file)
index 0000000..f39be5b
Binary files /dev/null and b/getdown/lib/getdown-launcher.jar differ
diff --git a/resources/images/jalview_logo_background_fade-640x480.png b/resources/images/jalview_logo_background_fade-640x480.png
new file mode 100644 (file)
index 0000000..4b65200
Binary files /dev/null and b/resources/images/jalview_logo_background_fade-640x480.png differ
diff --git a/resources/images/jalview_logos.ico b/resources/images/jalview_logos.ico
new file mode 100644 (file)
index 0000000..ba2ca82
Binary files /dev/null and b/resources/images/jalview_logos.ico differ
diff --git a/resources/install4j/DS_Store b/resources/install4j/DS_Store
new file mode 100644 (file)
index 0000000..374da46
Binary files /dev/null and b/resources/install4j/DS_Store differ
diff --git a/resources/install4j/jalview_dmg_background.png b/resources/install4j/jalview_dmg_background.png
new file mode 100644 (file)
index 0000000..139fb2b
Binary files /dev/null and b/resources/install4j/jalview_dmg_background.png differ
diff --git a/resources/install4j/jalview_dmg_background.xcf b/resources/install4j/jalview_dmg_background.xcf
new file mode 100644 (file)
index 0000000..aab616a
Binary files /dev/null and b/resources/install4j/jalview_dmg_background.xcf differ
index cc41c53..cda02fc 100755 (executable)
@@ -41,6 +41,8 @@ import jalview.util.MessageManager;
 import jalview.util.Platform;
 import jalview.ws.jws2.Jws2Discoverer;
 
+import java.awt.Image;
+import java.awt.Taskbar;
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileOutputStream;
@@ -335,6 +337,29 @@ public class Jalview
     {
       desktop = new Desktop();
       desktop.setInBatchMode(true); // indicate we are starting up
+
+      if (Taskbar.isTaskbarSupported())
+      {
+        Taskbar tb = Taskbar.getTaskbar();
+        if (tb.isSupported(Taskbar.Feature.ICON_IMAGE))
+        {
+          try
+          {
+            java.net.URL url = getClass()
+                    .getResource("/images/JalviewLogo_Huge.png");
+            if (url != null)
+            {
+              Image image = java.awt.Toolkit.getDefaultToolkit()
+                      .createImage(url);
+              tb.setIconImage(image);
+            }
+          } catch (Exception e)
+          {
+            e.printStackTrace();
+          }
+        }
+      }
+
       desktop.setVisible(true);
       desktop.startServiceDiscovery();
       if (!aparser.contains("nousagestats"))
diff --git a/src/jalview/bin/Launcher.java b/src/jalview/bin/Launcher.java
new file mode 100644 (file)
index 0000000..b595b4f
--- /dev/null
@@ -0,0 +1,119 @@
+package jalview.bin;
+
+import java.io.File;
+import java.lang.management.ManagementFactory;
+import java.lang.management.OperatingSystemMXBean;
+import java.util.ArrayList;
+
+public class Launcher
+{
+
+  private final static String startClass = "jalview.bin.Jalview";
+
+  private final static int maxHeapSizePerCent = 95;
+
+  private final static String dockIconPath = "JalviewLogo_Huge.png";
+
+  public static void main(String[] args)
+  {
+    final String javaBin = System.getProperty("java.home") + File.separator
+            + "bin" + File.separator + "java";
+
+    ArrayList<String> command = new ArrayList<>();
+    command.add(javaBin);
+
+    boolean isAMac = System.getProperty("os.name").indexOf("Mac") > -1;
+
+    for (String jvmArg : ManagementFactory.getRuntimeMXBean()
+            .getInputArguments())
+    {
+      command.add(jvmArg);
+    }
+    command.add("-cp");
+    command.add(ManagementFactory.getRuntimeMXBean().getClassPath());
+    ArrayList<String> arguments = new ArrayList<>();
+    for (String arg : args)
+    {
+      arguments.add(arg);
+    }
+
+    // add memory setting if not specified
+    boolean memSet = false;
+    boolean dockIcon = false;
+    ARG: for (int i = 0; i < command.size(); i++)
+    {
+      String arg = command.get(i);
+      if (arg.startsWith("-Xmx"))
+      {
+        memSet = true;
+      }
+      else if (arg.startsWith("-Xdock:icon"))
+      {
+        dockIcon = true;
+      }
+    }
+
+    if (!memSet)
+    {
+      long maxMemLong = -1;
+      long physicalMem = getPhysicalMemory();
+      if (physicalMem > 0)
+      {
+        maxMemLong = physicalMem * maxHeapSizePerCent / 100;
+      }
+      if (maxMemLong > 0)
+      {
+        command.add("-Xmx" + Long.toString(maxMemLong));
+      }
+    }
+
+    if (!dockIcon)
+    {
+      command.add("-Xdock:icon=" + dockIconPath);
+      // -Xdock:name=... doesn't actually work :(
+      // Leaving it in in case it gets fixed
+      command.add("-Xdock:name=" + "Jalview");
+    }
+
+    command.add(startClass);
+    command.addAll(arguments);
+
+    final ProcessBuilder builder = new ProcessBuilder(command);
+
+    System.out.println("COMMAND: " + String.join(" ", builder.command()));
+
+    try
+    {
+      builder.inheritIO();
+      builder.start();
+    } catch (Exception e)
+    {
+      e.printStackTrace();
+    }
+    // System.exit(0);
+
+  }
+
+  public static long getPhysicalMemory()
+  {
+    final OperatingSystemMXBean o = ManagementFactory
+            .getOperatingSystemMXBean();
+
+    try
+    {
+      if (o instanceof com.sun.management.OperatingSystemMXBean)
+      {
+        final com.sun.management.OperatingSystemMXBean osb = (com.sun.management.OperatingSystemMXBean) o;
+        return osb.getTotalPhysicalMemorySize();
+      }
+    } catch (NoClassDefFoundError e)
+    {
+      // com.sun.management.OperatingSystemMXBean doesn't exist in this JVM
+      System.out.println("No com.sun.management.OperatingSystemMXBean");
+    }
+
+    // We didn't get a com.sun.management.OperatingSystemMXBean.
+    return -1;
+  }
+
+}