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.commands.*;
38 import java.awt.dnd.*;
46 public class AlignFrame extends GAlignFrame implements DropTargetListener
49 public static final int DEFAULT_WIDTH = 700;
52 public static final int DEFAULT_HEIGHT = 500;
53 public AlignmentPanel alignPanel;
55 AlignViewport viewport;
57 Vector alignPanels = new Vector();
61 String currentFileFormat = null;
63 String fileName = null;
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, true);
101 * Make a new AlignFrame from exisiting alignmentPanels
102 * @param ap AlignmentPanel
103 * @param av AlignViewport
105 public AlignFrame(AlignmentPanel ap)
109 addAlignmentPanel(ap, false);
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 setMenusFromViewport(viewport);
142 if (viewport.wrapAlignment)
144 wrapMenuItem_actionPerformed(null);
151 public void setFileName(String file, String format)
154 currentFileFormat = format;
155 reload.setEnabled(true);
158 void addKeyListener()
160 final AlignFrame af = this;
161 addKeyListener(new KeyAdapter()
163 public void keyPressed(KeyEvent evt)
165 if (viewport.cursorMode
166 && evt.getKeyCode() >= KeyEvent.VK_0
167 && evt.getKeyCode() <= KeyEvent.VK_9)
169 alignPanel.seqPanel.numberPressed(evt.getKeyChar());
172 switch (evt.getKeyCode())
175 Desktop.instance.gatherViews(af);
179 if (!evt.isControlDown())
181 Desktop.instance.explodeViews(af);
186 case 27: // escape key
187 deselectAllSequenceMenuItem_actionPerformed(null);
191 case KeyEvent.VK_DOWN:
192 if (viewport.cursorMode)
194 alignPanel.seqPanel.moveCursor(0, 1);
197 moveSelectedSequences(false);
201 if (viewport.cursorMode)
203 alignPanel.seqPanel.moveCursor(0, -1);
206 moveSelectedSequences(true);
209 case KeyEvent.VK_LEFT:
210 if (viewport.cursorMode)
212 alignPanel.seqPanel.moveCursor( -1, 0);
216 case KeyEvent.VK_RIGHT:
217 if (viewport.cursorMode)
219 alignPanel.seqPanel.moveCursor(1, 0);
223 case KeyEvent.VK_SPACE:
224 if (viewport.cursorMode)
226 alignPanel.seqPanel.insertGapAtCursor(evt.isControlDown()
232 case KeyEvent.VK_DELETE:
233 case KeyEvent.VK_BACK_SPACE:
234 if (!viewport.cursorMode)
236 cut_actionPerformed(null);
239 alignPanel.seqPanel.deleteGapAtCursor(evt.isControlDown()
246 if (viewport.cursorMode)
248 alignPanel.seqPanel.setCursorRow();
252 if (viewport.cursorMode && !evt.isControlDown())
254 alignPanel.seqPanel.setCursorColumn();
258 if (viewport.cursorMode)
260 alignPanel.seqPanel.setCursorPosition();
264 case KeyEvent.VK_ENTER:
265 case KeyEvent.VK_COMMA:
266 if (viewport.cursorMode)
268 alignPanel.seqPanel.setCursorRowAndColumn();
273 if (viewport.cursorMode)
275 alignPanel.seqPanel.setSelectionAreaAtCursor(true);
279 if (viewport.cursorMode)
281 alignPanel.seqPanel.setSelectionAreaAtCursor(false);
286 viewport.cursorMode = !viewport.cursorMode;
287 statusBar.setText("Keyboard editing mode is " +
288 (viewport.cursorMode ? "on" : "off"));
289 if (viewport.cursorMode)
291 alignPanel.seqPanel.seqCanvas.cursorX = viewport.startRes;
292 alignPanel.seqPanel.seqCanvas.cursorY = viewport.startSeq;
294 alignPanel.seqPanel.seqCanvas.repaint();
300 ClassLoader cl = jalview.gui.Desktop.class.getClassLoader();
301 java.net.URL url = javax.help.HelpSet.findHelpSet(cl, "help/help");
302 javax.help.HelpSet hs = new javax.help.HelpSet(cl, url);
304 javax.help.HelpBroker hb = hs.createHelpBroker();
305 hb.setCurrentID("home");
306 hb.setDisplayed(true);
310 ex.printStackTrace();
316 boolean toggleSeqs = !evt.isControlDown();
317 boolean toggleCols = !evt.isShiftDown();
319 boolean hide = false;
321 SequenceGroup sg = viewport.getSelectionGroup();
324 if (sg != null && sg.getSize(false) != viewport.alignment.getHeight())
326 hideSelSequences_actionPerformed(null);
329 else if (! (toggleCols && viewport.colSel.getSelected().size() > 0))
330 showAllSeqs_actionPerformed(null);
335 if (viewport.colSel.getSelected().size() > 0)
337 hideSelColumns_actionPerformed(null);
339 viewport.selectionGroup = sg;
342 showAllColumns_actionPerformed(null);
346 case KeyEvent.VK_PAGE_UP:
347 if (viewport.wrapAlignment)
348 alignPanel.scrollUp(true);
350 alignPanel.setScrollValues(viewport.startRes,
352 - viewport.endSeq + viewport.startSeq);
354 case KeyEvent.VK_PAGE_DOWN:
355 if (viewport.wrapAlignment)
356 alignPanel.scrollUp(false);
358 alignPanel.setScrollValues(viewport.startRes,
360 + viewport.endSeq - viewport.startSeq);
368 public void addAlignmentPanel(final AlignmentPanel ap,
371 ap.alignFrame = this;
373 alignPanels.addElement(ap);
375 int aSize = alignPanels.size();
377 tabbedPane.setVisible(aSize>1 || ap.av.viewName!=null);
379 if (aSize == 1 && ap.av.viewName==null)
381 this.getContentPane().add(ap, BorderLayout.CENTER);
387 AlignmentPanel first = (AlignmentPanel) alignPanels.firstElement();
388 tabbedPane.addTab(first.av.viewName==null?"Original":first.av.viewName,first);
390 this.getContentPane().add(tabbedPane, BorderLayout.CENTER);
393 tabbedPane.addTab(ap.av.viewName==null?"Original":ap.av.viewName, ap);
395 ap.setVisible(false);
400 ap.av.updateConsensus(ap);
401 ap.av.updateConservation(ap);
406 public AlignViewport getViewport()
411 /* Set up intrinsic listeners for dynamically generated GUI bits. */
412 private void addServiceListeners()
414 final java.beans.PropertyChangeListener thisListener;
415 // Do this once to get current state
416 BuildWebServiceMenu();
417 Desktop.discoverer.addPropertyChangeListener(
418 thisListener = new java.beans.PropertyChangeListener()
420 public void propertyChange(PropertyChangeEvent evt)
422 // System.out.println("Discoverer property change.");
423 if (evt.getPropertyName().equals("services"))
425 // System.out.println("Rebuilding web service menu");
426 BuildWebServiceMenu();
431 addInternalFrameListener(new javax.swing.event.
432 InternalFrameAdapter()
434 public void internalFrameClosed(
435 javax.swing.event.InternalFrameEvent evt)
437 // System.out.println("deregistering discoverer listener");
438 Desktop.discoverer.removePropertyChangeListener(thisListener);
439 closeMenuItem_actionPerformed(true);
445 public void setGUINucleotide(boolean nucleotide)
447 showTranslation.setVisible( nucleotide );
448 conservationMenuItem.setEnabled( !nucleotide );
449 modifyConservation.setEnabled( !nucleotide );
451 //Remember AlignFrame always starts as protein
454 calculateMenu.remove(calculateMenu.getItemCount()-2);
459 * Need to call this method when tabs are selected for multiple views,
460 * or when loading from Jalview2XML.java
461 * @param av AlignViewport
463 void setMenusFromViewport(AlignViewport av)
465 colourTextMenuItem.setSelected(av.showColourText);
466 abovePIDThreshold.setSelected(av.getAbovePIDThreshold());
467 conservationMenuItem.setSelected(av.getConservationSelected());
468 seqLimits.setSelected(av.getShowJVSuffix());
469 renderGapsMenuItem.setSelected(av.renderGaps);
470 wrapMenuItem.setSelected(av.wrapAlignment);
471 annotationPanelMenuItem.setState(av.showAnnotation);
472 viewBoxesMenuItem.setSelected(av.showBoxes);
473 viewTextMenuItem.setSelected(av.showText);
475 setColourSelected(ColourSchemeProperty.
476 getColourName(av.getGlobalColourScheme()));
478 showSeqFeatures.setSelected(av.showSequenceFeatures);
479 hiddenMarkers.setState(av.showHiddenMarkers);
480 applyToAllGroups.setState(av.colourAppliesToAllGroups);
486 Hashtable progressBars;
487 public void setProgressBar(String message, long id)
489 if(progressBars == null)
490 progressBars = new Hashtable();
492 JPanel progressPanel;
493 GridLayout layout = (GridLayout) statusPanel.getLayout();
494 if(progressBars.get( new Long(id) )!=null)
496 progressPanel = (JPanel)progressBars.get( new Long(id) );
497 statusPanel.remove(progressPanel);
498 progressBars.remove( progressPanel );
499 progressPanel = null;
501 statusBar.setText(message);
503 layout.setRows(layout.getRows() - 1);
507 progressPanel = new JPanel(new BorderLayout(10, 5));
509 JProgressBar progressBar = new JProgressBar();
510 progressBar.setIndeterminate(true);
512 progressPanel.add(new JLabel(message), BorderLayout.WEST);
513 progressPanel.add(progressBar, BorderLayout.CENTER);
515 layout.setRows(layout.getRows() + 1);
516 statusPanel.add(progressPanel);
518 progressBars.put(new Long(id), progressPanel);
528 Added so Castor Mapping file can obtain Jalview Version
530 public String getVersion()
532 return jalview.bin.Cache.getProperty("VERSION");
535 public FeatureRenderer getFeatureRenderer()
537 return alignPanel.seqPanel.seqCanvas.getFeatureRenderer();
541 public void fetchSequence_actionPerformed(ActionEvent e)
543 new SequenceFetcher(this);
546 public void addFromFile_actionPerformed(ActionEvent e)
548 Desktop.instance.inputLocalFileMenuItem_actionPerformed(viewport);
551 public void reload_actionPerformed(ActionEvent e)
555 if(currentFileFormat.equals("Jalview"))
557 this.closeMenuItem_actionPerformed(true);
561 viewport.alignment.deleteAllGroups();
562 while (viewport.alignment.getHeight() > 0)
564 viewport.alignment.deleteSequence(0);
567 viewport.historyList.clear();
568 viewport.redoList.clear();
569 Alignment dset = viewport.alignment.getDataset();
570 while (dset.getHeight() > 0)
572 dset.deleteSequence(0);
575 firePropertyChange("Alignment", null, null);
580 FileLoader loader = new FileLoader();
581 loader.LoadFile(viewport, fileName, "File", currentFileFormat);
587 public void addFromText_actionPerformed(ActionEvent e)
589 Desktop.instance.inputTextboxMenuItem_actionPerformed(viewport);
592 public void addFromURL_actionPerformed(ActionEvent e)
594 Desktop.instance.inputURLMenuItem_actionPerformed(viewport);
598 public void save_actionPerformed(ActionEvent e)
600 if(fileName==null || currentFileFormat==null)
601 saveAs_actionPerformed(null);
603 saveAlignment(fileName, currentFileFormat);
609 * @param e DOCUMENT ME!
611 public void saveAs_actionPerformed(ActionEvent e)
613 JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
614 getProperty( "LAST_DIRECTORY"),
616 { "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc","jar" },
618 { "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview" },
623 chooser.setFileView(new JalviewFileView());
624 chooser.setDialogTitle("Save Alignment to file");
625 chooser.setToolTipText("Save");
627 int value = chooser.showSaveDialog(this);
629 if (value == JalviewFileChooser.APPROVE_OPTION)
631 currentFileFormat = chooser.getSelectedFormat();
632 if (currentFileFormat == null)
634 JOptionPane.showInternalMessageDialog(Desktop.desktop,
635 "You must select a file format before saving!",
636 "File format not specified",
637 JOptionPane.WARNING_MESSAGE);
638 value = chooser.showSaveDialog(this);
642 fileName = chooser.getSelectedFile().getPath();
644 jalview.bin.Cache.setProperty("DEFAULT_FILE_FORMAT",
647 jalview.bin.Cache.setProperty("LAST_DIRECTORY", fileName);
649 saveAlignment(fileName, currentFileFormat);
653 public boolean saveAlignment(String file, String format)
655 if (format.equalsIgnoreCase("Jalview"))
657 String shortName = title;
659 if (shortName.indexOf(java.io.File.separatorChar) > -1)
661 shortName = shortName.substring(shortName.lastIndexOf(
662 java.io.File.separatorChar) + 1);
665 new Jalview2XML().SaveAlignment(this, file, shortName);
667 statusBar.setText("Successfully saved to file: "
669 +format +" format.");
672 // USE Jalview2XML to save this file
678 String[] omitHidden = null;
680 if (viewport.hasHiddenColumns)
682 int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
683 "The Alignment contains hidden columns."
684 + "\nDo you want to save only the visible alignment?",
685 "Save / Omit Hidden Columns",
686 JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
688 if (reply == JOptionPane.YES_OPTION)
689 omitHidden = viewport.getViewAsString(false);
692 String output = new FormatAdapter().formatSequences(
694 viewport.alignment.getSequencesArray(),
704 java.io.PrintWriter out = new java.io.PrintWriter(
705 new java.io.FileWriter(file));
710 statusBar.setText("Successfully saved to file: "
712 +format +" format.");
717 ex.printStackTrace();
726 * @param e DOCUMENT ME!
728 protected void outputText_actionPerformed(ActionEvent e)
730 String [] omitHidden = null;
732 if(viewport.hasHiddenColumns)
734 int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
735 "The Alignment contains hidden columns."
736 +"\nDo you want to output only the visible alignment?",
737 "Save / Omit Hidden Columns",
738 JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
740 if(reply==JOptionPane.YES_OPTION)
742 omitHidden = viewport.getViewAsString(false);
746 CutAndPasteTransfer cap = new CutAndPasteTransfer();
747 cap.setForInput(null);
748 Desktop.addInternalFrame(cap,
749 "Alignment output - " + e.getActionCommand(), 600,
753 cap.setText(new FormatAdapter().formatSequences(
754 e.getActionCommand(),
755 viewport.alignment.getSequencesArray(),
762 * @param e DOCUMENT ME!
764 protected void htmlMenuItem_actionPerformed(ActionEvent e)
766 new HTMLOutput(viewport,
767 alignPanel.seqPanel.seqCanvas.getSequenceRenderer(),
768 alignPanel.seqPanel.seqCanvas.getFeatureRenderer());
771 public void createImageMap(File file, String image)
773 alignPanel.makePNGImageMap(file, image);
779 * @param e DOCUMENT ME!
781 public void createPNG(File f)
783 alignPanel.makePNG(f);
789 * @param e DOCUMENT ME!
791 public void createEPS(File f)
793 alignPanel.makeEPS(f);
799 * @param e DOCUMENT ME!
801 public void printMenuItem_actionPerformed(ActionEvent e)
803 //Putting in a thread avoids Swing painting problems
804 PrintThread thread = new PrintThread();
808 public void exportFeatures_actionPerformed(ActionEvent e)
810 new AnnotationExporter().exportFeatures(alignPanel);
814 public void exportAnnotations_actionPerformed(ActionEvent e)
816 new AnnotationExporter().exportAnnotations(
818 viewport.alignment.getAlignmentAnnotation()
823 public void associatedData_actionPerformed(ActionEvent e)
825 // Pick the tree file
826 JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
829 chooser.setFileView(new JalviewFileView());
830 chooser.setDialogTitle("Load Jalview Annotations or Features File");
831 chooser.setToolTipText("Load Jalview Annotations / Features file");
833 int value = chooser.showOpenDialog(null);
835 if (value == JalviewFileChooser.APPROVE_OPTION)
837 String choice = chooser.getSelectedFile().getPath();
838 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
839 loadJalviewDataFile(choice);
848 * @param e DOCUMENT ME!
850 public void closeMenuItem_actionPerformed(boolean closeAllTabs)
852 if(alignPanels!=null && alignPanels.size()<2)
857 if(alignPanels!=null)
860 for (int i = 0; i < alignPanels.size(); i++)
862 AlignmentPanel ap = (AlignmentPanel) alignPanels.elementAt(i);
863 PaintRefresher.RemoveComponent(ap.seqPanel.seqCanvas);
864 PaintRefresher.RemoveComponent(ap.idPanel.idCanvas);
865 PaintRefresher.RemoveComponent(ap);
869 int index = tabbedPane.getSelectedIndex();
871 tabbedPane.removeTabAt(index);
872 alignPanels.removeElement(alignPanel);
873 PaintRefresher.RemoveComponent(alignPanel.seqPanel.seqCanvas);
874 PaintRefresher.RemoveComponent(alignPanel.idPanel.idCanvas);
875 PaintRefresher.RemoveComponent(alignPanel);
878 tabbedPane.validate();
880 if(index==tabbedPane.getTabCount())
883 this.tabSelectionChanged(index);
888 this.setClosed(true);
892 ex.printStackTrace();
900 void updateEditMenuBar()
903 if (viewport.historyList.size() > 0)
905 undoMenuItem.setEnabled(true);
906 CommandI command = (CommandI) viewport.historyList.peek();
907 undoMenuItem.setText("Undo " + command.getDescription());
911 undoMenuItem.setEnabled(false);
912 undoMenuItem.setText("Undo");
915 if (viewport.redoList.size() > 0)
917 redoMenuItem.setEnabled(true);
919 CommandI command = (CommandI) viewport.redoList.peek();
920 redoMenuItem.setText("Redo " + command.getDescription());
924 redoMenuItem.setEnabled(false);
925 redoMenuItem.setText("Redo");
930 public void addHistoryItem(CommandI command)
932 if(command.getSize()>0)
934 viewport.historyList.push(command);
935 viewport.redoList.clear();
937 viewport.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;
946 * @param e DOCUMENT ME!
948 protected void undoMenuItem_actionPerformed(ActionEvent e)
950 CommandI command = (CommandI)viewport.historyList.pop();
951 viewport.redoList.push(command);
952 command.undoCommand();
954 viewport.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;
956 viewport.firePropertyChange("alignment", null,
957 viewport.getAlignment().getSequences());
963 * @param e DOCUMENT ME!
965 protected void redoMenuItem_actionPerformed(ActionEvent e)
967 CommandI command = (CommandI) viewport.redoList.pop();
968 viewport.historyList.push(command);
970 viewport.hasHiddenColumns = viewport.colSel.getHiddenColumns()!=null;
973 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
980 * @param up DOCUMENT ME!
982 public void moveSelectedSequences(boolean up)
984 SequenceGroup sg = viewport.getSelectionGroup();
993 for (int i = 1; i < viewport.alignment.getHeight(); i++)
995 SequenceI seq = viewport.alignment.getSequenceAt(i);
997 if (!sg.getSequences(false).contains(seq))
1002 SequenceI temp = viewport.alignment.getSequenceAt(i - 1);
1004 if (sg.getSequences(false).contains(temp))
1009 viewport.alignment.getSequences().setElementAt(temp, i);
1010 viewport.alignment.getSequences().setElementAt(seq, i - 1);
1015 for (int i = viewport.alignment.getHeight() - 2; i > -1; i--)
1017 SequenceI seq = viewport.alignment.getSequenceAt(i);
1019 if (!sg.getSequences(false).contains(seq))
1024 SequenceI temp = viewport.alignment.getSequenceAt(i + 1);
1026 if (sg.getSequences(false).contains(temp))
1031 viewport.alignment.getSequences().setElementAt(temp, i);
1032 viewport.alignment.getSequences().setElementAt(seq, i + 1);
1036 alignPanel.repaint();
1044 * @param e DOCUMENT ME!
1046 protected void copy_actionPerformed(ActionEvent e)
1049 if (viewport.getSelectionGroup() == null)
1054 SequenceI [] seqs = viewport.getSelectionAsNewSequence();
1055 String[] omitHidden = null;
1057 if (viewport.hasHiddenColumns)
1059 omitHidden = viewport.getViewAsString(true);
1062 String output = new FormatAdapter().formatSequences(
1067 StringSelection ss = new StringSelection(output);
1071 //Its really worth setting the clipboard contents
1072 //to empty before setting the large StringSelection!!
1073 Toolkit.getDefaultToolkit().getSystemClipboard()
1074 .setContents(new StringSelection(""), null);
1076 Toolkit.getDefaultToolkit().getSystemClipboard()
1077 .setContents(ss, Desktop.instance);
1079 catch (OutOfMemoryError er)
1081 er.printStackTrace();
1082 javax.swing.SwingUtilities.invokeLater(new Runnable()
1086 javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop,
1087 "Out of memory copying region!!"
1089 "\nSee help files for increasing Java Virtual Machine memory."
1091 javax.swing.JOptionPane.WARNING_MESSAGE);
1098 Vector hiddenColumns = null;
1099 if(viewport.hasHiddenColumns)
1101 hiddenColumns =new Vector();
1102 int hiddenOffset = viewport.getSelectionGroup().getStartRes();
1103 for(int i=0; i<viewport.getColumnSelection().getHiddenColumns().size(); i++)
1105 int[] region = (int[])
1106 viewport.getColumnSelection().getHiddenColumns().elementAt(i);
1108 hiddenColumns.addElement(new int[]{region[0]-hiddenOffset,
1109 region[1]-hiddenOffset});
1115 Desktop.jalviewClipboard = new Object[]{ seqs,
1116 viewport.alignment.getDataset(),
1118 statusBar.setText("Copied "+seqs.length+" sequences to clipboard.");
1124 * @param e DOCUMENT ME!
1126 protected void pasteNew_actionPerformed(ActionEvent e)
1134 * @param e DOCUMENT ME!
1136 protected void pasteThis_actionPerformed(ActionEvent e)
1144 * @param newAlignment DOCUMENT ME!
1146 void paste(boolean newAlignment)
1150 Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
1151 Transferable contents = c.getContents(this);
1153 if (contents == null)
1161 str = (String) contents.getTransferData(DataFlavor.stringFlavor);
1162 if (str.length() < 1)
1165 format = new IdentifyFile().Identify(str, "Paste");
1168 catch (OutOfMemoryError er)
1170 er.printStackTrace();
1171 javax.swing.SwingUtilities.invokeLater(new Runnable()
1175 javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop,
1176 "Out of memory pasting sequences!!"
1178 "\nSee help files for increasing Java Virtual Machine memory."
1180 javax.swing.JOptionPane.WARNING_MESSAGE);
1187 SequenceI[] sequences;
1190 if(Desktop.jalviewClipboard!=null)
1192 // The clipboard was filled from within Jalview, we must use the sequences
1193 // And dataset from the copied alignment
1194 sequences = (SequenceI[])Desktop.jalviewClipboard[0];
1198 sequences = new FormatAdapter().readFile(str, "Paste", format);
1201 AlignmentI alignment = null;
1205 alignment = new Alignment(sequences);
1207 if (Desktop.jalviewClipboard != null)
1208 alignment.setDataset( (Alignment) Desktop.jalviewClipboard[1]);
1210 alignment.setDataset(null);
1214 alignment = viewport.getAlignment();
1217 SequenceI [] newseqs = new SequenceI[sequences.length];
1218 for (int i = 0; i < sequences.length; i++)
1220 newseqs[i] = new Sequence(sequences[i].getName(),
1221 sequences[i].getSequence(), sequences[i].getStart(),
1222 sequences[i].getEnd());
1224 alignment.addSequence(newseqs[i]);
1230 addHistoryItem(new EditCommand(
1235 alignment.getWidth(),
1240 viewport.setEndSeq(alignment.getHeight());
1241 alignment.getWidth();
1242 viewport.firePropertyChange("alignment", null, alignment.getSequences());
1247 // Add any annotations attached to sequences
1248 for (int i = 0; i < sequences.length; i++)
1250 if (sequences[i].getAnnotation() != null)
1252 for (int a = 0; a < sequences[i].getAnnotation().length; a++)
1254 AlignmentAnnotation newAnnot =
1255 new AlignmentAnnotation(
1256 sequences[i].getAnnotation()[a].label,
1257 sequences[i].getAnnotation()[a].description,
1258 sequences[i].getAnnotation()[a].annotations,
1259 sequences[i].getAnnotation()[a].graphMin,
1260 sequences[i].getAnnotation()[a].graphMax,
1261 sequences[i].getAnnotation()[a].graph);
1263 sequences[i].getAnnotation()[a] = newAnnot;
1264 newAnnot.sequenceMapping = sequences[i].getAnnotation()[a].
1266 newAnnot.sequenceRef = sequences[i];
1267 newAnnot.adjustForAlignment();
1268 alignment.addAnnotation(newAnnot);
1269 alignment.setAnnotationIndex(newAnnot, a);
1272 alignPanel.annotationPanel.adjustPanelHeight();
1278 AlignFrame af = new AlignFrame(alignment, DEFAULT_WIDTH, DEFAULT_HEIGHT);
1279 String newtitle = new String("Copied sequences");
1281 if(Desktop.jalviewClipboard!=null && Desktop.jalviewClipboard[2]!=null)
1283 Vector hc = (Vector)Desktop.jalviewClipboard[2];
1284 for(int i=0; i<hc.size(); i++)
1286 int [] region = (int[]) hc.elementAt(i);
1287 af.viewport.hideColumns(region[0], region[1]);
1292 //>>>This is a fix for the moment, until a better solution is found!!<<<
1293 af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().transferSettings(
1294 alignPanel.seqPanel.seqCanvas.getFeatureRenderer());
1297 if (title.startsWith("Copied sequences"))
1303 newtitle = newtitle.concat("- from " + title);
1306 Desktop.addInternalFrame(af, newtitle, DEFAULT_WIDTH,
1313 catch (Exception ex)
1315 ex.printStackTrace();
1316 System.out.println("Exception whilst pasting: "+ex);
1317 // could be anything being pasted in here
1326 * @param e DOCUMENT ME!
1328 protected void cut_actionPerformed(ActionEvent e)
1330 copy_actionPerformed(null);
1331 delete_actionPerformed(null);
1337 * @param e DOCUMENT ME!
1339 protected void delete_actionPerformed(ActionEvent evt)
1342 SequenceGroup sg = viewport.getSelectionGroup();
1348 Vector seqs = new Vector();
1349 int cutLength = sg.getEndRes()-sg.getStartRes()+1;
1350 boolean seqsCut = false;
1352 for (int i = 0; i < sg.getSize(false); i++)
1354 seq = sg.getSequenceAt(i);
1355 seqs.addElement(seq);
1356 if(seq.getLength()<=cutLength)
1361 // If the cut affects all sequences, remove highlighted columns
1362 if (sg.getSize(false) == viewport.alignment.getHeight())
1364 viewport.getColumnSelection().removeElements(sg.getStartRes(),
1365 sg.getEndRes() + 1);
1369 SequenceI [] cut = new SequenceI[seqs.size()];
1370 for(int i=0; i<seqs.size(); i++)
1371 cut[i] = (SequenceI)seqs.elementAt(i);
1377 addHistoryItem(new EditCommand("Cut Sequences",
1381 sg.getEndRes()-sg.getStartRes()+1,
1382 viewport.alignment));
1385 viewport.setSelectionGroup(null);
1386 viewport.alignment.deleteGroup(sg);
1388 viewport.firePropertyChange("alignment", null,
1389 viewport.getAlignment().getSequences());
1391 if (viewport.getAlignment().getHeight() < 1)
1395 this.setClosed(true);
1397 catch (Exception ex)
1406 * @param e DOCUMENT ME!
1408 protected void deleteGroups_actionPerformed(ActionEvent e)
1410 viewport.alignment.deleteAllGroups();
1411 viewport.setSelectionGroup(null);
1412 PaintRefresher.Refresh(this, viewport.getSequenceSetId());
1413 alignPanel.repaint();
1419 * @param e DOCUMENT ME!
1421 public void selectAllSequenceMenuItem_actionPerformed(ActionEvent e)
1423 SequenceGroup sg = new SequenceGroup();
1425 for (int i = 0; i < viewport.getAlignment().getSequences().size();
1428 sg.addSequence(viewport.getAlignment().getSequenceAt(i), false);
1431 sg.setEndRes(viewport.alignment.getWidth() - 1);
1432 viewport.setSelectionGroup(sg);
1433 alignPanel.repaint();
1434 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
1440 * @param e DOCUMENT ME!
1442 public void deselectAllSequenceMenuItem_actionPerformed(ActionEvent e)
1444 if(viewport.cursorMode)
1446 alignPanel.seqPanel.keyboardNo1 = null;
1447 alignPanel.seqPanel.keyboardNo2 = null;
1449 viewport.setSelectionGroup(null);
1450 viewport.getColumnSelection().clear();
1451 viewport.setSelectionGroup(null);
1452 alignPanel.seqPanel.seqCanvas.highlightSearchResults(null);
1453 alignPanel.idPanel.idCanvas.searchResults = null;
1454 alignPanel.repaint();
1455 PaintRefresher.Refresh(this, viewport.getSequenceSetId());
1461 * @param e DOCUMENT ME!
1463 public void invertSequenceMenuItem_actionPerformed(ActionEvent e)
1465 SequenceGroup sg = viewport.getSelectionGroup();
1469 selectAllSequenceMenuItem_actionPerformed(null);
1474 for (int i = 0; i < viewport.getAlignment().getSequences().size();
1477 sg.addOrRemove(viewport.getAlignment().getSequenceAt(i), false);
1480 PaintRefresher.Refresh(this, viewport.getSequenceSetId());
1483 public void invertColSel_actionPerformed(ActionEvent e)
1485 viewport.invertColumnSelection();
1486 alignPanel.repaint();
1493 * @param e DOCUMENT ME!
1495 public void remove2LeftMenuItem_actionPerformed(ActionEvent e)
1497 trimAlignment(true);
1503 * @param e DOCUMENT ME!
1505 public void remove2RightMenuItem_actionPerformed(ActionEvent e)
1507 trimAlignment(false);
1510 void trimAlignment(boolean trimLeft)
1512 ColumnSelection colSel = viewport.getColumnSelection();
1515 if (colSel.size() > 0)
1518 column = colSel.getMin();
1520 column = colSel.getMax();
1523 if(viewport.getSelectionGroup()!=null)
1524 seqs = viewport.getSelectionGroup().getSequencesAsArray(true);
1526 seqs = viewport.alignment.getSequencesArray();
1529 TrimRegionCommand trimRegion;
1532 trimRegion = new TrimRegionCommand("Remove Left",
1533 TrimRegionCommand.TRIM_LEFT,
1538 viewport.selectionGroup);
1542 trimRegion = new TrimRegionCommand("Remove Right",
1543 TrimRegionCommand.TRIM_RIGHT,
1548 viewport.selectionGroup);
1551 statusBar.setText("Removed "+trimRegion.getSize()+" columns.");
1554 addHistoryItem(trimRegion);
1556 Vector groups = viewport.alignment.getGroups();
1558 for (int i = 0; i < groups.size(); i++)
1560 SequenceGroup sg = (SequenceGroup) groups.get(i);
1562 if ( (trimLeft && !sg.adjustForRemoveLeft(column))
1563 || (!trimLeft && !sg.adjustForRemoveRight(column)))
1565 viewport.alignment.deleteGroup(sg);
1569 viewport.firePropertyChange("alignment", null,
1570 viewport.getAlignment().getSequences());
1577 * @param e DOCUMENT ME!
1579 public void removeGappedColumnMenuItem_actionPerformed(ActionEvent e)
1581 int start = 0, end = viewport.alignment.getWidth()-1;
1584 if (viewport.getSelectionGroup() != null)
1586 seqs = viewport.getSelectionGroup().getSequencesAsArray(true);
1587 start = viewport.getSelectionGroup().getStartRes();
1588 end = viewport.getSelectionGroup().getEndRes();
1591 seqs = viewport.alignment.getSequencesArray();
1594 RemoveGapColCommand removeGapCols =
1595 new RemoveGapColCommand("Remove Gapped Columns",
1598 viewport.getGapCharacter());
1600 addHistoryItem(removeGapCols);
1602 statusBar.setText("Removed "+removeGapCols.getSize()+" empty columns.");
1604 //This is to maintain viewport position on first residue
1606 SequenceI seq = viewport.alignment.getSequenceAt(0);
1607 int startRes = seq.findPosition(viewport.startRes);
1608 // ShiftList shifts;
1609 // viewport.getAlignment().removeGaps(shifts=new ShiftList());
1610 // edit.alColumnChanges=shifts.getInverse();
1611 // if (viewport.hasHiddenColumns)
1612 // viewport.getColumnSelection().compensateForEdits(shifts);
1613 viewport.setStartRes(seq.findIndex(startRes)-1);
1614 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
1621 * @param e DOCUMENT ME!
1623 public void removeAllGapsMenuItem_actionPerformed(ActionEvent e)
1625 int start = 0, end = viewport.alignment.getWidth()-1;
1628 if (viewport.getSelectionGroup() != null)
1630 seqs = viewport.getSelectionGroup().getSequencesAsArray(true);
1631 start = viewport.getSelectionGroup().getStartRes();
1632 end = viewport.getSelectionGroup().getEndRes();
1635 seqs = viewport.alignment.getSequencesArray();
1637 //This is to maintain viewport position on first residue
1639 SequenceI seq = viewport.alignment.getSequenceAt(0);
1640 int startRes = seq.findPosition(viewport.startRes);
1642 addHistoryItem(new RemoveGapsCommand("Remove Gaps",
1645 viewport.getGapCharacter()));
1647 viewport.setStartRes(seq.findIndex(startRes)-1);
1649 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
1656 * @param e DOCUMENT ME!
1658 public void padGapsMenuitem_actionPerformed(ActionEvent e)
1660 viewport.padGaps = padGapsMenuitem.isSelected();
1662 viewport.firePropertyChange("alignment",
1664 viewport.getAlignment().getSequences());
1670 * @param e DOCUMENT ME!
1672 public void findMenuItem_actionPerformed(ActionEvent e)
1674 JInternalFrame frame = new JInternalFrame();
1675 Finder finder = new Finder(viewport, alignPanel, frame);
1676 frame.setContentPane(finder);
1677 frame.setLayer(JLayeredPane.PALETTE_LAYER);
1678 Desktop.addInternalFrame(frame, "Find", 340, 110);
1681 public void newView_actionPerformed(ActionEvent e)
1683 AlignmentPanel newap =
1684 new Jalview2XML().copyAlignPanel(alignPanel, true);
1686 if (viewport.viewName == null)
1687 viewport.viewName = "View 1";
1689 newap.av.historyList = viewport.historyList;
1690 newap.av.redoList = viewport.redoList;
1691 newap.av.viewName = "View " +
1692 (Desktop.getViewCount(viewport.getSequenceSetId()) + 1);
1694 addAlignmentPanel(newap, false);
1696 if(alignPanels.size()==2)
1698 System.out.println("set gather once2");
1699 viewport.gatherViewsHere = true;
1701 tabbedPane.setSelectedIndex(tabbedPane.getTabCount() - 1);
1708 * @param e DOCUMENT ME!
1710 public void font_actionPerformed(ActionEvent e)
1712 new FontChooser(alignPanel);
1719 * @param e DOCUMENT ME!
1721 protected void seqLimit_actionPerformed(ActionEvent e)
1723 viewport.setShowJVSuffix(seqLimits.isSelected());
1725 alignPanel.idPanel.idCanvas.setPreferredSize(alignPanel.calculateIdWidth());
1726 alignPanel.repaint();
1733 * @param e DOCUMENT ME!
1735 protected void colourTextMenuItem_actionPerformed(ActionEvent e)
1737 viewport.setColourText(colourTextMenuItem.isSelected());
1738 alignPanel.repaint();
1744 * @param e DOCUMENT ME!
1746 public void wrapMenuItem_actionPerformed(ActionEvent e)
1748 scaleAbove.setVisible(wrapMenuItem.isSelected());
1749 scaleLeft.setVisible(wrapMenuItem.isSelected());
1750 scaleRight.setVisible(wrapMenuItem.isSelected());
1751 viewport.setWrapAlignment(wrapMenuItem.isSelected());
1752 alignPanel.setWrapAlignment(wrapMenuItem.isSelected());
1755 public void showAllSeqs_actionPerformed(ActionEvent e)
1757 viewport.showAllHiddenSeqs();
1760 public void showAllColumns_actionPerformed(ActionEvent e)
1762 viewport.showAllHiddenColumns();
1766 public void hideSelSequences_actionPerformed(ActionEvent e)
1768 viewport.hideAllSelectedSeqs();
1769 alignPanel.repaint();
1772 public void hideSelColumns_actionPerformed(ActionEvent e)
1774 viewport.hideSelectedColumns();
1775 alignPanel.repaint();
1778 public void hiddenMarkers_actionPerformed(ActionEvent e)
1780 viewport.setShowHiddenMarkers(hiddenMarkers.isSelected());
1787 * @param e DOCUMENT ME!
1789 protected void scaleAbove_actionPerformed(ActionEvent e)
1791 viewport.setScaleAboveWrapped(scaleAbove.isSelected());
1792 alignPanel.repaint();
1798 * @param e DOCUMENT ME!
1800 protected void scaleLeft_actionPerformed(ActionEvent e)
1802 viewport.setScaleLeftWrapped(scaleLeft.isSelected());
1803 alignPanel.repaint();
1809 * @param e DOCUMENT ME!
1811 protected void scaleRight_actionPerformed(ActionEvent e)
1813 viewport.setScaleRightWrapped(scaleRight.isSelected());
1814 alignPanel.repaint();
1820 * @param e DOCUMENT ME!
1822 public void viewBoxesMenuItem_actionPerformed(ActionEvent e)
1824 viewport.setShowBoxes(viewBoxesMenuItem.isSelected());
1825 alignPanel.repaint();
1831 * @param e DOCUMENT ME!
1833 public void viewTextMenuItem_actionPerformed(ActionEvent e)
1835 viewport.setShowText(viewTextMenuItem.isSelected());
1836 alignPanel.repaint();
1842 * @param e DOCUMENT ME!
1844 protected void renderGapsMenuItem_actionPerformed(ActionEvent e)
1846 viewport.setRenderGaps(renderGapsMenuItem.isSelected());
1847 alignPanel.repaint();
1851 public FeatureSettings featureSettings;
1852 public void featureSettings_actionPerformed(ActionEvent e)
1854 if(featureSettings !=null )
1856 featureSettings.close();
1857 featureSettings = null;
1859 featureSettings = new FeatureSettings(this);
1865 * @param evt DOCUMENT ME!
1867 public void showSeqFeatures_actionPerformed(ActionEvent evt)
1869 viewport.setShowSequenceFeatures(showSeqFeatures.isSelected());
1870 alignPanel.repaint();
1871 if (alignPanel.getOverviewPanel() != null)
1873 alignPanel.getOverviewPanel().updateOverviewImage();
1880 * @param e DOCUMENT ME!
1882 public void annotationPanelMenuItem_actionPerformed(ActionEvent e)
1884 viewport.setShowAnnotation(annotationPanelMenuItem.isSelected());
1885 alignPanel.setAnnotationVisible(annotationPanelMenuItem.isSelected());
1891 * @param e DOCUMENT ME!
1893 public void overviewMenuItem_actionPerformed(ActionEvent e)
1895 if (alignPanel.overviewPanel != null)
1900 JInternalFrame frame = new JInternalFrame();
1901 OverviewPanel overview = new OverviewPanel(alignPanel);
1902 frame.setContentPane(overview);
1903 Desktop.addInternalFrame(frame, "Overview " + this.getTitle(),
1904 frame.getWidth(), frame.getHeight());
1906 frame.setLayer(JLayeredPane.PALETTE_LAYER);
1907 frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
1909 public void internalFrameClosed(
1910 javax.swing.event.InternalFrameEvent evt)
1912 alignPanel.setOverviewPanel(null);
1917 alignPanel.setOverviewPanel(overview);
1923 * @param e DOCUMENT ME!
1925 protected void noColourmenuItem_actionPerformed(ActionEvent e)
1933 * @param e DOCUMENT ME!
1935 public void clustalColour_actionPerformed(ActionEvent e)
1937 changeColour(new ClustalxColourScheme(
1938 viewport.alignment.getSequences(), viewport.alignment.getWidth()));
1944 * @param e DOCUMENT ME!
1946 public void zappoColour_actionPerformed(ActionEvent e)
1948 changeColour(new ZappoColourScheme());
1954 * @param e DOCUMENT ME!
1956 public void taylorColour_actionPerformed(ActionEvent e)
1958 changeColour(new TaylorColourScheme());
1964 * @param e DOCUMENT ME!
1966 public void hydrophobicityColour_actionPerformed(ActionEvent e)
1968 changeColour(new HydrophobicColourScheme());
1974 * @param e DOCUMENT ME!
1976 public void helixColour_actionPerformed(ActionEvent e)
1978 changeColour(new HelixColourScheme());
1984 * @param e DOCUMENT ME!
1986 public void strandColour_actionPerformed(ActionEvent e)
1988 changeColour(new StrandColourScheme());
1994 * @param e DOCUMENT ME!
1996 public void turnColour_actionPerformed(ActionEvent e)
1998 changeColour(new TurnColourScheme());
2004 * @param e DOCUMENT ME!
2006 public void buriedColour_actionPerformed(ActionEvent e)
2008 changeColour(new BuriedColourScheme());
2014 * @param e DOCUMENT ME!
2016 public void nucleotideColour_actionPerformed(ActionEvent e)
2018 changeColour(new NucleotideColourScheme());
2021 public void annotationColour_actionPerformed(ActionEvent e)
2023 new AnnotationColourChooser(viewport, alignPanel);
2030 * @param e DOCUMENT ME!
2032 protected void applyToAllGroups_actionPerformed(ActionEvent e)
2034 viewport.setColourAppliesToAllGroups(applyToAllGroups.isSelected());
2040 * @param cs DOCUMENT ME!
2042 public void changeColour(ColourSchemeI cs)
2048 if (viewport.getAbovePIDThreshold())
2050 threshold = SliderPanel.setPIDSliderSource(alignPanel, cs,
2053 cs.setThreshold(threshold,
2054 viewport.getIgnoreGapsConsensus());
2056 viewport.setGlobalColourScheme(cs);
2060 cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
2063 if (viewport.getConservationSelected())
2066 Alignment al = (Alignment) viewport.alignment;
2067 Conservation c = new Conservation("All",
2068 ResidueProperties.propHash, 3,
2069 al.getSequences(), 0,
2073 c.verdict(false, viewport.ConsPercGaps);
2075 cs.setConservation(c);
2077 cs.setConservationInc(SliderPanel.setConservationSlider(alignPanel, cs,
2082 cs.setConservation(null);
2085 cs.setConsensus(viewport.hconsensus);
2088 viewport.setGlobalColourScheme(cs);
2090 if (viewport.getColourAppliesToAllGroups())
2092 Vector groups = viewport.alignment.getGroups();
2094 for (int i = 0; i < groups.size(); i++)
2096 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
2104 if (cs instanceof ClustalxColourScheme)
2106 sg.cs = new ClustalxColourScheme(
2107 sg.getSequences(true), sg.getWidth());
2109 else if (cs instanceof UserColourScheme)
2111 sg.cs = new UserColourScheme( ( (UserColourScheme) cs).getColours());
2117 sg.cs = (ColourSchemeI) cs.getClass().newInstance();
2119 catch (Exception ex)
2124 if (viewport.getAbovePIDThreshold()
2125 || cs instanceof PIDColourScheme
2126 || cs instanceof Blosum62ColourScheme)
2128 sg.cs.setThreshold(threshold,
2129 viewport.getIgnoreGapsConsensus());
2131 sg.cs.setConsensus(AAFrequency.calculate(
2132 sg.getSequences(true), sg.getStartRes(),
2136 sg.cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
2139 if (viewport.getConservationSelected())
2141 Conservation c = new Conservation("Group",
2142 ResidueProperties.propHash, 3,
2143 sg.getSequences(true),
2147 c.verdict(false, viewport.ConsPercGaps);
2148 sg.cs.setConservation(c);
2151 sg.cs.setConservation(null);
2155 if (alignPanel.getOverviewPanel() != null)
2157 alignPanel.getOverviewPanel().updateOverviewImage();
2160 alignPanel.repaint();
2166 * @param e DOCUMENT ME!
2168 protected void modifyPID_actionPerformed(ActionEvent e)
2170 if (viewport.getAbovePIDThreshold() && viewport.globalColourScheme!=null)
2172 SliderPanel.setPIDSliderSource(alignPanel,
2173 viewport.getGlobalColourScheme(),
2175 SliderPanel.showPIDSlider();
2182 * @param e DOCUMENT ME!
2184 protected void modifyConservation_actionPerformed(ActionEvent e)
2186 if (viewport.getConservationSelected() && viewport.globalColourScheme!=null)
2188 SliderPanel.setConservationSlider(alignPanel,
2189 viewport.globalColourScheme,
2191 SliderPanel.showConservationSlider();
2198 * @param e DOCUMENT ME!
2200 protected void conservationMenuItem_actionPerformed(ActionEvent e)
2202 viewport.setConservationSelected(conservationMenuItem.isSelected());
2204 viewport.setAbovePIDThreshold(false);
2205 abovePIDThreshold.setSelected(false);
2207 changeColour(viewport.getGlobalColourScheme());
2209 modifyConservation_actionPerformed(null);
2215 * @param e DOCUMENT ME!
2217 public void abovePIDThreshold_actionPerformed(ActionEvent e)
2219 viewport.setAbovePIDThreshold(abovePIDThreshold.isSelected());
2221 conservationMenuItem.setSelected(false);
2222 viewport.setConservationSelected(false);
2224 changeColour(viewport.getGlobalColourScheme());
2226 modifyPID_actionPerformed(null);
2232 * @param e DOCUMENT ME!
2234 public void userDefinedColour_actionPerformed(ActionEvent e)
2236 if (e.getActionCommand().equals("User Defined..."))
2238 new UserDefinedColours(alignPanel, null);
2242 UserColourScheme udc = (UserColourScheme) UserDefinedColours.
2243 getUserColourSchemes().get(e.getActionCommand());
2249 public void updateUserColourMenu()
2252 Component[] menuItems = colourMenu.getMenuComponents();
2253 int i, iSize = menuItems.length;
2254 for (i = 0; i < iSize; i++)
2256 if (menuItems[i].getName() != null &&
2257 menuItems[i].getName().equals("USER_DEFINED"))
2259 colourMenu.remove(menuItems[i]);
2263 if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null)
2265 java.util.Enumeration userColours = jalview.gui.UserDefinedColours.
2266 getUserColourSchemes().keys();
2268 while (userColours.hasMoreElements())
2270 final JRadioButtonMenuItem radioItem = new JRadioButtonMenuItem(userColours.
2271 nextElement().toString());
2272 radioItem.setName("USER_DEFINED");
2273 radioItem.addMouseListener(new MouseAdapter()
2275 public void mousePressed(MouseEvent evt)
2277 if(evt.isControlDown() || SwingUtilities.isRightMouseButton(evt))
2279 radioItem.removeActionListener(radioItem.getActionListeners()[0]);
2281 int option = JOptionPane.showInternalConfirmDialog(jalview.gui.Desktop.desktop,
2282 "Remove from default list?",
2283 "Remove user defined colour",
2284 JOptionPane.YES_NO_OPTION);
2285 if(option == JOptionPane.YES_OPTION)
2287 jalview.gui.UserDefinedColours.removeColourFromDefaults(radioItem.getText());
2288 colourMenu.remove(radioItem);
2291 radioItem.addActionListener(new ActionListener()
2293 public void actionPerformed(ActionEvent evt)
2295 userDefinedColour_actionPerformed(evt);
2301 radioItem.addActionListener(new ActionListener()
2303 public void actionPerformed(ActionEvent evt)
2305 userDefinedColour_actionPerformed(evt);
2309 colourMenu.insert(radioItem, 15);
2310 colours.add(radioItem);
2318 * @param e DOCUMENT ME!
2320 public void PIDColour_actionPerformed(ActionEvent e)
2322 changeColour(new PIDColourScheme());
2328 * @param e DOCUMENT ME!
2330 public void BLOSUM62Colour_actionPerformed(ActionEvent e)
2332 changeColour(new Blosum62ColourScheme());
2338 * @param e DOCUMENT ME!
2340 public void sortPairwiseMenuItem_actionPerformed(ActionEvent e)
2342 SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray();
2343 AlignmentSorter.sortByPID(viewport.getAlignment(),
2344 viewport.getAlignment().getSequenceAt(0));
2345 addHistoryItem(new OrderCommand("Pairwise Sort", oldOrder, viewport.alignment));
2346 alignPanel.repaint();
2352 * @param e DOCUMENT ME!
2354 public void sortIDMenuItem_actionPerformed(ActionEvent e)
2356 SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray();
2357 AlignmentSorter.sortByID(viewport.getAlignment());
2358 addHistoryItem(new OrderCommand("ID Sort", oldOrder, viewport.alignment));
2359 alignPanel.repaint();
2365 * @param e DOCUMENT ME!
2367 public void sortGroupMenuItem_actionPerformed(ActionEvent e)
2369 SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray();
2370 AlignmentSorter.sortByGroup(viewport.getAlignment());
2371 addHistoryItem(new OrderCommand("Group Sort", oldOrder, viewport.alignment));
2373 alignPanel.repaint();
2379 * @param e DOCUMENT ME!
2381 public void removeRedundancyMenuItem_actionPerformed(ActionEvent e)
2383 new RedundancyPanel(alignPanel, this);
2390 * @param e DOCUMENT ME!
2392 public void pairwiseAlignmentMenuItem_actionPerformed(ActionEvent e)
2394 if ( (viewport.getSelectionGroup() == null) ||
2395 (viewport.getSelectionGroup().getSize(false) < 2))
2397 JOptionPane.showInternalMessageDialog(this,
2398 "You must select at least 2 sequences.",
2399 "Invalid Selection",
2400 JOptionPane.WARNING_MESSAGE);
2404 JInternalFrame frame = new JInternalFrame();
2405 frame.setContentPane(new PairwiseAlignPanel(viewport));
2406 Desktop.addInternalFrame(frame, "Pairwise Alignment", 600, 500);
2413 * @param e DOCUMENT ME!
2415 public void PCAMenuItem_actionPerformed(ActionEvent e)
2417 if ( ( (viewport.getSelectionGroup() != null) &&
2418 (viewport.getSelectionGroup().getSize(false) < 4) &&
2419 (viewport.getSelectionGroup().getSize(false) > 0)) ||
2420 (viewport.getAlignment().getHeight() < 4))
2422 JOptionPane.showInternalMessageDialog(this,
2423 "Principal component analysis must take\n" +
2424 "at least 4 input sequences.",
2425 "Sequence selection insufficient",
2426 JOptionPane.WARNING_MESSAGE);
2431 new PCAPanel(viewport);
2435 public void autoCalculate_actionPerformed(ActionEvent e)
2437 viewport.autoCalculateConsensus = autoCalculate.isSelected();
2438 if(viewport.autoCalculateConsensus)
2440 viewport.firePropertyChange("alignment",
2442 viewport.getAlignment().getSequences());
2450 * @param e DOCUMENT ME!
2452 public void averageDistanceTreeMenuItem_actionPerformed(ActionEvent e)
2454 NewTreePanel("AV", "PID", "Average distance tree using PID");
2460 * @param e DOCUMENT ME!
2462 public void neighbourTreeMenuItem_actionPerformed(ActionEvent e)
2464 NewTreePanel("NJ", "PID", "Neighbour joining tree using PID");
2470 * @param e DOCUMENT ME!
2472 protected void njTreeBlosumMenuItem_actionPerformed(ActionEvent e)
2474 NewTreePanel("NJ", "BL", "Neighbour joining tree using BLOSUM62");
2480 * @param e DOCUMENT ME!
2482 protected void avTreeBlosumMenuItem_actionPerformed(ActionEvent e)
2484 NewTreePanel("AV", "BL", "Average distance tree using BLOSUM62");
2490 * @param type DOCUMENT ME!
2491 * @param pwType DOCUMENT ME!
2492 * @param title DOCUMENT ME!
2494 void NewTreePanel(String type, String pwType, String title)
2498 if (viewport.getSelectionGroup() != null) {
2499 if (viewport.getSelectionGroup().getSize(false) < 3) {
2500 JOptionPane.showMessageDialog(Desktop.desktop,
2501 "You need to have more than two sequences selected to build a tree!",
2502 "Not enough sequences",
2503 JOptionPane.WARNING_MESSAGE);
2508 SequenceGroup sg = viewport.getSelectionGroup();
2510 /* Decide if the selection is a column region */
2511 while (s < sg.getSize(false))
2513 if ( ( (SequenceI) sg.getSequences(false).elementAt(s++)).getLength() <
2516 JOptionPane.showMessageDialog(Desktop.desktop,
2517 "The selected region to create a tree may\nonly contain residues or gaps.\n" +
2518 "Try using the Pad function in the edit menu,\n" +
2519 "or one of the multiple sequence alignment web services.",
2520 "Sequences in selection are not aligned",
2521 JOptionPane.WARNING_MESSAGE);
2527 title = title + " on region";
2528 tp = new TreePanel(alignPanel, type, pwType);
2532 //are the sequences aligned?
2533 if (!viewport.alignment.isAligned())
2535 JOptionPane.showMessageDialog(Desktop.desktop,
2536 "The sequences must be aligned before creating a tree.\n" +
2537 "Try using the Pad function in the edit menu,\n" +
2538 "or one of the multiple sequence alignment web services.",
2539 "Sequences not aligned",
2540 JOptionPane.WARNING_MESSAGE);
2545 if(viewport.alignment.getHeight()<2)
2548 tp = new TreePanel(alignPanel, type, pwType);
2551 addTreeMenuItem(tp, title);
2553 Desktop.addInternalFrame(tp, title + " from " + this.title, 600, 500);
2559 * @param title DOCUMENT ME!
2560 * @param order DOCUMENT ME!
2562 public void addSortByOrderMenuItem(String title, final AlignmentOrder order)
2564 final JMenuItem item = new JMenuItem("by " + title);
2566 item.addActionListener(new java.awt.event.ActionListener()
2568 public void actionPerformed(ActionEvent e)
2570 SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray();
2572 // TODO: JBPNote - have to map order entries to curent SequenceI pointers
2573 AlignmentSorter.sortBy(viewport.getAlignment(), order);
2575 addHistoryItem(new OrderCommand(order.getName(), oldOrder, viewport.alignment));
2577 alignPanel.repaint();
2583 * Maintain the Order by->Displayed Tree menu.
2584 * Creates a new menu item for a TreePanel with an appropriate
2585 * <code>jalview.analysis.AlignmentSorter</code> call. Listeners are added
2586 * to remove the menu item when the treePanel is closed, and adjust
2587 * the tree leaf to sequence mapping when the alignment is modified.
2588 * @param treePanel Displayed tree window.
2589 * @param title SortBy menu item title.
2591 void addTreeMenuItem(final TreePanel treePanel, String title)
2593 final JMenuItem item = new JMenuItem(title);
2599 sort.add(sortByTreeMenu);
2602 sortByTreeMenu.add(item);
2603 item.addActionListener(new java.awt.event.ActionListener()
2605 public void actionPerformed(ActionEvent e)
2607 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
2608 AlignmentSorter.sortByTree(viewport.getAlignment(),
2609 treePanel.getTree());
2611 addHistoryItem(new OrderCommand("Tree Sort",
2613 viewport.alignment));
2616 alignPanel.repaint();
2620 treePanel.addInternalFrameListener(new javax.swing.event.
2621 InternalFrameAdapter()
2623 public void internalFrameClosed(
2624 javax.swing.event.InternalFrameEvent evt)
2627 sortByTreeMenu.remove(item);
2631 sort.remove(sortByTreeMenu);
2639 * Work out whether the whole set of sequences
2640 * or just the selected set will be submitted for multiple alignment.
2643 private jalview.datamodel.AlignmentView gatherSequencesForAlignment()
2645 // Now, check we have enough sequences
2646 AlignmentView msa = null;
2648 if ( (viewport.getSelectionGroup() != null) &&
2649 (viewport.getSelectionGroup().getSize(false) > 1))
2651 // JBPNote UGLY! To prettify, make SequenceGroup and Alignment conform to some common interface!
2652 /*SequenceGroup seqs = viewport.getSelectionGroup();
2654 msa = new SequenceI[sz = seqs.getSize(false)];
2656 for (int i = 0; i < sz; i++)
2658 msa[i] = (SequenceI) seqs.getSequenceAt(i);
2660 msa = viewport.getAlignmentView(true);
2664 /*Vector seqs = viewport.getAlignment().getSequences();
2666 if (seqs.size() > 1)
2668 msa = new SequenceI[seqs.size()];
2670 for (int i = 0; i < seqs.size(); i++)
2672 msa[i] = (SequenceI) seqs.elementAt(i);
2675 msa = viewport.getAlignmentView(false);
2681 * Decides what is submitted to a secondary structure prediction service,
2682 * the currently selected sequence, or the currently selected alignment
2683 * (where the first sequence in the set is the one that the prediction
2686 AlignmentView gatherSeqOrMsaForSecStrPrediction()
2688 AlignmentView seqs = null;
2690 if ( (viewport.getSelectionGroup() != null) &&
2691 (viewport.getSelectionGroup().getSize(false) > 0))
2693 seqs = viewport.getAlignmentView(true);
2697 seqs = viewport.getAlignmentView(false);
2699 // limit sequences - JBPNote in future - could spawn multiple prediction jobs
2700 // TODO: viewport.alignment.isAligned is a global state - the local selection may well be aligned - we preserve 2.0.8 behaviour for moment.
2701 if (!viewport.alignment.isAligned())
2703 seqs.setSequences(new SeqCigar[] { seqs.getSequences()[0] } );
2710 * @param e DOCUMENT ME!
2712 protected void LoadtreeMenuItem_actionPerformed(ActionEvent e)
2714 // Pick the tree file
2715 JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
2718 chooser.setFileView(new JalviewFileView());
2719 chooser.setDialogTitle("Select a newick-like tree file");
2720 chooser.setToolTipText("Load a tree file");
2722 int value = chooser.showOpenDialog(null);
2724 if (value == JalviewFileChooser.APPROVE_OPTION)
2726 String choice = chooser.getSelectedFile().getPath();
2727 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
2731 jalview.io.NewickFile fin = new jalview.io.NewickFile(choice,
2733 viewport.setCurrentTree(ShowNewickTree(fin, choice).getTree());
2735 catch (Exception ex)
2737 JOptionPane.showMessageDialog(Desktop.desktop,
2738 "Problem reading tree file",
2740 JOptionPane.WARNING_MESSAGE);
2741 ex.printStackTrace();
2747 public TreePanel ShowNewickTree(NewickFile nf, String title)
2749 return ShowNewickTree(nf,title,600,500,4,5);
2751 public TreePanel ShowNewickTree(NewickFile nf, String title, AlignmentView input)
2753 return ShowNewickTree(nf,title, input, 600,500,4,5);
2755 public TreePanel ShowNewickTree(NewickFile nf, String title, int w,int h,int x, int y) {
2756 return ShowNewickTree(nf, title, null, w, h, x, y);
2759 * Add a treeviewer for the tree extracted from a newick file object to the current alignment view
2761 * @param nf the tree
2762 * @param title tree viewer title
2763 * @param input Associated alignment input data (or null)
2768 * @return TreePanel handle
2770 public TreePanel ShowNewickTree(NewickFile nf, String title, AlignmentView input, int w,int h,int x, int y) {
2771 TreePanel tp = null;
2777 if (nf.getTree() != null)
2779 tp = new TreePanel(alignPanel,
2787 tp.setLocation(x,y);
2790 Desktop.addInternalFrame(tp, title, w, h);
2791 addTreeMenuItem(tp, title);
2794 catch (Exception ex)
2796 ex.printStackTrace();
2807 PrinterJob printJob = PrinterJob.getPrinterJob();
2808 PageFormat pf = printJob.pageDialog(printJob.defaultPage());
2809 printJob.setPrintable(alignPanel, pf);
2811 if (printJob.printDialog())
2817 catch (Exception PrintException)
2819 PrintException.printStackTrace();
2826 * Generates menu items and listener event actions for web service clients
2829 public void BuildWebServiceMenu()
2831 if ( (Discoverer.services != null)
2832 && (Discoverer.services.size() > 0))
2834 Vector msaws = (Vector) Discoverer.services.get("MsaWS");
2835 Vector secstrpr = (Vector) Discoverer.services.get("SecStrPred");
2836 Vector wsmenu = new Vector();
2837 final AlignFrame af = this;
2840 // Add any Multiple Sequence Alignment Services
2841 final JMenu msawsmenu = new JMenu("Alignment");
2842 for (int i = 0, j = msaws.size(); i < j; i++)
2844 final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) msaws.
2846 final JMenuItem method = new JMenuItem(sh.getName());
2847 method.addActionListener(new ActionListener()
2849 public void actionPerformed(ActionEvent e)
2851 AlignmentView msa = gatherSequencesForAlignment();
2852 new jalview.ws.MsaWSClient(sh, title, msa,
2853 false, true, viewport.getAlignment().getDataset(), af);
2858 msawsmenu.add(method);
2859 // Deal with services that we know accept partial alignments.
2860 if (sh.getName().indexOf("lustal") > -1)
2862 // We know that ClustalWS can accept partial alignments for refinement.
2863 final JMenuItem methodR = new JMenuItem(sh.getName()+" Realign");
2864 methodR.addActionListener(new ActionListener()
2866 public void actionPerformed(ActionEvent e)
2868 AlignmentView msa = gatherSequencesForAlignment();
2869 new jalview.ws.MsaWSClient(sh, title, msa,
2870 true, true, viewport.getAlignment().getDataset(), af);
2875 msawsmenu.add(methodR);
2879 wsmenu.add(msawsmenu);
2881 if (secstrpr != null)
2883 // Add any secondary structure prediction services
2884 final JMenu secstrmenu = new JMenu("Secondary Structure Prediction");
2885 for (int i = 0, j = secstrpr.size(); i < j; i++)
2887 final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle)
2889 final JMenuItem method = new JMenuItem(sh.getName());
2890 method.addActionListener(new ActionListener()
2892 public void actionPerformed(ActionEvent e)
2894 AlignmentView msa = gatherSeqOrMsaForSecStrPrediction();
2895 if (msa.getSequences().length == 1)
2897 // Single Sequence prediction
2898 new jalview.ws.JPredClient(sh, title, false, msa, af, true);
2902 if (msa.getSequences().length > 1)
2904 // Sequence profile based prediction
2905 new jalview.ws.JPredClient(sh,
2906 title, true, msa, af, true);
2911 secstrmenu.add(method);
2913 wsmenu.add(secstrmenu);
2915 this.webService.removeAll();
2916 for (int i = 0, j = wsmenu.size(); i < j; i++)
2918 webService.add( (JMenu) wsmenu.get(i));
2923 this.webService.removeAll();
2924 this.webService.add(this.webServiceNoServices);
2926 // TODO: add in rediscovery function
2927 // TODO: reduce code redundancy.
2928 // TODO: group services by location as well as function.
2931 /* public void vamsasStore_actionPerformed(ActionEvent e)
2933 JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
2934 getProperty("LAST_DIRECTORY"));
2936 chooser.setFileView(new JalviewFileView());
2937 chooser.setDialogTitle("Export to Vamsas file");
2938 chooser.setToolTipText("Export");
2940 int value = chooser.showSaveDialog(this);
2942 if (value == JalviewFileChooser.APPROVE_OPTION)
2944 jalview.io.VamsasDatastore vs = new jalview.io.VamsasDatastore(viewport);
2945 //vs.store(chooser.getSelectedFile().getAbsolutePath() );
2946 vs.storeJalview( chooser.getSelectedFile().getAbsolutePath(), this);
2953 public void showTranslation_actionPerformed(ActionEvent e)
2955 SequenceI [] selection = viewport.getSelectionAsNewSequence();
2956 String [] seqstring = viewport.getViewAsString(true);
2958 int s, sSize = selection.length;
2959 SequenceI [] newSeq = new SequenceI[sSize];
2962 StringBuffer protein;
2964 for(s=0; s<sSize; s++)
2966 protein = new StringBuffer();
2967 seq = AlignSeq.extractGaps("-. ", seqstring[s]);
2968 resSize = seq.length();
2969 resSize -= resSize%3;
2971 for(res = 0; res < resSize; res+=3)
2973 String codon = seq.substring(res, res+3);
2974 codon = codon.replace('U', 'T');
2975 String aa = ResidueProperties.codonTranslate(codon);
2977 protein.append(viewport.getGapCharacter());
2978 else if(aa.equals("STOP"))
2979 protein.append("X");
2981 protein.append( aa );
2983 newSeq[s] = new Sequence(selection[s].getName(),
2984 protein.toString());
2988 AlignmentI al = new Alignment(newSeq);
2989 al.setDataset(null);
2992 ////////////////////////////////
2993 // Copy annotations across
2994 jalview.datamodel.AlignmentAnnotation[] annotations
2995 = viewport.alignment.getAlignmentAnnotation();
2997 if(annotations!=null)
2999 for (int i = 0; i < annotations.length; i++)
3001 if (annotations[i].label.equals("Quality") ||
3002 annotations[i].label.equals("Conservation") ||
3003 annotations[i].label.equals("Consensus"))
3008 aSize = viewport.alignment.getWidth() / 3;
3009 jalview.datamodel.Annotation[] anots =
3010 new jalview.datamodel.Annotation[aSize];
3012 for (a = 0; a < viewport.alignment.getWidth(); a++)
3014 if (annotations[i].annotations[a] == null
3015 || annotations[i].annotations[a] == null)
3018 anots[a / 3] = new Annotation(
3019 annotations[i].annotations[a].displayCharacter,
3020 annotations[i].annotations[a].description,
3021 annotations[i].annotations[a].secondaryStructure,
3022 annotations[i].annotations[a].value,
3023 annotations[i].annotations[a].colour);
3026 jalview.datamodel.AlignmentAnnotation aa
3027 = new jalview.datamodel.AlignmentAnnotation(annotations[i].label,
3028 annotations[i].description, anots);
3029 al.addAnnotation(aa);
3033 AlignFrame af = new AlignFrame(al, DEFAULT_WIDTH, DEFAULT_HEIGHT);
3034 Desktop.addInternalFrame(af, "Translation of "+this.getTitle(),
3046 * @param String DOCUMENT ME!
3048 public boolean parseFeaturesFile(String file, String type)
3050 boolean featuresFile = false;
3052 featuresFile = new FeaturesFile(file, type).parse(viewport.alignment.getDataset(),
3053 alignPanel.seqPanel.seqCanvas.
3054 getFeatureRenderer().featureColours,
3059 ex.printStackTrace();
3064 viewport.showSequenceFeatures = true;
3065 showSeqFeatures.setSelected(true);
3066 alignPanel.repaint();
3069 return featuresFile;
3072 public void dragEnter(DropTargetDragEvent evt)
3075 public void dragExit(DropTargetEvent evt)
3078 public void dragOver(DropTargetDragEvent evt)
3081 public void dropActionChanged(DropTargetDragEvent evt)
3084 public void drop(DropTargetDropEvent evt)
3086 Transferable t = evt.getTransferable();
3087 java.util.List files = null;
3091 DataFlavor uriListFlavor = new DataFlavor("text/uri-list;class=java.lang.String");
3092 if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor))
3094 //Works on Windows and MacOSX
3095 evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
3096 files = (java.util.List) t.getTransferData(DataFlavor.javaFileListFlavor);
3098 else if (t.isDataFlavorSupported(uriListFlavor))
3100 // This is used by Unix drag system
3101 evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
3102 String data = (String) t.getTransferData(uriListFlavor);
3103 files = new java.util.ArrayList(1);
3104 for (java.util.StringTokenizer st = new java.util.StringTokenizer(
3107 st.hasMoreTokens(); )
3109 String s = st.nextToken();
3110 if (s.startsWith("#"))
3112 // the line is a comment (as per the RFC 2483)
3116 java.net.URI uri = new java.net.URI(s);
3117 java.io.File file = new java.io.File(uri);
3124 e.printStackTrace();
3131 for (int i = 0; i < files.size(); i++)
3133 loadJalviewDataFile(files.get(i).toString());
3136 catch (Exception ex)
3138 ex.printStackTrace();
3143 // This method will attempt to load a "dropped" file first by testing
3144 // whether its and Annotation file, then features file. If both are
3145 // false then the user may have dropped an alignment file onto this
3147 public void loadJalviewDataFile(String file)
3150 String protocol = "File";
3152 if (file.indexOf("http:") > -1 || file.indexOf("file:") > -1)
3157 boolean isAnnotation = new AnnotationFile().readAnnotationFile(viewport.
3162 boolean isGroupsFile = parseFeaturesFile(file,protocol);
3165 String format = new IdentifyFile().Identify(file, protocol);
3167 if(format.equalsIgnoreCase("JnetFile"))
3169 jalview.io.JPredFile predictions = new jalview.io.JPredFile(
3171 new JnetAnnotationMaker().add_annotation(predictions,
3172 viewport.getAlignment(),
3174 alignPanel.adjustAnnotationHeight();
3175 alignPanel.repaint();
3178 new FileLoader().LoadFile(viewport, file, protocol, format);
3184 alignPanel.adjustAnnotationHeight();
3187 }catch(Exception ex)
3189 ex.printStackTrace();
3193 public void tabSelectionChanged(int index)
3197 alignPanel = (AlignmentPanel) alignPanels.elementAt(index);
3198 viewport = alignPanel.av;
3199 setMenusFromViewport(viewport);
3203 public void tabbedPane_mousePressed(MouseEvent e)
3205 if(SwingUtilities.isRightMouseButton(e))
3207 String reply = JOptionPane.showInternalInputDialog(this,
3210 JOptionPane.QUESTION_MESSAGE);
3214 viewport.viewName = reply;
3215 tabbedPane.setTitleAt( tabbedPane.getSelectedIndex() ,reply);
3221 public AlignViewport getCurrentView()