2 * Jalview - A Sequence Alignment Editor and Viewer
3 * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Softwarechang
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26 import java.awt.datatransfer.*;
27 import java.awt.event.*;
28 import java.awt.print.*;
31 import jalview.analysis.*;
32 import jalview.datamodel.*;
34 import jalview.jbgui.*;
35 import jalview.schemes.*;
36 import jalview.util.ShiftList;
37 import jalview.commands.*;
39 import java.awt.dnd.*;
47 public class AlignFrame extends GAlignFrame implements DropTargetListener
50 public static final int DEFAULT_WIDTH = 700;
53 public static final int DEFAULT_HEIGHT = 500;
54 public AlignmentPanel alignPanel;
55 AlignViewport viewport;
58 Vector alignPanels = new Vector();
62 public String currentFileFormat = null;
63 Stack historyList = new Stack();
64 Stack redoList = new Stack();
65 private int treeCount = 0;
68 * Creates a new AlignFrame object.
70 * @param al DOCUMENT ME!
72 public AlignFrame(AlignmentI al, int width, int height)
74 this(al, null, width, height);
79 * new alignment window with hidden columns
80 * @param al AlignmentI
81 * @param hiddenColumns ColumnSelection or null
83 public AlignFrame(AlignmentI al, ColumnSelection hiddenColumns,
84 int width, int height)
86 this.setSize(width, height);
87 viewport = new AlignViewport(al, hiddenColumns);
89 alignPanel = new AlignmentPanel(this, viewport);
91 if(al.getDataset()==null)
96 addAlignmentPanel(alignPanel);
101 * Make a new AlignFrame from exisiting alignmentPanels
102 * @param ap AlignmentPanel
103 * @param av AlignViewport
105 public AlignFrame(AlignmentPanel ap)
109 alignPanel.alignFrame = this;
110 addAlignmentPanel(ap);
116 this.setDropTarget(new java.awt.dnd.DropTarget(this, this));
118 if (viewport.conservation == null)
120 BLOSUM62Colour.setEnabled(false);
121 conservationMenuItem.setEnabled(false);
122 modifyConservation.setEnabled(false);
123 // PIDColour.setEnabled(false);
124 // abovePIDThreshold.setEnabled(false);
125 // modifyPID.setEnabled(false);
128 String sortby = jalview.bin.Cache.getDefault("SORT_ALIGNMENT", "No sort");
130 if (sortby.equals("Id"))
131 sortIDMenuItem_actionPerformed(null);
132 else if (sortby.equals("Pairwise Identity"))
133 sortPairwiseMenuItem_actionPerformed(null);
135 if (Desktop.desktop != null)
137 addServiceListeners();
138 setGUINucleotide(viewport.alignment.isNucleotide());
141 if (jalview.bin.Cache.getDefault("WRAP_ALIGNMENT", false))
143 wrapMenuItem.setSelected(true);
144 wrapMenuItem_actionPerformed(null);
150 void addKeyListener()
152 final AlignFrame af = this;
153 addKeyListener(new KeyAdapter()
155 public void keyPressed(KeyEvent evt)
157 if (viewport.cursorMode
158 && evt.getKeyCode() >= KeyEvent.VK_0
159 && evt.getKeyCode() <= KeyEvent.VK_9)
161 alignPanel.seqPanel.numberPressed(evt.getKeyChar());
164 switch (evt.getKeyCode())
167 if (!evt.isControlDown())
170 if(viewport.hasHiddenRows)
172 al = viewport.alignment.getHiddenSequences().getFullAlignment();
175 al = new Alignment(viewport.alignment.getSequencesArray());
177 AlignViewport newview = new AlignViewport(al);
179 AlignmentPanel copy = new AlignmentPanel(af, newview);
181 if(viewport.viewName==null)
182 viewport.viewName="View 1";
184 copy.av.sequenceSetID = viewport.getSequenceSetId();
185 copy.av.viewName = "View " +
186 (Desktop.getViewCount(viewport.getSequenceSetId())+1);
189 addAlignmentPanel(copy);
190 PaintRefresher.Register(copy, viewport.getSequenceSetId());
191 PaintRefresher.Register(alignPanel,
192 viewport.getSequenceSetId());
197 Desktop.instance.gatherViews(af);
201 if (!evt.isControlDown())
203 Desktop.instance.explodeViews(af);
208 case 27: // escape key
209 deselectAllSequenceMenuItem_actionPerformed(null);
213 case KeyEvent.VK_DOWN:
214 if (viewport.cursorMode)
216 alignPanel.seqPanel.moveCursor(0, 1);
219 moveSelectedSequences(false);
223 if (viewport.cursorMode)
225 alignPanel.seqPanel.moveCursor(0, -1);
228 moveSelectedSequences(true);
231 case KeyEvent.VK_LEFT:
232 if (viewport.cursorMode)
234 alignPanel.seqPanel.moveCursor( -1, 0);
238 case KeyEvent.VK_RIGHT:
239 if (viewport.cursorMode)
241 alignPanel.seqPanel.moveCursor(1, 0);
245 case KeyEvent.VK_SPACE:
246 if (viewport.cursorMode)
248 alignPanel.seqPanel.insertGapAtCursor(evt.isControlDown()
254 case KeyEvent.VK_DELETE:
255 case KeyEvent.VK_BACK_SPACE:
256 if (!viewport.cursorMode)
258 cut_actionPerformed(null);
261 alignPanel.seqPanel.deleteGapAtCursor(evt.isControlDown()
268 if (viewport.cursorMode)
270 alignPanel.seqPanel.setCursorRow();
274 if (viewport.cursorMode && !evt.isControlDown())
276 alignPanel.seqPanel.setCursorColumn();
280 if (viewport.cursorMode)
282 alignPanel.seqPanel.setCursorPosition();
286 case KeyEvent.VK_ENTER:
287 case KeyEvent.VK_COMMA:
288 if (viewport.cursorMode)
290 alignPanel.seqPanel.setCursorRowAndColumn();
295 if (viewport.cursorMode)
297 alignPanel.seqPanel.setSelectionAreaAtCursor(true);
301 if (viewport.cursorMode)
303 alignPanel.seqPanel.setSelectionAreaAtCursor(false);
308 viewport.cursorMode = !viewport.cursorMode;
309 statusBar.setText("Keyboard editing mode is " +
310 (viewport.cursorMode ? "on" : "off"));
311 if (viewport.cursorMode)
313 alignPanel.seqPanel.seqCanvas.cursorX = viewport.startRes;
314 alignPanel.seqPanel.seqCanvas.cursorY = viewport.startSeq;
316 alignPanel.seqPanel.seqCanvas.repaint();
322 ClassLoader cl = jalview.gui.Desktop.class.getClassLoader();
323 java.net.URL url = javax.help.HelpSet.findHelpSet(cl, "help/help");
324 javax.help.HelpSet hs = new javax.help.HelpSet(cl, url);
326 javax.help.HelpBroker hb = hs.createHelpBroker();
327 hb.setCurrentID("home");
328 hb.setDisplayed(true);
332 ex.printStackTrace();
338 boolean toggleSeqs = !evt.isControlDown();
339 boolean toggleCols = !evt.isShiftDown();
341 boolean hide = false;
343 SequenceGroup sg = viewport.getSelectionGroup();
346 if (sg != null && sg.getSize(false) != viewport.alignment.getHeight())
348 hideSelSequences_actionPerformed(null);
351 else if (! (toggleCols && viewport.colSel.getSelected().size() > 0))
352 showAllSeqs_actionPerformed(null);
357 if (viewport.colSel.getSelected().size() > 0)
359 hideSelColumns_actionPerformed(null);
361 viewport.selectionGroup = sg;
364 showAllColumns_actionPerformed(null);
368 case KeyEvent.VK_PAGE_UP:
369 if (viewport.wrapAlignment)
370 alignPanel.scrollUp(true);
372 alignPanel.setScrollValues(viewport.startRes,
374 - viewport.endSeq + viewport.startSeq);
376 case KeyEvent.VK_PAGE_DOWN:
377 if (viewport.wrapAlignment)
378 alignPanel.scrollUp(false);
380 alignPanel.setScrollValues(viewport.startRes,
382 + viewport.endSeq - viewport.startSeq);
392 public void addAlignmentPanel(final AlignmentPanel ap)
394 alignPanels.addElement(ap);
396 int aSize = alignPanels.size();
398 tabbedPane.setVisible(aSize>1 || ap.av.viewName!=null);
400 if (aSize == 1 && ap.av.viewName==null)
402 this.getContentPane().add(ap, BorderLayout.CENTER);
408 AlignmentPanel first = (AlignmentPanel) alignPanels.firstElement();
409 tabbedPane.addTab(first.av.viewName==null?"Original":first.av.viewName,first);
411 this.getContentPane().add(tabbedPane, BorderLayout.CENTER);
414 tabbedPane.addTab(ap.av.viewName==null?"Original":ap.av.viewName, ap);
417 ap.av.updateConsensus(ap);
418 ap.av.updateConservation(ap);
421 ap.av.addPropertyChangeListener(new PropertyChangeListener()
423 public void propertyChange(PropertyChangeEvent evt)
425 if (evt.getPropertyName().equals("alignment"))
427 PaintRefresher.Refresh(ap, ap.av.getSequenceSetId());
438 public AlignViewport getViewport()
443 /* Set up intrinsic listeners for dynamically generated GUI bits. */
444 private void addServiceListeners()
446 final java.beans.PropertyChangeListener thisListener;
447 // Do this once to get current state
448 BuildWebServiceMenu();
449 Desktop.discoverer.addPropertyChangeListener(
450 thisListener = new java.beans.PropertyChangeListener()
452 public void propertyChange(PropertyChangeEvent evt)
454 // System.out.println("Discoverer property change.");
455 if (evt.getPropertyName().equals("services"))
457 // System.out.println("Rebuilding web service menu");
458 BuildWebServiceMenu();
463 addInternalFrameListener(new javax.swing.event.
464 InternalFrameAdapter()
466 public void internalFrameClosed(
467 javax.swing.event.InternalFrameEvent evt)
469 // System.out.println("deregistering discoverer listener");
470 Desktop.discoverer.removePropertyChangeListener(thisListener);
471 closeMenuItem_actionPerformed(null);
477 public void setGUINucleotide(boolean nucleotide)
479 showTranslation.setVisible( nucleotide );
480 //sequenceFeatures.setVisible(!nucleotide );
481 //featureSettings.setVisible( !nucleotide );
482 conservationMenuItem.setVisible( !nucleotide );
483 modifyConservation.setVisible( !nucleotide );
485 //Remember AlignFrame always starts as protein
488 calculateMenu.remove(calculateMenu.getItemCount()-2);
493 Hashtable progressBars;
494 public void setProgressBar(String message, long id)
496 if(progressBars == null)
497 progressBars = new Hashtable();
499 JPanel progressPanel;
500 GridLayout layout = (GridLayout) statusPanel.getLayout();
501 if(progressBars.get( new Long(id) )!=null)
503 progressPanel = (JPanel)progressBars.get( new Long(id) );
504 statusPanel.remove(progressPanel);
505 progressBars.remove( progressPanel );
506 progressPanel = null;
508 statusBar.setText(message);
510 layout.setRows(layout.getRows() - 1);
514 progressPanel = new JPanel(new BorderLayout(10, 5));
516 JProgressBar progressBar = new JProgressBar();
517 progressBar.setIndeterminate(true);
519 progressPanel.add(new JLabel(message), BorderLayout.WEST);
520 progressPanel.add(progressBar, BorderLayout.CENTER);
522 layout.setRows(layout.getRows() + 1);
523 statusPanel.add(progressPanel);
525 progressBars.put(new Long(id), progressPanel);
535 Added so Castor Mapping file can obtain Jalview Version
537 public String getVersion()
539 return jalview.bin.Cache.getProperty("VERSION");
542 public FeatureRenderer getFeatureRenderer()
544 return alignPanel.seqPanel.seqCanvas.getFeatureRenderer();
548 public void fetchSequence_actionPerformed(ActionEvent e)
550 new SequenceFetcher(this);
553 public void addFromFile_actionPerformed(ActionEvent e)
555 Desktop.instance.inputLocalFileMenuItem_actionPerformed(viewport);
558 public void addFromText_actionPerformed(ActionEvent e)
560 Desktop.instance.inputTextboxMenuItem_actionPerformed(viewport);
563 public void addFromURL_actionPerformed(ActionEvent e)
565 Desktop.instance.inputURLMenuItem_actionPerformed(viewport);
571 * @param e DOCUMENT ME!
573 public void saveAlignmentMenu_actionPerformed(ActionEvent e)
575 JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
576 getProperty( "LAST_DIRECTORY"),
578 { "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc","jar" },
580 { "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview" },
585 chooser.setFileView(new JalviewFileView());
586 chooser.setDialogTitle("Save Alignment to file");
587 chooser.setToolTipText("Save");
589 int value = chooser.showSaveDialog(this);
591 if (value == JalviewFileChooser.APPROVE_OPTION)
593 currentFileFormat = chooser.getSelectedFormat();
595 if (currentFileFormat == null)
597 JOptionPane.showInternalMessageDialog(Desktop.desktop,
598 "You must select a file format before saving!",
599 "File format not specified",
600 JOptionPane.WARNING_MESSAGE);
601 value = chooser.showSaveDialog(this);
605 jalview.bin.Cache.setProperty("DEFAULT_FILE_FORMAT",
608 String choice = chooser.getSelectedFile().getPath();
609 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
611 saveAlignment(choice, currentFileFormat);
615 public boolean saveAlignment(String file, String format)
617 if (format.equalsIgnoreCase("Jalview"))
619 String shortName = title;
621 if (shortName.indexOf(java.io.File.separatorChar) > -1)
623 shortName = shortName.substring(shortName.lastIndexOf(
624 java.io.File.separatorChar) + 1);
627 new Jalview2XML().SaveAlignment(this, file, shortName);
629 // USE Jalview2XML to save this file
635 String[] omitHidden = null;
637 if (viewport.hasHiddenColumns)
639 int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
640 "The Alignment contains hidden columns."
641 + "\nDo you want to save only the visible alignment?",
642 "Save / Omit Hidden Columns",
643 JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
645 if (reply == JOptionPane.YES_OPTION)
646 omitHidden = viewport.getViewAsString(false);
649 String output = new FormatAdapter().formatSequences(
651 viewport.alignment.getSequencesArray(),
661 java.io.PrintWriter out = new java.io.PrintWriter(
662 new java.io.FileWriter(file));
671 ex.printStackTrace();
680 * @param e DOCUMENT ME!
682 protected void outputText_actionPerformed(ActionEvent e)
684 String [] omitHidden = null;
686 if(viewport.hasHiddenColumns)
688 int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
689 "The Alignment contains hidden columns."
690 +"\nDo you want to output only the visible alignment?",
691 "Save / Omit Hidden Columns",
692 JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
694 if(reply==JOptionPane.YES_OPTION)
696 omitHidden = viewport.getViewAsString(false);
700 CutAndPasteTransfer cap = new CutAndPasteTransfer();
701 Desktop.addInternalFrame(cap,
702 "Alignment output - " + e.getActionCommand(), 600,
706 cap.setText(new FormatAdapter().formatSequences(
707 e.getActionCommand(),
708 viewport.alignment.getSequencesArray(),
715 * @param e DOCUMENT ME!
717 protected void htmlMenuItem_actionPerformed(ActionEvent e)
719 new HTMLOutput(viewport,
720 alignPanel.seqPanel.seqCanvas.getSequenceRenderer(),
721 alignPanel.seqPanel.seqCanvas.getFeatureRenderer());
724 public void createImageMap(File file, String image)
726 alignPanel.makePNGImageMap(file, image);
732 * @param e DOCUMENT ME!
734 public void createPNG(File f)
736 alignPanel.makePNG(f);
742 * @param e DOCUMENT ME!
744 public void createEPS(File f)
746 alignPanel.makeEPS(f);
752 * @param e DOCUMENT ME!
754 public void printMenuItem_actionPerformed(ActionEvent e)
756 //Putting in a thread avoids Swing painting problems
757 PrintThread thread = new PrintThread();
761 public void exportFeatures_actionPerformed(ActionEvent e)
763 new AnnotationExporter().exportFeatures(alignPanel);
767 public void exportAnnotations_actionPerformed(ActionEvent e)
769 new AnnotationExporter().exportAnnotations(
771 viewport.alignment.getAlignmentAnnotation()
776 public void associatedData_actionPerformed(ActionEvent e)
778 // Pick the tree file
779 JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
782 chooser.setFileView(new JalviewFileView());
783 chooser.setDialogTitle("Load Jalview Annotations or Features File");
784 chooser.setToolTipText("Load Jalview Annotations / Features file");
786 int value = chooser.showOpenDialog(null);
788 if (value == JalviewFileChooser.APPROVE_OPTION)
790 String choice = chooser.getSelectedFile().getPath();
791 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
792 loadJalviewDataFile(choice);
801 * @param e DOCUMENT ME!
803 public void closeMenuItem_actionPerformed(ActionEvent e)
807 for(int i=0; i<alignPanels.size(); i++)
809 AlignmentPanel ap = (AlignmentPanel)alignPanels.elementAt(i);
810 PaintRefresher.RemoveComponent(ap.seqPanel.seqCanvas);
811 PaintRefresher.RemoveComponent(ap.idPanel.idCanvas);
812 PaintRefresher.RemoveComponent(ap);
815 this.setClosed(true);
826 void updateEditMenuBar()
829 if (historyList.size() > 0)
831 undoMenuItem.setEnabled(true);
832 CommandI command = (CommandI) historyList.peek();
833 undoMenuItem.setText("Undo " + command.getDescription());
837 undoMenuItem.setEnabled(false);
838 undoMenuItem.setText("Undo");
841 if (redoList.size() > 0)
843 redoMenuItem.setEnabled(true);
845 CommandI command = (CommandI) redoList.peek();
846 redoMenuItem.setText("Redo " + command.getDescription());
850 redoMenuItem.setEnabled(false);
851 redoMenuItem.setText("Redo");
856 public void addHistoryItem(CommandI command)
858 historyList.push(command);
862 viewport.hasHiddenColumns = viewport.colSel.getHiddenColumns()!=null;
870 * @param e DOCUMENT ME!
872 protected void undoMenuItem_actionPerformed(ActionEvent e)
874 CommandI command = (CommandI)historyList.pop();
875 redoList.push(command);
876 command.undoCommand();
879 viewport.hasHiddenColumns = viewport.colSel.getHiddenColumns()!=null;
881 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
887 * @param e DOCUMENT ME!
889 protected void redoMenuItem_actionPerformed(ActionEvent e)
891 CommandI command = (CommandI) redoList.pop();
892 historyList.push(command);
893 historyList.push(command);
895 viewport.hasHiddenColumns = viewport.colSel.getHiddenColumns()!=null;
898 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
905 * @param up DOCUMENT ME!
907 public void moveSelectedSequences(boolean up)
909 SequenceGroup sg = viewport.getSelectionGroup();
918 for (int i = 1; i < viewport.alignment.getHeight(); i++)
920 SequenceI seq = viewport.alignment.getSequenceAt(i);
922 if (!sg.getSequences(false).contains(seq))
927 SequenceI temp = viewport.alignment.getSequenceAt(i - 1);
929 if (sg.getSequences(false).contains(temp))
934 viewport.alignment.getSequences().setElementAt(temp, i);
935 viewport.alignment.getSequences().setElementAt(seq, i - 1);
940 for (int i = viewport.alignment.getHeight() - 2; i > -1; i--)
942 SequenceI seq = viewport.alignment.getSequenceAt(i);
944 if (!sg.getSequences(false).contains(seq))
949 SequenceI temp = viewport.alignment.getSequenceAt(i + 1);
951 if (sg.getSequences(false).contains(temp))
956 viewport.alignment.getSequences().setElementAt(temp, i);
957 viewport.alignment.getSequences().setElementAt(seq, i + 1);
961 alignPanel.repaint();
969 * @param e DOCUMENT ME!
971 protected void copy_actionPerformed(ActionEvent e)
974 if (viewport.getSelectionGroup() == null)
979 SequenceI [] seqs = viewport.getSelectionAsNewSequence();
980 String[] omitHidden = null;
982 if (viewport.hasHiddenColumns)
984 omitHidden = viewport.getViewAsString(true);
987 String output = new FormatAdapter().formatSequences(
992 StringSelection ss = new StringSelection(output);
996 //Its really worth setting the clipboard contents
997 //to empty before setting the large StringSelection!!
998 Toolkit.getDefaultToolkit().getSystemClipboard()
999 .setContents(new StringSelection(""), null);
1001 Toolkit.getDefaultToolkit().getSystemClipboard()
1002 .setContents(ss, Desktop.instance);
1004 catch (OutOfMemoryError er)
1006 er.printStackTrace();
1007 javax.swing.SwingUtilities.invokeLater(new Runnable()
1011 javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop,
1012 "Out of memory copying region!!"
1014 "\nSee help files for increasing Java Virtual Machine memory."
1016 javax.swing.JOptionPane.WARNING_MESSAGE);
1023 Vector hiddenColumns = null;
1024 if(viewport.hasHiddenColumns)
1026 hiddenColumns =new Vector();
1027 int hiddenOffset = viewport.getSelectionGroup().getStartRes();
1028 for(int i=0; i<viewport.getColumnSelection().getHiddenColumns().size(); i++)
1030 int[] region = (int[])
1031 viewport.getColumnSelection().getHiddenColumns().elementAt(i);
1033 hiddenColumns.addElement(new int[]{region[0]-hiddenOffset,
1034 region[1]-hiddenOffset});
1040 Desktop.jalviewClipboard = new Object[]{ seqs,
1041 viewport.alignment.getDataset(),
1043 statusBar.setText("Copied "+seqs.length+" sequences to clipboard.");
1049 * @param e DOCUMENT ME!
1051 protected void pasteNew_actionPerformed(ActionEvent e)
1059 * @param e DOCUMENT ME!
1061 protected void pasteThis_actionPerformed(ActionEvent e)
1069 * @param newAlignment DOCUMENT ME!
1071 void paste(boolean newAlignment)
1075 Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
1076 Transferable contents = c.getContents(this);
1078 if (contents == null)
1086 str = (String) contents.getTransferData(DataFlavor.stringFlavor);
1087 if (str.length() < 1)
1090 format = new IdentifyFile().Identify(str, "Paste");
1093 catch (OutOfMemoryError er)
1095 er.printStackTrace();
1096 javax.swing.SwingUtilities.invokeLater(new Runnable()
1100 javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop,
1101 "Out of memory pasting sequences!!"
1103 "\nSee help files for increasing Java Virtual Machine memory."
1105 javax.swing.JOptionPane.WARNING_MESSAGE);
1112 SequenceI[] sequences;
1115 if(Desktop.jalviewClipboard!=null)
1117 // The clipboard was filled from within Jalview, we must use the sequences
1118 // And dataset from the copied alignment
1119 sequences = (SequenceI[])Desktop.jalviewClipboard[0];
1123 sequences = new FormatAdapter().readFile(str, "Paste", format);
1126 AlignmentI alignment = null;
1130 alignment = new Alignment(sequences);
1132 if (Desktop.jalviewClipboard != null)
1133 alignment.setDataset( (Alignment) Desktop.jalviewClipboard[1]);
1135 alignment.setDataset(null);
1139 alignment = viewport.getAlignment();
1142 SequenceI [] newseqs = new SequenceI[sequences.length];
1143 for (int i = 0; i < sequences.length; i++)
1145 newseqs[i] = new Sequence(sequences[i].getName(),
1146 sequences[i].getSequence(), sequences[i].getStart(),
1147 sequences[i].getEnd());
1149 alignment.addSequence(newseqs[i]);
1150 PaintRefresher.Refresh(alignPanel,
1151 alignPanel.av.getSequenceSetId(),
1159 addHistoryItem(new EditCommand(
1164 alignment.getWidth(),
1169 viewport.setEndSeq(alignment.getHeight());
1170 alignment.getWidth();
1171 viewport.firePropertyChange("alignment", null, alignment.getSequences());
1176 // Add any annotations attached to sequences
1177 for (int i = 0; i < sequences.length; i++)
1179 if (sequences[i].getAnnotation() != null)
1181 for (int a = 0; a < sequences[i].getAnnotation().length; a++)
1183 AlignmentAnnotation newAnnot =
1184 new AlignmentAnnotation(
1185 sequences[i].getAnnotation()[a].label,
1186 sequences[i].getAnnotation()[a].description,
1187 sequences[i].getAnnotation()[a].annotations,
1188 sequences[i].getAnnotation()[a].graphMin,
1189 sequences[i].getAnnotation()[a].graphMax,
1190 sequences[i].getAnnotation()[a].graph);
1192 sequences[i].getAnnotation()[a] = newAnnot;
1193 newAnnot.sequenceMapping = sequences[i].getAnnotation()[a].
1195 newAnnot.sequenceRef = sequences[i];
1196 newAnnot.adjustForAlignment();
1197 alignment.addAnnotation(newAnnot);
1198 alignment.setAnnotationIndex(newAnnot, a);
1201 alignPanel.annotationPanel.adjustPanelHeight();
1207 AlignFrame af = new AlignFrame(alignment, DEFAULT_WIDTH, DEFAULT_HEIGHT);
1208 String newtitle = new String("Copied sequences");
1210 if(Desktop.jalviewClipboard!=null && Desktop.jalviewClipboard[2]!=null)
1212 Vector hc = (Vector)Desktop.jalviewClipboard[2];
1213 for(int i=0; i<hc.size(); i++)
1215 int [] region = (int[]) hc.elementAt(i);
1216 af.viewport.hideColumns(region[0], region[1]);
1221 //>>>This is a fix for the moment, until a better solution is found!!<<<
1222 af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().transferSettings(
1223 alignPanel.seqPanel.seqCanvas.getFeatureRenderer());
1226 if (title.startsWith("Copied sequences"))
1232 newtitle = newtitle.concat("- from " + title);
1235 Desktop.addInternalFrame(af, newtitle, DEFAULT_WIDTH,
1242 catch (Exception ex)
1244 ex.printStackTrace();
1245 System.out.println("Exception whilst pasting: "+ex);
1246 // could be anything being pasted in here
1255 * @param e DOCUMENT ME!
1257 protected void cut_actionPerformed(ActionEvent e)
1259 copy_actionPerformed(null);
1260 delete_actionPerformed(null);
1266 * @param e DOCUMENT ME!
1268 protected void delete_actionPerformed(ActionEvent e)
1271 SequenceGroup sg = viewport.getSelectionGroup();
1277 Vector seqs = new Vector();
1278 int cutLength = sg.getEndRes()-sg.getStartRes()+1;
1280 for (int i = 0; i < sg.getSize(false); i++)
1282 seq = sg.getSequenceAt(i);
1283 seqs.addElement(seq);
1284 if(seq.getLength()<=cutLength)
1285 PaintRefresher.Refresh(alignPanel,
1286 alignPanel.av.getSequenceSetId(),
1291 // If the cut affects all sequences, remove highlighted columns
1292 if (sg.getSize(false) == viewport.alignment.getHeight())
1294 viewport.getColumnSelection().removeElements(sg.getStartRes(),
1295 sg.getEndRes() + 1);
1299 SequenceI [] cut = new SequenceI[seqs.size()];
1300 for(int i=0; i<seqs.size(); i++)
1301 cut[i] = (SequenceI)seqs.elementAt(i);
1307 addHistoryItem(new EditCommand("Cut Sequences",
1311 sg.getEndRes()-sg.getStartRes()+1,
1312 viewport.alignment));
1314 viewport.setSelectionGroup(null);
1315 viewport.alignment.deleteGroup(sg);
1317 viewport.firePropertyChange("alignment", null,
1318 viewport.getAlignment().getSequences());
1320 if (viewport.getAlignment().getHeight() < 1)
1324 this.setClosed(true);
1326 catch (Exception ex)
1335 * @param e DOCUMENT ME!
1337 protected void deleteGroups_actionPerformed(ActionEvent e)
1339 viewport.alignment.deleteAllGroups();
1340 viewport.setSelectionGroup(null);
1341 PaintRefresher.Refresh(this, viewport.getSequenceSetId());
1342 alignPanel.repaint();
1348 * @param e DOCUMENT ME!
1350 public void selectAllSequenceMenuItem_actionPerformed(ActionEvent e)
1352 SequenceGroup sg = new SequenceGroup();
1354 for (int i = 0; i < viewport.getAlignment().getSequences().size();
1357 sg.addSequence(viewport.getAlignment().getSequenceAt(i), false);
1360 sg.setEndRes(viewport.alignment.getWidth() - 1);
1361 viewport.setSelectionGroup(sg);
1362 alignPanel.repaint();
1363 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
1369 * @param e DOCUMENT ME!
1371 public void deselectAllSequenceMenuItem_actionPerformed(ActionEvent e)
1373 if(viewport.cursorMode)
1375 alignPanel.seqPanel.keyboardNo1 = null;
1376 alignPanel.seqPanel.keyboardNo2 = null;
1378 viewport.setSelectionGroup(null);
1379 viewport.getColumnSelection().clear();
1380 viewport.setSelectionGroup(null);
1381 alignPanel.seqPanel.seqCanvas.highlightSearchResults(null);
1382 alignPanel.idPanel.idCanvas.searchResults = null;
1383 alignPanel.repaint();
1384 PaintRefresher.Refresh(this, viewport.getSequenceSetId());
1390 * @param e DOCUMENT ME!
1392 public void invertSequenceMenuItem_actionPerformed(ActionEvent e)
1394 SequenceGroup sg = viewport.getSelectionGroup();
1398 selectAllSequenceMenuItem_actionPerformed(null);
1403 for (int i = 0; i < viewport.getAlignment().getSequences().size();
1406 sg.addOrRemove(viewport.getAlignment().getSequenceAt(i), false);
1409 PaintRefresher.Refresh(this, viewport.getSequenceSetId());
1412 public void invertColSel_actionPerformed(ActionEvent e)
1414 viewport.invertColumnSelection();
1415 alignPanel.repaint();
1422 * @param e DOCUMENT ME!
1424 public void remove2LeftMenuItem_actionPerformed(ActionEvent e)
1426 trimAlignment(true);
1432 * @param e DOCUMENT ME!
1434 public void remove2RightMenuItem_actionPerformed(ActionEvent e)
1436 trimAlignment(false);
1439 void trimAlignment(boolean trimLeft)
1441 ColumnSelection colSel = viewport.getColumnSelection();
1444 if (colSel.size() > 0)
1447 column = colSel.getMin();
1449 column = colSel.getMax();
1452 if(viewport.getSelectionGroup()!=null)
1453 seqs = viewport.getSelectionGroup().getSequencesAsArray(true);
1455 seqs = viewport.alignment.getSequencesArray();
1458 TrimRegionCommand trimRegion;
1461 trimRegion = new TrimRegionCommand("Remove Left",
1462 TrimRegionCommand.TRIM_LEFT,
1467 viewport.selectionGroup);
1471 trimRegion = new TrimRegionCommand("Remove Right",
1472 TrimRegionCommand.TRIM_RIGHT,
1477 viewport.selectionGroup);
1480 addHistoryItem(trimRegion);
1482 Vector groups = viewport.alignment.getGroups();
1484 for (int i = 0; i < groups.size(); i++)
1486 SequenceGroup sg = (SequenceGroup) groups.get(i);
1488 if ( (trimLeft && !sg.adjustForRemoveLeft(column))
1489 || (!trimLeft && !sg.adjustForRemoveRight(column)))
1491 viewport.alignment.deleteGroup(sg);
1495 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
1502 * @param e DOCUMENT ME!
1504 public void removeGappedColumnMenuItem_actionPerformed(ActionEvent e)
1506 int start = 0, end = viewport.alignment.getWidth()-1;
1509 if (viewport.getSelectionGroup() != null)
1511 seqs = viewport.getSelectionGroup().getSequencesAsArray(true);
1512 start = viewport.getSelectionGroup().getStartRes();
1513 end = viewport.getSelectionGroup().getEndRes();
1516 seqs = viewport.alignment.getSequencesArray();
1519 addHistoryItem(new RemoveGapColCommand("Remove Gapped Columns",
1522 viewport.getGapCharacter()));
1524 //This is to maintain viewport position on first residue
1526 SequenceI seq = viewport.alignment.getSequenceAt(0);
1527 int startRes = seq.findPosition(viewport.startRes);
1528 // ShiftList shifts;
1529 // viewport.getAlignment().removeGaps(shifts=new ShiftList());
1530 // edit.alColumnChanges=shifts.getInverse();
1531 // if (viewport.hasHiddenColumns)
1532 // viewport.getColumnSelection().compensateForEdits(shifts);
1533 viewport.setStartRes(seq.findIndex(startRes)-1);
1534 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
1541 * @param e DOCUMENT ME!
1543 public void removeAllGapsMenuItem_actionPerformed(ActionEvent e)
1545 int start = 0, end = viewport.alignment.getWidth()-1;
1548 if (viewport.getSelectionGroup() != null)
1550 seqs = viewport.getSelectionGroup().getSequencesAsArray(true);
1551 start = viewport.getSelectionGroup().getStartRes();
1552 end = viewport.getSelectionGroup().getEndRes();
1555 seqs = viewport.alignment.getSequencesArray();
1557 //This is to maintain viewport position on first residue
1559 SequenceI seq = viewport.alignment.getSequenceAt(0);
1560 int startRes = seq.findPosition(viewport.startRes);
1562 addHistoryItem(new RemoveGapsCommand("Remove Gaps",
1565 viewport.getGapCharacter()));
1567 viewport.setStartRes(seq.findIndex(startRes)-1);
1569 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
1573 public void alignmentChanged()
1578 for(int i=0; i<alignPanels.size(); i++)
1580 ap = (AlignmentPanel) alignPanels.elementAt(i);
1584 av.getAlignment().padGaps();
1586 if (av.hconsensus != null && av.autoCalculateConsensus)
1588 av.updateConsensus(ap);
1589 av.updateConservation(ap);
1590 ap.annotationPanel.repaint();
1593 resetAllColourSchemes();
1595 av.alignment.adjustSequenceAnnotations();
1597 if (ap.overviewPanel != null)
1598 ap.overviewPanel.updateOverviewImage();
1604 void resetAllColourSchemes()
1606 ColourSchemeI cs = viewport.globalColourScheme;
1609 if (cs instanceof ClustalxColourScheme)
1611 ( (ClustalxColourScheme) viewport.getGlobalColourScheme()).
1612 resetClustalX(viewport.alignment.getSequences(),
1613 viewport.alignment.getWidth());
1616 cs.setConsensus(viewport.hconsensus);
1617 if (cs.conservationApplied())
1619 Alignment al = (Alignment) viewport.alignment;
1620 Conservation c = new Conservation("All",
1621 ResidueProperties.propHash, 3,
1622 al.getSequences(), 0,
1625 c.verdict(false, viewport.ConsPercGaps);
1627 cs.setConservation(c);
1631 int s, sSize = viewport.alignment.getGroups().size();
1632 for(s=0; s<sSize; s++)
1634 SequenceGroup sg = (SequenceGroup)viewport.alignment.getGroups().elementAt(s);
1635 if(sg.cs!=null && sg.cs instanceof ClustalxColourScheme)
1637 ((ClustalxColourScheme)sg.cs).resetClustalX(
1638 sg.getSequences(true), sg.getWidth());
1640 sg.recalcConservation();
1647 * @param e DOCUMENT ME!
1649 public void padGapsMenuitem_actionPerformed(ActionEvent e)
1651 // addHistoryItem(new HistoryItem("Pad Gaps", viewport.alignment,
1652 // HistoryItem.HIDE));
1654 viewport.padGaps = padGapsMenuitem.isSelected();
1656 viewport.firePropertyChange("alignment",
1658 viewport.getAlignment().getSequences());
1664 * @param e DOCUMENT ME!
1666 public void findMenuItem_actionPerformed(ActionEvent e)
1668 JInternalFrame frame = new JInternalFrame();
1669 Finder finder = new Finder(viewport, alignPanel, frame);
1670 frame.setContentPane(finder);
1671 frame.setLayer(JLayeredPane.PALETTE_LAYER);
1672 Desktop.addInternalFrame(frame, "Find", 340, 110);
1678 * @param e DOCUMENT ME!
1680 public void font_actionPerformed(ActionEvent e)
1682 new FontChooser(alignPanel);
1685 public void smoothFont_actionPerformed(ActionEvent e)
1687 viewport.antiAlias = smoothFont.isSelected();
1688 alignPanel.annotationPanel.image = null;
1689 alignPanel.repaint();
1696 * @param e DOCUMENT ME!
1698 protected void seqLimit_actionPerformed(ActionEvent e)
1700 viewport.setShowJVSuffix(seqLimits.isSelected());
1702 alignPanel.idPanel.idCanvas.setPreferredSize(alignPanel.calculateIdWidth());
1703 alignPanel.repaint();
1710 * @param e DOCUMENT ME!
1712 protected void colourTextMenuItem_actionPerformed(ActionEvent e)
1714 viewport.setColourText(colourTextMenuItem.isSelected());
1715 alignPanel.repaint();
1721 * @param e DOCUMENT ME!
1723 public void wrapMenuItem_actionPerformed(ActionEvent e)
1725 scaleAbove.setVisible(wrapMenuItem.isSelected());
1726 scaleLeft.setVisible(wrapMenuItem.isSelected());
1727 scaleRight.setVisible(wrapMenuItem.isSelected());
1728 viewport.setWrapAlignment(wrapMenuItem.isSelected());
1729 alignPanel.setWrapAlignment(wrapMenuItem.isSelected());
1732 public void showAllSeqs_actionPerformed(ActionEvent e)
1734 viewport.showAllHiddenSeqs();
1737 public void showAllColumns_actionPerformed(ActionEvent e)
1739 viewport.showAllHiddenColumns();
1743 public void hideSelSequences_actionPerformed(ActionEvent e)
1745 viewport.hideAllSelectedSeqs();
1746 alignPanel.repaint();
1749 public void hideSelColumns_actionPerformed(ActionEvent e)
1751 viewport.hideSelectedColumns();
1752 alignPanel.repaint();
1755 public void hiddenMarkers_actionPerformed(ActionEvent e)
1757 viewport.setShowHiddenMarkers(hiddenMarkers.isSelected());
1764 * @param e DOCUMENT ME!
1766 protected void scaleAbove_actionPerformed(ActionEvent e)
1768 viewport.setScaleAboveWrapped(scaleAbove.isSelected());
1769 alignPanel.repaint();
1775 * @param e DOCUMENT ME!
1777 protected void scaleLeft_actionPerformed(ActionEvent e)
1779 viewport.setScaleLeftWrapped(scaleLeft.isSelected());
1780 alignPanel.repaint();
1786 * @param e DOCUMENT ME!
1788 protected void scaleRight_actionPerformed(ActionEvent e)
1790 viewport.setScaleRightWrapped(scaleRight.isSelected());
1791 alignPanel.repaint();
1797 * @param e DOCUMENT ME!
1799 public void viewBoxesMenuItem_actionPerformed(ActionEvent e)
1801 viewport.setShowBoxes(viewBoxesMenuItem.isSelected());
1802 alignPanel.repaint();
1808 * @param e DOCUMENT ME!
1810 public void viewTextMenuItem_actionPerformed(ActionEvent e)
1812 viewport.setShowText(viewTextMenuItem.isSelected());
1813 alignPanel.repaint();
1819 * @param e DOCUMENT ME!
1821 protected void renderGapsMenuItem_actionPerformed(ActionEvent e)
1823 viewport.setRenderGaps(renderGapsMenuItem.isSelected());
1824 alignPanel.repaint();
1828 public FeatureSettings featureSettings;
1829 public void featureSettings_actionPerformed(ActionEvent e)
1831 if(featureSettings !=null )
1833 featureSettings.close();
1834 featureSettings = null;
1836 featureSettings = new FeatureSettings(this);
1842 * @param evt DOCUMENT ME!
1844 public void showSeqFeatures_actionPerformed(ActionEvent evt)
1846 viewport.setShowSequenceFeatures(showSeqFeatures.isSelected());
1847 alignPanel.repaint();
1848 if (alignPanel.getOverviewPanel() != null)
1850 alignPanel.getOverviewPanel().updateOverviewImage();
1857 * @param e DOCUMENT ME!
1859 public void annotationPanelMenuItem_actionPerformed(ActionEvent e)
1861 viewport.setShowAnnotation(annotationPanelMenuItem.isSelected());
1862 alignPanel.setAnnotationVisible(annotationPanelMenuItem.isSelected());
1868 * @param e DOCUMENT ME!
1870 public void overviewMenuItem_actionPerformed(ActionEvent e)
1872 if (alignPanel.overviewPanel != null)
1877 JInternalFrame frame = new JInternalFrame();
1878 OverviewPanel overview = new OverviewPanel(alignPanel);
1879 frame.setContentPane(overview);
1880 Desktop.addInternalFrame(frame, "Overview " + this.getTitle(),
1881 frame.getWidth(), frame.getHeight());
1883 frame.setLayer(JLayeredPane.PALETTE_LAYER);
1884 frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
1886 public void internalFrameClosed(
1887 javax.swing.event.InternalFrameEvent evt)
1889 alignPanel.setOverviewPanel(null);
1894 alignPanel.setOverviewPanel(overview);
1900 * @param e DOCUMENT ME!
1902 protected void noColourmenuItem_actionPerformed(ActionEvent e)
1910 * @param e DOCUMENT ME!
1912 public void clustalColour_actionPerformed(ActionEvent e)
1914 changeColour(new ClustalxColourScheme(
1915 viewport.alignment.getSequences(), viewport.alignment.getWidth()));
1921 * @param e DOCUMENT ME!
1923 public void zappoColour_actionPerformed(ActionEvent e)
1925 changeColour(new ZappoColourScheme());
1931 * @param e DOCUMENT ME!
1933 public void taylorColour_actionPerformed(ActionEvent e)
1935 changeColour(new TaylorColourScheme());
1941 * @param e DOCUMENT ME!
1943 public void hydrophobicityColour_actionPerformed(ActionEvent e)
1945 changeColour(new HydrophobicColourScheme());
1951 * @param e DOCUMENT ME!
1953 public void helixColour_actionPerformed(ActionEvent e)
1955 changeColour(new HelixColourScheme());
1961 * @param e DOCUMENT ME!
1963 public void strandColour_actionPerformed(ActionEvent e)
1965 changeColour(new StrandColourScheme());
1971 * @param e DOCUMENT ME!
1973 public void turnColour_actionPerformed(ActionEvent e)
1975 changeColour(new TurnColourScheme());
1981 * @param e DOCUMENT ME!
1983 public void buriedColour_actionPerformed(ActionEvent e)
1985 changeColour(new BuriedColourScheme());
1991 * @param e DOCUMENT ME!
1993 public void nucleotideColour_actionPerformed(ActionEvent e)
1995 changeColour(new NucleotideColourScheme());
1998 public void annotationColour_actionPerformed(ActionEvent e)
2000 new AnnotationColourChooser(viewport, alignPanel);
2007 * @param e DOCUMENT ME!
2009 protected void applyToAllGroups_actionPerformed(ActionEvent e)
2011 viewport.setColourAppliesToAllGroups(applyToAllGroups.isSelected());
2017 * @param cs DOCUMENT ME!
2019 public void changeColour(ColourSchemeI cs)
2025 if (viewport.getAbovePIDThreshold())
2027 threshold = SliderPanel.setPIDSliderSource(alignPanel, cs,
2030 cs.setThreshold(threshold,
2031 viewport.getIgnoreGapsConsensus());
2033 viewport.setGlobalColourScheme(cs);
2037 cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
2040 if (viewport.getConservationSelected())
2043 Alignment al = (Alignment) viewport.alignment;
2044 Conservation c = new Conservation("All",
2045 ResidueProperties.propHash, 3,
2046 al.getSequences(), 0,
2050 c.verdict(false, viewport.ConsPercGaps);
2052 cs.setConservation(c);
2054 cs.setConservationInc(SliderPanel.setConservationSlider(alignPanel, cs,
2059 cs.setConservation(null);
2062 cs.setConsensus(viewport.hconsensus);
2065 viewport.setGlobalColourScheme(cs);
2067 if (viewport.getColourAppliesToAllGroups())
2069 Vector groups = viewport.alignment.getGroups();
2071 for (int i = 0; i < groups.size(); i++)
2073 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
2081 if (cs instanceof ClustalxColourScheme)
2083 sg.cs = new ClustalxColourScheme(
2084 sg.getSequences(true), sg.getWidth());
2086 else if (cs instanceof UserColourScheme)
2088 sg.cs = new UserColourScheme( ( (UserColourScheme) cs).getColours());
2094 sg.cs = (ColourSchemeI) cs.getClass().newInstance();
2096 catch (Exception ex)
2101 if (viewport.getAbovePIDThreshold()
2102 || cs instanceof PIDColourScheme
2103 || cs instanceof Blosum62ColourScheme)
2105 sg.cs.setThreshold(threshold,
2106 viewport.getIgnoreGapsConsensus());
2108 sg.cs.setConsensus(AAFrequency.calculate(
2109 sg.getSequences(true), 0,
2113 sg.cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
2116 if (viewport.getConservationSelected())
2118 Conservation c = new Conservation("Group",
2119 ResidueProperties.propHash, 3,
2120 sg.getSequences(true), 0,
2121 viewport.alignment.getWidth() - 1);
2123 c.verdict(false, viewport.ConsPercGaps);
2124 sg.cs.setConservation(c);
2127 sg.cs.setConservation(null);
2131 if (alignPanel.getOverviewPanel() != null)
2133 alignPanel.getOverviewPanel().updateOverviewImage();
2136 alignPanel.repaint();
2142 * @param e DOCUMENT ME!
2144 protected void modifyPID_actionPerformed(ActionEvent e)
2146 if (viewport.getAbovePIDThreshold() && viewport.globalColourScheme!=null)
2148 SliderPanel.setPIDSliderSource(alignPanel,
2149 viewport.getGlobalColourScheme(),
2151 SliderPanel.showPIDSlider();
2158 * @param e DOCUMENT ME!
2160 protected void modifyConservation_actionPerformed(ActionEvent e)
2162 if (viewport.getConservationSelected() && viewport.globalColourScheme!=null)
2164 SliderPanel.setConservationSlider(alignPanel,
2165 viewport.globalColourScheme,
2167 SliderPanel.showConservationSlider();
2174 * @param e DOCUMENT ME!
2176 protected void conservationMenuItem_actionPerformed(ActionEvent e)
2178 viewport.setConservationSelected(conservationMenuItem.isSelected());
2180 viewport.setAbovePIDThreshold(false);
2181 abovePIDThreshold.setSelected(false);
2183 changeColour(viewport.getGlobalColourScheme());
2185 modifyConservation_actionPerformed(null);
2191 * @param e DOCUMENT ME!
2193 public void abovePIDThreshold_actionPerformed(ActionEvent e)
2195 viewport.setAbovePIDThreshold(abovePIDThreshold.isSelected());
2197 conservationMenuItem.setSelected(false);
2198 viewport.setConservationSelected(false);
2200 changeColour(viewport.getGlobalColourScheme());
2202 modifyPID_actionPerformed(null);
2208 * @param e DOCUMENT ME!
2210 public void userDefinedColour_actionPerformed(ActionEvent e)
2212 if (e.getActionCommand().equals("User Defined..."))
2214 new UserDefinedColours(alignPanel, null);
2218 UserColourScheme udc = (UserColourScheme) UserDefinedColours.
2219 getUserColourSchemes().get(e.getActionCommand());
2225 public void updateUserColourMenu()
2228 Component[] menuItems = colourMenu.getMenuComponents();
2229 int i, iSize = menuItems.length;
2230 for (i = 0; i < iSize; i++)
2232 if (menuItems[i].getName() != null &&
2233 menuItems[i].getName().equals("USER_DEFINED"))
2235 colourMenu.remove(menuItems[i]);
2239 if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null)
2241 java.util.Enumeration userColours = jalview.gui.UserDefinedColours.
2242 getUserColourSchemes().keys();
2244 while (userColours.hasMoreElements())
2246 final JRadioButtonMenuItem radioItem = new JRadioButtonMenuItem(userColours.
2247 nextElement().toString());
2248 radioItem.setName("USER_DEFINED");
2249 radioItem.addMouseListener(new MouseAdapter()
2251 public void mousePressed(MouseEvent evt)
2253 if(evt.isControlDown() || SwingUtilities.isRightMouseButton(evt))
2255 radioItem.removeActionListener(radioItem.getActionListeners()[0]);
2257 int option = JOptionPane.showInternalConfirmDialog(jalview.gui.Desktop.desktop,
2258 "Remove from default list?",
2259 "Remove user defined colour",
2260 JOptionPane.YES_NO_OPTION);
2261 if(option == JOptionPane.YES_OPTION)
2263 jalview.gui.UserDefinedColours.removeColourFromDefaults(radioItem.getText());
2264 colourMenu.remove(radioItem);
2267 radioItem.addActionListener(new ActionListener()
2269 public void actionPerformed(ActionEvent evt)
2271 userDefinedColour_actionPerformed(evt);
2277 radioItem.addActionListener(new ActionListener()
2279 public void actionPerformed(ActionEvent evt)
2281 userDefinedColour_actionPerformed(evt);
2285 colourMenu.insert(radioItem, 15);
2286 colours.add(radioItem);
2294 * @param e DOCUMENT ME!
2296 public void PIDColour_actionPerformed(ActionEvent e)
2298 changeColour(new PIDColourScheme());
2304 * @param e DOCUMENT ME!
2306 public void BLOSUM62Colour_actionPerformed(ActionEvent e)
2308 changeColour(new Blosum62ColourScheme());
2314 * @param e DOCUMENT ME!
2316 public void sortPairwiseMenuItem_actionPerformed(ActionEvent e)
2318 SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray();
2319 AlignmentSorter.sortByPID(viewport.getAlignment(),
2320 viewport.getAlignment().getSequenceAt(0));
2321 addHistoryItem(new OrderCommand("Pairwise Sort", oldOrder, viewport.alignment));
2322 alignPanel.repaint();
2328 * @param e DOCUMENT ME!
2330 public void sortIDMenuItem_actionPerformed(ActionEvent e)
2332 SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray();
2333 AlignmentSorter.sortByID(viewport.getAlignment());
2334 addHistoryItem(new OrderCommand("ID Sort", oldOrder, viewport.alignment));
2335 alignPanel.repaint();
2341 * @param e DOCUMENT ME!
2343 public void sortGroupMenuItem_actionPerformed(ActionEvent e)
2345 SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray();
2346 AlignmentSorter.sortByGroup(viewport.getAlignment());
2347 addHistoryItem(new OrderCommand("Group Sort", oldOrder, viewport.alignment));
2349 alignPanel.repaint();
2355 * @param e DOCUMENT ME!
2357 public void removeRedundancyMenuItem_actionPerformed(ActionEvent e)
2359 new RedundancyPanel(alignPanel, this);
2366 * @param e DOCUMENT ME!
2368 public void pairwiseAlignmentMenuItem_actionPerformed(ActionEvent e)
2370 if ( (viewport.getSelectionGroup() == null) ||
2371 (viewport.getSelectionGroup().getSize(false) < 2))
2373 JOptionPane.showInternalMessageDialog(this,
2374 "You must select at least 2 sequences.",
2375 "Invalid Selection",
2376 JOptionPane.WARNING_MESSAGE);
2380 JInternalFrame frame = new JInternalFrame();
2381 frame.setContentPane(new PairwiseAlignPanel(viewport));
2382 Desktop.addInternalFrame(frame, "Pairwise Alignment", 600, 500);
2389 * @param e DOCUMENT ME!
2391 public void PCAMenuItem_actionPerformed(ActionEvent e)
2393 if ( ( (viewport.getSelectionGroup() != null) &&
2394 (viewport.getSelectionGroup().getSize(false) < 4) &&
2395 (viewport.getSelectionGroup().getSize(false) > 0)) ||
2396 (viewport.getAlignment().getHeight() < 4))
2398 JOptionPane.showInternalMessageDialog(this,
2399 "Principal component analysis must take\n" +
2400 "at least 4 input sequences.",
2401 "Sequence selection insufficient",
2402 JOptionPane.WARNING_MESSAGE);
2407 new PCAPanel(viewport);
2411 public void autoCalculate_actionPerformed(ActionEvent e)
2413 viewport.autoCalculateConsensus = autoCalculate.isSelected();
2414 if(viewport.autoCalculateConsensus)
2416 viewport.firePropertyChange("alignment",
2418 viewport.getAlignment().getSequences());
2426 * @param e DOCUMENT ME!
2428 public void averageDistanceTreeMenuItem_actionPerformed(ActionEvent e)
2430 NewTreePanel("AV", "PID", "Average distance tree using PID");
2436 * @param e DOCUMENT ME!
2438 public void neighbourTreeMenuItem_actionPerformed(ActionEvent e)
2440 NewTreePanel("NJ", "PID", "Neighbour joining tree using PID");
2446 * @param e DOCUMENT ME!
2448 protected void njTreeBlosumMenuItem_actionPerformed(ActionEvent e)
2450 NewTreePanel("NJ", "BL", "Neighbour joining tree using BLOSUM62");
2456 * @param e DOCUMENT ME!
2458 protected void avTreeBlosumMenuItem_actionPerformed(ActionEvent e)
2460 NewTreePanel("AV", "BL", "Average distance tree using BLOSUM62");
2466 * @param type DOCUMENT ME!
2467 * @param pwType DOCUMENT ME!
2468 * @param title DOCUMENT ME!
2470 void NewTreePanel(String type, String pwType, String title)
2474 if (viewport.getSelectionGroup() != null) {
2475 if (viewport.getSelectionGroup().getSize(false) < 3) {
2476 JOptionPane.showMessageDialog(Desktop.desktop,
2477 "You need to have more than two sequences selected to build a tree!",
2478 "Not enough sequences",
2479 JOptionPane.WARNING_MESSAGE);
2484 SequenceGroup sg = viewport.getSelectionGroup();
2486 /* Decide if the selection is a column region */
2487 while (s < sg.getSize(false))
2489 if ( ( (SequenceI) sg.getSequences(false).elementAt(s++)).getLength() <
2492 JOptionPane.showMessageDialog(Desktop.desktop,
2493 "The selected region to create a tree may\nonly contain residues or gaps.\n" +
2494 "Try using the Pad function in the edit menu,\n" +
2495 "or one of the multiple sequence alignment web services.",
2496 "Sequences in selection are not aligned",
2497 JOptionPane.WARNING_MESSAGE);
2503 title = title + " on region";
2504 tp = new TreePanel(alignPanel, type, pwType);
2508 //are the sequences aligned?
2509 if (!viewport.alignment.isAligned())
2511 JOptionPane.showMessageDialog(Desktop.desktop,
2512 "The sequences must be aligned before creating a tree.\n" +
2513 "Try using the Pad function in the edit menu,\n" +
2514 "or one of the multiple sequence alignment web services.",
2515 "Sequences not aligned",
2516 JOptionPane.WARNING_MESSAGE);
2521 if(viewport.alignment.getHeight()<2)
2524 tp = new TreePanel(alignPanel, type, pwType);
2527 addTreeMenuItem(tp, title);
2529 Desktop.addInternalFrame(tp, title + " from " + this.title, 600, 500);
2535 * @param title DOCUMENT ME!
2536 * @param order DOCUMENT ME!
2538 public void addSortByOrderMenuItem(String title, final AlignmentOrder order)
2540 final JMenuItem item = new JMenuItem("by " + title);
2542 item.addActionListener(new java.awt.event.ActionListener()
2544 public void actionPerformed(ActionEvent e)
2546 SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray();
2548 // TODO: JBPNote - have to map order entries to curent SequenceI pointers
2549 AlignmentSorter.sortBy(viewport.getAlignment(), order);
2551 addHistoryItem(new OrderCommand(order.getName(), oldOrder, viewport.alignment));
2553 alignPanel.repaint();
2559 * Maintain the Order by->Displayed Tree menu.
2560 * Creates a new menu item for a TreePanel with an appropriate
2561 * <code>jalview.analysis.AlignmentSorter</code> call. Listeners are added
2562 * to remove the menu item when the treePanel is closed, and adjust
2563 * the tree leaf to sequence mapping when the alignment is modified.
2564 * @param treePanel Displayed tree window.
2565 * @param title SortBy menu item title.
2567 void addTreeMenuItem(final TreePanel treePanel, String title)
2569 final JMenuItem item = new JMenuItem(title);
2575 sort.add(sortByTreeMenu);
2578 sortByTreeMenu.add(item);
2579 item.addActionListener(new java.awt.event.ActionListener()
2581 public void actionPerformed(ActionEvent e)
2583 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
2584 AlignmentSorter.sortByTree(viewport.getAlignment(),
2585 treePanel.getTree());
2587 addHistoryItem(new OrderCommand("Tree Sort",
2589 viewport.alignment));
2592 alignPanel.repaint();
2596 treePanel.addInternalFrameListener(new javax.swing.event.
2597 InternalFrameAdapter()
2599 public void internalFrameClosed(
2600 javax.swing.event.InternalFrameEvent evt)
2603 sortByTreeMenu.remove(item);
2607 sort.remove(sortByTreeMenu);
2615 * Work out whether the whole set of sequences
2616 * or just the selected set will be submitted for multiple alignment.
2619 private jalview.datamodel.AlignmentView gatherSequencesForAlignment()
2621 // Now, check we have enough sequences
2622 AlignmentView msa = null;
2624 if ( (viewport.getSelectionGroup() != null) &&
2625 (viewport.getSelectionGroup().getSize(false) > 1))
2627 // JBPNote UGLY! To prettify, make SequenceGroup and Alignment conform to some common interface!
2628 /*SequenceGroup seqs = viewport.getSelectionGroup();
2630 msa = new SequenceI[sz = seqs.getSize(false)];
2632 for (int i = 0; i < sz; i++)
2634 msa[i] = (SequenceI) seqs.getSequenceAt(i);
2636 msa = viewport.getAlignmentView(true);
2640 /*Vector seqs = viewport.getAlignment().getSequences();
2642 if (seqs.size() > 1)
2644 msa = new SequenceI[seqs.size()];
2646 for (int i = 0; i < seqs.size(); i++)
2648 msa[i] = (SequenceI) seqs.elementAt(i);
2651 msa = viewport.getAlignmentView(false);
2657 * Decides what is submitted to a secondary structure prediction service,
2658 * the currently selected sequence, or the currently selected alignment
2659 * (where the first sequence in the set is the one that the prediction
2662 AlignmentView gatherSeqOrMsaForSecStrPrediction()
2664 AlignmentView seqs = null;
2666 if ( (viewport.getSelectionGroup() != null) &&
2667 (viewport.getSelectionGroup().getSize(false) > 0))
2669 seqs = viewport.getAlignmentView(true);
2673 seqs = viewport.getAlignmentView(false);
2675 // limit sequences - JBPNote in future - could spawn multiple prediction jobs
2676 // TODO: viewport.alignment.isAligned is a global state - the local selection may well be aligned - we preserve 2.0.8 behaviour for moment.
2677 if (!viewport.alignment.isAligned())
2679 seqs.setSequences(new SeqCigar[] { seqs.getSequences()[0] } );
2686 * @param e DOCUMENT ME!
2688 protected void LoadtreeMenuItem_actionPerformed(ActionEvent e)
2690 // Pick the tree file
2691 JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
2694 chooser.setFileView(new JalviewFileView());
2695 chooser.setDialogTitle("Select a newick-like tree file");
2696 chooser.setToolTipText("Load a tree file");
2698 int value = chooser.showOpenDialog(null);
2700 if (value == JalviewFileChooser.APPROVE_OPTION)
2702 String choice = chooser.getSelectedFile().getPath();
2703 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
2707 jalview.io.NewickFile fin = new jalview.io.NewickFile(choice,
2709 viewport.setCurrentTree(ShowNewickTree(fin, choice).getTree());
2711 catch (Exception ex)
2713 JOptionPane.showMessageDialog(Desktop.desktop,
2714 "Problem reading tree file",
2716 JOptionPane.WARNING_MESSAGE);
2717 ex.printStackTrace();
2723 public TreePanel ShowNewickTree(NewickFile nf, String title)
2725 return ShowNewickTree(nf,title,600,500,4,5);
2727 public TreePanel ShowNewickTree(NewickFile nf, String title, AlignmentView input)
2729 return ShowNewickTree(nf,title, input, 600,500,4,5);
2731 public TreePanel ShowNewickTree(NewickFile nf, String title, int w,int h,int x, int y) {
2732 return ShowNewickTree(nf, title, null, w, h, x, y);
2735 * Add a treeviewer for the tree extracted from a newick file object to the current alignment view
2737 * @param nf the tree
2738 * @param title tree viewer title
2739 * @param input Associated alignment input data (or null)
2744 * @return TreePanel handle
2746 public TreePanel ShowNewickTree(NewickFile nf, String title, AlignmentView input, int w,int h,int x, int y) {
2747 TreePanel tp = null;
2753 if (nf.getTree() != null)
2755 tp = new TreePanel(alignPanel,
2763 tp.setLocation(x,y);
2766 Desktop.addInternalFrame(tp, title, w, h);
2767 addTreeMenuItem(tp, title);
2770 catch (Exception ex)
2772 ex.printStackTrace();
2783 PrinterJob printJob = PrinterJob.getPrinterJob();
2784 PageFormat pf = printJob.pageDialog(printJob.defaultPage());
2785 printJob.setPrintable(alignPanel, pf);
2787 if (printJob.printDialog())
2793 catch (Exception PrintException)
2795 PrintException.printStackTrace();
2802 * Generates menu items and listener event actions for web service clients
2805 public void BuildWebServiceMenu()
2807 if ( (Discoverer.services != null)
2808 && (Discoverer.services.size() > 0))
2810 Vector msaws = (Vector) Discoverer.services.get("MsaWS");
2811 Vector secstrpr = (Vector) Discoverer.services.get("SecStrPred");
2812 Vector wsmenu = new Vector();
2813 final AlignFrame af = this;
2816 // Add any Multiple Sequence Alignment Services
2817 final JMenu msawsmenu = new JMenu("Alignment");
2818 for (int i = 0, j = msaws.size(); i < j; i++)
2820 final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) msaws.
2822 final JMenuItem method = new JMenuItem(sh.getName());
2823 method.addActionListener(new ActionListener()
2825 public void actionPerformed(ActionEvent e)
2827 AlignmentView msa = gatherSequencesForAlignment();
2828 new jalview.ws.MsaWSClient(sh, title, msa,
2829 false, true, viewport.getAlignment().getDataset(), af);
2834 msawsmenu.add(method);
2835 // Deal with services that we know accept partial alignments.
2836 if (sh.getName().indexOf("lustal") > -1)
2838 // We know that ClustalWS can accept partial alignments for refinement.
2839 final JMenuItem methodR = new JMenuItem(sh.getName()+" Realign");
2840 methodR.addActionListener(new ActionListener()
2842 public void actionPerformed(ActionEvent e)
2844 AlignmentView msa = gatherSequencesForAlignment();
2845 new jalview.ws.MsaWSClient(sh, title, msa,
2846 true, true, viewport.getAlignment().getDataset(), af);
2851 msawsmenu.add(methodR);
2855 wsmenu.add(msawsmenu);
2857 if (secstrpr != null)
2859 // Add any secondary structure prediction services
2860 final JMenu secstrmenu = new JMenu("Secondary Structure Prediction");
2861 for (int i = 0, j = secstrpr.size(); i < j; i++)
2863 final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle)
2865 final JMenuItem method = new JMenuItem(sh.getName());
2866 method.addActionListener(new ActionListener()
2868 public void actionPerformed(ActionEvent e)
2870 AlignmentView msa = gatherSeqOrMsaForSecStrPrediction();
2871 if (msa.getSequences().length == 1)
2873 // Single Sequence prediction
2874 new jalview.ws.JPredClient(sh, title, false, msa, af, true);
2878 if (msa.getSequences().length > 1)
2880 // Sequence profile based prediction
2881 new jalview.ws.JPredClient(sh,
2882 title, true, msa, af, true);
2887 secstrmenu.add(method);
2889 wsmenu.add(secstrmenu);
2891 this.webService.removeAll();
2892 for (int i = 0, j = wsmenu.size(); i < j; i++)
2894 webService.add( (JMenu) wsmenu.get(i));
2899 this.webService.removeAll();
2900 this.webService.add(this.webServiceNoServices);
2902 // TODO: add in rediscovery function
2903 // TODO: reduce code redundancy.
2904 // TODO: group services by location as well as function.
2907 /* public void vamsasStore_actionPerformed(ActionEvent e)
2909 JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
2910 getProperty("LAST_DIRECTORY"));
2912 chooser.setFileView(new JalviewFileView());
2913 chooser.setDialogTitle("Export to Vamsas file");
2914 chooser.setToolTipText("Export");
2916 int value = chooser.showSaveDialog(this);
2918 if (value == JalviewFileChooser.APPROVE_OPTION)
2920 jalview.io.VamsasDatastore vs = new jalview.io.VamsasDatastore(viewport);
2921 //vs.store(chooser.getSelectedFile().getAbsolutePath() );
2922 vs.storeJalview( chooser.getSelectedFile().getAbsolutePath(), this);
2929 public void showTranslation_actionPerformed(ActionEvent e)
2931 SequenceI [] selection = viewport.getSelectionAsNewSequence();
2932 String [] seqstring = viewport.getViewAsString(true);
2934 int s, sSize = selection.length;
2935 SequenceI [] newSeq = new SequenceI[sSize];
2938 StringBuffer protein;
2940 for(s=0; s<sSize; s++)
2942 protein = new StringBuffer();
2943 seq = AlignSeq.extractGaps("-. ", seqstring[s]);
2944 resSize = seq.length();
2945 resSize -= resSize%3;
2947 for(res = 0; res < resSize; res+=3)
2949 String codon = seq.substring(res, res+3);
2950 codon = codon.replace('U', 'T');
2951 String aa = ResidueProperties.codonTranslate(codon);
2953 protein.append(viewport.getGapCharacter());
2954 else if(aa.equals("STOP"))
2955 protein.append("X");
2957 protein.append( aa );
2959 newSeq[s] = new Sequence(selection[s].getName(),
2960 protein.toString());
2964 AlignmentI al = new Alignment(newSeq);
2965 al.setDataset(null);
2968 ////////////////////////////////
2969 // Copy annotations across
2970 jalview.datamodel.AlignmentAnnotation[] annotations
2971 = viewport.alignment.getAlignmentAnnotation();
2973 if(annotations!=null)
2975 for (int i = 0; i < annotations.length; i++)
2977 if (annotations[i].label.equals("Quality") ||
2978 annotations[i].label.equals("Conservation") ||
2979 annotations[i].label.equals("Consensus"))
2984 aSize = viewport.alignment.getWidth() / 3;
2985 jalview.datamodel.Annotation[] anots =
2986 new jalview.datamodel.Annotation[aSize];
2988 for (a = 0; a < viewport.alignment.getWidth(); a++)
2990 if (annotations[i].annotations[a] == null
2991 || annotations[i].annotations[a] == null)
2994 anots[a / 3] = new Annotation(
2995 annotations[i].annotations[a].displayCharacter,
2996 annotations[i].annotations[a].description,
2997 annotations[i].annotations[a].secondaryStructure,
2998 annotations[i].annotations[a].value,
2999 annotations[i].annotations[a].colour);
3002 jalview.datamodel.AlignmentAnnotation aa
3003 = new jalview.datamodel.AlignmentAnnotation(annotations[i].label,
3004 annotations[i].description, anots);
3005 al.addAnnotation(aa);
3009 AlignFrame af = new AlignFrame(al, DEFAULT_WIDTH, DEFAULT_HEIGHT);
3010 Desktop.addInternalFrame(af, "Translation of "+this.getTitle(),
3022 * @param String DOCUMENT ME!
3024 public boolean parseFeaturesFile(String file, String type)
3026 boolean featuresFile = false;
3028 featuresFile = new FeaturesFile(file, type).parse(viewport.alignment.getDataset(),
3029 alignPanel.seqPanel.seqCanvas.
3030 getFeatureRenderer().featureColours,
3035 ex.printStackTrace();
3040 viewport.showSequenceFeatures = true;
3041 showSeqFeatures.setSelected(true);
3042 alignPanel.repaint();
3045 return featuresFile;
3048 public void dragEnter(DropTargetDragEvent evt)
3051 public void dragExit(DropTargetEvent evt)
3054 public void dragOver(DropTargetDragEvent evt)
3057 public void dropActionChanged(DropTargetDragEvent evt)
3060 public void drop(DropTargetDropEvent evt)
3062 Transferable t = evt.getTransferable();
3063 java.util.List files = null;
3067 DataFlavor uriListFlavor = new DataFlavor("text/uri-list;class=java.lang.String");
3068 if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor))
3070 //Works on Windows and MacOSX
3071 evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
3072 files = (java.util.List) t.getTransferData(DataFlavor.javaFileListFlavor);
3074 else if (t.isDataFlavorSupported(uriListFlavor))
3076 // This is used by Unix drag system
3077 evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
3078 String data = (String) t.getTransferData(uriListFlavor);
3079 files = new java.util.ArrayList(1);
3080 for (java.util.StringTokenizer st = new java.util.StringTokenizer(
3083 st.hasMoreTokens(); )
3085 String s = st.nextToken();
3086 if (s.startsWith("#"))
3088 // the line is a comment (as per the RFC 2483)
3092 java.net.URI uri = new java.net.URI(s);
3093 java.io.File file = new java.io.File(uri);
3100 e.printStackTrace();
3107 for (int i = 0; i < files.size(); i++)
3109 loadJalviewDataFile(files.get(i).toString());
3112 catch (Exception ex)
3114 ex.printStackTrace();
3119 // This method will attempt to load a "dropped" file first by testing
3120 // whether its and Annotation file, then features file. If both are
3121 // false then the user may have dropped an alignment file onto this
3123 public void loadJalviewDataFile(String file)
3126 String protocol = "File";
3128 if (file.indexOf("http:") > -1 || file.indexOf("file:") > -1)
3133 boolean isAnnotation = new AnnotationFile().readAnnotationFile(viewport.
3138 boolean isGroupsFile = parseFeaturesFile(file,protocol);
3141 String format = new IdentifyFile().Identify(file, protocol);
3143 if(format.equalsIgnoreCase("JnetFile"))
3145 jalview.io.JPredFile predictions = new jalview.io.JPredFile(
3147 new JnetAnnotationMaker().add_annotation(predictions,
3148 viewport.getAlignment(),
3150 alignPanel.adjustAnnotationHeight();
3151 alignPanel.repaint();
3154 new FileLoader().LoadFile(viewport, file, protocol, format);
3160 alignPanel.adjustAnnotationHeight();
3163 }catch(Exception ex)
3165 ex.printStackTrace();
3169 public void tabSelectionChanged(int index)
3173 alignPanel = (AlignmentPanel) alignPanels.elementAt(index);
3174 viewport = alignPanel.av;
3178 public void tabbedPane_mousePressed(MouseEvent e)
3180 if(SwingUtilities.isRightMouseButton(e))
3182 String reply = JOptionPane.showInternalInputDialog(this,
3185 JOptionPane.QUESTION_MESSAGE);
3189 viewport.viewName = reply;
3190 tabbedPane.setTitleAt( tabbedPane.getSelectedIndex() ,reply);
3196 public AlignViewport getCurrentView()