package jalview.bin;
+import jalview.gui.Preferences;
+
import java.util.HashMap;
import java.util.Map;
+import java.util.Vector;
/**
* Collection of all known applet tags from JalviewLite
{
private final static String[] params = { "alignpdbfiles",
- "ANNOTATIONCOLOUR_MAX", "ANNOTATIONCOLOUR_MIN", "annotations",
+ Preferences.ANNOTATIONCOLOUR_MAX, Preferences.ANNOTATIONCOLOUR_MIN,
+ "annotations",
"APPLICATION_URL", "automaticScrolling", "centrecolumnlabels",
"debug", "defaultColour", "defaultColourNuc", "defaultColourProt",
"embedded", "enableSplitFrame", "externalstructureviewer", "features",
put("_code", code);
}
+ public AppletParams()
+ {
+ // TODO Auto-generated constructor stub
+ }
+
+ public static AppletParams getAppletParams(String[] args,
+ Vector<String> vargs)
+ {
+ AppletParams appletParams = new AppletParams();
+ String resourcePath = null;
+ for (int i = args.length; --i > 0;) // > 0 is correct, not >=0
+ {
+ if (args[i].startsWith("name=\"Info.resourcePath\""))
+ {
+ resourcePath = getAttr(args[i], "value");
+ if (resourcePath.length() > 0 && !resourcePath.endsWith("/"))
+ {
+ resourcePath += "/";
+ }
+ break;
+ }
+ }
+ for (int i = 1; i < args.length; i++)
+ {
+ String arg = args[i].trim();
+ if (arg.startsWith("name="))
+ {
+ String appName = getAttr(arg, "name");
+ String value = getAttr(arg, "value");
+ String appletName = appName.toLowerCase();
+
+ // note that Application arguments ARE case-sensitive, but
+ // Applet.getParameter() is not.
+
+ switch (appletName)
+ {
+
+ // tested, working:
+
+ case "file":
+ appName = "open";
+ value = resourcePath + value;
+ appletName = null;
+ break;
+ case "file2":
+ value = resourcePath + value;
+ appName = null;
+ break;
+ case "jnetfile":
+ value = resourcePath + value;
+ appName = null;
+ break;
+ case "jpredfile":
+ value = resourcePath + value;
+ appName = null;
+ break;
+ case "features":
+ value = resourcePath + value;
+ appName = null;
+ break;
+ case "pdbfile":
+ value = resourcePath + value;
+ appName = null;
+ break;
+ case "tree":
+ case "treefile":
+ appName = "tree";
+ value = resourcePath + value;
+ appletName = null; // taken care of by Jalview
+ break;
+ case "defaultcolour":
+ appName = Preferences.DEFAULT_COLOUR;
+ break;
+ case "defaultcolournuc":
+ appName = Preferences.DEFAULT_COLOUR_NUC;
+ break;
+ case "defaultcolourprot":
+ appName = Preferences.DEFAULT_COLOUR_PROT;
+ break;
+
+ // implemented; not tested:
+
+ case "oninit":
+ appName = null;
+ break;
+ case "annotations":
+ value = resourcePath + value;
+ appName = null;
+ break;
+ case "annotationcolour_max":
+ appName = Preferences.ANNOTATIONCOLOUR_MAX;
+ break;
+ case "annotationcolour_min":
+ appName = Preferences.ANNOTATIONCOLOUR_MIN;
+ break;
+ case "enablesplitframe":
+ appName = Preferences.ENABLE_SPLIT_FRAME;
+ break;
+ case "hidefeaturegroups":
+ break;
+ case "centrecolumnlabels":
+ appName = null;
+ break;
+ case "pdbseq":
+ appName = null;
+ break;
+ case "sortby":
+ appName = Preferences.SORT_ALIGNMENT; // id, etc.
+ break;
+ case "sortbytree":
+ appName = Preferences.SORT_BY_TREE;
+ value = checkTF(value);
+ appletName = null; // taken care of by Jalview
+ break;
+ case "format":
+ break;
+
+ // probably not relevant:
+
+ case "externalstructureviewer":
+ break;
+ case "alignpdbfiles":
+ break;
+ case "application_url":
+ appName = "APPLICATION_URL";
+ break;
+ case "automaticscrolling":
+ appName = "automaticScrolling";
+ break;
+ case "heightscale":
+ appName = "heightScale";
+ break;
+ case "jalviewhelpurl":
+ break;
+ case "label":
+ break;
+ case "linklabel_":
+ appName = "linkLabel_";
+ break;
+ case "linklabel_1":
+ appName = "linkLabel_1";
+ break;
+ case "linkurl_":
+ appName = "linkURL_";
+ break;
+ case "rgb":
+ appName = null; // no background for application
+ break;
+
+ // unknown:
+
+ case "nojmol":
+ break;
+ case "normaliselogo":
+ appName = Preferences.NORMALISE_LOGO;
+ break;
+ case "normalisesequencelogo":
+ appName = Preferences.NORMALISE_CONSENSUS_LOGO;
+ break;
+ case "relaxedidmatch":
+ break;
+ case "resolvetocodebase":
+ break;
+ case "scaleproteinascdna":
+ appName = "scaleProteinAsCdna";
+ break;
+ case "separator":
+ break;
+ case "sequence":
+ break;
+ case "uppercase":
+ appName = "upperCase";
+ break;
+ case "userdefinedcolour":
+ appName = "colour";
+ break;
+ case "widthscale":
+ appName = "widthScale";
+ break;
+ case "windowheight":
+ appName = "windowHeight";
+ break;
+ case "windowwidth":
+ appName = "windowWidth";
+ break;
+ case "wrap":
+ appName = Preferences.WRAP_ALIGNMENT;
+ break;
+ case "scorefile":
+ appName = "scoreFile";
+ value = resourcePath + value;
+ break;
+
+ // TRUE/FALSE
+
+ case "debug":
+ value = checkTF(value);
+ break;
+ case "embedded":
+ value = checkTF(value);
+ break;
+ case "showbutton":
+ value = checkTF(value);
+ break;
+ case "showannotation":
+ appName = Preferences.SHOW_ANNOTATIONS;
+ value = checkTF(value);
+ break;
+ case "showconsensus":
+ appName = Preferences.SHOW_CONSENSUS_LOGO;
+ value = checkTF(value);
+ break;
+ case "showconsensushistogram":
+ appName = Preferences.SHOW_CONSENSUS_HISTOGRAM;
+ value = checkTF(value);
+ break;
+ case "showconservation":
+ appName = Preferences.SHOW_CONSERVATION;
+ value = checkTF(value);
+ break;
+ case "showgroupconsensus":
+ appName = Preferences.SHOW_GROUP_CONSENSUS;
+ value = checkTF(value);
+ break;
+ case "showgroupconservation":
+ appName = Preferences.SHOW_GROUP_CONSERVATION;
+ value = checkTF(value);
+ break;
+ case "showoccupancy":
+ appName = Preferences.SHOW_OCCUPANCY;
+ value = checkTF(value);
+ break;
+ case "showquality":
+ appName = Preferences.SHOW_QUALITY;
+ value = checkTF(value);
+ break;
+ case "showsequencelogo":
+ appName = Preferences.SHOW_CONSENSUS_LOGO;
+ value = checkTF(value);
+ break;
+ case "showfeaturegroups":
+ value = checkTF(value);
+ break;
+ case "showfeaturesettings":
+ appName = "showFeatureSettings";
+ value = checkTF(value);
+ break;
+ case "showfullid":
+ appName = "showFullId";
+ value = checkTF(value);
+ break;
+ case "showtreebootstraps":
+ appName = "showTreeBootstraps";
+ value = checkTF(value);
+ break;
+ case "showtreedistances":
+ appName = "showTreeDistances";
+ value = checkTF(value);
+ break;
+ case "showunconserved":
+ appName = Preferences.SHOW_UNCONSERVED;
+ value = checkTF(value);
+ break;
+ case "showunlinkedtreenodes":
+ appName = "showUnlinkedTreeNodes";
+ value = checkTF(value);
+ break;
+ default:
+ // could be pdbFile2, for example
+ // or one of the app preference names
+ break;
+ }
+ if (value != null)
+ {
+ vargs.add(appName);
+ if (value != "true")
+ {
+ vargs.add(value);
+ }
+ }
+ if (value == null)
+ {
+ value = "false";
+ }
+ System.out.println("AppletParams appName=" + appName + "appletName="
+ + appletName + " value=" + value);
+ Cache.setPropertyNoSave(appName, value);
+ if (appletName != null)
+ {
+ appletParams.put(appletName, value);
+ }
+ }
+ }
+ return appletParams;
+ }
+
+ /**
+ * Check for a single-argument option.
+ *
+ * @param value
+ * @return "true" or null
+ */
+ private static String checkTF(String value)
+ {
+ return (value.toLowerCase() == "true" ? "true" : null);
+ }
+
/**
* Crude applet innerHTML parser
*
* @param attr
* @return
*/
- private String getAttr(String tag, String attr)
+ private static String getAttr(String tag, String attr)
{
int pt = tag.indexOf(attr + "=\"");
if (pt < 0)