2 * Jalview - A Sequence Alignment Editor and Viewer
3 * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Softwarechang
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26 import java.awt.datatransfer.*;
27 import java.awt.event.*;
28 import java.awt.print.*;
31 import jalview.analysis.*;
32 import jalview.datamodel.*;
34 import jalview.jbgui.*;
35 import jalview.schemes.*;
36 import jalview.util.ShiftList;
38 import java.awt.dnd.*;
39 import org.biojava.dasobert.eventmodel.*;
47 public class AlignFrame extends GAlignFrame implements DropTargetListener
50 public static final int DEFAULT_WIDTH = 700;
53 public static final int DEFAULT_HEIGHT = 500;
54 public AlignmentPanel alignPanel;
55 AlignViewport viewport;
58 Vector alignPanels = new Vector();
62 public String currentFileFormat = null;
63 Stack historyList = new Stack();
64 Stack redoList = new Stack();
65 private int treeCount = 0;
68 * Creates a new AlignFrame object.
70 * @param al DOCUMENT ME!
72 public AlignFrame(AlignmentI al, int width, int height)
74 this(al, null, width, height);
79 * new alignment window with hidden columns
80 * @param al AlignmentI
81 * @param hiddenColumns ColumnSelection or null
83 public AlignFrame(AlignmentI al, ColumnSelection hiddenColumns,
84 int width, int height)
86 this.setSize(width, height);
87 viewport = new AlignViewport(al, hiddenColumns);
89 alignPanel = new AlignmentPanel(this, viewport);
91 if(al.getDataset()==null)
96 addAlignmentPanel(alignPanel);
101 * Make a new AlignFrame from exisiting alignmentPanels
102 * @param ap AlignmentPanel
103 * @param av AlignViewport
105 public AlignFrame(AlignmentPanel ap)
109 addAlignmentPanel(ap);
115 this.setDropTarget(new java.awt.dnd.DropTarget(this, this));
117 if (viewport.conservation == null)
119 BLOSUM62Colour.setEnabled(false);
120 conservationMenuItem.setEnabled(false);
121 modifyConservation.setEnabled(false);
122 // PIDColour.setEnabled(false);
123 // abovePIDThreshold.setEnabled(false);
124 // modifyPID.setEnabled(false);
127 String sortby = jalview.bin.Cache.getDefault("SORT_ALIGNMENT", "No sort");
129 if (sortby.equals("Id"))
130 sortIDMenuItem_actionPerformed(null);
131 else if (sortby.equals("Pairwise Identity"))
132 sortPairwiseMenuItem_actionPerformed(null);
134 if (Desktop.desktop != null)
136 addServiceListeners();
137 setGUINucleotide(viewport.alignment.isNucleotide());
140 if (jalview.bin.Cache.getDefault("WRAP_ALIGNMENT", false))
142 wrapMenuItem.setSelected(true);
143 wrapMenuItem_actionPerformed(null);
149 void addKeyListener()
151 final AlignFrame af = this;
152 addKeyListener(new KeyAdapter()
154 public void keyPressed(KeyEvent evt)
156 if (viewport.cursorMode
157 && evt.getKeyCode() >= KeyEvent.VK_0
158 && evt.getKeyCode() <= KeyEvent.VK_9)
160 alignPanel.seqPanel.numberPressed(evt.getKeyChar());
163 switch (evt.getKeyCode())
166 if (!evt.isControlDown())
169 if(viewport.hasHiddenRows)
171 al = viewport.alignment.getHiddenSequences().getFullAlignment();
174 al = new Alignment(viewport.alignment.getSequencesArray());
176 AlignViewport newview = new AlignViewport(al);
178 AlignmentPanel copy = new AlignmentPanel(af, newview);
180 if(viewport.viewName==null)
181 viewport.viewName="View 1";
183 copy.av.sequenceSetID = viewport.getSequenceSetId();
184 copy.av.viewName = "View " +
185 (Desktop.getViewCount(viewport.getSequenceSetId())+1);
188 addAlignmentPanel(copy);
189 PaintRefresher.Register(copy, viewport.getSequenceSetId());
190 PaintRefresher.Register(alignPanel,
191 viewport.getSequenceSetId());
196 Desktop.instance.gatherViews(af);
200 if (!evt.isControlDown())
202 Desktop.instance.explodeViews(af);
207 case 27: // escape key
208 deselectAllSequenceMenuItem_actionPerformed(null);
212 case KeyEvent.VK_DOWN:
213 if (viewport.cursorMode)
215 alignPanel.seqPanel.moveCursor(0, 1);
218 moveSelectedSequences(false);
222 if (viewport.cursorMode)
224 alignPanel.seqPanel.moveCursor(0, -1);
227 moveSelectedSequences(true);
230 case KeyEvent.VK_LEFT:
231 if (viewport.cursorMode)
233 alignPanel.seqPanel.moveCursor( -1, 0);
237 case KeyEvent.VK_RIGHT:
238 if (viewport.cursorMode)
240 alignPanel.seqPanel.moveCursor(1, 0);
244 case KeyEvent.VK_SPACE:
245 if (viewport.cursorMode)
247 alignPanel.seqPanel.insertGapAtCursor(evt.isControlDown()
253 case KeyEvent.VK_DELETE:
254 case KeyEvent.VK_BACK_SPACE:
255 if (!viewport.cursorMode)
257 cut_actionPerformed(null);
260 alignPanel.seqPanel.deleteGapAtCursor(evt.isControlDown()
267 if (viewport.cursorMode)
269 alignPanel.seqPanel.setCursorRow();
273 if (viewport.cursorMode && !evt.isControlDown())
275 alignPanel.seqPanel.setCursorColumn();
279 if (viewport.cursorMode)
281 alignPanel.seqPanel.setCursorPosition();
285 case KeyEvent.VK_ENTER:
286 case KeyEvent.VK_COMMA:
287 if (viewport.cursorMode)
289 alignPanel.seqPanel.setCursorRowAndColumn();
294 if (viewport.cursorMode)
296 alignPanel.seqPanel.setSelectionAreaAtCursor(true);
300 if (viewport.cursorMode)
302 alignPanel.seqPanel.setSelectionAreaAtCursor(false);
307 viewport.cursorMode = !viewport.cursorMode;
308 statusBar.setText("Keyboard editing mode is " +
309 (viewport.cursorMode ? "on" : "off"));
310 if (viewport.cursorMode)
312 alignPanel.seqPanel.seqCanvas.cursorX = viewport.startRes;
313 alignPanel.seqPanel.seqCanvas.cursorY = viewport.startSeq;
315 alignPanel.seqPanel.seqCanvas.repaint();
321 ClassLoader cl = jalview.gui.Desktop.class.getClassLoader();
322 java.net.URL url = javax.help.HelpSet.findHelpSet(cl, "help/help");
323 javax.help.HelpSet hs = new javax.help.HelpSet(cl, url);
325 javax.help.HelpBroker hb = hs.createHelpBroker();
326 hb.setCurrentID("home");
327 hb.setDisplayed(true);
331 ex.printStackTrace();
337 boolean toggleSeqs = !evt.isControlDown();
338 boolean toggleCols = !evt.isShiftDown();
340 boolean hide = false;
342 SequenceGroup sg = viewport.getSelectionGroup();
345 if (sg != null && sg.getSize(false) != viewport.alignment.getHeight())
347 hideSelSequences_actionPerformed(null);
350 else if (! (toggleCols && viewport.colSel.getSelected().size() > 0))
351 showAllSeqs_actionPerformed(null);
356 if (viewport.colSel.getSelected().size() > 0)
358 hideSelColumns_actionPerformed(null);
360 viewport.selectionGroup = sg;
363 showAllColumns_actionPerformed(null);
367 case KeyEvent.VK_PAGE_UP:
368 if (viewport.wrapAlignment)
369 alignPanel.scrollUp(true);
371 alignPanel.setScrollValues(viewport.startRes,
373 - viewport.endSeq + viewport.startSeq);
375 case KeyEvent.VK_PAGE_DOWN:
376 if (viewport.wrapAlignment)
377 alignPanel.scrollUp(false);
379 alignPanel.setScrollValues(viewport.startRes,
381 + viewport.endSeq - viewport.startSeq);
391 public void addAlignmentPanel(final AlignmentPanel ap)
393 alignPanels.addElement(ap);
395 int aSize = alignPanels.size();
397 tabbedPane.setVisible(aSize>1 || ap.av.viewName!=null);
399 if (aSize == 1 && ap.av.viewName==null)
401 this.getContentPane().add(ap, BorderLayout.CENTER);
407 AlignmentPanel first = (AlignmentPanel) alignPanels.firstElement();
408 tabbedPane.addTab(first.av.viewName==null?"Original":first.av.viewName,first);
410 this.getContentPane().add(tabbedPane, BorderLayout.CENTER);
413 tabbedPane.addTab(ap.av.viewName==null?"Original":ap.av.viewName, ap);
416 ap.av.updateConsensus(ap);
417 ap.av.updateConservation(ap);
420 ap.av.addPropertyChangeListener(new PropertyChangeListener()
422 public void propertyChange(PropertyChangeEvent evt)
424 if (evt.getPropertyName().equals("alignment"))
426 PaintRefresher.Refresh(ap, ap.av.getSequenceSetId());
437 public AlignViewport getViewport()
442 /* Set up intrinsic listeners for dynamically generated GUI bits. */
443 private void addServiceListeners()
445 final java.beans.PropertyChangeListener thisListener;
446 // Do this once to get current state
447 BuildWebServiceMenu();
448 Desktop.discoverer.addPropertyChangeListener(
449 thisListener = new java.beans.PropertyChangeListener()
451 public void propertyChange(PropertyChangeEvent evt)
453 // System.out.println("Discoverer property change.");
454 if (evt.getPropertyName().equals("services"))
456 // System.out.println("Rebuilding web service menu");
457 BuildWebServiceMenu();
462 addInternalFrameListener(new javax.swing.event.
463 InternalFrameAdapter()
465 public void internalFrameClosed(
466 javax.swing.event.InternalFrameEvent evt)
468 // System.out.println("deregistering discoverer listener");
469 Desktop.discoverer.removePropertyChangeListener(thisListener);
470 closeMenuItem_actionPerformed(null);
476 public void setGUINucleotide(boolean nucleotide)
478 showTranslation.setVisible( nucleotide );
479 //sequenceFeatures.setVisible(!nucleotide );
480 //featureSettings.setVisible( !nucleotide );
481 conservationMenuItem.setVisible( !nucleotide );
482 modifyConservation.setVisible( !nucleotide );
484 //Remember AlignFrame always starts as protein
487 calculateMenu.remove(calculateMenu.getItemCount()-2);
492 Hashtable progressBars;
493 public void setProgressBar(String message, long id)
495 if(progressBars == null)
496 progressBars = new Hashtable();
498 JPanel progressPanel;
499 GridLayout layout = (GridLayout) statusPanel.getLayout();
500 if(progressBars.get( new Long(id) )!=null)
502 progressPanel = (JPanel)progressBars.get( new Long(id) );
503 statusPanel.remove(progressPanel);
504 progressBars.remove( progressPanel );
505 progressPanel = null;
507 statusBar.setText(message);
509 layout.setRows(layout.getRows() - 1);
513 progressPanel = new JPanel(new BorderLayout(10, 5));
515 JProgressBar progressBar = new JProgressBar();
516 progressBar.setIndeterminate(true);
518 progressPanel.add(new JLabel(message), BorderLayout.WEST);
519 progressPanel.add(progressBar, BorderLayout.CENTER);
521 layout.setRows(layout.getRows() + 1);
522 statusPanel.add(progressPanel);
524 progressBars.put(new Long(id), progressPanel);
534 Added so Castor Mapping file can obtain Jalview Version
536 public String getVersion()
538 return jalview.bin.Cache.getProperty("VERSION");
541 public FeatureRenderer getFeatureRenderer()
543 return alignPanel.seqPanel.seqCanvas.getFeatureRenderer();
547 public void fetchSequence_actionPerformed(ActionEvent e)
549 new SequenceFetcher(this);
552 public void addFromFile_actionPerformed(ActionEvent e)
554 Desktop.instance.inputLocalFileMenuItem_actionPerformed(viewport);
557 public void addFromText_actionPerformed(ActionEvent e)
559 Desktop.instance.inputTextboxMenuItem_actionPerformed(viewport);
562 public void addFromURL_actionPerformed(ActionEvent e)
564 Desktop.instance.inputURLMenuItem_actionPerformed(viewport);
570 * @param e DOCUMENT ME!
572 public void saveAlignmentMenu_actionPerformed(ActionEvent e)
574 JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
575 getProperty( "LAST_DIRECTORY"),
577 { "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc","jar" },
579 { "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview" },
584 chooser.setFileView(new JalviewFileView());
585 chooser.setDialogTitle("Save Alignment to file");
586 chooser.setToolTipText("Save");
588 int value = chooser.showSaveDialog(this);
590 if (value == JalviewFileChooser.APPROVE_OPTION)
592 currentFileFormat = chooser.getSelectedFormat();
594 if (currentFileFormat == null)
596 JOptionPane.showInternalMessageDialog(Desktop.desktop,
597 "You must select a file format before saving!",
598 "File format not specified",
599 JOptionPane.WARNING_MESSAGE);
600 value = chooser.showSaveDialog(this);
604 jalview.bin.Cache.setProperty("DEFAULT_FILE_FORMAT",
607 String choice = chooser.getSelectedFile().getPath();
608 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
610 saveAlignment(choice, currentFileFormat);
614 public boolean saveAlignment(String file, String format)
616 if (format.equalsIgnoreCase("Jalview"))
618 String shortName = title;
620 if (shortName.indexOf(java.io.File.separatorChar) > -1)
622 shortName = shortName.substring(shortName.lastIndexOf(
623 java.io.File.separatorChar) + 1);
626 new Jalview2XML().SaveAlignment(this, file, shortName);
628 // USE Jalview2XML to save this file
634 String[] omitHidden = null;
636 if (viewport.hasHiddenColumns)
638 int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
639 "The Alignment contains hidden columns."
640 + "\nDo you want to save only the visible alignment?",
641 "Save / Omit Hidden Columns",
642 JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
644 if (reply == JOptionPane.YES_OPTION)
645 omitHidden = viewport.getViewAsString(false);
648 String output = new FormatAdapter().formatSequences(
650 viewport.alignment.getSequencesArray(),
660 java.io.PrintWriter out = new java.io.PrintWriter(
661 new java.io.FileWriter(file));
670 ex.printStackTrace();
679 * @param e DOCUMENT ME!
681 protected void outputText_actionPerformed(ActionEvent e)
683 String [] omitHidden = null;
685 if(viewport.hasHiddenColumns)
687 int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
688 "The Alignment contains hidden columns."
689 +"\nDo you want to output only the visible alignment?",
690 "Save / Omit Hidden Columns",
691 JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
693 if(reply==JOptionPane.YES_OPTION)
695 omitHidden = viewport.getViewAsString(false);
699 CutAndPasteTransfer cap = new CutAndPasteTransfer();
700 Desktop.addInternalFrame(cap,
701 "Alignment output - " + e.getActionCommand(), 600,
705 cap.setText(new FormatAdapter().formatSequences(
706 e.getActionCommand(),
707 viewport.alignment.getSequencesArray(),
714 * @param e DOCUMENT ME!
716 protected void htmlMenuItem_actionPerformed(ActionEvent e)
718 new HTMLOutput(viewport,
719 alignPanel.seqPanel.seqCanvas.getSequenceRenderer(),
720 alignPanel.seqPanel.seqCanvas.getFeatureRenderer());
723 public void createImageMap(File file, String image)
725 alignPanel.makePNGImageMap(file, image);
731 * @param e DOCUMENT ME!
733 public void createPNG(File f)
735 alignPanel.makePNG(f);
741 * @param e DOCUMENT ME!
743 public void createEPS(File f)
745 alignPanel.makeEPS(f);
751 * @param e DOCUMENT ME!
753 public void printMenuItem_actionPerformed(ActionEvent e)
755 //Putting in a thread avoids Swing painting problems
756 PrintThread thread = new PrintThread();
760 public void exportFeatures_actionPerformed(ActionEvent e)
762 new AnnotationExporter().exportFeatures(alignPanel);
766 public void exportAnnotations_actionPerformed(ActionEvent e)
768 new AnnotationExporter().exportAnnotations(
770 viewport.alignment.getAlignmentAnnotation()
775 public void associatedData_actionPerformed(ActionEvent e)
777 // Pick the tree file
778 JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
781 chooser.setFileView(new JalviewFileView());
782 chooser.setDialogTitle("Load Jalview Annotations or Features File");
783 chooser.setToolTipText("Load Jalview Annotations / Features file");
785 int value = chooser.showOpenDialog(null);
787 if (value == JalviewFileChooser.APPROVE_OPTION)
789 String choice = chooser.getSelectedFile().getPath();
790 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
791 loadJalviewDataFile(choice);
800 * @param e DOCUMENT ME!
802 public void closeMenuItem_actionPerformed(ActionEvent e)
806 for(int i=0; i<alignPanels.size(); i++)
808 AlignmentPanel ap = (AlignmentPanel)alignPanels.elementAt(i);
809 PaintRefresher.RemoveComponent(ap.seqPanel.seqCanvas);
810 PaintRefresher.RemoveComponent(ap.idPanel.idCanvas);
811 PaintRefresher.RemoveComponent(ap);
814 this.setClosed(true);
825 void updateEditMenuBar()
827 /* if (historyList.size() > 0)
829 undoMenuItem.setEnabled(true);
831 HistoryItem hi = (HistoryItem) historyList.peek();
832 undoMenuItem.setText("Undo " + hi.getDescription());
836 undoMenuItem.setEnabled(false);
837 undoMenuItem.setText("Undo");
840 if (redoList.size() > 0)
842 redoMenuItem.setEnabled(true);
844 HistoryItem hi = (HistoryItem) redoList.peek();
845 redoMenuItem.setText("Redo " + hi.getDescription());
849 redoMenuItem.setEnabled(false);
850 redoMenuItem.setText("Redo");
857 * @param hi DOCUMENT ME!
859 public void addHistoryItem(HistoryItem hi)
861 historyList.push(hi);
869 * @param e DOCUMENT ME!
871 protected void undoMenuItem_actionPerformed(ActionEvent e)
873 HistoryItem nh,hi = (HistoryItem) historyList.pop();
874 redoList.push(nh=new HistoryItem(hi.getDescription(), viewport.alignment,
876 if (hi.alColumnChanges!=null)
877 nh.alColumnChanges = hi.alColumnChanges.getInverse();
878 restoreHistoryItem(hi);
879 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
885 * @param e DOCUMENT ME!
887 protected void redoMenuItem_actionPerformed(ActionEvent e)
889 HistoryItem nh,hi = (HistoryItem) redoList.pop();
890 historyList.push(nh=new HistoryItem(hi.getDescription(), viewport.alignment,
892 if (hi.alColumnChanges!=null)
893 nh.alColumnChanges=hi.alColumnChanges.getInverse();
894 restoreHistoryItem(hi);
896 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
899 // used by undo and redo
900 void restoreHistoryItem(HistoryItem hi)
903 hi.restore(viewport.getColumnSelection());
907 viewport.firePropertyChange("alignment", null,
908 viewport.getAlignment().getSequences());
914 * @param up DOCUMENT ME!
916 public void moveSelectedSequences(boolean up)
918 SequenceGroup sg = viewport.getSelectionGroup();
927 for (int i = 1; i < viewport.alignment.getHeight(); i++)
929 SequenceI seq = viewport.alignment.getSequenceAt(i);
931 if (!sg.getSequences(false).contains(seq))
936 SequenceI temp = viewport.alignment.getSequenceAt(i - 1);
938 if (sg.getSequences(false).contains(temp))
943 viewport.alignment.getSequences().setElementAt(temp, i);
944 viewport.alignment.getSequences().setElementAt(seq, i - 1);
949 for (int i = viewport.alignment.getHeight() - 2; i > -1; i--)
951 SequenceI seq = viewport.alignment.getSequenceAt(i);
953 if (!sg.getSequences(false).contains(seq))
958 SequenceI temp = viewport.alignment.getSequenceAt(i + 1);
960 if (sg.getSequences(false).contains(temp))
965 viewport.alignment.getSequences().setElementAt(temp, i);
966 viewport.alignment.getSequences().setElementAt(seq, i + 1);
970 alignPanel.repaint();
978 * @param e DOCUMENT ME!
980 protected void copy_actionPerformed(ActionEvent e)
983 if (viewport.getSelectionGroup() == null)
988 SequenceI [] seqs = viewport.getSelectionAsNewSequence();
989 String[] omitHidden = null;
991 if (viewport.hasHiddenColumns)
993 omitHidden = viewport.getViewAsString(true);
996 String output = new FormatAdapter().formatSequences(
1001 StringSelection ss = new StringSelection(output);
1005 //Its really worth setting the clipboard contents
1006 //to empty before setting the large StringSelection!!
1007 Toolkit.getDefaultToolkit().getSystemClipboard()
1008 .setContents(new StringSelection(""), null);
1010 Toolkit.getDefaultToolkit().getSystemClipboard()
1011 .setContents(ss, Desktop.instance);
1013 catch (OutOfMemoryError er)
1015 er.printStackTrace();
1016 javax.swing.SwingUtilities.invokeLater(new Runnable()
1020 javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop,
1021 "Out of memory copying region!!"
1023 "\nSee help files for increasing Java Virtual Machine memory."
1025 javax.swing.JOptionPane.WARNING_MESSAGE);
1032 Vector hiddenColumns = null;
1033 if(viewport.hasHiddenColumns)
1035 hiddenColumns =new Vector();
1036 int hiddenOffset = viewport.getSelectionGroup().getStartRes();
1037 for(int i=0; i<viewport.getColumnSelection().getHiddenColumns().size(); i++)
1039 int[] region = (int[])
1040 viewport.getColumnSelection().getHiddenColumns().elementAt(i);
1042 hiddenColumns.addElement(new int[]{region[0]-hiddenOffset,
1043 region[1]-hiddenOffset});
1049 Desktop.jalviewClipboard = new Object[]{ seqs,
1050 viewport.alignment.getDataset(),
1052 statusBar.setText("Copied "+seqs.length+" sequences to clipboard.");
1058 * @param e DOCUMENT ME!
1060 protected void pasteNew_actionPerformed(ActionEvent e)
1068 * @param e DOCUMENT ME!
1070 protected void pasteThis_actionPerformed(ActionEvent e)
1072 addHistoryItem(new HistoryItem("Paste Sequences", viewport.alignment,
1073 HistoryItem.PASTE));
1080 * @param newAlignment DOCUMENT ME!
1082 void paste(boolean newAlignment)
1086 Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
1087 Transferable contents = c.getContents(this);
1089 if (contents == null)
1097 str = (String) contents.getTransferData(DataFlavor.stringFlavor);
1098 if (str.length() < 1)
1101 format = new IdentifyFile().Identify(str, "Paste");
1104 catch (OutOfMemoryError er)
1106 er.printStackTrace();
1107 javax.swing.SwingUtilities.invokeLater(new Runnable()
1111 javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop,
1112 "Out of memory pasting sequences!!"
1114 "\nSee help files for increasing Java Virtual Machine memory."
1116 javax.swing.JOptionPane.WARNING_MESSAGE);
1123 SequenceI[] sequences;
1126 if(Desktop.jalviewClipboard!=null)
1128 // The clipboard was filled from within Jalview, we must use the sequences
1129 // And dataset from the copied alignment
1130 sequences = (SequenceI[])Desktop.jalviewClipboard[0];
1134 sequences = new FormatAdapter().readFile(str, "Paste", format);
1137 AlignmentI alignment = null;
1141 alignment = new Alignment(sequences);
1143 if (Desktop.jalviewClipboard != null)
1144 alignment.setDataset( (Alignment) Desktop.jalviewClipboard[1]);
1146 alignment.setDataset(null);
1150 alignment = viewport.getAlignment();
1153 for (int i = 0; i < sequences.length; i++)
1155 Sequence newseq = new Sequence(sequences[i].getName(),
1156 sequences[i].getSequence(), sequences[i].getStart(),
1157 sequences[i].getEnd());
1159 alignment.addSequence(newseq);
1160 PaintRefresher.Refresh(alignPanel,
1161 alignPanel.av.getSequenceSetId(),
1166 viewport.setEndSeq(alignment.getHeight());
1167 alignment.getWidth();
1168 viewport.firePropertyChange("alignment", null, alignment.getSequences());
1173 // Add any annotations attached to sequences
1174 for (int i = 0; i < sequences.length; i++)
1176 if (sequences[i].getAnnotation() != null)
1178 for (int a = 0; a < sequences[i].getAnnotation().length; a++)
1180 AlignmentAnnotation newAnnot =
1181 new AlignmentAnnotation(
1182 sequences[i].getAnnotation()[a].label,
1183 sequences[i].getAnnotation()[a].description,
1184 sequences[i].getAnnotation()[a].annotations,
1185 sequences[i].getAnnotation()[a].graphMin,
1186 sequences[i].getAnnotation()[a].graphMax,
1187 sequences[i].getAnnotation()[a].graph);
1189 sequences[i].getAnnotation()[a] = newAnnot;
1190 newAnnot.sequenceMapping = sequences[i].getAnnotation()[a].
1192 newAnnot.sequenceRef = sequences[i];
1193 newAnnot.adjustForAlignment();
1194 alignment.addAnnotation(newAnnot);
1195 alignment.setAnnotationIndex(newAnnot, a);
1198 alignPanel.annotationPanel.adjustPanelHeight();
1204 AlignFrame af = new AlignFrame(alignment, DEFAULT_WIDTH, DEFAULT_HEIGHT);
1205 String newtitle = new String("Copied sequences");
1207 if(Desktop.jalviewClipboard!=null && Desktop.jalviewClipboard[2]!=null)
1209 Vector hc = (Vector)Desktop.jalviewClipboard[2];
1210 for(int i=0; i<hc.size(); i++)
1212 int [] region = (int[]) hc.elementAt(i);
1213 af.viewport.hideColumns(region[0], region[1]);
1218 //>>>This is a fix for the moment, until a better solution is found!!<<<
1219 af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().transferSettings(
1220 alignPanel.seqPanel.seqCanvas.getFeatureRenderer());
1223 if (title.startsWith("Copied sequences"))
1229 newtitle = newtitle.concat("- from " + title);
1232 Desktop.addInternalFrame(af, newtitle, DEFAULT_WIDTH,
1239 catch (Exception ex)
1241 ex.printStackTrace();
1242 System.out.println("Exception whilst pasting: "+ex);
1243 // could be anything being pasted in here
1252 * @param e DOCUMENT ME!
1254 protected void cut_actionPerformed(ActionEvent e)
1256 copy_actionPerformed(null);
1257 delete_actionPerformed(null);
1263 * @param e DOCUMENT ME!
1265 protected void delete_actionPerformed(ActionEvent e)
1268 if (viewport.getSelectionGroup() == null)
1274 SequenceGroup sg = viewport.getSelectionGroup();
1277 addHistoryItem(new HistoryItem("Delete Sequences", viewport.alignment,
1281 for (int i = 0; i < sg.getSize(false); i++)
1283 SequenceI seq = sg.getSequenceAt(i);
1284 seq.deleteChars(sg.getStartRes(), sg.getEndRes() + 1);
1286 // If the cut affects all sequences, remove highlighted columns
1287 if (sg.getSize(false) == viewport.alignment.getHeight())
1289 viewport.getColumnSelection().removeElements(sg.getStartRes(),
1290 sg.getEndRes() + 1);
1293 if (seq.getSequence().length() < 1)
1295 viewport.getAlignment().deleteSequence(seq);
1296 PaintRefresher.Refresh(alignPanel,alignPanel.av.getSequenceSetId(),seq,null);
1300 viewport.setSelectionGroup(null);
1301 viewport.alignment.deleteGroup(sg);
1303 viewport.firePropertyChange("alignment", null,
1304 viewport.getAlignment().getSequences());
1308 if (viewport.getAlignment().getHeight() < 1)
1312 this.setClosed(true);
1314 catch (Exception ex)
1323 * @param e DOCUMENT ME!
1325 protected void deleteGroups_actionPerformed(ActionEvent e)
1327 viewport.alignment.deleteAllGroups();
1328 viewport.setSelectionGroup(null);
1329 PaintRefresher.Refresh(this, viewport.getSequenceSetId());
1330 alignPanel.repaint();
1336 * @param e DOCUMENT ME!
1338 public void selectAllSequenceMenuItem_actionPerformed(ActionEvent e)
1340 SequenceGroup sg = new SequenceGroup();
1342 for (int i = 0; i < viewport.getAlignment().getSequences().size();
1345 sg.addSequence(viewport.getAlignment().getSequenceAt(i), false);
1348 sg.setEndRes(viewport.alignment.getWidth() - 1);
1349 viewport.setSelectionGroup(sg);
1350 alignPanel.repaint();
1351 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
1357 * @param e DOCUMENT ME!
1359 public void deselectAllSequenceMenuItem_actionPerformed(ActionEvent e)
1361 if(viewport.cursorMode)
1363 alignPanel.seqPanel.keyboardNo1 = null;
1364 alignPanel.seqPanel.keyboardNo2 = null;
1366 viewport.setSelectionGroup(null);
1367 viewport.getColumnSelection().clear();
1368 viewport.setSelectionGroup(null);
1369 alignPanel.seqPanel.seqCanvas.highlightSearchResults(null);
1370 alignPanel.idPanel.idCanvas.searchResults = null;
1371 alignPanel.repaint();
1372 PaintRefresher.Refresh(this, viewport.getSequenceSetId());
1378 * @param e DOCUMENT ME!
1380 public void invertSequenceMenuItem_actionPerformed(ActionEvent e)
1382 SequenceGroup sg = viewport.getSelectionGroup();
1386 selectAllSequenceMenuItem_actionPerformed(null);
1391 for (int i = 0; i < viewport.getAlignment().getSequences().size();
1394 sg.addOrRemove(viewport.getAlignment().getSequenceAt(i), false);
1397 PaintRefresher.Refresh(this, viewport.getSequenceSetId());
1400 public void invertColSel_actionPerformed(ActionEvent e)
1402 viewport.invertColumnSelection();
1403 alignPanel.repaint();
1410 * @param e DOCUMENT ME!
1412 public void remove2LeftMenuItem_actionPerformed(ActionEvent e)
1414 ColumnSelection colSel = viewport.getColumnSelection();
1416 if (colSel.size() > 0)
1419 addHistoryItem(edit=new HistoryItem("Remove Left", viewport.alignment,
1422 int min = colSel.getMin();
1423 viewport.getAlignment().trimLeft(min);
1424 colSel.compensateForEdit(0, min);
1425 edit.addShift(0,min);
1426 if (viewport.getSelectionGroup() != null)
1428 viewport.getSelectionGroup().adjustForRemoveLeft(min);
1431 Vector groups = viewport.alignment.getGroups();
1433 for (int i = 0; i < groups.size(); i++)
1435 SequenceGroup sg = (SequenceGroup) groups.get(i);
1437 if (!sg.adjustForRemoveLeft(min))
1439 viewport.alignment.deleteGroup(sg);
1443 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
1450 * @param e DOCUMENT ME!
1452 public void remove2RightMenuItem_actionPerformed(ActionEvent e)
1454 ColumnSelection colSel = viewport.getColumnSelection();
1456 if (colSel.size() > 0)
1458 addHistoryItem(new HistoryItem("Remove Right", viewport.alignment,
1461 int max = colSel.getMax();
1462 viewport.getAlignment().trimRight(max);
1463 // TODO: delete hidden column entries in colSel to right of max
1464 // TODO: record hidden columns in history for undo.
1465 if (viewport.getSelectionGroup() != null)
1467 viewport.getSelectionGroup().adjustForRemoveRight(max);
1470 Vector groups = viewport.alignment.getGroups();
1472 for (int i = 0; i < groups.size(); i++)
1474 SequenceGroup sg = (SequenceGroup) groups.get(i);
1476 if (!sg.adjustForRemoveRight(max))
1478 viewport.alignment.deleteGroup(sg);
1482 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
1489 * @param e DOCUMENT ME!
1491 public void removeGappedColumnMenuItem_actionPerformed(ActionEvent e)
1494 addHistoryItem(edit=new HistoryItem("Remove Gapped Columns",
1495 viewport.alignment, HistoryItem.HIDE));
1497 //This is to maintain viewport position on first residue
1499 SequenceI seq = viewport.alignment.getSequenceAt(0);
1500 int startRes = seq.findPosition(viewport.startRes);
1502 viewport.getAlignment().removeGaps(shifts=new ShiftList());
1503 edit.alColumnChanges=shifts.getInverse();
1504 if (viewport.hasHiddenColumns)
1505 viewport.getColumnSelection().compensateForEdits(shifts);
1506 viewport.setStartRes(seq.findIndex(startRes)-1);
1507 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
1514 * @param e DOCUMENT ME!
1516 public void removeAllGapsMenuItem_actionPerformed(ActionEvent e)
1518 // TODO: hidden regions should not be touched by removeAllGaps - a minimal number of gaps will remain in alignment segments containing uneven length subsequences
1519 // TODO: columnSelection.compensateforedits should be called (and passed to history item)
1520 addHistoryItem(new HistoryItem("Remove Gaps", viewport.alignment,
1523 //This is to maintain viewport position on first residue
1525 SequenceI seq = viewport.alignment.getSequenceAt(0);
1526 int startRes = seq.findPosition(viewport.startRes);
1534 int end = viewport.alignment.getWidth();
1536 if (viewport.getSelectionGroup() != null
1537 && viewport.getSelectionGroup().getSequences(true) != null
1538 && viewport.getSelectionGroup().getSize(true) > 0)
1540 seqs = viewport.getSelectionGroup().getSequences(true);
1541 start = viewport.getSelectionGroup().getStartRes();
1542 end = viewport.getSelectionGroup().getEndRes()+1;
1546 seqs = viewport.alignment.getSequences();
1548 /* Commented out regions below are partial implementation of todo above.
1549 * divide start,end into visible chunks, and for each:
1550 int diff=end-start+1;
1552 int dr[] = new int[seqs.size()];
1554 for (int i = 0; i < seqs.size(); i++)
1556 current = (SequenceI) seqs.elementAt(i);
1558 current.removeGaps(start, end);
1559 /*if (d<diff) // can only shift
1565 /* // after the end of each chunk -
1567 // record shift for history.
1568 editgaps.addShift(start, diff);
1569 if (viewport.hasHiddenColumns && diffmax>diff) {
1571 StringBuffer gaps=new StringBuffer(diffmax);
1572 for (int i=0,j=diffmax-diff; i<j; i++)
1573 gaps.append(viewport.getGapCharacter());
1574 for (int i=0, j=seqs.size(); i<j; i++) {
1575 current = (SequenceI) seqs.elementAt(i);
1577 String sq = current.getSequence();
1578 current.setSequence(sq.substring(0, hcend-dr[i])+gaps.substring(0, dr[i]-diff)+sq.substring());
1584 viewport.setStartRes(seq.findIndex(startRes)-1);
1586 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
1590 public void alignmentChanged()
1595 for(int i=0; i<alignPanels.size(); i++)
1597 ap = (AlignmentPanel) alignPanels.elementAt(i);
1601 av.getAlignment().padGaps();
1603 if (av.hconsensus != null && av.autoCalculateConsensus)
1605 av.updateConsensus(ap);
1606 av.updateConservation(ap);
1607 ap.annotationPanel.repaint();
1610 resetAllColourSchemes();
1612 av.alignment.adjustSequenceAnnotations();
1614 if (ap.overviewPanel != null)
1615 ap.overviewPanel.updateOverviewImage();
1621 void resetAllColourSchemes()
1623 ColourSchemeI cs = viewport.globalColourScheme;
1626 if (cs instanceof ClustalxColourScheme)
1628 ( (ClustalxColourScheme) viewport.getGlobalColourScheme()).
1629 resetClustalX(viewport.alignment.getSequences(),
1630 viewport.alignment.getWidth());
1633 cs.setConsensus(viewport.hconsensus);
1634 if (cs.conservationApplied())
1636 Alignment al = (Alignment) viewport.alignment;
1637 Conservation c = new Conservation("All",
1638 ResidueProperties.propHash, 3,
1639 al.getSequences(), 0,
1642 c.verdict(false, viewport.ConsPercGaps);
1644 cs.setConservation(c);
1648 int s, sSize = viewport.alignment.getGroups().size();
1649 for(s=0; s<sSize; s++)
1651 SequenceGroup sg = (SequenceGroup)viewport.alignment.getGroups().elementAt(s);
1652 if(sg.cs!=null && sg.cs instanceof ClustalxColourScheme)
1654 ((ClustalxColourScheme)sg.cs).resetClustalX(
1655 sg.getSequences(true), sg.getWidth());
1657 sg.recalcConservation();
1664 * @param e DOCUMENT ME!
1666 public void padGapsMenuitem_actionPerformed(ActionEvent e)
1668 addHistoryItem(new HistoryItem("Pad Gaps", viewport.alignment,
1671 viewport.padGaps = padGapsMenuitem.isSelected();
1673 viewport.firePropertyChange("alignment",
1675 viewport.getAlignment().getSequences());
1681 * @param e DOCUMENT ME!
1683 public void findMenuItem_actionPerformed(ActionEvent e)
1685 JInternalFrame frame = new JInternalFrame();
1686 Finder finder = new Finder(viewport, alignPanel, frame);
1687 frame.setContentPane(finder);
1688 frame.setLayer(JLayeredPane.PALETTE_LAYER);
1689 Desktop.addInternalFrame(frame, "Find", 340, 110);
1695 * @param e DOCUMENT ME!
1697 public void font_actionPerformed(ActionEvent e)
1699 new FontChooser(alignPanel);
1702 public void smoothFont_actionPerformed(ActionEvent e)
1704 viewport.antiAlias = smoothFont.isSelected();
1705 alignPanel.annotationPanel.image = null;
1706 alignPanel.repaint();
1713 * @param e DOCUMENT ME!
1715 protected void seqLimit_actionPerformed(ActionEvent e)
1717 viewport.setShowJVSuffix(seqLimits.isSelected());
1719 alignPanel.idPanel.idCanvas.setPreferredSize(alignPanel.calculateIdWidth());
1720 alignPanel.repaint();
1727 * @param e DOCUMENT ME!
1729 protected void colourTextMenuItem_actionPerformed(ActionEvent e)
1731 viewport.setColourText(colourTextMenuItem.isSelected());
1732 alignPanel.repaint();
1738 * @param e DOCUMENT ME!
1740 public void wrapMenuItem_actionPerformed(ActionEvent e)
1742 scaleAbove.setVisible(wrapMenuItem.isSelected());
1743 scaleLeft.setVisible(wrapMenuItem.isSelected());
1744 scaleRight.setVisible(wrapMenuItem.isSelected());
1745 viewport.setWrapAlignment(wrapMenuItem.isSelected());
1746 alignPanel.setWrapAlignment(wrapMenuItem.isSelected());
1749 public void showAllSeqs_actionPerformed(ActionEvent e)
1751 viewport.showAllHiddenSeqs();
1754 public void showAllColumns_actionPerformed(ActionEvent e)
1756 viewport.showAllHiddenColumns();
1760 public void hideSelSequences_actionPerformed(ActionEvent e)
1762 viewport.hideAllSelectedSeqs();
1763 alignPanel.repaint();
1766 public void hideSelColumns_actionPerformed(ActionEvent e)
1768 viewport.hideSelectedColumns();
1769 alignPanel.repaint();
1772 public void hiddenMarkers_actionPerformed(ActionEvent e)
1774 viewport.setShowHiddenMarkers(hiddenMarkers.isSelected());
1781 * @param e DOCUMENT ME!
1783 protected void scaleAbove_actionPerformed(ActionEvent e)
1785 viewport.setScaleAboveWrapped(scaleAbove.isSelected());
1786 alignPanel.repaint();
1792 * @param e DOCUMENT ME!
1794 protected void scaleLeft_actionPerformed(ActionEvent e)
1796 viewport.setScaleLeftWrapped(scaleLeft.isSelected());
1797 alignPanel.repaint();
1803 * @param e DOCUMENT ME!
1805 protected void scaleRight_actionPerformed(ActionEvent e)
1807 viewport.setScaleRightWrapped(scaleRight.isSelected());
1808 alignPanel.repaint();
1814 * @param e DOCUMENT ME!
1816 public void viewBoxesMenuItem_actionPerformed(ActionEvent e)
1818 viewport.setShowBoxes(viewBoxesMenuItem.isSelected());
1819 alignPanel.repaint();
1825 * @param e DOCUMENT ME!
1827 public void viewTextMenuItem_actionPerformed(ActionEvent e)
1829 viewport.setShowText(viewTextMenuItem.isSelected());
1830 alignPanel.repaint();
1836 * @param e DOCUMENT ME!
1838 protected void renderGapsMenuItem_actionPerformed(ActionEvent e)
1840 viewport.setRenderGaps(renderGapsMenuItem.isSelected());
1841 alignPanel.repaint();
1845 public FeatureSettings featureSettings;
1846 public void featureSettings_actionPerformed(ActionEvent e)
1848 if(featureSettings !=null )
1850 featureSettings.close();
1851 featureSettings = null;
1853 featureSettings = new FeatureSettings(this);
1859 * @param evt DOCUMENT ME!
1861 public void showSeqFeatures_actionPerformed(ActionEvent evt)
1863 viewport.setShowSequenceFeatures(showSeqFeatures.isSelected());
1864 alignPanel.repaint();
1865 if (alignPanel.getOverviewPanel() != null)
1867 alignPanel.getOverviewPanel().updateOverviewImage();
1874 * @param e DOCUMENT ME!
1876 public void annotationPanelMenuItem_actionPerformed(ActionEvent e)
1878 viewport.setShowAnnotation(annotationPanelMenuItem.isSelected());
1879 alignPanel.setAnnotationVisible(annotationPanelMenuItem.isSelected());
1885 * @param e DOCUMENT ME!
1887 public void overviewMenuItem_actionPerformed(ActionEvent e)
1889 if (alignPanel.overviewPanel != null)
1894 JInternalFrame frame = new JInternalFrame();
1895 OverviewPanel overview = new OverviewPanel(alignPanel);
1896 frame.setContentPane(overview);
1897 Desktop.addInternalFrame(frame, "Overview " + this.getTitle(),
1898 frame.getWidth(), frame.getHeight());
1900 frame.setLayer(JLayeredPane.PALETTE_LAYER);
1901 frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
1903 public void internalFrameClosed(
1904 javax.swing.event.InternalFrameEvent evt)
1906 alignPanel.setOverviewPanel(null);
1911 alignPanel.setOverviewPanel(overview);
1917 * @param e DOCUMENT ME!
1919 protected void noColourmenuItem_actionPerformed(ActionEvent e)
1927 * @param e DOCUMENT ME!
1929 public void clustalColour_actionPerformed(ActionEvent e)
1931 changeColour(new ClustalxColourScheme(
1932 viewport.alignment.getSequences(), viewport.alignment.getWidth()));
1938 * @param e DOCUMENT ME!
1940 public void zappoColour_actionPerformed(ActionEvent e)
1942 changeColour(new ZappoColourScheme());
1948 * @param e DOCUMENT ME!
1950 public void taylorColour_actionPerformed(ActionEvent e)
1952 changeColour(new TaylorColourScheme());
1958 * @param e DOCUMENT ME!
1960 public void hydrophobicityColour_actionPerformed(ActionEvent e)
1962 changeColour(new HydrophobicColourScheme());
1968 * @param e DOCUMENT ME!
1970 public void helixColour_actionPerformed(ActionEvent e)
1972 changeColour(new HelixColourScheme());
1978 * @param e DOCUMENT ME!
1980 public void strandColour_actionPerformed(ActionEvent e)
1982 changeColour(new StrandColourScheme());
1988 * @param e DOCUMENT ME!
1990 public void turnColour_actionPerformed(ActionEvent e)
1992 changeColour(new TurnColourScheme());
1998 * @param e DOCUMENT ME!
2000 public void buriedColour_actionPerformed(ActionEvent e)
2002 changeColour(new BuriedColourScheme());
2008 * @param e DOCUMENT ME!
2010 public void nucleotideColour_actionPerformed(ActionEvent e)
2012 changeColour(new NucleotideColourScheme());
2015 public void annotationColour_actionPerformed(ActionEvent e)
2017 new AnnotationColourChooser(viewport, alignPanel);
2024 * @param e DOCUMENT ME!
2026 protected void applyToAllGroups_actionPerformed(ActionEvent e)
2028 viewport.setColourAppliesToAllGroups(applyToAllGroups.isSelected());
2034 * @param cs DOCUMENT ME!
2036 public void changeColour(ColourSchemeI cs)
2042 if (viewport.getAbovePIDThreshold())
2044 threshold = SliderPanel.setPIDSliderSource(alignPanel, cs,
2047 cs.setThreshold(threshold,
2048 viewport.getIgnoreGapsConsensus());
2050 viewport.setGlobalColourScheme(cs);
2054 cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
2057 if (viewport.getConservationSelected())
2060 Alignment al = (Alignment) viewport.alignment;
2061 Conservation c = new Conservation("All",
2062 ResidueProperties.propHash, 3,
2063 al.getSequences(), 0,
2067 c.verdict(false, viewport.ConsPercGaps);
2069 cs.setConservation(c);
2071 cs.setConservationInc(SliderPanel.setConservationSlider(alignPanel, cs,
2076 cs.setConservation(null);
2079 cs.setConsensus(viewport.hconsensus);
2082 viewport.setGlobalColourScheme(cs);
2084 if (viewport.getColourAppliesToAllGroups())
2086 Vector groups = viewport.alignment.getGroups();
2088 for (int i = 0; i < groups.size(); i++)
2090 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
2098 if (cs instanceof ClustalxColourScheme)
2100 sg.cs = new ClustalxColourScheme(
2101 sg.getSequences(true), sg.getWidth());
2103 else if (cs instanceof UserColourScheme)
2105 sg.cs = new UserColourScheme( ( (UserColourScheme) cs).getColours());
2111 sg.cs = (ColourSchemeI) cs.getClass().newInstance();
2113 catch (Exception ex)
2118 if (viewport.getAbovePIDThreshold()
2119 || cs instanceof PIDColourScheme
2120 || cs instanceof Blosum62ColourScheme)
2122 sg.cs.setThreshold(threshold,
2123 viewport.getIgnoreGapsConsensus());
2125 sg.cs.setConsensus(AAFrequency.calculate(
2126 sg.getSequences(true), 0,
2130 sg.cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
2133 if (viewport.getConservationSelected())
2135 Conservation c = new Conservation("Group",
2136 ResidueProperties.propHash, 3,
2137 sg.getSequences(true), 0,
2138 viewport.alignment.getWidth() - 1);
2140 c.verdict(false, viewport.ConsPercGaps);
2141 sg.cs.setConservation(c);
2144 sg.cs.setConservation(null);
2148 if (alignPanel.getOverviewPanel() != null)
2150 alignPanel.getOverviewPanel().updateOverviewImage();
2153 alignPanel.repaint();
2159 * @param e DOCUMENT ME!
2161 protected void modifyPID_actionPerformed(ActionEvent e)
2163 if (viewport.getAbovePIDThreshold() && viewport.globalColourScheme!=null)
2165 SliderPanel.setPIDSliderSource(alignPanel,
2166 viewport.getGlobalColourScheme(),
2168 SliderPanel.showPIDSlider();
2175 * @param e DOCUMENT ME!
2177 protected void modifyConservation_actionPerformed(ActionEvent e)
2179 if (viewport.getConservationSelected() && viewport.globalColourScheme!=null)
2181 SliderPanel.setConservationSlider(alignPanel,
2182 viewport.globalColourScheme,
2184 SliderPanel.showConservationSlider();
2191 * @param e DOCUMENT ME!
2193 protected void conservationMenuItem_actionPerformed(ActionEvent e)
2195 viewport.setConservationSelected(conservationMenuItem.isSelected());
2197 viewport.setAbovePIDThreshold(false);
2198 abovePIDThreshold.setSelected(false);
2200 changeColour(viewport.getGlobalColourScheme());
2202 modifyConservation_actionPerformed(null);
2208 * @param e DOCUMENT ME!
2210 public void abovePIDThreshold_actionPerformed(ActionEvent e)
2212 viewport.setAbovePIDThreshold(abovePIDThreshold.isSelected());
2214 conservationMenuItem.setSelected(false);
2215 viewport.setConservationSelected(false);
2217 changeColour(viewport.getGlobalColourScheme());
2219 modifyPID_actionPerformed(null);
2225 * @param e DOCUMENT ME!
2227 public void userDefinedColour_actionPerformed(ActionEvent e)
2229 if (e.getActionCommand().equals("User Defined..."))
2231 new UserDefinedColours(alignPanel, null);
2235 UserColourScheme udc = (UserColourScheme) UserDefinedColours.
2236 getUserColourSchemes().get(e.getActionCommand());
2242 public void updateUserColourMenu()
2245 Component[] menuItems = colourMenu.getMenuComponents();
2246 int i, iSize = menuItems.length;
2247 for (i = 0; i < iSize; i++)
2249 if (menuItems[i].getName() != null &&
2250 menuItems[i].getName().equals("USER_DEFINED"))
2252 colourMenu.remove(menuItems[i]);
2256 if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null)
2258 java.util.Enumeration userColours = jalview.gui.UserDefinedColours.
2259 getUserColourSchemes().keys();
2261 while (userColours.hasMoreElements())
2263 final JRadioButtonMenuItem radioItem = new JRadioButtonMenuItem(userColours.
2264 nextElement().toString());
2265 radioItem.setName("USER_DEFINED");
2266 radioItem.addMouseListener(new MouseAdapter()
2268 public void mousePressed(MouseEvent evt)
2270 if(evt.isControlDown() || SwingUtilities.isRightMouseButton(evt))
2272 radioItem.removeActionListener(radioItem.getActionListeners()[0]);
2274 int option = JOptionPane.showInternalConfirmDialog(jalview.gui.Desktop.desktop,
2275 "Remove from default list?",
2276 "Remove user defined colour",
2277 JOptionPane.YES_NO_OPTION);
2278 if(option == JOptionPane.YES_OPTION)
2280 jalview.gui.UserDefinedColours.removeColourFromDefaults(radioItem.getText());
2281 colourMenu.remove(radioItem);
2284 radioItem.addActionListener(new ActionListener()
2286 public void actionPerformed(ActionEvent evt)
2288 userDefinedColour_actionPerformed(evt);
2294 radioItem.addActionListener(new ActionListener()
2296 public void actionPerformed(ActionEvent evt)
2298 userDefinedColour_actionPerformed(evt);
2302 colourMenu.insert(radioItem, 15);
2303 colours.add(radioItem);
2311 * @param e DOCUMENT ME!
2313 public void PIDColour_actionPerformed(ActionEvent e)
2315 changeColour(new PIDColourScheme());
2321 * @param e DOCUMENT ME!
2323 public void BLOSUM62Colour_actionPerformed(ActionEvent e)
2325 changeColour(new Blosum62ColourScheme());
2331 * @param e DOCUMENT ME!
2333 public void sortPairwiseMenuItem_actionPerformed(ActionEvent e)
2335 addHistoryItem(new HistoryItem("Pairwise Sort", viewport.alignment,
2337 AlignmentSorter.sortByPID(viewport.getAlignment(),
2338 viewport.getAlignment().getSequenceAt(0));
2339 alignPanel.repaint();
2345 * @param e DOCUMENT ME!
2347 public void sortIDMenuItem_actionPerformed(ActionEvent e)
2349 addHistoryItem(new HistoryItem("ID Sort", viewport.alignment,
2351 AlignmentSorter.sortByID(viewport.getAlignment());
2352 alignPanel.repaint();
2358 * @param e DOCUMENT ME!
2360 public void sortGroupMenuItem_actionPerformed(ActionEvent e)
2362 addHistoryItem(new HistoryItem("Group Sort", viewport.alignment,
2365 AlignmentSorter.sortByGroup(viewport.getAlignment());
2366 alignPanel.repaint();
2372 * @param e DOCUMENT ME!
2374 public void removeRedundancyMenuItem_actionPerformed(ActionEvent e)
2376 new RedundancyPanel(alignPanel, this);
2383 * @param e DOCUMENT ME!
2385 public void pairwiseAlignmentMenuItem_actionPerformed(ActionEvent e)
2387 if ( (viewport.getSelectionGroup() == null) ||
2388 (viewport.getSelectionGroup().getSize(false) < 2))
2390 JOptionPane.showInternalMessageDialog(this,
2391 "You must select at least 2 sequences.",
2392 "Invalid Selection",
2393 JOptionPane.WARNING_MESSAGE);
2397 JInternalFrame frame = new JInternalFrame();
2398 frame.setContentPane(new PairwiseAlignPanel(viewport));
2399 Desktop.addInternalFrame(frame, "Pairwise Alignment", 600, 500);
2406 * @param e DOCUMENT ME!
2408 public void PCAMenuItem_actionPerformed(ActionEvent e)
2410 if ( ( (viewport.getSelectionGroup() != null) &&
2411 (viewport.getSelectionGroup().getSize(false) < 4) &&
2412 (viewport.getSelectionGroup().getSize(false) > 0)) ||
2413 (viewport.getAlignment().getHeight() < 4))
2415 JOptionPane.showInternalMessageDialog(this,
2416 "Principal component analysis must take\n" +
2417 "at least 4 input sequences.",
2418 "Sequence selection insufficient",
2419 JOptionPane.WARNING_MESSAGE);
2424 new PCAPanel(viewport);
2428 public void autoCalculate_actionPerformed(ActionEvent e)
2430 viewport.autoCalculateConsensus = autoCalculate.isSelected();
2431 if(viewport.autoCalculateConsensus)
2433 viewport.firePropertyChange("alignment",
2435 viewport.getAlignment().getSequences());
2443 * @param e DOCUMENT ME!
2445 public void averageDistanceTreeMenuItem_actionPerformed(ActionEvent e)
2447 NewTreePanel("AV", "PID", "Average distance tree using PID");
2453 * @param e DOCUMENT ME!
2455 public void neighbourTreeMenuItem_actionPerformed(ActionEvent e)
2457 NewTreePanel("NJ", "PID", "Neighbour joining tree using PID");
2463 * @param e DOCUMENT ME!
2465 protected void njTreeBlosumMenuItem_actionPerformed(ActionEvent e)
2467 NewTreePanel("NJ", "BL", "Neighbour joining tree using BLOSUM62");
2473 * @param e DOCUMENT ME!
2475 protected void avTreeBlosumMenuItem_actionPerformed(ActionEvent e)
2477 NewTreePanel("AV", "BL", "Average distance tree using BLOSUM62");
2483 * @param type DOCUMENT ME!
2484 * @param pwType DOCUMENT ME!
2485 * @param title DOCUMENT ME!
2487 void NewTreePanel(String type, String pwType, String title)
2491 if (viewport.getSelectionGroup() != null) {
2492 if (viewport.getSelectionGroup().getSize(false) < 3) {
2493 JOptionPane.showMessageDialog(Desktop.desktop,
2494 "You need to have more than two sequences selected to build a tree!",
2495 "Not enough sequences",
2496 JOptionPane.WARNING_MESSAGE);
2501 SequenceGroup sg = viewport.getSelectionGroup();
2503 /* Decide if the selection is a column region */
2504 while (s < sg.getSize(false))
2506 if ( ( (SequenceI) sg.getSequences(false).elementAt(s++)).getLength() <
2509 JOptionPane.showMessageDialog(Desktop.desktop,
2510 "The selected region to create a tree may\nonly contain residues or gaps.\n" +
2511 "Try using the Pad function in the edit menu,\n" +
2512 "or one of the multiple sequence alignment web services.",
2513 "Sequences in selection are not aligned",
2514 JOptionPane.WARNING_MESSAGE);
2520 title = title + " on region";
2521 tp = new TreePanel(alignPanel, type, pwType);
2525 //are the sequences aligned?
2526 if (!viewport.alignment.isAligned())
2528 JOptionPane.showMessageDialog(Desktop.desktop,
2529 "The sequences must be aligned before creating a tree.\n" +
2530 "Try using the Pad function in the edit menu,\n" +
2531 "or one of the multiple sequence alignment web services.",
2532 "Sequences not aligned",
2533 JOptionPane.WARNING_MESSAGE);
2538 if(viewport.alignment.getHeight()<2)
2541 tp = new TreePanel(alignPanel, type, pwType);
2544 addTreeMenuItem(tp, title);
2546 Desktop.addInternalFrame(tp, title + " from " + this.title, 600, 500);
2552 * @param title DOCUMENT ME!
2553 * @param order DOCUMENT ME!
2555 public void addSortByOrderMenuItem(String title, final AlignmentOrder order)
2557 final JMenuItem item = new JMenuItem("by " + title);
2559 item.addActionListener(new java.awt.event.ActionListener()
2561 public void actionPerformed(ActionEvent e)
2563 addHistoryItem(new HistoryItem("Sort", viewport.alignment,
2566 // TODO: JBPNote - have to map order entries to curent SequenceI pointers
2567 AlignmentSorter.sortBy(viewport.getAlignment(), order);
2568 alignPanel.repaint();
2574 * Maintain the Order by->Displayed Tree menu.
2575 * Creates a new menu item for a TreePanel with an appropriate
2576 * <code>jalview.analysis.AlignmentSorter</code> call. Listeners are added
2577 * to remove the menu item when the treePanel is closed, and adjust
2578 * the tree leaf to sequence mapping when the alignment is modified.
2579 * @param treePanel Displayed tree window.
2580 * @param title SortBy menu item title.
2582 void addTreeMenuItem(final TreePanel treePanel, String title)
2584 final JMenuItem item = new JMenuItem(title);
2590 sort.add(sortByTreeMenu);
2593 sortByTreeMenu.add(item);
2594 item.addActionListener(new java.awt.event.ActionListener()
2596 public void actionPerformed(ActionEvent e)
2598 addHistoryItem(new HistoryItem("Tree Sort",
2599 viewport.alignment, HistoryItem.SORT));
2600 AlignmentSorter.sortByTree(viewport.getAlignment(),
2601 treePanel.getTree());
2602 alignPanel.repaint();
2606 treePanel.addInternalFrameListener(new javax.swing.event.
2607 InternalFrameAdapter()
2609 public void internalFrameClosed(
2610 javax.swing.event.InternalFrameEvent evt)
2613 sortByTreeMenu.remove(item);
2617 sort.remove(sortByTreeMenu);
2625 * Work out whether the whole set of sequences
2626 * or just the selected set will be submitted for multiple alignment.
2629 private jalview.datamodel.AlignmentView gatherSequencesForAlignment()
2631 // Now, check we have enough sequences
2632 AlignmentView msa = null;
2634 if ( (viewport.getSelectionGroup() != null) &&
2635 (viewport.getSelectionGroup().getSize(false) > 1))
2637 // JBPNote UGLY! To prettify, make SequenceGroup and Alignment conform to some common interface!
2638 /*SequenceGroup seqs = viewport.getSelectionGroup();
2640 msa = new SequenceI[sz = seqs.getSize(false)];
2642 for (int i = 0; i < sz; i++)
2644 msa[i] = (SequenceI) seqs.getSequenceAt(i);
2646 msa = viewport.getAlignmentView(true);
2650 /*Vector seqs = viewport.getAlignment().getSequences();
2652 if (seqs.size() > 1)
2654 msa = new SequenceI[seqs.size()];
2656 for (int i = 0; i < seqs.size(); i++)
2658 msa[i] = (SequenceI) seqs.elementAt(i);
2661 msa = viewport.getAlignmentView(false);
2667 * Decides what is submitted to a secondary structure prediction service,
2668 * the currently selected sequence, or the currently selected alignment
2669 * (where the first sequence in the set is the one that the prediction
2672 AlignmentView gatherSeqOrMsaForSecStrPrediction()
2674 AlignmentView seqs = null;
2676 if ( (viewport.getSelectionGroup() != null) &&
2677 (viewport.getSelectionGroup().getSize(false) > 0))
2679 seqs = viewport.getAlignmentView(true);
2683 seqs = viewport.getAlignmentView(false);
2685 // limit sequences - JBPNote in future - could spawn multiple prediction jobs
2686 // TODO: viewport.alignment.isAligned is a global state - the local selection may well be aligned - we preserve 2.0.8 behaviour for moment.
2687 if (!viewport.alignment.isAligned())
2689 seqs.setSequences(new SeqCigar[] { seqs.getSequences()[0] } );
2696 * @param e DOCUMENT ME!
2698 protected void LoadtreeMenuItem_actionPerformed(ActionEvent e)
2700 // Pick the tree file
2701 JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
2704 chooser.setFileView(new JalviewFileView());
2705 chooser.setDialogTitle("Select a newick-like tree file");
2706 chooser.setToolTipText("Load a tree file");
2708 int value = chooser.showOpenDialog(null);
2710 if (value == JalviewFileChooser.APPROVE_OPTION)
2712 String choice = chooser.getSelectedFile().getPath();
2713 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
2717 jalview.io.NewickFile fin = new jalview.io.NewickFile(choice,
2719 viewport.setCurrentTree(ShowNewickTree(fin, choice).getTree());
2721 catch (Exception ex)
2723 JOptionPane.showMessageDialog(Desktop.desktop,
2724 "Problem reading tree file",
2726 JOptionPane.WARNING_MESSAGE);
2727 ex.printStackTrace();
2733 public TreePanel ShowNewickTree(NewickFile nf, String title)
2735 return ShowNewickTree(nf,title,600,500,4,5);
2737 public TreePanel ShowNewickTree(NewickFile nf, String title, AlignmentView input)
2739 return ShowNewickTree(nf,title, input, 600,500,4,5);
2741 public TreePanel ShowNewickTree(NewickFile nf, String title, int w,int h,int x, int y) {
2742 return ShowNewickTree(nf, title, null, w, h, x, y);
2745 * Add a treeviewer for the tree extracted from a newick file object to the current alignment view
2747 * @param nf the tree
2748 * @param title tree viewer title
2749 * @param input Associated alignment input data (or null)
2754 * @return TreePanel handle
2756 public TreePanel ShowNewickTree(NewickFile nf, String title, AlignmentView input, int w,int h,int x, int y) {
2757 TreePanel tp = null;
2763 if (nf.getTree() != null)
2765 tp = new TreePanel(alignPanel,
2773 tp.setLocation(x,y);
2776 Desktop.addInternalFrame(tp, title, w, h);
2777 addTreeMenuItem(tp, title);
2780 catch (Exception ex)
2782 ex.printStackTrace();
2793 PrinterJob printJob = PrinterJob.getPrinterJob();
2794 PageFormat pf = printJob.pageDialog(printJob.defaultPage());
2795 printJob.setPrintable(alignPanel, pf);
2797 if (printJob.printDialog())
2803 catch (Exception PrintException)
2805 PrintException.printStackTrace();
2812 * Generates menu items and listener event actions for web service clients
2815 public void BuildWebServiceMenu()
2817 if ( (Discoverer.services != null)
2818 && (Discoverer.services.size() > 0))
2820 Vector msaws = (Vector) Discoverer.services.get("MsaWS");
2821 Vector secstrpr = (Vector) Discoverer.services.get("SecStrPred");
2822 Vector wsmenu = new Vector();
2823 final AlignFrame af = this;
2826 // Add any Multiple Sequence Alignment Services
2827 final JMenu msawsmenu = new JMenu("Alignment");
2828 for (int i = 0, j = msaws.size(); i < j; i++)
2830 final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) msaws.
2832 final JMenuItem method = new JMenuItem(sh.getName());
2833 method.addActionListener(new ActionListener()
2835 public void actionPerformed(ActionEvent e)
2837 AlignmentView msa = gatherSequencesForAlignment();
2838 new jalview.ws.MsaWSClient(sh, title, msa,
2839 false, true, viewport.getAlignment().getDataset(), af);
2844 msawsmenu.add(method);
2845 // Deal with services that we know accept partial alignments.
2846 if (sh.getName().indexOf("lustal") > -1)
2848 // We know that ClustalWS can accept partial alignments for refinement.
2849 final JMenuItem methodR = new JMenuItem(sh.getName()+" Realign");
2850 methodR.addActionListener(new ActionListener()
2852 public void actionPerformed(ActionEvent e)
2854 AlignmentView msa = gatherSequencesForAlignment();
2855 new jalview.ws.MsaWSClient(sh, title, msa,
2856 true, true, viewport.getAlignment().getDataset(), af);
2861 msawsmenu.add(methodR);
2865 wsmenu.add(msawsmenu);
2867 if (secstrpr != null)
2869 // Add any secondary structure prediction services
2870 final JMenu secstrmenu = new JMenu("Secondary Structure Prediction");
2871 for (int i = 0, j = secstrpr.size(); i < j; i++)
2873 final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle)
2875 final JMenuItem method = new JMenuItem(sh.getName());
2876 method.addActionListener(new ActionListener()
2878 public void actionPerformed(ActionEvent e)
2880 AlignmentView msa = gatherSeqOrMsaForSecStrPrediction();
2881 if (msa.getSequences().length == 1)
2883 // Single Sequence prediction
2884 new jalview.ws.JPredClient(sh, title, false, msa, af, true);
2888 if (msa.getSequences().length > 1)
2890 // Sequence profile based prediction
2891 new jalview.ws.JPredClient(sh,
2892 title, true, msa, af, true);
2897 secstrmenu.add(method);
2899 wsmenu.add(secstrmenu);
2901 this.webService.removeAll();
2902 for (int i = 0, j = wsmenu.size(); i < j; i++)
2904 webService.add( (JMenu) wsmenu.get(i));
2909 this.webService.removeAll();
2910 this.webService.add(this.webServiceNoServices);
2912 // TODO: add in rediscovery function
2913 // TODO: reduce code redundancy.
2914 // TODO: group services by location as well as function.
2917 /* public void vamsasStore_actionPerformed(ActionEvent e)
2919 JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
2920 getProperty("LAST_DIRECTORY"));
2922 chooser.setFileView(new JalviewFileView());
2923 chooser.setDialogTitle("Export to Vamsas file");
2924 chooser.setToolTipText("Export");
2926 int value = chooser.showSaveDialog(this);
2928 if (value == JalviewFileChooser.APPROVE_OPTION)
2930 jalview.io.VamsasDatastore vs = new jalview.io.VamsasDatastore(viewport);
2931 //vs.store(chooser.getSelectedFile().getAbsolutePath() );
2932 vs.storeJalview( chooser.getSelectedFile().getAbsolutePath(), this);
2939 public void showTranslation_actionPerformed(ActionEvent e)
2941 SequenceI [] selection = viewport.getSelectionAsNewSequence();
2942 String [] seqstring = viewport.getViewAsString(true);
2944 int s, sSize = selection.length;
2945 SequenceI [] newSeq = new SequenceI[sSize];
2948 StringBuffer protein;
2950 for(s=0; s<sSize; s++)
2952 protein = new StringBuffer();
2953 seq = AlignSeq.extractGaps("-. ", seqstring[s]);
2954 resSize = seq.length();
2955 resSize -= resSize%3;
2957 for(res = 0; res < resSize; res+=3)
2959 String codon = seq.substring(res, res+3);
2960 codon = codon.replace('U', 'T');
2961 String aa = ResidueProperties.codonTranslate(codon);
2963 protein.append(viewport.getGapCharacter());
2964 else if(aa.equals("STOP"))
2965 protein.append("X");
2967 protein.append( aa );
2969 newSeq[s] = new Sequence(selection[s].getName(),
2970 protein.toString());
2974 AlignmentI al = new Alignment(newSeq);
2975 al.setDataset(null);
2978 ////////////////////////////////
2979 // Copy annotations across
2980 jalview.datamodel.AlignmentAnnotation[] annotations
2981 = viewport.alignment.getAlignmentAnnotation();
2983 if(annotations!=null)
2985 for (int i = 0; i < annotations.length; i++)
2987 if (annotations[i].label.equals("Quality") ||
2988 annotations[i].label.equals("Conservation") ||
2989 annotations[i].label.equals("Consensus"))
2994 aSize = viewport.alignment.getWidth() / 3;
2995 jalview.datamodel.Annotation[] anots =
2996 new jalview.datamodel.Annotation[aSize];
2998 for (a = 0; a < viewport.alignment.getWidth(); a++)
3000 if (annotations[i].annotations[a] == null
3001 || annotations[i].annotations[a] == null)
3004 anots[a / 3] = new Annotation(
3005 annotations[i].annotations[a].displayCharacter,
3006 annotations[i].annotations[a].description,
3007 annotations[i].annotations[a].secondaryStructure,
3008 annotations[i].annotations[a].value,
3009 annotations[i].annotations[a].colour);
3012 jalview.datamodel.AlignmentAnnotation aa
3013 = new jalview.datamodel.AlignmentAnnotation(annotations[i].label,
3014 annotations[i].description, anots);
3015 al.addAnnotation(aa);
3019 AlignFrame af = new AlignFrame(al, DEFAULT_WIDTH, DEFAULT_HEIGHT);
3020 Desktop.addInternalFrame(af, "Translation of "+this.getTitle(),
3032 * @param String DOCUMENT ME!
3034 public boolean parseFeaturesFile(String file, String type)
3036 boolean featuresFile = false;
3038 featuresFile = new FeaturesFile(file, type).parse(viewport.alignment.getDataset(),
3039 alignPanel.seqPanel.seqCanvas.
3040 getFeatureRenderer().featureColours,
3045 ex.printStackTrace();
3050 viewport.showSequenceFeatures = true;
3051 showSeqFeatures.setSelected(true);
3052 alignPanel.repaint();
3055 return featuresFile;
3058 public void dragEnter(DropTargetDragEvent evt)
3061 public void dragExit(DropTargetEvent evt)
3064 public void dragOver(DropTargetDragEvent evt)
3067 public void dropActionChanged(DropTargetDragEvent evt)
3070 public void drop(DropTargetDropEvent evt)
3072 Transferable t = evt.getTransferable();
3073 java.util.List files = null;
3077 DataFlavor uriListFlavor = new DataFlavor("text/uri-list;class=java.lang.String");
3078 if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor))
3080 //Works on Windows and MacOSX
3081 evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
3082 files = (java.util.List) t.getTransferData(DataFlavor.javaFileListFlavor);
3084 else if (t.isDataFlavorSupported(uriListFlavor))
3086 // This is used by Unix drag system
3087 evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
3088 String data = (String) t.getTransferData(uriListFlavor);
3089 files = new java.util.ArrayList(1);
3090 for (java.util.StringTokenizer st = new java.util.StringTokenizer(
3093 st.hasMoreTokens(); )
3095 String s = st.nextToken();
3096 if (s.startsWith("#"))
3098 // the line is a comment (as per the RFC 2483)
3102 java.net.URI uri = new java.net.URI(s);
3103 java.io.File file = new java.io.File(uri);
3110 e.printStackTrace();
3117 for (int i = 0; i < files.size(); i++)
3119 loadJalviewDataFile(files.get(i).toString());
3122 catch (Exception ex)
3124 ex.printStackTrace();
3129 // This method will attempt to load a "dropped" file first by testing
3130 // whether its and Annotation file, then features file. If both are
3131 // false then the user may have dropped an alignment file onto this
3133 public void loadJalviewDataFile(String file)
3136 String protocol = "File";
3138 if (file.indexOf("http:") > -1 || file.indexOf("file:") > -1)
3143 boolean isAnnotation = new AnnotationFile().readAnnotationFile(viewport.
3148 boolean isGroupsFile = parseFeaturesFile(file,protocol);
3151 String format = new IdentifyFile().Identify(file, protocol);
3153 if(format.equalsIgnoreCase("JnetFile"))
3155 jalview.io.JPredFile predictions = new jalview.io.JPredFile(
3157 new JnetAnnotationMaker().add_annotation(predictions,
3158 viewport.getAlignment(),
3160 alignPanel.adjustAnnotationHeight();
3161 alignPanel.repaint();
3164 new FileLoader().LoadFile(viewport, file, protocol, format);
3170 alignPanel.adjustAnnotationHeight();
3173 }catch(Exception ex)
3175 ex.printStackTrace();
3179 public void tabSelectionChanged(int index)
3183 alignPanel = (AlignmentPanel) alignPanels.elementAt(index);
3184 viewport = alignPanel.av;
3188 public void tabbedPane_mousePressed(MouseEvent e)
3190 if(SwingUtilities.isRightMouseButton(e))
3192 String reply = JOptionPane.showInternalInputDialog(this,
3195 JOptionPane.QUESTION_MESSAGE);
3199 viewport.viewName = reply;
3200 tabbedPane.setTitleAt( tabbedPane.getSelectedIndex() ,reply);
3206 public AlignViewport getCurrentView()