2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import jalview.analysis.AlignmentUtils;
24 import jalview.api.AlignViewportI;
25 import jalview.api.JalviewApp;
26 import jalview.api.StructureSelectionManagerProvider;
27 import jalview.appletgui.AlignFrame;
28 import jalview.appletgui.AlignViewport;
29 import jalview.appletgui.EmbmenuFrame;
30 import jalview.appletgui.FeatureSettings;
31 import jalview.appletgui.SplitFrame;
32 import jalview.datamodel.Alignment;
33 import jalview.datamodel.AlignmentI;
34 import jalview.datamodel.AlignmentOrder;
35 import jalview.datamodel.ColumnSelection;
36 import jalview.datamodel.PDBEntry;
37 import jalview.datamodel.SequenceGroup;
38 import jalview.datamodel.SequenceI;
39 import jalview.io.AnnotationFile;
40 import jalview.io.AppletFormatAdapter;
41 import jalview.io.DataSourceType;
42 import jalview.io.FileFormatI;
43 import jalview.io.FileFormats;
44 import jalview.io.FileParse;
45 import jalview.io.IdentifyFile;
46 import jalview.io.NewickFile;
47 import jalview.javascript.JSFunctionExec;
48 import jalview.javascript.JalviewLiteJsApi;
49 import jalview.javascript.JsCallBack;
50 import jalview.javascript.MouseOverStructureListener;
51 import jalview.structure.SelectionListener;
52 import jalview.structure.StructureSelectionManager;
53 import jalview.util.ColorUtils;
54 import jalview.util.MessageManager;
56 import java.applet.Applet;
57 import java.awt.Button;
58 import java.awt.Color;
59 import java.awt.Component;
60 import java.awt.EventQueue;
62 import java.awt.Frame;
63 import java.awt.Graphics;
64 import java.awt.event.ActionEvent;
65 import java.awt.event.WindowAdapter;
66 import java.awt.event.WindowEvent;
67 import java.io.BufferedReader;
68 import java.io.IOException;
69 import java.io.InputStreamReader;
71 import java.util.ArrayList;
72 import java.util.Hashtable;
73 import java.util.List;
74 import java.util.Vector;
76 import netscape.javascript.JSObject;
79 * Jalview Applet. Runs in Java 1.18 runtime
82 * @version $Revision: 1.92 $
84 public class JalviewLite extends Applet
85 implements StructureSelectionManagerProvider, JalviewLiteJsApi,
91 appLoader = new JalviewAppLoader(debug);
93 private static final String TRUE = "true";
95 private static final String FALSE = "false";
97 public StructureSelectionManager getStructureSelectionManager()
99 return StructureSelectionManager.getStructureSelectionManager(this);
102 // /////////////////////////////////////////
103 // The following public methods may be called
104 // externally, eg via javascript in HTML page
108 * @see jalview.bin.JalviewLiteJsApi#getSelectedSequences()
111 public String getSelectedSequences()
113 return getSelectedSequencesFrom(getDefaultTargetFrame());
119 * @see jalview.bin.JalviewLiteJsApi#getSelectedSequences(java.lang.String)
122 public String getSelectedSequences(String sep)
124 return getSelectedSequencesFrom(getDefaultTargetFrame(), sep);
131 * jalview.bin.JalviewLiteJsApi#getSelectedSequencesFrom(jalview.appletgui
135 public String getSelectedSequencesFrom(AlignFrame alf)
137 return getSelectedSequencesFrom(alf, separator); // ""+0x00AC);
144 * jalview.bin.JalviewLiteJsApi#getSelectedSequencesFrom(jalview.appletgui
145 * .AlignFrame, java.lang.String)
148 public String getSelectedSequencesFrom(AlignFrame alf, String sep)
150 StringBuffer result = new StringBuffer("");
151 if (sep == null || sep.length() == 0)
153 sep = separator; // "+0x00AC;
155 if (alf.viewport.getSelectionGroup() != null)
157 SequenceI[] seqs = alf.viewport.getSelectionGroup()
158 .getSequencesInOrder(alf.viewport.getAlignment());
160 for (int i = 0; i < seqs.length; i++)
162 result.append(seqs[i].getName());
167 return result.toString();
173 * @see jalview.bin.JalviewLiteJsApi#highlight(java.lang.String,
174 * java.lang.String, java.lang.String)
177 public void highlight(String sequenceId, String position,
178 String alignedPosition)
180 highlightIn(getDefaultTargetFrame(), sequenceId, position,
187 * @see jalview.bin.JalviewLiteJsApi#highlightIn(jalview.appletgui.AlignFrame,
188 * java.lang.String, java.lang.String, java.lang.String)
191 public void highlightIn(final AlignFrame alf, final String sequenceId,
192 final String position, final String alignedPosition)
194 // TODO: could try to highlight in all alignments if alf==null
195 jalview.analysis.SequenceIdMatcher matcher = new jalview.analysis.SequenceIdMatcher(
196 alf.viewport.getAlignment().getSequencesArray());
197 final SequenceI sq = matcher.findIdMatch(sequenceId);
203 apos = new Integer(position).intValue();
205 } catch (NumberFormatException ex)
209 final StructureSelectionManagerProvider me = this;
210 final int pos = apos;
211 // use vamsas listener to broadcast to all listeners in scope
212 if (alignedPosition != null && (alignedPosition.trim().length() == 0
213 || alignedPosition.toLowerCase().indexOf("false") > -1))
215 java.awt.EventQueue.invokeLater(new Runnable()
220 StructureSelectionManager.getStructureSelectionManager(me)
221 .mouseOverVamsasSequence(sq, sq.findIndex(pos), null);
227 java.awt.EventQueue.invokeLater(new Runnable()
232 StructureSelectionManager.getStructureSelectionManager(me)
233 .mouseOverVamsasSequence(sq, pos, null);
243 * @see jalview.bin.JalviewLiteJsApi#select(java.lang.String,
247 public void select(String sequenceIds, String columns)
249 selectIn(getDefaultTargetFrame(), sequenceIds, columns, separator);
255 * @see jalview.bin.JalviewLiteJsApi#select(java.lang.String,
256 * java.lang.String, java.lang.String)
259 public void select(String sequenceIds, String columns, String sep)
261 selectIn(getDefaultTargetFrame(), sequenceIds, columns, sep);
267 * @see jalview.bin.JalviewLiteJsApi#selectIn(jalview.appletgui.AlignFrame,
268 * java.lang.String, java.lang.String)
271 public void selectIn(AlignFrame alf, String sequenceIds, String columns)
273 selectIn(alf, sequenceIds, columns, separator);
279 * @see jalview.bin.JalviewLiteJsApi#selectIn(jalview.appletgui.AlignFrame,
280 * java.lang.String, java.lang.String, java.lang.String)
283 public void selectIn(final AlignFrame alf, String sequenceIds,
284 String columns, String sep)
286 if (sep == null || sep.length() == 0)
294 System.err.println("Selecting region using separator string '"
299 String[] ids = JalviewAppLoader.separatorListToArray(sequenceIds, sep);
300 String[] cols = JalviewAppLoader.separatorListToArray(columns, sep);
301 final SequenceGroup sel = new SequenceGroup();
302 final ColumnSelection csel = new ColumnSelection();
303 AlignmentI al = alf.viewport.getAlignment();
304 jalview.analysis.SequenceIdMatcher matcher = new jalview.analysis.SequenceIdMatcher(
305 alf.viewport.getAlignment().getSequencesArray());
306 int start = 0, end = al.getWidth(), alw = al.getWidth();
307 boolean seqsfound = true;
308 if (ids != null && ids.length > 0)
311 for (int i = 0; i < ids.length; i++)
313 if (ids[i].trim().length() == 0)
317 SequenceI sq = matcher.findIdMatch(ids[i]);
321 sel.addSequence(sq, false);
325 boolean inseqpos = false;
326 if (cols != null && cols.length > 0)
328 boolean seset = false;
329 for (int i = 0; i < cols.length; i++)
331 String cl = cols[i].trim();
332 if (cl.length() == 0)
337 if ((p = cl.indexOf("-")) > -1)
339 int from = -1, to = -1;
342 from = new Integer(cl.substring(0, p)).intValue();
344 } catch (NumberFormatException ex)
347 "ERROR: Couldn't parse first integer in range element column selection string '"
348 + cl + "' - format is 'from-to'");
353 to = new Integer(cl.substring(p + 1)).intValue();
355 } catch (NumberFormatException ex)
358 "ERROR: Couldn't parse second integer in range element column selection string '"
359 + cl + "' - format is 'from-to'");
362 if (from >= 0 && to >= 0)
379 // comment to prevent range extension
389 for (int r = from; r <= to; r++)
391 if (r >= 0 && r < alw)
398 System.err.println("Range '" + cl + "' deparsed as [" + from
404 System.err.println("ERROR: Invalid Range '" + cl
405 + "' deparsed as [" + from + "," + to + "]");
413 r = new Integer(cl).intValue();
415 } catch (NumberFormatException ex)
417 if (cl.toLowerCase().equals("sequence"))
419 // we are in the dataset sequence's coordinate frame.
425 "ERROR: Couldn't parse integer from point selection element of column selection string '"
430 if (r >= 0 && r <= alw)
440 // comment to prevent range extension
453 System.err.println("Point selection '" + cl
454 + "' deparsed as [" + r + "]");
459 System.err.println("ERROR: Invalid Point selection '" + cl
460 + "' deparsed as [" + r + "]");
467 // we only propagate the selection when it was the null selection, or the
468 // given sequences were found in the alignment.
469 if (inseqpos && sel.getSize() > 0)
471 // assume first sequence provides reference frame ?
472 SequenceI rs = sel.getSequenceAt(0);
473 start = rs.findIndex(start);
474 end = rs.findIndex(end);
475 List<Integer> cs = new ArrayList<>(csel.getSelected());
477 for (Integer selectedCol : cs)
479 csel.addElement(rs.findIndex(selectedCol));
482 sel.setStartRes(start);
484 EventQueue.invokeLater(new Runnable()
489 alf.select(sel, csel,
490 alf.getAlignViewport().getAlignment().getHiddenColumns());
500 * jalview.bin.JalviewLiteJsApi#getSelectedSequencesAsAlignment(java.lang.
501 * String, java.lang.String)
504 public String getSelectedSequencesAsAlignment(String format,
507 return getSelectedSequencesAsAlignmentFrom(getDefaultTargetFrame(),
515 * jalview.bin.JalviewLiteJsApi#getSelectedSequencesAsAlignmentFrom(jalview
516 * .appletgui.AlignFrame, java.lang.String, java.lang.String)
519 public String getSelectedSequencesAsAlignmentFrom(AlignFrame alf,
520 String format, String suffix)
524 FileFormatI theFormat = FileFormats.getInstance().forName(format);
525 boolean seqlimits = suffix.equalsIgnoreCase(TRUE);
526 if (alf.viewport.getSelectionGroup() != null)
528 // JBPNote: getSelectionAsNewSequence behaviour has changed - this
529 // method now returns a full copy of sequence data
530 // TODO consider using getSequenceSelection instead here
531 String reply = new AppletFormatAdapter().formatSequences(theFormat,
532 new Alignment(alf.viewport.getSelectionAsNewSequence()),
536 } catch (IllegalArgumentException ex)
538 ex.printStackTrace();
539 return "Error retrieving alignment, possibly invalid format specifier: "
548 * @see jalview.bin.JalviewLiteJsApi#getAlignmentOrder()
551 public String getAlignmentOrder()
553 return getAlignmentOrderFrom(getDefaultTargetFrame());
560 * jalview.bin.JalviewLiteJsApi#getAlignmentOrderFrom(jalview.appletgui.AlignFrame
564 public String getAlignmentOrderFrom(AlignFrame alf)
566 return getAlignmentOrderFrom(alf, separator);
573 * jalview.bin.JalviewLiteJsApi#getAlignmentOrderFrom(jalview.appletgui.AlignFrame
574 * , java.lang.String)
577 public String getAlignmentOrderFrom(AlignFrame alf, String sep)
579 AlignmentI alorder = alf.getAlignViewport().getAlignment();
580 String[] order = new String[alorder.getHeight()];
581 for (int i = 0; i < order.length; i++)
583 order[i] = alorder.getSequenceAt(i).getName();
585 return arrayToSeparatorList(order);
591 * @see jalview.bin.JalviewLiteJsApi#orderBy(java.lang.String,
595 public String orderBy(String order, String undoName)
597 return orderBy(order, undoName, separator);
603 * @see jalview.bin.JalviewLiteJsApi#orderBy(java.lang.String,
604 * java.lang.String, java.lang.String)
607 public String orderBy(String order, String undoName, String sep)
609 return orderAlignmentBy(getDefaultTargetFrame(), order, undoName, sep);
616 * jalview.bin.JalviewLiteJsApi#orderAlignmentBy(jalview.appletgui.AlignFrame,
617 * java.lang.String, java.lang.String, java.lang.String)
620 public String orderAlignmentBy(AlignFrame alf, String order,
621 String undoName, String sep)
623 String[] ids = JalviewAppLoader.separatorListToArray(order, sep);
624 SequenceI[] sqs = null;
625 if (ids != null && ids.length > 0)
627 jalview.analysis.SequenceIdMatcher matcher = new jalview.analysis.SequenceIdMatcher(
628 alf.viewport.getAlignment().getSequencesArray());
630 sqs = new SequenceI[ids.length];
631 for (int i = 0; i < ids.length; i++)
633 if (ids[i].trim().length() == 0)
637 SequenceI sq = matcher.findIdMatch(ids[i]);
645 SequenceI[] sqq = new SequenceI[s];
646 System.arraycopy(sqs, 0, sqq, 0, s);
659 final AlignmentOrder aorder = new AlignmentOrder(sqs);
661 if (undoName != null && undoName.trim().length() == 0)
665 final String _undoName = undoName;
666 // TODO: deal with synchronization here: cannot raise any events until after
667 // this has returned.
668 return alf.sortBy(aorder, _undoName) ? TRUE : "";
674 * @see jalview.bin.JalviewLiteJsApi#getAlignment(java.lang.String)
677 public String getAlignment(String format)
679 return getAlignmentFrom(getDefaultTargetFrame(), format, TRUE);
686 * jalview.bin.JalviewLiteJsApi#getAlignmentFrom(jalview.appletgui.AlignFrame,
690 public String getAlignmentFrom(AlignFrame alf, String format)
692 return getAlignmentFrom(alf, format, TRUE);
698 * @see jalview.bin.JalviewLiteJsApi#getAlignment(java.lang.String,
702 public String getAlignment(String format, String suffix)
704 return getAlignmentFrom(getDefaultTargetFrame(), format, suffix);
711 * jalview.bin.JalviewLiteJsApi#getAlignmentFrom(jalview.appletgui.AlignFrame,
712 * java.lang.String, java.lang.String)
715 public String getAlignmentFrom(AlignFrame alf, String format,
720 boolean seqlimits = suffix.equalsIgnoreCase(TRUE);
722 FileFormatI theFormat = FileFormats.getInstance().forName(format);
723 String reply = new AppletFormatAdapter().formatSequences(theFormat,
724 alf.viewport.getAlignment(), seqlimits);
726 } catch (IllegalArgumentException ex)
728 ex.printStackTrace();
729 return "Error retrieving alignment, possibly invalid format specifier: "
737 * @see jalview.bin.JalviewLiteJsApi#loadAnnotation(java.lang.String)
740 public void loadAnnotation(String annotation)
742 loadAnnotationFrom(getDefaultTargetFrame(), annotation);
749 * jalview.bin.JalviewLiteJsApi#loadAnnotationFrom(jalview.appletgui.AlignFrame
750 * , java.lang.String)
753 public void loadAnnotationFrom(AlignFrame alf, String annotation)
755 if (new AnnotationFile().annotateAlignmentView(alf.getAlignViewport(),
756 annotation, DataSourceType.PASTE))
758 alf.alignPanel.fontChanged();
759 alf.alignPanel.setScrollValues(0, 0);
763 alf.parseFeaturesFile(annotation, DataSourceType.PASTE);
770 * @see jalview.bin.JalviewLiteJsApi#loadAnnotation(java.lang.String)
773 public void loadFeatures(String features, boolean autoenabledisplay)
775 loadFeaturesFrom(getDefaultTargetFrame(), features, autoenabledisplay);
782 * jalview.bin.JalviewLiteJsApi#loadAnnotationFrom(jalview.appletgui.AlignFrame
783 * , java.lang.String)
786 public boolean loadFeaturesFrom(AlignFrame alf, String features,
787 boolean autoenabledisplay)
789 return alf.parseFeaturesFile(features, DataSourceType.PASTE,
796 * @see jalview.bin.JalviewLiteJsApi#getFeatures(java.lang.String)
799 public String getFeatures(String format)
801 return getFeaturesFrom(getDefaultTargetFrame(), format);
808 * jalview.bin.JalviewLiteJsApi#getFeaturesFrom(jalview.appletgui.AlignFrame,
812 public String getFeaturesFrom(AlignFrame alf, String format)
814 return alf.outputFeatures(false, format);
820 * @see jalview.bin.JalviewLiteJsApi#getAnnotation()
823 public String getAnnotation()
825 return getAnnotationFrom(getDefaultTargetFrame());
832 * jalview.bin.JalviewLiteJsApi#getAnnotationFrom(jalview.appletgui.AlignFrame
836 public String getAnnotationFrom(AlignFrame alf)
838 return alf.outputAnnotations(false);
844 * @see jalview.bin.JalviewLiteJsApi#newView()
847 public AlignFrame newView()
849 return newViewFrom(getDefaultTargetFrame());
855 * @see jalview.bin.JalviewLiteJsApi#newView(java.lang.String)
858 public AlignFrame newView(String name)
860 return newViewFrom(getDefaultTargetFrame(), name);
866 * @see jalview.bin.JalviewLiteJsApi#newViewFrom(jalview.appletgui.AlignFrame)
869 public AlignFrame newViewFrom(AlignFrame alf)
871 return alf.newView(null);
877 * @see jalview.bin.JalviewLiteJsApi#newViewFrom(jalview.appletgui.AlignFrame,
881 public AlignFrame newViewFrom(AlignFrame alf, String name)
883 return alf.newView(name);
889 * @see jalview.bin.JalviewLiteJsApi#loadAlignment(java.lang.String,
893 public AlignFrame loadAlignment(String text, String title)
895 AlignmentI al = null;
899 FileFormatI format = new IdentifyFile().identify(text,
900 DataSourceType.PASTE);
901 al = new AppletFormatAdapter().readFile(text, DataSourceType.PASTE,
903 if (al.getHeight() > 0)
905 return new AlignFrame(al, this, title, false);
907 } catch (IOException ex)
909 ex.printStackTrace();
917 * @see jalview.bin.JalviewLiteJsApi#setMouseoverListener(java.lang.String)
920 public void setMouseoverListener(String listener)
922 setMouseoverListener(currentAlignFrame, listener);
925 private Vector<jalview.javascript.JSFunctionExec> javascriptListeners = new Vector<>();
931 * jalview.bin.JalviewLiteJsApi#setMouseoverListener(jalview.appletgui.AlignFrame
932 * , java.lang.String)
935 public void setMouseoverListener(AlignFrame af, String listener)
937 if (listener != null)
939 listener = listener.trim();
940 if (listener.length() == 0)
943 "jalview Javascript error: Ignoring empty function for mouseover listener.");
947 jalview.javascript.MouseOverListener mol = new jalview.javascript.MouseOverListener(
949 javascriptListeners.addElement(mol);
950 StructureSelectionManager.getStructureSelectionManager(this)
951 .addStructureViewerListener(mol);
954 System.err.println("Added a mouseover listener for "
955 + ((af == null) ? "All frames"
957 + af.getAlignViewport().getSequenceSetId()));
958 System.err.println("There are now " + javascriptListeners.size()
959 + " listeners in total.");
966 * @see jalview.bin.JalviewLiteJsApi#setSelectionListener(java.lang.String)
969 public void setSelectionListener(String listener)
971 setSelectionListener(null, listener);
978 * jalview.bin.JalviewLiteJsApi#setSelectionListener(jalview.appletgui.AlignFrame
979 * , java.lang.String)
982 public void setSelectionListener(AlignFrame af, String listener)
984 if (listener != null)
986 listener = listener.trim();
987 if (listener.length() == 0)
990 "jalview Javascript error: Ignoring empty function for selection listener.");
994 jalview.javascript.JsSelectionSender mol = new jalview.javascript.JsSelectionSender(
996 javascriptListeners.addElement(mol);
997 StructureSelectionManager.getStructureSelectionManager(this)
998 .addSelectionListener(mol);
1001 System.err.println("Added a selection listener for "
1002 + ((af == null) ? "All frames"
1004 + af.getAlignViewport().getSequenceSetId()));
1005 System.err.println("There are now " + javascriptListeners.size()
1006 + " listeners in total.");
1011 * Callable from javascript to register a javascript function to pass events
1012 * to a structure viewer.
1015 * the name of a javascript function
1017 * a token separated list of PDB file names listened for
1018 * @see jalview.bin.JalviewLiteJsApi#setStructureListener(java.lang.String,
1022 public void setStructureListener(String listener, String modelSet)
1024 if (listener != null)
1026 listener = listener.trim();
1027 if (listener.length() == 0)
1030 "jalview Javascript error: Ignoring empty function for selection listener.");
1034 MouseOverStructureListener mol = new MouseOverStructureListener(this,
1035 listener, separatorListToArray(modelSet));
1036 javascriptListeners.addElement(mol);
1037 StructureSelectionManager.getStructureSelectionManager(this)
1038 .addStructureViewerListener(mol);
1041 System.err.println("Added a javascript structure viewer listener '"
1043 System.err.println("There are now " + javascriptListeners.size()
1044 + " listeners in total.");
1052 * jalview.bin.JalviewLiteJsApi#removeJavascriptListener(jalview.appletgui
1053 * .AlignFrame, java.lang.String)
1056 public void removeJavascriptListener(AlignFrame af, String listener)
1058 if (listener != null)
1060 listener = listener.trim();
1061 if (listener.length() == 0)
1066 boolean rprt = false;
1067 for (int ms = 0, msSize = javascriptListeners.size(); ms < msSize;)
1069 Object lstn = javascriptListeners.elementAt(ms);
1070 JsCallBack lstner = (JsCallBack) lstn;
1071 if ((af == null || lstner.getAlignFrame() == af) && (listener == null
1072 || lstner.getListenerFunction().equals(listener)))
1074 javascriptListeners.removeElement(lstner);
1076 if (lstner instanceof SelectionListener)
1078 StructureSelectionManager.getStructureSelectionManager(this)
1079 .removeSelectionListener((SelectionListener) lstner);
1083 StructureSelectionManager.getStructureSelectionManager(this)
1084 .removeStructureViewerListener(lstner, null);
1089 System.err.println("Removed listener '" + listener + "'");
1099 System.err.println("There are now " + javascriptListeners.size()
1100 + " listeners in total.");
1107 System.err.println("Applet " + getName() + " stop().");
1112 public void destroy()
1114 System.err.println("Applet " + getName() + " destroy().");
1118 private void tidyUp()
1121 if (currentAlignFrame != null && currentAlignFrame.viewport != null
1122 && currentAlignFrame.viewport.applet != null)
1124 AlignViewport av = currentAlignFrame.viewport;
1125 currentAlignFrame.closeMenuItem_actionPerformed();
1127 currentAlignFrame = null;
1129 if (javascriptListeners != null)
1131 while (javascriptListeners.size() > 0)
1133 jalview.javascript.JSFunctionExec mol = javascriptListeners
1135 javascriptListeners.removeElement(mol);
1136 if (mol instanceof SelectionListener)
1138 StructureSelectionManager.getStructureSelectionManager(this)
1139 .removeSelectionListener((SelectionListener) mol);
1143 StructureSelectionManager.getStructureSelectionManager(this)
1144 .removeStructureViewerListener(mol, null);
1149 if (jsFunctionExec != null)
1151 jsFunctionExec.stopQueue();
1152 jsFunctionExec.jvlite = null;
1154 initialAlignFrame = null;
1155 jsFunctionExec = null;
1156 javascriptListeners = null;
1157 StructureSelectionManager.release(this);
1160 private jalview.javascript.JSFunctionExec jsFunctionExec;
1165 * @see jalview.bin.JalviewLiteJsApi#mouseOverStructure(java.lang.String,
1166 * java.lang.String, java.lang.String)
1169 public void mouseOverStructure(final String pdbResNum, final String chain,
1170 final String pdbfile)
1172 final StructureSelectionManagerProvider me = this;
1173 java.awt.EventQueue.invokeLater(new Runnable()
1180 StructureSelectionManager.getStructureSelectionManager(me)
1181 .mouseOverStructure(new Integer(pdbResNum).intValue(),
1186 .println("mouseOver for '" + pdbResNum + "' in chain '"
1187 + chain + "' in structure '" + pdbfile + "'");
1189 } catch (NumberFormatException e)
1191 System.err.println("Ignoring invalid residue number string '"
1203 * jalview.bin.JalviewLiteJsApi#scrollViewToIn(jalview.appletgui.AlignFrame,
1204 * java.lang.String, java.lang.String)
1207 public void scrollViewToIn(final AlignFrame alf, final String topRow,
1208 final String leftHandColumn)
1210 java.awt.EventQueue.invokeLater(new Runnable()
1217 alf.scrollTo(new Integer(topRow).intValue(),
1218 new Integer(leftHandColumn).intValue());
1220 } catch (Exception ex)
1222 System.err.println("Couldn't parse integer arguments (topRow='"
1223 + topRow + "' and leftHandColumn='" + leftHandColumn
1225 ex.printStackTrace();
1235 * jalview.javascript.JalviewLiteJsApi#scrollViewToRowIn(jalview.appletgui
1236 * .AlignFrame, java.lang.String)
1239 public void scrollViewToRowIn(final AlignFrame alf, final String topRow)
1242 java.awt.EventQueue.invokeLater(new Runnable()
1249 alf.scrollToRow(new Integer(topRow).intValue());
1251 } catch (Exception ex)
1253 System.err.println("Couldn't parse integer arguments (topRow='"
1255 ex.printStackTrace();
1266 * jalview.javascript.JalviewLiteJsApi#scrollViewToColumnIn(jalview.appletgui
1267 * .AlignFrame, java.lang.String)
1270 public void scrollViewToColumnIn(final AlignFrame alf,
1271 final String leftHandColumn)
1273 java.awt.EventQueue.invokeLater(new Runnable()
1281 alf.scrollToColumn(new Integer(leftHandColumn).intValue());
1283 } catch (Exception ex)
1286 "Couldn't parse integer arguments (leftHandColumn='"
1287 + leftHandColumn + "')");
1288 ex.printStackTrace();
1295 // //////////////////////////////////////////////
1296 // //////////////////////////////////////////////
1298 public static int lastFrameX = 200;
1300 public static int lastFrameY = 200;
1302 boolean fileFound = true;
1304 String file = "No file";
1306 String file2 = null;
1308 Button launcher = new Button(
1309 MessageManager.getString("label.start_jalview"));
1312 * The currentAlignFrame is static, it will change if and when the user
1313 * selects a new window. Note that it will *never* point back to the embedded
1314 * AlignFrame if the applet is started as embedded on the page and then
1315 * afterwards a new view is created.
1317 public AlignFrame currentAlignFrame = null;
1320 * This is the first frame to be displayed, and does not change. API calls
1321 * will default to this instance if currentAlignFrame is null.
1323 AlignFrame initialAlignFrame = null;
1325 boolean embedded = false;
1327 private boolean checkForJmol = true;
1329 private boolean checkedForJmol = false; // ensure we don't check for jmol
1331 // every time the app is re-inited
1333 public boolean jmolAvailable = false;
1335 private boolean alignPdbStructures = false;
1338 * use an external structure viewer exclusively (no jmols or mc_views will be
1339 * opened by JalviewLite itself)
1341 public boolean useXtrnalSviewer = false;
1343 public JalviewAppLoader appLoader;
1345 public AlignFrame loaderFrame;
1347 public static boolean debug = false;
1349 static String builddate = null, version = null, installation = null;
1351 private static void initBuildDetails()
1353 if (builddate == null)
1355 builddate = "unknown";
1357 installation = "applet";
1358 java.net.URL url = JalviewLite.class
1359 .getResource("/.build_properties");
1364 BufferedReader reader = new BufferedReader(
1365 new InputStreamReader(url.openStream()));
1367 while ((line = reader.readLine()) != null)
1369 if (line.indexOf("VERSION") > -1)
1371 version = line.substring(line.indexOf("=") + 1);
1373 if (line.indexOf("BUILD_DATE") > -1)
1375 builddate = line.substring(line.indexOf("=") + 1);
1377 if (line.indexOf("INSTALLATION") > -1)
1379 installation = line.substring(line.indexOf("=") + 1);
1382 } catch (Exception ex)
1384 ex.printStackTrace();
1390 public static String getBuildDate()
1396 public static String getInstallation()
1399 return installation;
1402 public static String getVersion()
1408 // public JSObject scriptObject = null;
1411 * init method for Jalview Applet
1416 debug = TRUE.equalsIgnoreCase(getParameter("debug"));
1421 System.err.println("Applet context is '"
1422 + getAppletContext().getClass().toString() + "'");
1424 JSObject scriptObject = JSObject.getWindow(this);
1425 if (debug && scriptObject != null)
1427 System.err.println("Applet has Javascript callback support.");
1430 } catch (Exception ex)
1433 "Warning: No JalviewLite javascript callbacks available.");
1436 ex.printStackTrace();
1442 System.err.println("JalviewLite Version " + getVersion());
1443 System.err.println("Build Date : " + getBuildDate());
1444 System.err.println("Installation : " + getInstallation());
1446 String externalsviewer = getParameter("externalstructureviewer");
1447 if (externalsviewer != null)
1449 useXtrnalSviewer = externalsviewer.trim().toLowerCase().equals(TRUE);
1452 * if true disable the check for jmol
1454 String chkforJmol = getParameter("nojmol");
1455 if (chkforJmol != null)
1457 checkForJmol = !chkforJmol.equals(TRUE);
1460 * get the separator parameter if present
1462 String sep = getParameter("separator");
1465 if (sep.length() > 0)
1470 System.err.println("Separator set to '" + separator + "'");
1475 throw new Error(MessageManager
1476 .getString("error.invalid_separator_parameter"));
1482 String param = getParameter("RGB");
1488 r = Integer.parseInt(param.substring(0, 2), 16);
1489 g = Integer.parseInt(param.substring(2, 4), 16);
1490 b = Integer.parseInt(param.substring(4, 6), 16);
1491 } catch (Exception ex)
1498 param = getParameter("label");
1501 launcher.setLabel(param);
1504 setBackground(new Color(r, g, b));
1506 file = getParameter("file");
1510 // Maybe the sequences are added as parameters
1511 StringBuffer data = new StringBuffer("PASTE");
1513 while ((file = getParameter("sequence" + i)) != null)
1515 data.append(file.toString() + "\n");
1518 if (data.length() > 5)
1520 file = data.toString();
1523 if (getDefaultParameter("enableSplitFrame", true))
1525 file2 = getParameter("file2");
1528 embedded = TRUE.equalsIgnoreCase(getParameter("embedded"));
1531 LoadingThread loader = new LoadingThread(file, file2, this);
1534 else if (file != null)
1537 * Start the applet immediately or show a button to start it
1539 if (FALSE.equalsIgnoreCase(getParameter("showbutton")))
1541 LoadingThread loader = new LoadingThread(file, file2, this);
1547 launcher.addActionListener(new java.awt.event.ActionListener()
1550 public void actionPerformed(ActionEvent e)
1552 LoadingThread loader = new LoadingThread(file, file2,
1561 // jalview initialisation with no alignment. loadAlignment() method can
1562 // still be called to open new alignments.
1569 private void initLiveConnect()
1571 // try really hard to get the liveConnect thing working
1572 boolean notFailed = false;
1574 while (!notFailed && tries < 10)
1578 System.err.println("LiveConnect request thread going to sleep.");
1582 Thread.sleep(700 * (1 + tries));
1583 } catch (InterruptedException q)
1589 System.err.println("LiveConnect request thread woken up.");
1593 JSObject scriptObject = JSObject.getWindow(this);
1594 if (scriptObject.eval("navigator") != null)
1598 } catch (Exception jsex)
1600 System.err.println("Attempt " + tries
1601 + " to access LiveConnect javascript failed.");
1606 private void callInitCallback()
1608 String initjscallback = getParameter("oninit");
1609 if (initjscallback == null)
1613 initjscallback = initjscallback.trim();
1614 if (initjscallback.length() > 0)
1616 JSObject scriptObject = null;
1619 scriptObject = JSObject.getWindow(this);
1620 } catch (Exception ex)
1624 // try really hard to let the browser plugin know we want liveconnect
1627 if (scriptObject != null)
1631 // do onInit with the JS executor thread
1632 new JSFunctionExec(this).executeJavascriptFunction(true,
1633 initjscallback, null,
1634 "Calling oninit callback '" + initjscallback + "'.");
1635 } catch (Exception e)
1637 System.err.println("Exception when executing _oninit callback '"
1638 + initjscallback + "'.");
1639 e.printStackTrace();
1644 System.err.println("Not executing _oninit callback '"
1645 + initjscallback + "' - no scripting allowed.");
1651 * Initialises and displays a new java.awt.Frame
1654 * java.awt.Frame to be displayed
1656 * title of new frame
1658 * width if new frame
1660 * height of new frame
1662 public static void addFrame(final Frame frame, String title, int width,
1665 frame.setLocation(lastFrameX, lastFrameY);
1668 frame.setSize(width, height);
1669 frame.setTitle(title);
1670 frame.addWindowListener(new WindowAdapter()
1673 public void windowClosing(WindowEvent e)
1675 if (frame instanceof AlignFrame)
1677 AlignViewport vp = ((AlignFrame) frame).viewport;
1678 ((AlignFrame) frame).closeMenuItem_actionPerformed();
1679 if (vp.applet.currentAlignFrame == frame)
1681 vp.applet.currentAlignFrame = null;
1689 if (frame instanceof EmbmenuFrame)
1691 ((EmbmenuFrame) frame).destroyMenus();
1693 frame.setMenuBar(null);
1698 public void windowActivated(WindowEvent e)
1700 if (frame instanceof AlignFrame)
1702 ((AlignFrame) frame).viewport.applet.currentAlignFrame = (AlignFrame) frame;
1705 System.err.println("Activated window " + frame);
1709 super.windowActivated(e);
1712 * Probably not necessary to do this - see TODO above. (non-Javadoc)
1715 * java.awt.event.WindowAdapter#windowDeactivated(java.awt.event.WindowEvent
1718 * public void windowDeactivated(WindowEvent e) { if (currentAlignFrame ==
1719 * frame) { currentAlignFrame = null; if (debug) {
1720 * System.err.println("Deactivated window "+frame); } }
1721 * super.windowDeactivated(e); }
1724 frame.setVisible(true);
1728 * This paints the background surrounding the "Launch Jalview button" <br>
1730 * If file given in parameter not found, displays error message
1736 public void paint(Graphics g)
1740 g.setColor(new Color(200, 200, 200));
1741 g.setColor(Color.cyan);
1742 g.fillRect(0, 0, getSize().width, getSize().height);
1743 g.setColor(Color.red);
1745 MessageManager.getString("label.jalview_cannot_open_file"), 5,
1747 g.drawString("\"" + file + "\"", 5, 30);
1751 g.setColor(Color.black);
1752 g.setFont(new Font("Arial", Font.BOLD, 24));
1753 g.drawString(MessageManager.getString("label.jalview_applet"), 50,
1754 getSize().height / 2 - 30);
1755 g.drawString(MessageManager.getString("label.loading_data") + "...",
1756 50, getSize().height / 2);
1761 * get all components associated with the applet of the given type
1766 public Vector getAppletWindow(Class class1)
1768 Vector wnds = new Vector();
1769 Component[] cmp = getComponents();
1772 for (int i = 0; i < cmp.length; i++)
1774 if (class1.isAssignableFrom(cmp[i].getClass()))
1776 wnds.addElement(cmp);
1783 class LoadJmolThread extends Thread
1785 private boolean running = false;
1790 if (running || checkedForJmol)
1799 if (!System.getProperty("java.version").startsWith("1.1"))
1801 Class.forName("org.jmol.adapter.smarter.SmarterJmolAdapter");
1802 jmolAvailable = true;
1807 "Jmol not available - Using mc_view for structures");
1809 } catch (java.lang.ClassNotFoundException ex)
1815 jmolAvailable = false;
1819 "Skipping Jmol check. Will use mc_view (probably)");
1822 checkedForJmol = true;
1826 public boolean notFinished()
1828 return running || !checkedForJmol;
1832 class LoadingThread extends Thread
1835 * State variable: protocol for access to file source
1837 DataSourceType protocol;
1839 String _file; // alignment file or URL spec
1841 String _file2; // second alignment file or URL spec
1845 public void dbgMsg(String msg)
1847 if (JalviewLite.debug)
1849 System.err.println(msg);
1854 * update the protocol state variable for accessing the datasource located
1858 * @return possibly updated datasource string
1860 public String resolveFileProtocol(String path)
1863 String[] ret = new String[] { path };
1864 protocol = JalviewAppLoader.resolveFileProtocol(applet, ret);
1868 public LoadingThread(String file, String file2, JalviewLite _applet)
1871 this._file2 = file2;
1878 LoadJmolThread jmolchecker = new LoadJmolThread();
1879 jmolchecker.start();
1880 while (jmolchecker.notFinished())
1882 // wait around until the Jmol check is complete.
1886 } catch (Exception e)
1891 // applet.callInitCallback();
1895 * Load the alignment and any related files as specified by applet
1898 private void startLoading()
1900 dbgMsg("Loading thread started with:\n>>file\n" + _file
1903 dbgMsg("Loading started.");
1905 AlignFrame newAlignFrame = readAlignment(_file);
1906 AlignFrame newAlignFrame2 = readAlignment(_file2);
1907 if (newAlignFrame != null)
1909 addToDisplay(newAlignFrame, newAlignFrame2);
1910 applet.loaderFrame = newAlignFrame;
1911 appLoader.load(applet);
1916 applet.remove(launcher);
1923 * Add an AlignFrame to the display; or if two are provided, a SplitFrame.
1928 public void addToDisplay(AlignFrame af, AlignFrame af2)
1932 AlignmentI al1 = af.viewport.getAlignment();
1933 AlignmentI al2 = af2.viewport.getAlignment();
1934 AlignmentI cdna = al1.isNucleotide() ? al1 : al2;
1935 AlignmentI prot = al1.isNucleotide() ? al2 : al1;
1936 if (AlignmentUtils.mapProteinAlignmentToCdna(prot, cdna))
1939 SplitFrame sf = new SplitFrame(af, af2);
1940 sf.addToDisplay(embedded, JalviewLite.this);
1945 String msg = "Could not map any sequence in " + af2.getTitle()
1947 + (al1.isNucleotide() ? "protein product" : "cDNA")
1948 + " for " + af.getTitle();
1949 System.err.println(msg);
1953 af.addToDisplay(embedded);
1957 * Read the alignment file (from URL, text 'paste', or archive by
1962 protected AlignFrame readAlignment(String fileParam)
1964 if (fileParam == null)
1968 String resolvedFile = resolveFileProtocol(fileParam);
1969 AlignmentI al = null;
1972 FileFormatI format = new IdentifyFile().identify(resolvedFile,
1974 dbgMsg("File identified as '" + format + "'");
1975 al = new AppletFormatAdapter().readFile(resolvedFile, protocol,
1977 if ((al != null) && (al.getHeight() > 0))
1979 dbgMsg("Successfully loaded file.");
1980 al.setDataset(null);
1981 AlignFrame newAlignFrame = new AlignFrame(al, applet,
1982 resolvedFile, embedded, false);
1983 newAlignFrame.setTitle(resolvedFile);
1984 if (initialAlignFrame == null)
1986 initialAlignFrame = newAlignFrame;
1988 // update the focus.
1989 currentAlignFrame = newAlignFrame;
1991 if (protocol == DataSourceType.PASTE)
1993 newAlignFrame.setTitle(MessageManager
1994 .formatMessage("label.sequences_from", new Object[]
1995 { applet.getDocumentBase().toString() }));
1998 newAlignFrame.statusBar.setText(MessageManager.formatMessage(
1999 "label.successfully_loaded_file", new Object[]
2002 return newAlignFrame;
2004 } catch (java.io.IOException ex)
2006 dbgMsg("File load exception.");
2007 ex.printStackTrace();
2012 FileParse fp = new FileParse(resolvedFile, protocol);
2014 dbgMsg(">>>Dumping contents of '" + resolvedFile + "' " + "("
2016 while ((ln = fp.nextLine()) != null)
2020 dbgMsg(">>>Dump finished.");
2021 } catch (Exception e)
2024 "Exception when trying to dump the content of the file parameter.");
2025 e.printStackTrace();
2035 * @return the default alignFrame acted on by the public applet methods. May
2036 * return null with an error message on System.err indicating the
2039 public AlignFrame getDefaultTargetFrame()
2041 if (currentAlignFrame != null)
2043 return currentAlignFrame;
2045 if (initialAlignFrame != null)
2047 return initialAlignFrame;
2050 "Implementation error: Jalview Applet API cannot work out which AlignFrame to use.");
2055 * separator used for separatorList
2057 protected String separator = "" + ((char) 0x00AC); // the default used to be
2058 // '|' but many sequence
2059 // IDS include pipes.
2062 * set to enable the URL based javascript execution mechanism
2064 public boolean jsfallbackEnabled = false;
2067 * parse the string into a list
2070 * @return elements separated by separator
2072 public String[] separatorListToArray(String list)
2074 return JalviewAppLoader.separatorListToArray(list, separator);
2078 * concatenate the list with separator
2081 * @return concatenated string
2083 public String arrayToSeparatorList(String[] list)
2085 return arrayToSeparatorList(list, separator);
2089 * concatenate the list with separator
2093 * @return concatenated string
2095 public static String arrayToSeparatorList(String[] list, String separator)
2097 // TODO use StringUtils version
2098 StringBuffer v = new StringBuffer();
2099 if (list != null && list.length > 0)
2101 for (int i = 0, iSize = list.length; i < iSize; i++)
2103 if (list[i] != null)
2107 v.append(separator);
2115 .println("Returning '" + separator + "' separated List:\n");
2116 System.err.println(v);
2118 return v.toString();
2123 "Returning empty '" + separator + "' separated List\n");
2125 return "" + separator;
2131 * @see jalview.bin.JalviewLiteJsApi#getFeatureGroups()
2134 public String getFeatureGroups()
2136 String lst = arrayToSeparatorList(
2137 getDefaultTargetFrame().getFeatureGroups());
2145 * jalview.bin.JalviewLiteJsApi#getFeatureGroupsOn(jalview.appletgui.AlignFrame
2149 public String getFeatureGroupsOn(AlignFrame alf)
2151 String lst = arrayToSeparatorList(alf.getFeatureGroups());
2158 * @see jalview.bin.JalviewLiteJsApi#getFeatureGroupsOfState(boolean)
2161 public String getFeatureGroupsOfState(boolean visible)
2163 return arrayToSeparatorList(
2164 getDefaultTargetFrame().getFeatureGroupsOfState(visible));
2171 * jalview.bin.JalviewLiteJsApi#getFeatureGroupsOfStateOn(jalview.appletgui
2172 * .AlignFrame, boolean)
2175 public String getFeatureGroupsOfStateOn(AlignFrame alf, boolean visible)
2177 return arrayToSeparatorList(alf.getFeatureGroupsOfState(visible));
2183 * @see jalview.bin.JalviewLiteJsApi#setFeatureGroupStateOn(jalview.appletgui.
2184 * AlignFrame, java.lang.String, boolean)
2187 public void setFeatureGroupStateOn(final AlignFrame alf,
2188 final String groups, boolean state)
2190 final boolean st = state;// !(state==null || state.equals("") ||
2191 // state.toLowerCase().equals("false"));
2192 java.awt.EventQueue.invokeLater(new Runnable()
2197 alf.setFeatureGroupState(separatorListToArray(groups), st);
2205 * @see jalview.bin.JalviewLiteJsApi#setFeatureGroupState(java.lang.String,
2209 public void setFeatureGroupState(String groups, boolean state)
2211 setFeatureGroupStateOn(getDefaultTargetFrame(), groups, state);
2217 * @see jalview.bin.JalviewLiteJsApi#getSeparator()
2220 public String getSeparator()
2228 * @see jalview.bin.JalviewLiteJsApi#setSeparator(java.lang.String)
2231 public void setSeparator(String separator)
2233 if (separator == null || separator.length() < 1)
2236 separator = "" + ((char) 0x00AC);
2238 this.separator = separator;
2241 System.err.println("Default Separator now: '" + separator + "'");
2246 * get boolean value of applet parameter 'name' and return default if
2247 * parameter is not set
2252 * the value to return otherwise
2253 * @return true or false
2256 public boolean getDefaultParameter(String name, boolean def)
2259 if ((stn = getParameter(name)) == null)
2263 if (TRUE.equalsIgnoreCase(stn))
2273 * @see jalview.bin.JalviewLiteJsApi#addPdbFile(jalview.appletgui.AlignFrame,
2274 * java.lang.String, java.lang.String, java.lang.String)
2277 public boolean addPdbFile(AlignFrame alFrame, String sequenceId,
2278 String pdbEntryString, String pdbFile)
2280 return alFrame.addPdbFile(sequenceId, pdbEntryString, pdbFile);
2284 public void setAlignPdbStructures(boolean alignPdbStructures)
2286 this.alignPdbStructures = alignPdbStructures;
2289 public boolean isAlignPdbStructures()
2291 return alignPdbStructures;
2297 // callInitCallback();
2300 private Hashtable<String, long[]> jshashes = new Hashtable<>();
2302 private Hashtable<String, Hashtable<String, String[]>> jsmessages = new Hashtable<>();
2304 public void setJsMessageSet(String messageclass, String viewId,
2305 String[] colcommands)
2307 Hashtable<String, String[]> msgset = jsmessages.get(messageclass);
2310 msgset = new Hashtable<>();
2311 jsmessages.put(messageclass, msgset);
2313 msgset.put(viewId, colcommands);
2314 long[] l = new long[colcommands.length];
2315 for (int i = 0; i < colcommands.length; i++)
2317 l[i] = colcommands[i].hashCode();
2319 jshashes.put(messageclass + "|" + viewId, l);
2325 * @see jalview.bin.JalviewLiteJsApi#getJsMessage(java.lang.String,
2329 public String getJsMessage(String messageclass, String viewId)
2331 Hashtable<String, String[]> msgset = jsmessages.get(messageclass);
2334 String[] msgs = msgset.get(viewId);
2337 for (int i = 0; i < msgs.length; i++)
2339 if (msgs[i] != null)
2351 public boolean isJsMessageSetChanged(String string, String string2,
2352 String[] colcommands)
2354 long[] l = jshashes.get(string + "|" + string2);
2355 if (l == null && colcommands != null)
2359 for (int i = 0; i < colcommands.length; i++)
2361 if (l[i] != colcommands[i].hashCode())
2369 private Vector jsExecQueue = new Vector();
2371 public Vector getJsExecQueue()
2376 public void setExecutor(JSFunctionExec jsFunctionExec2)
2378 jsFunctionExec = jsFunctionExec2;
2382 * return the given colour value parameter or the given default if parameter
2389 public Color getDefaultColourParameter(String colparam, Color defcolour)
2391 String colprop = getParameter(colparam);
2392 if (colprop == null || colprop.trim().length() == 0)
2396 Color col = ColorUtils.parseColourString(colprop);
2399 System.err.println("Couldn't parse '" + colprop + "' as a colour for "
2402 return (col == null) ? defcolour : col;
2405 public void openJalviewHelpUrl()
2407 String helpUrl = getParameter("jalviewhelpurl");
2408 if (helpUrl == null || helpUrl.trim().length() < 5)
2410 helpUrl = "http://www.jalview.org/help.html";
2412 showURL(helpUrl, "HELP");
2416 * open a URL in the browser - resolving it according to relative refs and
2417 * coping with javascript: protocol if necessary.
2422 public void showURL(String url, String target)
2426 if (url.indexOf(":") == -1)
2428 // TODO: verify (Bas Vroling bug) prepend codebase or server URL to
2430 // Should really use docbase, not codebase.
2432 url = JalviewAppLoader.resolveUrlForLocalOrAbsolute(url,
2433 prepend = getDefaultParameter("resolvetocodebase", false)
2435 : getDocumentBase());
2438 System.err.println("Show url (prepended " + prepend
2439 + " - toggle resolvetocodebase if code/docbase resolution is wrong): "
2447 System.err.println("Show url: " + url);
2450 if (url.indexOf("javascript:") == 0)
2452 // no target for the javascript context
2453 getAppletContext().showDocument(new java.net.URL(url));
2457 getAppletContext().showDocument(new java.net.URL(url), target);
2459 } catch (Exception ex)
2461 ex.printStackTrace();
2466 public AlignViewportI getViewport()
2468 return loaderFrame.getAlignViewport();
2472 public void newStructureView(PDBEntry pdb, SequenceI[] seqs,
2473 String[] chains, DataSourceType protocol)
2475 loaderFrame.newStructureView(this, pdb, seqs, chains,
2480 public void alignedStructureView(PDBEntry[] pdb, SequenceI[][] seqs,
2481 String[][] chains, String[] protocols)
2483 loaderFrame.alignedStructureView(this, pdb, seqs, chains, protocols);
2487 public void updateForLoader()
2489 loaderFrame.alignPanel.fontChanged();
2490 loaderFrame.alignPanel.setScrollValues(0, 0);
2494 public void setFeatureGroupState(String[] groups, boolean state)
2496 loaderFrame.setFeatureGroupState(groups, state);
2500 public boolean parseFeaturesFile(String param, DataSourceType protocol)
2502 return loaderFrame.parseFeaturesFile(param, protocol);
2506 public void newFeatureSettings()
2508 getViewport().setShowSequenceFeatures(true);
2509 new FeatureSettings(loaderFrame.alignPanel);
2513 public boolean loadScoreFile(String sScoreFile) throws IOException
2515 return loaderFrame.loadScoreFile(sScoreFile);
2519 public void loadTree(NewickFile tree, String treeFile) throws IOException
2521 loaderFrame.loadTree(tree, treeFile);
2525 * bind structures in a viewer to any matching sequences in an alignFrame (use
2526 * sequenceIds to limit scope of search to specific sequences)
2530 * @param sequenceIds
2531 * @return TODO: consider making an exception structure for indicating when
2532 * binding fails public SequenceStructureBinding
2533 * addStructureViewInstance( AlignFrame alFrame, Object viewer, String
2536 * if (sequenceIds != null && sequenceIds.length() > 0) { return
2537 * alFrame.addStructureViewInstance(viewer,
2538 * separatorListToArray(sequenceIds)); } else { return
2539 * alFrame.addStructureViewInstance(viewer, null); } // return null; }