*/
package jalview.util;
-import jalview.javascript.json.JSON;
-
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import java.io.BufferedReader;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
+import jalview.javascript.json.JSON;
+
/**
* System platform information used by Applet and Application
*
false;
private static Boolean isNoJSMac = null, isNoJSWin = null, isMac = null,
- isWin = null;
+ isWin = null, isLinux = null;
private static Boolean isHeadless = null;
+ // If launched from CLI with launcher script then -DCOLUMNWIDTH is set
+ private static final int CONSOLEWIDTH;
+
+ private static final String CONSOLEWIDTHPROPERTY = "CONSOLEWIDTH";
+
+ static
+ {
+ int cw = 80;
+ if (System.getProperty(CONSOLEWIDTHPROPERTY) != null
+ && System.getProperty(CONSOLEWIDTHPROPERTY).length() > 0)
+ {
+ try
+ {
+ cw = Integer.parseInt(System.getProperty(CONSOLEWIDTHPROPERTY));
+ } catch (NumberFormatException e)
+ {
+ }
+ }
+ CONSOLEWIDTH = cw;
+ }
+
/**
* added to group mouse events into Windows and nonWindows (mac, unix, linux)
*
}
/**
+ * added to check LaF for Linux
+ *
+ * @return
+ */
+ public static boolean isLinux()
+ {
+ return (isLinux == null
+ ? (isLinux = (System.getProperty("os.name")
+ .indexOf("Linux") >= 0))
+ : isLinux);
+ }
+
+ /**
*
* @return true if HTML5 JavaScript
*/
time = mark = t;
if (msg != null)
{
- System.err.println("Platform: timer reset\t\t\t" + msg);
+ jalview.bin.Console.errPrintln("Platform: timer reset\t\t\t" + msg);
}
break;
case TIME_MARK:
}
if (msg != null)
{
- System.err.println("Platform: timer mark\t" + ((t - time) / 1000f)
+ jalview.bin.Console.errPrintln("Platform: timer mark\t" + ((t - time) / 1000f)
+ "\t" + ((t - mark) / 1000f) + "\t" + msg);
}
mark = t;
case TIME_GET:
if (msg != null)
{
- System.err.println("Platform: timer dur\t" + ((t - time) / 1000f)
+ jalview.bin.Console.errPrintln("Platform: timer dur\t" + ((t - time) / 1000f)
+ "\t" + ((duration) / 1000f) + "\t" + msg);
}
set = 0;
public static byte[] getFileBytes(File f)
{
- return /** @j2sNative f && swingjs.JSUtil.getFileBytes$java_io_File(f) || */
+ return /** @j2sNative f && swingjs.JSUtil.getFileAsBytes$O(f) || */
null;
}
* info[key];
*/
- System.out.println(
+ jalview.bin.Console.outPrintln(
"Platform id=" + id + " reading Info." + key + " = " + value);
p.put(id + "_" + key, value);
public static Object parseJSON(String json) throws ParseException
{
- return (isJS() ? JSON.parse(json)
- : new JSONParser().parse(json));
+ return (isJS() ? JSON.parse(json) : new JSONParser().parse(json));
}
public static Object parseJSON(Reader r)
* @param is
* @param outFile
* @throws IOException
- * if the file cannot be created or there is a problem
- * reading the input stream.
+ * if the file cannot be created or there is a problem reading the
+ * input stream.
*/
public static void streamToFile(InputStream is, File outFile)
throws IOException
if (isJS())
{
- System.out.println(
- "Platform adding known access-control-allow-origin * for domain "
- + domain);
+ jalview.bin.Console.outPrintln(
+ "Platform adding known access-control-allow-origin * for domain "
+ + domain);
/**
* @j2sNative
*
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
*
* @j2sNative var a =
* decodeURI((document.location.href.replace("&","?").split("?j2s")[0]
- * + "?").split("?")[1].split("#")[0]); a && (System.out.println("URL arguments detected were "+a) &&
- * (J2S.thisApplet.__Info.urlargs = a.split(" "))
- * (!!J2S.thisApplet.__Info.args || J2S.thisApplet.__Info.args == "" || J2S.thisApplet.__Info.args == "??") && (J2S.thisApplet.__Info.args = a) && (System.out.println("URL arguments were passed to J2S main.");
+ * + "?").split("?")[1].split("#")[0]); a &&
+ * (jalview.bin.Console.outPrintln("URL arguments detected were "+a)) &&
+ * (J2S.thisApplet.__Info.urlargs = a.split(" "));
+ * (!J2S.thisApplet.__Info.args || J2S.thisApplet.__Info.args
+ * == "" || J2S.thisApplet.__Info.args == "??") &&
+ * (J2S.thisApplet.__Info.args = a) && (jalview.bin.Console.outPrintln("URL
+ * arguments were passed to J2S main."));
*/
} catch (Throwable t)
{
}
/**
- * A (case sensitive) file path comparator that ignores the difference between /
- * and \
+ * A (case sensitive) file path comparator that ignores the difference between
+ * / and \
*
* @param path1
* @param path2
String p2 = path2.replace('\\', '/');
return p1.equals(p2);
}
+
+ /**
+ * If started on command line using launch script, return the console width
+ */
+ public static int consoleWidth()
+ {
+ return CONSOLEWIDTH;
+ }
}