+ }
+ }
+
+ public static String getBuildDate()
+ {
+ initBuildDetails();
+ return builddate;
+ }
+
+ public static String getInstallation()
+ {
+ initBuildDetails();
+ return installation;
+ }
+
+ public static String getVersion()
+ {
+ initBuildDetails();
+ return version;
+ }
+
+ // public JSObject scriptObject = null;
+
+ /**
+ * init method for Jalview Applet
+ */
+ public void init()
+ {
+ // remove any handlers that might be hanging around from an earlier instance
+ try
+ {
+ if (debug)
+ {
+ System.err.println("Applet context is '"
+ + getAppletContext().getClass().toString() + "'");
+ }
+ JSObject scriptObject = JSObject.getWindow(this);
+ if (debug && scriptObject != null)
+ {
+ System.err.println("Applet has Javascript callback support.");
+ }
+
+ } catch (Exception ex)
+ {
+ System.err
+ .println("Warning: No JalviewLite javascript callbacks available.");
+ if (debug)
+ {
+ ex.printStackTrace();
+ }
+ }
+ /**
+ * turn on extra applet debugging
+ */
+ String dbg = getParameter("debug");
+ if (dbg != null)
+ {
+ debug = dbg.toLowerCase().equals("true");
+ }
+ if (debug)
+ {
+
+ System.err.println("JalviewLite Version " + getVersion());
+ System.err.println("Build Date : " + getBuildDate());
+ System.err.println("Installation : " + getInstallation());
+
+ }
+ String externalsviewer = getParameter("externalstructureviewer");
+ if (externalsviewer != null)
+ {
+ useXtrnalSviewer = externalsviewer.trim().toLowerCase()
+ .equals("true");
+ }
+ /**
+ * if true disable the check for jmol
+ */
+ String chkforJmol = getParameter("nojmol");
+ if (chkforJmol != null)
+ {
+ checkForJmol = !chkforJmol.equals("true");
+ }
+ /**
+ * get the separator parameter if present
+ */
+ String sep = getParameter("separator");
+ if (sep != null)
+ {
+ if (sep.length() > 0)
+ {
+ separator = sep;
+ if (debug)
+ {
+ System.err.println("Separator set to '" + separator + "'");
+ }
+ }
+ else
+ {
+ throw new Error(MessageManager.getString("error.invalid_separator_parameter"));
+ }
+ }
+ int r = 255;
+ int g = 255;
+ int b = 255;
+ String param = getParameter("RGB");
+
+ if (param != null)
+ {
+ try
+ {
+ r = Integer.parseInt(param.substring(0, 2), 16);
+ g = Integer.parseInt(param.substring(2, 4), 16);
+ b = Integer.parseInt(param.substring(4, 6), 16);
+ } catch (Exception ex)
+ {
+ r = 255;
+ g = 255;
+ b = 255;
+ }
+ }
+ param = getParameter("label");
+ if (param != null)
+ {
+ launcher.setLabel(param);
+ }
+
+ setBackground(new Color(r, g, b));
+
+ file = getParameter("file");
+
+ if (file == null)
+ {
+ // Maybe the sequences are added as parameters
+ StringBuffer data = new StringBuffer("PASTE");
+ int i = 1;
+ while ((file = getParameter("sequence" + i)) != null)
+ {
+ data.append(file.toString() + "\n");
+ i++;
+ }
+ if (data.length() > 5)
+ {
+ file = data.toString();
+ }
+ }
+
+ final JalviewLite jvapplet = this;
+ if (getParameter("embedded") != null
+ && getParameter("embedded").equalsIgnoreCase("true"))
+ {
+ // Launch as embedded applet in page
+ embedded = true;
+ LoadingThread loader = new LoadingThread(file, jvapplet);
+ loader.start();
+ }
+ else if (file != null)
+ {
+ if (getParameter("showbutton") == null
+ || !getParameter("showbutton").equalsIgnoreCase("false"))
+ {
+ // Add the JalviewLite 'Button' to the page
+ add(launcher);
+ launcher.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ LoadingThread loader = new LoadingThread(file, jvapplet);
+ loader.start();
+ }
+ });
+ }
+ else
+ {
+ // Open jalviewLite immediately.
+ LoadingThread loader = new LoadingThread(file, jvapplet);
+ loader.start();
+ }
+ }
+ else
+ {
+ // jalview initialisation with no alignment. loadAlignment() method can
+ // still be called to open new alignments.
+ file = "NO FILE";
+ fileFound = false;
+ callInitCallback();
+ }
+ }
+
+ private void initLiveConnect()
+ {
+ // try really hard to get the liveConnect thing working
+ boolean notFailed = false;
+ int tries = 0;
+ while (!notFailed && tries < 10)
+ {
+ if (tries > 0)
+ {
+ System.err.println("LiveConnect request thread going to sleep.");
+ }
+ try
+ {
+ Thread.sleep(700 * (1 + tries));
+ } catch (InterruptedException q)
+ {
+ }
+ ;
+ if (tries++ > 0)
+ {
+ System.err.println("LiveConnect request thread woken up.");
+ }
+ try
+ {
+ JSObject scriptObject = JSObject.getWindow(this);
+ if (scriptObject.eval("navigator") != null)
+ {
+ notFailed = true;
+ }
+ } catch (JSException jsex)
+ {
+ System.err.println("Attempt " + tries
+ + " to access LiveConnect javascript failed.");
+ }
+ }
+ }
+
+ private void callInitCallback()
+ {
+ String initjscallback = getParameter("oninit");
+ if (initjscallback == null)
+ {
+ return;
+ }
+ initjscallback = initjscallback.trim();
+ if (initjscallback.length() > 0)
+ {
+ JSObject scriptObject = null;
+ try
+ {
+ scriptObject = JSObject.getWindow(this);
+ } catch (Exception ex)
+ {
+ }
+ ;
+ // try really hard to let the browser plugin know we want liveconnect
+ initLiveConnect();
+
+ if (scriptObject != null)
+ {
+ try
+ {
+ // do onInit with the JS executor thread
+ new JSFunctionExec(this).executeJavascriptFunction(true,
+ initjscallback, null, "Calling oninit callback '"
+ + initjscallback + "'.");
+ } catch (Exception e)
+ {
+ System.err.println("Exception when executing _oninit callback '"
+ + initjscallback + "'.");
+ e.printStackTrace();
+ }
+ }
+ else
+ {
+ System.err.println("Not executing _oninit callback '"
+ + initjscallback + "' - no scripting allowed.");
+ }
+ }
+ }
+
+ /**
+ * Initialises and displays a new java.awt.Frame
+ *
+ * @param frame
+ * java.awt.Frame to be displayed
+ * @param title
+ * title of new frame
+ * @param width
+ * width if new frame
+ * @param height
+ * height of new frame
+ */
+ public static void addFrame(final Frame frame, String title, int width,
+ int height)
+ {
+ frame.setLocation(lastFrameX, lastFrameY);
+ lastFrameX += 40;
+ lastFrameY += 40;
+ frame.setSize(width, height);
+ frame.setTitle(title);
+ frame.addWindowListener(new WindowAdapter()
+ {
+ public void windowClosing(WindowEvent e)
+ {
+ if (frame instanceof AlignFrame)
+ {
+ AlignViewport vp = ((AlignFrame) frame).viewport;
+ ((AlignFrame) frame).closeMenuItem_actionPerformed();
+ if (vp.applet.currentAlignFrame == frame)
+ {
+ vp.applet.currentAlignFrame = null;
+ }
+ vp.applet = null;
+ vp = null;
+
+ }
+ lastFrameX -= 40;
+ lastFrameY -= 40;
+ if (frame instanceof EmbmenuFrame)
+ {
+ ((EmbmenuFrame) frame).destroyMenus();
+ }
+ frame.setMenuBar(null);
+ frame.dispose();
+ }
+
+ public void windowActivated(WindowEvent e)
+ {
+ if (frame instanceof AlignFrame)
+ {
+ ((AlignFrame) frame).viewport.applet.currentAlignFrame = (AlignFrame) frame;
+ if (debug)
+ {
+ System.err.println("Activated window " + frame);
+ }
+ }
+ // be good.
+ super.windowActivated(e);
+ }
+ /*
+ * Probably not necessary to do this - see TODO above. (non-Javadoc)
+ *
+ * @see
+ * java.awt.event.WindowAdapter#windowDeactivated(java.awt.event.WindowEvent
+ * )
+ *
+ * public void windowDeactivated(WindowEvent e) { if (currentAlignFrame ==
+ * frame) { currentAlignFrame = null; if (debug) {
+ * System.err.println("Deactivated window "+frame); } }
+ * super.windowDeactivated(e); }
+ */
+ });
+ frame.setVisible(true);
+ }
+
+ /**
+ * This paints the background surrounding the "Launch Jalview button" <br>
+ * <br>
+ * If file given in parameter not found, displays error message
+ *
+ * @param g
+ * graphics context
+ */
+ public void paint(Graphics g)
+ {
+ if (!fileFound)
+ {
+ g.setColor(new Color(200, 200, 200));
+ g.setColor(Color.cyan);
+ g.fillRect(0, 0, getSize().width, getSize().height);
+ g.setColor(Color.red);
+ g.drawString(
+ MessageManager.getString("label.jalview_cannot_open_file"),
+ 5, 15);
+ g.drawString("\"" + file + "\"", 5, 30);
+ }
+ else if (embedded)
+ {
+ g.setColor(Color.black);
+ g.setFont(new Font("Arial", Font.BOLD, 24));
+ g.drawString(MessageManager.getString("label.jalview_applet"), 50,
+ getSize().height / 2 - 30);
+ g.drawString(MessageManager.getString("label.loading_data") + "...",
+ 50, getSize().height / 2);
+ }
+ }
+
+ /**
+ * get all components associated with the applet of the given type
+ *
+ * @param class1
+ * @return
+ */
+ public Vector getAppletWindow(Class class1)
+ {
+ Vector wnds = new Vector();
+ Component[] cmp = getComponents();
+ if (cmp != null)
+ {
+ for (int i = 0; i < cmp.length; i++)
+ {
+ if (class1.isAssignableFrom(cmp[i].getClass()))
+ {
+ wnds.addElement(cmp);
+ }
+ }
+ }
+ return wnds;
+ }
+
+ class LoadJmolThread extends Thread
+ {
+ private boolean running = false;
+
+ public void run()
+ {
+ if (running || checkedForJmol)
+ {
+ return;
+ }
+ running = true;
+ if (checkForJmol)
+ {
+ try
+ {
+ if (!System.getProperty("java.version").startsWith("1.1"))
+ {
+ Class.forName("org.jmol.adapter.smarter.SmarterJmolAdapter");
+ jmolAvailable = true;
+ }
+ if (!jmolAvailable)
+ {
+ System.out
+ .println("Jmol not available - Using MCview for structures");
+ }
+ } catch (java.lang.ClassNotFoundException ex)
+ {
+ }
+ }
+ else
+ {
+ jmolAvailable = false;
+ if (debug)
+ {
+ System.err
+ .println("Skipping Jmol check. Will use MCView (probably)");
+ }
+ }
+ checkedForJmol = true;
+ running = false;
+ }
+
+ public boolean notFinished()
+ {
+ return running || !checkedForJmol;
+ }
+ }
+
+ class LoadingThread extends Thread
+ {
+ /**
+ * State variable: File source
+ */
+ String file;
+
+ /**
+ * State variable: protocol for access to file source
+ */
+ String protocol;
+
+ /**
+ * State variable: format of file source
+ */
+ String format;
+
+ String _file;
+
+ JalviewLite applet;
+
+ private void dbgMsg(String msg)
+ {
+ if (applet.debug)
+ {
+ System.err.println(msg);
+ }
+ }
+
+ /**
+ * update the protocol state variable for accessing the datasource located
+ * by file.
+ *
+ * @param file
+ * @return possibly updated datasource string
+ */
+ public String setProtocolState(String file)
+ {
+ if (file.startsWith("PASTE"))
+ {
+ file = file.substring(5);
+ protocol = AppletFormatAdapter.PASTE;
+ }
+ else if (inArchive(file))
+ {
+ protocol = AppletFormatAdapter.CLASSLOADER;
+ }
+ else
+ {
+ file = addProtocol(file);
+ protocol = AppletFormatAdapter.URL;
+ }
+ dbgMsg("Protocol identified as '" + protocol + "'");
+ return file;
+ }
+
+ public LoadingThread(String _file, JalviewLite _applet)
+ {
+ this._file = _file;
+ applet = _applet;
+ }
+
+ public void run()
+ {
+ LoadJmolThread jmolchecker = new LoadJmolThread();
+ jmolchecker.start();
+ while (jmolchecker.notFinished())
+ {
+ // wait around until the Jmol check is complete.
+ try
+ {
+ Thread.sleep(2);
+ } catch (Exception e)
+ {
+ }
+ ;
+ }
+ startLoading();
+ // applet.callInitCallback();
+ }
+
+ private void startLoading()
+ {
+ AlignFrame newAlignFrame;
+ dbgMsg("Loading thread started with:\n>>file\n" + _file + ">>endfile");
+ file = setProtocolState(_file);
+
+ format = new jalview.io.IdentifyFile().Identify(file, protocol);
+ dbgMsg("File identified as '" + format + "'");
+ dbgMsg("Loading started.");
+ Alignment al = null;
+ try
+ {
+ al = new AppletFormatAdapter().readFile(file, protocol, format);
+ } catch (java.io.IOException ex)
+ {
+ dbgMsg("File load exception.");
+ ex.printStackTrace();
+ if (debug)
+ {
+ try
+ {
+ FileParse fp = new FileParse(file, protocol);
+ String ln = null;
+ dbgMsg(">>>Dumping contents of '" + file + "' " + "("
+ + protocol + ")");
+ while ((ln = fp.nextLine()) != null)
+ {
+ dbgMsg(ln);
+ }
+ dbgMsg(">>>Dump finished.");
+ } catch (Exception e)
+ {
+ System.err
+ .println("Exception when trying to dump the content of the file parameter.");
+ e.printStackTrace();
+ }
+ }
+ }
+ if ((al != null) && (al.getHeight() > 0))
+ {
+ dbgMsg("Successfully loaded file.");
+ newAlignFrame = new AlignFrame(al, applet, file, embedded);
+ if (initialAlignFrame == null)
+ {
+ initialAlignFrame = newAlignFrame;
+ }
+ // update the focus.
+ currentAlignFrame = newAlignFrame;
+
+ if (protocol == jalview.io.AppletFormatAdapter.PASTE)
+ {
+ newAlignFrame.setTitle(MessageManager.formatMessage(
+ "label.sequences_from", new String[]
+ { applet.getDocumentBase().toString() }));
+ }
+
+ newAlignFrame.statusBar.setText(MessageManager.formatMessage(
+ "label.successfully_loaded_file", new String[]
+ { file }));
+
+ String treeFile = applet.getParameter("tree");
+ if (treeFile == null)
+ {
+ treeFile = applet.getParameter("treeFile");
+ }
+
+ if (treeFile != null)
+ {
+ try
+ {
+ treeFile = setProtocolState(treeFile);
+ /*
+ * if (inArchive(treeFile)) { protocol =
+ * AppletFormatAdapter.CLASSLOADER; } else { protocol =
+ * AppletFormatAdapter.URL; treeFile = addProtocol(treeFile); }
+ */
+ jalview.io.NewickFile fin = new jalview.io.NewickFile(treeFile,
+ protocol);
+
+ fin.parse();
+
+ if (fin.getTree() != null)
+ {
+ newAlignFrame.loadTree(fin, treeFile);
+ dbgMsg("Successfuly imported tree.");
+ }
+ else
+ {
+ dbgMsg("Tree parameter did not resolve to a valid tree.");
+ }
+ } catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ /*
+ * Try to load T-Coffee score file
+ */
+ String sScoreFile = applet.getParameter("scoreFile");
+ if (sScoreFile != null && !"".equals(sScoreFile))
+ {
+ try
+ {
+ if (debug)
+ {
+ System.err
+ .println("Attempting to load T-COFFEE score file from the scoreFile parameter");
+ }
+ if (!newAlignFrame.loadScoreFile(sScoreFile))
+ {
+ System.err
+ .println("Failed to parse T-COFFEE parameter as a valid score file ('"
+ + sScoreFile + "')");
+ }
+ } catch (Exception e)
+ {
+ System.err.printf("Cannot read score file: '%s'. Cause: %s \n",
+ sScoreFile, e.getMessage());
+ }
+ }
+
+ // ///////////////////////////
+ // modify display of features
+ // we do this before any features have been loaded, ensuring any hidden
+ // groups are hidden when features first displayed
+ //
+ // hide specific groups
+ //
+ String param = applet.getParameter("hidefeaturegroups");
+ if (param != null)
+ {
+ newAlignFrame.setFeatureGroupState(separatorListToArray(param),
+ false);
+ // applet.setFeatureGroupStateOn(newAlignFrame, param, false);
+ }
+ // show specific groups
+ param = applet.getParameter("showfeaturegroups");
+ if (param != null)
+ {
+ newAlignFrame.setFeatureGroupState(separatorListToArray(param),
+ true);
+ // applet.setFeatureGroupStateOn(newAlignFrame, param, true);
+ }
+ // and now load features
+ param = applet.getParameter("features");
+ if (param != null)
+ {
+ param = setProtocolState(param);
+
+ newAlignFrame.parseFeaturesFile(param, protocol);
+ }
+
+ param = applet.getParameter("showFeatureSettings");
+ if (param != null && param.equalsIgnoreCase("true"))
+ {
+ newAlignFrame.viewport.setShowSequenceFeatures(true);
+ new FeatureSettings(newAlignFrame.alignPanel);
+ }
+
+ param = applet.getParameter("annotations");
+ if (param != null)
+ {
+ param = setProtocolState(param);
+
+ if (new AnnotationFile().annotateAlignmentView(
+ newAlignFrame.viewport, param, protocol))
+ {
+ newAlignFrame.alignPanel.fontChanged();
+ newAlignFrame.alignPanel.setScrollValues(0, 0);
+ }
+ else
+ {
+ System.err
+ .println("Annotations were not added from annotation file '"
+ + param + "'");
+ }
+
+ }
+
+ param = applet.getParameter("jnetfile");
+ if (param != null)
+ {
+ try
+ {
+ param = setProtocolState(param);
+ jalview.io.JPredFile predictions = new jalview.io.JPredFile(
+ param, protocol);
+ JnetAnnotationMaker.add_annotation(predictions,
+ newAlignFrame.viewport.getAlignment(), 0, false); // false==do
+ SequenceI repseq = newAlignFrame.viewport.getAlignment()
+ .getSequenceAt(0);
+ newAlignFrame.viewport.getAlignment().setSeqrep(repseq);
+ ColumnSelection cs = new ColumnSelection();
+ cs.hideInsertionsFor(repseq);
+ newAlignFrame.viewport.setColumnSelection(cs);
+ // not
+ // add
+ // sequence
+ // profile
+ // from
+ // concise
+ // output
+ newAlignFrame.alignPanel.fontChanged();
+ newAlignFrame.alignPanel.setScrollValues(0, 0);
+ } catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ /*
+ * <param name="alignpdbfiles" value="false/true"/> Undocumented for 2.6
+ * - related to JAL-434
+ */
+ applet.setAlignPdbStructures(getDefaultParameter("alignpdbfiles",
+ false));
+ /*
+ * <param name="PDBfile" value="1gaq.txt PDB|1GAQ|1GAQ|A PDB|1GAQ|1GAQ|B
+ * PDB|1GAQ|1GAQ|C">
+ *
+ * <param name="PDBfile2" value="1gaq.txt A=SEQA B=SEQB C=SEQB">
+ *
+ * <param name="PDBfile3" value="1q0o Q45135_9MICO">
+ */
+
+ int pdbFileCount = 0;
+ // Accumulate pdbs here if they are heading for the same view (if
+ // alignPdbStructures is true)
+ Vector pdbs = new Vector();
+ // create a lazy matcher if we're asked to
+ jalview.analysis.SequenceIdMatcher matcher = (applet
+ .getDefaultParameter("relaxedidmatch", false)) ? new jalview.analysis.SequenceIdMatcher(
+ newAlignFrame.getAlignViewport().getAlignment()
+ .getSequencesArray()) : null;
+
+ do
+ {
+ if (pdbFileCount > 0)
+ {
+ param = applet.getParameter("PDBFILE" + pdbFileCount);
+ }
+ else
+ {
+ param = applet.getParameter("PDBFILE");
+ }
+
+ if (param != null)
+ {
+ PDBEntry pdb = new PDBEntry();
+
+ String seqstring;
+ SequenceI[] seqs = null;
+ String[] chains = null;
+
+ StringTokenizer st = new StringTokenizer(param, " ");
+
+ if (st.countTokens() < 2)
+ {
+ String sequence = applet.getParameter("PDBSEQ");
+ if (sequence != null)
+ {
+ seqs = new SequenceI[]
+ { matcher == null ? (Sequence) newAlignFrame
+ .getAlignViewport().getAlignment()
+ .findName(sequence) : matcher.findIdMatch(sequence) };
+ }
+
+ }
+ else
+ {
+ param = st.nextToken();
+ Vector tmp = new Vector();
+ Vector tmp2 = new Vector();
+
+ while (st.hasMoreTokens())
+ {
+ seqstring = st.nextToken();
+ StringTokenizer st2 = new StringTokenizer(seqstring, "=");
+ if (st2.countTokens() > 1)
+ {
+ // This is the chain
+ tmp2.addElement(st2.nextToken());
+ seqstring = st2.nextToken();
+ }
+ tmp.addElement(matcher == null ? (Sequence) newAlignFrame
+ .getAlignViewport().getAlignment()
+ .findName(seqstring) : matcher
+ .findIdMatch(seqstring));
+ }
+
+ seqs = new SequenceI[tmp.size()];
+ tmp.copyInto(seqs);
+ if (tmp2.size() == tmp.size())
+ {
+ chains = new String[tmp2.size()];
+ tmp2.copyInto(chains);
+ }
+ }
+ param = setProtocolState(param);
+
+ if (// !jmolAvailable
+ // &&
+ protocol == AppletFormatAdapter.CLASSLOADER
+ && !useXtrnalSviewer)
+ {
+ // Re: JAL-357 : the bug isn't a problem if we are using an
+ // external viewer!
+ // TODO: verify this Re:
+ // https://mantis.lifesci.dundee.ac.uk/view.php?id=36605
+ // This exception preserves the current behaviour where, even if
+ // the local pdb file was identified in the class loader
+ protocol = AppletFormatAdapter.URL; // this is probably NOT
+ // CORRECT!
+ param = addProtocol(param); //
+ }
+
+ pdb.setFile(param);
+
+ if (seqs != null)
+ {
+ for (int i = 0; i < seqs.length; i++)
+ {
+ if (seqs[i] != null)
+ {
+ ((Sequence) seqs[i]).addPDBId(pdb);
+ StructureSelectionManager.getStructureSelectionManager(
+ applet).registerPDBEntry(pdb);
+ }
+ else
+ {
+ if (JalviewLite.debug)
+ {
+ // this may not really be a problem but we give a warning
+ // anyway
+ System.err
+ .println("Warning: Possible input parsing error: Null sequence for attachment of PDB (sequence "
+ + i + ")");
+ }
+ }
+ }
+
+ if (!alignPdbStructures)
+ {
+ newAlignFrame.newStructureView(applet, pdb, seqs, chains,
+ protocol);
+ }
+ else
+ {
+ pdbs.addElement(new Object[]
+ { pdb, seqs, chains, new String(protocol) });
+ }
+ }
+ }
+
+ pdbFileCount++;
+ } while (param != null || pdbFileCount < 10);
+ if (pdbs.size() > 0)
+ {
+ SequenceI[][] seqs = new SequenceI[pdbs.size()][];
+ PDBEntry[] pdb = new PDBEntry[pdbs.size()];
+ String[][] chains = new String[pdbs.size()][];
+ String[] protocols = new String[pdbs.size()];
+ for (int pdbsi = 0, pdbsiSize = pdbs.size(); pdbsi < pdbsiSize; pdbsi++)
+ {
+ Object[] o = (Object[]) pdbs.elementAt(pdbsi);
+ pdb[pdbsi] = (PDBEntry) o[0];
+ seqs[pdbsi] = (SequenceI[]) o[1];
+ chains[pdbsi] = (String[]) o[2];
+ protocols[pdbsi] = (String) o[3];
+ }
+ newAlignFrame.alignedStructureView(applet, pdb, seqs, chains,
+ protocols);
+
+ }
+ }
+ else
+ {
+ fileFound = false;
+ applet.remove(launcher);
+ applet.repaint();
+ }
+ callInitCallback();
+ }
+
+ /**
+ * Discovers whether the given file is in the Applet Archive
+ *
+ * @param file
+ * String
+ * @return boolean
+ */
+ boolean inArchive(String file)
+ {
+ // This might throw a security exception in certain browsers
+ // Netscape Communicator for instance.
+ try
+ {
+ boolean rtn = (getClass().getResourceAsStream("/" + file) != null);
+ if (debug)
+ {
+ System.err.println("Resource '" + file + "' was "
+ + (rtn ? "" : "not") + " located by classloader.");
+ }
+ return rtn;
+ } catch (Exception ex)
+ {
+ System.out.println("Exception checking resources: " + file + " "
+ + ex);
+ return false;
+ }
+ }
+
+ String addProtocol(String file)
+ {
+ if (file.indexOf("://") == -1)
+ {
+ String fl = applet.resolveUrlForLocalOrAbsolute(file,
+ getDocumentBase());
+ try
+ {
+ if (new java.net.URL(fl).openStream() != null)
+ {
+ if (debug)
+ {
+ System.err.println("Prepended document base for resource: '"
+ + file + "'");
+ }
+ return fl;
+ }
+ } catch (Exception x)
+ {
+ }
+ ;
+ fl = applet.resolveUrlForLocalOrAbsolute(file, getCodeBase());
+ try
+ {
+ if (new java.net.URL(fl).openStream() != null)
+ {
+ if (debug)
+ {
+ System.err.println("Prepended codebase for resource: '"
+ + file + "'");
+ }
+ return fl;
+ }
+ } catch (Exception x)
+ {
+ }
+ ;
+
+ }
+
+ return file;
+ }
+ }
+
+ /**
+ * @return the default alignFrame acted on by the public applet methods. May
+ * return null with an error message on System.err indicating the
+ * fact.
+ */
+ public AlignFrame getDefaultTargetFrame()
+ {
+ if (currentAlignFrame != null)
+ {
+ return currentAlignFrame;
+ }
+ if (initialAlignFrame != null)
+ {
+ return initialAlignFrame;
+ }
+ System.err
+ .println("Implementation error: Jalview Applet API cannot work out which AlignFrame to use.");
+ return null;
+ }
+
+ /**
+ * separator used for separatorList
+ */
+ protected String separator = "" + ((char) 0x00AC); // the default used to be
+ // '|' but many sequence
+ // IDS include pipes.
+
+ /**
+ * set to enable the URL based javascript execution mechanism
+ */
+ public boolean jsfallbackEnabled = false;