From: Ben Soares Date: Thu, 23 Nov 2023 20:07:42 +0000 (+0000) Subject: JAL-4059 Storing important thisApplet information in java. Some CSS loading indicators. X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=c07cdd787ce23af4e965103256b22b23233c8d8c;p=jalview.git JAL-4059 Storing important thisApplet information in java. Some CSS loading indicators. --- diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 4770ebd..d2fab5c 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -657,103 +657,7 @@ public class Desktop extends jalview.jbgui.GDesktop if (Platform.isJS()) { - final String ns = JalviewJSUtil.getJ2sNamespace(); - if (ns != null) - { - final String jalviewjsDesktopElementId = "testApplet_LayeredPaneUI_10_8div"; - final String nsc = ns + (ns.length() > 0 ? ":" : ""); - final String nsu = ns + (ns.length() > 0 ? "_" : ""); - final String splashId = nsc + "jalviewjsSplash"; - final String splashClassActive = nsu + "jalviewjsSplashActive"; - final String splashClassInactive = nsu + "jalviewjsSplashInactive"; - final String splashClassHidden = nsu + "jalviewjsSplashHidden"; - final String j2s_overflow = JalviewJSUtil - .getJ2sInfoValue("overflow"); - /** - * @j2sNative // splash element disappearance - * - * function sleep(ms) { - * - * return new Promise(resolve => setTimeout(resolve, ms)); - * - * } - * - * var splashElement = document.getElementById(splashId); - * - * if (splashElement !== undefined) { - * - * splashElement.classList.remove(splashClassActive); - * - * splashElement.classList.add(splashClassInactive); - * - * async function hideSplash() { - * - * await sleep(5000); - * - * splashElement.classList.add(splashClassHidden); - * - * } - * - * hideSplash(); - * - * } - * - * // overflow setting - * - * async function changeVisibility() { - * - * var desktopElement = null; - * - * var timeCount = 0; - * - * var setCount = 0; - * - * var stayedSetCount = 0; - * - * while ((desktopElement == null || setCount < 5) && - * timeCount < 50 && stayedSetCount < 5) { - * - * await sleep(100); - * - * if (desktopElement == null) { - * - * desktopElement = - * document.getElementById(jalviewjsDesktopElementId); - * - * } - * - * if (desktopElement !== undefined && desktopElement !== - * null) { - * - * if (desktopElement.style.overflow == "hidden") { - * - * desktopElement.style.overflow = "visible"; - * - * setCount++; - * - * stayedSetCount = 0; - * - * } else { - * - * stayedSetCount++; - * - * } - * - * } - * - * timeCount++; - * - * } - * - * } - * - * if (new String(j2s_overflow).substring(0,4) === "true") { - * - * changeVisibility(); - * - * } - */ - } + JalviewJSUtil.setJ2SLoadedCSS(); // used for jalviewjsTest jalview.bin.Console.info("JALVIEWJS: CREATED DESKTOP"); } diff --git a/src/jalview/util/JalviewJSUtil.java b/src/jalview/util/JalviewJSUtil.java index 0b95cdb..e176ba7 100644 --- a/src/jalview/util/JalviewJSUtil.java +++ b/src/jalview/util/JalviewJSUtil.java @@ -41,6 +41,14 @@ public class JalviewJSUtil "height", "serverURL", "j2sPath", "console" }; /** + * Key values to get from thisApplet + */ + private static final String j2sIdKey = "_id"; + + private static final String[] j2sAppletKeys = { j2sIdKey, "_j2sPath", + "_j2sFullPath" }; + + /** * The prefix for non-named keys in the Info={} block */ private static final String j2sParameterPrefix = "j2s_"; @@ -96,7 +104,6 @@ public class JalviewJSUtil || Arrays.asList(j2sSavedKeys).contains(key))) { j2sInfo.put(key, val); - if (key.equals(j2sNamespaceKey)) { setJ2sNamespace(val); @@ -109,6 +116,54 @@ public class JalviewJSUtil * * } */ + + // Now set important parameters from the J2S.thisApplet object + key = null; + val = null; + /** + * @j2sNative if (J2S.thisApplet !== undefined) { + * + * Object.entries(J2S.thisApplet).forEach( entry => { + * + * key = entry[0]; + * + * val = entry[1]; + */ + if (key != null && Arrays.asList(j2sAppletKeys).contains(key)) + { + j2sInfo.put(key, val); + if (key.equals(j2sIdKey)) + { + setJ2sId(val); + } + } + /** + * @j2sNative } + * + * ); + * + * } + */ + } + + /** + * Applet ID + */ + private static String j2sId = null; + + private static void setJ2sId(String id) + { + if (!Platform.isJS()) + { + return; + } + Console.outPrintln("j2sId set to '" + id + "'"); + j2sId = id; + } + + public static String getJ2sId() + { + return j2sId; } /** @@ -252,4 +307,104 @@ public class JalviewJSUtil } } + public static void setJ2SLoadedCSS() + { + final String ns = JalviewJSUtil.getJ2sNamespace(); + if (ns != null) + { + final String jalviewjsDesktopElementId = getJ2sId() + + "_LayeredPaneUI_10_8div"; + final String nsc = ns + (ns.length() > 0 ? ":" : ""); + final String nsu = ns + (ns.length() > 0 ? "_" : ""); + final String splashId = nsc + "jalviewjsSplash"; + final String splashClassActive = nsu + "jalviewjsSplashActive"; + final String splashClassInactive = nsu + "jalviewjsSplashInactive"; + final String splashClassFinal = nsu + "jalviewjsSplashFinal"; + final String j2s_overflow = JalviewJSUtil.getJ2sInfoValue("overflow"); + /** + * @j2sNative // splash element disappearance + * + * function sleep(ms) { + * + * return new Promise(resolve => setTimeout(resolve, ms)); + * + * } + * + * var splashElement = document.getElementById(splashId); + * + * if (splashElement !== undefined) { + * + * splashElement.classList.remove(splashClassActive); + * + * splashElement.classList.add(splashClassInactive); + * + * async function hideSplash() { + * + * await sleep(5000); + * + * splashElement.classList.add(splashClassFinal); + * + * } + * + * hideSplash(); + * + * } + * + * // overflow setting + * + * async function changeVisibility() { + * + * var desktopElement = null; + * + * var timeCount = 0; + * + * var setCount = 0; + * + * var stayedSetCount = 0; + * + * while ((desktopElement == null || setCount < 5) && timeCount + * < 50 && stayedSetCount < 5) { + * + * await sleep(100); + * + * if (desktopElement == null) { + * + * desktopElement = + * document.getElementById(jalviewjsDesktopElementId); + * + * } + * + * if (desktopElement !== undefined && desktopElement !== null) + * { + * + * if (desktopElement.style.overflow == "hidden") { + * + * desktopElement.style.overflow = "visible"; + * + * setCount++; + * + * stayedSetCount = 0; + * + * } else { + * + * stayedSetCount++; + * + * } + * + * } + * + * timeCount++; + * + * } + * + * } + * + * if (new String(j2s_overflow).substring(0,4) === "true") { + * + * changeVisibility(); + * + * } + */ + } + } } diff --git a/utils/jalviewjs/site-resources/jalview_bin_Jalview-namespace.html b/utils/jalviewjs/site-resources/jalview_bin_Jalview-namespace.html index 779c967..0114267 100644 --- a/utils/jalviewjs/site-resources/jalview_bin_Jalview-namespace.html +++ b/utils/jalviewjs/site-resources/jalview_bin_Jalview-namespace.html @@ -42,14 +42,14 @@ Info = { opacity: 0%; transition: opacity 1s; } -.jv_jalviewjsSplashHidden { +.jv_jalviewjsSplashFinal { display: none; }
@@ -58,7 +58,7 @@ getClassList = function(){J2S._saveFile('_j2sclasslist.txt', Clazz.ClassFilesLoa
-This is System.out. clear it start/stop profiling
see ___j2sflags.htm for SwingJS URL command-line options
get _j2sClassList.txt +This is System.out. clear it start/stop profiling
see ___j2sflags.htm for SwingJS URL command-line options
get _j2sClassList.txt diff --git a/utils/jalviewjs/site-resources/jalview_bin_JalviewJS-corenamespace.html b/utils/jalviewjs/site-resources/jalview_bin_JalviewJS-corenamespace.html index cb58e91..c140192 100644 --- a/utils/jalviewjs/site-resources/jalview_bin_JalviewJS-corenamespace.html +++ b/utils/jalviewjs/site-resources/jalview_bin_JalviewJS-corenamespace.html @@ -31,34 +31,68 @@ Info = { transform: rotate(360deg); } } -.jv_jalviewjsSplashRotate { - animation: rotation 6s infinite cubic-bezier(0.4, 0.6, 0.6, 0.4); +@keyframes pulse { + 0% { + transform: scale(1); + } + 50% { + transform: scale(0.85); + } + 100% { + transform: scale(1); + } } -.jv_jalviewjsSplashActive { +.jv1_jalviewjsSplashRotate { + animation: rotation 3s infinite cubic-bezier(0.4, 0.6, 0.6, 0.4); +} +.jv1_jalviewjsSplashActive { display: visible; opacity: 100%; + z-index: 100; } -.jv_jalviewjsSplashInactive { +.jv1_jalviewjsSplashInactive { opacity: 0%; transition: opacity 1s; + z-index: 100; } -.jv_jalviewjsSplashHidden { +.jv1_jalviewjsSplashFinal { display: none; } + +.jv_jalviewjsSplashRotate { + animation: pulse 1s cubic-bezier(0.4, 0.6, 0.6, 0.4); + animation-iteration-count: infinite; + animation-fill-mode: forwards; +} +.jv_jalviewjsSplashActive { + z-index: 100; +} +.jv_jalviewjsSplashInactive { + animation-iteration-count: 1; + animation-fill-mode: forwards; + opacity: 30%; + transition: all 1s; + z-index: 100; +} +.jv_jalviewjsSplashFinal { + z-index: -1; + opacity: 30%; +} +
-
+
-This is System.out. clear it start/stop profiling
see ___j2sflags.htm for SwingJS URL command-line options
get _j2sClassList.txt +This is System.out. clear it start/stop profiling
see ___j2sflags.htm for SwingJS URL command-line options
get _j2sClassList.txt