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 viewport.gatherViewsHere = true;
1700 tabbedPane.setSelectedIndex(tabbedPane.getTabCount() - 1);
1707 * @param e DOCUMENT ME!
1709 public void font_actionPerformed(ActionEvent e)
1711 new FontChooser(alignPanel);
1718 * @param e DOCUMENT ME!
1720 protected void seqLimit_actionPerformed(ActionEvent e)
1722 viewport.setShowJVSuffix(seqLimits.isSelected());
1724 alignPanel.idPanel.idCanvas.setPreferredSize(alignPanel.calculateIdWidth());
1725 alignPanel.repaint();
1732 * @param e DOCUMENT ME!
1734 protected void colourTextMenuItem_actionPerformed(ActionEvent e)
1736 viewport.setColourText(colourTextMenuItem.isSelected());
1737 alignPanel.repaint();
1743 * @param e DOCUMENT ME!
1745 public void wrapMenuItem_actionPerformed(ActionEvent e)
1747 scaleAbove.setVisible(wrapMenuItem.isSelected());
1748 scaleLeft.setVisible(wrapMenuItem.isSelected());
1749 scaleRight.setVisible(wrapMenuItem.isSelected());
1750 viewport.setWrapAlignment(wrapMenuItem.isSelected());
1751 alignPanel.setWrapAlignment(wrapMenuItem.isSelected());
1754 public void showAllSeqs_actionPerformed(ActionEvent e)
1756 viewport.showAllHiddenSeqs();
1759 public void showAllColumns_actionPerformed(ActionEvent e)
1761 viewport.showAllHiddenColumns();
1765 public void hideSelSequences_actionPerformed(ActionEvent e)
1767 viewport.hideAllSelectedSeqs();
1768 alignPanel.repaint();
1771 public void hideSelColumns_actionPerformed(ActionEvent e)
1773 viewport.hideSelectedColumns();
1774 alignPanel.repaint();
1777 public void hiddenMarkers_actionPerformed(ActionEvent e)
1779 viewport.setShowHiddenMarkers(hiddenMarkers.isSelected());
1786 * @param e DOCUMENT ME!
1788 protected void scaleAbove_actionPerformed(ActionEvent e)
1790 viewport.setScaleAboveWrapped(scaleAbove.isSelected());
1791 alignPanel.repaint();
1797 * @param e DOCUMENT ME!
1799 protected void scaleLeft_actionPerformed(ActionEvent e)
1801 viewport.setScaleLeftWrapped(scaleLeft.isSelected());
1802 alignPanel.repaint();
1808 * @param e DOCUMENT ME!
1810 protected void scaleRight_actionPerformed(ActionEvent e)
1812 viewport.setScaleRightWrapped(scaleRight.isSelected());
1813 alignPanel.repaint();
1819 * @param e DOCUMENT ME!
1821 public void viewBoxesMenuItem_actionPerformed(ActionEvent e)
1823 viewport.setShowBoxes(viewBoxesMenuItem.isSelected());
1824 alignPanel.repaint();
1830 * @param e DOCUMENT ME!
1832 public void viewTextMenuItem_actionPerformed(ActionEvent e)
1834 viewport.setShowText(viewTextMenuItem.isSelected());
1835 alignPanel.repaint();
1841 * @param e DOCUMENT ME!
1843 protected void renderGapsMenuItem_actionPerformed(ActionEvent e)
1845 viewport.setRenderGaps(renderGapsMenuItem.isSelected());
1846 alignPanel.repaint();
1850 public FeatureSettings featureSettings;
1851 public void featureSettings_actionPerformed(ActionEvent e)
1853 if(featureSettings !=null )
1855 featureSettings.close();
1856 featureSettings = null;
1858 featureSettings = new FeatureSettings(this);
1864 * @param evt DOCUMENT ME!
1866 public void showSeqFeatures_actionPerformed(ActionEvent evt)
1868 viewport.setShowSequenceFeatures(showSeqFeatures.isSelected());
1869 alignPanel.repaint();
1870 if (alignPanel.getOverviewPanel() != null)
1872 alignPanel.getOverviewPanel().updateOverviewImage();
1879 * @param e DOCUMENT ME!
1881 public void annotationPanelMenuItem_actionPerformed(ActionEvent e)
1883 viewport.setShowAnnotation(annotationPanelMenuItem.isSelected());
1884 alignPanel.setAnnotationVisible(annotationPanelMenuItem.isSelected());
1890 * @param e DOCUMENT ME!
1892 public void overviewMenuItem_actionPerformed(ActionEvent e)
1894 if (alignPanel.overviewPanel != null)
1899 JInternalFrame frame = new JInternalFrame();
1900 OverviewPanel overview = new OverviewPanel(alignPanel);
1901 frame.setContentPane(overview);
1902 Desktop.addInternalFrame(frame, "Overview " + this.getTitle(),
1903 frame.getWidth(), frame.getHeight());
1905 frame.setLayer(JLayeredPane.PALETTE_LAYER);
1906 frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
1908 public void internalFrameClosed(
1909 javax.swing.event.InternalFrameEvent evt)
1911 alignPanel.setOverviewPanel(null);
1916 alignPanel.setOverviewPanel(overview);
1922 * @param e DOCUMENT ME!
1924 protected void noColourmenuItem_actionPerformed(ActionEvent e)
1932 * @param e DOCUMENT ME!
1934 public void clustalColour_actionPerformed(ActionEvent e)
1936 changeColour(new ClustalxColourScheme(
1937 viewport.alignment.getSequences(), viewport.alignment.getWidth()));
1943 * @param e DOCUMENT ME!
1945 public void zappoColour_actionPerformed(ActionEvent e)
1947 changeColour(new ZappoColourScheme());
1953 * @param e DOCUMENT ME!
1955 public void taylorColour_actionPerformed(ActionEvent e)
1957 changeColour(new TaylorColourScheme());
1963 * @param e DOCUMENT ME!
1965 public void hydrophobicityColour_actionPerformed(ActionEvent e)
1967 changeColour(new HydrophobicColourScheme());
1973 * @param e DOCUMENT ME!
1975 public void helixColour_actionPerformed(ActionEvent e)
1977 changeColour(new HelixColourScheme());
1983 * @param e DOCUMENT ME!
1985 public void strandColour_actionPerformed(ActionEvent e)
1987 changeColour(new StrandColourScheme());
1993 * @param e DOCUMENT ME!
1995 public void turnColour_actionPerformed(ActionEvent e)
1997 changeColour(new TurnColourScheme());
2003 * @param e DOCUMENT ME!
2005 public void buriedColour_actionPerformed(ActionEvent e)
2007 changeColour(new BuriedColourScheme());
2013 * @param e DOCUMENT ME!
2015 public void nucleotideColour_actionPerformed(ActionEvent e)
2017 changeColour(new NucleotideColourScheme());
2020 public void annotationColour_actionPerformed(ActionEvent e)
2022 new AnnotationColourChooser(viewport, alignPanel);
2029 * @param e DOCUMENT ME!
2031 protected void applyToAllGroups_actionPerformed(ActionEvent e)
2033 viewport.setColourAppliesToAllGroups(applyToAllGroups.isSelected());
2039 * @param cs DOCUMENT ME!
2041 public void changeColour(ColourSchemeI cs)
2047 if (viewport.getAbovePIDThreshold())
2049 threshold = SliderPanel.setPIDSliderSource(alignPanel, cs,
2052 cs.setThreshold(threshold,
2053 viewport.getIgnoreGapsConsensus());
2055 viewport.setGlobalColourScheme(cs);
2059 cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
2062 if (viewport.getConservationSelected())
2065 Alignment al = (Alignment) viewport.alignment;
2066 Conservation c = new Conservation("All",
2067 ResidueProperties.propHash, 3,
2068 al.getSequences(), 0,
2072 c.verdict(false, viewport.ConsPercGaps);
2074 cs.setConservation(c);
2076 cs.setConservationInc(SliderPanel.setConservationSlider(alignPanel, cs,
2081 cs.setConservation(null);
2084 cs.setConsensus(viewport.hconsensus);
2087 viewport.setGlobalColourScheme(cs);
2089 if (viewport.getColourAppliesToAllGroups())
2091 Vector groups = viewport.alignment.getGroups();
2093 for (int i = 0; i < groups.size(); i++)
2095 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
2103 if (cs instanceof ClustalxColourScheme)
2105 sg.cs = new ClustalxColourScheme(
2106 sg.getSequences(true), sg.getWidth());
2108 else if (cs instanceof UserColourScheme)
2110 sg.cs = new UserColourScheme( ( (UserColourScheme) cs).getColours());
2116 sg.cs = (ColourSchemeI) cs.getClass().newInstance();
2118 catch (Exception ex)
2123 if (viewport.getAbovePIDThreshold()
2124 || cs instanceof PIDColourScheme
2125 || cs instanceof Blosum62ColourScheme)
2127 sg.cs.setThreshold(threshold,
2128 viewport.getIgnoreGapsConsensus());
2130 sg.cs.setConsensus(AAFrequency.calculate(
2131 sg.getSequences(true), sg.getStartRes(),
2135 sg.cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
2138 if (viewport.getConservationSelected())
2140 Conservation c = new Conservation("Group",
2141 ResidueProperties.propHash, 3,
2142 sg.getSequences(true),
2146 c.verdict(false, viewport.ConsPercGaps);
2147 sg.cs.setConservation(c);
2150 sg.cs.setConservation(null);
2154 if (alignPanel.getOverviewPanel() != null)
2156 alignPanel.getOverviewPanel().updateOverviewImage();
2159 alignPanel.repaint();
2165 * @param e DOCUMENT ME!
2167 protected void modifyPID_actionPerformed(ActionEvent e)
2169 if (viewport.getAbovePIDThreshold() && viewport.globalColourScheme!=null)
2171 SliderPanel.setPIDSliderSource(alignPanel,
2172 viewport.getGlobalColourScheme(),
2174 SliderPanel.showPIDSlider();
2181 * @param e DOCUMENT ME!
2183 protected void modifyConservation_actionPerformed(ActionEvent e)
2185 if (viewport.getConservationSelected() && viewport.globalColourScheme!=null)
2187 SliderPanel.setConservationSlider(alignPanel,
2188 viewport.globalColourScheme,
2190 SliderPanel.showConservationSlider();
2197 * @param e DOCUMENT ME!
2199 protected void conservationMenuItem_actionPerformed(ActionEvent e)
2201 viewport.setConservationSelected(conservationMenuItem.isSelected());
2203 viewport.setAbovePIDThreshold(false);
2204 abovePIDThreshold.setSelected(false);
2206 changeColour(viewport.getGlobalColourScheme());
2208 modifyConservation_actionPerformed(null);
2214 * @param e DOCUMENT ME!
2216 public void abovePIDThreshold_actionPerformed(ActionEvent e)
2218 viewport.setAbovePIDThreshold(abovePIDThreshold.isSelected());
2220 conservationMenuItem.setSelected(false);
2221 viewport.setConservationSelected(false);
2223 changeColour(viewport.getGlobalColourScheme());
2225 modifyPID_actionPerformed(null);
2231 * @param e DOCUMENT ME!
2233 public void userDefinedColour_actionPerformed(ActionEvent e)
2235 if (e.getActionCommand().equals("User Defined..."))
2237 new UserDefinedColours(alignPanel, null);
2241 UserColourScheme udc = (UserColourScheme) UserDefinedColours.
2242 getUserColourSchemes().get(e.getActionCommand());
2248 public void updateUserColourMenu()
2251 Component[] menuItems = colourMenu.getMenuComponents();
2252 int i, iSize = menuItems.length;
2253 for (i = 0; i < iSize; i++)
2255 if (menuItems[i].getName() != null &&
2256 menuItems[i].getName().equals("USER_DEFINED"))
2258 colourMenu.remove(menuItems[i]);
2262 if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null)
2264 java.util.Enumeration userColours = jalview.gui.UserDefinedColours.
2265 getUserColourSchemes().keys();
2267 while (userColours.hasMoreElements())
2269 final JRadioButtonMenuItem radioItem = new JRadioButtonMenuItem(userColours.
2270 nextElement().toString());
2271 radioItem.setName("USER_DEFINED");
2272 radioItem.addMouseListener(new MouseAdapter()
2274 public void mousePressed(MouseEvent evt)
2276 if(evt.isControlDown() || SwingUtilities.isRightMouseButton(evt))
2278 radioItem.removeActionListener(radioItem.getActionListeners()[0]);
2280 int option = JOptionPane.showInternalConfirmDialog(jalview.gui.Desktop.desktop,
2281 "Remove from default list?",
2282 "Remove user defined colour",
2283 JOptionPane.YES_NO_OPTION);
2284 if(option == JOptionPane.YES_OPTION)
2286 jalview.gui.UserDefinedColours.removeColourFromDefaults(radioItem.getText());
2287 colourMenu.remove(radioItem);
2290 radioItem.addActionListener(new ActionListener()
2292 public void actionPerformed(ActionEvent evt)
2294 userDefinedColour_actionPerformed(evt);
2300 radioItem.addActionListener(new ActionListener()
2302 public void actionPerformed(ActionEvent evt)
2304 userDefinedColour_actionPerformed(evt);
2308 colourMenu.insert(radioItem, 15);
2309 colours.add(radioItem);
2317 * @param e DOCUMENT ME!
2319 public void PIDColour_actionPerformed(ActionEvent e)
2321 changeColour(new PIDColourScheme());
2327 * @param e DOCUMENT ME!
2329 public void BLOSUM62Colour_actionPerformed(ActionEvent e)
2331 changeColour(new Blosum62ColourScheme());
2337 * @param e DOCUMENT ME!
2339 public void sortPairwiseMenuItem_actionPerformed(ActionEvent e)
2341 SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray();
2342 AlignmentSorter.sortByPID(viewport.getAlignment(),
2343 viewport.getAlignment().getSequenceAt(0));
2344 addHistoryItem(new OrderCommand("Pairwise Sort", oldOrder, viewport.alignment));
2345 alignPanel.repaint();
2351 * @param e DOCUMENT ME!
2353 public void sortIDMenuItem_actionPerformed(ActionEvent e)
2355 SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray();
2356 AlignmentSorter.sortByID(viewport.getAlignment());
2357 addHistoryItem(new OrderCommand("ID Sort", oldOrder, viewport.alignment));
2358 alignPanel.repaint();
2364 * @param e DOCUMENT ME!
2366 public void sortGroupMenuItem_actionPerformed(ActionEvent e)
2368 SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray();
2369 AlignmentSorter.sortByGroup(viewport.getAlignment());
2370 addHistoryItem(new OrderCommand("Group Sort", oldOrder, viewport.alignment));
2372 alignPanel.repaint();
2378 * @param e DOCUMENT ME!
2380 public void removeRedundancyMenuItem_actionPerformed(ActionEvent e)
2382 new RedundancyPanel(alignPanel, this);
2389 * @param e DOCUMENT ME!
2391 public void pairwiseAlignmentMenuItem_actionPerformed(ActionEvent e)
2393 if ( (viewport.getSelectionGroup() == null) ||
2394 (viewport.getSelectionGroup().getSize(false) < 2))
2396 JOptionPane.showInternalMessageDialog(this,
2397 "You must select at least 2 sequences.",
2398 "Invalid Selection",
2399 JOptionPane.WARNING_MESSAGE);
2403 JInternalFrame frame = new JInternalFrame();
2404 frame.setContentPane(new PairwiseAlignPanel(viewport));
2405 Desktop.addInternalFrame(frame, "Pairwise Alignment", 600, 500);
2412 * @param e DOCUMENT ME!
2414 public void PCAMenuItem_actionPerformed(ActionEvent e)
2416 if ( ( (viewport.getSelectionGroup() != null) &&
2417 (viewport.getSelectionGroup().getSize(false) < 4) &&
2418 (viewport.getSelectionGroup().getSize(false) > 0)) ||
2419 (viewport.getAlignment().getHeight() < 4))
2421 JOptionPane.showInternalMessageDialog(this,
2422 "Principal component analysis must take\n" +
2423 "at least 4 input sequences.",
2424 "Sequence selection insufficient",
2425 JOptionPane.WARNING_MESSAGE);
2430 new PCAPanel(viewport);
2434 public void autoCalculate_actionPerformed(ActionEvent e)
2436 viewport.autoCalculateConsensus = autoCalculate.isSelected();
2437 if(viewport.autoCalculateConsensus)
2439 viewport.firePropertyChange("alignment",
2441 viewport.getAlignment().getSequences());
2449 * @param e DOCUMENT ME!
2451 public void averageDistanceTreeMenuItem_actionPerformed(ActionEvent e)
2453 NewTreePanel("AV", "PID", "Average distance tree using PID");
2459 * @param e DOCUMENT ME!
2461 public void neighbourTreeMenuItem_actionPerformed(ActionEvent e)
2463 NewTreePanel("NJ", "PID", "Neighbour joining tree using PID");
2469 * @param e DOCUMENT ME!
2471 protected void njTreeBlosumMenuItem_actionPerformed(ActionEvent e)
2473 NewTreePanel("NJ", "BL", "Neighbour joining tree using BLOSUM62");
2479 * @param e DOCUMENT ME!
2481 protected void avTreeBlosumMenuItem_actionPerformed(ActionEvent e)
2483 NewTreePanel("AV", "BL", "Average distance tree using BLOSUM62");
2489 * @param type DOCUMENT ME!
2490 * @param pwType DOCUMENT ME!
2491 * @param title DOCUMENT ME!
2493 void NewTreePanel(String type, String pwType, String title)
2497 if (viewport.getSelectionGroup() != null) {
2498 if (viewport.getSelectionGroup().getSize(false) < 3) {
2499 JOptionPane.showMessageDialog(Desktop.desktop,
2500 "You need to have more than two sequences selected to build a tree!",
2501 "Not enough sequences",
2502 JOptionPane.WARNING_MESSAGE);
2507 SequenceGroup sg = viewport.getSelectionGroup();
2509 /* Decide if the selection is a column region */
2510 while (s < sg.getSize(false))
2512 if ( ( (SequenceI) sg.getSequences(false).elementAt(s++)).getLength() <
2515 JOptionPane.showMessageDialog(Desktop.desktop,
2516 "The selected region to create a tree may\nonly contain residues or gaps.\n" +
2517 "Try using the Pad function in the edit menu,\n" +
2518 "or one of the multiple sequence alignment web services.",
2519 "Sequences in selection are not aligned",
2520 JOptionPane.WARNING_MESSAGE);
2526 title = title + " on region";
2527 tp = new TreePanel(alignPanel, type, pwType);
2531 //are the sequences aligned?
2532 if (!viewport.alignment.isAligned())
2534 JOptionPane.showMessageDialog(Desktop.desktop,
2535 "The sequences must be aligned before creating a tree.\n" +
2536 "Try using the Pad function in the edit menu,\n" +
2537 "or one of the multiple sequence alignment web services.",
2538 "Sequences not aligned",
2539 JOptionPane.WARNING_MESSAGE);
2544 if(viewport.alignment.getHeight()<2)
2547 tp = new TreePanel(alignPanel, type, pwType);
2550 addTreeMenuItem(tp, title);
2552 Desktop.addInternalFrame(tp, title + " from " + this.title, 600, 500);
2558 * @param title DOCUMENT ME!
2559 * @param order DOCUMENT ME!
2561 public void addSortByOrderMenuItem(String title, final AlignmentOrder order)
2563 final JMenuItem item = new JMenuItem("by " + title);
2565 item.addActionListener(new java.awt.event.ActionListener()
2567 public void actionPerformed(ActionEvent e)
2569 SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray();
2571 // TODO: JBPNote - have to map order entries to curent SequenceI pointers
2572 AlignmentSorter.sortBy(viewport.getAlignment(), order);
2574 addHistoryItem(new OrderCommand(order.getName(), oldOrder, viewport.alignment));
2576 alignPanel.repaint();
2582 * Maintain the Order by->Displayed Tree menu.
2583 * Creates a new menu item for a TreePanel with an appropriate
2584 * <code>jalview.analysis.AlignmentSorter</code> call. Listeners are added
2585 * to remove the menu item when the treePanel is closed, and adjust
2586 * the tree leaf to sequence mapping when the alignment is modified.
2587 * @param treePanel Displayed tree window.
2588 * @param title SortBy menu item title.
2590 void addTreeMenuItem(final TreePanel treePanel, String title)
2592 final JMenuItem item = new JMenuItem(title);
2598 sort.add(sortByTreeMenu);
2601 sortByTreeMenu.add(item);
2602 item.addActionListener(new java.awt.event.ActionListener()
2604 public void actionPerformed(ActionEvent e)
2606 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
2607 AlignmentSorter.sortByTree(viewport.getAlignment(),
2608 treePanel.getTree());
2610 addHistoryItem(new OrderCommand("Tree Sort",
2612 viewport.alignment));
2615 alignPanel.repaint();
2619 treePanel.addInternalFrameListener(new javax.swing.event.
2620 InternalFrameAdapter()
2622 public void internalFrameClosed(
2623 javax.swing.event.InternalFrameEvent evt)
2626 sortByTreeMenu.remove(item);
2630 sort.remove(sortByTreeMenu);
2638 * Work out whether the whole set of sequences
2639 * or just the selected set will be submitted for multiple alignment.
2642 private jalview.datamodel.AlignmentView gatherSequencesForAlignment()
2644 // Now, check we have enough sequences
2645 AlignmentView msa = null;
2647 if ( (viewport.getSelectionGroup() != null) &&
2648 (viewport.getSelectionGroup().getSize(false) > 1))
2650 // JBPNote UGLY! To prettify, make SequenceGroup and Alignment conform to some common interface!
2651 /*SequenceGroup seqs = viewport.getSelectionGroup();
2653 msa = new SequenceI[sz = seqs.getSize(false)];
2655 for (int i = 0; i < sz; i++)
2657 msa[i] = (SequenceI) seqs.getSequenceAt(i);
2659 msa = viewport.getAlignmentView(true);
2663 /*Vector seqs = viewport.getAlignment().getSequences();
2665 if (seqs.size() > 1)
2667 msa = new SequenceI[seqs.size()];
2669 for (int i = 0; i < seqs.size(); i++)
2671 msa[i] = (SequenceI) seqs.elementAt(i);
2674 msa = viewport.getAlignmentView(false);
2680 * Decides what is submitted to a secondary structure prediction service,
2681 * the currently selected sequence, or the currently selected alignment
2682 * (where the first sequence in the set is the one that the prediction
2685 AlignmentView gatherSeqOrMsaForSecStrPrediction()
2687 AlignmentView seqs = null;
2689 if ( (viewport.getSelectionGroup() != null) &&
2690 (viewport.getSelectionGroup().getSize(false) > 0))
2692 seqs = viewport.getAlignmentView(true);
2696 seqs = viewport.getAlignmentView(false);
2698 // limit sequences - JBPNote in future - could spawn multiple prediction jobs
2699 // TODO: viewport.alignment.isAligned is a global state - the local selection may well be aligned - we preserve 2.0.8 behaviour for moment.
2700 if (!viewport.alignment.isAligned())
2702 seqs.setSequences(new SeqCigar[] { seqs.getSequences()[0] } );
2709 * @param e DOCUMENT ME!
2711 protected void LoadtreeMenuItem_actionPerformed(ActionEvent e)
2713 // Pick the tree file
2714 JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
2717 chooser.setFileView(new JalviewFileView());
2718 chooser.setDialogTitle("Select a newick-like tree file");
2719 chooser.setToolTipText("Load a tree file");
2721 int value = chooser.showOpenDialog(null);
2723 if (value == JalviewFileChooser.APPROVE_OPTION)
2725 String choice = chooser.getSelectedFile().getPath();
2726 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
2730 jalview.io.NewickFile fin = new jalview.io.NewickFile(choice,
2732 viewport.setCurrentTree(ShowNewickTree(fin, choice).getTree());
2734 catch (Exception ex)
2736 JOptionPane.showMessageDialog(Desktop.desktop,
2737 "Problem reading tree file",
2739 JOptionPane.WARNING_MESSAGE);
2740 ex.printStackTrace();
2746 public TreePanel ShowNewickTree(NewickFile nf, String title)
2748 return ShowNewickTree(nf,title,600,500,4,5);
2750 public TreePanel ShowNewickTree(NewickFile nf, String title, AlignmentView input)
2752 return ShowNewickTree(nf,title, input, 600,500,4,5);
2754 public TreePanel ShowNewickTree(NewickFile nf, String title, int w,int h,int x, int y) {
2755 return ShowNewickTree(nf, title, null, w, h, x, y);
2758 * Add a treeviewer for the tree extracted from a newick file object to the current alignment view
2760 * @param nf the tree
2761 * @param title tree viewer title
2762 * @param input Associated alignment input data (or null)
2767 * @return TreePanel handle
2769 public TreePanel ShowNewickTree(NewickFile nf, String title, AlignmentView input, int w,int h,int x, int y) {
2770 TreePanel tp = null;
2776 if (nf.getTree() != null)
2778 tp = new TreePanel(alignPanel,
2786 tp.setLocation(x,y);
2789 Desktop.addInternalFrame(tp, title, w, h);
2790 addTreeMenuItem(tp, title);
2793 catch (Exception ex)
2795 ex.printStackTrace();
2806 PrinterJob printJob = PrinterJob.getPrinterJob();
2807 PageFormat pf = printJob.pageDialog(printJob.defaultPage());
2808 printJob.setPrintable(alignPanel, pf);
2810 if (printJob.printDialog())
2816 catch (Exception PrintException)
2818 PrintException.printStackTrace();
2825 * Generates menu items and listener event actions for web service clients
2828 public void BuildWebServiceMenu()
2830 if ( (Discoverer.services != null)
2831 && (Discoverer.services.size() > 0))
2833 Vector msaws = (Vector) Discoverer.services.get("MsaWS");
2834 Vector secstrpr = (Vector) Discoverer.services.get("SecStrPred");
2835 Vector wsmenu = new Vector();
2836 final AlignFrame af = this;
2839 // Add any Multiple Sequence Alignment Services
2840 final JMenu msawsmenu = new JMenu("Alignment");
2841 for (int i = 0, j = msaws.size(); i < j; i++)
2843 final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) msaws.
2845 final JMenuItem method = new JMenuItem(sh.getName());
2846 method.addActionListener(new ActionListener()
2848 public void actionPerformed(ActionEvent e)
2850 AlignmentView msa = gatherSequencesForAlignment();
2851 new jalview.ws.MsaWSClient(sh, title, msa,
2852 false, true, viewport.getAlignment().getDataset(), af);
2857 msawsmenu.add(method);
2858 // Deal with services that we know accept partial alignments.
2859 if (sh.getName().indexOf("lustal") > -1)
2861 // We know that ClustalWS can accept partial alignments for refinement.
2862 final JMenuItem methodR = new JMenuItem(sh.getName()+" Realign");
2863 methodR.addActionListener(new ActionListener()
2865 public void actionPerformed(ActionEvent e)
2867 AlignmentView msa = gatherSequencesForAlignment();
2868 new jalview.ws.MsaWSClient(sh, title, msa,
2869 true, true, viewport.getAlignment().getDataset(), af);
2874 msawsmenu.add(methodR);
2878 wsmenu.add(msawsmenu);
2880 if (secstrpr != null)
2882 // Add any secondary structure prediction services
2883 final JMenu secstrmenu = new JMenu("Secondary Structure Prediction");
2884 for (int i = 0, j = secstrpr.size(); i < j; i++)
2886 final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle)
2888 final JMenuItem method = new JMenuItem(sh.getName());
2889 method.addActionListener(new ActionListener()
2891 public void actionPerformed(ActionEvent e)
2893 AlignmentView msa = gatherSeqOrMsaForSecStrPrediction();
2894 if (msa.getSequences().length == 1)
2896 // Single Sequence prediction
2897 new jalview.ws.JPredClient(sh, title, false, msa, af, true);
2901 if (msa.getSequences().length > 1)
2903 // Sequence profile based prediction
2904 new jalview.ws.JPredClient(sh,
2905 title, true, msa, af, true);
2910 secstrmenu.add(method);
2912 wsmenu.add(secstrmenu);
2914 this.webService.removeAll();
2915 for (int i = 0, j = wsmenu.size(); i < j; i++)
2917 webService.add( (JMenu) wsmenu.get(i));
2922 this.webService.removeAll();
2923 this.webService.add(this.webServiceNoServices);
2925 // TODO: add in rediscovery function
2926 // TODO: reduce code redundancy.
2927 // TODO: group services by location as well as function.
2930 /* public void vamsasStore_actionPerformed(ActionEvent e)
2932 JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
2933 getProperty("LAST_DIRECTORY"));
2935 chooser.setFileView(new JalviewFileView());
2936 chooser.setDialogTitle("Export to Vamsas file");
2937 chooser.setToolTipText("Export");
2939 int value = chooser.showSaveDialog(this);
2941 if (value == JalviewFileChooser.APPROVE_OPTION)
2943 jalview.io.VamsasDatastore vs = new jalview.io.VamsasDatastore(viewport);
2944 //vs.store(chooser.getSelectedFile().getAbsolutePath() );
2945 vs.storeJalview( chooser.getSelectedFile().getAbsolutePath(), this);
2952 public void showTranslation_actionPerformed(ActionEvent e)
2954 SequenceI [] selection = viewport.getSelectionAsNewSequence();
2955 String [] seqstring = viewport.getViewAsString(true);
2957 int s, sSize = selection.length;
2958 SequenceI [] newSeq = new SequenceI[sSize];
2961 StringBuffer protein;
2963 for(s=0; s<sSize; s++)
2965 protein = new StringBuffer();
2966 seq = AlignSeq.extractGaps("-. ", seqstring[s]);
2967 resSize = seq.length();
2968 resSize -= resSize%3;
2970 for(res = 0; res < resSize; res+=3)
2972 String codon = seq.substring(res, res+3);
2973 codon = codon.replace('U', 'T');
2974 String aa = ResidueProperties.codonTranslate(codon);
2976 protein.append(viewport.getGapCharacter());
2977 else if(aa.equals("STOP"))
2978 protein.append("X");
2980 protein.append( aa );
2982 newSeq[s] = new Sequence(selection[s].getName(),
2983 protein.toString());
2987 AlignmentI al = new Alignment(newSeq);
2988 al.setDataset(null);
2991 ////////////////////////////////
2992 // Copy annotations across
2993 jalview.datamodel.AlignmentAnnotation[] annotations
2994 = viewport.alignment.getAlignmentAnnotation();
2996 if(annotations!=null)
2998 for (int i = 0; i < annotations.length; i++)
3000 if (annotations[i].label.equals("Quality") ||
3001 annotations[i].label.equals("Conservation") ||
3002 annotations[i].label.equals("Consensus"))
3007 aSize = viewport.alignment.getWidth() / 3;
3008 jalview.datamodel.Annotation[] anots =
3009 new jalview.datamodel.Annotation[aSize];
3011 for (a = 0; a < viewport.alignment.getWidth(); a++)
3013 if (annotations[i].annotations[a] == null
3014 || annotations[i].annotations[a] == null)
3017 anots[a / 3] = new Annotation(
3018 annotations[i].annotations[a].displayCharacter,
3019 annotations[i].annotations[a].description,
3020 annotations[i].annotations[a].secondaryStructure,
3021 annotations[i].annotations[a].value,
3022 annotations[i].annotations[a].colour);
3025 jalview.datamodel.AlignmentAnnotation aa
3026 = new jalview.datamodel.AlignmentAnnotation(annotations[i].label,
3027 annotations[i].description, anots);
3028 al.addAnnotation(aa);
3032 AlignFrame af = new AlignFrame(al, DEFAULT_WIDTH, DEFAULT_HEIGHT);
3033 Desktop.addInternalFrame(af, "Translation of "+this.getTitle(),
3045 * @param String DOCUMENT ME!
3047 public boolean parseFeaturesFile(String file, String type)
3049 boolean featuresFile = false;
3051 featuresFile = new FeaturesFile(file, type).parse(viewport.alignment.getDataset(),
3052 alignPanel.seqPanel.seqCanvas.
3053 getFeatureRenderer().featureColours,
3058 ex.printStackTrace();
3063 viewport.showSequenceFeatures = true;
3064 showSeqFeatures.setSelected(true);
3065 alignPanel.repaint();
3068 return featuresFile;
3071 public void dragEnter(DropTargetDragEvent evt)
3074 public void dragExit(DropTargetEvent evt)
3077 public void dragOver(DropTargetDragEvent evt)
3080 public void dropActionChanged(DropTargetDragEvent evt)
3083 public void drop(DropTargetDropEvent evt)
3085 Transferable t = evt.getTransferable();
3086 java.util.List files = null;
3090 DataFlavor uriListFlavor = new DataFlavor("text/uri-list;class=java.lang.String");
3091 if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor))
3093 //Works on Windows and MacOSX
3094 evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
3095 files = (java.util.List) t.getTransferData(DataFlavor.javaFileListFlavor);
3097 else if (t.isDataFlavorSupported(uriListFlavor))
3099 // This is used by Unix drag system
3100 evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
3101 String data = (String) t.getTransferData(uriListFlavor);
3102 files = new java.util.ArrayList(1);
3103 for (java.util.StringTokenizer st = new java.util.StringTokenizer(
3106 st.hasMoreTokens(); )
3108 String s = st.nextToken();
3109 if (s.startsWith("#"))
3111 // the line is a comment (as per the RFC 2483)
3115 java.net.URI uri = new java.net.URI(s);
3116 java.io.File file = new java.io.File(uri);
3123 e.printStackTrace();
3130 for (int i = 0; i < files.size(); i++)
3132 loadJalviewDataFile(files.get(i).toString());
3135 catch (Exception ex)
3137 ex.printStackTrace();
3142 // This method will attempt to load a "dropped" file first by testing
3143 // whether its and Annotation file, then features file. If both are
3144 // false then the user may have dropped an alignment file onto this
3146 public void loadJalviewDataFile(String file)
3149 String protocol = "File";
3151 if (file.indexOf("http:") > -1 || file.indexOf("file:") > -1)
3156 boolean isAnnotation = new AnnotationFile().readAnnotationFile(viewport.
3161 boolean isGroupsFile = parseFeaturesFile(file,protocol);
3164 String format = new IdentifyFile().Identify(file, protocol);
3166 if(format.equalsIgnoreCase("JnetFile"))
3168 jalview.io.JPredFile predictions = new jalview.io.JPredFile(
3170 new JnetAnnotationMaker().add_annotation(predictions,
3171 viewport.getAlignment(),
3173 alignPanel.adjustAnnotationHeight();
3174 alignPanel.repaint();
3177 new FileLoader().LoadFile(viewport, file, protocol, format);
3183 alignPanel.adjustAnnotationHeight();
3186 }catch(Exception ex)
3188 ex.printStackTrace();
3192 public void tabSelectionChanged(int index)
3196 alignPanel = (AlignmentPanel) alignPanels.elementAt(index);
3197 viewport = alignPanel.av;
3198 setMenusFromViewport(viewport);
3202 public void tabbedPane_mousePressed(MouseEvent e)
3204 if(SwingUtilities.isRightMouseButton(e))
3206 String reply = JOptionPane.showInternalInputDialog(this,
3209 JOptionPane.QUESTION_MESSAGE);
3213 viewport.viewName = reply;
3214 tabbedPane.setTitleAt( tabbedPane.getSelectedIndex() ,reply);
3220 public AlignViewport getCurrentView()