2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import java.awt.BorderLayout;
24 import java.awt.Color;
25 import java.awt.Component;
26 import java.awt.Dimension;
27 import java.awt.Rectangle;
28 import java.awt.Toolkit;
29 import java.awt.datatransfer.Clipboard;
30 import java.awt.datatransfer.DataFlavor;
31 import java.awt.datatransfer.StringSelection;
32 import java.awt.datatransfer.Transferable;
33 import java.awt.dnd.DnDConstants;
34 import java.awt.dnd.DropTargetDragEvent;
35 import java.awt.dnd.DropTargetDropEvent;
36 import java.awt.dnd.DropTargetEvent;
37 import java.awt.dnd.DropTargetListener;
38 import java.awt.event.ActionEvent;
39 import java.awt.event.ActionListener;
40 import java.awt.event.FocusAdapter;
41 import java.awt.event.FocusEvent;
42 import java.awt.event.ItemEvent;
43 import java.awt.event.ItemListener;
44 import java.awt.event.KeyAdapter;
45 import java.awt.event.KeyEvent;
46 import java.awt.event.MouseEvent;
47 import java.awt.print.PageFormat;
48 import java.awt.print.PrinterJob;
49 import java.beans.PropertyChangeEvent;
51 import java.io.FileWriter;
52 import java.io.PrintWriter;
54 import java.util.ArrayList;
55 import java.util.Arrays;
56 import java.util.Deque;
57 import java.util.Enumeration;
58 import java.util.Hashtable;
59 import java.util.List;
60 import java.util.Vector;
62 import javax.swing.ButtonGroup;
63 import javax.swing.JCheckBoxMenuItem;
64 import javax.swing.JComponent;
65 import javax.swing.JEditorPane;
66 import javax.swing.JInternalFrame;
67 import javax.swing.JLabel;
68 import javax.swing.JLayeredPane;
69 import javax.swing.JMenu;
70 import javax.swing.JMenuItem;
71 import javax.swing.JPanel;
72 import javax.swing.JScrollPane;
73 import javax.swing.SwingUtilities;
75 import ext.vamsas.ServiceHandle;
76 import jalview.analysis.AlignmentSorter;
77 import jalview.analysis.AlignmentUtils;
78 import jalview.analysis.CrossRef;
79 import jalview.analysis.Dna;
80 import jalview.analysis.GeneticCodeI;
81 import jalview.analysis.ParseProperties;
82 import jalview.analysis.SequenceIdMatcher;
83 import jalview.api.AlignExportSettingsI;
84 import jalview.api.AlignViewControllerGuiI;
85 import jalview.api.AlignViewControllerI;
86 import jalview.api.AlignViewportI;
87 import jalview.api.AlignmentViewPanel;
88 import jalview.api.FeatureSettingsControllerI;
89 import jalview.api.FeatureSettingsModelI;
90 import jalview.api.SplitContainerI;
91 import jalview.api.ViewStyleI;
92 import jalview.api.analysis.SimilarityParamsI;
93 import jalview.bin.Cache;
94 import jalview.bin.Jalview;
95 import jalview.commands.CommandI;
96 import jalview.commands.EditCommand;
97 import jalview.commands.EditCommand.Action;
98 import jalview.commands.OrderCommand;
99 import jalview.commands.RemoveGapColCommand;
100 import jalview.commands.RemoveGapsCommand;
101 import jalview.commands.SlideSequencesCommand;
102 import jalview.commands.TrimRegionCommand;
103 import jalview.datamodel.AlignExportSettingsAdapter;
104 import jalview.datamodel.AlignedCodonFrame;
105 import jalview.datamodel.Alignment;
106 import jalview.datamodel.AlignmentAnnotation;
107 import jalview.datamodel.AlignmentExportData;
108 import jalview.datamodel.AlignmentI;
109 import jalview.datamodel.AlignmentOrder;
110 import jalview.datamodel.AlignmentView;
111 import jalview.datamodel.ColumnSelection;
112 import jalview.datamodel.HiddenColumns;
113 import jalview.datamodel.PDBEntry;
114 import jalview.datamodel.SeqCigar;
115 import jalview.datamodel.Sequence;
116 import jalview.datamodel.SequenceGroup;
117 import jalview.datamodel.SequenceI;
118 import jalview.gui.ColourMenuHelper.ColourChangeListener;
119 import jalview.gui.ViewSelectionMenu.ViewSetProvider;
120 import jalview.io.AlignmentProperties;
121 import jalview.io.AnnotationFile;
122 import jalview.io.BackupFiles;
123 import jalview.io.BioJsHTMLOutput;
124 import jalview.io.DataSourceType;
125 import jalview.io.FileFormat;
126 import jalview.io.FileFormatI;
127 import jalview.io.FileFormats;
128 import jalview.io.FileLoader;
129 import jalview.io.FileParse;
130 import jalview.io.FormatAdapter;
131 import jalview.io.HtmlSvgOutput;
132 import jalview.io.IdentifyFile;
133 import jalview.io.JPredFile;
134 import jalview.io.JalviewFileChooser;
135 import jalview.io.JalviewFileView;
136 import jalview.io.JnetAnnotationMaker;
137 import jalview.io.NewickFile;
138 import jalview.io.ScoreMatrixFile;
139 import jalview.io.TCoffeeScoreFile;
140 import jalview.io.vcf.VCFLoader;
141 import jalview.jbgui.GAlignFrame;
142 import jalview.project.Jalview2XML;
143 import jalview.schemes.ColourSchemeI;
144 import jalview.schemes.ColourSchemes;
145 import jalview.schemes.ResidueColourScheme;
146 import jalview.schemes.TCoffeeColourScheme;
147 import jalview.util.ImageMaker.TYPE;
148 import jalview.util.MessageManager;
149 import jalview.util.Platform;
150 import jalview.viewmodel.AlignmentViewport;
151 import jalview.viewmodel.ViewportRanges;
152 import jalview.ws.DBRefFetcher;
153 import jalview.ws.DBRefFetcher.FetchFinishedListenerI;
154 import jalview.ws.jws1.Discoverer;
155 import jalview.ws.jws2.Jws2Discoverer;
156 import jalview.ws.jws2.jabaws2.Jws2Instance;
157 import jalview.ws.seqfetcher.DbSourceProxy;
163 * @version $Revision$
165 @SuppressWarnings("serial")
166 public class AlignFrame extends GAlignFrame implements DropTargetListener,
167 IProgressIndicator, AlignViewControllerGuiI, ColourChangeListener
170 public static final int DEFAULT_WIDTH = 700;
172 public static final int DEFAULT_HEIGHT = 500;
175 * The currently displayed panel (selected tabbed view if more than one)
177 public AlignmentPanel alignPanel;
179 AlignViewport viewport;
181 public AlignViewControllerI avc;
183 List<AlignmentPanel> alignPanels = new ArrayList<>();
186 * Last format used to load or save alignments in this window
188 FileFormatI currentFileFormat = null;
191 * Current filename for this alignment
193 String fileName = null;
198 * Creates a new AlignFrame object with specific width and height.
204 public AlignFrame(AlignmentI al, int width, int height)
206 this(al, null, width, height);
210 * Creates a new AlignFrame object with specific width, height and
216 * @param sequenceSetId
218 public AlignFrame(AlignmentI al, int width, int height,
219 String sequenceSetId)
221 this(al, null, width, height, sequenceSetId);
225 * Creates a new AlignFrame object with specific width, height and
231 * @param sequenceSetId
234 public AlignFrame(AlignmentI al, int width, int height,
235 String sequenceSetId, String viewId)
237 this(al, null, width, height, sequenceSetId, viewId);
241 * new alignment window with hidden columns
245 * @param hiddenColumns
246 * ColumnSelection or null
248 * Width of alignment frame
252 public AlignFrame(AlignmentI al, HiddenColumns hiddenColumns, int width,
255 this(al, hiddenColumns, width, height, null);
259 * Create alignment frame for al with hiddenColumns, a specific width and
260 * height, and specific sequenceId
263 * @param hiddenColumns
266 * @param sequenceSetId
269 public AlignFrame(AlignmentI al, HiddenColumns hiddenColumns, int width,
270 int height, String sequenceSetId)
272 this(al, hiddenColumns, width, height, sequenceSetId, null);
276 * Create alignment frame for al with hiddenColumns, a specific width and
277 * height, and specific sequenceId
280 * @param hiddenColumns
283 * @param sequenceSetId
288 public AlignFrame(AlignmentI al, HiddenColumns hiddenColumns, int width,
289 int height, String sequenceSetId, String viewId)
291 setSize(width, height);
293 if (al.getDataset() == null)
298 viewport = new AlignViewport(al, hiddenColumns, sequenceSetId, viewId);
300 alignPanel = new AlignmentPanel(this, viewport);
302 addAlignmentPanel(alignPanel, true);
306 public AlignFrame(AlignmentI al, SequenceI[] hiddenSeqs,
307 HiddenColumns hiddenColumns, int width, int height)
309 setSize(width, height);
311 if (al.getDataset() == null)
316 viewport = new AlignViewport(al, hiddenColumns);
318 if (hiddenSeqs != null && hiddenSeqs.length > 0)
320 viewport.hideSequence(hiddenSeqs);
322 alignPanel = new AlignmentPanel(this, viewport);
323 addAlignmentPanel(alignPanel, true);
328 * Make a new AlignFrame from existing alignmentPanels
335 public AlignFrame(AlignmentPanel ap)
339 addAlignmentPanel(ap, false);
344 * initalise the alignframe from the underlying viewport data and the
349 // setBackground(Color.white); // BH 2019
351 if (!Jalview.isHeadlessMode())
353 progressBar = new ProgressBar(this.statusPanel, this.statusBar);
356 avc = new jalview.controller.AlignViewController(this, viewport,
358 if (viewport.getAlignmentConservationAnnotation() == null)
360 // BLOSUM62Colour.setEnabled(false);
361 conservationMenuItem.setEnabled(false);
362 modifyConservation.setEnabled(false);
363 // PIDColour.setEnabled(false);
364 // abovePIDThreshold.setEnabled(false);
365 // modifyPID.setEnabled(false);
368 String sortby = jalview.bin.Cache.getDefault("SORT_ALIGNMENT",
371 if (sortby.equals("Id"))
373 sortIDMenuItem_actionPerformed(null);
375 else if (sortby.equals("Pairwise Identity"))
377 sortPairwiseMenuItem_actionPerformed(null);
381 .setShowAutocalculatedAbove(isShowAutoCalculatedAbove());
383 setMenusFromViewport(viewport);
384 buildSortByAnnotationScoresMenu();
385 calculateTree.addActionListener(new ActionListener()
389 public void actionPerformed(ActionEvent e)
396 if (Desktop.getDesktopPane() != null)
398 this.setDropTarget(new java.awt.dnd.DropTarget(this, this));
399 if (!Platform.isJS())
401 addServiceListeners();
406 if (viewport.getWrapAlignment())
408 wrapMenuItem_actionPerformed(null);
411 if (jalview.bin.Cache.getDefault("SHOW_OVERVIEW", false))
413 this.overviewMenuItem_actionPerformed(null);
418 final List<AlignmentPanel> selviews = new ArrayList<>();
419 final List<AlignmentPanel> origview = new ArrayList<>();
420 final String menuLabel = MessageManager
421 .getString("label.copy_format_from");
422 ViewSelectionMenu vsel = new ViewSelectionMenu(menuLabel,
423 new ViewSetProvider()
427 public AlignmentPanel[] getAllAlignmentPanels()
430 origview.add(alignPanel);
431 // make an array of all alignment panels except for this one
432 List<AlignmentPanel> aps = new ArrayList<>(
433 Arrays.asList(Desktop.getAlignmentPanels(null)));
434 aps.remove(AlignFrame.this.alignPanel);
435 return aps.toArray(new AlignmentPanel[aps.size()]);
437 }, selviews, new ItemListener()
441 public void itemStateChanged(ItemEvent e)
443 if (origview.size() > 0)
445 final AlignmentPanel ap = origview.get(0);
448 * Copy the ViewStyle of the selected panel to 'this one'.
449 * Don't change value of 'scaleProteinAsCdna' unless copying
452 ViewStyleI vs = selviews.get(0).getAlignViewport()
454 boolean fromSplitFrame = selviews.get(0)
455 .getAlignViewport().getCodingComplement() != null;
458 vs.setScaleProteinAsCdna(ap.getAlignViewport()
459 .getViewStyle().isScaleProteinAsCdna());
461 ap.getAlignViewport().setViewStyle(vs);
464 * Also rescale ViewStyle of SplitFrame complement if there is
465 * one _and_ it is set to 'scaledProteinAsCdna'; we don't copy
466 * the whole ViewStyle (allow cDNA protein to have different
469 AlignViewportI complement = ap.getAlignViewport()
470 .getCodingComplement();
471 if (complement != null && vs.isScaleProteinAsCdna())
473 AlignFrame af = Desktop.getAlignFrameFor(complement);
474 ((SplitFrame) af.getSplitViewContainer())
476 af.setMenusForViewport();
480 ap.setSelected(true);
481 ap.alignFrame.setMenusForViewport();
486 if (Cache.getDefault("VERSION", "DEVELOPMENT").toLowerCase()
487 .indexOf("devel") > -1
488 || Cache.getDefault("VERSION", "DEVELOPMENT").toLowerCase()
489 .indexOf("test") > -1)
491 formatMenu.add(vsel);
493 addFocusListener(new FocusAdapter()
496 public void focusGained(FocusEvent e)
498 Jalview.setCurrentAlignFrame(AlignFrame.this);
505 * Change the filename and format for the alignment, and enable the 'reload'
506 * button functionality.
513 public void setFileName(String file, FileFormatI format)
516 setFileFormat(format);
517 reload.setEnabled(true);
521 * JavaScript will have this, maybe others. More dependable than a file name
522 * and maintains a reference to the actual bytes loaded.
526 public void setFileObject(File file)
528 this.fileObject = file;
532 * Add a KeyListener with handlers for various KeyPressed and KeyReleased
535 void addKeyListener()
537 addKeyListener(new KeyAdapter()
540 public void keyPressed(KeyEvent evt)
542 if (viewport.cursorMode
543 && ((evt.getKeyCode() >= KeyEvent.VK_0
544 && evt.getKeyCode() <= KeyEvent.VK_9)
545 || (evt.getKeyCode() >= KeyEvent.VK_NUMPAD0
546 && evt.getKeyCode() <= KeyEvent.VK_NUMPAD9))
547 && Character.isDigit(evt.getKeyChar()))
549 alignPanel.getSeqPanel().numberPressed(evt.getKeyChar());
552 switch (evt.getKeyCode())
555 case 27: // escape key
556 deselectAllSequenceMenuItem_actionPerformed(null);
560 case KeyEvent.VK_DOWN:
561 if (evt.isAltDown() || !viewport.cursorMode)
563 moveSelectedSequences(false);
565 if (viewport.cursorMode)
567 alignPanel.getSeqPanel().moveCursor(0, 1);
572 if (evt.isAltDown() || !viewport.cursorMode)
574 moveSelectedSequences(true);
576 if (viewport.cursorMode)
578 alignPanel.getSeqPanel().moveCursor(0, -1);
583 case KeyEvent.VK_LEFT:
584 if (evt.isAltDown() || !viewport.cursorMode)
586 slideSequences(false,
587 alignPanel.getSeqPanel().getKeyboardNo1());
591 alignPanel.getSeqPanel().moveCursor(-1, 0);
596 case KeyEvent.VK_RIGHT:
597 if (evt.isAltDown() || !viewport.cursorMode)
599 slideSequences(true, alignPanel.getSeqPanel().getKeyboardNo1());
603 alignPanel.getSeqPanel().moveCursor(1, 0);
607 case KeyEvent.VK_SPACE:
608 if (viewport.cursorMode)
610 alignPanel.getSeqPanel().insertGapAtCursor(evt.isControlDown()
611 || evt.isShiftDown() || evt.isAltDown());
615 // case KeyEvent.VK_A:
616 // if (viewport.cursorMode)
618 // alignPanel.seqPanel.insertNucAtCursor(false,"A");
619 // //System.out.println("A");
623 * case KeyEvent.VK_CLOSE_BRACKET: if (viewport.cursorMode) {
624 * System.out.println("closing bracket"); } break;
626 case KeyEvent.VK_DELETE:
627 case KeyEvent.VK_BACK_SPACE:
628 if (!viewport.cursorMode)
630 cut_actionPerformed();
634 alignPanel.getSeqPanel().deleteGapAtCursor(evt.isControlDown()
635 || evt.isShiftDown() || evt.isAltDown());
641 if (viewport.cursorMode)
643 alignPanel.getSeqPanel().setCursorRow();
647 if (viewport.cursorMode && !evt.isControlDown())
649 alignPanel.getSeqPanel().setCursorColumn();
653 if (viewport.cursorMode)
655 alignPanel.getSeqPanel().setCursorPosition();
659 case KeyEvent.VK_ENTER:
660 case KeyEvent.VK_COMMA:
661 if (viewport.cursorMode)
663 alignPanel.getSeqPanel().setCursorRowAndColumn();
668 if (viewport.cursorMode)
670 alignPanel.getSeqPanel().setSelectionAreaAtCursor(true);
674 if (viewport.cursorMode)
676 alignPanel.getSeqPanel().setSelectionAreaAtCursor(false);
681 viewport.cursorMode = !viewport.cursorMode;
682 setStatus(MessageManager
683 .formatMessage("label.keyboard_editing_mode", new String[]
684 { (viewport.cursorMode ? "on" : "off") }));
685 if (viewport.cursorMode)
687 ViewportRanges ranges = viewport.getRanges();
688 alignPanel.getSeqPanel().seqCanvas.cursorX = ranges
690 alignPanel.getSeqPanel().seqCanvas.cursorY = ranges
693 alignPanel.getSeqPanel().seqCanvas.repaint();
699 Help.showHelpWindow();
700 } catch (Exception ex)
702 ex.printStackTrace();
707 boolean toggleSeqs = !evt.isControlDown();
708 boolean toggleCols = !evt.isShiftDown();
709 toggleHiddenRegions(toggleSeqs, toggleCols);
714 boolean toggleSel = evt.isControlDown() || evt.isMetaDown();
715 boolean modifyExisting = true; // always modify, don't clear
716 // evt.isShiftDown();
717 boolean invertHighlighted = evt.isAltDown();
718 avc.markHighlightedColumns(invertHighlighted, modifyExisting,
722 case KeyEvent.VK_PAGE_UP:
723 viewport.getRanges().pageUp();
725 case KeyEvent.VK_PAGE_DOWN:
726 viewport.getRanges().pageDown();
732 public void keyReleased(KeyEvent evt)
734 switch (evt.getKeyCode())
736 case KeyEvent.VK_LEFT:
737 if (evt.isAltDown() || !viewport.cursorMode)
739 viewport.firePropertyChange("alignment", null,
740 viewport.getAlignment().getSequences());
744 case KeyEvent.VK_RIGHT:
745 if (evt.isAltDown() || !viewport.cursorMode)
747 viewport.firePropertyChange("alignment", null,
748 viewport.getAlignment().getSequences());
756 public void addAlignmentPanel(final AlignmentPanel ap, boolean newPanel)
758 ap.alignFrame = this;
759 avc = new jalview.controller.AlignViewController(this, viewport,
764 PaintRefresher.Register(ap, ap.av.getSequenceSetId());
766 int aSize = alignPanels.size();
768 tabbedPane.setVisible(aSize > 1 || ap.av.getViewName() != null);
770 if (aSize == 1 && ap.av.getViewName() == null)
772 this.getContentPane().add(ap, BorderLayout.CENTER);
778 setInitialTabVisible();
781 expandViews.setEnabled(true);
782 gatherViews.setEnabled(true);
783 tabbedPane.addTab(ap.av.getViewName(), ap);
785 ap.setVisible(false);
790 if (ap.av.isPadGaps())
792 ap.av.getAlignment().padGaps();
794 ap.av.updateConservation(ap);
795 ap.av.updateConsensus(ap);
796 ap.av.updateStrucConsensus(ap);
800 public void setInitialTabVisible()
802 expandViews.setEnabled(true);
803 gatherViews.setEnabled(true);
804 tabbedPane.setVisible(true);
805 AlignmentPanel first = alignPanels.get(0);
806 tabbedPane.addTab(first.av.getViewName(), first);
807 this.getContentPane().add(tabbedPane, BorderLayout.CENTER);
810 public AlignViewport getViewport()
815 /* Set up intrinsic listeners for dynamically generated GUI bits. */
816 private void addServiceListeners()
818 final java.beans.PropertyChangeListener thisListener;
819 Desktop.getInstance().addJalviewPropertyChangeListener("services",
820 thisListener = new java.beans.PropertyChangeListener()
823 public void propertyChange(PropertyChangeEvent evt)
825 // // System.out.println("Discoverer property change.");
826 // if (evt.getPropertyName().equals("services"))
828 SwingUtilities.invokeLater(new Runnable()
835 "Rebuild WS Menu for service change");
836 BuildWebServiceMenu();
843 addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
846 public void internalFrameClosed(
847 javax.swing.event.InternalFrameEvent evt)
849 // System.out.println("deregistering discoverer listener");
850 Desktop.getInstance().removeJalviewPropertyChangeListener(
851 "services", thisListener);
852 closeMenuItem_actionPerformed(true);
855 // Finally, build the menu once to get current service state
856 new Thread(new Runnable()
861 BuildWebServiceMenu();
867 * Configure menu items that vary according to whether the alignment is
868 * nucleotide or protein
870 public void setGUINucleotide()
872 AlignmentI al = getViewport().getAlignment();
873 boolean nucleotide = al.isNucleotide();
875 loadVcf.setVisible(nucleotide);
876 showTranslation.setVisible(nucleotide);
877 showReverse.setVisible(nucleotide);
878 showReverseComplement.setVisible(nucleotide);
879 conservationMenuItem.setEnabled(!nucleotide);
881 .setEnabled(!nucleotide && conservationMenuItem.isSelected());
882 showGroupConservation.setEnabled(!nucleotide);
884 showComplementMenuItem
885 .setText(nucleotide ? MessageManager.getString("label.protein")
886 : MessageManager.getString("label.nucleotide"));
890 * set up menus for the current viewport. This may be called after any
891 * operation that affects the data in the current view (selection changed,
892 * etc) to update the menus to reflect the new state.
895 public void setMenusForViewport()
897 setMenusFromViewport(viewport);
901 * Need to call this method when tabs are selected for multiple views, or when
902 * loading from Jalview2XML.java
907 public void setMenusFromViewport(AlignViewport av)
909 padGapsMenuitem.setSelected(av.isPadGaps());
910 colourTextMenuItem.setSelected(av.isShowColourText());
911 abovePIDThreshold.setSelected(av.getAbovePIDThreshold());
912 modifyPID.setEnabled(abovePIDThreshold.isSelected());
913 conservationMenuItem.setSelected(av.getConservationSelected());
914 modifyConservation.setEnabled(conservationMenuItem.isSelected());
915 seqLimits.setSelected(av.getShowJVSuffix());
916 idRightAlign.setSelected(av.isRightAlignIds());
917 centreColumnLabelsMenuItem.setState(av.isCentreColumnLabels());
918 renderGapsMenuItem.setSelected(av.isRenderGaps());
919 wrapMenuItem.setSelected(av.getWrapAlignment());
920 scaleAbove.setVisible(av.getWrapAlignment());
921 scaleLeft.setVisible(av.getWrapAlignment());
922 scaleRight.setVisible(av.getWrapAlignment());
923 annotationPanelMenuItem.setState(av.isShowAnnotation());
925 * Show/hide annotations only enabled if annotation panel is shown
927 showAllSeqAnnotations.setEnabled(annotationPanelMenuItem.getState());
928 hideAllSeqAnnotations.setEnabled(annotationPanelMenuItem.getState());
929 showAllAlAnnotations.setEnabled(annotationPanelMenuItem.getState());
930 hideAllAlAnnotations.setEnabled(annotationPanelMenuItem.getState());
931 viewBoxesMenuItem.setSelected(av.getShowBoxes());
932 viewTextMenuItem.setSelected(av.getShowText());
933 showNonconservedMenuItem.setSelected(av.getShowUnconserved());
934 showGroupConsensus.setSelected(av.isShowGroupConsensus());
935 showGroupConservation.setSelected(av.isShowGroupConservation());
936 showConsensusHistogram.setSelected(av.isShowConsensusHistogram());
937 showSequenceLogo.setSelected(av.isShowSequenceLogo());
938 normaliseSequenceLogo.setSelected(av.isNormaliseSequenceLogo());
940 ColourMenuHelper.setColourSelected(colourMenu,
941 av.getGlobalColourScheme());
943 showSeqFeatures.setSelected(av.isShowSequenceFeatures());
944 hiddenMarkers.setState(av.getShowHiddenMarkers());
945 applyToAllGroups.setState(av.getColourAppliesToAllGroups());
946 showNpFeatsMenuitem.setSelected(av.isShowNPFeats());
947 showDbRefsMenuitem.setSelected(av.isShowDBRefs());
948 autoCalculate.setSelected(av.autoCalculateConsensus);
949 sortByTree.setSelected(av.sortByTree);
950 listenToViewSelections.setSelected(av.followSelection);
952 showProducts.setEnabled(canShowProducts());
953 setGroovyEnabled(Desktop.getGroovyConsole() != null);
959 * Set the enabled state of the 'Run Groovy' option in the Calculate menu
963 public void setGroovyEnabled(boolean b)
965 runGroovy.setEnabled(b);
968 private IProgressIndicator progressBar;
973 * @see jalview.gui.IProgressIndicator#setProgressBar(java.lang.String, long)
976 public void setProgressBar(String message, long id)
978 progressBar.setProgressBar(message, id);
982 public void registerHandler(final long id,
983 final IProgressIndicatorHandler handler)
985 progressBar.registerHandler(id, handler);
990 * @return true if any progress bars are still active
993 public boolean operationInProgress()
995 return progressBar.operationInProgress();
999 * Sets the text of the status bar. Note that setting a null or empty value
1000 * will cause the status bar to be hidden, with possibly undesirable flicker
1001 * of the screen layout.
1004 public void setStatus(String text)
1006 statusBar.setText(text == null || text.isEmpty() ? " " : text);
1010 * Added so Castor Mapping file can obtain Jalview Version
1012 public String getVersion()
1014 return jalview.bin.Cache.getProperty("VERSION");
1017 public FeatureRenderer getFeatureRenderer()
1019 return alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer();
1023 public void fetchSequence_actionPerformed()
1025 new SequenceFetcher(this);
1029 public void addFromFile_actionPerformed(ActionEvent e)
1031 Desktop.getInstance().inputLocalFileMenuItem_actionPerformed(viewport);
1035 public void reload_actionPerformed(ActionEvent e)
1037 if (fileName != null)
1039 // TODO: JAL-1108 - ensure all associated frames are closed regardless of
1040 // originating file's format
1041 // TODO: work out how to recover feature settings for correct view(s) when
1042 // file is reloaded.
1043 if (FileFormat.Jalview.equals(currentFileFormat))
1045 JInternalFrame[] frames = Desktop.getDesktopPane().getAllFrames();
1046 for (int i = 0; i < frames.length; i++)
1048 if (frames[i] instanceof AlignFrame && frames[i] != this
1049 && ((AlignFrame) frames[i]).fileName != null
1050 && ((AlignFrame) frames[i]).fileName.equals(fileName))
1054 frames[i].setSelected(true);
1055 Desktop.getInstance().closeAssociatedWindows();
1056 } catch (java.beans.PropertyVetoException ex)
1062 Desktop.getInstance().closeAssociatedWindows();
1064 FileLoader loader = new FileLoader();
1065 DataSourceType protocol = fileName.startsWith("http:")
1066 ? DataSourceType.URL
1067 : DataSourceType.FILE;
1068 loader.LoadFile(viewport, fileName, protocol, currentFileFormat);
1072 Rectangle bounds = this.getBounds();
1074 FileLoader loader = new FileLoader();
1076 AlignFrame newframe = null;
1078 if (fileObject == null)
1081 DataSourceType protocol = (fileName.startsWith("http:")
1082 ? DataSourceType.URL
1083 : DataSourceType.FILE);
1084 newframe = loader.LoadFileWaitTillLoaded(fileName, protocol,
1089 newframe = loader.LoadFileWaitTillLoaded(fileObject,
1090 DataSourceType.FILE, currentFileFormat);
1093 newframe.setBounds(bounds);
1094 if (featureSettings != null && featureSettings.isShowing())
1096 final Rectangle fspos = featureSettings.frame.getBounds();
1097 // TODO: need a 'show feature settings' function that takes bounds -
1098 // need to refactor Desktop.addFrame
1099 newframe.featureSettings_actionPerformed(null);
1100 final FeatureSettings nfs = newframe.featureSettings;
1101 SwingUtilities.invokeLater(new Runnable()
1106 nfs.frame.setBounds(fspos);
1109 this.featureSettings.close();
1110 this.featureSettings = null;
1112 this.closeMenuItem_actionPerformed(true);
1118 public void addFromText_actionPerformed(ActionEvent e)
1120 Desktop.getInstance()
1121 .inputTextboxMenuItem_actionPerformed(viewport.getAlignPanel());
1125 public void addFromURL_actionPerformed(ActionEvent e)
1127 Desktop.getInstance().inputURLMenuItem_actionPerformed(viewport);
1131 public void save_actionPerformed(ActionEvent e)
1133 if (fileName == null || (currentFileFormat == null)
1134 || fileName.startsWith("http"))
1136 saveAs_actionPerformed();
1140 saveAlignment(fileName, currentFileFormat);
1145 * Saves the alignment to a file with a name chosen by the user, if necessary
1146 * warning if a file would be overwritten
1149 public void saveAs_actionPerformed()
1151 String format = currentFileFormat == null ? null
1152 : currentFileFormat.getName();
1153 JalviewFileChooser chooser = JalviewFileChooser
1154 .forWrite(Cache.getProperty("LAST_DIRECTORY"), format);
1156 chooser.setFileView(new JalviewFileView());
1157 chooser.setDialogTitle(
1158 MessageManager.getString("label.save_alignment_to_file"));
1159 chooser.setToolTipText(MessageManager.getString("action.save"));
1161 int value = chooser.showSaveDialog(this);
1163 if (value != JalviewFileChooser.APPROVE_OPTION)
1167 currentFileFormat = chooser.getSelectedFormat();
1168 // todo is this (2005) test now obsolete - value is never null?
1169 while (currentFileFormat == null)
1171 JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
1173 .getString("label.select_file_format_before_saving"),
1174 MessageManager.getString("label.file_format_not_specified"),
1175 JvOptionPane.WARNING_MESSAGE);
1176 currentFileFormat = chooser.getSelectedFormat();
1177 value = chooser.showSaveDialog(this);
1178 if (value != JalviewFileChooser.APPROVE_OPTION)
1184 fileName = chooser.getSelectedFile().getPath();
1186 Cache.setProperty("DEFAULT_FILE_FORMAT", currentFileFormat.getName());
1187 Cache.setProperty("LAST_DIRECTORY", fileName);
1188 saveAlignment(fileName, currentFileFormat);
1191 boolean lastSaveSuccessful = false;
1193 FileFormatI lastFormatSaved;
1195 String lastFilenameSaved;
1198 * Raise a dialog or status message for the last call to saveAlignment.
1200 * @return true if last call to saveAlignment(file, format) was successful.
1202 public boolean isSaveAlignmentSuccessful()
1205 if (!lastSaveSuccessful)
1207 JvOptionPane.showInternalMessageDialog(this, MessageManager
1208 .formatMessage("label.couldnt_save_file", new Object[]
1209 { lastFilenameSaved }),
1210 MessageManager.getString("label.error_saving_file"),
1211 JvOptionPane.WARNING_MESSAGE);
1216 setStatus(MessageManager.formatMessage(
1217 "label.successfully_saved_to_file_in_format", new Object[]
1218 { lastFilenameSaved, lastFormatSaved }));
1221 return lastSaveSuccessful;
1225 * Saves the alignment to the specified file path, in the specified format,
1226 * which may be an alignment format, or Jalview project format. If the
1227 * alignment has hidden regions, or the format is one capable of including
1228 * non-sequence data (features, annotations, groups), then the user may be
1229 * prompted to specify what to include in the output.
1234 public void saveAlignment(String file, FileFormatI format)
1236 lastSaveSuccessful = true;
1237 lastFilenameSaved = file;
1238 lastFormatSaved = format;
1240 if (FileFormat.Jalview.equals(format))
1242 String shortName = title;
1243 if (shortName.indexOf(File.separatorChar) > -1)
1245 shortName = shortName
1246 .substring(shortName.lastIndexOf(File.separatorChar) + 1);
1248 lastSaveSuccessful = new Jalview2XML().saveAlignment(this, file,
1251 statusBar.setText(MessageManager.formatMessage(
1252 "label.successfully_saved_to_file_in_format", new Object[]
1253 { fileName, format }));
1258 AlignExportSettingsI options = new AlignExportSettingsAdapter(false);
1259 Runnable cancelAction = new Runnable()
1264 lastSaveSuccessful = false;
1267 Runnable outputAction = new Runnable()
1272 // todo defer this to inside formatSequences (or later)
1273 AlignmentExportData exportData = viewport
1274 .getAlignExportData(options);
1275 String output = new FormatAdapter(alignPanel, options)
1276 .formatSequences(format, exportData.getAlignment(),
1277 exportData.getOmitHidden(),
1278 exportData.getStartEndPostions(),
1279 viewport.getAlignment().getHiddenColumns());
1282 lastSaveSuccessful = false;
1286 // create backupfiles object and get new temp filename destination
1287 boolean doBackup = BackupFiles.getEnabled();
1288 BackupFiles backupfiles = doBackup ? new BackupFiles(file) : null;
1291 String tempFilePath = doBackup ? backupfiles.getTempFilePath()
1293 PrintWriter out = new PrintWriter(new FileWriter(tempFilePath));
1297 AlignFrame.this.setTitle(file);
1298 statusBar.setText(MessageManager.formatMessage(
1299 "label.successfully_saved_to_file_in_format",
1301 { fileName, format.getName() }));
1302 lastSaveSuccessful = true;
1303 } catch (Exception ex)
1305 lastSaveSuccessful = false;
1306 ex.printStackTrace();
1311 backupfiles.setWriteSuccess(lastSaveSuccessful);
1312 // do the backup file roll and rename the temp file to actual file
1313 lastSaveSuccessful = backupfiles.rollBackupsAndRenameTempFile();
1320 * show dialog with export options if applicable; else just do it
1322 if (AlignExportOptions.isNeeded(viewport, format))
1324 AlignExportOptions choices = new AlignExportOptions(
1325 alignPanel.getAlignViewport(), format, options);
1326 choices.setResponseAction(0, outputAction);
1327 choices.setResponseAction(1, cancelAction);
1328 choices.showDialog();
1337 * Outputs the alignment to textbox in the requested format, if necessary
1338 * first prompting the user for whether to include hidden regions or
1341 * @param fileFormatName
1344 protected void outputText_actionPerformed(String fileFormatName)
1346 FileFormatI fileFormat = FileFormats.getInstance()
1347 .forName(fileFormatName);
1348 AlignExportSettingsI options = new AlignExportSettingsAdapter(false);
1349 Runnable outputAction = new Runnable()
1354 // todo defer this to inside formatSequences (or later)
1355 AlignmentExportData exportData = viewport
1356 .getAlignExportData(options);
1357 CutAndPasteTransfer cap = new CutAndPasteTransfer();
1358 cap.setForInput(null);
1361 FileFormatI format = fileFormat;
1362 cap.setText(new FormatAdapter(alignPanel, options)
1363 .formatSequences(format, exportData.getAlignment(),
1364 exportData.getOmitHidden(),
1365 exportData.getStartEndPostions(),
1366 viewport.getAlignment().getHiddenColumns()));
1367 Desktop.addInternalFrame(cap, MessageManager.formatMessage(
1368 "label.alignment_output_command", new Object[]
1369 { fileFormat.getName() }), 600, 500);
1370 } catch (OutOfMemoryError oom)
1372 new OOMWarning("Outputting alignment as " + fileFormat.getName(),
1380 * show dialog with export options if applicable; else just do it
1382 if (AlignExportOptions.isNeeded(viewport, fileFormat))
1384 AlignExportOptions choices = new AlignExportOptions(
1385 alignPanel.getAlignViewport(), fileFormat, options);
1386 choices.setResponseAction(0, outputAction);
1387 choices.showDialog();
1402 protected void htmlMenuItem_actionPerformed(ActionEvent e)
1404 HtmlSvgOutput htmlSVG = new HtmlSvgOutput(alignPanel);
1405 htmlSVG.exportHTML(null);
1409 public void bioJSMenuItem_actionPerformed(ActionEvent e)
1411 BioJsHTMLOutput bjs = new BioJsHTMLOutput(alignPanel);
1412 bjs.exportHTML(null);
1415 public void createImageMap(File file, String image)
1417 alignPanel.makePNGImageMap(file, image);
1421 * Creates a PNG image of the alignment and writes it to the given file. If
1422 * the file is null, the user is prompted to choose a file.
1427 public void createPNG(File f)
1429 alignPanel.makeAlignmentImage(TYPE.PNG, f);
1433 * Creates an EPS image of the alignment and writes it to the given file. If
1434 * the file is null, the user is prompted to choose a file.
1439 public void createEPS(File f)
1441 alignPanel.makeAlignmentImage(TYPE.EPS, f);
1445 * Creates an SVG image of the alignment and writes it to the given file. If
1446 * the file is null, the user is prompted to choose a file.
1451 public void createSVG(File f)
1453 alignPanel.makeAlignmentImage(TYPE.SVG, f);
1457 public void pageSetup_actionPerformed(ActionEvent e)
1459 PrinterJob printJob = PrinterJob.getPrinterJob();
1460 PrintThread.pf = printJob.pageDialog(printJob.defaultPage());
1470 public void printMenuItem_actionPerformed(ActionEvent e)
1472 // Putting in a thread avoids Swing painting problems
1473 PrintThread thread = new PrintThread(alignPanel);
1478 public void exportFeatures_actionPerformed(ActionEvent e)
1480 new AnnotationExporter(alignPanel).exportFeatures();
1484 public void exportAnnotations_actionPerformed(ActionEvent e)
1486 new AnnotationExporter(alignPanel).exportAnnotations();
1490 public void associatedData_actionPerformed(ActionEvent e)
1492 final JalviewFileChooser chooser = new JalviewFileChooser(
1493 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
1494 chooser.setFileView(new JalviewFileView());
1495 String tooltip = MessageManager
1496 .getString("label.load_jalview_annotations");
1497 chooser.setDialogTitle(tooltip);
1498 chooser.setToolTipText(tooltip);
1499 chooser.setResponseHandler(0, new Runnable()
1504 String choice = chooser.getSelectedFile().getPath();
1505 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
1506 loadJalviewDataFile(chooser.getSelectedFile(), null, null, null);
1510 chooser.showOpenDialog(this);
1514 * Close the current view or all views in the alignment frame. If the frame
1515 * only contains one view then the alignment will be removed from memory.
1517 * @param closeAllTabs
1520 public void closeMenuItem_actionPerformed(boolean closeAllTabs)
1522 if (alignPanels != null && alignPanels.size() < 2)
1524 closeAllTabs = true;
1529 if (alignPanels != null)
1533 if (this.isClosed())
1535 // really close all the windows - otherwise wait till
1536 // setClosed(true) is called
1537 for (int i = 0; i < alignPanels.size(); i++)
1539 AlignmentPanel ap = alignPanels.get(i);
1546 closeView(alignPanel);
1551 if (featureSettings != null && featureSettings.isOpen())
1553 featureSettings.close();
1554 featureSettings = null;
1557 * this will raise an INTERNAL_FRAME_CLOSED event and this method will
1558 * be called recursively, with the frame now in 'closed' state
1560 this.setClosed(true);
1562 } catch (Exception ex)
1564 ex.printStackTrace();
1569 * Close the specified panel and close up tabs appropriately.
1571 * @param panelToClose
1573 public void closeView(AlignmentPanel panelToClose)
1575 int index = tabbedPane.getSelectedIndex();
1576 int closedindex = tabbedPane.indexOfComponent(panelToClose);
1577 alignPanels.remove(panelToClose);
1578 panelToClose.closePanel();
1579 panelToClose = null;
1581 tabbedPane.removeTabAt(closedindex);
1582 tabbedPane.validate();
1584 if (index > closedindex || index == tabbedPane.getTabCount())
1586 // modify currently selected tab index if necessary.
1590 this.tabSelectionChanged(index);
1596 void updateEditMenuBar()
1599 if (viewport.getHistoryList().size() > 0)
1601 undoMenuItem.setEnabled(true);
1602 CommandI command = viewport.getHistoryList().peek();
1603 undoMenuItem.setText(MessageManager
1604 .formatMessage("label.undo_command", new Object[]
1605 { command.getDescription() }));
1609 undoMenuItem.setEnabled(false);
1610 undoMenuItem.setText(MessageManager.getString("action.undo"));
1613 if (viewport.getRedoList().size() > 0)
1615 redoMenuItem.setEnabled(true);
1617 CommandI command = viewport.getRedoList().peek();
1618 redoMenuItem.setText(MessageManager
1619 .formatMessage("label.redo_command", new Object[]
1620 { command.getDescription() }));
1624 redoMenuItem.setEnabled(false);
1625 redoMenuItem.setText(MessageManager.getString("action.redo"));
1630 public void addHistoryItem(CommandI command)
1632 if (command.getSize() > 0)
1634 viewport.addToHistoryList(command);
1635 viewport.clearRedoList();
1636 updateEditMenuBar();
1637 viewport.updateHiddenColumns();
1638 // viewport.hasHiddenColumns = (viewport.getColumnSelection() != null
1639 // && viewport.getColumnSelection().getHiddenColumns() != null &&
1640 // viewport.getColumnSelection()
1641 // .getHiddenColumns().size() > 0);
1647 * @return alignment objects for all views
1649 AlignmentI[] getViewAlignments()
1651 if (alignPanels != null)
1653 AlignmentI[] als = new AlignmentI[alignPanels.size()];
1655 for (AlignmentPanel ap : alignPanels)
1657 als[i++] = ap.av.getAlignment();
1661 if (viewport != null)
1663 return new AlignmentI[] { viewport.getAlignment() };
1675 protected void undoMenuItem_actionPerformed(ActionEvent e)
1677 if (viewport.getHistoryList().isEmpty())
1681 CommandI command = viewport.getHistoryList().pop();
1682 viewport.addToRedoList(command);
1683 command.undoCommand(getViewAlignments());
1685 AlignmentViewport originalSource = getOriginatingSource(command);
1686 updateEditMenuBar();
1688 if (originalSource != null)
1690 if (originalSource != viewport)
1693 "Implementation worry: mismatch of viewport origin for undo");
1695 originalSource.updateHiddenColumns();
1696 // originalSource.hasHiddenColumns = (viewport.getColumnSelection() !=
1698 // && viewport.getColumnSelection().getHiddenColumns() != null &&
1699 // viewport.getColumnSelection()
1700 // .getHiddenColumns().size() > 0);
1701 originalSource.firePropertyChange("alignment", null,
1702 originalSource.getAlignment().getSequences());
1713 protected void redoMenuItem_actionPerformed(ActionEvent e)
1715 if (viewport.getRedoList().size() < 1)
1720 CommandI command = viewport.getRedoList().pop();
1721 viewport.addToHistoryList(command);
1722 command.doCommand(getViewAlignments());
1724 AlignmentViewport originalSource = getOriginatingSource(command);
1725 updateEditMenuBar();
1727 if (originalSource != null)
1730 if (originalSource != viewport)
1733 "Implementation worry: mismatch of viewport origin for redo");
1735 originalSource.updateHiddenColumns();
1736 // originalSource.hasHiddenColumns = (viewport.getColumnSelection() !=
1738 // && viewport.getColumnSelection().getHiddenColumns() != null &&
1739 // viewport.getColumnSelection()
1740 // .getHiddenColumns().size() > 0);
1741 originalSource.firePropertyChange("alignment", null,
1742 originalSource.getAlignment().getSequences());
1746 AlignmentViewport getOriginatingSource(CommandI command)
1748 AlignmentViewport originalSource = null;
1749 // For sequence removal and addition, we need to fire
1750 // the property change event FROM the viewport where the
1751 // original alignment was altered
1752 AlignmentI al = null;
1753 if (command instanceof EditCommand)
1755 EditCommand editCommand = (EditCommand) command;
1756 al = editCommand.getAlignment();
1757 List<Component> comps = PaintRefresher.components
1758 .get(viewport.getSequenceSetId());
1760 for (Component comp : comps)
1762 if (comp instanceof AlignmentPanel)
1764 if (al == ((AlignmentPanel) comp).av.getAlignment())
1766 originalSource = ((AlignmentPanel) comp).av;
1773 if (originalSource == null)
1775 // The original view is closed, we must validate
1776 // the current view against the closed view first
1779 PaintRefresher.validateSequences(al, viewport.getAlignment());
1782 originalSource = viewport;
1785 return originalSource;
1794 public void moveSelectedSequences(boolean up)
1796 SequenceGroup sg = viewport.getSelectionGroup();
1802 viewport.getAlignment().moveSelectedSequencesByOne(sg,
1803 viewport.getHiddenRepSequences(), up);
1804 alignPanel.paintAlignment(true, false);
1807 synchronized void slideSequences(boolean right, int size)
1809 List<SequenceI> sg = new ArrayList<>();
1810 if (viewport.cursorMode)
1812 sg.add(viewport.getAlignment()
1813 .getSequenceAt(alignPanel.getSeqPanel().seqCanvas.cursorY));
1815 else if (viewport.getSelectionGroup() != null
1816 && viewport.getSelectionGroup().getSize() != viewport
1817 .getAlignment().getHeight())
1819 sg = viewport.getSelectionGroup()
1820 .getSequences(viewport.getHiddenRepSequences());
1828 List<SequenceI> invertGroup = new ArrayList<>();
1830 for (SequenceI seq : viewport.getAlignment().getSequences())
1832 if (!sg.contains(seq))
1834 invertGroup.add(seq);
1838 SequenceI[] seqs1 = sg.toArray(new SequenceI[0]);
1840 SequenceI[] seqs2 = new SequenceI[invertGroup.size()];
1841 for (int i = 0; i < invertGroup.size(); i++)
1843 seqs2[i] = invertGroup.get(i);
1846 SlideSequencesCommand ssc;
1849 ssc = new SlideSequencesCommand("Slide Sequences", seqs2, seqs1, size,
1850 viewport.getGapCharacter());
1854 ssc = new SlideSequencesCommand("Slide Sequences", seqs1, seqs2, size,
1855 viewport.getGapCharacter());
1858 int groupAdjustment = 0;
1859 if (ssc.getGapsInsertedBegin() && right)
1861 if (viewport.cursorMode)
1863 alignPanel.getSeqPanel().moveCursor(size, 0);
1867 groupAdjustment = size;
1870 else if (!ssc.getGapsInsertedBegin() && !right)
1872 if (viewport.cursorMode)
1874 alignPanel.getSeqPanel().moveCursor(-size, 0);
1878 groupAdjustment = -size;
1882 if (groupAdjustment != 0)
1884 viewport.getSelectionGroup().setStartRes(
1885 viewport.getSelectionGroup().getStartRes() + groupAdjustment);
1886 viewport.getSelectionGroup().setEndRes(
1887 viewport.getSelectionGroup().getEndRes() + groupAdjustment);
1891 * just extend the last slide command if compatible; but not if in
1892 * SplitFrame mode (to ensure all edits are broadcast - JAL-1802)
1894 boolean appendHistoryItem = false;
1895 Deque<CommandI> historyList = viewport.getHistoryList();
1896 boolean inSplitFrame = getSplitViewContainer() != null;
1897 if (!inSplitFrame && historyList != null && historyList.size() > 0
1898 && historyList.peek() instanceof SlideSequencesCommand)
1900 appendHistoryItem = ssc.appendSlideCommand(
1901 (SlideSequencesCommand) historyList.peek());
1904 if (!appendHistoryItem)
1906 addHistoryItem(ssc);
1919 protected void copy_actionPerformed()
1921 if (viewport.getSelectionGroup() == null)
1925 // TODO: preserve the ordering of displayed alignment annotation in any
1926 // internal paste (particularly sequence associated annotation)
1927 SequenceI[] seqs = viewport.getSelectionAsNewSequence();
1928 String[] omitHidden = null;
1930 if (viewport.hasHiddenColumns())
1932 omitHidden = viewport.getViewAsString(true);
1935 String output = new FormatAdapter().formatSequences(FileFormat.Fasta,
1936 seqs, omitHidden, null);
1938 StringSelection ss = new StringSelection(output);
1942 Desktop.getInstance().internalCopy = true;
1943 // Its really worth setting the clipboard contents
1944 // to empty before setting the large StringSelection!!
1945 Toolkit.getDefaultToolkit().getSystemClipboard()
1946 .setContents(new StringSelection(""), null);
1948 Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss,
1949 Desktop.getInstance());
1950 } catch (OutOfMemoryError er)
1952 new OOMWarning("copying region", er);
1956 HiddenColumns hiddenColumns = null;
1957 if (viewport.hasHiddenColumns())
1959 int hiddenOffset = viewport.getSelectionGroup().getStartRes();
1960 int hiddenCutoff = viewport.getSelectionGroup().getEndRes();
1962 // create new HiddenColumns object with copy of hidden regions
1963 // between startRes and endRes, offset by startRes
1964 hiddenColumns = new HiddenColumns(
1965 viewport.getAlignment().getHiddenColumns(), hiddenOffset,
1966 hiddenCutoff, hiddenOffset);
1969 Desktop.getInstance().jalviewClipboard = new Object[] { seqs,
1970 viewport.getAlignment().getDataset(), hiddenColumns };
1971 setStatus(MessageManager.formatMessage(
1972 "label.copied_sequences_to_clipboard", new Object[]
1973 { Integer.valueOf(seqs.length).toString() }));
1983 protected void pasteNew_actionPerformed(ActionEvent e)
1995 protected void pasteThis_actionPerformed(ActionEvent e)
2001 * Paste contents of Jalview clipboard
2003 * @param newAlignment
2004 * true to paste to a new alignment, otherwise add to this.
2006 void paste(boolean newAlignment)
2008 boolean externalPaste = true;
2009 Desktop d = Desktop.getInstance();
2012 Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
2013 Transferable contents = c.getContents(this);
2015 if (contents == null)
2024 str = (String) contents.getTransferData(DataFlavor.stringFlavor);
2025 if (str.length() < 1)
2030 format = new IdentifyFile().identify(str, DataSourceType.PASTE);
2032 } catch (OutOfMemoryError er)
2034 new OOMWarning("Out of memory pasting sequences!!", er);
2038 SequenceI[] sequences;
2039 boolean annotationAdded = false;
2040 AlignmentI alignment = null;
2042 if (d.jalviewClipboard != null)
2044 // The clipboard was filled from within Jalview, we must use the
2046 // And dataset from the copied alignment
2047 SequenceI[] newseq = (SequenceI[]) d.jalviewClipboard[0];
2048 // be doubly sure that we create *new* sequence objects.
2049 sequences = new SequenceI[newseq.length];
2050 for (int i = 0; i < newseq.length; i++)
2052 sequences[i] = new Sequence(newseq[i]);
2054 alignment = new Alignment(sequences);
2055 externalPaste = false;
2059 // parse the clipboard as an alignment.
2060 alignment = new FormatAdapter().readFile(str, DataSourceType.PASTE,
2062 sequences = alignment.getSequencesArray();
2066 ArrayList<Integer> newGraphGroups = new ArrayList<>();
2072 if (d.jalviewClipboard != null)
2074 // dataset is inherited
2075 alignment.setDataset((Alignment) d.jalviewClipboard[1]);
2079 // new dataset is constructed
2080 alignment.setDataset(null);
2082 alwidth = alignment.getWidth() + 1;
2086 AlignmentI pastedal = alignment; // preserve pasted alignment object
2087 // Add pasted sequences and dataset into existing alignment.
2088 alignment = viewport.getAlignment();
2089 alwidth = alignment.getWidth() + 1;
2090 // decide if we need to import sequences from an existing dataset
2091 boolean importDs = d.jalviewClipboard != null
2092 && d.jalviewClipboard[1] != alignment.getDataset();
2093 // importDs==true instructs us to copy over new dataset sequences from
2094 // an existing alignment
2095 Vector<SequenceI> newDs = (importDs) ? new Vector<>() : null; // used to
2097 // minimum dataset set
2099 for (int i = 0; i < sequences.length; i++)
2103 newDs.addElement(null);
2105 SequenceI ds = sequences[i].getDatasetSequence(); // null for a simple
2107 if (importDs && ds != null)
2109 if (!newDs.contains(ds))
2111 newDs.setElementAt(ds, i);
2112 ds = new Sequence(ds);
2113 // update with new dataset sequence
2114 sequences[i].setDatasetSequence(ds);
2118 ds = sequences[newDs.indexOf(ds)].getDatasetSequence();
2123 // copy and derive new dataset sequence
2124 sequences[i] = sequences[i].deriveSequence();
2125 alignment.getDataset()
2126 .addSequence(sequences[i].getDatasetSequence());
2127 // TODO: avoid creation of duplicate dataset sequences with a
2128 // 'contains' method using SequenceI.equals()/SequenceI.contains()
2130 alignment.addSequence(sequences[i]); // merges dataset
2134 newDs.clear(); // tidy up
2136 if (alignment.getAlignmentAnnotation() != null)
2138 for (AlignmentAnnotation alan : alignment
2139 .getAlignmentAnnotation())
2141 if (alan.graphGroup > fgroup)
2143 fgroup = alan.graphGroup;
2147 if (pastedal.getAlignmentAnnotation() != null)
2149 // Add any annotation attached to alignment.
2150 AlignmentAnnotation[] alann = pastedal.getAlignmentAnnotation();
2151 for (int i = 0; i < alann.length; i++)
2153 annotationAdded = true;
2154 if (alann[i].sequenceRef == null && !alann[i].autoCalculated)
2156 AlignmentAnnotation newann = new AlignmentAnnotation(
2158 if (newann.graphGroup > -1)
2160 if (newGraphGroups.size() <= newann.graphGroup
2161 || newGraphGroups.get(newann.graphGroup) == null)
2163 for (int q = newGraphGroups
2164 .size(); q <= newann.graphGroup; q++)
2166 newGraphGroups.add(q, null);
2168 newGraphGroups.set(newann.graphGroup,
2169 Integer.valueOf(++fgroup));
2171 newann.graphGroup = newGraphGroups.get(newann.graphGroup)
2175 newann.padAnnotation(alwidth);
2176 alignment.addAnnotation(newann);
2186 addHistoryItem(new EditCommand(
2187 MessageManager.getString("label.add_sequences"),
2188 Action.PASTE, sequences, 0, alignment.getWidth(),
2191 // Add any annotations attached to sequences
2192 for (int i = 0; i < sequences.length; i++)
2194 if (sequences[i].getAnnotation() != null)
2196 AlignmentAnnotation newann;
2197 for (int a = 0; a < sequences[i].getAnnotation().length; a++)
2199 annotationAdded = true;
2200 newann = sequences[i].getAnnotation()[a];
2201 newann.adjustForAlignment();
2202 newann.padAnnotation(alwidth);
2203 if (newann.graphGroup > -1)
2205 if (newann.graphGroup > -1)
2207 if (newGraphGroups.size() <= newann.graphGroup
2208 || newGraphGroups.get(newann.graphGroup) == null)
2210 for (int q = newGraphGroups
2211 .size(); q <= newann.graphGroup; q++)
2213 newGraphGroups.add(q, null);
2215 newGraphGroups.set(newann.graphGroup,
2216 Integer.valueOf(++fgroup));
2218 newann.graphGroup = newGraphGroups.get(newann.graphGroup)
2222 alignment.addAnnotation(sequences[i].getAnnotation()[a]); // annotation
2226 alignment.setAnnotationIndex(sequences[i].getAnnotation()[a],
2234 // propagate alignment changed.
2235 viewport.getRanges().setEndSeq(alignment.getHeight() - 1);
2236 if (annotationAdded)
2238 // Duplicate sequence annotation in all views.
2239 AlignmentI[] alview = this.getViewAlignments();
2240 for (int i = 0; i < sequences.length; i++)
2242 AlignmentAnnotation sann[] = sequences[i].getAnnotation();
2247 for (int avnum = 0; avnum < alview.length; avnum++)
2249 if (alview[avnum] != alignment)
2251 // duplicate in a view other than the one with input focus
2252 int avwidth = alview[avnum].getWidth() + 1;
2253 // this relies on sann being preserved after we
2254 // modify the sequence's annotation array for each duplication
2255 for (int a = 0; a < sann.length; a++)
2257 AlignmentAnnotation newann = new AlignmentAnnotation(
2259 sequences[i].addAlignmentAnnotation(newann);
2260 newann.padAnnotation(avwidth);
2261 alview[avnum].addAnnotation(newann); // annotation was
2262 // duplicated earlier
2263 // TODO JAL-1145 graphGroups are not updated for sequence
2264 // annotation added to several views. This may cause
2266 alview[avnum].setAnnotationIndex(newann, a);
2271 buildSortByAnnotationScoresMenu();
2273 viewport.firePropertyChange("alignment", null,
2274 alignment.getSequences());
2275 if (alignPanels != null)
2277 for (AlignmentPanel ap : alignPanels)
2279 ap.validateAnnotationDimensions(false);
2284 alignPanel.validateAnnotationDimensions(false);
2290 AlignFrame af = new AlignFrame(alignment, DEFAULT_WIDTH,
2292 String newtitle = new String("Copied sequences");
2294 if (d.jalviewClipboard != null && d.jalviewClipboard[2] != null)
2296 HiddenColumns hc = (HiddenColumns) d.jalviewClipboard[2];
2297 af.viewport.setHiddenColumns(hc);
2300 // >>>This is a fix for the moment, until a better solution is
2302 af.alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer()
2303 .transferSettings(alignPanel.getSeqPanel().seqCanvas
2304 .getFeatureRenderer());
2306 // TODO: maintain provenance of an alignment, rather than just make the
2307 // title a concatenation of operations.
2310 if (title.startsWith("Copied sequences"))
2316 newtitle = newtitle.concat("- from " + title);
2321 newtitle = new String("Pasted sequences");
2324 Desktop.addInternalFrame(af, newtitle, DEFAULT_WIDTH,
2329 } catch (Exception ex)
2331 ex.printStackTrace();
2332 System.out.println("Exception whilst pasting: " + ex);
2333 // could be anything being pasted in here
2339 protected void expand_newalign(ActionEvent e)
2343 AlignmentI alignment = AlignmentUtils
2344 .expandContext(getViewport().getAlignment(), -1);
2345 AlignFrame af = new AlignFrame(alignment, DEFAULT_WIDTH,
2347 String newtitle = new String("Flanking alignment");
2348 Desktop d = Desktop.getInstance();
2349 if (d.jalviewClipboard != null && d.jalviewClipboard[2] != null)
2351 HiddenColumns hc = (HiddenColumns) d.jalviewClipboard[2];
2352 af.viewport.setHiddenColumns(hc);
2355 // >>>This is a fix for the moment, until a better solution is
2357 af.alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer()
2358 .transferSettings(alignPanel.getSeqPanel().seqCanvas
2359 .getFeatureRenderer());
2361 // TODO: maintain provenance of an alignment, rather than just make the
2362 // title a concatenation of operations.
2364 if (title.startsWith("Copied sequences"))
2370 newtitle = newtitle.concat("- from " + title);
2374 Desktop.addInternalFrame(af, newtitle, DEFAULT_WIDTH, DEFAULT_HEIGHT);
2376 } catch (Exception ex)
2378 ex.printStackTrace();
2379 System.out.println("Exception whilst pasting: " + ex);
2380 // could be anything being pasted in here
2381 } catch (OutOfMemoryError oom)
2383 new OOMWarning("Viewing flanking region of alignment", oom);
2388 * Action Cut (delete and copy) the selected region
2391 protected void cut_actionPerformed()
2393 copy_actionPerformed();
2394 delete_actionPerformed();
2398 * Performs menu option to Delete the currently selected region
2401 protected void delete_actionPerformed()
2404 SequenceGroup sg = viewport.getSelectionGroup();
2410 Runnable okAction = new Runnable()
2415 SequenceI[] cut = sg.getSequences()
2416 .toArray(new SequenceI[sg.getSize()]);
2418 addHistoryItem(new EditCommand(
2419 MessageManager.getString("label.cut_sequences"), Action.CUT,
2420 cut, sg.getStartRes(),
2421 sg.getEndRes() - sg.getStartRes() + 1,
2422 viewport.getAlignment()));
2424 viewport.setSelectionGroup(null);
2425 viewport.sendSelection();
2426 viewport.getAlignment().deleteGroup(sg);
2428 viewport.firePropertyChange("alignment", null,
2429 viewport.getAlignment().getSequences());
2430 if (viewport.getAlignment().getHeight() < 1)
2434 AlignFrame.this.setClosed(true);
2435 } catch (Exception ex)
2443 * If the cut affects all sequences, prompt for confirmation
2445 boolean wholeHeight = sg.getSize() == viewport.getAlignment()
2447 boolean wholeWidth = (((sg.getEndRes() - sg.getStartRes())
2448 + 1) == viewport.getAlignment().getWidth()) ? true : false;
2449 if (wholeHeight && wholeWidth)
2451 JvOptionPane dialog = JvOptionPane
2452 .newOptionDialog(Desktop.getDesktopPane());
2453 dialog.setResponseHandler(0, okAction); // 0 = OK_OPTION
2454 Object[] options = new Object[] {
2455 MessageManager.getString("action.ok"),
2456 MessageManager.getString("action.cancel") };
2457 dialog.showDialog(MessageManager.getString("warn.delete_all"),
2458 MessageManager.getString("label.delete_all"),
2459 JvOptionPane.DEFAULT_OPTION, JvOptionPane.PLAIN_MESSAGE, null,
2460 options, options[0]);
2475 protected void deleteGroups_actionPerformed(ActionEvent e)
2477 if (avc.deleteGroups())
2479 PaintRefresher.Refresh(this, viewport.getSequenceSetId());
2480 alignPanel.updateAnnotation();
2481 alignPanel.paintAlignment(true, true);
2492 public void selectAllSequenceMenuItem_actionPerformed(ActionEvent e)
2494 SequenceGroup sg = new SequenceGroup(
2495 viewport.getAlignment().getSequences());
2497 sg.setEndRes(viewport.getAlignment().getWidth() - 1);
2498 viewport.setSelectionGroup(sg);
2499 viewport.isSelectionGroupChanged(true);
2500 viewport.sendSelection();
2501 // JAL-2034 - should delegate to
2502 // alignPanel to decide if overview needs
2504 alignPanel.paintAlignment(false, false);
2505 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
2515 public void deselectAllSequenceMenuItem_actionPerformed(ActionEvent e)
2517 if (viewport.cursorMode)
2519 alignPanel.getSeqPanel().keyboardNo1 = null;
2520 alignPanel.getSeqPanel().keyboardNo2 = null;
2522 viewport.setSelectionGroup(null);
2523 viewport.getColumnSelection().clear();
2524 viewport.setSelectionGroup(null);
2525 alignPanel.getIdPanel().getIdCanvas().searchResults = null;
2526 // JAL-2034 - should delegate to
2527 // alignPanel to decide if overview needs
2529 alignPanel.paintAlignment(false, false);
2530 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
2531 viewport.sendSelection();
2541 public void invertSequenceMenuItem_actionPerformed(ActionEvent e)
2543 SequenceGroup sg = viewport.getSelectionGroup();
2547 selectAllSequenceMenuItem_actionPerformed(null);
2552 for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++)
2554 sg.addOrRemove(viewport.getAlignment().getSequenceAt(i), false);
2556 // JAL-2034 - should delegate to
2557 // alignPanel to decide if overview needs
2560 alignPanel.paintAlignment(true, false);
2561 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
2562 viewport.sendSelection();
2566 public void invertColSel_actionPerformed(ActionEvent e)
2568 viewport.invertColumnSelection();
2569 alignPanel.paintAlignment(true, false);
2570 viewport.sendSelection();
2580 public void remove2LeftMenuItem_actionPerformed(ActionEvent e)
2582 trimAlignment(true);
2592 public void remove2RightMenuItem_actionPerformed(ActionEvent e)
2594 trimAlignment(false);
2597 void trimAlignment(boolean trimLeft)
2599 ColumnSelection colSel = viewport.getColumnSelection();
2602 if (!colSel.isEmpty())
2606 column = colSel.getMin();
2610 column = colSel.getMax();
2614 if (viewport.getSelectionGroup() != null)
2616 seqs = viewport.getSelectionGroup()
2617 .getSequencesAsArray(viewport.getHiddenRepSequences());
2621 seqs = viewport.getAlignment().getSequencesArray();
2624 TrimRegionCommand trimRegion;
2627 trimRegion = new TrimRegionCommand("Remove Left", true, seqs,
2628 column, viewport.getAlignment());
2629 viewport.getRanges().setStartRes(0);
2633 trimRegion = new TrimRegionCommand("Remove Right", false, seqs,
2634 column, viewport.getAlignment());
2637 setStatus(MessageManager.formatMessage("label.removed_columns",
2639 { Integer.valueOf(trimRegion.getSize()).toString() }));
2641 addHistoryItem(trimRegion);
2643 for (SequenceGroup sg : viewport.getAlignment().getGroups())
2645 if ((trimLeft && !sg.adjustForRemoveLeft(column))
2646 || (!trimLeft && !sg.adjustForRemoveRight(column)))
2648 viewport.getAlignment().deleteGroup(sg);
2652 viewport.firePropertyChange("alignment", null,
2653 viewport.getAlignment().getSequences());
2664 public void removeGappedColumnMenuItem_actionPerformed(ActionEvent e)
2666 int start = 0, end = viewport.getAlignment().getWidth() - 1;
2669 if (viewport.getSelectionGroup() != null)
2671 seqs = viewport.getSelectionGroup()
2672 .getSequencesAsArray(viewport.getHiddenRepSequences());
2673 start = viewport.getSelectionGroup().getStartRes();
2674 end = viewport.getSelectionGroup().getEndRes();
2678 seqs = viewport.getAlignment().getSequencesArray();
2681 RemoveGapColCommand removeGapCols = new RemoveGapColCommand(
2682 "Remove Gapped Columns", seqs, start, end,
2683 viewport.getAlignment());
2685 addHistoryItem(removeGapCols);
2687 setStatus(MessageManager.formatMessage("label.removed_empty_columns",
2689 { Integer.valueOf(removeGapCols.getSize()).toString() }));
2691 // This is to maintain viewport position on first residue
2692 // of first sequence
2693 SequenceI seq = viewport.getAlignment().getSequenceAt(0);
2694 ViewportRanges ranges = viewport.getRanges();
2695 int startRes = seq.findPosition(ranges.getStartRes());
2696 // ShiftList shifts;
2697 // viewport.getAlignment().removeGaps(shifts=new ShiftList());
2698 // edit.alColumnChanges=shifts.getInverse();
2699 // if (viewport.hasHiddenColumns)
2700 // viewport.getColumnSelection().compensateForEdits(shifts);
2701 ranges.setStartRes(seq.findIndex(startRes) - 1);
2702 viewport.firePropertyChange("alignment", null,
2703 viewport.getAlignment().getSequences());
2714 public void removeAllGapsMenuItem_actionPerformed(ActionEvent e)
2716 int start = 0, end = viewport.getAlignment().getWidth() - 1;
2719 if (viewport.getSelectionGroup() != null)
2721 seqs = viewport.getSelectionGroup()
2722 .getSequencesAsArray(viewport.getHiddenRepSequences());
2723 start = viewport.getSelectionGroup().getStartRes();
2724 end = viewport.getSelectionGroup().getEndRes();
2728 seqs = viewport.getAlignment().getSequencesArray();
2731 // This is to maintain viewport position on first residue
2732 // of first sequence
2733 SequenceI seq = viewport.getAlignment().getSequenceAt(0);
2734 int startRes = seq.findPosition(viewport.getRanges().getStartRes());
2736 addHistoryItem(new RemoveGapsCommand("Remove Gaps", seqs, start, end,
2737 viewport.getAlignment()));
2739 viewport.getRanges().setStartRes(seq.findIndex(startRes) - 1);
2741 viewport.firePropertyChange("alignment", null,
2742 viewport.getAlignment().getSequences());
2753 public void padGapsMenuitem_actionPerformed(ActionEvent e)
2755 viewport.setPadGaps(padGapsMenuitem.isSelected());
2756 viewport.firePropertyChange("alignment", null,
2757 viewport.getAlignment().getSequences());
2767 public void findMenuItem_actionPerformed(ActionEvent e)
2773 * Create a new view of the current alignment.
2776 public void newView_actionPerformed(ActionEvent e)
2778 newView(null, true);
2782 * Creates and shows a new view of the current alignment.
2785 * title of newly created view; if null, one will be generated
2786 * @param copyAnnotation
2787 * if true then duplicate all annnotation, groups and settings
2788 * @return new alignment panel, already displayed.
2790 public AlignmentPanel newView(String viewTitle, boolean copyAnnotation)
2793 * Create a new AlignmentPanel (with its own, new Viewport)
2795 AlignmentPanel newap = new jalview.project.Jalview2XML()
2796 .copyAlignPanel(alignPanel);
2797 if (!copyAnnotation)
2800 * remove all groups and annotation except for the automatic stuff
2802 newap.av.getAlignment().deleteAllGroups();
2803 newap.av.getAlignment().deleteAllAnnotations(false);
2806 newap.av.setGatherViewsHere(false);
2808 if (viewport.getViewName() == null)
2810 viewport.setViewName(
2811 MessageManager.getString("label.view_name_original"));
2815 * Views share the same edits undo and redo stacks
2817 newap.av.setHistoryList(viewport.getHistoryList());
2818 newap.av.setRedoList(viewport.getRedoList());
2821 * copy any visualisation settings that are not saved in the project
2823 newap.av.setColourAppliesToAllGroups(
2824 viewport.getColourAppliesToAllGroups());
2827 * Views share the same mappings; need to deregister any new mappings
2828 * created by copyAlignPanel, and register the new reference to the shared
2831 newap.av.replaceMappings(viewport.getAlignment());
2834 * start up cDNA consensus (if applicable) now mappings are in place
2836 if (newap.av.initComplementConsensus())
2838 newap.refresh(true); // adjust layout of annotations
2841 newap.av.setViewName(getNewViewName(viewTitle));
2843 addAlignmentPanel(newap, true);
2844 newap.alignmentChanged();
2846 if (alignPanels.size() == 2)
2848 viewport.setGatherViewsHere(true);
2850 tabbedPane.setSelectedIndex(tabbedPane.getTabCount() - 1);
2855 * Make a new name for the view, ensuring it is unique within the current
2856 * sequenceSetId. (This used to be essential for Jalview Project archives, but
2857 * these now use viewId. Unique view names are still desirable for usability.)
2862 protected String getNewViewName(String viewTitle)
2864 int index = Desktop.getViewCount(viewport.getSequenceSetId());
2865 boolean addFirstIndex = false;
2866 if (viewTitle == null || viewTitle.trim().length() == 0)
2868 viewTitle = MessageManager.getString("action.view");
2869 addFirstIndex = true;
2873 index = 1;// we count from 1 if given a specific name
2875 String newViewName = viewTitle + ((addFirstIndex) ? " " + index : "");
2877 List<Component> comps = PaintRefresher.components
2878 .get(viewport.getSequenceSetId());
2880 List<String> existingNames = getExistingViewNames(comps);
2882 while (existingNames.contains(newViewName))
2884 newViewName = viewTitle + " " + (++index);
2890 * Returns a list of distinct view names found in the given list of
2891 * components. View names are held on the viewport of an AlignmentPanel.
2896 protected List<String> getExistingViewNames(List<Component> comps)
2898 List<String> existingNames = new ArrayList<>();
2899 for (Component comp : comps)
2901 if (comp instanceof AlignmentPanel)
2903 AlignmentPanel ap = (AlignmentPanel) comp;
2904 if (!existingNames.contains(ap.av.getViewName()))
2906 existingNames.add(ap.av.getViewName());
2910 return existingNames;
2914 * Explode tabbed views into separate windows.
2917 public void expandViews_actionPerformed(ActionEvent e)
2919 Desktop.explodeViews(this);
2923 * Gather views in separate windows back into a tabbed presentation.
2926 public void gatherViews_actionPerformed(ActionEvent e)
2928 Desktop.getInstance().gatherViews(this);
2938 public void font_actionPerformed(ActionEvent e)
2940 new FontChooser(alignPanel);
2950 protected void seqLimit_actionPerformed(ActionEvent e)
2952 viewport.setShowJVSuffix(seqLimits.isSelected());
2954 alignPanel.getIdPanel().getIdCanvas()
2955 .setPreferredSize(alignPanel.calculateIdWidth());
2956 alignPanel.paintAlignment(true, false);
2960 public void idRightAlign_actionPerformed(ActionEvent e)
2962 viewport.setRightAlignIds(idRightAlign.isSelected());
2963 alignPanel.paintAlignment(false, false);
2967 public void centreColumnLabels_actionPerformed(ActionEvent e)
2969 viewport.setCentreColumnLabels(centreColumnLabelsMenuItem.getState());
2970 alignPanel.paintAlignment(false, false);
2976 * @see jalview.jbgui.GAlignFrame#followHighlight_actionPerformed()
2979 protected void followHighlight_actionPerformed()
2982 * Set the 'follow' flag on the Viewport (and scroll to position if now
2985 final boolean state = this.followHighlightMenuItem.getState();
2986 viewport.setFollowHighlight(state);
2989 alignPanel.scrollToPosition(viewport.getSearchResults());
3000 protected void colourTextMenuItem_actionPerformed(ActionEvent e)
3002 viewport.setColourText(colourTextMenuItem.isSelected());
3003 alignPanel.paintAlignment(false, false);
3013 public void wrapMenuItem_actionPerformed(ActionEvent e)
3015 scaleAbove.setVisible(wrapMenuItem.isSelected());
3016 scaleLeft.setVisible(wrapMenuItem.isSelected());
3017 scaleRight.setVisible(wrapMenuItem.isSelected());
3018 viewport.setWrapAlignment(wrapMenuItem.isSelected());
3019 alignPanel.updateLayout();
3023 public void showAllSeqs_actionPerformed(ActionEvent e)
3025 viewport.showAllHiddenSeqs();
3029 public void showAllColumns_actionPerformed(ActionEvent e)
3031 viewport.showAllHiddenColumns();
3032 alignPanel.paintAlignment(true, true);
3033 viewport.sendSelection();
3037 public void hideSelSequences_actionPerformed(ActionEvent e)
3039 viewport.hideAllSelectedSeqs();
3043 * called by key handler and the hide all/show all menu items
3048 protected void toggleHiddenRegions(boolean toggleSeqs, boolean toggleCols)
3051 boolean hide = false;
3052 SequenceGroup sg = viewport.getSelectionGroup();
3053 if (!toggleSeqs && !toggleCols)
3055 // Hide everything by the current selection - this is a hack - we do the
3056 // invert and then hide
3057 // first check that there will be visible columns after the invert.
3058 if (viewport.hasSelectedColumns() || (sg != null && sg.getSize() > 0
3059 && sg.getStartRes() <= sg.getEndRes()))
3061 // now invert the sequence set, if required - empty selection implies
3062 // that no hiding is required.
3065 invertSequenceMenuItem_actionPerformed(null);
3066 sg = viewport.getSelectionGroup();
3070 viewport.expandColSelection(sg, true);
3071 // finally invert the column selection and get the new sequence
3073 invertColSel_actionPerformed(null);
3080 if (sg != null && sg.getSize() != viewport.getAlignment().getHeight())
3082 hideSelSequences_actionPerformed(null);
3085 else if (!(toggleCols && viewport.hasSelectedColumns()))
3087 showAllSeqs_actionPerformed(null);
3093 if (viewport.hasSelectedColumns())
3095 hideSelColumns_actionPerformed(null);
3098 viewport.setSelectionGroup(sg);
3103 showAllColumns_actionPerformed(null);
3112 * jalview.jbgui.GAlignFrame#hideAllButSelection_actionPerformed(java.awt.
3113 * event.ActionEvent)
3116 public void hideAllButSelection_actionPerformed(ActionEvent e)
3118 toggleHiddenRegions(false, false);
3119 viewport.sendSelection();
3126 * jalview.jbgui.GAlignFrame#hideAllSelection_actionPerformed(java.awt.event
3130 public void hideAllSelection_actionPerformed(ActionEvent e)
3132 SequenceGroup sg = viewport.getSelectionGroup();
3133 viewport.expandColSelection(sg, false);
3134 viewport.hideAllSelectedSeqs();
3135 viewport.hideSelectedColumns();
3136 alignPanel.updateLayout();
3137 alignPanel.paintAlignment(true, true);
3138 viewport.sendSelection();
3145 * jalview.jbgui.GAlignFrame#showAllhidden_actionPerformed(java.awt.event.
3149 public void showAllhidden_actionPerformed(ActionEvent e)
3151 viewport.showAllHiddenColumns();
3152 viewport.showAllHiddenSeqs();
3153 alignPanel.paintAlignment(true, true);
3154 viewport.sendSelection();
3158 public void hideSelColumns_actionPerformed(ActionEvent e)
3160 viewport.hideSelectedColumns();
3161 alignPanel.updateLayout();
3162 alignPanel.paintAlignment(true, true);
3163 viewport.sendSelection();
3167 public void hiddenMarkers_actionPerformed(ActionEvent e)
3169 viewport.setShowHiddenMarkers(hiddenMarkers.isSelected());
3180 protected void scaleAbove_actionPerformed(ActionEvent e)
3182 viewport.setScaleAboveWrapped(scaleAbove.isSelected());
3183 alignPanel.updateLayout();
3184 alignPanel.paintAlignment(true, false);
3194 protected void scaleLeft_actionPerformed(ActionEvent e)
3196 viewport.setScaleLeftWrapped(scaleLeft.isSelected());
3197 alignPanel.updateLayout();
3198 alignPanel.paintAlignment(true, false);
3208 protected void scaleRight_actionPerformed(ActionEvent e)
3210 viewport.setScaleRightWrapped(scaleRight.isSelected());
3211 alignPanel.updateLayout();
3212 alignPanel.paintAlignment(true, false);
3222 public void viewBoxesMenuItem_actionPerformed(ActionEvent e)
3224 viewport.setShowBoxes(viewBoxesMenuItem.isSelected());
3225 alignPanel.paintAlignment(false, false);
3235 public void viewTextMenuItem_actionPerformed(ActionEvent e)
3237 viewport.setShowText(viewTextMenuItem.isSelected());
3238 alignPanel.paintAlignment(false, false);
3248 protected void renderGapsMenuItem_actionPerformed(ActionEvent e)
3250 viewport.setRenderGaps(renderGapsMenuItem.isSelected());
3251 alignPanel.paintAlignment(false, false);
3254 public FeatureSettings featureSettings;
3257 public FeatureSettingsControllerI getFeatureSettingsUI()
3259 return featureSettings;
3263 public void featureSettings_actionPerformed(ActionEvent e)
3265 showFeatureSettingsUI();
3269 public FeatureSettingsControllerI showFeatureSettingsUI()
3271 if (featureSettings != null)
3273 featureSettings.closeOldSettings();
3274 featureSettings = null;
3276 if (!showSeqFeatures.isSelected())
3278 // make sure features are actually displayed
3279 showSeqFeatures.setSelected(true);
3280 showSeqFeatures_actionPerformed(null);
3282 featureSettings = new FeatureSettings(this);
3283 return featureSettings;
3287 * Set or clear 'Show Sequence Features'
3293 public void showSeqFeatures_actionPerformed(ActionEvent evt)
3295 viewport.setShowSequenceFeatures(showSeqFeatures.isSelected());
3296 alignPanel.paintAlignment(true, true);
3300 * Action on toggle of the 'Show annotations' menu item. This shows or hides
3301 * the annotations panel as a whole.
3303 * The options to show/hide all annotations should be enabled when the panel
3304 * is shown, and disabled when the panel is hidden.
3309 public void annotationPanelMenuItem_actionPerformed(ActionEvent e)
3311 final boolean setVisible = annotationPanelMenuItem.isSelected();
3312 viewport.setShowAnnotation(setVisible);
3313 this.showAllSeqAnnotations.setEnabled(setVisible);
3314 this.hideAllSeqAnnotations.setEnabled(setVisible);
3315 this.showAllAlAnnotations.setEnabled(setVisible);
3316 this.hideAllAlAnnotations.setEnabled(setVisible);
3317 alignPanel.updateLayout();
3321 public void alignmentProperties()
3324 StringBuffer contents = new AlignmentProperties(viewport.getAlignment())
3327 String content = MessageManager.formatMessage("label.html_content",
3329 { contents.toString() });
3332 if (Platform.isJS())
3334 JLabel textLabel = new JLabel();
3335 textLabel.setText(content);
3336 textLabel.setBackground(Color.WHITE);
3338 pane = new JPanel(new BorderLayout());
3339 ((JPanel) pane).setOpaque(true);
3340 pane.setBackground(Color.WHITE);
3341 ((JPanel) pane).add(textLabel, BorderLayout.NORTH);
3350 JEditorPane editPane = new JEditorPane("text/html", "");
3351 editPane.setEditable(false);
3352 editPane.setText(content);
3356 JInternalFrame frame = new JInternalFrame();
3358 frame.getContentPane().add(new JScrollPane(pane));
3360 Desktop.addInternalFrame(frame, MessageManager
3361 .formatMessage("label.alignment_properties", new Object[]
3362 { getTitle() }), 500, 400);
3372 public void overviewMenuItem_actionPerformed(ActionEvent e)
3374 if (alignPanel.overviewPanel != null)
3379 JInternalFrame frame = new JInternalFrame();
3381 // BH 2019.07.26 we allow for an embedded
3382 // undecorated overview with defined size
3383 frame.setName(Jalview.getAppID("overview"));
3385 Dimension dim = Platform.getDimIfEmbedded(frame, -1, -1);
3386 if (dim != null && dim.width == 0)
3388 dim = null; // hidden, not embedded
3390 OverviewPanel overview = new OverviewPanel(alignPanel, dim);
3392 frame.setContentPane(overview);
3395 dim = new Dimension();
3396 // was frame.getSize(), but that is 0,0 at this point;
3400 // we are imbedding, and so we have an undecorated frame
3401 // and we can set the the frame dimensions accordingly.
3403 // allowing for unresizable option using, style="resize:none"
3404 boolean resizable = (Platform.getEmbeddedAttribute(frame,
3405 "resize") != "none");
3406 Desktop.addInternalFrame(frame, MessageManager
3407 .formatMessage("label.overview_params", new Object[]
3408 { this.getTitle() }), true, dim.width, dim.height, resizable,
3411 frame.setLayer(JLayeredPane.PALETTE_LAYER);
3412 frame.addInternalFrameListener(
3413 new javax.swing.event.InternalFrameAdapter()
3416 public void internalFrameClosed(
3417 javax.swing.event.InternalFrameEvent evt)
3420 alignPanel.setOverviewPanel(null);
3423 if (getKeyListeners().length > 0)
3425 frame.addKeyListener(getKeyListeners()[0]);
3428 alignPanel.setOverviewPanel(overview);
3432 public void textColour_actionPerformed()
3434 new TextColourChooser().chooseColour(alignPanel, null);
3438 * public void covariationColour_actionPerformed() {
3440 * CovariationColourScheme(viewport.getAlignment().getAlignmentAnnotation
3444 public void annotationColour_actionPerformed()
3446 new AnnotationColourChooser(viewport, alignPanel);
3450 public void annotationColumn_actionPerformed(ActionEvent e)
3452 new AnnotationColumnChooser(viewport, alignPanel);
3456 * Action on the user checking or unchecking the option to apply the selected
3457 * colour scheme to all groups. If unchecked, groups may have their own
3458 * independent colour schemes.
3463 public void applyToAllGroups_actionPerformed(boolean selected)
3465 viewport.setColourAppliesToAllGroups(selected);
3469 * Action on user selecting a colour from the colour menu
3472 * the name (not the menu item label!) of the colour scheme
3475 public void changeColour_actionPerformed(String name)
3478 * 'User Defined' opens a panel to configure or load a
3479 * user-defined colour scheme
3481 if (ResidueColourScheme.USER_DEFINED_MENU.equals(name))
3483 new UserDefinedColours(alignPanel);
3488 * otherwise set the chosen colour scheme (or null for 'None')
3490 ColourSchemeI cs = ColourSchemes.getInstance().getColourScheme(name,
3491 viewport, viewport.getAlignment(),
3492 viewport.getHiddenRepSequences());
3497 * Actions on setting or changing the alignment colour scheme
3502 public void changeColour(ColourSchemeI cs)
3504 // TODO: pull up to controller method
3505 ColourMenuHelper.setColourSelected(colourMenu, cs);
3507 viewport.setGlobalColourScheme(cs);
3509 alignPanel.paintAlignment(true, true);
3513 * Show the PID threshold slider panel
3516 protected void modifyPID_actionPerformed()
3518 SliderPanel.setPIDSliderSource(alignPanel, viewport.getResidueShading(),
3519 alignPanel.getViewName());
3520 SliderPanel.showPIDSlider();
3524 * Show the Conservation slider panel
3527 protected void modifyConservation_actionPerformed()
3529 SliderPanel.setConservationSlider(alignPanel,
3530 viewport.getResidueShading(), alignPanel.getViewName());
3531 SliderPanel.showConservationSlider();
3535 * Action on selecting or deselecting (Colour) By Conservation
3538 public void conservationMenuItem_actionPerformed(boolean selected)
3540 modifyConservation.setEnabled(selected);
3541 viewport.setConservationSelected(selected);
3542 viewport.getResidueShading().setConservationApplied(selected);
3544 changeColour(viewport.getGlobalColourScheme());
3547 modifyConservation_actionPerformed();
3551 SliderPanel.hideConservationSlider();
3556 * Action on selecting or deselecting (Colour) Above PID Threshold
3559 public void abovePIDThreshold_actionPerformed(boolean selected)
3561 modifyPID.setEnabled(selected);
3562 viewport.setAbovePIDThreshold(selected);
3565 viewport.getResidueShading().setThreshold(0,
3566 viewport.isIgnoreGapsConsensus());
3569 changeColour(viewport.getGlobalColourScheme());
3572 modifyPID_actionPerformed();
3576 SliderPanel.hidePIDSlider();
3587 public void sortPairwiseMenuItem_actionPerformed(ActionEvent e)
3589 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
3590 AlignmentSorter.sortByPID(viewport.getAlignment(),
3591 viewport.getAlignment().getSequenceAt(0));
3592 addHistoryItem(new OrderCommand("Pairwise Sort", oldOrder,
3593 viewport.getAlignment()));
3594 alignPanel.paintAlignment(true, false);
3604 public void sortIDMenuItem_actionPerformed(ActionEvent e)
3606 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
3607 AlignmentSorter.sortByID(viewport.getAlignment());
3609 new OrderCommand("ID Sort", oldOrder, viewport.getAlignment()));
3610 alignPanel.paintAlignment(true, false);
3620 public void sortLengthMenuItem_actionPerformed(ActionEvent e)
3622 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
3623 AlignmentSorter.sortByLength(viewport.getAlignment());
3624 addHistoryItem(new OrderCommand("Length Sort", oldOrder,
3625 viewport.getAlignment()));
3626 alignPanel.paintAlignment(true, false);
3636 public void sortGroupMenuItem_actionPerformed(ActionEvent e)
3638 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
3639 AlignmentSorter.sortByGroup(viewport.getAlignment());
3640 addHistoryItem(new OrderCommand("Group Sort", oldOrder,
3641 viewport.getAlignment()));
3643 alignPanel.paintAlignment(true, false);
3653 public void removeRedundancyMenuItem_actionPerformed(ActionEvent e)
3655 new RedundancyPanel(alignPanel, this);
3665 public void pairwiseAlignmentMenuItem_actionPerformed(ActionEvent e)
3667 if ((viewport.getSelectionGroup() == null)
3668 || (viewport.getSelectionGroup().getSize() < 2))
3670 JvOptionPane.showInternalMessageDialog(this,
3671 MessageManager.getString(
3672 "label.you_must_select_least_two_sequences"),
3673 MessageManager.getString("label.invalid_selection"),
3674 JvOptionPane.WARNING_MESSAGE);
3678 JInternalFrame frame = new JInternalFrame();
3679 frame.setContentPane(new PairwiseAlignPanel(viewport));
3680 Desktop.addInternalFrame(frame,
3681 MessageManager.getString("action.pairwise_alignment"), 600,
3687 public void autoCalculate_actionPerformed(ActionEvent e)
3689 viewport.autoCalculateConsensus = autoCalculate.isSelected();
3690 if (viewport.autoCalculateConsensus)
3692 viewport.firePropertyChange("alignment", null,
3693 viewport.getAlignment().getSequences());
3698 public void sortByTreeOption_actionPerformed(ActionEvent e)
3700 viewport.sortByTree = sortByTree.isSelected();
3704 protected void listenToViewSelections_actionPerformed(ActionEvent e)
3706 viewport.followSelection = listenToViewSelections.isSelected();
3710 * Constructs a tree panel and adds it to the desktop
3713 * tree type (NJ or AV)
3715 * name of score model used to compute the tree
3717 * parameters for the distance or similarity calculation
3719 void newTreePanel(String type, String modelName,
3720 SimilarityParamsI options)
3722 String frameTitle = "";
3725 boolean onSelection = false;
3726 if (viewport.getSelectionGroup() != null
3727 && viewport.getSelectionGroup().getSize() > 0)
3729 SequenceGroup sg = viewport.getSelectionGroup();
3731 /* Decide if the selection is a column region */
3732 for (SequenceI _s : sg.getSequences())
3734 if (_s.getLength() < sg.getEndRes())
3736 JvOptionPane.showMessageDialog(Desktop.getDesktopPane(),
3737 MessageManager.getString(
3738 "label.selected_region_to_tree_may_only_contain_residues_or_gaps"),
3739 MessageManager.getString(
3740 "label.sequences_selection_not_aligned"),
3741 JvOptionPane.WARNING_MESSAGE);
3750 if (viewport.getAlignment().getHeight() < 2)
3756 tp = new TreePanel(alignPanel, type, modelName, options);
3757 frameTitle = tp.getPanelTitle() + (onSelection ? " on region" : "");
3759 frameTitle += " from ";
3761 if (viewport.getViewName() != null)
3763 frameTitle += viewport.getViewName() + " of ";
3766 frameTitle += this.title;
3768 Dimension dim = Platform.getDimIfEmbedded(tp, 600, 500);
3769 Desktop.addInternalFrame(tp, frameTitle, dim.width, dim.height);
3780 public void addSortByOrderMenuItem(String title,
3781 final AlignmentOrder order)
3783 final JMenuItem item = new JMenuItem(MessageManager
3784 .formatMessage("action.by_title_param", new Object[]
3787 item.addActionListener(new java.awt.event.ActionListener()
3790 public void actionPerformed(ActionEvent e)
3792 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
3794 // TODO: JBPNote - have to map order entries to curent SequenceI
3796 AlignmentSorter.sortBy(viewport.getAlignment(), order);
3798 addHistoryItem(new OrderCommand(order.getName(), oldOrder,
3799 viewport.getAlignment()));
3801 alignPanel.paintAlignment(true, false);
3807 * Add a new sort by annotation score menu item
3810 * the menu to add the option to
3812 * the label used to retrieve scores for each sequence on the
3815 public void addSortByAnnotScoreMenuItem(JMenu sort,
3816 final String scoreLabel)
3818 final JMenuItem item = new JMenuItem(scoreLabel);
3820 item.addActionListener(new java.awt.event.ActionListener()
3823 public void actionPerformed(ActionEvent e)
3825 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
3826 AlignmentSorter.sortByAnnotationScore(scoreLabel,
3827 viewport.getAlignment());// ,viewport.getSelectionGroup());
3828 addHistoryItem(new OrderCommand("Sort by " + scoreLabel, oldOrder,
3829 viewport.getAlignment()));
3830 alignPanel.paintAlignment(true, false);
3836 * last hash for alignment's annotation array - used to minimise cost of
3839 protected int _annotationScoreVectorHash;
3842 * search the alignment and rebuild the sort by annotation score submenu the
3843 * last alignment annotation vector hash is stored to minimize cost of
3844 * rebuilding in subsequence calls.
3848 public void buildSortByAnnotationScoresMenu()
3850 if (viewport.getAlignment().getAlignmentAnnotation() == null)
3855 if (viewport.getAlignment().getAlignmentAnnotation()
3856 .hashCode() != _annotationScoreVectorHash)
3858 sortByAnnotScore.removeAll();
3859 // almost certainly a quicker way to do this - but we keep it simple
3860 Hashtable<String, String> scoreSorts = new Hashtable<>();
3861 AlignmentAnnotation aann[];
3862 for (SequenceI sqa : viewport.getAlignment().getSequences())
3864 aann = sqa.getAnnotation();
3865 for (int i = 0; aann != null && i < aann.length; i++)
3867 if (aann[i].hasScore() && aann[i].sequenceRef != null)
3869 scoreSorts.put(aann[i].label, aann[i].label);
3873 Enumeration<String> labels = scoreSorts.keys();
3874 while (labels.hasMoreElements())
3876 addSortByAnnotScoreMenuItem(sortByAnnotScore, labels.nextElement());
3878 sortByAnnotScore.setVisible(scoreSorts.size() > 0);
3881 _annotationScoreVectorHash = viewport.getAlignment()
3882 .getAlignmentAnnotation().hashCode();
3887 * Maintain the Order by->Displayed Tree menu. Creates a new menu item for a
3888 * TreePanel with an appropriate <code>jalview.analysis.AlignmentSorter</code>
3889 * call. Listeners are added to remove the menu item when the treePanel is
3890 * closed, and adjust the tree leaf to sequence mapping when the alignment is
3894 public void buildTreeSortMenu()
3896 sortByTreeMenu.removeAll();
3898 List<Component> comps = PaintRefresher.components
3899 .get(viewport.getSequenceSetId());
3900 List<TreePanel> treePanels = new ArrayList<>();
3901 for (Component comp : comps)
3903 if (comp instanceof TreePanel)
3905 treePanels.add((TreePanel) comp);
3909 if (treePanels.size() < 1)
3911 sortByTreeMenu.setVisible(false);
3915 sortByTreeMenu.setVisible(true);
3917 for (final TreePanel tp : treePanels)
3919 final JMenuItem item = new JMenuItem(tp.getTitle());
3920 item.addActionListener(new java.awt.event.ActionListener()
3923 public void actionPerformed(ActionEvent e)
3925 tp.sortByTree_actionPerformed();
3926 addHistoryItem(tp.sortAlignmentIn(alignPanel));
3931 sortByTreeMenu.add(item);
3935 public boolean sortBy(AlignmentOrder alorder, String undoname)
3937 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
3938 AlignmentSorter.sortBy(viewport.getAlignment(), alorder);
3939 if (undoname != null)
3941 addHistoryItem(new OrderCommand(undoname, oldOrder,
3942 viewport.getAlignment()));
3944 alignPanel.paintAlignment(true, false);
3949 * Work out whether the whole set of sequences or just the selected set will
3950 * be submitted for multiple alignment.
3953 public jalview.datamodel.AlignmentView gatherSequencesForAlignment()
3955 // Now, check we have enough sequences
3956 AlignmentView msa = null;
3958 if ((viewport.getSelectionGroup() != null)
3959 && (viewport.getSelectionGroup().getSize() > 1))
3961 // JBPNote UGLY! To prettify, make SequenceGroup and Alignment conform to
3962 // some common interface!
3964 * SequenceGroup seqs = viewport.getSelectionGroup(); int sz; msa = new
3965 * SequenceI[sz = seqs.getSize(false)];
3967 * for (int i = 0; i < sz; i++) { msa[i] = (SequenceI)
3968 * seqs.getSequenceAt(i); }
3970 msa = viewport.getAlignmentView(true);
3972 else if (viewport.getSelectionGroup() != null
3973 && viewport.getSelectionGroup().getSize() == 1)
3975 int option = JvOptionPane.showConfirmDialog(this,
3976 MessageManager.getString("warn.oneseq_msainput_selection"),
3977 MessageManager.getString("label.invalid_selection"),
3978 JvOptionPane.OK_CANCEL_OPTION);
3979 if (option == JvOptionPane.OK_OPTION)
3981 msa = viewport.getAlignmentView(false);
3986 msa = viewport.getAlignmentView(false);
3992 * Decides what is submitted to a secondary structure prediction service: the
3993 * first sequence in the alignment, or in the current selection, or, if the
3994 * alignment is 'aligned' (ie padded with gaps), then the currently selected
3995 * region or the whole alignment. (where the first sequence in the set is the
3996 * one that the prediction will be for).
3998 public AlignmentView gatherSeqOrMsaForSecStrPrediction()
4000 AlignmentView seqs = null;
4002 if ((viewport.getSelectionGroup() != null)
4003 && (viewport.getSelectionGroup().getSize() > 0))
4005 seqs = viewport.getAlignmentView(true);
4009 seqs = viewport.getAlignmentView(false);
4011 // limit sequences - JBPNote in future - could spawn multiple prediction
4013 // TODO: viewport.getAlignment().isAligned is a global state - the local
4014 // selection may well be aligned - we preserve 2.0.8 behaviour for moment.
4015 if (!viewport.getAlignment().isAligned(false))
4017 seqs.setSequences(new SeqCigar[] { seqs.getSequences()[0] });
4018 // TODO: if seqs.getSequences().length>1 then should really have warned
4032 protected void loadTreeMenuItem_actionPerformed(ActionEvent e)
4034 // Pick the tree file
4035 JalviewFileChooser chooser = new JalviewFileChooser(
4036 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
4037 chooser.setFileView(new JalviewFileView());
4038 chooser.setDialogTitle(
4039 MessageManager.getString("label.select_newick_like_tree_file"));
4040 chooser.setToolTipText(
4041 MessageManager.getString("label.load_tree_file"));
4043 chooser.setResponseHandler(0, new Runnable()
4048 String filePath = chooser.getSelectedFile().getPath();
4049 Cache.setProperty("LAST_DIRECTORY", filePath);
4050 NewickFile fin = null;
4053 fin = new NewickFile(new FileParse(chooser.getSelectedFile(),
4054 DataSourceType.FILE));
4055 viewport.setCurrentTree(showNewickTree(fin, filePath).getTree());
4056 } catch (Exception ex)
4058 JvOptionPane.showMessageDialog(Desktop.getDesktopPane(),
4061 .getString("label.problem_reading_tree_file"),
4062 JvOptionPane.WARNING_MESSAGE);
4063 ex.printStackTrace();
4065 if (fin != null && fin.hasWarningMessage())
4067 JvOptionPane.showMessageDialog(Desktop.getDesktopPane(),
4068 fin.getWarningMessage(),
4069 MessageManager.getString(
4070 "label.possible_problem_with_tree_file"),
4071 JvOptionPane.WARNING_MESSAGE);
4075 chooser.showOpenDialog(this);
4078 public TreePanel showNewickTree(NewickFile nf, String treeTitle)
4080 return showNewickTree(nf, treeTitle, 600, 500, 4, 5);
4083 public TreePanel showNewickTree(NewickFile nf, String treeTitle, int w,
4084 int h, int x, int y)
4086 return showNewickTree(nf, treeTitle, null, w, h, x, y);
4090 * Add a treeviewer for the tree extracted from a Newick file object to the
4091 * current alignment view
4098 * Associated alignment input data (or null)
4107 * @return TreePanel handle
4109 public TreePanel showNewickTree(NewickFile nf, String treeTitle,
4110 AlignmentView input, int w, int h, int x, int y)
4112 TreePanel tp = null;
4118 if (nf.getTree() != null)
4120 tp = new TreePanel(alignPanel, nf, treeTitle, input);
4121 Dimension dim = Platform.getDimIfEmbedded(tp, -1, -1);
4124 dim = new Dimension(w, h);
4128 // no offset, either
4131 tp.setSize(dim.width, dim.height);
4135 tp.setLocation(x, y);
4138 Desktop.addInternalFrame(tp, treeTitle, dim.width, dim.height);
4140 } catch (Exception ex)
4142 ex.printStackTrace();
4148 private boolean buildingMenu = false;
4151 * Generates menu items and listener event actions for web service clients
4154 public void BuildWebServiceMenu()
4156 while (buildingMenu)
4160 System.err.println("Waiting for building menu to finish.");
4162 } catch (Exception e)
4166 final AlignFrame me = this;
4167 buildingMenu = true;
4168 new Thread(new Runnable()
4173 final List<JMenuItem> legacyItems = new ArrayList<>();
4176 // System.err.println("Building ws menu again "
4177 // + Thread.currentThread());
4178 // TODO: add support for context dependent disabling of services based
4180 // alignment and current selection
4181 // TODO: add additional serviceHandle parameter to specify abstract
4183 // class independently of AbstractName
4184 // TODO: add in rediscovery GUI function to restart discoverer
4185 // TODO: group services by location as well as function and/or
4187 // object broker mechanism.
4188 final Vector<JMenu> wsmenu = new Vector<>();
4189 final IProgressIndicator af = me;
4192 * do not i18n these strings - they are hard-coded in class
4193 * compbio.data.msa.Category, Jws2Discoverer.isRecalculable() and
4194 * SequenceAnnotationWSClient.initSequenceAnnotationWSClient()
4196 final JMenu msawsmenu = new JMenu("Alignment");
4197 final JMenu secstrmenu = new JMenu(
4198 "Secondary Structure Prediction");
4199 final JMenu seqsrchmenu = new JMenu("Sequence Database Search");
4200 final JMenu analymenu = new JMenu("Analysis");
4201 final JMenu dismenu = new JMenu("Protein Disorder");
4202 // JAL-940 - only show secondary structure prediction services from
4203 // the legacy server
4204 Hashtable<String, Vector<ServiceHandle>> ds = Discoverer
4207 if (// Cache.getDefault("SHOW_JWS1_SERVICES", true)
4209 ds != null && (ds.size() > 0))
4211 // TODO: refactor to allow list of AbstractName/Handler bindings to
4213 // stored or retrieved from elsewhere
4214 // No MSAWS used any more:
4215 // Vector msaws = null; // (Vector)
4216 // Discoverer.services.get("MsaWS");
4217 Vector<ServiceHandle> secstrpr = ds.get("SecStrPred");
4218 if (secstrpr != null)
4220 // Add any secondary structure prediction services
4221 for (int i = 0, j = secstrpr.size(); i < j; i++)
4223 final ext.vamsas.ServiceHandle sh = secstrpr.get(i);
4224 jalview.ws.WSMenuEntryProviderI impl = jalview.ws.jws1.Discoverer
4225 .getServiceClient(sh);
4226 int p = secstrmenu.getItemCount();
4227 impl.attachWSMenuEntry(secstrmenu, me);
4228 int q = secstrmenu.getItemCount();
4229 for (int litm = p; litm < q; litm++)
4231 legacyItems.add(secstrmenu.getItem(litm));
4237 // Add all submenus in the order they should appear on the web
4239 wsmenu.add(msawsmenu);
4240 wsmenu.add(secstrmenu);
4241 wsmenu.add(dismenu);
4242 wsmenu.add(analymenu);
4243 // No search services yet
4244 // wsmenu.add(seqsrchmenu);
4246 javax.swing.SwingUtilities.invokeLater(new Runnable()
4253 webService.removeAll();
4254 // first, add discovered services onto the webservices menu
4255 if (wsmenu.size() > 0)
4257 for (int i = 0, j = wsmenu.size(); i < j; i++)
4259 webService.add(wsmenu.get(i));
4264 webService.add(me.webServiceNoServices);
4266 // TODO: move into separate menu builder class.
4267 boolean new_sspred = false;
4268 if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
4270 Jws2Discoverer jws2servs = Jws2Discoverer.getInstance();
4271 if (jws2servs != null)
4273 if (jws2servs.hasServices())
4275 jws2servs.attachWSMenuEntry(webService, me);
4276 for (Jws2Instance sv : jws2servs.getServices())
4278 if (sv.description.toLowerCase().contains("jpred"))
4280 for (JMenuItem jmi : legacyItems)
4282 jmi.setVisible(false);
4288 if (jws2servs.isRunning())
4290 JMenuItem tm = new JMenuItem(
4291 "Still discovering JABA Services");
4292 tm.setEnabled(false);
4297 build_urlServiceMenu(me.webService);
4298 build_fetchdbmenu(webService);
4299 for (JMenu item : wsmenu)
4301 if (item.getItemCount() == 0)
4303 item.setEnabled(false);
4307 item.setEnabled(true);
4310 } catch (Exception e)
4313 "Exception during web service menu building process.",
4318 } catch (Exception e)
4321 buildingMenu = false;
4328 * construct any groupURL type service menu entries.
4332 protected void build_urlServiceMenu(JMenu webService)
4334 // TODO: remove this code when 2.7 is released
4335 // DEBUG - alignmentView
4337 * JMenuItem testAlView = new JMenuItem("Test AlignmentView"); final
4338 * AlignFrame af = this; testAlView.addActionListener(new ActionListener() {
4340 * @Override public void actionPerformed(ActionEvent e) {
4341 * jalview.datamodel.AlignmentView
4342 * .testSelectionViews(af.viewport.getAlignment(),
4343 * af.viewport.getColumnSelection(), af.viewport.selectionGroup); }
4345 * }); webService.add(testAlView);
4347 // TODO: refactor to RestClient discoverer and merge menu entries for
4348 // rest-style services with other types of analysis/calculation service
4349 // SHmmr test client - still being implemented.
4350 // DEBUG - alignmentView
4352 for (jalview.ws.rest.RestClient client : jalview.ws.rest.RestClient
4355 client.attachWSMenuEntry(
4356 JvSwingUtils.findOrCreateMenu(webService, client.getAction()),
4362 * Searches the alignment sequences for xRefs and builds the Show
4363 * Cross-References menu (formerly called Show Products), with database
4364 * sources for which cross-references are found (protein sources for a
4365 * nucleotide alignment and vice versa)
4367 * @return true if Show Cross-references menu should be enabled
4369 public boolean canShowProducts()
4371 SequenceI[] seqs = viewport.getAlignment().getSequencesArray();
4372 AlignmentI dataset = viewport.getAlignment().getDataset();
4374 showProducts.removeAll();
4375 final boolean dna = viewport.getAlignment().isNucleotide();
4377 if (seqs == null || seqs.length == 0)
4379 // nothing to see here.
4383 boolean showp = false;
4386 List<String> ptypes = new CrossRef(seqs, dataset)
4387 .findXrefSourcesForSequences(dna);
4389 for (final String source : ptypes)
4392 final AlignFrame af = this;
4393 JMenuItem xtype = new JMenuItem(source);
4394 xtype.addActionListener(new ActionListener()
4397 public void actionPerformed(ActionEvent e)
4399 showProductsFor(af.viewport.getSequenceSelection(), dna,
4403 showProducts.add(xtype);
4405 showProducts.setVisible(showp);
4406 showProducts.setEnabled(showp);
4407 } catch (Exception e)
4410 "canShowProducts threw an exception - please report to help@jalview.org",
4418 * Finds and displays cross-references for the selected sequences (protein
4419 * products for nucleotide sequences, dna coding sequences for peptides).
4422 * the sequences to show cross-references for
4424 * true if from a nucleotide alignment (so showing proteins)
4426 * the database to show cross-references for
4428 protected void showProductsFor(final SequenceI[] sel, final boolean _odna,
4429 final String source)
4431 new Thread(CrossRefAction.getHandlerFor(sel, _odna, source, this))
4436 * Construct and display a new frame containing the translation of this
4437 * frame's DNA sequences to their aligned protein (amino acid) equivalents.
4440 public void showTranslation_actionPerformed(GeneticCodeI codeTable)
4442 AlignmentI al = null;
4445 Dna dna = new Dna(viewport, viewport.getViewAsVisibleContigs(true));
4447 al = dna.translateCdna(codeTable);
4448 } catch (Exception ex)
4450 jalview.bin.Cache.log.error(
4451 "Exception during translation. Please report this !", ex);
4452 final String msg = MessageManager.getString(
4453 "label.error_when_translating_sequences_submit_bug_report");
4454 final String errorTitle = MessageManager
4455 .getString("label.implementation_error")
4456 + MessageManager.getString("label.translation_failed");
4457 JvOptionPane.showMessageDialog(Desktop.getDesktopPane(), msg,
4458 errorTitle, JvOptionPane.ERROR_MESSAGE);
4461 if (al == null || al.getHeight() == 0)
4463 final String msg = MessageManager.getString(
4464 "label.select_at_least_three_bases_in_at_least_one_sequence_to_cDNA_translation");
4465 final String errorTitle = MessageManager
4466 .getString("label.translation_failed");
4467 JvOptionPane.showMessageDialog(Desktop.getDesktopPane(), msg,
4468 errorTitle, JvOptionPane.WARNING_MESSAGE);
4472 AlignFrame af = new AlignFrame(al, DEFAULT_WIDTH, DEFAULT_HEIGHT);
4473 af.setFileFormat(this.currentFileFormat);
4474 final String newTitle = MessageManager
4475 .formatMessage("label.translation_of_params", new Object[]
4476 { this.getTitle(), codeTable.getId() });
4477 af.setTitle(newTitle);
4478 if (Cache.getDefault(Preferences.ENABLE_SPLIT_FRAME, true))
4480 final SequenceI[] seqs = viewport.getSelectionAsNewSequence();
4481 AlignViewport.openSplitFrame(this, af, new Alignment(seqs));
4485 Desktop.addInternalFrame(af, newTitle, DEFAULT_WIDTH,
4492 * Set the file format
4496 public void setFileFormat(FileFormatI format)
4498 this.currentFileFormat = format;
4502 * Try to load a features file onto the alignment.
4505 * contents or path to retrieve file or a File object
4507 * access mode of file (see jalview.io.AlignFile)
4508 * @return true if features file was parsed correctly.
4510 public boolean parseFeaturesFile(Object file, DataSourceType sourceType)
4513 return avc.parseFeaturesFile(file, sourceType,
4514 Cache.getDefault("RELAXEDSEQIDMATCHING", false));
4519 public void refreshFeatureUI(boolean enableIfNecessary)
4521 // note - currently this is only still here rather than in the controller
4522 // because of the featureSettings hard reference that is yet to be
4524 if (enableIfNecessary)
4526 viewport.setShowSequenceFeatures(true);
4527 showSeqFeatures.setSelected(true);
4533 public void dragEnter(DropTargetDragEvent evt)
4538 public void dragExit(DropTargetEvent evt)
4543 public void dragOver(DropTargetDragEvent evt)
4548 public void dropActionChanged(DropTargetDragEvent evt)
4553 public void drop(DropTargetDropEvent evt)
4555 // JAL-1552 - acceptDrop required before getTransferable call for
4556 // Java's Transferable for native dnd
4557 evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
4558 Transferable t = evt.getTransferable();
4560 final List<Object> files = new ArrayList<>();
4561 List<DataSourceType> protocols = new ArrayList<>();
4565 Desktop.transferFromDropTarget(files, protocols, evt, t);
4566 if (files.size() > 0)
4568 new Thread(new Runnable()
4573 loadDroppedFiles(files, protocols, evt, t);
4577 } catch (Exception e)
4579 e.printStackTrace();
4583 protected void loadDroppedFiles(List<Object> files,
4584 List<DataSourceType> protocols, DropTargetDropEvent evt,
4589 // check to see if any of these files have names matching sequences
4592 SequenceIdMatcher idm = new SequenceIdMatcher(
4593 viewport.getAlignment().getSequencesArray());
4595 * Object[] { String,SequenceI}
4597 ArrayList<Object[]> filesmatched = new ArrayList<>();
4598 ArrayList<Object> filesnotmatched = new ArrayList<>();
4599 for (int i = 0; i < files.size(); i++)
4602 Object file = files.get(i);
4603 String fileName = file.toString();
4605 DataSourceType protocol = (file instanceof File
4606 ? DataSourceType.FILE
4607 : FormatAdapter.checkProtocol(fileName));
4608 if (protocol == DataSourceType.FILE)
4611 if (file instanceof File)
4614 Platform.cacheFileData(fl);
4618 fl = new File(fileName);
4620 pdbfn = fl.getName();
4622 else if (protocol == DataSourceType.URL)
4624 URL url = new URL(fileName);
4625 pdbfn = url.getFile();
4627 if (pdbfn.length() > 0)
4629 // attempt to find a match in the alignment
4630 SequenceI[] mtch = idm.findAllIdMatches(pdbfn);
4631 int l = 0, c = pdbfn.indexOf(".");
4632 while (mtch == null && c != -1)
4637 } while ((c = pdbfn.indexOf(".", l)) > l);
4640 pdbfn = pdbfn.substring(0, l);
4642 mtch = idm.findAllIdMatches(pdbfn);
4649 type = new IdentifyFile().identify(file, protocol);
4650 } catch (Exception ex)
4654 if (type != null && type.isStructureFile())
4656 filesmatched.add(new Object[] { file, protocol, mtch });
4660 // File wasn't named like one of the sequences or wasn't a PDB
4662 filesnotmatched.add(file);
4666 if (filesmatched.size() > 0)
4668 boolean autoAssociate = Cache.getDefault("AUTOASSOCIATE_PDBANDSEQS",
4672 String msg = MessageManager.formatMessage(
4673 "label.automatically_associate_structure_files_with_sequences_same_name",
4675 { Integer.valueOf(filesmatched.size()).toString() });
4676 String ttl = MessageManager.getString(
4677 "label.automatically_associate_structure_files_by_name");
4678 int choice = JvOptionPane.showConfirmDialog(this, msg, ttl,
4679 JvOptionPane.YES_NO_OPTION);
4680 autoAssociate = choice == JvOptionPane.YES_OPTION;
4684 for (Object[] fm : filesmatched)
4686 // try and associate
4687 // TODO: may want to set a standard ID naming formalism for
4688 // associating PDB files which have no IDs.
4689 for (SequenceI toassoc : (SequenceI[]) fm[2])
4691 PDBEntry pe = new AssociatePdbFileWithSeq()
4692 .associatePdbWithSeq(fm[0].toString(),
4693 (DataSourceType) fm[1], toassoc, false,
4694 Desktop.getInstance());
4697 System.err.println("Associated file : " + (fm[0].toString())
4698 + " with " + toassoc.getDisplayId(true));
4702 // TODO: do we need to update overview ? only if features are
4704 alignPanel.paintAlignment(true, false);
4710 * add declined structures as sequences
4712 for (Object[] o : filesmatched)
4714 filesnotmatched.add(o[0]);
4718 if (filesnotmatched.size() > 0)
4720 if (assocfiles > 0 && (Cache
4721 .getDefault("AUTOASSOCIATE_PDBANDSEQS_IGNOREOTHERS", false)
4722 || JvOptionPane.showConfirmDialog(this,
4723 "<html>" + MessageManager.formatMessage(
4724 "label.ignore_unmatched_dropped_files_info",
4726 { Integer.valueOf(filesnotmatched.size())
4729 MessageManager.getString(
4730 "label.ignore_unmatched_dropped_files"),
4731 JvOptionPane.YES_NO_OPTION) == JvOptionPane.YES_OPTION))
4735 for (Object fn : filesnotmatched)
4737 loadJalviewDataFile(fn, null, null, null);
4741 } catch (Exception ex)
4743 ex.printStackTrace();
4748 * Attempt to load a "dropped" file or URL string, by testing in turn for
4750 * <li>an Annotation file</li>
4751 * <li>a JNet file</li>
4752 * <li>a features file</li>
4753 * <li>else try to interpret as an alignment file</li>
4757 * either a filename or a URL string.
4759 public void loadJalviewDataFile(Object file, DataSourceType sourceType,
4760 FileFormatI format, SequenceI assocSeq)
4762 // BH 2018 was String file
4765 if (sourceType == null)
4767 sourceType = FormatAdapter.checkProtocol(file);
4769 // if the file isn't identified, or not positively identified as some
4770 // other filetype (PFAM is default unidentified alignment file type) then
4771 // try to parse as annotation.
4772 boolean isAnnotation = (format == null
4773 || FileFormat.Pfam.equals(format))
4774 ? new AnnotationFile().annotateAlignmentView(viewport,
4780 // first see if its a T-COFFEE score file
4781 TCoffeeScoreFile tcf = null;
4784 tcf = new TCoffeeScoreFile(file, sourceType);
4787 if (tcf.annotateAlignment(viewport.getAlignment(), true))
4791 new TCoffeeColourScheme(viewport.getAlignment()));
4792 isAnnotation = true;
4793 setStatus(MessageManager.getString(
4794 "label.successfully_pasted_tcoffee_scores_to_alignment"));
4798 // some problem - if no warning its probable that the ID matching
4799 // process didn't work
4800 JvOptionPane.showMessageDialog(Desktop.getDesktopPane(),
4801 tcf.getWarningMessage() == null
4802 ? MessageManager.getString(
4803 "label.check_file_matches_sequence_ids_alignment")
4804 : tcf.getWarningMessage(),
4805 MessageManager.getString(
4806 "label.problem_reading_tcoffee_score_file"),
4807 JvOptionPane.WARNING_MESSAGE);
4814 } catch (Exception x)
4817 "Exception when processing data source as T-COFFEE score file",
4823 // try to see if its a JNet 'concise' style annotation file *before*
4825 // try to parse it as a features file
4828 format = new IdentifyFile().identify(file, sourceType);
4830 if (FileFormat.ScoreMatrix == format)
4832 ScoreMatrixFile sm = new ScoreMatrixFile(
4833 new FileParse(file, sourceType));
4835 // todo: i18n this message
4836 setStatus(MessageManager.formatMessage(
4837 "label.successfully_loaded_matrix",
4838 sm.getMatrixName()));
4840 else if (FileFormat.Jnet.equals(format))
4842 JPredFile predictions = new JPredFile(file, sourceType);
4843 new JnetAnnotationMaker();
4844 JnetAnnotationMaker.add_annotation(predictions,
4845 viewport.getAlignment(), 0, false);
4846 viewport.getAlignment().setupJPredAlignment();
4847 isAnnotation = true;
4849 // else if (IdentifyFile.FeaturesFile.equals(format))
4850 else if (FileFormat.Features.equals(format))
4852 if (parseFeaturesFile(file, sourceType))
4854 SplitFrame splitFrame = (SplitFrame) getSplitViewContainer();
4855 if (splitFrame != null)
4857 splitFrame.repaint();
4861 alignPanel.paintAlignment(true, true);
4867 new FileLoader().LoadFile(viewport, file, sourceType, format);
4873 updateForAnnotations();
4875 } catch (Exception ex)
4877 ex.printStackTrace();
4878 } catch (OutOfMemoryError oom)
4883 } catch (Exception x)
4888 + (sourceType != null
4889 ? (sourceType == DataSourceType.PASTE
4891 : "using " + sourceType + " from "
4895 ? "(parsing as '" + format + "' file)"
4897 oom, Desktop.getDesktopPane());
4902 * Do all updates necessary after an annotation file such as jnet. Also called
4903 * from Jalview.loadAppletParams for "annotations", "jnetFile"
4906 public void updateForAnnotations()
4908 alignPanel.adjustAnnotationHeight();
4909 viewport.updateSequenceIdColours();
4910 buildSortByAnnotationScoresMenu();
4911 alignPanel.paintAlignment(true, true);
4915 * Change the display state for the given feature groups -- Added by BH from
4919 * list of group strings
4921 * visible or invisible
4923 public void setFeatureGroupState(String[] groups, boolean state)
4925 jalview.api.FeatureRenderer fr = null;
4926 viewport.setShowSequenceFeatures(true);
4927 if (alignPanel != null
4928 && (fr = alignPanel.getFeatureRenderer()) != null)
4931 fr.setGroupVisibility(Arrays.asList(groups), state);
4932 alignPanel.getSeqPanel().seqCanvas.repaint();
4933 if (alignPanel.overviewPanel != null)
4935 alignPanel.overviewPanel.updateOverviewImage();
4941 * Method invoked by the ChangeListener on the tabbed pane, in other words
4942 * when a different tabbed pane is selected by the user or programmatically.
4945 public void tabSelectionChanged(int index)
4949 alignPanel = alignPanels.get(index);
4950 viewport = alignPanel.av;
4951 avc.setViewportAndAlignmentPanel(viewport, alignPanel);
4952 setMenusFromViewport(viewport);
4953 if (featureSettings != null && featureSettings.isOpen()
4954 && featureSettings.fr.getViewport() != viewport)
4956 if (viewport.isShowSequenceFeatures())
4958 // refresh the featureSettings to reflect UI change
4959 showFeatureSettingsUI();
4963 // close feature settings for this view.
4964 featureSettings.close();
4971 * 'focus' any colour slider that is open to the selected viewport
4973 if (viewport.getConservationSelected())
4975 SliderPanel.setConservationSlider(alignPanel,
4976 viewport.getResidueShading(), alignPanel.getViewName());
4980 SliderPanel.hideConservationSlider();
4982 if (viewport.getAbovePIDThreshold())
4984 SliderPanel.setPIDSliderSource(alignPanel,
4985 viewport.getResidueShading(), alignPanel.getViewName());
4989 SliderPanel.hidePIDSlider();
4993 * If there is a frame linked to this one in a SplitPane, switch it to the
4994 * same view tab index. No infinite recursion of calls should happen, since
4995 * tabSelectionChanged() should not get invoked on setting the selected
4996 * index to an unchanged value. Guard against setting an invalid index
4997 * before the new view peer tab has been created.
4999 final AlignViewportI peer = viewport.getCodingComplement();
5002 AlignFrame linkedAlignFrame = ((AlignViewport) peer)
5003 .getAlignPanel().alignFrame;
5004 if (linkedAlignFrame.tabbedPane.getTabCount() > index)
5006 linkedAlignFrame.tabbedPane.setSelectedIndex(index);
5012 * On right mouse click on view tab, prompt for and set new view name.
5015 public void tabbedPane_mousePressed(MouseEvent e)
5017 if (e.isPopupTrigger())
5019 String msg = MessageManager.getString("label.enter_view_name");
5020 String ttl = tabbedPane.getTitleAt(tabbedPane.getSelectedIndex());
5021 String reply = JvOptionPane.showInputDialog(msg, ttl);
5025 viewport.setViewName(reply);
5026 // TODO warn if reply is in getExistingViewNames()?
5027 tabbedPane.setTitleAt(tabbedPane.getSelectedIndex(), reply);
5032 public AlignViewport getCurrentView()
5038 * Open the dialog for regex description parsing.
5041 protected void extractScores_actionPerformed(ActionEvent e)
5043 ParseProperties pp = new jalview.analysis.ParseProperties(
5044 viewport.getAlignment());
5045 // TODO: verify regex and introduce GUI dialog for version 2.5
5046 // if (pp.getScoresFromDescription("col", "score column ",
5047 // "\\W*([-+]?\\d*\\.?\\d*e?-?\\d*)\\W+([-+]?\\d*\\.?\\d*e?-?\\d*)",
5049 if (pp.getScoresFromDescription("description column",
5050 "score in description column ", "\\W*([-+eE0-9.]+)", true) > 0)
5052 buildSortByAnnotationScoresMenu();
5060 * jalview.jbgui.GAlignFrame#showDbRefs_actionPerformed(java.awt.event.ActionEvent
5064 protected void showDbRefs_actionPerformed(ActionEvent e)
5066 viewport.setShowDBRefs(showDbRefsMenuitem.isSelected());
5072 * @seejalview.jbgui.GAlignFrame#showNpFeats_actionPerformed(java.awt.event.
5076 protected void showNpFeats_actionPerformed(ActionEvent e)
5078 viewport.setShowNPFeats(showNpFeatsMenuitem.isSelected());
5082 * find the viewport amongst the tabs in this alignment frame and close that
5087 public boolean closeView(AlignViewportI av)
5091 this.closeMenuItem_actionPerformed(false);
5094 Component[] comp = tabbedPane.getComponents();
5095 for (int i = 0; comp != null && i < comp.length; i++)
5097 if (comp[i] instanceof AlignmentPanel)
5099 if (((AlignmentPanel) comp[i]).av == av)
5102 closeView((AlignmentPanel) comp[i]);
5110 protected void build_fetchdbmenu(JMenu webService)
5112 // Temporary hack - DBRef Fetcher always top level ws entry.
5113 // TODO We probably want to store a sequence database checklist in
5114 // preferences and have checkboxes.. rather than individual sources selected
5116 final JMenu rfetch = new JMenu(
5117 MessageManager.getString("action.fetch_db_references"));
5118 rfetch.setToolTipText(MessageManager.getString(
5119 "label.retrieve_parse_sequence_database_records_alignment_or_selected_sequences"));
5120 webService.add(rfetch);
5122 final JCheckBoxMenuItem trimrs = new JCheckBoxMenuItem(
5123 MessageManager.getString("option.trim_retrieved_seqs"));
5124 trimrs.setToolTipText(
5125 MessageManager.getString("label.trim_retrieved_sequences"));
5127 Cache.getDefault(DBRefFetcher.TRIM_RETRIEVED_SEQUENCES, true));
5128 trimrs.addActionListener(new ActionListener()
5131 public void actionPerformed(ActionEvent e)
5133 trimrs.setSelected(trimrs.isSelected());
5134 Cache.setProperty(DBRefFetcher.TRIM_RETRIEVED_SEQUENCES,
5135 Boolean.valueOf(trimrs.isSelected()).toString());
5139 JMenuItem fetchr = new JMenuItem(
5140 MessageManager.getString("label.standard_databases"));
5141 fetchr.setToolTipText(
5142 MessageManager.getString("label.fetch_embl_uniprot"));
5143 fetchr.addActionListener(new ActionListener()
5147 public void actionPerformed(ActionEvent e)
5149 new Thread(new Runnable()
5154 boolean isNucleotide = alignPanel.alignFrame.getViewport()
5155 .getAlignment().isNucleotide();
5156 DBRefFetcher dbRefFetcher = new DBRefFetcher(
5157 alignPanel.av.getSequenceSelection(),
5158 alignPanel.alignFrame, null,
5159 alignPanel.alignFrame.featureSettings, isNucleotide);
5160 dbRefFetcher.addListener(new FetchFinishedListenerI()
5163 public void finished()
5166 for (FeatureSettingsModelI srcSettings : dbRefFetcher
5167 .getFeatureSettingsModels())
5170 alignPanel.av.mergeFeaturesStyle(srcSettings);
5172 AlignFrame.this.setMenusForViewport();
5175 dbRefFetcher.fetchDBRefs(false);
5183 new Thread(new Runnable()
5188 final jalview.ws.SequenceFetcher sf = jalview.gui.SequenceFetcher
5189 .getSequenceFetcherSingleton();
5190 javax.swing.SwingUtilities.invokeLater(new Runnable()
5195 String[] dbclasses = sf.getNonAlignmentSources();
5196 List<DbSourceProxy> otherdb;
5197 JMenu dfetch = new JMenu();
5198 JMenu ifetch = new JMenu();
5199 JMenuItem fetchr = null;
5200 int comp = 0, icomp = 0, mcomp = 15;
5201 String mname = null;
5203 for (String dbclass : dbclasses)
5205 otherdb = sf.getSourceProxy(dbclass);
5206 // add a single entry for this class, or submenu allowing 'fetch
5208 if (otherdb == null || otherdb.size() < 1)
5214 mname = "From " + dbclass;
5216 if (otherdb.size() == 1)
5218 final DbSourceProxy[] dassource = otherdb
5219 .toArray(new DbSourceProxy[0]);
5220 DbSourceProxy src = otherdb.get(0);
5221 fetchr = new JMenuItem(src.getDbSource());
5222 fetchr.addActionListener(new ActionListener()
5226 public void actionPerformed(ActionEvent e)
5228 new Thread(new Runnable()
5234 boolean isNucleotide = alignPanel.alignFrame
5235 .getViewport().getAlignment()
5237 DBRefFetcher dbRefFetcher = new DBRefFetcher(
5238 alignPanel.av.getSequenceSelection(),
5239 alignPanel.alignFrame, dassource,
5240 alignPanel.alignFrame.featureSettings,
5243 .addListener(new FetchFinishedListenerI()
5246 public void finished()
5248 FeatureSettingsModelI srcSettings = dassource[0]
5249 .getFeatureColourScheme();
5250 alignPanel.av.mergeFeaturesStyle(
5252 AlignFrame.this.setMenusForViewport();
5255 dbRefFetcher.fetchDBRefs(false);
5261 fetchr.setToolTipText(JvSwingUtils.wrapTooltip(true,
5262 MessageManager.formatMessage(
5263 "label.fetch_retrieve_from", new Object[]
5264 { src.getDbName() })));
5270 final DbSourceProxy[] dassource = otherdb
5271 .toArray(new DbSourceProxy[0]);
5273 DbSourceProxy src = otherdb.get(0);
5274 fetchr = new JMenuItem(MessageManager
5275 .formatMessage("label.fetch_all_param", new Object[]
5276 { src.getDbSource() }));
5277 fetchr.addActionListener(new ActionListener()
5280 public void actionPerformed(ActionEvent e)
5282 new Thread(new Runnable()
5288 boolean isNucleotide = alignPanel.alignFrame
5289 .getViewport().getAlignment()
5291 DBRefFetcher dbRefFetcher = new DBRefFetcher(
5292 alignPanel.av.getSequenceSelection(),
5293 alignPanel.alignFrame, dassource,
5294 alignPanel.alignFrame.featureSettings,
5297 .addListener(new FetchFinishedListenerI()
5300 public void finished()
5302 AlignFrame.this.setMenusForViewport();
5305 dbRefFetcher.fetchDBRefs(false);
5311 fetchr.setToolTipText(JvSwingUtils.wrapTooltip(true,
5312 MessageManager.formatMessage(
5313 "label.fetch_retrieve_from_all_sources",
5315 { Integer.valueOf(otherdb.size())
5317 src.getDbSource(), src.getDbName() })));
5320 // and then build the rest of the individual menus
5321 ifetch = new JMenu(MessageManager.formatMessage(
5322 "label.source_from_db_source", new Object[]
5323 { src.getDbSource() }));
5325 String imname = null;
5327 for (DbSourceProxy sproxy : otherdb)
5329 String dbname = sproxy.getDbName();
5330 String sname = dbname.length() > 5
5331 ? dbname.substring(0, 5) + "..."
5333 String msname = dbname.length() > 10
5334 ? dbname.substring(0, 10) + "..."
5338 imname = MessageManager
5339 .formatMessage("label.from_msname", new Object[]
5342 fetchr = new JMenuItem(msname);
5343 final DbSourceProxy[] dassrc = { sproxy };
5344 fetchr.addActionListener(new ActionListener()
5348 public void actionPerformed(ActionEvent e)
5350 new Thread(new Runnable()
5356 boolean isNucleotide = alignPanel.alignFrame
5357 .getViewport().getAlignment()
5359 DBRefFetcher dbRefFetcher = new DBRefFetcher(
5360 alignPanel.av.getSequenceSelection(),
5361 alignPanel.alignFrame, dassrc,
5362 alignPanel.alignFrame.featureSettings,
5365 .addListener(new FetchFinishedListenerI()
5368 public void finished()
5370 AlignFrame.this.setMenusForViewport();
5373 dbRefFetcher.fetchDBRefs(false);
5379 fetchr.setToolTipText(
5380 "<html>" + MessageManager.formatMessage(
5381 "label.fetch_retrieve_from", new Object[]
5385 if (++icomp >= mcomp || i == (otherdb.size()))
5387 ifetch.setText(MessageManager.formatMessage(
5388 "label.source_to_target", imname, sname));
5390 ifetch = new JMenu();
5398 if (comp >= mcomp || dbi >= (dbclasses.length))
5400 dfetch.setText(MessageManager.formatMessage(
5401 "label.source_to_target", mname, dbclass));
5403 dfetch = new JMenu();
5416 * Left justify the whole alignment.
5419 protected void justifyLeftMenuItem_actionPerformed(ActionEvent e)
5421 AlignmentI al = viewport.getAlignment();
5423 viewport.firePropertyChange("alignment", null, al);
5427 * Right justify the whole alignment.
5430 protected void justifyRightMenuItem_actionPerformed(ActionEvent e)
5432 AlignmentI al = viewport.getAlignment();
5434 viewport.firePropertyChange("alignment", null, al);
5438 public void setShowSeqFeatures(boolean b)
5440 showSeqFeatures.setSelected(b);
5441 viewport.setShowSequenceFeatures(b);
5448 * jalview.jbgui.GAlignFrame#showUnconservedMenuItem_actionPerformed(java.
5449 * awt.event.ActionEvent)
5452 protected void showUnconservedMenuItem_actionPerformed(ActionEvent e)
5454 viewport.setShowUnconserved(showNonconservedMenuItem.getState());
5455 alignPanel.paintAlignment(false, false);
5462 * jalview.jbgui.GAlignFrame#showGroupConsensus_actionPerformed(java.awt.event
5466 protected void showGroupConsensus_actionPerformed(ActionEvent e)
5468 viewport.setShowGroupConsensus(showGroupConsensus.getState());
5469 alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
5477 * jalview.jbgui.GAlignFrame#showGroupConservation_actionPerformed(java.awt
5478 * .event.ActionEvent)
5481 protected void showGroupConservation_actionPerformed(ActionEvent e)
5483 viewport.setShowGroupConservation(showGroupConservation.getState());
5484 alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
5491 * jalview.jbgui.GAlignFrame#showConsensusHistogram_actionPerformed(java.awt
5492 * .event.ActionEvent)
5495 protected void showConsensusHistogram_actionPerformed(ActionEvent e)
5497 viewport.setShowConsensusHistogram(showConsensusHistogram.getState());
5498 alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
5505 * jalview.jbgui.GAlignFrame#showConsensusProfile_actionPerformed(java.awt
5506 * .event.ActionEvent)
5509 protected void showSequenceLogo_actionPerformed(ActionEvent e)
5511 viewport.setShowSequenceLogo(showSequenceLogo.getState());
5512 alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
5516 protected void normaliseSequenceLogo_actionPerformed(ActionEvent e)
5518 showSequenceLogo.setState(true);
5519 viewport.setShowSequenceLogo(true);
5520 viewport.setNormaliseSequenceLogo(normaliseSequenceLogo.getState());
5521 alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
5525 protected void applyAutoAnnotationSettings_actionPerformed(ActionEvent e)
5527 alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
5534 * jalview.jbgui.GAlignFrame#makeGrpsFromSelection_actionPerformed(java.awt
5535 * .event.ActionEvent)
5538 protected void makeGrpsFromSelection_actionPerformed(ActionEvent e)
5540 if (avc.makeGroupsFromSelection())
5542 PaintRefresher.Refresh(this, viewport.getSequenceSetId());
5543 alignPanel.updateAnnotation();
5544 alignPanel.paintAlignment(true,
5545 viewport.needToUpdateStructureViews());
5549 public void clearAlignmentSeqRep()
5551 // TODO refactor alignmentseqrep to controller
5552 if (viewport.getAlignment().hasSeqrep())
5554 viewport.getAlignment().setSeqrep(null);
5555 PaintRefresher.Refresh(this, viewport.getSequenceSetId());
5556 alignPanel.updateAnnotation();
5557 alignPanel.paintAlignment(true, true);
5562 protected void createGroup_actionPerformed(ActionEvent e)
5564 if (avc.createGroup())
5566 if (applyAutoAnnotationSettings.isSelected())
5568 alignPanel.updateAnnotation(true, false);
5570 alignPanel.alignmentChanged();
5575 protected void unGroup_actionPerformed(ActionEvent e)
5579 alignPanel.alignmentChanged();
5584 * make the given alignmentPanel the currently selected tab
5586 * @param alignmentPanel
5588 public void setDisplayedView(AlignmentPanel alignmentPanel)
5590 if (!viewport.getSequenceSetId()
5591 .equals(alignmentPanel.av.getSequenceSetId()))
5593 throw new Error(MessageManager.getString(
5594 "error.implementation_error_cannot_show_view_alignment_frame"));
5596 if (tabbedPane != null && tabbedPane.getTabCount() > 0 && alignPanels
5597 .indexOf(alignmentPanel) != tabbedPane.getSelectedIndex())
5599 tabbedPane.setSelectedIndex(alignPanels.indexOf(alignmentPanel));
5604 * Action on selection of menu options to Show or Hide annotations.
5607 * @param forSequences
5608 * update sequence-related annotations
5609 * @param forAlignment
5610 * update non-sequence-related annotations
5613 protected void setAnnotationsVisibility(boolean visible,
5614 boolean forSequences, boolean forAlignment)
5616 AlignmentAnnotation[] anns = alignPanel.getAlignment()
5617 .getAlignmentAnnotation();
5622 for (AlignmentAnnotation aa : anns)
5625 * don't display non-positional annotations on an alignment
5627 if (aa.annotations == null)
5631 boolean apply = (aa.sequenceRef == null && forAlignment)
5632 || (aa.sequenceRef != null && forSequences);
5635 aa.visible = visible;
5638 alignPanel.validateAnnotationDimensions(true);
5639 alignPanel.alignmentChanged();
5643 * Store selected annotation sort order for the view and repaint.
5646 protected void sortAnnotations_actionPerformed()
5648 this.alignPanel.av.setSortAnnotationsBy(getAnnotationSortOrder());
5650 .setShowAutocalculatedAbove(isShowAutoCalculatedAbove());
5651 alignPanel.paintAlignment(false, false);
5656 * @return alignment panels in this alignment frame
5658 public List<? extends AlignmentViewPanel> getAlignPanels()
5660 // alignPanels is never null
5661 // return alignPanels == null ? Arrays.asList(alignPanel) : alignPanels;
5666 * Open a new alignment window, with the cDNA associated with this (protein)
5667 * alignment, aligned as is the protein.
5669 protected void viewAsCdna_actionPerformed()
5671 // TODO no longer a menu action - refactor as required
5672 final AlignmentI alignment = getViewport().getAlignment();
5673 List<AlignedCodonFrame> mappings = alignment.getCodonFrames();
5674 if (mappings == null)
5678 List<SequenceI> cdnaSeqs = new ArrayList<>();
5679 for (SequenceI aaSeq : alignment.getSequences())
5681 for (AlignedCodonFrame acf : mappings)
5683 SequenceI dnaSeq = acf.getDnaForAaSeq(aaSeq.getDatasetSequence());
5687 * There is a cDNA mapping for this protein sequence - add to new
5688 * alignment. It will share the same dataset sequence as other mapped
5689 * cDNA (no new mappings need to be created).
5691 final Sequence newSeq = new Sequence(dnaSeq);
5692 newSeq.setDatasetSequence(dnaSeq);
5693 cdnaSeqs.add(newSeq);
5697 if (cdnaSeqs.size() == 0)
5699 // show a warning dialog no mapped cDNA
5702 AlignmentI cdna = new Alignment(
5703 cdnaSeqs.toArray(new SequenceI[cdnaSeqs.size()]));
5704 GAlignFrame alignFrame = new AlignFrame(cdna, AlignFrame.DEFAULT_WIDTH,
5705 AlignFrame.DEFAULT_HEIGHT);
5706 cdna.alignAs(alignment);
5707 String newtitle = "cDNA " + MessageManager.getString("label.for") + " "
5709 Desktop.addInternalFrame(alignFrame, newtitle, AlignFrame.DEFAULT_WIDTH,
5710 AlignFrame.DEFAULT_HEIGHT);
5714 * Set visibility of dna/protein complement view (available when shown in a
5720 protected void showComplement_actionPerformed(boolean show)
5722 SplitContainerI sf = getSplitViewContainer();
5725 sf.setComplementVisible(this, show);
5730 * Generate the reverse (optionally complemented) of the selected sequences,
5731 * and add them to the alignment
5734 protected void showReverse_actionPerformed(boolean complement)
5736 AlignmentI al = null;
5739 Dna dna = new Dna(viewport, viewport.getViewAsVisibleContigs(true));
5740 al = dna.reverseCdna(complement);
5741 viewport.addAlignment(al, "");
5742 addHistoryItem(new EditCommand(
5743 MessageManager.getString("label.add_sequences"), Action.PASTE,
5744 al.getSequencesArray(), 0, al.getWidth(),
5745 viewport.getAlignment()));
5746 } catch (Exception ex)
5748 System.err.println(ex.getMessage());
5754 * Try to run a script in the Groovy console, having first ensured that this
5755 * AlignFrame is set as currentAlignFrame in Desktop, to allow the script to
5756 * be targeted at this alignment.
5759 protected void runGroovy_actionPerformed()
5761 Jalview.setCurrentAlignFrame(this);
5762 groovy.ui.Console console = Desktop.getGroovyConsole();
5763 if (console != null)
5767 console.runScript();
5768 } catch (Exception ex)
5770 System.err.println((ex.toString()));
5771 JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
5772 MessageManager.getString("label.couldnt_run_groovy_script"),
5773 MessageManager.getString("label.groovy_support_failed"),
5774 JvOptionPane.ERROR_MESSAGE);
5779 System.err.println("Can't run Groovy script as console not found");
5784 * Hides columns containing (or not containing) a specified feature, provided
5785 * that would not leave all columns hidden
5787 * @param featureType
5788 * @param columnsContaining
5791 public boolean hideFeatureColumns(String featureType,
5792 boolean columnsContaining)
5794 boolean notForHiding = avc.markColumnsContainingFeatures(
5795 columnsContaining, false, false, featureType);
5798 if (avc.markColumnsContainingFeatures(!columnsContaining, false,
5799 false, featureType))
5801 getViewport().hideSelectedColumns();
5809 protected void selectHighlightedColumns_actionPerformed(
5810 ActionEvent actionEvent)
5812 // include key modifier check in case user selects from menu
5813 avc.markHighlightedColumns(
5814 (actionEvent.getModifiers() & ActionEvent.ALT_MASK) != 0, true,
5815 (actionEvent.getModifiers() & (ActionEvent.META_MASK
5816 | ActionEvent.CTRL_MASK)) != 0);
5820 * Rebuilds the Colour menu, including any user-defined colours which have
5821 * been loaded either on startup or during the session
5823 public void buildColourMenu()
5825 colourMenu.removeAll();
5827 colourMenu.add(applyToAllGroups);
5828 colourMenu.add(textColour);
5829 colourMenu.addSeparator();
5831 ButtonGroup bg = ColourMenuHelper.addMenuItems(colourMenu, this,
5832 viewport.getAlignment(), false);
5834 colourMenu.add(annotationColour);
5835 bg.add(annotationColour);
5836 colourMenu.addSeparator();
5837 colourMenu.add(conservationMenuItem);
5838 colourMenu.add(modifyConservation);
5839 colourMenu.add(abovePIDThreshold);
5840 colourMenu.add(modifyPID);
5842 ColourSchemeI colourScheme = viewport.getGlobalColourScheme();
5843 ColourMenuHelper.setColourSelected(colourMenu, colourScheme);
5847 * Open a dialog (if not already open) that allows the user to select and
5848 * calculate PCA or Tree analysis
5850 protected void openTreePcaDialog()
5852 if (alignPanel.getCalculationDialog() == null)
5854 new CalculationChooser(AlignFrame.this);
5859 protected void loadVcf_actionPerformed()
5861 JalviewFileChooser chooser = new JalviewFileChooser(
5862 Cache.getProperty("LAST_DIRECTORY"));
5863 chooser.setFileView(new JalviewFileView());
5864 chooser.setDialogTitle(MessageManager.getString("label.load_vcf_file"));
5865 chooser.setToolTipText(MessageManager.getString("label.load_vcf_file"));
5866 final AlignFrame us = this;
5867 chooser.setResponseHandler(0, new Runnable()
5872 String choice = chooser.getSelectedFile().getPath();
5873 Cache.setProperty("LAST_DIRECTORY", choice);
5874 SequenceI[] seqs = viewport.getAlignment().getSequencesArray();
5875 new VCFLoader(choice).loadVCF(seqs, us);
5878 chooser.showOpenDialog(null);
5882 private Rectangle lastFeatureSettingsBounds = null;
5885 public void setFeatureSettingsGeometry(Rectangle bounds)
5887 lastFeatureSettingsBounds = bounds;
5891 public Rectangle getFeatureSettingsGeometry()
5893 return lastFeatureSettingsBounds;
5896 public void scrollTo(int row, int column)
5898 alignPanel.getSeqPanel().scrollTo(row, column);
5901 public void scrollToRow(int row)
5903 alignPanel.getSeqPanel().scrollToRow(row);
5906 public void scrollToColumn(int column)
5908 alignPanel.getSeqPanel().scrollToColumn(column);
5912 * BH 2019 from JalviewLite
5914 * get sequence feature groups that are hidden or shown
5920 public String[] getFeatureGroupsOfState(boolean visible)
5922 jalview.api.FeatureRenderer fr = null;
5923 if (alignPanel != null
5924 && (fr = alignPanel.getFeatureRenderer()) != null)
5926 List<String> gps = fr.getGroups(visible);
5927 String[] _gps = gps.toArray(new String[gps.size()]);
5935 * @return list of feature groups on the view
5937 public String[] getFeatureGroups()
5939 jalview.api.FeatureRenderer fr = null;
5940 if (alignPanel != null
5941 && (fr = alignPanel.getFeatureRenderer()) != null)
5943 List<String> gps = fr.getFeatureGroups();
5944 String[] _gps = gps.toArray(new String[gps.size()]);
5950 public void select(SequenceGroup sel, ColumnSelection csel,
5951 HiddenColumns hidden)
5953 alignPanel.getSeqPanel().selection(sel, csel, hidden, null);
5958 class PrintThread extends Thread
5962 public PrintThread(AlignmentPanel ap)
5967 static PageFormat pf;
5972 PrinterJob printJob = PrinterJob.getPrinterJob();
5976 printJob.setPrintable(ap, pf);
5980 printJob.setPrintable(ap);
5983 if (printJob.printDialog())
5988 } catch (Exception PrintException)
5990 PrintException.printStackTrace();