+ jsFunctionExec = jsFunctionExec2;\r
+ }\r
+\r
+ /**\r
+ * return the given colour value parameter or the given default if parameter\r
+ * not given\r
+ * \r
+ * @param colparam\r
+ * @param defcolour\r
+ * @return\r
+ */\r
+ public Color getDefaultColourParameter(String colparam, Color defcolour)\r
+ {\r
+ String colprop = getParameter(colparam);\r
+ if (colprop == null || colprop.trim().length() == 0)\r
+ {\r
+ return defcolour;\r
+ }\r
+ Color col = jalview.schemes.ColourSchemeProperty\r
+ .getAWTColorFromName(colprop);\r
+ if (col == null)\r
+ {\r
+ try\r
+ {\r
+ col = new jalview.schemes.UserColourScheme(colprop).findColour('A');\r
+ } catch (Exception ex)\r
+ {\r
+ System.err.println("Couldn't parse '" + colprop\r
+ + "' as a colour for " + colparam);\r
+ col = null;\r
+ }\r
+ }\r
+ return (col == null) ? defcolour : col;\r
+\r
+ }\r
+\r
+ public void openJalviewHelpUrl()\r
+ {\r
+ String helpUrl = getParameter("jalviewhelpurl");\r
+ if (helpUrl == null || helpUrl.trim().length() < 5)\r
+ {\r
+ helpUrl = "http://www.jalview.org/help.html";\r
+ }\r
+ showURL(helpUrl, "HELP");\r
+ }\r
+\r
+ /**\r
+ * form a complete URL given a path to a resource and a reference location on\r
+ * the same server\r
+ * \r
+ * @param url\r
+ * - an absolute path on the same server as localref or a document\r
+ * located relative to localref\r
+ * @param localref\r
+ * - a URL on the same server as url\r
+ * @return a complete URL for the resource located by url\r
+ */\r
+ private String resolveUrlForLocalOrAbsolute(String url, URL localref)\r
+ {\r
+ String codebase = localref.toString();\r
+ if (url.indexOf("/") == 0)\r
+ {\r
+ url = codebase.substring(0, codebase.length()\r
+ - localref.getFile().length())\r
+ + url;\r
+ }\r
+ else\r
+ {\r
+ url = localref + url;\r
+ }\r
+ return url;\r
+ }\r
+\r
+ /**\r
+ * open a URL in the browser - resolving it according to relative refs and\r
+ * coping with javascript: protocol if necessary.\r
+ * \r
+ * @param url\r
+ * @param target\r
+ */\r
+ public void showURL(String url, String target)\r
+ {\r
+ try\r
+ {\r
+ if (url.indexOf(":") == -1)\r
+ {\r
+ // TODO: verify (Bas Vroling bug) prepend codebase or server URL to\r
+ // form valid URL\r
+ // Should really use docbase, not codebase.\r
+ URL prepend;\r
+ url = resolveUrlForLocalOrAbsolute(\r
+ url,\r
+ prepend = getDefaultParameter("resolvetocodebase", false) ? getDocumentBase()\r
+ : getCodeBase());\r
+ if (debug)\r
+ {\r
+ System.err\r
+ .println("Show url (prepended "\r
+ + prepend\r
+ + " - toggle resolvetocodebase if code/docbase resolution is wrong): "\r
+ + url);\r
+ }\r
+ }\r
+ else\r
+ {\r
+ if (debug)\r
+ {\r
+ System.err.println("Show url: " + url);\r
+ }\r
+ }\r
+ if (url.indexOf("javascript:") == 0)\r
+ {\r
+ // no target for the javascript context\r
+ getAppletContext().showDocument(new java.net.URL(url));\r
+ }\r
+ else\r
+ {\r
+ getAppletContext().showDocument(new java.net.URL(url), target);\r
+ }\r
+ } catch (Exception ex)\r
+ {\r
+ ex.printStackTrace();\r
+ }\r