timing code
[jalview.git] / src / jalview / util / Platform.java
index f34849e..1f03f88 100644 (file)
@@ -21,7 +21,6 @@
 package jalview.util;
 
 import java.awt.Toolkit;
-import java.awt.event.InputEvent;
 import java.awt.event.MouseEvent;
 
 import javax.swing.SwingUtilities;
@@ -34,15 +33,18 @@ import javax.swing.SwingUtilities;
 public class Platform
 {
 
-  private static Boolean isNoJSMac = null, isNoJSWin = null, isMac = null, isWin = null;
+  private static boolean isJS = /** @j2sNative true || */false;
 
+  private static Boolean isNoJSMac = null, isNoJSWin = null, 
+                 isMac = null, isWin = null;
+  
   private static Boolean isHeadless = null;
 
   /**
    * added to group mouse events into Windows and nonWindows (mac, unix, linux)
    * @return
    */
-  public static boolean isMac() 
+  public static boolean isMac()
   {
          return (isMac == null ? (isMac = (System.getProperty("os.name").indexOf("Mac") >= 0)) : isMac);
   }
@@ -57,6 +59,15 @@ public class Platform
   }
 
   /**
+   * 
+   * @return true if HTML5 JavaScript
+   */
+  public static boolean isJS()
+  {
+       return isJS;
+  }
+
+  /**
    * sorry folks - Macs really are different
    * 
    * BH: disabled for SwingJS -- will need to check key-press issues
@@ -65,7 +76,7 @@ public class Platform
    */
   public static boolean isAMacAndNotJS()
   {
-       return (isNoJSMac == null ? (isNoJSMac = /** @j2sNative false && */isMac()) : isNoJSMac);
+       return (isNoJSMac == null ? (isNoJSMac = !isJS && isMac()) : isNoJSMac);
   }
 
 /**
@@ -75,7 +86,7 @@ public class Platform
    */
   public static boolean isWindowsAndNotJS()
   {
-       return (isNoJSWin == null ? (isNoJSWin = /** @j2sNative false && */isWin()) : isNoJSWin);
+       return (isNoJSWin == null ? (isNoJSWin = !isJS && isWin()) : isNoJSWin);
    }
 
   /**
@@ -182,4 +193,31 @@ public class Platform
        // was !isAMac(), but that is true also for Linux and Unix and JS
          return isWin() && SwingUtilities.isMiddleMouseButton(e);
   }
+
+  public static boolean allowMnemonics() 
+  {
+       return !isMac();
+  }
+  
+  public final static int TIME_RESET = 0;
+  public final static int TIME_MARK  = 1;
+  
+  public static long time, mark;
+  
+  public static void timeCheck(String msg, int mode) {
+         switch (mode) {
+         case TIME_RESET:
+                 time = mark = System.currentTimeMillis();
+                 System.err.println("Platform: timer reset\t\t\t" + msg);
+                 break;
+         case TIME_MARK:
+                 long t = System.currentTimeMillis();
+                 if (time == 0)
+                         time = mark = t;
+                 System.err.println("Platform: timer mark\t" + ((t - time)/1000f) + "\t" + ((t - mark)/1000f) + "\t" + msg);
+                 mark = t;
+                 break;
+         }
+  }
+   
 }