From 5741a86e2baec7b85500f885419f32763a0bfd91 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Thu, 23 Nov 2023 15:04:52 +0000 Subject: [PATCH] JAL-4059 rename vars to j2s_ this and that for clarity --- src/jalview/bin/Jalview.java | 70 ++++++++++++++------ src/jalview/gui/Desktop.java | 16 ++--- src/jalview/util/Platform.java | 2 +- .../jalview_bin_Jalview-corenamespace.html | 38 +++++++++-- .../jalview_bin_Jalview-namespace.html | 20 +++--- 5 files changed, 100 insertions(+), 46 deletions(-) diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index 4eed72f..d0a8be3 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -312,7 +312,7 @@ public class Jalview implements JalviewObjectI } else { - setJSInfo(); + setJ2sInfo(); } if (args == null || args.length == 0 || (args.length == 1 @@ -2100,29 +2100,57 @@ public class Jalview implements JalviewObjectI } /** - * Info dict set by instantiating JalviewJS + * To be populated by Info={} hash set by instantiating JalviewJS */ - private Map JSInfo = null; + private Map j2sInfo = null; - private final String[] JSSavedKeys = { "main", "core", "width", "height", + /** + * The non-j2s_-prefixed parameters to store + */ + private final String[] j2sSavedKeys = { "main", "core", "width", "height", "serverURL", "j2sPath", "console" }; - private final String JSSavedKeysPrefix = "js_"; + /** + * The prefix for non-named keys in the Info={} block + */ + private static final String j2sParameterPrefix = "j2s_"; - private final String JSNamespaceKey = JSSavedKeysPrefix + "namespace"; + /** + * The Info key name for namespacing (query string parameters, class and id + * values) + */ + private static final String j2sNamespaceKey = j2sParameterPrefix + + "namespace"; - public String getJSInfoValue(String key) + /** + * Get a value passed in from the Info={} hash. key should NOT use the + * namespace prefix. + * + * @param key + * key name without the j2s_ namespace in the Info={} hash. + * @return value value from the Info={} hash. + */ + public String getJ2sInfoValue(String key) { - return JSInfo == null ? null : JSInfo.get(key); + if (j2sInfo == null || key == null) + { + return null; + } + String j2sKey = Arrays.asList(j2sSavedKeys).contains(key) ? key + : j2sParameterPrefix + key; + return j2sInfo.get(j2sKey); } - public void setJSInfo() + /** + * Get and save parameters and values from the Info={} hash. + */ + public void setJ2sInfo() { if (!Platform.isJS()) { return; } - JSInfo = new HashMap<>(); + j2sInfo = new HashMap<>(); String key = null; String val = null; /** @@ -2134,14 +2162,14 @@ public class Jalview implements JalviewObjectI * * val = entry[1]; */ - if (key != null && (key.startsWith(JSSavedKeysPrefix) - || Arrays.asList(JSSavedKeys).contains(key))) + if (key != null && (key.startsWith(j2sParameterPrefix) + || Arrays.asList(j2sSavedKeys).contains(key))) { - JSInfo.put(key, val); + j2sInfo.put(key, val); - if (key.equals(JSNamespaceKey)) + if (key.equals(j2sNamespaceKey)) { - setJSNamespace(val); + setJ2sNamespace(val); } } /** @@ -2156,20 +2184,20 @@ public class Jalview implements JalviewObjectI /** * Namespace (if set) by JalviewJS */ - private String JSNamespace = null; + private String j2sNamespace = null; - private void setJSNamespace(String ns) + private void setJ2sNamespace(String ns) { if (!Platform.isJS()) { return; } - Console.outPrintln("JSNamespace set to '" + ns + "'"); - JSNamespace = ns; + Console.outPrintln("j2sNamespace set to '" + ns + "'"); + j2sNamespace = ns; } - public String getJSNamespace() + public String getJ2sNamespace() { - return JSNamespace; + return j2sNamespace; } } diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 8211dcb..ad989af 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -656,18 +656,18 @@ public class Desktop extends jalview.jbgui.GDesktop if (Platform.isJS()) { - final String ns = Jalview.getInstance().getJSNamespace(); + final String ns = Jalview.getInstance().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 + "jalviewSplash"; - final String splashClassActive = nsu + "jalviewSplashActive"; - final String splashClassInactive = nsu + "jalviewSplashInactive"; - final String splashClassHidden = nsu + "jalviewSplashHidden"; - final String js_overflow = Jalview.getInstance() - .getJSInfoValue("js_overflow"); + final String splashId = nsc + "jalviewjsSplash"; + final String splashClassActive = nsu + "jalviewjsSplashActive"; + final String splashClassInactive = nsu + "jalviewjsSplashInactive"; + final String splashClassHidden = nsu + "jalviewjsSplashHidden"; + final String j2s_overflow = Jalview.getInstance() + .getJ2sInfoValue("overflow"); /** * @j2sNative // splash element disappearance * @@ -746,7 +746,7 @@ public class Desktop extends jalview.jbgui.GDesktop * * } * - * if (new String(js_overflow).substring(0,4) === "true") { + * if (new String(j2s_overflow).substring(0,4) === "true") { * * changeVisibility(); * diff --git a/src/jalview/util/Platform.java b/src/jalview/util/Platform.java index 52a1bcf..87e308e 100644 --- a/src/jalview/util/Platform.java +++ b/src/jalview/util/Platform.java @@ -667,7 +667,7 @@ public class Platform * if namespace is not defined then use the old style single first * parameter for arguments * - * @j2sNative var namespace = J2S.thisApplet.__Info.js_namespace; + * @j2sNative var namespace = J2S.thisApplet.__Info.j2s_namespace; * * if (namespace === undefined) * diff --git a/utils/jalviewjs/site-resources/jalview_bin_Jalview-corenamespace.html b/utils/jalviewjs/site-resources/jalview_bin_Jalview-corenamespace.html index bfcf8ea..fbe7ad2 100644 --- a/utils/jalviewjs/site-resources/jalview_bin_Jalview-corenamespace.html +++ b/utils/jalviewjs/site-resources/jalview_bin_Jalview-corenamespace.html @@ -17,19 +17,45 @@ Info = { j2sPath: 'swingjs/j2s', console:'sysoutdiv', allowjavascript: true, - namespace: "jv" + // all j2s_... values can be accessed in Jalview.getInstance().getJSInfoValue(key) + j2s_namespace: "jv", + j2s_overflow: true } +
-
-
- +
+
+
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_Jalview-namespace.html b/utils/jalviewjs/site-resources/jalview_bin_Jalview-namespace.html index cf95a42..779c967 100644 --- a/utils/jalviewjs/site-resources/jalview_bin_Jalview-namespace.html +++ b/utils/jalviewjs/site-resources/jalview_bin_Jalview-namespace.html @@ -17,9 +17,9 @@ Info = { j2sPath: 'swingjs/j2s', console:'sysoutdiv', allowjavascript: true, - // all js_... values can be accessed in Jalview.getInstance().getJSInfoValue(key) - js_namespace: "jv", - js_overflow: true + // all j2s_... values can be accessed in Jalview.getInstance().getJSInfoValue(key) + j2s_namespace: "jv", + j2s_overflow: true }
-
+
-- 1.7.10.2