From d891897b082f5483159db17e46d2a5910a593512 Mon Sep 17 00:00:00 2001 From: BobHanson Date: Thu, 19 Mar 2020 08:08:02 -0500 Subject: [PATCH] JAL-3560 moving JS-specific code to Platform, fix Platform.streamToFile --- src/jalview/gui/StructureViewer.java | 5 ++--- src/jalview/util/Platform.java | 24 +++++++++++++++--------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/jalview/gui/StructureViewer.java b/src/jalview/gui/StructureViewer.java index dc5d77d..17b786d 100644 --- a/src/jalview/gui/StructureViewer.java +++ b/src/jalview/gui/StructureViewer.java @@ -53,8 +53,7 @@ public class StructureViewer static { - Platform.loadStaticResource("core/core_jvjmol.z.js", - "org.jmol.viewer.Viewer"); + Platform.ensureJmol(); } private static final String UNKNOWN_VIEWER_TYPE = "Unknown structure viewer type "; @@ -69,7 +68,7 @@ public class StructureViewer public enum ViewerType { JMOL, CHIMERA - }; + } /** * Constructor diff --git a/src/jalview/util/Platform.java b/src/jalview/util/Platform.java index 121ac1b..d9241b8 100644 --- a/src/jalview/util/Platform.java +++ b/src/jalview/util/Platform.java @@ -22,7 +22,6 @@ package jalview.util; import jalview.javascript.json.JSON; -import java.awt.Color; import java.awt.Dimension; import java.awt.Toolkit; import java.awt.event.MouseEvent; @@ -574,17 +573,18 @@ public class Platform public static void streamToFile(InputStream is, File outFile) throws IOException { + if (isJS() && /** + * JSTempFile direct transfer + * + * @j2sNative outFile.setBytes$O && outFile.setBytes$O(is) && + */ + true) + { + return; + } FileOutputStream fio = new FileOutputStream(outFile); try { - if (isJS() - && /** - * @j2sNative outFile.setBytes$O && outFile.setBytes$O(is) && - */ - true) - { - return; - } byte[] bb = new byte[32 * 1024]; int l; while ((l = is.read(bb)) > 0) @@ -700,6 +700,11 @@ public class Platform */ } + public static void ensureJmol() + { + loadStaticResource("core/core_jvjmol.z.js", "org.jmol.viewer.Viewer"); + } + public static void ensureRegex() { loadStaticResource("core/core_stevesoft.z.js", @@ -839,4 +844,5 @@ public class Platform } + } -- 1.7.10.2