import java.awt.Component;
import java.awt.Dimension;
-import java.awt.GraphicsEnvironment;
import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
: isMac);
}
- public static int SHORTCUT_KEY_MASK = (Platform.isMac() ? KeyEvent.META_DOWN_MASK : KeyEvent.CTRL_DOWN_MASK);
-
+ public static int SHORTCUT_KEY_MASK = (Platform.isMac()
+ ? KeyEvent.META_DOWN_MASK
+ : KeyEvent.CTRL_DOWN_MASK);
+
static
{
- // Using non-deprecated Extended key mask modifiers, but Java 8 has no
- // getMenuShortcutKeyMaskEx method
- Toolkit tk = Toolkit.getDefaultToolkit();
- Method method = null;
+ // Using non-deprecated Extended key mask modifiers, but Java 8 has no
+ // getMenuShortcutKeyMaskEx method
+ Toolkit tk = Toolkit.getDefaultToolkit();
+ Method method = null;
+ try
+ {
+ method = tk.getClass().getMethod("getMenuShortcutKeyMaskEx");
+ } catch (NoSuchMethodException e)
+ {
+ System.err.println(
+ "Could not find Toolkit method getMenuShortcutKeyMaskEx. Trying getMenuShortcutKeyMask.");
+ }
+ if (method == null)
+ {
try
{
- method = tk.getClass().getMethod("getMenuShortcutKeyMaskEx");
+ method = tk.getClass().getMethod("getMenuShortcutKeyMask");
} catch (NoSuchMethodException e)
{
System.err.println(
- "Could not find Toolkit method getMenuShortcutKeyMaskEx. Trying getMenuShortcutKeyMask.");
- }
- if (method == null)
- {
- try
- {
- method = tk.getClass().getMethod("getMenuShortcutKeyMask");
- } catch (NoSuchMethodException e)
- {
- System.err.println(
- "Could not find Toolkit method getMenuShortcutKeyMaskEx or getMenuShortcutKeyMask.");
- e.printStackTrace();
- }
+ "Could not find Toolkit method getMenuShortcutKeyMaskEx or getMenuShortcutKeyMask.");
+ e.printStackTrace();
}
- if (method != null)
+ }
+ if (method != null)
+ {
+ try
{
- try
- {
- method.setAccessible(true);
- SHORTCUT_KEY_MASK = ((int) method.invoke(tk, new Object[0]));
- } catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- if (SHORTCUT_KEY_MASK <= 0xF)
+ method.setAccessible(true);
+ SHORTCUT_KEY_MASK = ((int) method.invoke(tk, new Object[0]));
+ } catch (Exception e)
{
- // shift this into the extended region (was Java 8)
- SHORTCUT_KEY_MASK = SHORTCUT_KEY_MASK << 6;
+ e.printStackTrace();
}
}
+ if (SHORTCUT_KEY_MASK <= 0xF)
+ {
+ // shift this into the extended region (was Java 8)
+ SHORTCUT_KEY_MASK = SHORTCUT_KEY_MASK << 6;
+ }
}
/**
*/
protected static boolean isControlDown(MouseEvent e, boolean aMac)
{
-//
-// System.out.println(e.isPopupTrigger()
-// + " " + ((SHORTCUT_KEY_MASK & e.getModifiersEx()) != 0)
-// + " " + e.isControlDown());
- return (aMac ? !e.isPopupTrigger()
- && (SHORTCUT_KEY_MASK & e.getModifiersEx()) != 0
+ //
+ // System.out.println(e.isPopupTrigger()
+ // + " " + ((SHORTCUT_KEY_MASK & e.getModifiersEx()) != 0)
+ // + " " + e.isControlDown());
+ return (aMac
+ ? !e.isPopupTrigger()
+ && (SHORTCUT_KEY_MASK & e.getModifiersEx()) != 0
: e.isControlDown());
}
public static void getURLCommandArguments()
{
- try {
- /**
- * Retrieve the first query field as command arguments to Jalview. Include
- * only if prior to "?j2s" or "&j2s" or "#". Assign the applet's __Info.args
- * element to this value.
- *
- * @j2sNative var a =
- * decodeURI((document.location.href.replace("&","?").split("?j2s")[0]
- * + "?").split("?")[1].split("#")[0]); a &&
- * (J2S.thisApplet.__Info.args = a.split(" "));
- *
- * System.out.println("URL arguments: " + a);
- */
- } catch (Throwable t) {
+ try
+ {
+ /**
+ * Retrieve the first query field as command arguments to Jalview. Include
+ * only if prior to "?j2s" or "&j2s" or "#". Assign the applet's
+ * __Info.args element to this value.
+ *
+ * @j2sNative var a =
+ * decodeURI((document.location.href.replace("&","?").split("?j2s")[0]
+ * + "?").split("?")[1].split("#")[0]); a &&
+ * (J2S.thisApplet.__Info.args = a.split(" "));
+ *
+ * System.out.println("URL arguments: " + a);
+ */
+ } catch (Throwable t)
+ {
}
}
*
* @param frame
* a JFrame or JInternalFrame
- * @param type "name", "node", "init", "dim", or any DOM attribute, such as "id"
+ * @param type
+ * "name", "node", "init", "dim", or any DOM attribute, such as "id"
* @return null if frame is not embedded.
*/
public static Object getEmbeddedAttribute(Component frame, String type)
*/
public static String getAppID(String frameType)
{
-
+
String id = Jalview.getInstance().j2sAppletID;
if (id == null)
{
- Jalview.getInstance().j2sAppletID = id = (isJS ? (String) jsutil
- .getAppletAttribute("_id") : "jalview");
+ Jalview.getInstance().j2sAppletID = id = (isJS
+ ? (String) jsutil.getAppletAttribute("_id")
+ : "jalview");
}
return id + (frameType == null ? "" : "-" + frameType);
}
-
/**
* Option to avoid unnecessary seeking of nonexistent resources in JavaScript.
* Works in Java as well.