2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
3 * Copyright (C) 2008 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 Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26 import java.awt.datatransfer.*;
27 import java.awt.dnd.*;
28 import java.awt.event.*;
29 import java.awt.print.*;
31 import javax.swing.event.MenuEvent;
33 import jalview.analysis.*;
34 import jalview.commands.*;
35 import jalview.datamodel.*;
37 import jalview.jbgui.*;
38 import jalview.schemes.*;
47 public class AlignFrame
48 extends GAlignFrame implements DropTargetListener, IProgressIndicator
51 public static final int DEFAULT_WIDTH = 700;
54 public static final int DEFAULT_HEIGHT = 500;
55 public AlignmentPanel alignPanel;
57 AlignViewport viewport;
59 Vector alignPanels = new Vector();
63 * Last format used to load or save alignments in this window
65 String currentFileFormat = null;
67 * Current filename for this alignment
69 String fileName = null;
75 * Creates a new AlignFrame object.
77 * @param al DOCUMENT ME!
79 public AlignFrame(AlignmentI al, int width, int height)
81 this(al, null, width, height);
86 * new alignment window with hidden columns
87 * @param al AlignmentI
88 * @param hiddenColumns ColumnSelection or null
90 public AlignFrame(AlignmentI al, ColumnSelection hiddenColumns,
91 int width, int height)
93 this.setSize(width, height);
94 viewport = new AlignViewport(al, hiddenColumns);
96 alignPanel = new AlignmentPanel(this, viewport);
98 if(al.getDataset()==null)
103 addAlignmentPanel(alignPanel, true);
108 * Make a new AlignFrame from exisiting alignmentPanels
109 * @param ap AlignmentPanel
110 * @param av AlignViewport
112 public AlignFrame(AlignmentPanel ap)
116 addAlignmentPanel(ap, false);
122 if (viewport.conservation == null)
124 BLOSUM62Colour.setEnabled(false);
125 conservationMenuItem.setEnabled(false);
126 modifyConservation.setEnabled(false);
127 // PIDColour.setEnabled(false);
128 // abovePIDThreshold.setEnabled(false);
129 // modifyPID.setEnabled(false);
132 String sortby = jalview.bin.Cache.getDefault("SORT_ALIGNMENT", "No sort");
134 if (sortby.equals("Id"))
136 sortIDMenuItem_actionPerformed(null);
138 else if (sortby.equals("Pairwise Identity"))
140 sortPairwiseMenuItem_actionPerformed(null);
143 if (Desktop.desktop != null)
145 this.setDropTarget(new java.awt.dnd.DropTarget(this, this));
146 addServiceListeners();
147 setGUINucleotide(viewport.alignment.isNucleotide());
150 setMenusFromViewport(viewport);
151 buildSortByAnnotationScoresMenu();
152 if (viewport.wrapAlignment)
154 wrapMenuItem_actionPerformed(null);
157 if (jalview.bin.Cache.getDefault("SHOW_OVERVIEW",false))
159 this.overviewMenuItem_actionPerformed(null);
166 * Change the filename and format for the alignment, and
167 * enable the 'reload' button functionality.
168 * @param file valid filename
169 * @param format format of file
171 public void setFileName(String file, String format)
174 currentFileFormat = format;
175 reload.setEnabled(true);
178 void addKeyListener()
180 addKeyListener(new KeyAdapter()
182 public void keyPressed(KeyEvent evt)
184 if (viewport.cursorMode &&
185 ( (evt.getKeyCode() >= KeyEvent.VK_0 &&
186 evt.getKeyCode() <= KeyEvent.VK_9)
188 (evt.getKeyCode() >= KeyEvent.VK_NUMPAD0 &&
189 evt.getKeyCode() <= KeyEvent.VK_NUMPAD9)
191 && Character.isDigit(evt.getKeyChar()))
192 alignPanel.seqPanel.numberPressed(evt.getKeyChar());
194 switch (evt.getKeyCode())
197 case 27: // escape key
198 deselectAllSequenceMenuItem_actionPerformed(null);
202 case KeyEvent.VK_DOWN:
203 if (evt.isAltDown() || !viewport.cursorMode)
204 moveSelectedSequences(false);
205 if (viewport.cursorMode)
206 alignPanel.seqPanel.moveCursor(0, 1);
210 if (evt.isAltDown() || !viewport.cursorMode)
211 moveSelectedSequences(true);
212 if (viewport.cursorMode)
213 alignPanel.seqPanel.moveCursor(0, -1);
217 case KeyEvent.VK_LEFT:
218 if (evt.isAltDown() || !viewport.cursorMode)
219 slideSequences(false,
220 alignPanel.seqPanel.getKeyboardNo1());
222 alignPanel.seqPanel.moveCursor( -1, 0);
227 case KeyEvent.VK_RIGHT:
228 if (evt.isAltDown() || !viewport.cursorMode)
230 alignPanel.seqPanel.getKeyboardNo1());
232 alignPanel.seqPanel.moveCursor(1, 0);
235 case KeyEvent.VK_SPACE:
236 if (viewport.cursorMode)
238 alignPanel.seqPanel.insertGapAtCursor(evt.isControlDown()
244 case KeyEvent.VK_DELETE:
245 case KeyEvent.VK_BACK_SPACE:
246 if (!viewport.cursorMode)
248 cut_actionPerformed(null);
252 alignPanel.seqPanel.deleteGapAtCursor(evt.isControlDown()
260 if (viewport.cursorMode)
262 alignPanel.seqPanel.setCursorRow();
266 if (viewport.cursorMode && !evt.isControlDown())
268 alignPanel.seqPanel.setCursorColumn();
272 if (viewport.cursorMode)
274 alignPanel.seqPanel.setCursorPosition();
278 case KeyEvent.VK_ENTER:
279 case KeyEvent.VK_COMMA:
280 if (viewport.cursorMode)
282 alignPanel.seqPanel.setCursorRowAndColumn();
287 if (viewport.cursorMode)
289 alignPanel.seqPanel.setSelectionAreaAtCursor(true);
293 if (viewport.cursorMode)
295 alignPanel.seqPanel.setSelectionAreaAtCursor(false);
300 viewport.cursorMode = !viewport.cursorMode;
301 statusBar.setText("Keyboard editing mode is " +
302 (viewport.cursorMode ? "on" : "off"));
303 if (viewport.cursorMode)
305 alignPanel.seqPanel.seqCanvas.cursorX = viewport.startRes;
306 alignPanel.seqPanel.seqCanvas.cursorY = viewport.startSeq;
308 alignPanel.seqPanel.seqCanvas.repaint();
314 ClassLoader cl = jalview.gui.Desktop.class.getClassLoader();
315 java.net.URL url = javax.help.HelpSet.findHelpSet(cl, "help/help");
316 javax.help.HelpSet hs = new javax.help.HelpSet(cl, url);
318 javax.help.HelpBroker hb = hs.createHelpBroker();
319 hb.setCurrentID("home");
320 hb.setDisplayed(true);
324 ex.printStackTrace();
330 boolean toggleSeqs = !evt.isControlDown();
331 boolean toggleCols = !evt.isShiftDown();
333 boolean hide = false;
335 SequenceGroup sg = viewport.getSelectionGroup();
338 if (sg != null && sg.getSize() != viewport.alignment.getHeight())
340 hideSelSequences_actionPerformed(null);
343 else if (! (toggleCols &&
344 viewport.colSel.getSelected().size() > 0))
346 showAllSeqs_actionPerformed(null);
352 if (viewport.colSel.getSelected().size() > 0)
354 hideSelColumns_actionPerformed(null);
357 viewport.selectionGroup = sg;
362 showAllColumns_actionPerformed(null);
367 case KeyEvent.VK_PAGE_UP:
368 if (viewport.wrapAlignment)
370 alignPanel.scrollUp(true);
374 alignPanel.setScrollValues(viewport.startRes,
376 - viewport.endSeq + viewport.startSeq);
379 case KeyEvent.VK_PAGE_DOWN:
380 if (viewport.wrapAlignment)
382 alignPanel.scrollUp(false);
386 alignPanel.setScrollValues(viewport.startRes,
388 + viewport.endSeq - viewport.startSeq);
394 public void keyReleased(KeyEvent evt)
396 switch(evt.getKeyCode())
398 case KeyEvent.VK_LEFT:
399 if (evt.isAltDown() || !viewport.cursorMode)
400 viewport.firePropertyChange("alignment", null,
401 viewport.getAlignment().getSequences());
404 case KeyEvent.VK_RIGHT:
405 if (evt.isAltDown() || !viewport.cursorMode)
406 viewport.firePropertyChange("alignment", null,
407 viewport.getAlignment().getSequences());
415 public void addAlignmentPanel(final AlignmentPanel ap,
418 ap.alignFrame = this;
420 alignPanels.addElement(ap);
422 PaintRefresher.Register(ap, ap.av.getSequenceSetId());
424 int aSize = alignPanels.size();
426 tabbedPane.setVisible(aSize>1 || ap.av.viewName!=null);
428 if (aSize == 1 && ap.av.viewName==null)
430 this.getContentPane().add(ap, BorderLayout.CENTER);
436 setInitialTabVisible();
439 expandViews.setEnabled(true);
440 gatherViews.setEnabled(true);
441 tabbedPane.addTab(ap.av.viewName, ap);
443 ap.setVisible(false);
450 ap.av.alignment.padGaps();
452 ap.av.updateConservation(ap);
453 ap.av.updateConsensus(ap);
457 public void setInitialTabVisible()
459 expandViews.setEnabled(true);
460 gatherViews.setEnabled(true);
461 tabbedPane.setVisible(true);
462 AlignmentPanel first = (AlignmentPanel) alignPanels.firstElement();
463 tabbedPane.addTab(first.av.viewName,first);
464 this.getContentPane().add(tabbedPane, BorderLayout.CENTER);
468 public AlignViewport getViewport()
473 /* Set up intrinsic listeners for dynamically generated GUI bits. */
474 private void addServiceListeners()
476 final java.beans.PropertyChangeListener thisListener;
477 // Do this once to get current state
478 BuildWebServiceMenu();
479 Desktop.discoverer.addPropertyChangeListener(
480 thisListener = new java.beans.PropertyChangeListener()
482 public void propertyChange(PropertyChangeEvent evt)
484 // System.out.println("Discoverer property change.");
485 if (evt.getPropertyName().equals("services"))
487 // System.out.println("Rebuilding web service menu");
488 BuildWebServiceMenu();
493 addInternalFrameListener(new javax.swing.event.
494 InternalFrameAdapter()
496 public void internalFrameClosed(
497 javax.swing.event.InternalFrameEvent evt)
499 // System.out.println("deregistering discoverer listener");
500 Desktop.discoverer.removePropertyChangeListener(thisListener);
501 closeMenuItem_actionPerformed(true);
507 public void setGUINucleotide(boolean nucleotide)
509 showTranslation.setVisible( nucleotide );
510 conservationMenuItem.setEnabled( !nucleotide );
511 modifyConservation.setEnabled( !nucleotide );
513 //Remember AlignFrame always starts as protein
516 calculateMenu.remove(calculateMenu.getItemCount()-2);
522 * set up menus for the currently viewport.
523 * This may be called after any operation that affects the data in the current view (selection changed, etc) to update the menus to reflect the new state.
525 public void setMenusForViewport()
527 setMenusFromViewport(viewport);
530 * Need to call this method when tabs are selected for multiple views,
531 * or when loading from Jalview2XML.java
532 * @param av AlignViewport
534 void setMenusFromViewport(AlignViewport av)
536 padGapsMenuitem.setSelected(av.padGaps);
537 colourTextMenuItem.setSelected(av.showColourText);
538 abovePIDThreshold.setSelected(av.getAbovePIDThreshold());
539 conservationMenuItem.setSelected(av.getConservationSelected());
540 seqLimits.setSelected(av.getShowJVSuffix());
541 idRightAlign.setSelected(av.rightAlignIds);
542 centreColumnLabelsMenuItem.setState(av.centreColumnLabels);
543 renderGapsMenuItem.setSelected(av.renderGaps);
544 wrapMenuItem.setSelected(av.wrapAlignment);
545 scaleAbove.setVisible(av.wrapAlignment);
546 scaleLeft.setVisible(av.wrapAlignment);
547 scaleRight.setVisible(av.wrapAlignment);
548 annotationPanelMenuItem.setState(av.showAnnotation);
549 viewBoxesMenuItem.setSelected(av.showBoxes);
550 viewTextMenuItem.setSelected(av.showText);
552 setColourSelected(ColourSchemeProperty.
553 getColourName(av.getGlobalColourScheme()));
555 showSeqFeatures.setSelected(av.showSequenceFeatures);
556 hiddenMarkers.setState(av.showHiddenMarkers);
557 applyToAllGroups.setState(av.colourAppliesToAllGroups);
559 setShowProductsEnabled();
565 Hashtable progressBars;
567 * @see jalview.gui.IProgressIndicator#setProgressBar(java.lang.String, long)
569 public void setProgressBar(String message, long id)
571 if(progressBars == null)
573 progressBars = new Hashtable();
576 JPanel progressPanel;
577 GridLayout layout = (GridLayout) statusPanel.getLayout();
578 if(progressBars.get( new Long(id) )!=null)
580 progressPanel = (JPanel)progressBars.get( new Long(id) );
581 statusPanel.remove(progressPanel);
582 progressBars.remove( progressPanel );
583 progressPanel = null;
586 statusBar.setText(message);
589 layout.setRows(layout.getRows() - 1);
593 progressPanel = new JPanel(new BorderLayout(10, 5));
595 JProgressBar progressBar = new JProgressBar();
596 progressBar.setIndeterminate(true);
598 progressPanel.add(new JLabel(message), BorderLayout.WEST);
599 progressPanel.add(progressBar, BorderLayout.CENTER);
601 layout.setRows(layout.getRows() + 1);
602 statusPanel.add(progressPanel);
604 progressBars.put(new Long(id), progressPanel);
607 setMenusForViewport();
612 * @return true if any progress bars are still active
614 public boolean operationInProgress()
616 if (progressBars!=null && progressBars.size()>0)
623 Added so Castor Mapping file can obtain Jalview Version
625 public String getVersion()
627 return jalview.bin.Cache.getProperty("VERSION");
630 public FeatureRenderer getFeatureRenderer()
632 return alignPanel.seqPanel.seqCanvas.getFeatureRenderer();
636 public void fetchSequence_actionPerformed(ActionEvent e)
638 new SequenceFetcher(this);
641 public void addFromFile_actionPerformed(ActionEvent e)
643 Desktop.instance.inputLocalFileMenuItem_actionPerformed(viewport);
646 public void reload_actionPerformed(ActionEvent e)
650 if(currentFileFormat.equals("Jalview"))
652 JInternalFrame [] frames = Desktop.desktop.getAllFrames();
653 for(int i=0; i<frames.length; i++)
655 if (frames[i] instanceof AlignFrame
657 && ( (AlignFrame) frames[i]).fileName.equals(fileName))
661 frames[i].setSelected(true);
662 Desktop.instance.closeAssociatedWindows();
664 catch (java.beans.PropertyVetoException ex)
669 Desktop.instance.closeAssociatedWindows();
671 FileLoader loader = new FileLoader();
672 String protocol = fileName.startsWith("http:")? "URL":"File";
673 loader.LoadFile(viewport, fileName, protocol, currentFileFormat);
677 Rectangle bounds = this.getBounds();
679 FileLoader loader = new FileLoader();
680 String protocol = fileName.startsWith("http:") ? "URL" : "File";
681 AlignFrame newframe =
682 loader.LoadFileWaitTillLoaded(fileName, protocol, currentFileFormat);
684 newframe.setBounds(bounds);
686 this.closeMenuItem_actionPerformed(true);
692 public void addFromText_actionPerformed(ActionEvent e)
694 Desktop.instance.inputTextboxMenuItem_actionPerformed(viewport);
697 public void addFromURL_actionPerformed(ActionEvent e)
699 Desktop.instance.inputURLMenuItem_actionPerformed(viewport);
703 public void save_actionPerformed(ActionEvent e)
706 || (currentFileFormat==null || jalview.io.AppletFormatAdapter.isValidFormat(currentFileFormat, true))
707 || fileName.startsWith("http")
710 saveAs_actionPerformed(null);
714 saveAlignment(fileName, currentFileFormat);
721 * @param e DOCUMENT ME!
723 public void saveAs_actionPerformed(ActionEvent e)
725 JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
726 getProperty( "LAST_DIRECTORY"),
727 jalview.io.AppletFormatAdapter.WRITABLE_EXTENSIONS,
728 jalview.io.AppletFormatAdapter.WRITABLE_FNAMES,
733 chooser.setFileView(new JalviewFileView());
734 chooser.setDialogTitle("Save Alignment to file");
735 chooser.setToolTipText("Save");
737 int value = chooser.showSaveDialog(this);
739 if (value == JalviewFileChooser.APPROVE_OPTION)
741 currentFileFormat = chooser.getSelectedFormat();
742 if (currentFileFormat == null)
744 JOptionPane.showInternalMessageDialog(Desktop.desktop,
745 "You must select a file format before saving!",
746 "File format not specified",
747 JOptionPane.WARNING_MESSAGE);
748 value = chooser.showSaveDialog(this);
752 fileName = chooser.getSelectedFile().getPath();
754 jalview.bin.Cache.setProperty("DEFAULT_FILE_FORMAT",
757 jalview.bin.Cache.setProperty("LAST_DIRECTORY", fileName);
758 if (currentFileFormat.indexOf(" ")>-1)
760 currentFileFormat = currentFileFormat.substring(0, currentFileFormat.indexOf(" "));
762 saveAlignment(fileName, currentFileFormat);
766 public boolean saveAlignment(String file, String format)
768 boolean success = true;
770 if (format.equalsIgnoreCase("Jalview"))
772 String shortName = title;
774 if (shortName.indexOf(java.io.File.separatorChar) > -1)
776 shortName = shortName.substring(shortName.lastIndexOf(
777 java.io.File.separatorChar) + 1);
780 success = new Jalview2XML().SaveAlignment(this, file, shortName);
782 statusBar.setText("Successfully saved to file: "
784 +format +" format.");
789 if (!jalview.io.AppletFormatAdapter.isValidFormat(format, true))
791 // JBPNote need to have a raise_gui flag here
792 JOptionPane.showInternalMessageDialog(
793 this, "Cannot save file " + fileName + " using format "+format,
794 "Alignment output format not supported",
795 JOptionPane.WARNING_MESSAGE);
796 saveAs_actionPerformed(null);
800 String[] omitHidden = null;
802 if (viewport.hasHiddenColumns)
804 int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
805 "The Alignment contains hidden columns."
806 + "\nDo you want to save only the visible alignment?",
807 "Save / Omit Hidden Columns",
808 JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
810 if (reply == JOptionPane.YES_OPTION)
812 omitHidden = viewport.getViewAsString(false);
815 FormatAdapter f = new FormatAdapter();
816 String output = f.formatSequences(
818 (Alignment) viewport.alignment, // class cast exceptions will occur in the distant future
819 omitHidden, f.getCacheSuffixDefault(format), viewport.colSel);
829 java.io.PrintWriter out = new java.io.PrintWriter(
830 new java.io.FileWriter(file));
835 statusBar.setText("Successfully saved to file: "
837 + format + " format.");
842 ex.printStackTrace();
849 JOptionPane.showInternalMessageDialog(
850 this, "Couldn't save file: " + fileName,
852 JOptionPane.WARNING_MESSAGE);
861 * @param e DOCUMENT ME!
863 protected void outputText_actionPerformed(ActionEvent e)
865 String [] omitHidden = null;
867 if(viewport.hasHiddenColumns)
869 int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
870 "The Alignment contains hidden columns."
871 +"\nDo you want to output only the visible alignment?",
872 "Save / Omit Hidden Columns",
873 JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
875 if(reply==JOptionPane.YES_OPTION)
877 omitHidden = viewport.getViewAsString(false);
881 CutAndPasteTransfer cap = new CutAndPasteTransfer();
882 cap.setForInput(null);
883 Desktop.addInternalFrame(cap,
884 "Alignment output - " + e.getActionCommand(), 600,
888 cap.setText(new FormatAdapter().formatSequences(
889 e.getActionCommand(),
891 omitHidden, viewport.colSel));
897 * @param e DOCUMENT ME!
899 protected void htmlMenuItem_actionPerformed(ActionEvent e)
901 new HTMLOutput(alignPanel,
902 alignPanel.seqPanel.seqCanvas.getSequenceRenderer(),
903 alignPanel.seqPanel.seqCanvas.getFeatureRenderer());
906 public void createImageMap(File file, String image)
908 alignPanel.makePNGImageMap(file, image);
914 * @param e DOCUMENT ME!
916 public void createPNG(File f)
918 alignPanel.makePNG(f);
924 * @param e DOCUMENT ME!
926 public void createEPS(File f)
928 alignPanel.makeEPS(f);
932 public void pageSetup_actionPerformed(ActionEvent e)
934 PrinterJob printJob = PrinterJob.getPrinterJob();
935 PrintThread.pf = printJob.pageDialog(printJob.defaultPage());
941 * @param e DOCUMENT ME!
943 public void printMenuItem_actionPerformed(ActionEvent e)
945 //Putting in a thread avoids Swing painting problems
946 PrintThread thread = new PrintThread(alignPanel);
950 public void exportFeatures_actionPerformed(ActionEvent e)
952 new AnnotationExporter().exportFeatures(alignPanel);
956 public void exportAnnotations_actionPerformed(ActionEvent e)
958 new AnnotationExporter().exportAnnotations(
960 viewport.showAnnotation ? viewport.alignment.getAlignmentAnnotation() : null,
961 viewport.alignment.getGroups(),
962 ((Alignment)viewport.alignment).alignmentProperties
967 public void associatedData_actionPerformed(ActionEvent e)
969 // Pick the tree file
970 JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
973 chooser.setFileView(new JalviewFileView());
974 chooser.setDialogTitle("Load Jalview Annotations or Features File");
975 chooser.setToolTipText("Load Jalview Annotations / Features file");
977 int value = chooser.showOpenDialog(null);
979 if (value == JalviewFileChooser.APPROVE_OPTION)
981 String choice = chooser.getSelectedFile().getPath();
982 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
983 loadJalviewDataFile(choice);
992 * @param e DOCUMENT ME!
994 public void closeMenuItem_actionPerformed(boolean closeAllTabs)
996 if(alignPanels!=null && alignPanels.size()<2)
1003 if(alignPanels!=null)
1007 for (int i = 0; i < alignPanels.size(); i++)
1009 AlignmentPanel ap = (AlignmentPanel) alignPanels.elementAt(i);
1010 jalview.structure.StructureSelectionManager.getStructureSelectionManager()
1011 .removeStructureViewerListener(ap.seqPanel, null);
1012 PaintRefresher.RemoveComponent(ap.seqPanel.seqCanvas);
1013 PaintRefresher.RemoveComponent(ap.idPanel.idCanvas);
1014 PaintRefresher.RemoveComponent(ap);
1015 ap.av.alignment = null;
1020 int index = tabbedPane.getSelectedIndex();
1022 alignPanels.removeElement(alignPanel);
1023 PaintRefresher.RemoveComponent(alignPanel.seqPanel.seqCanvas);
1024 PaintRefresher.RemoveComponent(alignPanel.idPanel.idCanvas);
1025 PaintRefresher.RemoveComponent(alignPanel);
1026 viewport.alignment = null;
1030 tabbedPane.removeTabAt(index);
1031 tabbedPane.validate();
1033 if(index==tabbedPane.getTabCount())
1038 this.tabSelectionChanged(index);
1044 this.setClosed(true);
1047 catch (Exception ex)
1049 ex.printStackTrace();
1057 void updateEditMenuBar()
1060 if (viewport.historyList.size() > 0)
1062 undoMenuItem.setEnabled(true);
1063 CommandI command = (CommandI) viewport.historyList.peek();
1064 undoMenuItem.setText("Undo " + command.getDescription());
1068 undoMenuItem.setEnabled(false);
1069 undoMenuItem.setText("Undo");
1072 if (viewport.redoList.size() > 0)
1074 redoMenuItem.setEnabled(true);
1076 CommandI command = (CommandI) viewport.redoList.peek();
1077 redoMenuItem.setText("Redo " + command.getDescription());
1081 redoMenuItem.setEnabled(false);
1082 redoMenuItem.setText("Redo");
1087 public void addHistoryItem(CommandI command)
1089 if(command.getSize()>0)
1091 viewport.historyList.push(command);
1092 viewport.redoList.clear();
1093 updateEditMenuBar();
1094 viewport.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;
1100 * @return alignment objects for all views
1102 AlignmentI[] getViewAlignments()
1104 if (alignPanels!=null)
1106 Enumeration e = alignPanels.elements();
1107 AlignmentI[] als = new AlignmentI[alignPanels.size()];
1108 for (int i=0; e.hasMoreElements(); i++)
1110 als[i] = ((AlignmentPanel) e.nextElement()).av.getAlignment();
1116 return new AlignmentI[] { viewport.alignment };
1123 * @param e DOCUMENT ME!
1125 protected void undoMenuItem_actionPerformed(ActionEvent e)
1127 if (viewport.historyList.empty())
1129 CommandI command = (CommandI)viewport.historyList.pop();
1130 viewport.redoList.push(command);
1131 command.undoCommand(getViewAlignments());
1133 AlignViewport originalSource = getOriginatingSource(command);
1134 updateEditMenuBar();
1136 if(originalSource!=null)
1138 originalSource.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;
1139 originalSource.firePropertyChange("alignment",
1141 originalSource.alignment.getSequences());
1148 * @param e DOCUMENT ME!
1150 protected void redoMenuItem_actionPerformed(ActionEvent e)
1152 if(viewport.redoList.size()<1)
1157 CommandI command = (CommandI) viewport.redoList.pop();
1158 viewport.historyList.push(command);
1159 command.doCommand(getViewAlignments());
1161 AlignViewport originalSource = getOriginatingSource(command);
1162 updateEditMenuBar();
1164 if(originalSource!=null)
1166 originalSource.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;
1167 originalSource.firePropertyChange("alignment",
1169 originalSource.alignment.getSequences());
1173 AlignViewport getOriginatingSource(CommandI command)
1175 AlignViewport originalSource = null;
1176 //For sequence removal and addition, we need to fire
1177 //the property change event FROM the viewport where the
1178 //original alignment was altered
1180 if (command instanceof EditCommand)
1182 EditCommand editCommand = (EditCommand) command;
1183 al = editCommand.getAlignment();
1184 Vector comps = (Vector) PaintRefresher.components
1185 .get(viewport.getSequenceSetId());
1187 for (int i = 0; i < comps.size(); i++)
1189 if (comps.elementAt(i) instanceof AlignmentPanel)
1191 if (al == ( (AlignmentPanel) comps.elementAt(i)).av.alignment)
1193 originalSource = ( (AlignmentPanel) comps.elementAt(i)).av;
1200 if (originalSource == null)
1202 //The original view is closed, we must validate
1203 //the current view against the closed view first
1206 PaintRefresher.validateSequences(al, viewport.alignment);
1209 originalSource = viewport;
1212 return originalSource;
1218 * @param up DOCUMENT ME!
1220 public void moveSelectedSequences(boolean up)
1222 SequenceGroup sg = viewport.getSelectionGroup();
1231 for (int i = 1; i < viewport.alignment.getHeight(); i++)
1233 SequenceI seq = viewport.alignment.getSequenceAt(i);
1235 if (!sg.getSequences(null).contains(seq))
1240 SequenceI temp = viewport.alignment.getSequenceAt(i - 1);
1242 if (sg.getSequences(null).contains(temp))
1247 viewport.alignment.getSequences().setElementAt(temp, i);
1248 viewport.alignment.getSequences().setElementAt(seq, i - 1);
1253 for (int i = viewport.alignment.getHeight() - 2; i > -1; i--)
1255 SequenceI seq = viewport.alignment.getSequenceAt(i);
1257 if (!sg.getSequences(null).contains(seq))
1262 SequenceI temp = viewport.alignment.getSequenceAt(i + 1);
1264 if (sg.getSequences(null).contains(temp))
1269 viewport.alignment.getSequences().setElementAt(temp, i);
1270 viewport.alignment.getSequences().setElementAt(seq, i + 1);
1274 alignPanel.paintAlignment(true);
1280 synchronized void slideSequences(boolean right, int size)
1282 Vector sg = new Vector();
1283 if(viewport.cursorMode)
1285 sg.addElement(viewport.alignment.getSequenceAt(
1286 alignPanel.seqPanel.seqCanvas.cursorY));
1288 else if(viewport.getSelectionGroup()!=null
1289 && viewport.getSelectionGroup().getSize()!=viewport.alignment.getHeight())
1291 sg = viewport.getSelectionGroup().getSequences(
1292 viewport.hiddenRepSequences);
1300 Vector invertGroup = new Vector();
1302 for (int i = 0; i < viewport.alignment.getHeight(); i++)
1304 if(!sg.contains(viewport.alignment.getSequenceAt(i)))
1305 invertGroup.add(viewport.alignment.getSequenceAt(i));
1308 SequenceI[] seqs1 = new SequenceI[sg.size()];
1309 for (int i = 0; i < sg.size(); i++)
1310 seqs1[i] = (SequenceI) sg.elementAt(i);
1312 SequenceI[] seqs2 = new SequenceI[invertGroup.size()];
1313 for (int i = 0; i < invertGroup.size(); i++)
1314 seqs2[i] = (SequenceI) invertGroup.elementAt(i);
1316 SlideSequencesCommand ssc;
1318 ssc = new SlideSequencesCommand("Slide Sequences",
1320 viewport.getGapCharacter()
1323 ssc = new SlideSequencesCommand("Slide Sequences",
1325 viewport.getGapCharacter()
1328 int groupAdjustment = 0;
1329 if (ssc.getGapsInsertedBegin() && right)
1331 if (viewport.cursorMode)
1332 alignPanel.seqPanel.moveCursor(size, 0);
1334 groupAdjustment = size;
1336 else if (!ssc.getGapsInsertedBegin() && !right)
1338 if (viewport.cursorMode)
1339 alignPanel.seqPanel.moveCursor( -size, 0);
1341 groupAdjustment = -size;
1344 if (groupAdjustment != 0)
1346 viewport.getSelectionGroup().setStartRes(
1347 viewport.getSelectionGroup().getStartRes() + groupAdjustment);
1348 viewport.getSelectionGroup().setEndRes(
1349 viewport.getSelectionGroup().getEndRes() + groupAdjustment);
1353 boolean appendHistoryItem = false;
1354 if(viewport.historyList!=null
1355 && viewport.historyList.size()>0
1356 && viewport.historyList.peek() instanceof SlideSequencesCommand)
1358 appendHistoryItem = ssc.appendSlideCommand(
1359 (SlideSequencesCommand)viewport.historyList.peek())
1363 if(!appendHistoryItem)
1364 addHistoryItem(ssc);
1373 * @param e DOCUMENT ME!
1375 protected void copy_actionPerformed(ActionEvent e)
1378 if (viewport.getSelectionGroup() == null)
1382 // TODO: preserve the ordering of displayed alignment annotation in any internal paste (particularly sequence associated annotation)
1383 SequenceI [] seqs = viewport.getSelectionAsNewSequence();
1384 String[] omitHidden = null;
1386 if (viewport.hasHiddenColumns)
1388 omitHidden = viewport.getViewAsString(true);
1391 String output = new FormatAdapter().formatSequences(
1396 StringSelection ss = new StringSelection(output);
1400 jalview.gui.Desktop.internalCopy = true;
1401 //Its really worth setting the clipboard contents
1402 //to empty before setting the large StringSelection!!
1403 Toolkit.getDefaultToolkit().getSystemClipboard()
1404 .setContents(new StringSelection(""), null);
1406 Toolkit.getDefaultToolkit().getSystemClipboard()
1407 .setContents(ss, Desktop.instance);
1409 catch (OutOfMemoryError er)
1411 er.printStackTrace();
1412 javax.swing.SwingUtilities.invokeLater(new Runnable()
1416 javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop,
1417 "Out of memory copying region!!"
1419 "\nSee help files for increasing Java Virtual Machine memory."
1421 javax.swing.JOptionPane.WARNING_MESSAGE);
1428 Vector hiddenColumns = null;
1429 if(viewport.hasHiddenColumns)
1431 hiddenColumns =new Vector();
1432 int hiddenOffset = viewport.getSelectionGroup().getStartRes();
1433 for (int i = 0; i < viewport.getColumnSelection().getHiddenColumns().size();
1436 int[] region = (int[])
1437 viewport.getColumnSelection().getHiddenColumns().elementAt(i);
1439 hiddenColumns.addElement(new int[]
1440 {region[0] - hiddenOffset,
1441 region[1]-hiddenOffset});
1445 Desktop.jalviewClipboard = new Object[]
1448 viewport.alignment.getDataset(),
1450 statusBar.setText("Copied "+seqs.length+" sequences to clipboard.");
1456 * @param e DOCUMENT ME!
1458 protected void pasteNew_actionPerformed(ActionEvent e)
1466 * @param e DOCUMENT ME!
1468 protected void pasteThis_actionPerformed(ActionEvent e)
1474 * Paste contents of Jalview clipboard
1476 * @param newAlignment true to paste to a new alignment, otherwise add to this.
1478 void paste(boolean newAlignment)
1480 boolean externalPaste=true;
1483 Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
1484 Transferable contents = c.getContents(this);
1486 if (contents == null)
1494 str = (String) contents.getTransferData(DataFlavor.stringFlavor);
1495 if (str.length() < 1)
1500 format = new IdentifyFile().Identify(str, "Paste");
1503 catch (OutOfMemoryError er)
1505 er.printStackTrace();
1506 javax.swing.SwingUtilities.invokeLater(new Runnable()
1510 javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop,
1511 "Out of memory pasting sequences!!"
1513 "\nSee help files for increasing Java Virtual Machine memory."
1515 javax.swing.JOptionPane.WARNING_MESSAGE);
1522 SequenceI[] sequences;
1523 boolean annotationAdded = false;
1524 AlignmentI alignment = null;
1526 if(Desktop.jalviewClipboard!=null)
1528 // The clipboard was filled from within Jalview, we must use the sequences
1529 // And dataset from the copied alignment
1530 SequenceI[] newseq = (SequenceI[])Desktop.jalviewClipboard[0];
1531 // be doubly sure that we create *new* sequence objects.
1532 sequences = new SequenceI[newseq.length];
1533 for (int i=0;i<newseq.length;i++) {
1534 sequences[i] = new Sequence(newseq[i]);
1536 alignment = new Alignment(sequences);
1537 externalPaste = false;
1541 // parse the clipboard as an alignment.
1542 alignment = new FormatAdapter().readFile(str, "Paste", format);
1543 sequences = alignment.getSequencesArray();
1551 if (Desktop.jalviewClipboard != null)
1553 // dataset is inherited
1554 alignment.setDataset( (Alignment) Desktop.jalviewClipboard[1]);
1558 // new dataset is constructed
1559 alignment.setDataset(null);
1561 alwidth = alignment.getWidth()+1;
1565 AlignmentI pastedal = alignment; // preserve pasted alignment object
1566 // Add pasted sequences and dataset into existing alignment.
1567 alignment = viewport.getAlignment();
1568 alwidth = alignment.getWidth()+1;
1569 // decide if we need to import sequences from an existing dataset
1570 boolean importDs = Desktop.jalviewClipboard != null
1571 && Desktop.jalviewClipboard[1] != alignment.getDataset();
1572 // importDs==true instructs us to copy over new dataset sequences from
1573 // an existing alignment
1574 Vector newDs = (importDs) ? new Vector() : null; // used to create
1575 // minimum dataset set
1577 for (int i = 0; i < sequences.length; i++)
1581 newDs.addElement(null);
1583 SequenceI ds = sequences[i].getDatasetSequence(); // null for a simple
1585 if (importDs && ds != null)
1587 if (!newDs.contains(ds))
1589 newDs.setElementAt(ds, i);
1590 ds = new Sequence(ds);
1591 // update with new dataset sequence
1592 sequences[i].setDatasetSequence(ds);
1596 ds = sequences[newDs.indexOf(ds)].getDatasetSequence();
1601 // copy and derive new dataset sequence
1602 sequences[i] = sequences[i].deriveSequence();
1603 alignment.getDataset().addSequence(sequences[i].getDatasetSequence());
1604 // TODO: avoid creation of duplicate dataset sequences with a
1605 // 'contains' method using SequenceI.equals()/SequenceI.contains()
1607 alignment.addSequence(sequences[i]); // merges dataset
1611 newDs.clear(); // tidy up
1613 if (pastedal.getAlignmentAnnotation()!=null) {
1614 // Add any annotation attached to alignment.
1615 AlignmentAnnotation[] alann = pastedal.getAlignmentAnnotation();
1616 for (int i=0; i<alann.length; i++)
1618 annotationAdded=true;
1619 if (alann[i].sequenceRef==null && !alann[i].autoCalculated) {
1620 AlignmentAnnotation newann = new AlignmentAnnotation(alann[i]);
1621 newann.padAnnotation(alwidth);
1622 alignment.addAnnotation(newann);
1627 if (!newAlignment) {
1631 addHistoryItem(new EditCommand(
1636 alignment.getWidth(),
1640 // Add any annotations attached to sequences
1641 for (int i = 0; i < sequences.length; i++)
1643 if (sequences[i].getAnnotation() != null)
1645 for (int a = 0; a < sequences[i].getAnnotation().length; a++)
1647 annotationAdded=true;
1648 sequences[i].getAnnotation()[a].adjustForAlignment();
1649 sequences[i].getAnnotation()[a].padAnnotation(alwidth);
1650 alignment.addAnnotation(sequences[i].getAnnotation()[a]); // annotation was duplicated earlier
1651 alignment.setAnnotationIndex(sequences[i].getAnnotation()[a], a);
1655 if (!newAlignment) {
1657 // propagate alignment changed.
1658 viewport.setEndSeq(alignment.getHeight());
1659 if (annotationAdded)
1661 // Duplicate sequence annotation in all views.
1662 AlignmentI[] alview = this.getViewAlignments();
1663 for (int i = 0; i < sequences.length; i++)
1665 AlignmentAnnotation sann[] = sequences[i].getAnnotation();
1668 for (int avnum=0;avnum<alview.length; avnum++)
1670 if (alview[avnum]!=alignment)
1672 // duplicate in a view other than the one with input focus
1673 int avwidth = alview[avnum].getWidth()+1;
1674 // this relies on sann being preserved after we
1675 // modify the sequence's annotation array for each duplication
1676 for (int a=0; a<sann.length; a++)
1678 AlignmentAnnotation newann = new AlignmentAnnotation(sann[a]);
1679 sequences[i].addAlignmentAnnotation(newann);
1680 newann.padAnnotation(avwidth);
1681 alview[avnum].addAnnotation(newann); // annotation was duplicated earlier
1682 alview[avnum].setAnnotationIndex(newann, a);
1687 buildSortByAnnotationScoresMenu();
1689 viewport.firePropertyChange("alignment", null, alignment.getSequences());
1692 AlignFrame af = new AlignFrame(alignment, DEFAULT_WIDTH, DEFAULT_HEIGHT);
1693 String newtitle = new String("Copied sequences");
1695 if(Desktop.jalviewClipboard!=null && Desktop.jalviewClipboard[2]!=null)
1697 Vector hc = (Vector)Desktop.jalviewClipboard[2];
1698 for(int i=0; i<hc.size(); i++)
1700 int [] region = (int[]) hc.elementAt(i);
1701 af.viewport.hideColumns(region[0], region[1]);
1706 //>>>This is a fix for the moment, until a better solution is found!!<<<
1707 af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().transferSettings(
1708 alignPanel.seqPanel.seqCanvas.getFeatureRenderer());
1710 // TODO: maintain provenance of an alignment, rather than just make the title a concatenation of operations.
1711 if (!externalPaste) {
1712 if (title.startsWith("Copied sequences"))
1718 newtitle = newtitle.concat("- from " + title);
1721 newtitle = new String("Pasted sequences");
1724 Desktop.addInternalFrame(af, newtitle, DEFAULT_WIDTH,
1731 catch (Exception ex)
1733 ex.printStackTrace();
1734 System.out.println("Exception whilst pasting: "+ex);
1735 // could be anything being pasted in here
1744 * @param e DOCUMENT ME!
1746 protected void cut_actionPerformed(ActionEvent e)
1748 copy_actionPerformed(null);
1749 delete_actionPerformed(null);
1755 * @param e DOCUMENT ME!
1757 protected void delete_actionPerformed(ActionEvent evt)
1760 SequenceGroup sg = viewport.getSelectionGroup();
1766 Vector seqs = new Vector();
1768 for (int i = 0; i < sg.getSize(); i++)
1770 seq = sg.getSequenceAt(i);
1771 seqs.addElement(seq);
1775 // If the cut affects all sequences, remove highlighted columns
1776 if (sg.getSize() == viewport.alignment.getHeight())
1778 viewport.getColumnSelection().removeElements(sg.getStartRes(),
1779 sg.getEndRes() + 1);
1783 SequenceI [] cut = new SequenceI[seqs.size()];
1784 for(int i=0; i<seqs.size(); i++)
1786 cut[i] = (SequenceI)seqs.elementAt(i);
1793 addHistoryItem(new EditCommand("Cut Sequences",
1797 sg.getEndRes()-sg.getStartRes()+1,
1798 viewport.alignment));
1801 viewport.setSelectionGroup(null);
1802 viewport.alignment.deleteGroup(sg);
1804 viewport.firePropertyChange("alignment", null,
1805 viewport.getAlignment().getSequences());
1807 if (viewport.getAlignment().getHeight() < 1)
1811 this.setClosed(true);
1813 catch (Exception ex)
1822 * @param e DOCUMENT ME!
1824 protected void deleteGroups_actionPerformed(ActionEvent e)
1826 viewport.alignment.deleteAllGroups();
1827 viewport.sequenceColours = null;
1828 viewport.setSelectionGroup(null);
1829 PaintRefresher.Refresh(this, viewport.getSequenceSetId());
1830 alignPanel.paintAlignment(true);
1836 * @param e DOCUMENT ME!
1838 public void selectAllSequenceMenuItem_actionPerformed(ActionEvent e)
1840 SequenceGroup sg = new SequenceGroup();
1842 for (int i = 0; i < viewport.getAlignment().getSequences().size();
1845 sg.addSequence(viewport.getAlignment().getSequenceAt(i), false);
1848 sg.setEndRes(viewport.alignment.getWidth() - 1);
1849 viewport.setSelectionGroup(sg);
1850 alignPanel.paintAlignment(true);
1851 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
1857 * @param e DOCUMENT ME!
1859 public void deselectAllSequenceMenuItem_actionPerformed(ActionEvent e)
1861 if(viewport.cursorMode)
1863 alignPanel.seqPanel.keyboardNo1 = null;
1864 alignPanel.seqPanel.keyboardNo2 = null;
1866 viewport.setSelectionGroup(null);
1867 viewport.getColumnSelection().clear();
1868 viewport.setSelectionGroup(null);
1869 alignPanel.seqPanel.seqCanvas.highlightSearchResults(null);
1870 alignPanel.idPanel.idCanvas.searchResults = null;
1871 alignPanel.paintAlignment(true);
1872 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
1878 * @param e DOCUMENT ME!
1880 public void invertSequenceMenuItem_actionPerformed(ActionEvent e)
1882 SequenceGroup sg = viewport.getSelectionGroup();
1886 selectAllSequenceMenuItem_actionPerformed(null);
1891 for (int i = 0; i < viewport.getAlignment().getSequences().size();
1894 sg.addOrRemove(viewport.getAlignment().getSequenceAt(i), false);
1897 alignPanel.paintAlignment(true);
1899 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
1902 public void invertColSel_actionPerformed(ActionEvent e)
1904 viewport.invertColumnSelection();
1905 alignPanel.paintAlignment(true);
1912 * @param e DOCUMENT ME!
1914 public void remove2LeftMenuItem_actionPerformed(ActionEvent e)
1916 trimAlignment(true);
1922 * @param e DOCUMENT ME!
1924 public void remove2RightMenuItem_actionPerformed(ActionEvent e)
1926 trimAlignment(false);
1929 void trimAlignment(boolean trimLeft)
1931 ColumnSelection colSel = viewport.getColumnSelection();
1934 if (colSel.size() > 0)
1938 column = colSel.getMin();
1942 column = colSel.getMax();
1946 if(viewport.getSelectionGroup()!=null)
1948 seqs = viewport.getSelectionGroup().getSequencesAsArray(viewport.
1949 hiddenRepSequences);
1953 seqs = viewport.alignment.getSequencesArray();
1957 TrimRegionCommand trimRegion;
1960 trimRegion = new TrimRegionCommand("Remove Left",
1961 TrimRegionCommand.TRIM_LEFT,
1966 viewport.selectionGroup);
1967 viewport.setStartRes(0);
1971 trimRegion = new TrimRegionCommand("Remove Right",
1972 TrimRegionCommand.TRIM_RIGHT,
1977 viewport.selectionGroup);
1980 statusBar.setText("Removed "+trimRegion.getSize()+" columns.");
1983 addHistoryItem(trimRegion);
1985 Vector groups = viewport.alignment.getGroups();
1987 for (int i = 0; i < groups.size(); i++)
1989 SequenceGroup sg = (SequenceGroup) groups.get(i);
1991 if ( (trimLeft && !sg.adjustForRemoveLeft(column))
1992 || (!trimLeft && !sg.adjustForRemoveRight(column)))
1994 viewport.alignment.deleteGroup(sg);
1998 viewport.firePropertyChange("alignment", null,
1999 viewport.getAlignment().getSequences());
2006 * @param e DOCUMENT ME!
2008 public void removeGappedColumnMenuItem_actionPerformed(ActionEvent e)
2010 int start = 0, end = viewport.alignment.getWidth()-1;
2013 if (viewport.getSelectionGroup() != null)
2015 seqs = viewport.getSelectionGroup().getSequencesAsArray(viewport.
2016 hiddenRepSequences);
2017 start = viewport.getSelectionGroup().getStartRes();
2018 end = viewport.getSelectionGroup().getEndRes();
2022 seqs = viewport.alignment.getSequencesArray();
2026 RemoveGapColCommand removeGapCols =
2027 new RemoveGapColCommand("Remove Gapped Columns",
2030 viewport.alignment);
2032 addHistoryItem(removeGapCols);
2034 statusBar.setText("Removed "+removeGapCols.getSize()+" empty columns.");
2036 //This is to maintain viewport position on first residue
2038 SequenceI seq = viewport.alignment.getSequenceAt(0);
2039 int startRes = seq.findPosition(viewport.startRes);
2040 // ShiftList shifts;
2041 // viewport.getAlignment().removeGaps(shifts=new ShiftList());
2042 // edit.alColumnChanges=shifts.getInverse();
2043 // if (viewport.hasHiddenColumns)
2044 // viewport.getColumnSelection().compensateForEdits(shifts);
2045 viewport.setStartRes(seq.findIndex(startRes)-1);
2046 viewport.firePropertyChange("alignment", null,
2047 viewport.getAlignment().getSequences());
2054 * @param e DOCUMENT ME!
2056 public void removeAllGapsMenuItem_actionPerformed(ActionEvent e)
2058 int start = 0, end = viewport.alignment.getWidth()-1;
2061 if (viewport.getSelectionGroup() != null)
2063 seqs = viewport.getSelectionGroup().getSequencesAsArray(viewport.
2064 hiddenRepSequences);
2065 start = viewport.getSelectionGroup().getStartRes();
2066 end = viewport.getSelectionGroup().getEndRes();
2070 seqs = viewport.alignment.getSequencesArray();
2073 //This is to maintain viewport position on first residue
2075 SequenceI seq = viewport.alignment.getSequenceAt(0);
2076 int startRes = seq.findPosition(viewport.startRes);
2078 addHistoryItem(new RemoveGapsCommand("Remove Gaps",
2081 viewport.alignment));
2083 viewport.setStartRes(seq.findIndex(startRes)-1);
2085 viewport.firePropertyChange("alignment", null,
2086 viewport.getAlignment().getSequences());
2093 * @param e DOCUMENT ME!
2095 public void padGapsMenuitem_actionPerformed(ActionEvent e)
2097 viewport.padGaps = padGapsMenuitem.isSelected();
2099 viewport.firePropertyChange("alignment",
2101 viewport.getAlignment().getSequences());
2107 * @param e DOCUMENT ME!
2109 public void findMenuItem_actionPerformed(ActionEvent e)
2114 public void newView_actionPerformed(ActionEvent e)
2116 AlignmentPanel newap =
2117 new Jalview2XML().copyAlignPanel(alignPanel, true);
2119 newap.av.gatherViewsHere = false;
2121 if (viewport.viewName == null)
2123 viewport.viewName = "Original";
2126 newap.av.historyList = viewport.historyList;
2127 newap.av.redoList = viewport.redoList;
2129 int index = Desktop.getViewCount(viewport.getSequenceSetId());
2130 String newViewName = "View " +index;
2132 Vector comps = (Vector) PaintRefresher.components.get(viewport.
2133 getSequenceSetId());
2134 Vector existingNames = new Vector();
2135 for(int i=0; i<comps.size(); i++)
2137 if(comps.elementAt(i) instanceof AlignmentPanel)
2139 AlignmentPanel ap = (AlignmentPanel)comps.elementAt(i);
2140 if(!existingNames.contains(ap.av.viewName))
2142 existingNames.addElement(ap.av.viewName);
2147 while(existingNames.contains(newViewName))
2149 newViewName = "View "+ (++index);
2152 newap.av.viewName = newViewName;
2154 addAlignmentPanel(newap, false);
2156 if(alignPanels.size()==2)
2158 viewport.gatherViewsHere = true;
2160 tabbedPane.setSelectedIndex(tabbedPane.getTabCount() - 1);
2163 public void expandViews_actionPerformed(ActionEvent e)
2165 Desktop.instance.explodeViews(this);
2168 public void gatherViews_actionPerformed(ActionEvent e)
2170 Desktop.instance.gatherViews(this);
2178 * @param e DOCUMENT ME!
2180 public void font_actionPerformed(ActionEvent e)
2182 new FontChooser(alignPanel);
2189 * @param e DOCUMENT ME!
2191 protected void seqLimit_actionPerformed(ActionEvent e)
2193 viewport.setShowJVSuffix(seqLimits.isSelected());
2195 alignPanel.idPanel.idCanvas.setPreferredSize(alignPanel.calculateIdWidth());
2196 alignPanel.paintAlignment(true);
2199 public void idRightAlign_actionPerformed(ActionEvent e)
2201 viewport.rightAlignIds = idRightAlign.isSelected();
2202 alignPanel.paintAlignment(true);
2205 public void centreColumnLabels_actionPerformed(ActionEvent e)
2207 viewport.centreColumnLabels = centreColumnLabelsMenuItem.getState();
2208 alignPanel.paintAlignment(true);
2216 * @param e DOCUMENT ME!
2218 protected void colourTextMenuItem_actionPerformed(ActionEvent e)
2220 viewport.setColourText(colourTextMenuItem.isSelected());
2221 alignPanel.paintAlignment(true);
2227 * @param e DOCUMENT ME!
2229 public void wrapMenuItem_actionPerformed(ActionEvent e)
2231 scaleAbove.setVisible(wrapMenuItem.isSelected());
2232 scaleLeft.setVisible(wrapMenuItem.isSelected());
2233 scaleRight.setVisible(wrapMenuItem.isSelected());
2234 viewport.setWrapAlignment(wrapMenuItem.isSelected());
2235 alignPanel.setWrapAlignment(wrapMenuItem.isSelected());
2238 public void showAllSeqs_actionPerformed(ActionEvent e)
2240 viewport.showAllHiddenSeqs();
2243 public void showAllColumns_actionPerformed(ActionEvent e)
2245 viewport.showAllHiddenColumns();
2249 public void hideSelSequences_actionPerformed(ActionEvent e)
2251 viewport.hideAllSelectedSeqs();
2252 alignPanel.paintAlignment(true);
2255 public void hideSelColumns_actionPerformed(ActionEvent e)
2257 viewport.hideSelectedColumns();
2258 alignPanel.paintAlignment(true);
2261 public void hiddenMarkers_actionPerformed(ActionEvent e)
2263 viewport.setShowHiddenMarkers(hiddenMarkers.isSelected());
2270 * @param e DOCUMENT ME!
2272 protected void scaleAbove_actionPerformed(ActionEvent e)
2274 viewport.setScaleAboveWrapped(scaleAbove.isSelected());
2275 alignPanel.paintAlignment(true);
2281 * @param e DOCUMENT ME!
2283 protected void scaleLeft_actionPerformed(ActionEvent e)
2285 viewport.setScaleLeftWrapped(scaleLeft.isSelected());
2286 alignPanel.paintAlignment(true);
2292 * @param e DOCUMENT ME!
2294 protected void scaleRight_actionPerformed(ActionEvent e)
2296 viewport.setScaleRightWrapped(scaleRight.isSelected());
2297 alignPanel.paintAlignment(true);
2303 * @param e DOCUMENT ME!
2305 public void viewBoxesMenuItem_actionPerformed(ActionEvent e)
2307 viewport.setShowBoxes(viewBoxesMenuItem.isSelected());
2308 alignPanel.paintAlignment(true);
2314 * @param e DOCUMENT ME!
2316 public void viewTextMenuItem_actionPerformed(ActionEvent e)
2318 viewport.setShowText(viewTextMenuItem.isSelected());
2319 alignPanel.paintAlignment(true);
2325 * @param e DOCUMENT ME!
2327 protected void renderGapsMenuItem_actionPerformed(ActionEvent e)
2329 viewport.setRenderGaps(renderGapsMenuItem.isSelected());
2330 alignPanel.paintAlignment(true);
2334 public FeatureSettings featureSettings;
2335 public void featureSettings_actionPerformed(ActionEvent e)
2337 if(featureSettings !=null )
2339 featureSettings.close();
2340 featureSettings = null;
2342 featureSettings = new FeatureSettings(this);
2348 * @param evt DOCUMENT ME!
2350 public void showSeqFeatures_actionPerformed(ActionEvent evt)
2352 viewport.setShowSequenceFeatures(showSeqFeatures.isSelected());
2353 alignPanel.paintAlignment(true);
2354 if (alignPanel.getOverviewPanel() != null)
2356 alignPanel.getOverviewPanel().updateOverviewImage();
2363 * @param e DOCUMENT ME!
2365 public void annotationPanelMenuItem_actionPerformed(ActionEvent e)
2367 viewport.setShowAnnotation(annotationPanelMenuItem.isSelected());
2368 alignPanel.setAnnotationVisible(annotationPanelMenuItem.isSelected());
2371 public void alignmentProperties()
2373 JEditorPane editPane = new JEditorPane("text/html","");
2374 editPane.setEditable(false);
2375 StringBuffer contents = new StringBuffer("<html>");
2378 int min=Integer.MAX_VALUE, max=0;
2379 for(int i=0; i<viewport.alignment.getHeight(); i++)
2381 int size = viewport.alignment.getSequenceAt(i).getEnd()
2382 -viewport.alignment.getSequenceAt(i).getStart();
2389 avg = avg/(float)viewport.alignment.getHeight();
2391 contents.append("<br>Sequences: "+ viewport.alignment.getHeight());
2392 contents.append("<br>Minimum Sequence Length: "+min);
2393 contents.append("<br>Maximum Sequence Length: "+max);
2394 contents.append("<br>Average Length: "+(int)avg);
2396 if (((Alignment)viewport.alignment).getProperties() != null)
2398 Hashtable props = ((Alignment)viewport.alignment).getProperties();
2399 Enumeration en = props.keys();
2400 contents.append("<br><br><table border=\"1\">");
2401 while(en.hasMoreElements())
2403 String key = en.nextElement().toString();
2404 StringBuffer val = new StringBuffer();
2405 String vals = props.get(key).toString();
2408 npos = vals.indexOf("\n",pos);
2411 val.append(vals.substring(pos));
2413 val.append(vals.substring(pos, npos));
2418 contents.append("<tr><td>"+key+"</td><td>"+val+"</td></tr>");
2420 contents.append("</table>");
2422 editPane.setText(contents.toString()+"</html>");
2423 JInternalFrame frame = new JInternalFrame();
2424 frame.getContentPane().add(new JScrollPane(editPane));
2426 Desktop.instance.addInternalFrame(frame,"Alignment Properties: "+getTitle(),500,400);
2433 * @param e DOCUMENT ME!
2435 public void overviewMenuItem_actionPerformed(ActionEvent e)
2437 if (alignPanel.overviewPanel != null)
2442 JInternalFrame frame = new JInternalFrame();
2443 OverviewPanel overview = new OverviewPanel(alignPanel);
2444 frame.setContentPane(overview);
2445 Desktop.addInternalFrame(frame, "Overview " + this.getTitle(),
2446 frame.getWidth(), frame.getHeight());
2448 frame.setLayer(JLayeredPane.PALETTE_LAYER);
2449 frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
2451 public void internalFrameClosed(
2452 javax.swing.event.InternalFrameEvent evt)
2454 alignPanel.setOverviewPanel(null);
2459 alignPanel.setOverviewPanel(overview);
2462 public void textColour_actionPerformed(ActionEvent e)
2464 new TextColourChooser().chooseColour(alignPanel, null);
2470 * @param e DOCUMENT ME!
2472 protected void noColourmenuItem_actionPerformed(ActionEvent e)
2480 * @param e DOCUMENT ME!
2482 public void clustalColour_actionPerformed(ActionEvent e)
2484 changeColour(new ClustalxColourScheme(
2485 viewport.alignment.getSequences(), viewport.alignment.getWidth()));
2491 * @param e DOCUMENT ME!
2493 public void zappoColour_actionPerformed(ActionEvent e)
2495 changeColour(new ZappoColourScheme());
2501 * @param e DOCUMENT ME!
2503 public void taylorColour_actionPerformed(ActionEvent e)
2505 changeColour(new TaylorColourScheme());
2511 * @param e DOCUMENT ME!
2513 public void hydrophobicityColour_actionPerformed(ActionEvent e)
2515 changeColour(new HydrophobicColourScheme());
2521 * @param e DOCUMENT ME!
2523 public void helixColour_actionPerformed(ActionEvent e)
2525 changeColour(new HelixColourScheme());
2531 * @param e DOCUMENT ME!
2533 public void strandColour_actionPerformed(ActionEvent e)
2535 changeColour(new StrandColourScheme());
2541 * @param e DOCUMENT ME!
2543 public void turnColour_actionPerformed(ActionEvent e)
2545 changeColour(new TurnColourScheme());
2551 * @param e DOCUMENT ME!
2553 public void buriedColour_actionPerformed(ActionEvent e)
2555 changeColour(new BuriedColourScheme());
2561 * @param e DOCUMENT ME!
2563 public void nucleotideColour_actionPerformed(ActionEvent e)
2565 changeColour(new NucleotideColourScheme());
2568 public void annotationColour_actionPerformed(ActionEvent e)
2570 new AnnotationColourChooser(viewport, alignPanel);
2577 * @param e DOCUMENT ME!
2579 protected void applyToAllGroups_actionPerformed(ActionEvent e)
2581 viewport.setColourAppliesToAllGroups(applyToAllGroups.isSelected());
2587 * @param cs DOCUMENT ME!
2589 public void changeColour(ColourSchemeI cs)
2595 if (viewport.getAbovePIDThreshold())
2597 threshold = SliderPanel.setPIDSliderSource(alignPanel, cs,
2600 cs.setThreshold(threshold,
2601 viewport.getIgnoreGapsConsensus());
2603 viewport.setGlobalColourScheme(cs);
2607 cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
2610 if (viewport.getConservationSelected())
2613 Alignment al = (Alignment) viewport.alignment;
2614 Conservation c = new Conservation("All",
2615 ResidueProperties.propHash, 3,
2616 al.getSequences(), 0,
2620 c.verdict(false, viewport.ConsPercGaps);
2622 cs.setConservation(c);
2624 cs.setConservationInc(SliderPanel.setConservationSlider(alignPanel, cs,
2629 cs.setConservation(null);
2632 cs.setConsensus(viewport.hconsensus);
2635 viewport.setGlobalColourScheme(cs);
2637 if (viewport.getColourAppliesToAllGroups())
2639 Vector groups = viewport.alignment.getGroups();
2641 for (int i = 0; i < groups.size(); i++)
2643 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
2651 if (cs instanceof ClustalxColourScheme)
2653 sg.cs = new ClustalxColourScheme(
2654 sg.getSequences(viewport.hiddenRepSequences), sg.getWidth());
2656 else if (cs instanceof UserColourScheme)
2658 sg.cs = new UserColourScheme( ( (UserColourScheme) cs).getColours());
2664 sg.cs = (ColourSchemeI) cs.getClass().newInstance();
2666 catch (Exception ex)
2671 if (viewport.getAbovePIDThreshold()
2672 || cs instanceof PIDColourScheme
2673 || cs instanceof Blosum62ColourScheme)
2675 sg.cs.setThreshold(threshold,
2676 viewport.getIgnoreGapsConsensus());
2678 sg.cs.setConsensus(AAFrequency.calculate(
2679 sg.getSequences(viewport.hiddenRepSequences), sg.getStartRes(),
2684 sg.cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
2688 if (viewport.getConservationSelected())
2690 Conservation c = new Conservation("Group",
2691 ResidueProperties.propHash, 3,
2692 sg.getSequences(viewport.
2693 hiddenRepSequences),
2697 c.verdict(false, viewport.ConsPercGaps);
2698 sg.cs.setConservation(c);
2702 sg.cs.setConservation(null);
2707 if (alignPanel.getOverviewPanel() != null)
2709 alignPanel.getOverviewPanel().updateOverviewImage();
2715 alignPanel.paintAlignment(true);
2721 * @param e DOCUMENT ME!
2723 protected void modifyPID_actionPerformed(ActionEvent e)
2725 if (viewport.getAbovePIDThreshold() && viewport.globalColourScheme!=null)
2727 SliderPanel.setPIDSliderSource(alignPanel,
2728 viewport.getGlobalColourScheme(),
2730 SliderPanel.showPIDSlider();
2737 * @param e DOCUMENT ME!
2739 protected void modifyConservation_actionPerformed(ActionEvent e)
2741 if (viewport.getConservationSelected() && viewport.globalColourScheme!=null)
2743 SliderPanel.setConservationSlider(alignPanel,
2744 viewport.globalColourScheme,
2746 SliderPanel.showConservationSlider();
2753 * @param e DOCUMENT ME!
2755 protected void conservationMenuItem_actionPerformed(ActionEvent e)
2757 viewport.setConservationSelected(conservationMenuItem.isSelected());
2759 viewport.setAbovePIDThreshold(false);
2760 abovePIDThreshold.setSelected(false);
2762 changeColour(viewport.getGlobalColourScheme());
2764 modifyConservation_actionPerformed(null);
2770 * @param e DOCUMENT ME!
2772 public void abovePIDThreshold_actionPerformed(ActionEvent e)
2774 viewport.setAbovePIDThreshold(abovePIDThreshold.isSelected());
2776 conservationMenuItem.setSelected(false);
2777 viewport.setConservationSelected(false);
2779 changeColour(viewport.getGlobalColourScheme());
2781 modifyPID_actionPerformed(null);
2787 * @param e DOCUMENT ME!
2789 public void userDefinedColour_actionPerformed(ActionEvent e)
2791 if (e.getActionCommand().equals("User Defined..."))
2793 new UserDefinedColours(alignPanel, null);
2797 UserColourScheme udc = (UserColourScheme) UserDefinedColours.
2798 getUserColourSchemes().get(e.getActionCommand());
2804 public void updateUserColourMenu()
2807 Component[] menuItems = colourMenu.getMenuComponents();
2808 int i, iSize = menuItems.length;
2809 for (i = 0; i < iSize; i++)
2811 if (menuItems[i].getName() != null &&
2812 menuItems[i].getName().equals("USER_DEFINED"))
2814 colourMenu.remove(menuItems[i]);
2818 if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null)
2820 java.util.Enumeration userColours = jalview.gui.UserDefinedColours.
2821 getUserColourSchemes().keys();
2823 while (userColours.hasMoreElements())
2825 final JRadioButtonMenuItem radioItem = new JRadioButtonMenuItem(
2827 nextElement().toString());
2828 radioItem.setName("USER_DEFINED");
2829 radioItem.addMouseListener(new MouseAdapter()
2831 public void mousePressed(MouseEvent evt)
2833 if(evt.isControlDown() || SwingUtilities.isRightMouseButton(evt))
2835 radioItem.removeActionListener(radioItem.getActionListeners()[0]);
2837 int option = JOptionPane.showInternalConfirmDialog(jalview.gui.
2839 "Remove from default list?",
2840 "Remove user defined colour",
2841 JOptionPane.YES_NO_OPTION);
2842 if(option == JOptionPane.YES_OPTION)
2844 jalview.gui.UserDefinedColours.removeColourFromDefaults(
2845 radioItem.getText());
2846 colourMenu.remove(radioItem);
2850 radioItem.addActionListener(new ActionListener()
2852 public void actionPerformed(ActionEvent evt)
2854 userDefinedColour_actionPerformed(evt);
2861 radioItem.addActionListener(new ActionListener()
2863 public void actionPerformed(ActionEvent evt)
2865 userDefinedColour_actionPerformed(evt);
2869 colourMenu.insert(radioItem, 15);
2870 colours.add(radioItem);
2878 * @param e DOCUMENT ME!
2880 public void PIDColour_actionPerformed(ActionEvent e)
2882 changeColour(new PIDColourScheme());
2888 * @param e DOCUMENT ME!
2890 public void BLOSUM62Colour_actionPerformed(ActionEvent e)
2892 changeColour(new Blosum62ColourScheme());
2898 * @param e DOCUMENT ME!
2900 public void sortPairwiseMenuItem_actionPerformed(ActionEvent e)
2902 SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray();
2903 AlignmentSorter.sortByPID(viewport.getAlignment(),
2904 viewport.getAlignment().getSequenceAt(0), null);
2905 addHistoryItem(new OrderCommand("Pairwise Sort", oldOrder,
2906 viewport.alignment));
2907 alignPanel.paintAlignment(true);
2913 * @param e DOCUMENT ME!
2915 public void sortIDMenuItem_actionPerformed(ActionEvent e)
2917 SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray();
2918 AlignmentSorter.sortByID(viewport.getAlignment());
2919 addHistoryItem(new OrderCommand("ID Sort", oldOrder, viewport.alignment));
2920 alignPanel.paintAlignment(true);
2926 * @param e DOCUMENT ME!
2928 public void sortGroupMenuItem_actionPerformed(ActionEvent e)
2930 SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray();
2931 AlignmentSorter.sortByGroup(viewport.getAlignment());
2932 addHistoryItem(new OrderCommand("Group Sort", oldOrder, viewport.alignment));
2934 alignPanel.paintAlignment(true);
2939 * @param e DOCUMENT ME!
2941 public void removeRedundancyMenuItem_actionPerformed(ActionEvent e)
2943 new RedundancyPanel(alignPanel, this);
2950 * @param e DOCUMENT ME!
2952 public void pairwiseAlignmentMenuItem_actionPerformed(ActionEvent e)
2954 if ( (viewport.getSelectionGroup() == null) ||
2955 (viewport.getSelectionGroup().getSize() < 2))
2957 JOptionPane.showInternalMessageDialog(this,
2958 "You must select at least 2 sequences.",
2959 "Invalid Selection",
2960 JOptionPane.WARNING_MESSAGE);
2964 JInternalFrame frame = new JInternalFrame();
2965 frame.setContentPane(new PairwiseAlignPanel(viewport));
2966 Desktop.addInternalFrame(frame, "Pairwise Alignment", 600, 500);
2973 * @param e DOCUMENT ME!
2975 public void PCAMenuItem_actionPerformed(ActionEvent e)
2977 if ( ( (viewport.getSelectionGroup() != null) &&
2978 (viewport.getSelectionGroup().getSize() < 4) &&
2979 (viewport.getSelectionGroup().getSize() > 0)) ||
2980 (viewport.getAlignment().getHeight() < 4))
2982 JOptionPane.showInternalMessageDialog(this,
2983 "Principal component analysis must take\n" +
2984 "at least 4 input sequences.",
2985 "Sequence selection insufficient",
2986 JOptionPane.WARNING_MESSAGE);
2991 new PCAPanel(alignPanel);
2995 public void autoCalculate_actionPerformed(ActionEvent e)
2997 viewport.autoCalculateConsensus = autoCalculate.isSelected();
2998 if(viewport.autoCalculateConsensus)
3000 viewport.firePropertyChange("alignment",
3002 viewport.getAlignment().getSequences());
3010 * @param e DOCUMENT ME!
3012 public void averageDistanceTreeMenuItem_actionPerformed(ActionEvent e)
3014 NewTreePanel("AV", "PID", "Average distance tree using PID");
3020 * @param e DOCUMENT ME!
3022 public void neighbourTreeMenuItem_actionPerformed(ActionEvent e)
3024 NewTreePanel("NJ", "PID", "Neighbour joining tree using PID");
3030 * @param e DOCUMENT ME!
3032 protected void njTreeBlosumMenuItem_actionPerformed(ActionEvent e)
3034 NewTreePanel("NJ", "BL", "Neighbour joining tree using BLOSUM62");
3040 * @param e DOCUMENT ME!
3042 protected void avTreeBlosumMenuItem_actionPerformed(ActionEvent e)
3044 NewTreePanel("AV", "BL", "Average distance tree using BLOSUM62");
3050 * @param type DOCUMENT ME!
3051 * @param pwType DOCUMENT ME!
3052 * @param title DOCUMENT ME!
3054 void NewTreePanel(String type, String pwType, String title)
3058 if (viewport.getSelectionGroup() != null)
3060 if (viewport.getSelectionGroup().getSize() < 3)
3062 JOptionPane.showMessageDialog(Desktop.desktop,
3063 "You need to have more than two sequences selected to build a tree!",
3064 "Not enough sequences",
3065 JOptionPane.WARNING_MESSAGE);
3070 SequenceGroup sg = viewport.getSelectionGroup();
3072 /* Decide if the selection is a column region */
3073 while (s < sg.getSize())
3075 if ( ( (SequenceI) sg.getSequences(null).elementAt(s++)).getLength() <
3078 JOptionPane.showMessageDialog(Desktop.desktop,
3079 "The selected region to create a tree may\nonly contain residues or gaps.\n" +
3080 "Try using the Pad function in the edit menu,\n" +
3081 "or one of the multiple sequence alignment web services.",
3082 "Sequences in selection are not aligned",
3083 JOptionPane.WARNING_MESSAGE);
3089 title = title + " on region";
3090 tp = new TreePanel(alignPanel, type, pwType);
3094 //are the sequences aligned?
3095 if (!viewport.alignment.isAligned())
3097 JOptionPane.showMessageDialog(Desktop.desktop,
3098 "The sequences must be aligned before creating a tree.\n" +
3099 "Try using the Pad function in the edit menu,\n" +
3100 "or one of the multiple sequence alignment web services.",
3101 "Sequences not aligned",
3102 JOptionPane.WARNING_MESSAGE);
3107 if(viewport.alignment.getHeight()<2)
3112 tp = new TreePanel(alignPanel, type, pwType);
3117 if(viewport.viewName!=null)
3119 title+= viewport.viewName+" of ";
3122 title += this.title;
3124 Desktop.addInternalFrame(tp, title, 600, 500);
3130 * @param title DOCUMENT ME!
3131 * @param order DOCUMENT ME!
3133 public void addSortByOrderMenuItem(String title, final AlignmentOrder order)
3135 final JMenuItem item = new JMenuItem("by " + title);
3137 item.addActionListener(new java.awt.event.ActionListener()
3139 public void actionPerformed(ActionEvent e)
3141 SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray();
3143 // TODO: JBPNote - have to map order entries to curent SequenceI pointers
3144 AlignmentSorter.sortBy(viewport.getAlignment(), order);
3146 addHistoryItem(new OrderCommand(order.getName(), oldOrder,
3147 viewport.alignment));
3149 alignPanel.paintAlignment(true);
3154 * Add a new sort by annotation score menu item
3155 * @param sort the menu to add the option to
3156 * @param scoreLabel the label used to retrieve scores for each sequence on the alignment
3158 public void addSortByAnnotScoreMenuItem(JMenu sort, final String scoreLabel)
3160 final JMenuItem item = new JMenuItem(scoreLabel);
3162 item.addActionListener(new java.awt.event.ActionListener()
3164 public void actionPerformed(ActionEvent e)
3166 SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray();
3167 AlignmentSorter.sortByAnnotationScore(scoreLabel, viewport.getAlignment());//,viewport.getSelectionGroup());
3168 addHistoryItem(new OrderCommand("Sort by "+scoreLabel, oldOrder, viewport.alignment));
3169 alignPanel.paintAlignment(true);
3174 * last hash for alignment's annotation array - used to minimise cost of rebuild.
3176 protected int _annotationScoreVectorHash;
3178 * search the alignment and rebuild the sort by annotation score submenu
3179 * the last alignment annotation vector hash is stored to minimize
3180 * cost of rebuilding in subsequence calls.
3183 public void buildSortByAnnotationScoresMenu()
3185 if(viewport.alignment.getAlignmentAnnotation()==null)
3190 if (viewport.alignment.getAlignmentAnnotation().hashCode()!=_annotationScoreVectorHash)
3192 sortByAnnotScore.removeAll();
3193 // almost certainly a quicker way to do this - but we keep it simple
3194 Hashtable scoreSorts=new Hashtable();
3195 AlignmentAnnotation aann[];
3196 Enumeration sq = viewport.alignment.getSequences().elements();
3197 while (sq.hasMoreElements())
3199 aann = ((SequenceI) sq.nextElement()).getAnnotation();
3200 for (int i=0;aann!=null && i<aann.length; i++)
3202 if (aann[i].hasScore() && aann[i].sequenceRef!=null)
3204 scoreSorts.put(aann[i].label, aann[i].label);
3208 Enumeration labels = scoreSorts.keys();
3209 while (labels.hasMoreElements())
3211 addSortByAnnotScoreMenuItem(sortByAnnotScore, (String) labels.nextElement());
3213 sortByAnnotScore.setVisible(scoreSorts.size()>0);
3216 _annotationScoreVectorHash =
3217 viewport.alignment.getAlignmentAnnotation().hashCode();
3222 * Maintain the Order by->Displayed Tree menu.
3223 * Creates a new menu item for a TreePanel with an appropriate
3224 * <code>jalview.analysis.AlignmentSorter</code> call. Listeners are added
3225 * to remove the menu item when the treePanel is closed, and adjust
3226 * the tree leaf to sequence mapping when the alignment is modified.
3227 * @param treePanel Displayed tree window.
3228 * @param title SortBy menu item title.
3230 public void buildTreeMenu()
3232 sortByTreeMenu.removeAll();
3234 Vector comps = (Vector) PaintRefresher.components.get(viewport.
3235 getSequenceSetId());
3236 Vector treePanels = new Vector();
3237 int i, iSize = comps.size();
3238 for(i=0; i<iSize; i++)
3240 if(comps.elementAt(i) instanceof TreePanel)
3242 treePanels.add(comps.elementAt(i));
3246 iSize = treePanels.size();
3250 sortByTreeMenu.setVisible(false);
3254 sortByTreeMenu.setVisible(true);
3256 for(i=0; i<treePanels.size(); i++)
3258 TreePanel tp = (TreePanel)treePanels.elementAt(i);
3259 final JMenuItem item = new JMenuItem(tp.getTitle());
3260 final NJTree tree = ((TreePanel)treePanels.elementAt(i)).getTree();
3261 item.addActionListener(new java.awt.event.ActionListener()
3263 public void actionPerformed(ActionEvent e)
3265 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
3266 AlignmentSorter.sortByTree(viewport.getAlignment(), tree);
3268 addHistoryItem(new OrderCommand("Tree Sort",
3270 viewport.alignment));
3272 alignPanel.paintAlignment(true);
3276 sortByTreeMenu.add(item);
3281 * Work out whether the whole set of sequences
3282 * or just the selected set will be submitted for multiple alignment.
3285 public jalview.datamodel.AlignmentView gatherSequencesForAlignment()
3287 // Now, check we have enough sequences
3288 AlignmentView msa = null;
3290 if ( (viewport.getSelectionGroup() != null) &&
3291 (viewport.getSelectionGroup().getSize() > 1))
3293 // JBPNote UGLY! To prettify, make SequenceGroup and Alignment conform to some common interface!
3294 /*SequenceGroup seqs = viewport.getSelectionGroup();
3296 msa = new SequenceI[sz = seqs.getSize(false)];
3298 for (int i = 0; i < sz; i++)
3300 msa[i] = (SequenceI) seqs.getSequenceAt(i);
3302 msa = viewport.getAlignmentView(true);
3306 /*Vector seqs = viewport.getAlignment().getSequences();
3308 if (seqs.size() > 1)
3310 msa = new SequenceI[seqs.size()];
3312 for (int i = 0; i < seqs.size(); i++)
3314 msa[i] = (SequenceI) seqs.elementAt(i);
3317 msa = viewport.getAlignmentView(false);
3323 * Decides what is submitted to a secondary structure prediction service:
3324 * the first sequence in the alignment, or in the current selection,
3325 * or, if the alignment is 'aligned' (ie padded with gaps), then the
3326 * currently selected region or the whole alignment.
3327 * (where the first sequence in the set is the one that the prediction
3330 public AlignmentView gatherSeqOrMsaForSecStrPrediction()
3332 AlignmentView seqs = null;
3334 if ( (viewport.getSelectionGroup() != null) &&
3335 (viewport.getSelectionGroup().getSize() > 0))
3337 seqs = viewport.getAlignmentView(true);
3341 seqs = viewport.getAlignmentView(false);
3343 // limit sequences - JBPNote in future - could spawn multiple prediction jobs
3344 // TODO: viewport.alignment.isAligned is a global state - the local selection may well be aligned - we preserve 2.0.8 behaviour for moment.
3345 if (!viewport.alignment.isAligned())
3347 seqs.setSequences(new SeqCigar[]
3348 {seqs.getSequences()[0]});
3355 * @param e DOCUMENT ME!
3357 protected void LoadtreeMenuItem_actionPerformed(ActionEvent e)
3359 // Pick the tree file
3360 JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
3363 chooser.setFileView(new JalviewFileView());
3364 chooser.setDialogTitle("Select a newick-like tree file");
3365 chooser.setToolTipText("Load a tree file");
3367 int value = chooser.showOpenDialog(null);
3369 if (value == JalviewFileChooser.APPROVE_OPTION)
3371 String choice = chooser.getSelectedFile().getPath();
3372 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
3373 jalview.io.NewickFile fin = null;
3376 fin = new jalview.io.NewickFile(choice,
3378 viewport.setCurrentTree(ShowNewickTree(fin, choice).getTree());
3380 catch (Exception ex)
3382 JOptionPane.showMessageDialog(Desktop.desktop,
3384 "Problem reading tree file",
3385 JOptionPane.WARNING_MESSAGE);
3386 ex.printStackTrace();
3388 if (fin!=null && fin.hasWarningMessage())
3390 JOptionPane.showMessageDialog(Desktop.desktop,
3391 fin.getWarningMessage(),
3392 "Possible problem with tree file",
3393 JOptionPane.WARNING_MESSAGE);
3399 public TreePanel ShowNewickTree(NewickFile nf, String title)
3401 return ShowNewickTree(nf,title,600,500,4,5);
3404 public TreePanel ShowNewickTree(NewickFile nf, String title,
3405 AlignmentView input)
3407 return ShowNewickTree(nf,title, input, 600,500,4,5);
3410 public TreePanel ShowNewickTree(NewickFile nf, String title, int w, int h,
3413 return ShowNewickTree(nf, title, null, w, h, x, y);
3416 * Add a treeviewer for the tree extracted from a newick file object to the current alignment view
3418 * @param nf the tree
3419 * @param title tree viewer title
3420 * @param input Associated alignment input data (or null)
3425 * @return TreePanel handle
3427 public TreePanel ShowNewickTree(NewickFile nf, String title,
3428 AlignmentView input, int w, int h, int x,
3431 TreePanel tp = null;
3437 if (nf.getTree() != null)
3439 tp = new TreePanel(alignPanel,
3448 tp.setLocation(x,y);
3452 Desktop.addInternalFrame(tp, title, w, h);
3455 catch (Exception ex)
3457 ex.printStackTrace();
3465 * Generates menu items and listener event actions for web service clients
3468 public void BuildWebServiceMenu()
3470 // TODO: add support for context dependent disabling of services based on alignment and current selection
3471 // TODO: add additional serviceHandle parameter to specify abstract handler class independently of AbstractName
3472 // TODO: add in rediscovery GUI function to restart discoverer
3473 // TODO: group services by location as well as function and/or introduce object broker mechanism.
3474 if ( (Discoverer.services != null)
3475 && (Discoverer.services.size() > 0))
3477 // TODO: refactor to allow list of AbstractName/Handler bindings to be stored or retrieved from elsewhere
3478 Vector msaws = (Vector) Discoverer.services.get("MsaWS");
3479 Vector secstrpr = (Vector) Discoverer.services.get("SecStrPred");
3480 Vector seqsrch = (Vector) Discoverer.services.get("SeqSearch");
3481 // TODO: move GUI generation code onto service implementation - so a client instance attaches itself to the GUI with method call like jalview.ws.MsaWSClient.bind(servicehandle, Desktop.instance, alignframe)
3482 Vector wsmenu = new Vector();
3483 final IProgressIndicator af = this;
3486 // Add any Multiple Sequence Alignment Services
3487 final JMenu msawsmenu = new JMenu("Alignment");
3488 for (int i = 0, j = msaws.size(); i < j; i++)
3490 final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) msaws.
3492 jalview.ws.WSClient impl = jalview.ws.Discoverer.getServiceClient(sh);
3493 impl.attachWSMenuEntry(msawsmenu, this);
3496 wsmenu.add(msawsmenu);
3498 if (secstrpr != null)
3500 // Add any secondary structure prediction services
3501 final JMenu secstrmenu = new JMenu("Secondary Structure Prediction");
3502 for (int i = 0, j = secstrpr.size(); i < j; i++)
3504 final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle)
3506 jalview.ws.WSClient impl = jalview.ws.Discoverer.getServiceClient(sh);
3507 impl.attachWSMenuEntry(secstrmenu, this);
3509 wsmenu.add(secstrmenu);
3513 // Add any sequence search services
3514 final JMenu seqsrchmenu = new JMenu("Sequence Database Search");
3515 for (int i = 0, j = seqsrch.size(); i < j; i++)
3517 final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle)
3518 seqsrch.elementAt(i);
3519 jalview.ws.WSClient impl = jalview.ws.Discoverer.getServiceClient(sh);
3520 impl.attachWSMenuEntry(seqsrchmenu, this);
3522 // finally, add the whole shebang onto the webservices menu
3523 wsmenu.add(seqsrchmenu);
3525 resetWebServiceMenu();
3526 for (int i = 0, j = wsmenu.size(); i < j; i++)
3528 webService.add( (JMenu) wsmenu.get(i));
3533 resetWebServiceMenu();
3534 this.webService.add(this.webServiceNoServices);
3540 * empty the web service menu and add any ad-hoc functions
3541 * not dynamically discovered.
3544 private void resetWebServiceMenu()
3546 webService.removeAll();
3547 // Temporary hack - DBRef Fetcher always top level ws entry.
3548 JMenuItem rfetch = new JMenuItem("Fetch DB References");
3549 rfetch.setToolTipText("Retrieve and parse sequence database records for the alignment or the currently selected sequences");
3550 webService.add(rfetch);
3551 rfetch.addActionListener(new ActionListener() {
3553 public void actionPerformed(ActionEvent e)
3555 new Thread(new Runnable() {
3559 new jalview.ws.DBRefFetcher(
3560 alignPanel.av.getSequenceSelection(),
3561 alignPanel.alignFrame).fetchDBRefs(false);
3570 /* public void vamsasStore_actionPerformed(ActionEvent e)
3572 JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
3573 getProperty("LAST_DIRECTORY"));
3575 chooser.setFileView(new JalviewFileView());
3576 chooser.setDialogTitle("Export to Vamsas file");
3577 chooser.setToolTipText("Export");
3579 int value = chooser.showSaveDialog(this);
3581 if (value == JalviewFileChooser.APPROVE_OPTION)
3583 jalview.io.VamsasDatastore vs = new jalview.io.VamsasDatastore(viewport);
3584 //vs.store(chooser.getSelectedFile().getAbsolutePath() );
3585 vs.storeJalview( chooser.getSelectedFile().getAbsolutePath(), this);
3589 * prototype of an automatically enabled/disabled analysis function
3592 protected void setShowProductsEnabled()
3594 SequenceI [] selection = viewport.getSequenceSelection();
3595 if (canShowProducts(selection, viewport.getSelectionGroup()!=null, viewport.getAlignment().getDataset()))
3597 showProducts.setEnabled(true);
3600 showProducts.setEnabled(false);
3604 * search selection for sequence xRef products and build the
3605 * show products menu.
3608 * @return true if showProducts menu should be enabled.
3610 public boolean canShowProducts(SequenceI[] selection, boolean isRegionSelection, Alignment dataset)
3612 boolean showp=false;
3614 showProducts.removeAll();
3615 final boolean dna = viewport.getAlignment().isNucleotide();
3616 final Alignment ds = dataset;
3617 String[] ptypes = CrossRef.findSequenceXrefTypes(dna, selection, dataset);
3618 //Object[] prods = CrossRef.buildXProductsList(viewport.getAlignment().isNucleotide(), selection, dataset, true);
3619 final SequenceI[] sel = selection;
3620 for (int t=0; ptypes!=null && t<ptypes.length; t++)
3623 final boolean isRegSel = isRegionSelection;
3624 final AlignFrame af = this;
3625 final String source = ptypes[t];
3626 JMenuItem xtype = new JMenuItem(ptypes[t]);
3627 xtype.addActionListener(new ActionListener() {
3629 public void actionPerformed(ActionEvent e)
3631 // TODO: new thread for this call with vis-delay
3632 af.showProductsFor(af.viewport.getSequenceSelection(), ds, isRegSel, dna, source);
3636 showProducts.add(xtype);
3638 showProducts.setVisible(showp);
3639 showProducts.setEnabled(showp);
3640 } catch (Exception e)
3642 jalview.bin.Cache.log.warn("canTranslate threw an exception - please report to help@jalview.org",e);
3647 protected void showProductsFor(SequenceI[] sel, Alignment ds, boolean isRegSel, boolean dna, String source)
3649 final boolean fisRegSel = isRegSel;
3650 final boolean fdna = dna;
3651 final String fsrc = source;
3652 final AlignFrame ths = this;
3653 final SequenceI[] fsel = sel;
3654 Runnable foo = new Runnable() {
3658 final long sttime = System.currentTimeMillis();
3659 ths.setProgressBar("Searching for sequences from "+fsrc, sttime);
3661 Alignment ds = ths.getViewport().alignment.getDataset(); // update our local dataset reference
3662 Alignment prods = CrossRef.findXrefSequences(fsel, fdna, fsrc, ds);
3665 SequenceI[] sprods = new SequenceI[prods.getHeight()];
3666 for (int s=0; s<sprods.length;s++)
3668 sprods[s] = (prods.getSequenceAt(s)).deriveSequence();
3669 if (ds.getSequences()==null || !ds.getSequences().contains(sprods[s].getDatasetSequence()))
3670 ds.addSequence(sprods[s].getDatasetSequence());
3671 sprods[s].updatePDBIds();
3673 Alignment al = new Alignment(sprods);
3674 AlignedCodonFrame[] cf = prods.getCodonFrames();
3675 for (int s=0; cf!=null && s<cf.length; s++)
3677 al.addCodonFrame(cf[s]);
3681 AlignFrame naf = new AlignFrame(al, DEFAULT_WIDTH, DEFAULT_HEIGHT);
3682 String newtitle =""+((fdna) ? "Proteins " : "Nucleotides ") + " for "+((fisRegSel) ? "selected region of " : "")
3684 Desktop.addInternalFrame(naf, newtitle, DEFAULT_WIDTH,
3687 System.err.println("No Sequences generated for xRef type "+fsrc);
3692 jalview.bin.Cache.log.error("Exception when finding crossreferences",e);
3696 jalview.bin.Cache.log.error("Error when finding crossreferences",e);
3698 ths.setProgressBar("Finished searching for sequences from "+fsrc, sttime);
3702 Thread frunner = new Thread(foo);
3707 public boolean canShowTranslationProducts(SequenceI[] selection, AlignmentI alignment)
3711 return (jalview.analysis.Dna.canTranslate(selection, viewport.getViewAsVisibleContigs(true)));
3712 } catch (Exception e)
3714 jalview.bin.Cache.log.warn("canTranslate threw an exception - please report to help@jalview.org",e);
3719 public void showProducts_actionPerformed(ActionEvent e)
3721 ///////////////////////////////
3722 // Collect Data to be translated/transferred
3724 SequenceI [] selection = viewport.getSequenceSelection();
3725 AlignmentI al = null;
3727 al = jalview.analysis.Dna.CdnaTranslate(selection, viewport.getViewAsVisibleContigs(true),
3728 viewport.getGapCharacter(), viewport.getAlignment().getDataset());
3729 } catch (Exception ex) {
3731 jalview.bin.Cache.log.debug("Exception during translation.",ex);
3735 JOptionPane.showMessageDialog(Desktop.desktop,
3736 "Please select at least three bases in at least one sequence in order to perform a cDNA translation.",
3737 "Translation Failed",
3738 JOptionPane.WARNING_MESSAGE);
3740 AlignFrame af = new AlignFrame(al, DEFAULT_WIDTH, DEFAULT_HEIGHT);
3741 Desktop.addInternalFrame(af, "Translation of "+this.getTitle(),
3747 public void showTranslation_actionPerformed(ActionEvent e)
3749 ///////////////////////////////
3750 // Collect Data to be translated/transferred
3752 SequenceI [] selection = viewport.getSequenceSelection();
3753 String [] seqstring = viewport.getViewAsString(true);
3754 AlignmentI al = null;
3756 al = jalview.analysis.Dna.CdnaTranslate(selection, seqstring, viewport.getViewAsVisibleContigs(true),
3757 viewport.getGapCharacter(), viewport.alignment.getAlignmentAnnotation(),
3758 viewport.alignment.getWidth(), viewport.getAlignment().getDataset());
3759 } catch (Exception ex) {
3761 jalview.bin.Cache.log.debug("Exception during translation.",ex);
3765 JOptionPane.showMessageDialog(Desktop.desktop,
3766 "Please select at least three bases in at least one sequence in order to perform a cDNA translation.",
3767 "Translation Failed",
3768 JOptionPane.WARNING_MESSAGE);
3770 AlignFrame af = new AlignFrame(al, DEFAULT_WIDTH, DEFAULT_HEIGHT);
3771 Desktop.addInternalFrame(af, "Translation of "+this.getTitle(),
3778 * Try to load a features file onto the alignment.
3779 * @param file contents or path to retrieve file
3780 * @param type access mode of file (see jalview.io.AlignFile)
3781 * @return true if features file was parsed corectly.
3783 public boolean parseFeaturesFile(String file, String type)
3785 boolean featuresFile = false;
3788 featuresFile = new FeaturesFile(file,
3789 type).parse(viewport.alignment.getDataset(),
3790 alignPanel.seqPanel.seqCanvas.
3791 getFeatureRenderer().featureColours,
3796 ex.printStackTrace();
3801 viewport.showSequenceFeatures = true;
3802 showSeqFeatures.setSelected(true);
3803 alignPanel.paintAlignment(true);
3806 return featuresFile;
3809 public void dragEnter(DropTargetDragEvent evt)
3812 public void dragExit(DropTargetEvent evt)
3815 public void dragOver(DropTargetDragEvent evt)
3818 public void dropActionChanged(DropTargetDragEvent evt)
3821 public void drop(DropTargetDropEvent evt)
3823 Transferable t = evt.getTransferable();
3824 java.util.List files = null;
3828 DataFlavor uriListFlavor = new DataFlavor(
3829 "text/uri-list;class=java.lang.String");
3830 if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor))
3832 //Works on Windows and MacOSX
3833 evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
3834 files = (java.util.List) t.getTransferData(DataFlavor.
3835 javaFileListFlavor);
3837 else if (t.isDataFlavorSupported(uriListFlavor))
3839 // This is used by Unix drag system
3840 evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
3841 String data = (String) t.getTransferData(uriListFlavor);
3842 files = new java.util.ArrayList(1);
3843 for (java.util.StringTokenizer st = new java.util.StringTokenizer(
3846 st.hasMoreTokens(); )
3848 String s = st.nextToken();
3849 if (s.startsWith("#"))
3851 // the line is a comment (as per the RFC 2483)
3855 java.net.URI uri = new java.net.URI(s);
3856 java.io.File file = new java.io.File(uri);
3863 e.printStackTrace();
3870 for (int i = 0; i < files.size(); i++)
3872 loadJalviewDataFile(files.get(i).toString());
3875 catch (Exception ex)
3877 ex.printStackTrace();
3883 * Attempt to load a "dropped" file: First by testing
3884 * whether it's and Annotation file, then a JNet file, and finally a features file. If all are
3885 * false then the user may have dropped an alignment file onto this
3887 * @param file either a filename or a URL string.
3889 public void loadJalviewDataFile(String file)
3893 String protocol = "File";
3895 if (file.indexOf("http:") > -1 || file.indexOf("file:") > -1)
3900 boolean isAnnotation = new AnnotationFile().readAnnotationFile(viewport.
3901 alignment, file, protocol);
3905 // try to see if its a JNet 'concise' style annotation file *before* we try to parse it as a features file
3906 String format = new IdentifyFile().Identify(file, protocol);
3907 if(format.equalsIgnoreCase("JnetFile"))
3909 jalview.io.JPredFile predictions = new jalview.io.JPredFile(
3911 new JnetAnnotationMaker().add_annotation(predictions,
3912 viewport.getAlignment(),
3918 // try to parse it as a features file
3919 boolean isGroupsFile = parseFeaturesFile(file,protocol);
3920 // if it wasn't a features file then we just treat it as a general alignment file to load into the current view.
3923 new FileLoader().LoadFile(viewport, file, protocol, format);
3925 alignPanel.paintAlignment(true);
3932 alignPanel.adjustAnnotationHeight();
3933 viewport.updateSequenceIdColours();
3934 buildSortByAnnotationScoresMenu();
3935 alignPanel.paintAlignment(true);
3938 catch (Exception ex)
3940 ex.printStackTrace();
3944 public void tabSelectionChanged(int index)
3948 alignPanel = (AlignmentPanel) alignPanels.elementAt(index);
3949 viewport = alignPanel.av;
3950 setMenusFromViewport(viewport);
3954 public void tabbedPane_mousePressed(MouseEvent e)
3956 if(SwingUtilities.isRightMouseButton(e))
3958 String reply = JOptionPane.showInternalInputDialog(this,
3961 JOptionPane.QUESTION_MESSAGE);
3965 viewport.viewName = reply;
3966 tabbedPane.setTitleAt( tabbedPane.getSelectedIndex() ,reply);
3972 public AlignViewport getCurrentView()
3979 * Open the dialog for regex description parsing.
3981 protected void extractScores_actionPerformed(ActionEvent e)
3983 ParseProperties pp = new jalview.analysis.ParseProperties(viewport.alignment);
3984 // TODO: verify regex and introduce GUI dialog for version 2.5
3985 //if (pp.getScoresFromDescription("col", "score column ", "\\W*([-+]?\\d*\\.?\\d*e?-?\\d*)\\W+([-+]?\\d*\\.?\\d*e?-?\\d*)", true)>0)
3986 if (pp.getScoresFromDescription("description column", "score in description column ", "\\W*([-+eE0-9.]+)", true)>0) {
3987 buildSortByAnnotationScoresMenu();
3996 public PrintThread(AlignmentPanel ap)
4000 static PageFormat pf;
4003 PrinterJob printJob = PrinterJob.getPrinterJob();
4007 printJob.setPrintable(ap, pf);
4011 printJob.setPrintable(ap);
4014 if (printJob.printDialog())
4020 catch (Exception PrintException)
4022 PrintException.printStackTrace();