2 * Jalview - A Sequence Alignment Editor and Viewer
3 * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Softwarechang
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26 import java.awt.datatransfer.*;
27 import java.awt.event.*;
28 import java.awt.print.*;
31 import jalview.analysis.*;
32 import jalview.datamodel.*;
34 import jalview.jbgui.*;
35 import jalview.schemes.*;
36 import jalview.util.ShiftList;
37 import jalview.commands.*;
39 import java.awt.dnd.*;
47 public class AlignFrame extends GAlignFrame implements DropTargetListener
50 public static final int DEFAULT_WIDTH = 700;
53 public static final int DEFAULT_HEIGHT = 500;
54 public AlignmentPanel alignPanel;
55 AlignViewport viewport;
58 Vector alignPanels = new Vector();
62 public String currentFileFormat = null;
63 Stack historyList = new Stack();
64 Stack redoList = new Stack();
65 private int treeCount = 0;
68 * Creates a new AlignFrame object.
70 * @param al DOCUMENT ME!
72 public AlignFrame(AlignmentI al, int width, int height)
74 this(al, null, width, height);
79 * new alignment window with hidden columns
80 * @param al AlignmentI
81 * @param hiddenColumns ColumnSelection or null
83 public AlignFrame(AlignmentI al, ColumnSelection hiddenColumns,
84 int width, int height)
86 this.setSize(width, height);
87 viewport = new AlignViewport(al, hiddenColumns);
89 alignPanel = new AlignmentPanel(this, viewport);
91 if(al.getDataset()==null)
96 addAlignmentPanel(alignPanel);
101 * Make a new AlignFrame from exisiting alignmentPanels
102 * @param ap AlignmentPanel
103 * @param av AlignViewport
105 public AlignFrame(AlignmentPanel ap)
109 addAlignmentPanel(ap);
115 this.setDropTarget(new java.awt.dnd.DropTarget(this, this));
117 if (viewport.conservation == null)
119 BLOSUM62Colour.setEnabled(false);
120 conservationMenuItem.setEnabled(false);
121 modifyConservation.setEnabled(false);
122 // PIDColour.setEnabled(false);
123 // abovePIDThreshold.setEnabled(false);
124 // modifyPID.setEnabled(false);
127 String sortby = jalview.bin.Cache.getDefault("SORT_ALIGNMENT", "No sort");
129 if (sortby.equals("Id"))
130 sortIDMenuItem_actionPerformed(null);
131 else if (sortby.equals("Pairwise Identity"))
132 sortPairwiseMenuItem_actionPerformed(null);
134 if (Desktop.desktop != null)
136 addServiceListeners();
137 setGUINucleotide(viewport.alignment.isNucleotide());
140 if (jalview.bin.Cache.getDefault("WRAP_ALIGNMENT", false))
142 wrapMenuItem.setSelected(true);
143 wrapMenuItem_actionPerformed(null);
149 void addKeyListener()
151 final AlignFrame af = this;
152 addKeyListener(new KeyAdapter()
154 public void keyPressed(KeyEvent evt)
156 if (viewport.cursorMode
157 && evt.getKeyCode() >= KeyEvent.VK_0
158 && evt.getKeyCode() <= KeyEvent.VK_9)
160 alignPanel.seqPanel.numberPressed(evt.getKeyChar());
163 switch (evt.getKeyCode())
166 if (!evt.isControlDown())
169 if(viewport.hasHiddenRows)
171 al = viewport.alignment.getHiddenSequences().getFullAlignment();
174 al = new Alignment(viewport.alignment.getSequencesArray());
176 AlignViewport newview = new AlignViewport(al);
178 AlignmentPanel copy = new AlignmentPanel(af, newview);
180 if(viewport.viewName==null)
181 viewport.viewName="View 1";
183 copy.av.sequenceSetID = viewport.getSequenceSetId();
184 copy.av.viewName = "View " +
185 (Desktop.getViewCount(viewport.getSequenceSetId())+1);
188 addAlignmentPanel(copy);
189 PaintRefresher.Register(copy, viewport.getSequenceSetId());
190 PaintRefresher.Register(alignPanel,
191 viewport.getSequenceSetId());
196 Desktop.instance.gatherViews(af);
200 if (!evt.isControlDown())
202 Desktop.instance.explodeViews(af);
207 case 27: // escape key
208 deselectAllSequenceMenuItem_actionPerformed(null);
212 case KeyEvent.VK_DOWN:
213 if (viewport.cursorMode)
215 alignPanel.seqPanel.moveCursor(0, 1);
218 moveSelectedSequences(false);
222 if (viewport.cursorMode)
224 alignPanel.seqPanel.moveCursor(0, -1);
227 moveSelectedSequences(true);
230 case KeyEvent.VK_LEFT:
231 if (viewport.cursorMode)
233 alignPanel.seqPanel.moveCursor( -1, 0);
237 case KeyEvent.VK_RIGHT:
238 if (viewport.cursorMode)
240 alignPanel.seqPanel.moveCursor(1, 0);
244 case KeyEvent.VK_SPACE:
245 if (viewport.cursorMode)
247 alignPanel.seqPanel.insertGapAtCursor(evt.isControlDown()
253 case KeyEvent.VK_DELETE:
254 case KeyEvent.VK_BACK_SPACE:
255 if (!viewport.cursorMode)
257 cut_actionPerformed(null);
260 alignPanel.seqPanel.deleteGapAtCursor(evt.isControlDown()
267 if (viewport.cursorMode)
269 alignPanel.seqPanel.setCursorRow();
273 if (viewport.cursorMode && !evt.isControlDown())
275 alignPanel.seqPanel.setCursorColumn();
279 if (viewport.cursorMode)
281 alignPanel.seqPanel.setCursorPosition();
285 case KeyEvent.VK_ENTER:
286 case KeyEvent.VK_COMMA:
287 if (viewport.cursorMode)
289 alignPanel.seqPanel.setCursorRowAndColumn();
294 if (viewport.cursorMode)
296 alignPanel.seqPanel.setSelectionAreaAtCursor(true);
300 if (viewport.cursorMode)
302 alignPanel.seqPanel.setSelectionAreaAtCursor(false);
307 viewport.cursorMode = !viewport.cursorMode;
308 statusBar.setText("Keyboard editing mode is " +
309 (viewport.cursorMode ? "on" : "off"));
310 if (viewport.cursorMode)
312 alignPanel.seqPanel.seqCanvas.cursorX = viewport.startRes;
313 alignPanel.seqPanel.seqCanvas.cursorY = viewport.startSeq;
315 alignPanel.seqPanel.seqCanvas.repaint();
321 ClassLoader cl = jalview.gui.Desktop.class.getClassLoader();
322 java.net.URL url = javax.help.HelpSet.findHelpSet(cl, "help/help");
323 javax.help.HelpSet hs = new javax.help.HelpSet(cl, url);
325 javax.help.HelpBroker hb = hs.createHelpBroker();
326 hb.setCurrentID("home");
327 hb.setDisplayed(true);
331 ex.printStackTrace();
337 boolean toggleSeqs = !evt.isControlDown();
338 boolean toggleCols = !evt.isShiftDown();
340 boolean hide = false;
342 SequenceGroup sg = viewport.getSelectionGroup();
345 if (sg != null && sg.getSize(false) != viewport.alignment.getHeight())
347 hideSelSequences_actionPerformed(null);
350 else if (! (toggleCols && viewport.colSel.getSelected().size() > 0))
351 showAllSeqs_actionPerformed(null);
356 if (viewport.colSel.getSelected().size() > 0)
358 hideSelColumns_actionPerformed(null);
360 viewport.selectionGroup = sg;
363 showAllColumns_actionPerformed(null);
367 case KeyEvent.VK_PAGE_UP:
368 if (viewport.wrapAlignment)
369 alignPanel.scrollUp(true);
371 alignPanel.setScrollValues(viewport.startRes,
373 - viewport.endSeq + viewport.startSeq);
375 case KeyEvent.VK_PAGE_DOWN:
376 if (viewport.wrapAlignment)
377 alignPanel.scrollUp(false);
379 alignPanel.setScrollValues(viewport.startRes,
381 + viewport.endSeq - viewport.startSeq);
391 public void addAlignmentPanel(final AlignmentPanel ap)
393 alignPanels.addElement(ap);
395 int aSize = alignPanels.size();
397 tabbedPane.setVisible(aSize>1 || ap.av.viewName!=null);
399 if (aSize == 1 && ap.av.viewName==null)
401 this.getContentPane().add(ap, BorderLayout.CENTER);
407 AlignmentPanel first = (AlignmentPanel) alignPanels.firstElement();
408 tabbedPane.addTab(first.av.viewName==null?"Original":first.av.viewName,first);
410 this.getContentPane().add(tabbedPane, BorderLayout.CENTER);
413 tabbedPane.addTab(ap.av.viewName==null?"Original":ap.av.viewName, ap);
416 ap.av.updateConsensus(ap);
417 ap.av.updateConservation(ap);
420 ap.av.addPropertyChangeListener(new PropertyChangeListener()
422 public void propertyChange(PropertyChangeEvent evt)
424 if (evt.getPropertyName().equals("alignment"))
426 PaintRefresher.Refresh(ap, ap.av.getSequenceSetId());
437 public AlignViewport getViewport()
442 /* Set up intrinsic listeners for dynamically generated GUI bits. */
443 private void addServiceListeners()
445 final java.beans.PropertyChangeListener thisListener;
446 // Do this once to get current state
447 BuildWebServiceMenu();
448 Desktop.discoverer.addPropertyChangeListener(
449 thisListener = new java.beans.PropertyChangeListener()
451 public void propertyChange(PropertyChangeEvent evt)
453 // System.out.println("Discoverer property change.");
454 if (evt.getPropertyName().equals("services"))
456 // System.out.println("Rebuilding web service menu");
457 BuildWebServiceMenu();
462 addInternalFrameListener(new javax.swing.event.
463 InternalFrameAdapter()
465 public void internalFrameClosed(
466 javax.swing.event.InternalFrameEvent evt)
468 // System.out.println("deregistering discoverer listener");
469 Desktop.discoverer.removePropertyChangeListener(thisListener);
470 closeMenuItem_actionPerformed(null);
476 public void setGUINucleotide(boolean nucleotide)
478 showTranslation.setVisible( nucleotide );
479 //sequenceFeatures.setVisible(!nucleotide );
480 //featureSettings.setVisible( !nucleotide );
481 conservationMenuItem.setVisible( !nucleotide );
482 modifyConservation.setVisible( !nucleotide );
484 //Remember AlignFrame always starts as protein
487 calculateMenu.remove(calculateMenu.getItemCount()-2);
492 Hashtable progressBars;
493 public void setProgressBar(String message, long id)
495 if(progressBars == null)
496 progressBars = new Hashtable();
498 JPanel progressPanel;
499 GridLayout layout = (GridLayout) statusPanel.getLayout();
500 if(progressBars.get( new Long(id) )!=null)
502 progressPanel = (JPanel)progressBars.get( new Long(id) );
503 statusPanel.remove(progressPanel);
504 progressBars.remove( progressPanel );
505 progressPanel = null;
507 statusBar.setText(message);
509 layout.setRows(layout.getRows() - 1);
513 progressPanel = new JPanel(new BorderLayout(10, 5));
515 JProgressBar progressBar = new JProgressBar();
516 progressBar.setIndeterminate(true);
518 progressPanel.add(new JLabel(message), BorderLayout.WEST);
519 progressPanel.add(progressBar, BorderLayout.CENTER);
521 layout.setRows(layout.getRows() + 1);
522 statusPanel.add(progressPanel);
524 progressBars.put(new Long(id), progressPanel);
534 Added so Castor Mapping file can obtain Jalview Version
536 public String getVersion()
538 return jalview.bin.Cache.getProperty("VERSION");
541 public FeatureRenderer getFeatureRenderer()
543 return alignPanel.seqPanel.seqCanvas.getFeatureRenderer();
547 public void fetchSequence_actionPerformed(ActionEvent e)
549 new SequenceFetcher(this);
552 public void addFromFile_actionPerformed(ActionEvent e)
554 Desktop.instance.inputLocalFileMenuItem_actionPerformed(viewport);
557 public void addFromText_actionPerformed(ActionEvent e)
559 Desktop.instance.inputTextboxMenuItem_actionPerformed(viewport);
562 public void addFromURL_actionPerformed(ActionEvent e)
564 Desktop.instance.inputURLMenuItem_actionPerformed(viewport);
570 * @param e DOCUMENT ME!
572 public void saveAlignmentMenu_actionPerformed(ActionEvent e)
574 JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
575 getProperty( "LAST_DIRECTORY"),
577 { "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc","jar" },
579 { "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview" },
584 chooser.setFileView(new JalviewFileView());
585 chooser.setDialogTitle("Save Alignment to file");
586 chooser.setToolTipText("Save");
588 int value = chooser.showSaveDialog(this);
590 if (value == JalviewFileChooser.APPROVE_OPTION)
592 currentFileFormat = chooser.getSelectedFormat();
594 if (currentFileFormat == null)
596 JOptionPane.showInternalMessageDialog(Desktop.desktop,
597 "You must select a file format before saving!",
598 "File format not specified",
599 JOptionPane.WARNING_MESSAGE);
600 value = chooser.showSaveDialog(this);
604 jalview.bin.Cache.setProperty("DEFAULT_FILE_FORMAT",
607 String choice = chooser.getSelectedFile().getPath();
608 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
610 saveAlignment(choice, currentFileFormat);
614 public boolean saveAlignment(String file, String format)
616 if (format.equalsIgnoreCase("Jalview"))
618 String shortName = title;
620 if (shortName.indexOf(java.io.File.separatorChar) > -1)
622 shortName = shortName.substring(shortName.lastIndexOf(
623 java.io.File.separatorChar) + 1);
626 new Jalview2XML().SaveAlignment(this, file, shortName);
628 // USE Jalview2XML to save this file
634 String[] omitHidden = null;
636 if (viewport.hasHiddenColumns)
638 int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
639 "The Alignment contains hidden columns."
640 + "\nDo you want to save only the visible alignment?",
641 "Save / Omit Hidden Columns",
642 JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
644 if (reply == JOptionPane.YES_OPTION)
645 omitHidden = viewport.getViewAsString(false);
648 String output = new FormatAdapter().formatSequences(
650 viewport.alignment.getSequencesArray(),
660 java.io.PrintWriter out = new java.io.PrintWriter(
661 new java.io.FileWriter(file));
670 ex.printStackTrace();
679 * @param e DOCUMENT ME!
681 protected void outputText_actionPerformed(ActionEvent e)
683 String [] omitHidden = null;
685 if(viewport.hasHiddenColumns)
687 int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
688 "The Alignment contains hidden columns."
689 +"\nDo you want to output only the visible alignment?",
690 "Save / Omit Hidden Columns",
691 JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
693 if(reply==JOptionPane.YES_OPTION)
695 omitHidden = viewport.getViewAsString(false);
699 CutAndPasteTransfer cap = new CutAndPasteTransfer();
700 Desktop.addInternalFrame(cap,
701 "Alignment output - " + e.getActionCommand(), 600,
705 cap.setText(new FormatAdapter().formatSequences(
706 e.getActionCommand(),
707 viewport.alignment.getSequencesArray(),
714 * @param e DOCUMENT ME!
716 protected void htmlMenuItem_actionPerformed(ActionEvent e)
718 new HTMLOutput(viewport,
719 alignPanel.seqPanel.seqCanvas.getSequenceRenderer(),
720 alignPanel.seqPanel.seqCanvas.getFeatureRenderer());
723 public void createImageMap(File file, String image)
725 alignPanel.makePNGImageMap(file, image);
731 * @param e DOCUMENT ME!
733 public void createPNG(File f)
735 alignPanel.makePNG(f);
741 * @param e DOCUMENT ME!
743 public void createEPS(File f)
745 alignPanel.makeEPS(f);
751 * @param e DOCUMENT ME!
753 public void printMenuItem_actionPerformed(ActionEvent e)
755 //Putting in a thread avoids Swing painting problems
756 PrintThread thread = new PrintThread();
760 public void exportFeatures_actionPerformed(ActionEvent e)
762 new AnnotationExporter().exportFeatures(alignPanel);
766 public void exportAnnotations_actionPerformed(ActionEvent e)
768 new AnnotationExporter().exportAnnotations(
770 viewport.alignment.getAlignmentAnnotation()
775 public void associatedData_actionPerformed(ActionEvent e)
777 // Pick the tree file
778 JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
781 chooser.setFileView(new JalviewFileView());
782 chooser.setDialogTitle("Load Jalview Annotations or Features File");
783 chooser.setToolTipText("Load Jalview Annotations / Features file");
785 int value = chooser.showOpenDialog(null);
787 if (value == JalviewFileChooser.APPROVE_OPTION)
789 String choice = chooser.getSelectedFile().getPath();
790 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
791 loadJalviewDataFile(choice);
800 * @param e DOCUMENT ME!
802 public void closeMenuItem_actionPerformed(ActionEvent e)
806 for(int i=0; i<alignPanels.size(); i++)
808 AlignmentPanel ap = (AlignmentPanel)alignPanels.elementAt(i);
809 PaintRefresher.RemoveComponent(ap.seqPanel.seqCanvas);
810 PaintRefresher.RemoveComponent(ap.idPanel.idCanvas);
811 PaintRefresher.RemoveComponent(ap);
814 this.setClosed(true);
825 void updateEditMenuBar()
827 if (historyList.size() > 0)
829 undoMenuItem.setEnabled(true);
831 CommandI command = (CommandI) historyList.peek();
832 undoMenuItem.setText("Undo " + command.getDescription());
836 undoMenuItem.setEnabled(false);
837 undoMenuItem.setText("Undo");
840 if (redoList.size() > 0)
842 redoMenuItem.setEnabled(true);
844 CommandI command = (CommandI) redoList.peek();
845 redoMenuItem.setText("Redo " + command.getDescription());
849 redoMenuItem.setEnabled(false);
850 redoMenuItem.setText("Redo");
855 public void addHistoryItem(CommandI command)
857 historyList.push(command);
861 viewport.hasHiddenColumns = viewport.colSel.getHiddenColumns()!=null;
869 * @param e DOCUMENT ME!
871 protected void undoMenuItem_actionPerformed(ActionEvent e)
873 CommandI command = (CommandI)historyList.pop();
874 redoList.push(command);
875 command.undoCommand();
877 // HistoryItem nh,hi = (HistoryItem) historyList.pop();
878 // redoList.push(nh=new HistoryItem(hi.getDescription(), viewport.alignment,
879 // HistoryItem.HIDE));
880 // if (hi.alColumnChanges!=null)
881 // nh.alColumnChanges = hi.alColumnChanges.getInverse();
882 // restoreHistoryItem(hi);
883 viewport.hasHiddenColumns = viewport.colSel.getHiddenColumns()!=null;
885 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
891 * @param e DOCUMENT ME!
893 protected void redoMenuItem_actionPerformed(ActionEvent e)
895 CommandI command = (CommandI) redoList.pop();
896 historyList.push(command);
898 viewport.hasHiddenColumns = viewport.colSel.getHiddenColumns()!=null;
900 // HistoryItem nh,hi = (HistoryItem) redoList.pop();
901 // historyList.push(nh=new HistoryItem(hi.getDescription(), viewport.alignment,
902 // HistoryItem.HIDE));
903 // if (hi.alColumnChanges!=null)
904 // nh.alColumnChanges=hi.alColumnChanges.getInverse();
905 // restoreHistoryItem(hi);
907 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
914 * @param up DOCUMENT ME!
916 public void moveSelectedSequences(boolean up)
918 SequenceGroup sg = viewport.getSelectionGroup();
927 for (int i = 1; i < viewport.alignment.getHeight(); i++)
929 SequenceI seq = viewport.alignment.getSequenceAt(i);
931 if (!sg.getSequences(false).contains(seq))
936 SequenceI temp = viewport.alignment.getSequenceAt(i - 1);
938 if (sg.getSequences(false).contains(temp))
943 viewport.alignment.getSequences().setElementAt(temp, i);
944 viewport.alignment.getSequences().setElementAt(seq, i - 1);
949 for (int i = viewport.alignment.getHeight() - 2; i > -1; i--)
951 SequenceI seq = viewport.alignment.getSequenceAt(i);
953 if (!sg.getSequences(false).contains(seq))
958 SequenceI temp = viewport.alignment.getSequenceAt(i + 1);
960 if (sg.getSequences(false).contains(temp))
965 viewport.alignment.getSequences().setElementAt(temp, i);
966 viewport.alignment.getSequences().setElementAt(seq, i + 1);
970 alignPanel.repaint();
978 * @param e DOCUMENT ME!
980 protected void copy_actionPerformed(ActionEvent e)
983 if (viewport.getSelectionGroup() == null)
988 SequenceI [] seqs = viewport.getSelectionAsNewSequence();
989 String[] omitHidden = null;
991 if (viewport.hasHiddenColumns)
993 omitHidden = viewport.getViewAsString(true);
996 String output = new FormatAdapter().formatSequences(
1001 StringSelection ss = new StringSelection(output);
1005 //Its really worth setting the clipboard contents
1006 //to empty before setting the large StringSelection!!
1007 Toolkit.getDefaultToolkit().getSystemClipboard()
1008 .setContents(new StringSelection(""), null);
1010 Toolkit.getDefaultToolkit().getSystemClipboard()
1011 .setContents(ss, Desktop.instance);
1013 catch (OutOfMemoryError er)
1015 er.printStackTrace();
1016 javax.swing.SwingUtilities.invokeLater(new Runnable()
1020 javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop,
1021 "Out of memory copying region!!"
1023 "\nSee help files for increasing Java Virtual Machine memory."
1025 javax.swing.JOptionPane.WARNING_MESSAGE);
1032 Vector hiddenColumns = null;
1033 if(viewport.hasHiddenColumns)
1035 hiddenColumns =new Vector();
1036 int hiddenOffset = viewport.getSelectionGroup().getStartRes();
1037 for(int i=0; i<viewport.getColumnSelection().getHiddenColumns().size(); i++)
1039 int[] region = (int[])
1040 viewport.getColumnSelection().getHiddenColumns().elementAt(i);
1042 hiddenColumns.addElement(new int[]{region[0]-hiddenOffset,
1043 region[1]-hiddenOffset});
1049 Desktop.jalviewClipboard = new Object[]{ seqs,
1050 viewport.alignment.getDataset(),
1052 statusBar.setText("Copied "+seqs.length+" sequences to clipboard.");
1058 * @param e DOCUMENT ME!
1060 protected void pasteNew_actionPerformed(ActionEvent e)
1068 * @param e DOCUMENT ME!
1070 protected void pasteThis_actionPerformed(ActionEvent e)
1078 * @param newAlignment DOCUMENT ME!
1080 void paste(boolean newAlignment)
1084 Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
1085 Transferable contents = c.getContents(this);
1087 if (contents == null)
1095 str = (String) contents.getTransferData(DataFlavor.stringFlavor);
1096 if (str.length() < 1)
1099 format = new IdentifyFile().Identify(str, "Paste");
1102 catch (OutOfMemoryError er)
1104 er.printStackTrace();
1105 javax.swing.SwingUtilities.invokeLater(new Runnable()
1109 javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop,
1110 "Out of memory pasting sequences!!"
1112 "\nSee help files for increasing Java Virtual Machine memory."
1114 javax.swing.JOptionPane.WARNING_MESSAGE);
1121 SequenceI[] sequences;
1124 if(Desktop.jalviewClipboard!=null)
1126 // The clipboard was filled from within Jalview, we must use the sequences
1127 // And dataset from the copied alignment
1128 sequences = (SequenceI[])Desktop.jalviewClipboard[0];
1132 sequences = new FormatAdapter().readFile(str, "Paste", format);
1135 AlignmentI alignment = null;
1139 alignment = new Alignment(sequences);
1141 if (Desktop.jalviewClipboard != null)
1142 alignment.setDataset( (Alignment) Desktop.jalviewClipboard[1]);
1144 alignment.setDataset(null);
1148 alignment = viewport.getAlignment();
1151 SequenceI [] newseqs = new SequenceI[sequences.length];
1152 for (int i = 0; i < sequences.length; i++)
1154 newseqs[i] = new Sequence(sequences[i].getName(),
1155 sequences[i].getSequence(), sequences[i].getStart(),
1156 sequences[i].getEnd());
1158 alignment.addSequence(newseqs[i]);
1159 PaintRefresher.Refresh(alignPanel,
1160 alignPanel.av.getSequenceSetId(),
1168 addHistoryItem(new EditCommand(
1173 alignment.getWidth(),
1178 viewport.setEndSeq(alignment.getHeight());
1179 alignment.getWidth();
1180 viewport.firePropertyChange("alignment", null, alignment.getSequences());
1185 // Add any annotations attached to sequences
1186 for (int i = 0; i < sequences.length; i++)
1188 if (sequences[i].getAnnotation() != null)
1190 for (int a = 0; a < sequences[i].getAnnotation().length; a++)
1192 AlignmentAnnotation newAnnot =
1193 new AlignmentAnnotation(
1194 sequences[i].getAnnotation()[a].label,
1195 sequences[i].getAnnotation()[a].description,
1196 sequences[i].getAnnotation()[a].annotations,
1197 sequences[i].getAnnotation()[a].graphMin,
1198 sequences[i].getAnnotation()[a].graphMax,
1199 sequences[i].getAnnotation()[a].graph);
1201 sequences[i].getAnnotation()[a] = newAnnot;
1202 newAnnot.sequenceMapping = sequences[i].getAnnotation()[a].
1204 newAnnot.sequenceRef = sequences[i];
1205 newAnnot.adjustForAlignment();
1206 alignment.addAnnotation(newAnnot);
1207 alignment.setAnnotationIndex(newAnnot, a);
1210 alignPanel.annotationPanel.adjustPanelHeight();
1216 AlignFrame af = new AlignFrame(alignment, DEFAULT_WIDTH, DEFAULT_HEIGHT);
1217 String newtitle = new String("Copied sequences");
1219 if(Desktop.jalviewClipboard!=null && Desktop.jalviewClipboard[2]!=null)
1221 Vector hc = (Vector)Desktop.jalviewClipboard[2];
1222 for(int i=0; i<hc.size(); i++)
1224 int [] region = (int[]) hc.elementAt(i);
1225 af.viewport.hideColumns(region[0], region[1]);
1230 //>>>This is a fix for the moment, until a better solution is found!!<<<
1231 af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().transferSettings(
1232 alignPanel.seqPanel.seqCanvas.getFeatureRenderer());
1235 if (title.startsWith("Copied sequences"))
1241 newtitle = newtitle.concat("- from " + title);
1244 Desktop.addInternalFrame(af, newtitle, DEFAULT_WIDTH,
1251 catch (Exception ex)
1253 ex.printStackTrace();
1254 System.out.println("Exception whilst pasting: "+ex);
1255 // could be anything being pasted in here
1264 * @param e DOCUMENT ME!
1266 protected void cut_actionPerformed(ActionEvent e)
1268 copy_actionPerformed(null);
1269 delete_actionPerformed(null);
1275 * @param e DOCUMENT ME!
1277 protected void delete_actionPerformed(ActionEvent e)
1280 SequenceGroup sg = viewport.getSelectionGroup();
1286 Vector seqs = new Vector();
1287 int cutLength = sg.getEndRes()-sg.getStartRes()+1;
1289 for (int i = 0; i < sg.getSize(false); i++)
1291 seq = sg.getSequenceAt(i);
1292 seqs.addElement(seq);
1293 if(seq.getLength()<=cutLength)
1294 PaintRefresher.Refresh(alignPanel,
1295 alignPanel.av.getSequenceSetId(),
1300 // If the cut affects all sequences, remove highlighted columns
1301 if (sg.getSize(false) == viewport.alignment.getHeight())
1303 viewport.getColumnSelection().removeElements(sg.getStartRes(),
1304 sg.getEndRes() + 1);
1308 SequenceI [] cut = new SequenceI[seqs.size()];
1309 for(int i=0; i<seqs.size(); i++)
1310 cut[i] = (SequenceI)seqs.elementAt(i);
1316 addHistoryItem(new EditCommand("Cut Sequences",
1320 sg.getEndRes()-sg.getStartRes()+1,
1321 viewport.alignment));
1323 viewport.setSelectionGroup(null);
1324 viewport.alignment.deleteGroup(sg);
1326 viewport.firePropertyChange("alignment", null,
1327 viewport.getAlignment().getSequences());
1329 if (viewport.getAlignment().getHeight() < 1)
1333 this.setClosed(true);
1335 catch (Exception ex)
1344 * @param e DOCUMENT ME!
1346 protected void deleteGroups_actionPerformed(ActionEvent e)
1348 viewport.alignment.deleteAllGroups();
1349 viewport.setSelectionGroup(null);
1350 PaintRefresher.Refresh(this, viewport.getSequenceSetId());
1351 alignPanel.repaint();
1357 * @param e DOCUMENT ME!
1359 public void selectAllSequenceMenuItem_actionPerformed(ActionEvent e)
1361 SequenceGroup sg = new SequenceGroup();
1363 for (int i = 0; i < viewport.getAlignment().getSequences().size();
1366 sg.addSequence(viewport.getAlignment().getSequenceAt(i), false);
1369 sg.setEndRes(viewport.alignment.getWidth() - 1);
1370 viewport.setSelectionGroup(sg);
1371 alignPanel.repaint();
1372 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
1378 * @param e DOCUMENT ME!
1380 public void deselectAllSequenceMenuItem_actionPerformed(ActionEvent e)
1382 if(viewport.cursorMode)
1384 alignPanel.seqPanel.keyboardNo1 = null;
1385 alignPanel.seqPanel.keyboardNo2 = null;
1387 viewport.setSelectionGroup(null);
1388 viewport.getColumnSelection().clear();
1389 viewport.setSelectionGroup(null);
1390 alignPanel.seqPanel.seqCanvas.highlightSearchResults(null);
1391 alignPanel.idPanel.idCanvas.searchResults = null;
1392 alignPanel.repaint();
1393 PaintRefresher.Refresh(this, viewport.getSequenceSetId());
1399 * @param e DOCUMENT ME!
1401 public void invertSequenceMenuItem_actionPerformed(ActionEvent e)
1403 SequenceGroup sg = viewport.getSelectionGroup();
1407 selectAllSequenceMenuItem_actionPerformed(null);
1412 for (int i = 0; i < viewport.getAlignment().getSequences().size();
1415 sg.addOrRemove(viewport.getAlignment().getSequenceAt(i), false);
1418 PaintRefresher.Refresh(this, viewport.getSequenceSetId());
1421 public void invertColSel_actionPerformed(ActionEvent e)
1423 viewport.invertColumnSelection();
1424 alignPanel.repaint();
1431 * @param e DOCUMENT ME!
1433 public void remove2LeftMenuItem_actionPerformed(ActionEvent e)
1435 trimAlignment(true);
1441 * @param e DOCUMENT ME!
1443 public void remove2RightMenuItem_actionPerformed(ActionEvent e)
1445 trimAlignment(false);
1448 void trimAlignment(boolean trimLeft)
1450 ColumnSelection colSel = viewport.getColumnSelection();
1453 if (colSel.size() > 0)
1456 column = colSel.getMin();
1458 column = colSel.getMax();
1461 if(viewport.getSelectionGroup()!=null)
1462 seqs = viewport.getSelectionGroup().getSequencesAsArray(true);
1464 seqs = viewport.alignment.getSequencesArray();
1467 TrimRegionCommand trimRegion;
1470 trimRegion = new TrimRegionCommand("Remove Left",
1471 TrimRegionCommand.TRIM_LEFT,
1476 viewport.selectionGroup);
1480 trimRegion = new TrimRegionCommand("Remove Right",
1481 TrimRegionCommand.TRIM_RIGHT,
1486 viewport.selectionGroup);
1489 addHistoryItem(trimRegion);
1491 Vector groups = viewport.alignment.getGroups();
1493 for (int i = 0; i < groups.size(); i++)
1495 SequenceGroup sg = (SequenceGroup) groups.get(i);
1497 if ( (trimLeft && !sg.adjustForRemoveLeft(column))
1498 || (!trimLeft && !sg.adjustForRemoveRight(column)))
1500 viewport.alignment.deleteGroup(sg);
1504 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
1511 * @param e DOCUMENT ME!
1513 public void removeGappedColumnMenuItem_actionPerformed(ActionEvent e)
1515 int start = 0, end = viewport.alignment.getWidth();
1518 if (viewport.getSelectionGroup() != null)
1520 seqs = viewport.getSelectionGroup().getSequencesAsArray(true);
1521 start = viewport.getSelectionGroup().getStartRes();
1522 end = viewport.getSelectionGroup().getEndRes();
1525 seqs = viewport.alignment.getSequencesArray();
1528 addHistoryItem(new RemoveGapColCommand("Remove Gapped Columns",
1531 viewport.getGapCharacter()));
1533 //This is to maintain viewport position on first residue
1535 SequenceI seq = viewport.alignment.getSequenceAt(0);
1536 int startRes = seq.findPosition(viewport.startRes);
1537 // ShiftList shifts;
1538 // viewport.getAlignment().removeGaps(shifts=new ShiftList());
1539 // edit.alColumnChanges=shifts.getInverse();
1540 // if (viewport.hasHiddenColumns)
1541 // viewport.getColumnSelection().compensateForEdits(shifts);
1542 viewport.setStartRes(seq.findIndex(startRes)-1);
1543 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
1550 * @param e DOCUMENT ME!
1552 public void removeAllGapsMenuItem_actionPerformed(ActionEvent e)
1554 int start = 0, end = viewport.alignment.getWidth();
1557 if (viewport.getSelectionGroup() != null)
1559 seqs = viewport.getSelectionGroup().getSequencesAsArray(true);
1560 start = viewport.getSelectionGroup().getStartRes();
1561 end = viewport.getSelectionGroup().getEndRes();
1564 seqs = viewport.alignment.getSequencesArray();
1566 //This is to maintain viewport position on first residue
1568 SequenceI seq = viewport.alignment.getSequenceAt(0);
1569 int startRes = seq.findPosition(viewport.startRes);
1571 addHistoryItem(new RemoveGapsCommand("Remove Gaps",
1574 viewport.getGapCharacter()));
1576 viewport.setStartRes(seq.findIndex(startRes)-1);
1578 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
1582 public void alignmentChanged()
1587 for(int i=0; i<alignPanels.size(); i++)
1589 ap = (AlignmentPanel) alignPanels.elementAt(i);
1593 av.getAlignment().padGaps();
1595 if (av.hconsensus != null && av.autoCalculateConsensus)
1597 av.updateConsensus(ap);
1598 av.updateConservation(ap);
1599 ap.annotationPanel.repaint();
1602 resetAllColourSchemes();
1604 av.alignment.adjustSequenceAnnotations();
1606 if (ap.overviewPanel != null)
1607 ap.overviewPanel.updateOverviewImage();
1613 void resetAllColourSchemes()
1615 ColourSchemeI cs = viewport.globalColourScheme;
1618 if (cs instanceof ClustalxColourScheme)
1620 ( (ClustalxColourScheme) viewport.getGlobalColourScheme()).
1621 resetClustalX(viewport.alignment.getSequences(),
1622 viewport.alignment.getWidth());
1625 cs.setConsensus(viewport.hconsensus);
1626 if (cs.conservationApplied())
1628 Alignment al = (Alignment) viewport.alignment;
1629 Conservation c = new Conservation("All",
1630 ResidueProperties.propHash, 3,
1631 al.getSequences(), 0,
1634 c.verdict(false, viewport.ConsPercGaps);
1636 cs.setConservation(c);
1640 int s, sSize = viewport.alignment.getGroups().size();
1641 for(s=0; s<sSize; s++)
1643 SequenceGroup sg = (SequenceGroup)viewport.alignment.getGroups().elementAt(s);
1644 if(sg.cs!=null && sg.cs instanceof ClustalxColourScheme)
1646 ((ClustalxColourScheme)sg.cs).resetClustalX(
1647 sg.getSequences(true), sg.getWidth());
1649 sg.recalcConservation();
1656 * @param e DOCUMENT ME!
1658 public void padGapsMenuitem_actionPerformed(ActionEvent e)
1660 // addHistoryItem(new HistoryItem("Pad Gaps", viewport.alignment,
1661 // HistoryItem.HIDE));
1663 viewport.padGaps = padGapsMenuitem.isSelected();
1665 viewport.firePropertyChange("alignment",
1667 viewport.getAlignment().getSequences());
1673 * @param e DOCUMENT ME!
1675 public void findMenuItem_actionPerformed(ActionEvent e)
1677 JInternalFrame frame = new JInternalFrame();
1678 Finder finder = new Finder(viewport, alignPanel, frame);
1679 frame.setContentPane(finder);
1680 frame.setLayer(JLayeredPane.PALETTE_LAYER);
1681 Desktop.addInternalFrame(frame, "Find", 340, 110);
1687 * @param e DOCUMENT ME!
1689 public void font_actionPerformed(ActionEvent e)
1691 new FontChooser(alignPanel);
1694 public void smoothFont_actionPerformed(ActionEvent e)
1696 viewport.antiAlias = smoothFont.isSelected();
1697 alignPanel.annotationPanel.image = null;
1698 alignPanel.repaint();
1705 * @param e DOCUMENT ME!
1707 protected void seqLimit_actionPerformed(ActionEvent e)
1709 viewport.setShowJVSuffix(seqLimits.isSelected());
1711 alignPanel.idPanel.idCanvas.setPreferredSize(alignPanel.calculateIdWidth());
1712 alignPanel.repaint();
1719 * @param e DOCUMENT ME!
1721 protected void colourTextMenuItem_actionPerformed(ActionEvent e)
1723 viewport.setColourText(colourTextMenuItem.isSelected());
1724 alignPanel.repaint();
1730 * @param e DOCUMENT ME!
1732 public void wrapMenuItem_actionPerformed(ActionEvent e)
1734 scaleAbove.setVisible(wrapMenuItem.isSelected());
1735 scaleLeft.setVisible(wrapMenuItem.isSelected());
1736 scaleRight.setVisible(wrapMenuItem.isSelected());
1737 viewport.setWrapAlignment(wrapMenuItem.isSelected());
1738 alignPanel.setWrapAlignment(wrapMenuItem.isSelected());
1741 public void showAllSeqs_actionPerformed(ActionEvent e)
1743 viewport.showAllHiddenSeqs();
1746 public void showAllColumns_actionPerformed(ActionEvent e)
1748 viewport.showAllHiddenColumns();
1752 public void hideSelSequences_actionPerformed(ActionEvent e)
1754 viewport.hideAllSelectedSeqs();
1755 alignPanel.repaint();
1758 public void hideSelColumns_actionPerformed(ActionEvent e)
1760 viewport.hideSelectedColumns();
1761 alignPanel.repaint();
1764 public void hiddenMarkers_actionPerformed(ActionEvent e)
1766 viewport.setShowHiddenMarkers(hiddenMarkers.isSelected());
1773 * @param e DOCUMENT ME!
1775 protected void scaleAbove_actionPerformed(ActionEvent e)
1777 viewport.setScaleAboveWrapped(scaleAbove.isSelected());
1778 alignPanel.repaint();
1784 * @param e DOCUMENT ME!
1786 protected void scaleLeft_actionPerformed(ActionEvent e)
1788 viewport.setScaleLeftWrapped(scaleLeft.isSelected());
1789 alignPanel.repaint();
1795 * @param e DOCUMENT ME!
1797 protected void scaleRight_actionPerformed(ActionEvent e)
1799 viewport.setScaleRightWrapped(scaleRight.isSelected());
1800 alignPanel.repaint();
1806 * @param e DOCUMENT ME!
1808 public void viewBoxesMenuItem_actionPerformed(ActionEvent e)
1810 viewport.setShowBoxes(viewBoxesMenuItem.isSelected());
1811 alignPanel.repaint();
1817 * @param e DOCUMENT ME!
1819 public void viewTextMenuItem_actionPerformed(ActionEvent e)
1821 viewport.setShowText(viewTextMenuItem.isSelected());
1822 alignPanel.repaint();
1828 * @param e DOCUMENT ME!
1830 protected void renderGapsMenuItem_actionPerformed(ActionEvent e)
1832 viewport.setRenderGaps(renderGapsMenuItem.isSelected());
1833 alignPanel.repaint();
1837 public FeatureSettings featureSettings;
1838 public void featureSettings_actionPerformed(ActionEvent e)
1840 if(featureSettings !=null )
1842 featureSettings.close();
1843 featureSettings = null;
1845 featureSettings = new FeatureSettings(this);
1851 * @param evt DOCUMENT ME!
1853 public void showSeqFeatures_actionPerformed(ActionEvent evt)
1855 viewport.setShowSequenceFeatures(showSeqFeatures.isSelected());
1856 alignPanel.repaint();
1857 if (alignPanel.getOverviewPanel() != null)
1859 alignPanel.getOverviewPanel().updateOverviewImage();
1866 * @param e DOCUMENT ME!
1868 public void annotationPanelMenuItem_actionPerformed(ActionEvent e)
1870 viewport.setShowAnnotation(annotationPanelMenuItem.isSelected());
1871 alignPanel.setAnnotationVisible(annotationPanelMenuItem.isSelected());
1877 * @param e DOCUMENT ME!
1879 public void overviewMenuItem_actionPerformed(ActionEvent e)
1881 if (alignPanel.overviewPanel != null)
1886 JInternalFrame frame = new JInternalFrame();
1887 OverviewPanel overview = new OverviewPanel(alignPanel);
1888 frame.setContentPane(overview);
1889 Desktop.addInternalFrame(frame, "Overview " + this.getTitle(),
1890 frame.getWidth(), frame.getHeight());
1892 frame.setLayer(JLayeredPane.PALETTE_LAYER);
1893 frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
1895 public void internalFrameClosed(
1896 javax.swing.event.InternalFrameEvent evt)
1898 alignPanel.setOverviewPanel(null);
1903 alignPanel.setOverviewPanel(overview);
1909 * @param e DOCUMENT ME!
1911 protected void noColourmenuItem_actionPerformed(ActionEvent e)
1919 * @param e DOCUMENT ME!
1921 public void clustalColour_actionPerformed(ActionEvent e)
1923 changeColour(new ClustalxColourScheme(
1924 viewport.alignment.getSequences(), viewport.alignment.getWidth()));
1930 * @param e DOCUMENT ME!
1932 public void zappoColour_actionPerformed(ActionEvent e)
1934 changeColour(new ZappoColourScheme());
1940 * @param e DOCUMENT ME!
1942 public void taylorColour_actionPerformed(ActionEvent e)
1944 changeColour(new TaylorColourScheme());
1950 * @param e DOCUMENT ME!
1952 public void hydrophobicityColour_actionPerformed(ActionEvent e)
1954 changeColour(new HydrophobicColourScheme());
1960 * @param e DOCUMENT ME!
1962 public void helixColour_actionPerformed(ActionEvent e)
1964 changeColour(new HelixColourScheme());
1970 * @param e DOCUMENT ME!
1972 public void strandColour_actionPerformed(ActionEvent e)
1974 changeColour(new StrandColourScheme());
1980 * @param e DOCUMENT ME!
1982 public void turnColour_actionPerformed(ActionEvent e)
1984 changeColour(new TurnColourScheme());
1990 * @param e DOCUMENT ME!
1992 public void buriedColour_actionPerformed(ActionEvent e)
1994 changeColour(new BuriedColourScheme());
2000 * @param e DOCUMENT ME!
2002 public void nucleotideColour_actionPerformed(ActionEvent e)
2004 changeColour(new NucleotideColourScheme());
2007 public void annotationColour_actionPerformed(ActionEvent e)
2009 new AnnotationColourChooser(viewport, alignPanel);
2016 * @param e DOCUMENT ME!
2018 protected void applyToAllGroups_actionPerformed(ActionEvent e)
2020 viewport.setColourAppliesToAllGroups(applyToAllGroups.isSelected());
2026 * @param cs DOCUMENT ME!
2028 public void changeColour(ColourSchemeI cs)
2034 if (viewport.getAbovePIDThreshold())
2036 threshold = SliderPanel.setPIDSliderSource(alignPanel, cs,
2039 cs.setThreshold(threshold,
2040 viewport.getIgnoreGapsConsensus());
2042 viewport.setGlobalColourScheme(cs);
2046 cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
2049 if (viewport.getConservationSelected())
2052 Alignment al = (Alignment) viewport.alignment;
2053 Conservation c = new Conservation("All",
2054 ResidueProperties.propHash, 3,
2055 al.getSequences(), 0,
2059 c.verdict(false, viewport.ConsPercGaps);
2061 cs.setConservation(c);
2063 cs.setConservationInc(SliderPanel.setConservationSlider(alignPanel, cs,
2068 cs.setConservation(null);
2071 cs.setConsensus(viewport.hconsensus);
2074 viewport.setGlobalColourScheme(cs);
2076 if (viewport.getColourAppliesToAllGroups())
2078 Vector groups = viewport.alignment.getGroups();
2080 for (int i = 0; i < groups.size(); i++)
2082 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
2090 if (cs instanceof ClustalxColourScheme)
2092 sg.cs = new ClustalxColourScheme(
2093 sg.getSequences(true), sg.getWidth());
2095 else if (cs instanceof UserColourScheme)
2097 sg.cs = new UserColourScheme( ( (UserColourScheme) cs).getColours());
2103 sg.cs = (ColourSchemeI) cs.getClass().newInstance();
2105 catch (Exception ex)
2110 if (viewport.getAbovePIDThreshold()
2111 || cs instanceof PIDColourScheme
2112 || cs instanceof Blosum62ColourScheme)
2114 sg.cs.setThreshold(threshold,
2115 viewport.getIgnoreGapsConsensus());
2117 sg.cs.setConsensus(AAFrequency.calculate(
2118 sg.getSequences(true), 0,
2122 sg.cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
2125 if (viewport.getConservationSelected())
2127 Conservation c = new Conservation("Group",
2128 ResidueProperties.propHash, 3,
2129 sg.getSequences(true), 0,
2130 viewport.alignment.getWidth() - 1);
2132 c.verdict(false, viewport.ConsPercGaps);
2133 sg.cs.setConservation(c);
2136 sg.cs.setConservation(null);
2140 if (alignPanel.getOverviewPanel() != null)
2142 alignPanel.getOverviewPanel().updateOverviewImage();
2145 alignPanel.repaint();
2151 * @param e DOCUMENT ME!
2153 protected void modifyPID_actionPerformed(ActionEvent e)
2155 if (viewport.getAbovePIDThreshold() && viewport.globalColourScheme!=null)
2157 SliderPanel.setPIDSliderSource(alignPanel,
2158 viewport.getGlobalColourScheme(),
2160 SliderPanel.showPIDSlider();
2167 * @param e DOCUMENT ME!
2169 protected void modifyConservation_actionPerformed(ActionEvent e)
2171 if (viewport.getConservationSelected() && viewport.globalColourScheme!=null)
2173 SliderPanel.setConservationSlider(alignPanel,
2174 viewport.globalColourScheme,
2176 SliderPanel.showConservationSlider();
2183 * @param e DOCUMENT ME!
2185 protected void conservationMenuItem_actionPerformed(ActionEvent e)
2187 viewport.setConservationSelected(conservationMenuItem.isSelected());
2189 viewport.setAbovePIDThreshold(false);
2190 abovePIDThreshold.setSelected(false);
2192 changeColour(viewport.getGlobalColourScheme());
2194 modifyConservation_actionPerformed(null);
2200 * @param e DOCUMENT ME!
2202 public void abovePIDThreshold_actionPerformed(ActionEvent e)
2204 viewport.setAbovePIDThreshold(abovePIDThreshold.isSelected());
2206 conservationMenuItem.setSelected(false);
2207 viewport.setConservationSelected(false);
2209 changeColour(viewport.getGlobalColourScheme());
2211 modifyPID_actionPerformed(null);
2217 * @param e DOCUMENT ME!
2219 public void userDefinedColour_actionPerformed(ActionEvent e)
2221 if (e.getActionCommand().equals("User Defined..."))
2223 new UserDefinedColours(alignPanel, null);
2227 UserColourScheme udc = (UserColourScheme) UserDefinedColours.
2228 getUserColourSchemes().get(e.getActionCommand());
2234 public void updateUserColourMenu()
2237 Component[] menuItems = colourMenu.getMenuComponents();
2238 int i, iSize = menuItems.length;
2239 for (i = 0; i < iSize; i++)
2241 if (menuItems[i].getName() != null &&
2242 menuItems[i].getName().equals("USER_DEFINED"))
2244 colourMenu.remove(menuItems[i]);
2248 if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null)
2250 java.util.Enumeration userColours = jalview.gui.UserDefinedColours.
2251 getUserColourSchemes().keys();
2253 while (userColours.hasMoreElements())
2255 final JRadioButtonMenuItem radioItem = new JRadioButtonMenuItem(userColours.
2256 nextElement().toString());
2257 radioItem.setName("USER_DEFINED");
2258 radioItem.addMouseListener(new MouseAdapter()
2260 public void mousePressed(MouseEvent evt)
2262 if(evt.isControlDown() || SwingUtilities.isRightMouseButton(evt))
2264 radioItem.removeActionListener(radioItem.getActionListeners()[0]);
2266 int option = JOptionPane.showInternalConfirmDialog(jalview.gui.Desktop.desktop,
2267 "Remove from default list?",
2268 "Remove user defined colour",
2269 JOptionPane.YES_NO_OPTION);
2270 if(option == JOptionPane.YES_OPTION)
2272 jalview.gui.UserDefinedColours.removeColourFromDefaults(radioItem.getText());
2273 colourMenu.remove(radioItem);
2276 radioItem.addActionListener(new ActionListener()
2278 public void actionPerformed(ActionEvent evt)
2280 userDefinedColour_actionPerformed(evt);
2286 radioItem.addActionListener(new ActionListener()
2288 public void actionPerformed(ActionEvent evt)
2290 userDefinedColour_actionPerformed(evt);
2294 colourMenu.insert(radioItem, 15);
2295 colours.add(radioItem);
2303 * @param e DOCUMENT ME!
2305 public void PIDColour_actionPerformed(ActionEvent e)
2307 changeColour(new PIDColourScheme());
2313 * @param e DOCUMENT ME!
2315 public void BLOSUM62Colour_actionPerformed(ActionEvent e)
2317 changeColour(new Blosum62ColourScheme());
2323 * @param e DOCUMENT ME!
2325 public void sortPairwiseMenuItem_actionPerformed(ActionEvent e)
2327 SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray();
2328 AlignmentSorter.sortByPID(viewport.getAlignment(),
2329 viewport.getAlignment().getSequenceAt(0));
2330 addHistoryItem(new OrderCommand("Pairwise Sort", oldOrder, viewport.alignment));
2331 alignPanel.repaint();
2337 * @param e DOCUMENT ME!
2339 public void sortIDMenuItem_actionPerformed(ActionEvent e)
2341 SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray();
2342 AlignmentSorter.sortByID(viewport.getAlignment());
2343 addHistoryItem(new OrderCommand("ID Sort", oldOrder, viewport.alignment));
2344 alignPanel.repaint();
2350 * @param e DOCUMENT ME!
2352 public void sortGroupMenuItem_actionPerformed(ActionEvent e)
2354 SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray();
2355 AlignmentSorter.sortByGroup(viewport.getAlignment());
2356 addHistoryItem(new OrderCommand("Group Sort", oldOrder, viewport.alignment));
2358 alignPanel.repaint();
2364 * @param e DOCUMENT ME!
2366 public void removeRedundancyMenuItem_actionPerformed(ActionEvent e)
2368 new RedundancyPanel(alignPanel, this);
2375 * @param e DOCUMENT ME!
2377 public void pairwiseAlignmentMenuItem_actionPerformed(ActionEvent e)
2379 if ( (viewport.getSelectionGroup() == null) ||
2380 (viewport.getSelectionGroup().getSize(false) < 2))
2382 JOptionPane.showInternalMessageDialog(this,
2383 "You must select at least 2 sequences.",
2384 "Invalid Selection",
2385 JOptionPane.WARNING_MESSAGE);
2389 JInternalFrame frame = new JInternalFrame();
2390 frame.setContentPane(new PairwiseAlignPanel(viewport));
2391 Desktop.addInternalFrame(frame, "Pairwise Alignment", 600, 500);
2398 * @param e DOCUMENT ME!
2400 public void PCAMenuItem_actionPerformed(ActionEvent e)
2402 if ( ( (viewport.getSelectionGroup() != null) &&
2403 (viewport.getSelectionGroup().getSize(false) < 4) &&
2404 (viewport.getSelectionGroup().getSize(false) > 0)) ||
2405 (viewport.getAlignment().getHeight() < 4))
2407 JOptionPane.showInternalMessageDialog(this,
2408 "Principal component analysis must take\n" +
2409 "at least 4 input sequences.",
2410 "Sequence selection insufficient",
2411 JOptionPane.WARNING_MESSAGE);
2416 new PCAPanel(viewport);
2420 public void autoCalculate_actionPerformed(ActionEvent e)
2422 viewport.autoCalculateConsensus = autoCalculate.isSelected();
2423 if(viewport.autoCalculateConsensus)
2425 viewport.firePropertyChange("alignment",
2427 viewport.getAlignment().getSequences());
2435 * @param e DOCUMENT ME!
2437 public void averageDistanceTreeMenuItem_actionPerformed(ActionEvent e)
2439 NewTreePanel("AV", "PID", "Average distance tree using PID");
2445 * @param e DOCUMENT ME!
2447 public void neighbourTreeMenuItem_actionPerformed(ActionEvent e)
2449 NewTreePanel("NJ", "PID", "Neighbour joining tree using PID");
2455 * @param e DOCUMENT ME!
2457 protected void njTreeBlosumMenuItem_actionPerformed(ActionEvent e)
2459 NewTreePanel("NJ", "BL", "Neighbour joining tree using BLOSUM62");
2465 * @param e DOCUMENT ME!
2467 protected void avTreeBlosumMenuItem_actionPerformed(ActionEvent e)
2469 NewTreePanel("AV", "BL", "Average distance tree using BLOSUM62");
2475 * @param type DOCUMENT ME!
2476 * @param pwType DOCUMENT ME!
2477 * @param title DOCUMENT ME!
2479 void NewTreePanel(String type, String pwType, String title)
2483 if (viewport.getSelectionGroup() != null) {
2484 if (viewport.getSelectionGroup().getSize(false) < 3) {
2485 JOptionPane.showMessageDialog(Desktop.desktop,
2486 "You need to have more than two sequences selected to build a tree!",
2487 "Not enough sequences",
2488 JOptionPane.WARNING_MESSAGE);
2493 SequenceGroup sg = viewport.getSelectionGroup();
2495 /* Decide if the selection is a column region */
2496 while (s < sg.getSize(false))
2498 if ( ( (SequenceI) sg.getSequences(false).elementAt(s++)).getLength() <
2501 JOptionPane.showMessageDialog(Desktop.desktop,
2502 "The selected region to create a tree may\nonly contain residues or gaps.\n" +
2503 "Try using the Pad function in the edit menu,\n" +
2504 "or one of the multiple sequence alignment web services.",
2505 "Sequences in selection are not aligned",
2506 JOptionPane.WARNING_MESSAGE);
2512 title = title + " on region";
2513 tp = new TreePanel(alignPanel, type, pwType);
2517 //are the sequences aligned?
2518 if (!viewport.alignment.isAligned())
2520 JOptionPane.showMessageDialog(Desktop.desktop,
2521 "The sequences must be aligned before creating a tree.\n" +
2522 "Try using the Pad function in the edit menu,\n" +
2523 "or one of the multiple sequence alignment web services.",
2524 "Sequences not aligned",
2525 JOptionPane.WARNING_MESSAGE);
2530 if(viewport.alignment.getHeight()<2)
2533 tp = new TreePanel(alignPanel, type, pwType);
2536 addTreeMenuItem(tp, title);
2538 Desktop.addInternalFrame(tp, title + " from " + this.title, 600, 500);
2544 * @param title DOCUMENT ME!
2545 * @param order DOCUMENT ME!
2547 public void addSortByOrderMenuItem(String title, final AlignmentOrder order)
2549 final JMenuItem item = new JMenuItem("by " + title);
2551 item.addActionListener(new java.awt.event.ActionListener()
2553 public void actionPerformed(ActionEvent e)
2555 SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray();
2557 // TODO: JBPNote - have to map order entries to curent SequenceI pointers
2558 AlignmentSorter.sortBy(viewport.getAlignment(), order);
2560 addHistoryItem(new OrderCommand(order.getName(), oldOrder, viewport.alignment));
2562 alignPanel.repaint();
2568 * Maintain the Order by->Displayed Tree menu.
2569 * Creates a new menu item for a TreePanel with an appropriate
2570 * <code>jalview.analysis.AlignmentSorter</code> call. Listeners are added
2571 * to remove the menu item when the treePanel is closed, and adjust
2572 * the tree leaf to sequence mapping when the alignment is modified.
2573 * @param treePanel Displayed tree window.
2574 * @param title SortBy menu item title.
2576 void addTreeMenuItem(final TreePanel treePanel, String title)
2578 final JMenuItem item = new JMenuItem(title);
2584 sort.add(sortByTreeMenu);
2587 sortByTreeMenu.add(item);
2588 item.addActionListener(new java.awt.event.ActionListener()
2590 public void actionPerformed(ActionEvent e)
2592 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
2593 AlignmentSorter.sortByTree(viewport.getAlignment(),
2594 treePanel.getTree());
2596 addHistoryItem(new OrderCommand("Tree Sort",
2598 viewport.alignment));
2601 alignPanel.repaint();
2605 treePanel.addInternalFrameListener(new javax.swing.event.
2606 InternalFrameAdapter()
2608 public void internalFrameClosed(
2609 javax.swing.event.InternalFrameEvent evt)
2612 sortByTreeMenu.remove(item);
2616 sort.remove(sortByTreeMenu);
2624 * Work out whether the whole set of sequences
2625 * or just the selected set will be submitted for multiple alignment.
2628 private jalview.datamodel.AlignmentView gatherSequencesForAlignment()
2630 // Now, check we have enough sequences
2631 AlignmentView msa = null;
2633 if ( (viewport.getSelectionGroup() != null) &&
2634 (viewport.getSelectionGroup().getSize(false) > 1))
2636 // JBPNote UGLY! To prettify, make SequenceGroup and Alignment conform to some common interface!
2637 /*SequenceGroup seqs = viewport.getSelectionGroup();
2639 msa = new SequenceI[sz = seqs.getSize(false)];
2641 for (int i = 0; i < sz; i++)
2643 msa[i] = (SequenceI) seqs.getSequenceAt(i);
2645 msa = viewport.getAlignmentView(true);
2649 /*Vector seqs = viewport.getAlignment().getSequences();
2651 if (seqs.size() > 1)
2653 msa = new SequenceI[seqs.size()];
2655 for (int i = 0; i < seqs.size(); i++)
2657 msa[i] = (SequenceI) seqs.elementAt(i);
2660 msa = viewport.getAlignmentView(false);
2666 * Decides what is submitted to a secondary structure prediction service,
2667 * the currently selected sequence, or the currently selected alignment
2668 * (where the first sequence in the set is the one that the prediction
2671 AlignmentView gatherSeqOrMsaForSecStrPrediction()
2673 AlignmentView seqs = null;
2675 if ( (viewport.getSelectionGroup() != null) &&
2676 (viewport.getSelectionGroup().getSize(false) > 0))
2678 seqs = viewport.getAlignmentView(true);
2682 seqs = viewport.getAlignmentView(false);
2684 // limit sequences - JBPNote in future - could spawn multiple prediction jobs
2685 // TODO: viewport.alignment.isAligned is a global state - the local selection may well be aligned - we preserve 2.0.8 behaviour for moment.
2686 if (!viewport.alignment.isAligned())
2688 seqs.setSequences(new SeqCigar[] { seqs.getSequences()[0] } );
2695 * @param e DOCUMENT ME!
2697 protected void LoadtreeMenuItem_actionPerformed(ActionEvent e)
2699 // Pick the tree file
2700 JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
2703 chooser.setFileView(new JalviewFileView());
2704 chooser.setDialogTitle("Select a newick-like tree file");
2705 chooser.setToolTipText("Load a tree file");
2707 int value = chooser.showOpenDialog(null);
2709 if (value == JalviewFileChooser.APPROVE_OPTION)
2711 String choice = chooser.getSelectedFile().getPath();
2712 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
2716 jalview.io.NewickFile fin = new jalview.io.NewickFile(choice,
2718 viewport.setCurrentTree(ShowNewickTree(fin, choice).getTree());
2720 catch (Exception ex)
2722 JOptionPane.showMessageDialog(Desktop.desktop,
2723 "Problem reading tree file",
2725 JOptionPane.WARNING_MESSAGE);
2726 ex.printStackTrace();
2732 public TreePanel ShowNewickTree(NewickFile nf, String title)
2734 return ShowNewickTree(nf,title,600,500,4,5);
2736 public TreePanel ShowNewickTree(NewickFile nf, String title, AlignmentView input)
2738 return ShowNewickTree(nf,title, input, 600,500,4,5);
2740 public TreePanel ShowNewickTree(NewickFile nf, String title, int w,int h,int x, int y) {
2741 return ShowNewickTree(nf, title, null, w, h, x, y);
2744 * Add a treeviewer for the tree extracted from a newick file object to the current alignment view
2746 * @param nf the tree
2747 * @param title tree viewer title
2748 * @param input Associated alignment input data (or null)
2753 * @return TreePanel handle
2755 public TreePanel ShowNewickTree(NewickFile nf, String title, AlignmentView input, int w,int h,int x, int y) {
2756 TreePanel tp = null;
2762 if (nf.getTree() != null)
2764 tp = new TreePanel(alignPanel,
2772 tp.setLocation(x,y);
2775 Desktop.addInternalFrame(tp, title, w, h);
2776 addTreeMenuItem(tp, title);
2779 catch (Exception ex)
2781 ex.printStackTrace();
2792 PrinterJob printJob = PrinterJob.getPrinterJob();
2793 PageFormat pf = printJob.pageDialog(printJob.defaultPage());
2794 printJob.setPrintable(alignPanel, pf);
2796 if (printJob.printDialog())
2802 catch (Exception PrintException)
2804 PrintException.printStackTrace();
2811 * Generates menu items and listener event actions for web service clients
2814 public void BuildWebServiceMenu()
2816 if ( (Discoverer.services != null)
2817 && (Discoverer.services.size() > 0))
2819 Vector msaws = (Vector) Discoverer.services.get("MsaWS");
2820 Vector secstrpr = (Vector) Discoverer.services.get("SecStrPred");
2821 Vector wsmenu = new Vector();
2822 final AlignFrame af = this;
2825 // Add any Multiple Sequence Alignment Services
2826 final JMenu msawsmenu = new JMenu("Alignment");
2827 for (int i = 0, j = msaws.size(); i < j; i++)
2829 final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) msaws.
2831 final JMenuItem method = new JMenuItem(sh.getName());
2832 method.addActionListener(new ActionListener()
2834 public void actionPerformed(ActionEvent e)
2836 AlignmentView msa = gatherSequencesForAlignment();
2837 new jalview.ws.MsaWSClient(sh, title, msa,
2838 false, true, viewport.getAlignment().getDataset(), af);
2843 msawsmenu.add(method);
2844 // Deal with services that we know accept partial alignments.
2845 if (sh.getName().indexOf("lustal") > -1)
2847 // We know that ClustalWS can accept partial alignments for refinement.
2848 final JMenuItem methodR = new JMenuItem(sh.getName()+" Realign");
2849 methodR.addActionListener(new ActionListener()
2851 public void actionPerformed(ActionEvent e)
2853 AlignmentView msa = gatherSequencesForAlignment();
2854 new jalview.ws.MsaWSClient(sh, title, msa,
2855 true, true, viewport.getAlignment().getDataset(), af);
2860 msawsmenu.add(methodR);
2864 wsmenu.add(msawsmenu);
2866 if (secstrpr != null)
2868 // Add any secondary structure prediction services
2869 final JMenu secstrmenu = new JMenu("Secondary Structure Prediction");
2870 for (int i = 0, j = secstrpr.size(); i < j; i++)
2872 final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle)
2874 final JMenuItem method = new JMenuItem(sh.getName());
2875 method.addActionListener(new ActionListener()
2877 public void actionPerformed(ActionEvent e)
2879 AlignmentView msa = gatherSeqOrMsaForSecStrPrediction();
2880 if (msa.getSequences().length == 1)
2882 // Single Sequence prediction
2883 new jalview.ws.JPredClient(sh, title, false, msa, af, true);
2887 if (msa.getSequences().length > 1)
2889 // Sequence profile based prediction
2890 new jalview.ws.JPredClient(sh,
2891 title, true, msa, af, true);
2896 secstrmenu.add(method);
2898 wsmenu.add(secstrmenu);
2900 this.webService.removeAll();
2901 for (int i = 0, j = wsmenu.size(); i < j; i++)
2903 webService.add( (JMenu) wsmenu.get(i));
2908 this.webService.removeAll();
2909 this.webService.add(this.webServiceNoServices);
2911 // TODO: add in rediscovery function
2912 // TODO: reduce code redundancy.
2913 // TODO: group services by location as well as function.
2916 /* public void vamsasStore_actionPerformed(ActionEvent e)
2918 JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
2919 getProperty("LAST_DIRECTORY"));
2921 chooser.setFileView(new JalviewFileView());
2922 chooser.setDialogTitle("Export to Vamsas file");
2923 chooser.setToolTipText("Export");
2925 int value = chooser.showSaveDialog(this);
2927 if (value == JalviewFileChooser.APPROVE_OPTION)
2929 jalview.io.VamsasDatastore vs = new jalview.io.VamsasDatastore(viewport);
2930 //vs.store(chooser.getSelectedFile().getAbsolutePath() );
2931 vs.storeJalview( chooser.getSelectedFile().getAbsolutePath(), this);
2938 public void showTranslation_actionPerformed(ActionEvent e)
2940 SequenceI [] selection = viewport.getSelectionAsNewSequence();
2941 String [] seqstring = viewport.getViewAsString(true);
2943 int s, sSize = selection.length;
2944 SequenceI [] newSeq = new SequenceI[sSize];
2947 StringBuffer protein;
2949 for(s=0; s<sSize; s++)
2951 protein = new StringBuffer();
2952 seq = AlignSeq.extractGaps("-. ", seqstring[s]);
2953 resSize = seq.length();
2954 resSize -= resSize%3;
2956 for(res = 0; res < resSize; res+=3)
2958 String codon = seq.substring(res, res+3);
2959 codon = codon.replace('U', 'T');
2960 String aa = ResidueProperties.codonTranslate(codon);
2962 protein.append(viewport.getGapCharacter());
2963 else if(aa.equals("STOP"))
2964 protein.append("X");
2966 protein.append( aa );
2968 newSeq[s] = new Sequence(selection[s].getName(),
2969 protein.toString());
2973 AlignmentI al = new Alignment(newSeq);
2974 al.setDataset(null);
2977 ////////////////////////////////
2978 // Copy annotations across
2979 jalview.datamodel.AlignmentAnnotation[] annotations
2980 = viewport.alignment.getAlignmentAnnotation();
2982 if(annotations!=null)
2984 for (int i = 0; i < annotations.length; i++)
2986 if (annotations[i].label.equals("Quality") ||
2987 annotations[i].label.equals("Conservation") ||
2988 annotations[i].label.equals("Consensus"))
2993 aSize = viewport.alignment.getWidth() / 3;
2994 jalview.datamodel.Annotation[] anots =
2995 new jalview.datamodel.Annotation[aSize];
2997 for (a = 0; a < viewport.alignment.getWidth(); a++)
2999 if (annotations[i].annotations[a] == null
3000 || annotations[i].annotations[a] == null)
3003 anots[a / 3] = new Annotation(
3004 annotations[i].annotations[a].displayCharacter,
3005 annotations[i].annotations[a].description,
3006 annotations[i].annotations[a].secondaryStructure,
3007 annotations[i].annotations[a].value,
3008 annotations[i].annotations[a].colour);
3011 jalview.datamodel.AlignmentAnnotation aa
3012 = new jalview.datamodel.AlignmentAnnotation(annotations[i].label,
3013 annotations[i].description, anots);
3014 al.addAnnotation(aa);
3018 AlignFrame af = new AlignFrame(al, DEFAULT_WIDTH, DEFAULT_HEIGHT);
3019 Desktop.addInternalFrame(af, "Translation of "+this.getTitle(),
3031 * @param String DOCUMENT ME!
3033 public boolean parseFeaturesFile(String file, String type)
3035 boolean featuresFile = false;
3037 featuresFile = new FeaturesFile(file, type).parse(viewport.alignment.getDataset(),
3038 alignPanel.seqPanel.seqCanvas.
3039 getFeatureRenderer().featureColours,
3044 ex.printStackTrace();
3049 viewport.showSequenceFeatures = true;
3050 showSeqFeatures.setSelected(true);
3051 alignPanel.repaint();
3054 return featuresFile;
3057 public void dragEnter(DropTargetDragEvent evt)
3060 public void dragExit(DropTargetEvent evt)
3063 public void dragOver(DropTargetDragEvent evt)
3066 public void dropActionChanged(DropTargetDragEvent evt)
3069 public void drop(DropTargetDropEvent evt)
3071 Transferable t = evt.getTransferable();
3072 java.util.List files = null;
3076 DataFlavor uriListFlavor = new DataFlavor("text/uri-list;class=java.lang.String");
3077 if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor))
3079 //Works on Windows and MacOSX
3080 evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
3081 files = (java.util.List) t.getTransferData(DataFlavor.javaFileListFlavor);
3083 else if (t.isDataFlavorSupported(uriListFlavor))
3085 // This is used by Unix drag system
3086 evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
3087 String data = (String) t.getTransferData(uriListFlavor);
3088 files = new java.util.ArrayList(1);
3089 for (java.util.StringTokenizer st = new java.util.StringTokenizer(
3092 st.hasMoreTokens(); )
3094 String s = st.nextToken();
3095 if (s.startsWith("#"))
3097 // the line is a comment (as per the RFC 2483)
3101 java.net.URI uri = new java.net.URI(s);
3102 java.io.File file = new java.io.File(uri);
3109 e.printStackTrace();
3116 for (int i = 0; i < files.size(); i++)
3118 loadJalviewDataFile(files.get(i).toString());
3121 catch (Exception ex)
3123 ex.printStackTrace();
3128 // This method will attempt to load a "dropped" file first by testing
3129 // whether its and Annotation file, then features file. If both are
3130 // false then the user may have dropped an alignment file onto this
3132 public void loadJalviewDataFile(String file)
3135 String protocol = "File";
3137 if (file.indexOf("http:") > -1 || file.indexOf("file:") > -1)
3142 boolean isAnnotation = new AnnotationFile().readAnnotationFile(viewport.
3147 boolean isGroupsFile = parseFeaturesFile(file,protocol);
3150 String format = new IdentifyFile().Identify(file, protocol);
3152 if(format.equalsIgnoreCase("JnetFile"))
3154 jalview.io.JPredFile predictions = new jalview.io.JPredFile(
3156 new JnetAnnotationMaker().add_annotation(predictions,
3157 viewport.getAlignment(),
3159 alignPanel.adjustAnnotationHeight();
3160 alignPanel.repaint();
3163 new FileLoader().LoadFile(viewport, file, protocol, format);
3169 alignPanel.adjustAnnotationHeight();
3172 }catch(Exception ex)
3174 ex.printStackTrace();
3178 public void tabSelectionChanged(int index)
3182 alignPanel = (AlignmentPanel) alignPanels.elementAt(index);
3183 viewport = alignPanel.av;
3187 public void tabbedPane_mousePressed(MouseEvent e)
3189 if(SwingUtilities.isRightMouseButton(e))
3191 String reply = JOptionPane.showInternalInputDialog(this,
3194 JOptionPane.QUESTION_MESSAGE);
3198 viewport.viewName = reply;
3199 tabbedPane.setTitleAt( tabbedPane.getSelectedIndex() ,reply);
3205 public AlignViewport getCurrentView()