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.Rectangle;
27 import java.awt.Toolkit;
28 import java.awt.datatransfer.Clipboard;
29 import java.awt.datatransfer.DataFlavor;
30 import java.awt.datatransfer.StringSelection;
31 import java.awt.datatransfer.Transferable;
32 import java.awt.dnd.DnDConstants;
33 import java.awt.dnd.DropTargetDragEvent;
34 import java.awt.dnd.DropTargetDropEvent;
35 import java.awt.dnd.DropTargetEvent;
36 import java.awt.dnd.DropTargetListener;
37 import java.awt.event.ActionEvent;
38 import java.awt.event.ActionListener;
39 import java.awt.event.FocusAdapter;
40 import java.awt.event.FocusEvent;
41 import java.awt.event.ItemEvent;
42 import java.awt.event.ItemListener;
43 import java.awt.event.KeyAdapter;
44 import java.awt.event.KeyEvent;
45 import java.awt.event.MouseEvent;
46 import java.awt.print.PageFormat;
47 import java.awt.print.PrinterJob;
48 import java.beans.PropertyChangeEvent;
50 import java.io.FileWriter;
51 import java.io.IOException;
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.Locale;
61 import java.util.Vector;
62 import java.util.concurrent.Callable;
64 import javax.swing.ButtonGroup;
65 import javax.swing.JCheckBoxMenuItem;
66 import javax.swing.JComponent;
67 import javax.swing.JEditorPane;
68 import javax.swing.JInternalFrame;
69 import javax.swing.JLabel;
70 import javax.swing.JLayeredPane;
71 import javax.swing.JMenu;
72 import javax.swing.JMenuItem;
73 import javax.swing.JPanel;
74 import javax.swing.JScrollPane;
75 import javax.swing.SwingUtilities;
77 import ext.vamsas.ServiceHandle;
78 import jalview.analysis.AlignmentSorter;
79 import jalview.analysis.AlignmentUtils;
80 import jalview.analysis.CrossRef;
81 import jalview.analysis.Dna;
82 import jalview.analysis.GeneticCodeI;
83 import jalview.analysis.ParseProperties;
84 import jalview.analysis.SequenceIdMatcher;
85 import jalview.api.AlignExportSettingsI;
86 import jalview.api.AlignViewControllerGuiI;
87 import jalview.api.AlignViewControllerI;
88 import jalview.api.AlignViewportI;
89 import jalview.api.AlignmentViewPanel;
90 import jalview.api.FeatureSettingsControllerI;
91 import jalview.api.FeatureSettingsModelI;
92 import jalview.api.SplitContainerI;
93 import jalview.api.ViewStyleI;
94 import jalview.api.analysis.SimilarityParamsI;
95 import jalview.bin.Cache;
96 import jalview.bin.Console;
97 import jalview.bin.Jalview;
98 import jalview.commands.CommandI;
99 import jalview.commands.EditCommand;
100 import jalview.commands.EditCommand.Action;
101 import jalview.commands.OrderCommand;
102 import jalview.commands.RemoveGapColCommand;
103 import jalview.commands.RemoveGapsCommand;
104 import jalview.commands.SlideSequencesCommand;
105 import jalview.commands.TrimRegionCommand;
106 import jalview.datamodel.AlignExportSettingsAdapter;
107 import jalview.datamodel.AlignedCodonFrame;
108 import jalview.datamodel.Alignment;
109 import jalview.datamodel.AlignmentAnnotation;
110 import jalview.datamodel.AlignmentExportData;
111 import jalview.datamodel.AlignmentI;
112 import jalview.datamodel.AlignmentOrder;
113 import jalview.datamodel.AlignmentView;
114 import jalview.datamodel.ColumnSelection;
115 import jalview.datamodel.HiddenColumns;
116 import jalview.datamodel.PDBEntry;
117 import jalview.datamodel.SeqCigar;
118 import jalview.datamodel.Sequence;
119 import jalview.datamodel.SequenceGroup;
120 import jalview.datamodel.SequenceI;
121 import jalview.gui.ColourMenuHelper.ColourChangeListener;
122 import jalview.gui.ViewSelectionMenu.ViewSetProvider;
123 import jalview.io.AlignmentProperties;
124 import jalview.io.AnnotationFile;
125 import jalview.io.BackupFiles;
126 import jalview.io.BioJsHTMLOutput;
127 import jalview.io.DataSourceType;
128 import jalview.io.FileFormat;
129 import jalview.io.FileFormatI;
130 import jalview.io.FileFormats;
131 import jalview.io.FileLoader;
132 import jalview.io.FileParse;
133 import jalview.io.FormatAdapter;
134 import jalview.io.HtmlSvgOutput;
135 import jalview.io.IdentifyFile;
136 import jalview.io.JPredFile;
137 import jalview.io.JalviewFileChooser;
138 import jalview.io.JalviewFileView;
139 import jalview.io.JnetAnnotationMaker;
140 import jalview.io.NewickFile;
141 import jalview.io.ScoreMatrixFile;
142 import jalview.io.TCoffeeScoreFile;
143 import jalview.io.vcf.VCFLoader;
144 import jalview.jbgui.GAlignFrame;
145 import jalview.project.Jalview2XML;
146 import jalview.schemes.ColourSchemeI;
147 import jalview.schemes.ColourSchemes;
148 import jalview.schemes.ResidueColourScheme;
149 import jalview.schemes.TCoffeeColourScheme;
150 import jalview.util.HttpUtils;
151 import jalview.util.ImageMaker.TYPE;
152 import jalview.util.MessageManager;
153 import jalview.util.Platform;
154 import jalview.viewmodel.AlignmentViewport;
155 import jalview.viewmodel.ViewportRanges;
156 import jalview.ws.DBRefFetcher;
157 import jalview.ws.DBRefFetcher.FetchFinishedListenerI;
158 import jalview.ws.jws1.Discoverer;
159 import jalview.ws.jws2.Jws2Discoverer;
160 import jalview.ws.jws2.jabaws2.Jws2Instance;
161 import jalview.ws.seqfetcher.DbSourceProxy;
167 * @version $Revision$
169 @SuppressWarnings("serial")
170 public class AlignFrame extends GAlignFrame implements DropTargetListener,
171 IProgressIndicator, AlignViewControllerGuiI, ColourChangeListener
174 public static final int DEFAULT_WIDTH = 700;
176 public static final int DEFAULT_HEIGHT = 500;
179 * The currently displayed panel (selected tabbed view if more than one)
181 public AlignmentPanel alignPanel;
183 AlignViewport viewport;
185 public AlignViewControllerI avc;
187 List<AlignmentPanel> alignPanels = new ArrayList<>();
190 * Last format used to load or save alignments in this window
192 FileFormatI currentFileFormat = null;
195 * Current filename for this alignment
197 String fileName = null;
202 * Creates a new AlignFrame object with specific width and height.
208 public AlignFrame(AlignmentI al, int width, int height)
210 this(al, null, width, height);
214 * Creates a new AlignFrame object with specific width, height and
220 * @param sequenceSetId
222 public AlignFrame(AlignmentI al, int width, int height,
223 String sequenceSetId)
225 this(al, null, width, height, sequenceSetId);
229 * Creates a new AlignFrame object with specific width, height and
235 * @param sequenceSetId
238 public AlignFrame(AlignmentI al, int width, int height,
239 String sequenceSetId, String viewId)
241 this(al, null, width, height, sequenceSetId, viewId);
245 * new alignment window with hidden columns
249 * @param hiddenColumns
250 * ColumnSelection or null
252 * Width of alignment frame
256 public AlignFrame(AlignmentI al, HiddenColumns hiddenColumns, int width,
259 this(al, hiddenColumns, width, height, null);
263 * Create alignment frame for al with hiddenColumns, a specific width and
264 * height, and specific sequenceId
267 * @param hiddenColumns
270 * @param sequenceSetId
273 public AlignFrame(AlignmentI al, HiddenColumns hiddenColumns, int width,
274 int height, String sequenceSetId)
276 this(al, hiddenColumns, width, height, sequenceSetId, null);
280 * Create alignment frame for al with hiddenColumns, a specific width and
281 * height, and specific sequenceId
284 * @param hiddenColumns
287 * @param sequenceSetId
292 public AlignFrame(AlignmentI al, HiddenColumns hiddenColumns, int width,
293 int height, String sequenceSetId, String viewId)
295 setSize(width, height);
297 if (al.getDataset() == null)
302 viewport = new AlignViewport(al, hiddenColumns, sequenceSetId, viewId);
304 alignPanel = new AlignmentPanel(this, viewport);
306 addAlignmentPanel(alignPanel, true);
310 public AlignFrame(AlignmentI al, SequenceI[] hiddenSeqs,
311 HiddenColumns hiddenColumns, int width, int height)
313 setSize(width, height);
315 if (al.getDataset() == null)
320 viewport = new AlignViewport(al, hiddenColumns);
322 if (hiddenSeqs != null && hiddenSeqs.length > 0)
324 viewport.hideSequence(hiddenSeqs);
326 alignPanel = new AlignmentPanel(this, viewport);
327 addAlignmentPanel(alignPanel, true);
332 * Make a new AlignFrame from existing alignmentPanels
339 public AlignFrame(AlignmentPanel ap)
343 addAlignmentPanel(ap, false);
348 * initalise the alignframe from the underlying viewport data and the
355 // setBackground(Color.white); // BH 2019
357 if (!Jalview.isHeadlessMode())
359 progressBar = new ProgressBar(this.statusPanel, this.statusBar);
362 avc = new jalview.controller.AlignViewController(this, viewport,
364 if (viewport.getAlignmentConservationAnnotation() == null)
366 // BLOSUM62Colour.setEnabled(false);
367 conservationMenuItem.setEnabled(false);
368 modifyConservation.setEnabled(false);
369 // PIDColour.setEnabled(false);
370 // abovePIDThreshold.setEnabled(false);
371 // modifyPID.setEnabled(false);
374 String sortby = Cache.getDefault("SORT_ALIGNMENT", "No sort");
376 if (sortby.equals("Id"))
378 sortIDMenuItem_actionPerformed(null);
380 else if (sortby.equals("Pairwise Identity"))
382 sortPairwiseMenuItem_actionPerformed(null);
386 .setShowAutocalculatedAbove(isShowAutoCalculatedAbove());
388 setMenusFromViewport(viewport);
389 buildSortByAnnotationScoresMenu();
390 calculateTree.addActionListener(new ActionListener()
394 public void actionPerformed(ActionEvent e)
401 if (Desktop.desktop != null)
403 this.setDropTarget(new java.awt.dnd.DropTarget(this, this));
404 if (!Platform.isJS())
406 addServiceListeners();
411 if (viewport.getWrapAlignment())
413 wrapMenuItem_actionPerformed(null);
416 if (Cache.getDefault("SHOW_OVERVIEW", false))
418 this.overviewMenuItem_actionPerformed(null);
423 final List<AlignmentViewPanel> selviews = new ArrayList<>();
424 final List<AlignmentPanel> origview = new ArrayList<>();
425 final String menuLabel = MessageManager
426 .getString("label.copy_format_from");
427 ViewSelectionMenu vsel = new ViewSelectionMenu(menuLabel,
428 new ViewSetProvider()
432 public AlignmentPanel[] getAllAlignmentPanels()
435 origview.add(alignPanel);
436 // make an array of all alignment panels except for this one
437 List<AlignmentPanel> aps = new ArrayList<>(
438 Arrays.asList(Desktop.getAlignmentPanels(null)));
439 aps.remove(AlignFrame.this.alignPanel);
440 return aps.toArray(new AlignmentPanel[aps.size()]);
442 }, selviews, new ItemListener()
446 public void itemStateChanged(ItemEvent e)
448 if (origview.size() > 0)
450 final AlignmentPanel ap = origview.get(0);
453 * Copy the ViewStyle of the selected panel to 'this one'.
454 * Don't change value of 'scaleProteinAsCdna' unless copying
457 ViewStyleI vs = selviews.get(0).getAlignViewport()
459 boolean fromSplitFrame = selviews.get(0)
460 .getAlignViewport().getCodingComplement() != null;
463 vs.setScaleProteinAsCdna(ap.getAlignViewport()
464 .getViewStyle().isScaleProteinAsCdna());
466 ap.getAlignViewport().setViewStyle(vs);
469 * Also rescale ViewStyle of SplitFrame complement if there is
470 * one _and_ it is set to 'scaledProteinAsCdna'; we don't copy
471 * the whole ViewStyle (allow cDNA protein to have different
474 AlignViewportI complement = ap.getAlignViewport()
475 .getCodingComplement();
476 if (complement != null && vs.isScaleProteinAsCdna())
478 AlignFrame af = Desktop.getAlignFrameFor(complement);
479 ((SplitFrame) af.getSplitViewContainer())
481 af.setMenusForViewport();
485 ap.setSelected(true);
486 ap.alignFrame.setMenusForViewport();
491 if (Cache.getDefault("VERSION", "DEVELOPMENT").toLowerCase(Locale.ROOT)
492 .indexOf("devel") > -1
493 || Cache.getDefault("VERSION", "DEVELOPMENT")
494 .toLowerCase(Locale.ROOT).indexOf("test") > -1)
496 formatMenu.add(vsel);
498 addFocusListener(new FocusAdapter()
501 public void focusGained(FocusEvent e)
503 Jalview.setCurrentAlignFrame(AlignFrame.this);
510 * Change the filename and format for the alignment, and enable the 'reload'
511 * button functionality.
518 public void setFileName(String file, FileFormatI format)
521 setFileFormat(format);
522 reload.setEnabled(true);
526 * JavaScript will have this, maybe others. More dependable than a file name
527 * and maintains a reference to the actual bytes loaded.
531 public void setFileObject(File file)
533 this.fileObject = file;
537 * Add a KeyListener with handlers for various KeyPressed and KeyReleased
540 void addKeyListener()
542 addKeyListener(new KeyAdapter()
545 public void keyPressed(KeyEvent evt)
547 if (viewport.cursorMode
548 && ((evt.getKeyCode() >= KeyEvent.VK_0
549 && evt.getKeyCode() <= KeyEvent.VK_9)
550 || (evt.getKeyCode() >= KeyEvent.VK_NUMPAD0
551 && evt.getKeyCode() <= KeyEvent.VK_NUMPAD9))
552 && Character.isDigit(evt.getKeyChar()))
554 alignPanel.getSeqPanel().numberPressed(evt.getKeyChar());
557 switch (evt.getKeyCode())
560 case 27: // escape key
561 deselectAllSequenceMenuItem_actionPerformed(null);
565 case KeyEvent.VK_DOWN:
566 if (evt.isAltDown() || !viewport.cursorMode)
568 moveSelectedSequences(false);
570 if (viewport.cursorMode)
572 alignPanel.getSeqPanel().moveCursor(0, 1, evt.isShiftDown());
577 if (evt.isAltDown() || !viewport.cursorMode)
579 moveSelectedSequences(true);
581 if (viewport.cursorMode)
583 alignPanel.getSeqPanel().moveCursor(0, -1, evt.isShiftDown());
588 case KeyEvent.VK_LEFT:
589 if (evt.isAltDown() || !viewport.cursorMode)
591 slideSequences(false,
592 alignPanel.getSeqPanel().getKeyboardNo1());
596 alignPanel.getSeqPanel().moveCursor(-1, 0, evt.isShiftDown());
601 case KeyEvent.VK_RIGHT:
602 if (evt.isAltDown() || !viewport.cursorMode)
604 slideSequences(true, alignPanel.getSeqPanel().getKeyboardNo1());
608 alignPanel.getSeqPanel().moveCursor(1, 0, evt.isShiftDown());
612 case KeyEvent.VK_SPACE:
613 if (viewport.cursorMode)
615 alignPanel.getSeqPanel().insertGapAtCursor(evt.isControlDown()
616 || evt.isShiftDown() || evt.isAltDown());
620 // case KeyEvent.VK_A:
621 // if (viewport.cursorMode)
623 // alignPanel.seqPanel.insertNucAtCursor(false,"A");
624 // //System.out.println("A");
628 * case KeyEvent.VK_CLOSE_BRACKET: if (viewport.cursorMode) {
629 * System.out.println("closing bracket"); } break;
631 case KeyEvent.VK_DELETE:
632 case KeyEvent.VK_BACK_SPACE:
633 if (!viewport.cursorMode)
635 cut_actionPerformed();
639 alignPanel.getSeqPanel().deleteGapAtCursor(evt.isControlDown()
640 || evt.isShiftDown() || evt.isAltDown());
646 if (viewport.cursorMode)
648 alignPanel.getSeqPanel().setCursorRow();
652 if (viewport.cursorMode && !evt.isControlDown())
654 alignPanel.getSeqPanel().setCursorColumn();
658 if (viewport.cursorMode)
660 alignPanel.getSeqPanel().setCursorPosition();
664 case KeyEvent.VK_ENTER:
665 case KeyEvent.VK_COMMA:
666 if (viewport.cursorMode)
668 alignPanel.getSeqPanel().setCursorRowAndColumn();
673 if (viewport.cursorMode)
675 alignPanel.getSeqPanel().setSelectionAreaAtCursor(true);
679 if (viewport.cursorMode)
681 alignPanel.getSeqPanel().setSelectionAreaAtCursor(false);
686 viewport.cursorMode = !viewport.cursorMode;
687 setStatus(MessageManager
688 .formatMessage("label.keyboard_editing_mode", new String[]
689 { (viewport.cursorMode ? "on" : "off") }));
690 if (viewport.cursorMode)
692 ViewportRanges ranges = viewport.getRanges();
693 alignPanel.getSeqPanel().seqCanvas.cursorX = ranges
695 alignPanel.getSeqPanel().seqCanvas.cursorY = ranges
698 alignPanel.getSeqPanel().seqCanvas.repaint();
704 Help.showHelpWindow();
705 } catch (Exception ex)
707 ex.printStackTrace();
712 boolean toggleSeqs = !evt.isControlDown();
713 boolean toggleCols = !evt.isShiftDown();
714 toggleHiddenRegions(toggleSeqs, toggleCols);
719 boolean toggleSel = evt.isControlDown() || evt.isMetaDown();
720 boolean modifyExisting = true; // always modify, don't clear
721 // evt.isShiftDown();
722 boolean invertHighlighted = evt.isAltDown();
723 avc.markHighlightedColumns(invertHighlighted, modifyExisting,
727 case KeyEvent.VK_PAGE_UP:
728 viewport.getRanges().pageUp();
730 case KeyEvent.VK_PAGE_DOWN:
731 viewport.getRanges().pageDown();
737 public void keyReleased(KeyEvent evt)
739 switch (evt.getKeyCode())
741 case KeyEvent.VK_LEFT:
742 if (evt.isAltDown() || !viewport.cursorMode)
744 viewport.firePropertyChange("alignment", null,
745 viewport.getAlignment().getSequences());
749 case KeyEvent.VK_RIGHT:
750 if (evt.isAltDown() || !viewport.cursorMode)
752 viewport.firePropertyChange("alignment", null,
753 viewport.getAlignment().getSequences());
761 public void addAlignmentPanel(final AlignmentPanel ap, boolean newPanel)
763 ap.alignFrame = this;
764 avc = new jalview.controller.AlignViewController(this, viewport,
769 PaintRefresher.Register(ap, ap.av.getSequenceSetId());
771 int aSize = alignPanels.size();
773 tabbedPane.setVisible(aSize > 1 || ap.av.getViewName() != null);
775 if (aSize == 1 && ap.av.getViewName() == null)
777 this.getContentPane().add(ap, BorderLayout.CENTER);
783 setInitialTabVisible();
786 expandViews.setEnabled(true);
787 gatherViews.setEnabled(true);
788 tabbedPane.addTab(ap.av.getViewName(), ap);
790 ap.setVisible(false);
795 if (ap.av.isPadGaps())
797 ap.av.getAlignment().padGaps();
799 ap.av.updateConservation(ap);
800 ap.av.updateConsensus(ap);
801 ap.av.updateStrucConsensus(ap);
805 public void setInitialTabVisible()
807 expandViews.setEnabled(true);
808 gatherViews.setEnabled(true);
809 tabbedPane.setVisible(true);
810 AlignmentPanel first = alignPanels.get(0);
811 tabbedPane.addTab(first.av.getViewName(), first);
812 this.getContentPane().add(tabbedPane, BorderLayout.CENTER);
815 public AlignViewport getViewport()
820 /* Set up intrinsic listeners for dynamically generated GUI bits. */
821 private void addServiceListeners()
823 final java.beans.PropertyChangeListener thisListener;
824 Desktop.instance.addJalviewPropertyChangeListener("services",
825 thisListener = new java.beans.PropertyChangeListener()
828 public void propertyChange(PropertyChangeEvent evt)
830 // // System.out.println("Discoverer property change.");
831 // if (evt.getPropertyName().equals("services"))
833 SwingUtilities.invokeLater(new Runnable()
840 "Rebuild WS Menu for service change");
841 BuildWebServiceMenu();
848 addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
851 public void internalFrameClosed(
852 javax.swing.event.InternalFrameEvent evt)
854 // System.out.println("deregistering discoverer listener");
855 Desktop.instance.removeJalviewPropertyChangeListener("services",
857 closeMenuItem_actionPerformed(true);
860 // Finally, build the menu once to get current service state
861 new Thread(new Runnable()
866 BuildWebServiceMenu();
872 * Configure menu items that vary according to whether the alignment is
873 * nucleotide or protein
875 public void setGUINucleotide()
877 AlignmentI al = getViewport().getAlignment();
878 boolean nucleotide = al.isNucleotide();
880 loadVcf.setVisible(nucleotide);
881 showTranslation.setVisible(nucleotide);
882 showReverse.setVisible(nucleotide);
883 showReverseComplement.setVisible(nucleotide);
884 conservationMenuItem.setEnabled(!nucleotide);
886 .setEnabled(!nucleotide && conservationMenuItem.isSelected());
887 showGroupConservation.setEnabled(!nucleotide);
889 showComplementMenuItem
890 .setText(nucleotide ? MessageManager.getString("label.protein")
891 : MessageManager.getString("label.nucleotide"));
895 * set up menus for the current viewport. This may be called after any
896 * operation that affects the data in the current view (selection changed,
897 * etc) to update the menus to reflect the new state.
900 public void setMenusForViewport()
902 setMenusFromViewport(viewport);
906 * Need to call this method when tabs are selected for multiple views, or when
907 * loading from Jalview2XML.java
912 public void setMenusFromViewport(AlignViewport av)
914 padGapsMenuitem.setSelected(av.isPadGaps());
915 colourTextMenuItem.setSelected(av.isShowColourText());
916 abovePIDThreshold.setSelected(av.getAbovePIDThreshold());
917 modifyPID.setEnabled(abovePIDThreshold.isSelected());
918 conservationMenuItem.setSelected(av.getConservationSelected());
919 modifyConservation.setEnabled(conservationMenuItem.isSelected());
920 seqLimits.setSelected(av.getShowJVSuffix());
921 idRightAlign.setSelected(av.isRightAlignIds());
922 centreColumnLabelsMenuItem.setState(av.isCentreColumnLabels());
923 renderGapsMenuItem.setSelected(av.isRenderGaps());
924 wrapMenuItem.setSelected(av.getWrapAlignment());
925 scaleAbove.setVisible(av.getWrapAlignment());
926 scaleLeft.setVisible(av.getWrapAlignment());
927 scaleRight.setVisible(av.getWrapAlignment());
928 annotationPanelMenuItem.setState(av.isShowAnnotation());
930 * Show/hide annotations only enabled if annotation panel is shown
932 showAllSeqAnnotations.setEnabled(annotationPanelMenuItem.getState());
933 hideAllSeqAnnotations.setEnabled(annotationPanelMenuItem.getState());
934 showAllAlAnnotations.setEnabled(annotationPanelMenuItem.getState());
935 hideAllAlAnnotations.setEnabled(annotationPanelMenuItem.getState());
936 viewBoxesMenuItem.setSelected(av.getShowBoxes());
937 viewTextMenuItem.setSelected(av.getShowText());
938 showNonconservedMenuItem.setSelected(av.getShowUnconserved());
939 showGroupConsensus.setSelected(av.isShowGroupConsensus());
940 showGroupConservation.setSelected(av.isShowGroupConservation());
941 showConsensusHistogram.setSelected(av.isShowConsensusHistogram());
942 showSequenceLogo.setSelected(av.isShowSequenceLogo());
943 normaliseSequenceLogo.setSelected(av.isNormaliseSequenceLogo());
945 ColourMenuHelper.setColourSelected(colourMenu,
946 av.getGlobalColourScheme());
948 showSeqFeatures.setSelected(av.isShowSequenceFeatures());
949 hiddenMarkers.setState(av.getShowHiddenMarkers());
950 applyToAllGroups.setState(av.getColourAppliesToAllGroups());
951 showNpFeatsMenuitem.setSelected(av.isShowNPFeats());
952 showDbRefsMenuitem.setSelected(av.isShowDBRefs());
953 autoCalculate.setSelected(av.autoCalculateConsensus);
954 sortByTree.setSelected(av.sortByTree);
955 listenToViewSelections.setSelected(av.followSelection);
957 showProducts.setEnabled(canShowProducts());
958 setGroovyEnabled(Desktop.getGroovyConsole() != null);
964 * Set the enabled state of the 'Run Groovy' option in the Calculate menu
968 public void setGroovyEnabled(boolean b)
970 runGroovy.setEnabled(b);
973 private IProgressIndicator progressBar;
978 * @see jalview.gui.IProgressIndicator#setProgressBar(java.lang.String, long)
981 public void setProgressBar(String message, long id)
983 progressBar.setProgressBar(message, id);
987 public void registerHandler(final long id,
988 final IProgressIndicatorHandler handler)
990 progressBar.registerHandler(id, handler);
995 * @return true if any progress bars are still active
998 public boolean operationInProgress()
1000 return progressBar.operationInProgress();
1004 * Sets the text of the status bar. Note that setting a null or empty value
1005 * will cause the status bar to be hidden, with possibly undesirable flicker
1006 * of the screen layout.
1009 public void setStatus(String text)
1011 statusBar.setText(text == null || text.isEmpty() ? " " : text);
1015 * Added so Castor Mapping file can obtain Jalview Version
1017 public String getVersion()
1019 return Cache.getProperty("VERSION");
1022 public FeatureRenderer getFeatureRenderer()
1024 return alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer();
1028 public void fetchSequence_actionPerformed()
1030 new SequenceFetcher(this);
1034 public void addFromFile_actionPerformed(ActionEvent e)
1036 Desktop.instance.inputLocalFileMenuItem_actionPerformed(viewport);
1040 public void reload_actionPerformed(ActionEvent e)
1042 if (fileName != null)
1044 // TODO: JAL-1108 - ensure all associated frames are closed regardless of
1045 // originating file's format
1046 // TODO: work out how to recover feature settings for correct view(s) when
1047 // file is reloaded.
1048 if (FileFormat.Jalview.equals(currentFileFormat))
1050 JInternalFrame[] frames = Desktop.desktop.getAllFrames();
1051 for (int i = 0; i < frames.length; i++)
1053 if (frames[i] instanceof AlignFrame && frames[i] != this
1054 && ((AlignFrame) frames[i]).fileName != null
1055 && ((AlignFrame) frames[i]).fileName.equals(fileName))
1059 frames[i].setSelected(true);
1060 Desktop.instance.closeAssociatedWindows();
1061 } catch (java.beans.PropertyVetoException ex)
1067 Desktop.instance.closeAssociatedWindows();
1069 FileLoader loader = new FileLoader();
1070 DataSourceType protocol = HttpUtils.startsWithHttpOrHttps(fileName)
1071 ? DataSourceType.URL
1072 : DataSourceType.FILE;
1073 loader.LoadFile(viewport, fileName, protocol, currentFileFormat);
1077 Rectangle bounds = this.getBounds();
1079 FileLoader loader = new FileLoader();
1081 AlignFrame newframe = null;
1083 if (fileObject == null)
1086 DataSourceType protocol = HttpUtils.startsWithHttpOrHttps(
1087 fileName) ? DataSourceType.URL : DataSourceType.FILE;
1088 newframe = loader.LoadFileWaitTillLoaded(fileName, protocol,
1093 newframe = loader.LoadFileWaitTillLoaded(fileObject,
1094 DataSourceType.FILE, currentFileFormat);
1097 newframe.setBounds(bounds);
1098 if (featureSettings != null && featureSettings.isShowing())
1100 final Rectangle fspos = featureSettings.frame.getBounds();
1101 // TODO: need a 'show feature settings' function that takes bounds -
1102 // need to refactor Desktop.addFrame
1103 newframe.featureSettings_actionPerformed(null);
1104 final FeatureSettings nfs = newframe.featureSettings;
1105 SwingUtilities.invokeLater(new Runnable()
1110 nfs.frame.setBounds(fspos);
1113 this.featureSettings.close();
1114 this.featureSettings = null;
1116 this.closeMenuItem_actionPerformed(true);
1122 public void addFromText_actionPerformed(ActionEvent e)
1125 .inputTextboxMenuItem_actionPerformed(viewport.getAlignPanel());
1129 public void addFromURL_actionPerformed(ActionEvent e)
1131 Desktop.instance.inputURLMenuItem_actionPerformed(viewport);
1135 public void save_actionPerformed(ActionEvent e)
1137 if (fileName == null || (currentFileFormat == null)
1138 || HttpUtils.startsWithHttpOrHttps(fileName))
1140 saveAs_actionPerformed();
1144 saveAlignment(fileName, currentFileFormat);
1149 * Saves the alignment to a file with a name chosen by the user, if necessary
1150 * warning if a file would be overwritten
1153 public void saveAs_actionPerformed()
1155 String format = currentFileFormat == null ? null
1156 : currentFileFormat.getName();
1157 JalviewFileChooser chooser = JalviewFileChooser
1158 .forWrite(Cache.getProperty("LAST_DIRECTORY"), format);
1160 chooser.setFileView(new JalviewFileView());
1161 chooser.setDialogTitle(
1162 MessageManager.getString("label.save_alignment_to_file"));
1163 chooser.setToolTipText(MessageManager.getString("action.save"));
1165 int value = chooser.showSaveDialog(this);
1167 if (value != JalviewFileChooser.APPROVE_OPTION)
1171 currentFileFormat = chooser.getSelectedFormat();
1172 // todo is this (2005) test now obsolete - value is never null?
1173 while (currentFileFormat == null)
1175 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
1177 .getString("label.select_file_format_before_saving"),
1178 MessageManager.getString("label.file_format_not_specified"),
1179 JvOptionPane.WARNING_MESSAGE);
1180 currentFileFormat = chooser.getSelectedFormat();
1181 value = chooser.showSaveDialog(this);
1182 if (value != JalviewFileChooser.APPROVE_OPTION)
1188 fileName = chooser.getSelectedFile().getPath();
1190 Cache.setProperty("DEFAULT_FILE_FORMAT", currentFileFormat.getName());
1191 Cache.setProperty("LAST_DIRECTORY", fileName);
1192 saveAlignment(fileName, currentFileFormat);
1195 boolean lastSaveSuccessful = false;
1197 FileFormatI lastFormatSaved;
1199 String lastFilenameSaved;
1202 * Raise a dialog or status message for the last call to saveAlignment.
1204 * @return true if last call to saveAlignment(file, format) was successful.
1206 public boolean isSaveAlignmentSuccessful()
1209 if (!lastSaveSuccessful)
1211 if (!Platform.isHeadless())
1213 JvOptionPane.showInternalMessageDialog(this, MessageManager
1214 .formatMessage("label.couldnt_save_file", new Object[]
1215 { lastFilenameSaved }),
1216 MessageManager.getString("label.error_saving_file"),
1217 JvOptionPane.WARNING_MESSAGE);
1221 Console.error(MessageManager
1222 .formatMessage("label.couldnt_save_file", new Object[]
1223 { lastFilenameSaved }));
1229 setStatus(MessageManager.formatMessage(
1230 "label.successfully_saved_to_file_in_format", new Object[]
1231 { lastFilenameSaved, lastFormatSaved }));
1234 return lastSaveSuccessful;
1238 * Saves the alignment to the specified file path, in the specified format,
1239 * which may be an alignment format, or Jalview project format. If the
1240 * alignment has hidden regions, or the format is one capable of including
1241 * non-sequence data (features, annotations, groups), then the user may be
1242 * prompted to specify what to include in the output.
1247 public void saveAlignment(String file, FileFormatI format)
1249 lastSaveSuccessful = true;
1250 lastFilenameSaved = file;
1251 lastFormatSaved = format;
1253 if (FileFormat.Jalview.equals(format))
1255 String shortName = title;
1256 if (shortName.indexOf(File.separatorChar) > -1)
1258 shortName = shortName
1259 .substring(shortName.lastIndexOf(File.separatorChar) + 1);
1261 lastSaveSuccessful = new Jalview2XML().saveAlignment(this, file,
1264 Console.debug("lastSaveSuccessful=" + lastSaveSuccessful);
1265 if (lastSaveSuccessful)
1267 this.getViewport().setSavedUpToDate(true);
1270 statusBar.setText(MessageManager.formatMessage(
1271 "label.successfully_saved_to_file_in_format", new Object[]
1277 AlignExportSettingsI options = new AlignExportSettingsAdapter(false);
1278 Callable<Void> cancelAction = () -> {
1279 lastSaveSuccessful = false;
1282 Callable<Void> outputAction = () -> {
1283 // todo defer this to inside formatSequences (or later)
1284 AlignmentExportData exportData = viewport.getAlignExportData(options);
1285 String output = new FormatAdapter(alignPanel, options)
1286 .formatSequences(format, exportData.getAlignment(),
1287 exportData.getOmitHidden(),
1288 exportData.getStartEndPostions(),
1289 viewport.getAlignment().getHiddenColumns());
1292 lastSaveSuccessful = false;
1296 // create backupfiles object and get new temp filename destination
1297 boolean doBackup = BackupFiles.getEnabled();
1298 BackupFiles backupfiles = null;
1301 Console.trace("ALIGNFRAME making backupfiles object for " + file);
1302 backupfiles = new BackupFiles(file);
1306 String tempFilePath = doBackup ? backupfiles.getTempFilePath()
1308 Console.trace("ALIGNFRAME setting PrintWriter");
1309 PrintWriter out = new PrintWriter(new FileWriter(tempFilePath));
1311 if (backupfiles != null)
1313 Console.trace("ALIGNFRAME about to write to temp file "
1314 + backupfiles.getTempFilePath());
1318 Console.trace("ALIGNFRAME about to close file");
1320 Console.trace("ALIGNFRAME closed file");
1321 AlignFrame.this.setTitle(file);
1322 statusBar.setText(MessageManager.formatMessage(
1323 "label.successfully_saved_to_file_in_format", new Object[]
1324 { fileName, format.getName() }));
1325 lastSaveSuccessful = true;
1326 } catch (IOException e)
1328 lastSaveSuccessful = false;
1330 "ALIGNFRAME Something happened writing the temp file");
1331 Console.error(e.getMessage());
1332 Console.debug(Cache.getStackTraceString(e));
1333 } catch (Exception ex)
1335 lastSaveSuccessful = false;
1337 "ALIGNFRAME Something unexpected happened writing the temp file");
1338 Console.error(ex.getMessage());
1339 Console.debug(Cache.getStackTraceString(ex));
1344 backupfiles.setWriteSuccess(lastSaveSuccessful);
1345 Console.debug("ALIGNFRAME writing temp file was "
1346 + (lastSaveSuccessful ? "" : "NOT ") + "successful");
1347 // do the backup file roll and rename the temp file to actual file
1348 Console.trace("ALIGNFRAME about to rollBackupsAndRenameTempFile");
1349 lastSaveSuccessful = backupfiles.rollBackupsAndRenameTempFile();
1350 Console.debug("ALIGNFRAME performed rollBackupsAndRenameTempFile "
1351 + (lastSaveSuccessful ? "" : "un") + "successfully");
1354 Console.debug("lastSaveSuccessful=" + lastSaveSuccessful);
1355 if (lastSaveSuccessful)
1357 AlignFrame.this.getViewport().setSavedUpToDate(true);
1364 * show dialog with export options if applicable; else just do it
1366 if (AlignExportOptions.isNeeded(viewport, format))
1368 AlignExportOptions choices = new AlignExportOptions(
1369 alignPanel.getAlignViewport(), format, options);
1370 choices.setResponseAction(0, outputAction);
1371 choices.setResponseAction(1, cancelAction);
1372 choices.showDialog();
1378 outputAction.call();
1379 } catch (Exception e)
1381 // TODO Auto-generated catch block
1382 e.printStackTrace();
1388 * Outputs the alignment to textbox in the requested format, if necessary
1389 * first prompting the user for whether to include hidden regions or
1392 * @param fileFormatName
1395 protected void outputText_actionPerformed(String fileFormatName)
1397 FileFormatI fileFormat = FileFormats.getInstance()
1398 .forName(fileFormatName);
1399 AlignExportSettingsI options = new AlignExportSettingsAdapter(false);
1400 Callable<Void> outputAction = () -> {
1401 // todo defer this to inside formatSequences (or later)
1402 AlignmentExportData exportData = viewport.getAlignExportData(options);
1403 CutAndPasteTransfer cap = new CutAndPasteTransfer();
1404 cap.setForInput(null);
1407 FileFormatI format = fileFormat;
1408 cap.setText(new FormatAdapter(alignPanel, options).formatSequences(
1409 format, exportData.getAlignment(),
1410 exportData.getOmitHidden(),
1411 exportData.getStartEndPostions(),
1412 viewport.getAlignment().getHiddenColumns()));
1413 Desktop.addInternalFrame(cap, MessageManager.formatMessage(
1414 "label.alignment_output_command", new Object[]
1415 { fileFormat.getName() }), 600, 500);
1416 } catch (OutOfMemoryError oom)
1418 new OOMWarning("Outputting alignment as " + fileFormat.getName(),
1426 * show dialog with export options if applicable; else just do it
1428 if (AlignExportOptions.isNeeded(viewport, fileFormat))
1430 AlignExportOptions choices = new AlignExportOptions(
1431 alignPanel.getAlignViewport(), fileFormat, options);
1432 choices.setResponseAction(0, outputAction);
1433 choices.showDialog();
1439 outputAction.call();
1440 } catch (Exception e)
1442 e.printStackTrace();
1454 protected void htmlMenuItem_actionPerformed(ActionEvent e)
1456 HtmlSvgOutput htmlSVG = new HtmlSvgOutput(alignPanel);
1457 htmlSVG.exportHTML(null);
1461 public void bioJSMenuItem_actionPerformed(ActionEvent e)
1463 BioJsHTMLOutput bjs = new BioJsHTMLOutput(alignPanel);
1464 bjs.exportHTML(null);
1467 public void createImageMap(File file, String image)
1469 alignPanel.makePNGImageMap(file, image);
1473 * Creates a PNG image of the alignment and writes it to the given file. If
1474 * the file is null, the user is prompted to choose a file.
1479 public void createPNG(File f)
1481 alignPanel.makeAlignmentImage(TYPE.PNG, f);
1485 * Creates an EPS image of the alignment and writes it to the given file. If
1486 * the file is null, the user is prompted to choose a file.
1491 public void createEPS(File f)
1493 alignPanel.makeAlignmentImage(TYPE.EPS, f);
1497 * Creates an SVG image of the alignment and writes it to the given file. If
1498 * the file is null, the user is prompted to choose a file.
1503 public void createSVG(File f)
1505 alignPanel.makeAlignmentImage(TYPE.SVG, f);
1509 public void pageSetup_actionPerformed(ActionEvent e)
1511 PrinterJob printJob = PrinterJob.getPrinterJob();
1512 PrintThread.pf = printJob.pageDialog(printJob.defaultPage());
1522 public void printMenuItem_actionPerformed(ActionEvent e)
1524 // Putting in a thread avoids Swing painting problems
1525 PrintThread thread = new PrintThread(alignPanel);
1530 public void exportFeatures_actionPerformed(ActionEvent e)
1532 new AnnotationExporter(alignPanel).exportFeatures();
1536 public void exportAnnotations_actionPerformed(ActionEvent e)
1538 new AnnotationExporter(alignPanel).exportAnnotations();
1542 public void associatedData_actionPerformed(ActionEvent e)
1544 final JalviewFileChooser chooser = new JalviewFileChooser(
1545 Cache.getProperty("LAST_DIRECTORY"));
1546 chooser.setFileView(new JalviewFileView());
1547 String tooltip = MessageManager
1548 .getString("label.load_jalview_annotations");
1549 chooser.setDialogTitle(tooltip);
1550 chooser.setToolTipText(tooltip);
1551 chooser.setResponseHandler(0, () -> {
1552 String choice = chooser.getSelectedFile().getPath();
1553 Cache.setProperty("LAST_DIRECTORY", choice);
1554 loadJalviewDataFile(chooser.getSelectedFile(), null, null, null);
1558 chooser.showOpenDialog(this);
1562 * Close the current view or all views in the alignment frame. If the frame
1563 * only contains one view then the alignment will be removed from memory.
1565 * @param closeAllTabs
1568 public void closeMenuItem_actionPerformed(boolean closeAllTabs)
1570 if (alignPanels != null && alignPanels.size() < 2)
1572 closeAllTabs = true;
1577 if (alignPanels != null)
1581 if (this.isClosed())
1583 // really close all the windows - otherwise wait till
1584 // setClosed(true) is called
1585 for (int i = 0; i < alignPanels.size(); i++)
1587 AlignmentPanel ap = alignPanels.get(i);
1594 closeView(alignPanel);
1599 if (featureSettings != null && featureSettings.isOpen())
1601 featureSettings.close();
1602 featureSettings = null;
1605 * this will raise an INTERNAL_FRAME_CLOSED event and this method will
1606 * be called recursively, with the frame now in 'closed' state
1608 this.setClosed(true);
1610 } catch (Exception ex)
1612 ex.printStackTrace();
1617 * Close the specified panel and close up tabs appropriately.
1619 * @param panelToClose
1621 public void closeView(AlignmentPanel panelToClose)
1623 int index = tabbedPane.getSelectedIndex();
1624 int closedindex = tabbedPane.indexOfComponent(panelToClose);
1625 alignPanels.remove(panelToClose);
1626 panelToClose.closePanel();
1627 panelToClose = null;
1629 tabbedPane.removeTabAt(closedindex);
1630 tabbedPane.validate();
1632 if (index > closedindex || index == tabbedPane.getTabCount())
1634 // modify currently selected tab index if necessary.
1638 this.tabSelectionChanged(index);
1644 void updateEditMenuBar()
1647 if (viewport.getHistoryList().size() > 0)
1649 undoMenuItem.setEnabled(true);
1650 CommandI command = viewport.getHistoryList().peek();
1651 undoMenuItem.setText(MessageManager
1652 .formatMessage("label.undo_command", new Object[]
1653 { command.getDescription() }));
1657 undoMenuItem.setEnabled(false);
1658 undoMenuItem.setText(MessageManager.getString("action.undo"));
1661 if (viewport.getRedoList().size() > 0)
1663 redoMenuItem.setEnabled(true);
1665 CommandI command = viewport.getRedoList().peek();
1666 redoMenuItem.setText(MessageManager
1667 .formatMessage("label.redo_command", new Object[]
1668 { command.getDescription() }));
1672 redoMenuItem.setEnabled(false);
1673 redoMenuItem.setText(MessageManager.getString("action.redo"));
1678 public void addHistoryItem(CommandI command)
1680 if (command.getSize() > 0)
1682 viewport.addToHistoryList(command);
1683 viewport.clearRedoList();
1684 updateEditMenuBar();
1685 viewport.updateHiddenColumns();
1686 // viewport.hasHiddenColumns = (viewport.getColumnSelection() != null
1687 // && viewport.getColumnSelection().getHiddenColumns() != null &&
1688 // viewport.getColumnSelection()
1689 // .getHiddenColumns().size() > 0);
1695 * @return alignment objects for all views
1697 AlignmentI[] getViewAlignments()
1699 if (alignPanels != null)
1701 AlignmentI[] als = new AlignmentI[alignPanels.size()];
1703 for (AlignmentPanel ap : alignPanels)
1705 als[i++] = ap.av.getAlignment();
1709 if (viewport != null)
1711 return new AlignmentI[] { viewport.getAlignment() };
1723 protected void undoMenuItem_actionPerformed(ActionEvent e)
1725 if (viewport.getHistoryList().isEmpty())
1729 CommandI command = viewport.getHistoryList().pop();
1730 viewport.addToRedoList(command);
1731 command.undoCommand(getViewAlignments());
1733 AlignmentViewport originalSource = getOriginatingSource(command);
1734 updateEditMenuBar();
1736 if (originalSource != null)
1738 if (originalSource != viewport)
1741 "Implementation worry: mismatch of viewport origin for undo");
1743 originalSource.updateHiddenColumns();
1744 // originalSource.hasHiddenColumns = (viewport.getColumnSelection() !=
1746 // && viewport.getColumnSelection().getHiddenColumns() != null &&
1747 // viewport.getColumnSelection()
1748 // .getHiddenColumns().size() > 0);
1749 originalSource.firePropertyChange("alignment", null,
1750 originalSource.getAlignment().getSequences());
1761 protected void redoMenuItem_actionPerformed(ActionEvent e)
1763 if (viewport.getRedoList().size() < 1)
1768 CommandI command = viewport.getRedoList().pop();
1769 viewport.addToHistoryList(command);
1770 command.doCommand(getViewAlignments());
1772 AlignmentViewport originalSource = getOriginatingSource(command);
1773 updateEditMenuBar();
1775 if (originalSource != null)
1778 if (originalSource != viewport)
1781 "Implementation worry: mismatch of viewport origin for redo");
1783 originalSource.updateHiddenColumns();
1784 // originalSource.hasHiddenColumns = (viewport.getColumnSelection() !=
1786 // && viewport.getColumnSelection().getHiddenColumns() != null &&
1787 // viewport.getColumnSelection()
1788 // .getHiddenColumns().size() > 0);
1789 originalSource.firePropertyChange("alignment", null,
1790 originalSource.getAlignment().getSequences());
1794 AlignmentViewport getOriginatingSource(CommandI command)
1796 AlignmentViewport originalSource = null;
1797 // For sequence removal and addition, we need to fire
1798 // the property change event FROM the viewport where the
1799 // original alignment was altered
1800 AlignmentI al = null;
1801 if (command instanceof EditCommand)
1803 EditCommand editCommand = (EditCommand) command;
1804 al = editCommand.getAlignment();
1805 List<Component> comps = PaintRefresher.components
1806 .get(viewport.getSequenceSetId());
1808 for (Component comp : comps)
1810 if (comp instanceof AlignmentPanel)
1812 if (al == ((AlignmentPanel) comp).av.getAlignment())
1814 originalSource = ((AlignmentPanel) comp).av;
1821 if (originalSource == null)
1823 // The original view is closed, we must validate
1824 // the current view against the closed view first
1827 PaintRefresher.validateSequences(al, viewport.getAlignment());
1830 originalSource = viewport;
1833 return originalSource;
1837 * Calls AlignmentI.moveSelectedSequencesByOne with current sequence selection
1838 * or the sequence under cursor in keyboard mode
1843 public void moveSelectedSequences(boolean up)
1845 SequenceGroup sg = viewport.getSelectionGroup();
1849 if (viewport.cursorMode)
1851 sg = new SequenceGroup();
1852 sg.addSequence(viewport.getAlignment().getSequenceAt(
1853 alignPanel.getSeqPanel().seqCanvas.cursorY), false);
1861 if (sg.getSize() < 1)
1866 // TODO: JAL-3733 - add an event to the undo buffer for this !
1868 viewport.getAlignment().moveSelectedSequencesByOne(sg,
1869 viewport.getHiddenRepSequences(), up);
1870 alignPanel.paintAlignment(true, false);
1873 synchronized void slideSequences(boolean right, int size)
1875 List<SequenceI> sg = new ArrayList<>();
1876 if (viewport.cursorMode)
1878 sg.add(viewport.getAlignment()
1879 .getSequenceAt(alignPanel.getSeqPanel().seqCanvas.cursorY));
1881 else if (viewport.getSelectionGroup() != null
1882 && viewport.getSelectionGroup().getSize() != viewport
1883 .getAlignment().getHeight())
1885 sg = viewport.getSelectionGroup()
1886 .getSequences(viewport.getHiddenRepSequences());
1894 List<SequenceI> invertGroup = new ArrayList<>();
1896 for (SequenceI seq : viewport.getAlignment().getSequences())
1898 if (!sg.contains(seq))
1900 invertGroup.add(seq);
1904 SequenceI[] seqs1 = sg.toArray(new SequenceI[0]);
1906 SequenceI[] seqs2 = new SequenceI[invertGroup.size()];
1907 for (int i = 0; i < invertGroup.size(); i++)
1909 seqs2[i] = invertGroup.get(i);
1912 SlideSequencesCommand ssc;
1915 ssc = new SlideSequencesCommand("Slide Sequences", seqs2, seqs1, size,
1916 viewport.getGapCharacter());
1920 ssc = new SlideSequencesCommand("Slide Sequences", seqs1, seqs2, size,
1921 viewport.getGapCharacter());
1924 int groupAdjustment = 0;
1925 if (ssc.getGapsInsertedBegin() && right)
1927 if (viewport.cursorMode)
1929 alignPanel.getSeqPanel().moveCursor(size, 0);
1933 groupAdjustment = size;
1936 else if (!ssc.getGapsInsertedBegin() && !right)
1938 if (viewport.cursorMode)
1940 alignPanel.getSeqPanel().moveCursor(-size, 0);
1944 groupAdjustment = -size;
1948 if (groupAdjustment != 0)
1950 viewport.getSelectionGroup().setStartRes(
1951 viewport.getSelectionGroup().getStartRes() + groupAdjustment);
1952 viewport.getSelectionGroup().setEndRes(
1953 viewport.getSelectionGroup().getEndRes() + groupAdjustment);
1957 * just extend the last slide command if compatible; but not if in
1958 * SplitFrame mode (to ensure all edits are broadcast - JAL-1802)
1960 boolean appendHistoryItem = false;
1961 Deque<CommandI> historyList = viewport.getHistoryList();
1962 boolean inSplitFrame = getSplitViewContainer() != null;
1963 if (!inSplitFrame && historyList != null && historyList.size() > 0
1964 && historyList.peek() instanceof SlideSequencesCommand)
1966 appendHistoryItem = ssc.appendSlideCommand(
1967 (SlideSequencesCommand) historyList.peek());
1970 if (!appendHistoryItem)
1972 addHistoryItem(ssc);
1985 protected void copy_actionPerformed()
1987 if (viewport.getSelectionGroup() == null)
1991 // TODO: preserve the ordering of displayed alignment annotation in any
1992 // internal paste (particularly sequence associated annotation)
1993 SequenceI[] seqs = viewport.getSelectionAsNewSequence();
1994 String[] omitHidden = null;
1996 if (viewport.hasHiddenColumns())
1998 omitHidden = viewport.getViewAsString(true);
2001 String output = new FormatAdapter().formatSequences(FileFormat.Fasta,
2002 seqs, omitHidden, null);
2004 StringSelection ss = new StringSelection(output);
2008 jalview.gui.Desktop.internalCopy = true;
2009 // Its really worth setting the clipboard contents
2010 // to empty before setting the large StringSelection!!
2011 Toolkit.getDefaultToolkit().getSystemClipboard()
2012 .setContents(new StringSelection(""), null);
2014 Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss,
2016 } catch (OutOfMemoryError er)
2018 new OOMWarning("copying region", er);
2022 HiddenColumns hiddenColumns = null;
2023 if (viewport.hasHiddenColumns())
2025 int hiddenOffset = viewport.getSelectionGroup().getStartRes();
2026 int hiddenCutoff = viewport.getSelectionGroup().getEndRes();
2028 // create new HiddenColumns object with copy of hidden regions
2029 // between startRes and endRes, offset by startRes
2030 hiddenColumns = new HiddenColumns(
2031 viewport.getAlignment().getHiddenColumns(), hiddenOffset,
2032 hiddenCutoff, hiddenOffset);
2035 Desktop.jalviewClipboard = new Object[] { seqs,
2036 viewport.getAlignment().getDataset(), hiddenColumns };
2037 setStatus(MessageManager.formatMessage(
2038 "label.copied_sequences_to_clipboard", new Object[]
2039 { Integer.valueOf(seqs.length).toString() }));
2049 protected void pasteNew_actionPerformed(ActionEvent e)
2061 protected void pasteThis_actionPerformed(ActionEvent e)
2067 * Paste contents of Jalview clipboard
2069 * @param newAlignment
2070 * true to paste to a new alignment, otherwise add to this.
2072 void paste(boolean newAlignment)
2074 boolean externalPaste = true;
2077 Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
2078 Transferable contents = c.getContents(this);
2080 if (contents == null)
2089 str = (String) contents.getTransferData(DataFlavor.stringFlavor);
2090 if (str.length() < 1)
2095 format = new IdentifyFile().identify(str, DataSourceType.PASTE);
2097 } catch (OutOfMemoryError er)
2099 new OOMWarning("Out of memory pasting sequences!!", er);
2103 SequenceI[] sequences;
2104 boolean annotationAdded = false;
2105 AlignmentI alignment = null;
2107 if (Desktop.jalviewClipboard != null)
2109 // The clipboard was filled from within Jalview, we must use the
2111 // And dataset from the copied alignment
2112 SequenceI[] newseq = (SequenceI[]) Desktop.jalviewClipboard[0];
2113 // be doubly sure that we create *new* sequence objects.
2114 sequences = new SequenceI[newseq.length];
2115 for (int i = 0; i < newseq.length; i++)
2117 sequences[i] = new Sequence(newseq[i]);
2119 alignment = new Alignment(sequences);
2120 externalPaste = false;
2124 // parse the clipboard as an alignment.
2125 alignment = new FormatAdapter().readFile(str, DataSourceType.PASTE,
2127 sequences = alignment.getSequencesArray();
2131 ArrayList<Integer> newGraphGroups = new ArrayList<>();
2137 if (Desktop.jalviewClipboard != null)
2139 // dataset is inherited
2140 alignment.setDataset((Alignment) Desktop.jalviewClipboard[1]);
2144 // new dataset is constructed
2145 alignment.setDataset(null);
2147 alwidth = alignment.getWidth() + 1;
2151 AlignmentI pastedal = alignment; // preserve pasted alignment object
2152 // Add pasted sequences and dataset into existing alignment.
2153 alignment = viewport.getAlignment();
2154 alwidth = alignment.getWidth() + 1;
2155 // decide if we need to import sequences from an existing dataset
2156 boolean importDs = Desktop.jalviewClipboard != null
2157 && Desktop.jalviewClipboard[1] != alignment.getDataset();
2158 // importDs==true instructs us to copy over new dataset sequences from
2159 // an existing alignment
2160 Vector<SequenceI> newDs = (importDs) ? new Vector<>() : null; // used to
2162 // minimum dataset set
2164 for (int i = 0; i < sequences.length; i++)
2168 newDs.addElement(null);
2170 SequenceI ds = sequences[i].getDatasetSequence(); // null for a simple
2172 if (importDs && ds != null)
2174 if (!newDs.contains(ds))
2176 newDs.setElementAt(ds, i);
2177 ds = new Sequence(ds);
2178 // update with new dataset sequence
2179 sequences[i].setDatasetSequence(ds);
2183 ds = sequences[newDs.indexOf(ds)].getDatasetSequence();
2188 // copy and derive new dataset sequence
2189 sequences[i] = sequences[i].deriveSequence();
2190 alignment.getDataset()
2191 .addSequence(sequences[i].getDatasetSequence());
2192 // TODO: avoid creation of duplicate dataset sequences with a
2193 // 'contains' method using SequenceI.equals()/SequenceI.contains()
2195 alignment.addSequence(sequences[i]); // merges dataset
2199 newDs.clear(); // tidy up
2201 if (alignment.getAlignmentAnnotation() != null)
2203 for (AlignmentAnnotation alan : alignment
2204 .getAlignmentAnnotation())
2206 if (alan.graphGroup > fgroup)
2208 fgroup = alan.graphGroup;
2212 if (pastedal.getAlignmentAnnotation() != null)
2214 // Add any annotation attached to alignment.
2215 AlignmentAnnotation[] alann = pastedal.getAlignmentAnnotation();
2216 for (int i = 0; i < alann.length; i++)
2218 annotationAdded = true;
2219 if (alann[i].sequenceRef == null && !alann[i].autoCalculated)
2221 AlignmentAnnotation newann = new AlignmentAnnotation(
2223 if (newann.graphGroup > -1)
2225 if (newGraphGroups.size() <= newann.graphGroup
2226 || newGraphGroups.get(newann.graphGroup) == null)
2228 for (int q = newGraphGroups
2229 .size(); q <= newann.graphGroup; q++)
2231 newGraphGroups.add(q, null);
2233 newGraphGroups.set(newann.graphGroup,
2234 Integer.valueOf(++fgroup));
2236 newann.graphGroup = newGraphGroups.get(newann.graphGroup)
2240 newann.padAnnotation(alwidth);
2241 alignment.addAnnotation(newann);
2251 addHistoryItem(new EditCommand(
2252 MessageManager.getString("label.add_sequences"),
2253 Action.PASTE, sequences, 0, alignment.getWidth(),
2256 // Add any annotations attached to sequences
2257 for (int i = 0; i < sequences.length; i++)
2259 if (sequences[i].getAnnotation() != null)
2261 AlignmentAnnotation newann;
2262 for (int a = 0; a < sequences[i].getAnnotation().length; a++)
2264 annotationAdded = true;
2265 newann = sequences[i].getAnnotation()[a];
2266 newann.adjustForAlignment();
2267 newann.padAnnotation(alwidth);
2268 if (newann.graphGroup > -1)
2270 if (newann.graphGroup > -1)
2272 if (newGraphGroups.size() <= newann.graphGroup
2273 || newGraphGroups.get(newann.graphGroup) == null)
2275 for (int q = newGraphGroups
2276 .size(); q <= newann.graphGroup; q++)
2278 newGraphGroups.add(q, null);
2280 newGraphGroups.set(newann.graphGroup,
2281 Integer.valueOf(++fgroup));
2283 newann.graphGroup = newGraphGroups.get(newann.graphGroup)
2287 alignment.addAnnotation(sequences[i].getAnnotation()[a]); // annotation
2291 alignment.setAnnotationIndex(sequences[i].getAnnotation()[a],
2299 // propagate alignment changed.
2300 viewport.getRanges().setEndSeq(alignment.getHeight() - 1);
2301 if (annotationAdded)
2303 // Duplicate sequence annotation in all views.
2304 AlignmentI[] alview = this.getViewAlignments();
2305 for (int i = 0; i < sequences.length; i++)
2307 AlignmentAnnotation sann[] = sequences[i].getAnnotation();
2312 for (int avnum = 0; avnum < alview.length; avnum++)
2314 if (alview[avnum] != alignment)
2316 // duplicate in a view other than the one with input focus
2317 int avwidth = alview[avnum].getWidth() + 1;
2318 // this relies on sann being preserved after we
2319 // modify the sequence's annotation array for each duplication
2320 for (int a = 0; a < sann.length; a++)
2322 AlignmentAnnotation newann = new AlignmentAnnotation(
2324 sequences[i].addAlignmentAnnotation(newann);
2325 newann.padAnnotation(avwidth);
2326 alview[avnum].addAnnotation(newann); // annotation was
2327 // duplicated earlier
2328 // TODO JAL-1145 graphGroups are not updated for sequence
2329 // annotation added to several views. This may cause
2331 alview[avnum].setAnnotationIndex(newann, a);
2336 buildSortByAnnotationScoresMenu();
2338 viewport.firePropertyChange("alignment", null,
2339 alignment.getSequences());
2340 if (alignPanels != null)
2342 for (AlignmentPanel ap : alignPanels)
2344 ap.validateAnnotationDimensions(false);
2349 alignPanel.validateAnnotationDimensions(false);
2355 AlignFrame af = new AlignFrame(alignment, DEFAULT_WIDTH,
2357 String newtitle = new String("Copied sequences");
2359 if (Desktop.jalviewClipboard != null
2360 && Desktop.jalviewClipboard[2] != null)
2362 HiddenColumns hc = (HiddenColumns) Desktop.jalviewClipboard[2];
2363 af.viewport.setHiddenColumns(hc);
2366 // >>>This is a fix for the moment, until a better solution is
2368 af.alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer()
2369 .transferSettings(alignPanel.getSeqPanel().seqCanvas
2370 .getFeatureRenderer());
2372 // TODO: maintain provenance of an alignment, rather than just make the
2373 // title a concatenation of operations.
2376 if (title.startsWith("Copied sequences"))
2382 newtitle = newtitle.concat("- from " + title);
2387 newtitle = new String("Pasted sequences");
2390 Desktop.addInternalFrame(af, newtitle, DEFAULT_WIDTH,
2395 } catch (Exception ex)
2397 ex.printStackTrace();
2398 System.out.println("Exception whilst pasting: " + ex);
2399 // could be anything being pasted in here
2405 protected void expand_newalign(ActionEvent e)
2409 AlignmentI alignment = AlignmentUtils
2410 .expandContext(getViewport().getAlignment(), -1);
2411 AlignFrame af = new AlignFrame(alignment, DEFAULT_WIDTH,
2413 String newtitle = new String("Flanking alignment");
2415 if (Desktop.jalviewClipboard != null
2416 && Desktop.jalviewClipboard[2] != null)
2418 HiddenColumns hc = (HiddenColumns) Desktop.jalviewClipboard[2];
2419 af.viewport.setHiddenColumns(hc);
2422 // >>>This is a fix for the moment, until a better solution is
2424 af.alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer()
2425 .transferSettings(alignPanel.getSeqPanel().seqCanvas
2426 .getFeatureRenderer());
2428 // TODO: maintain provenance of an alignment, rather than just make the
2429 // title a concatenation of operations.
2431 if (title.startsWith("Copied sequences"))
2437 newtitle = newtitle.concat("- from " + title);
2441 Desktop.addInternalFrame(af, newtitle, DEFAULT_WIDTH, DEFAULT_HEIGHT);
2443 } catch (Exception ex)
2445 ex.printStackTrace();
2446 System.out.println("Exception whilst pasting: " + ex);
2447 // could be anything being pasted in here
2448 } catch (OutOfMemoryError oom)
2450 new OOMWarning("Viewing flanking region of alignment", oom);
2455 * Action Cut (delete and copy) the selected region
2458 protected void cut_actionPerformed()
2460 copy_actionPerformed();
2461 delete_actionPerformed();
2465 * Performs menu option to Delete the currently selected region
2468 protected void delete_actionPerformed()
2471 SequenceGroup sg = viewport.getSelectionGroup();
2477 Callable okAction = () -> {
2478 SequenceI[] cut = sg.getSequences()
2479 .toArray(new SequenceI[sg.getSize()]);
2481 addHistoryItem(new EditCommand(
2482 MessageManager.getString("label.cut_sequences"), Action.CUT,
2483 cut, sg.getStartRes(), sg.getEndRes() - sg.getStartRes() + 1,
2484 viewport.getAlignment()));
2486 viewport.setSelectionGroup(null);
2487 viewport.sendSelection();
2488 viewport.getAlignment().deleteGroup(sg);
2490 viewport.firePropertyChange("alignment", null,
2491 viewport.getAlignment().getSequences());
2492 if (viewport.getAlignment().getHeight() < 1)
2496 AlignFrame.this.setClosed(true);
2497 } catch (Exception ex)
2505 * If the cut affects all sequences, prompt for confirmation
2507 boolean wholeHeight = sg.getSize() == viewport.getAlignment()
2509 boolean wholeWidth = (((sg.getEndRes() - sg.getStartRes())
2510 + 1) == viewport.getAlignment().getWidth()) ? true : false;
2511 if (wholeHeight && wholeWidth)
2513 JvOptionPane dialog = JvOptionPane.newOptionDialog(Desktop.desktop);
2514 dialog.setResponseHandler(0, okAction); // 0 = OK_OPTION
2515 Object[] options = new Object[] {
2516 MessageManager.getString("action.ok"),
2517 MessageManager.getString("action.cancel") };
2518 dialog.showDialog(MessageManager.getString("warn.delete_all"),
2519 MessageManager.getString("label.delete_all"),
2520 JvOptionPane.DEFAULT_OPTION, JvOptionPane.PLAIN_MESSAGE, null,
2521 options, options[0]);
2528 } catch (Exception e)
2530 e.printStackTrace();
2542 protected void deleteGroups_actionPerformed(ActionEvent e)
2544 if (avc.deleteGroups())
2546 PaintRefresher.Refresh(this, viewport.getSequenceSetId());
2547 alignPanel.updateAnnotation();
2548 alignPanel.paintAlignment(true, true);
2559 public void selectAllSequenceMenuItem_actionPerformed(ActionEvent e)
2561 SequenceGroup sg = new SequenceGroup(
2562 viewport.getAlignment().getSequences());
2564 sg.setEndRes(viewport.getAlignment().getWidth() - 1);
2565 viewport.setSelectionGroup(sg);
2566 viewport.isSelectionGroupChanged(true);
2567 viewport.sendSelection();
2568 // JAL-2034 - should delegate to
2569 // alignPanel to decide if overview needs
2571 alignPanel.paintAlignment(false, false);
2572 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
2582 public void deselectAllSequenceMenuItem_actionPerformed(ActionEvent e)
2584 if (viewport.cursorMode)
2586 alignPanel.getSeqPanel().keyboardNo1 = null;
2587 alignPanel.getSeqPanel().keyboardNo2 = null;
2589 viewport.setSelectionGroup(null);
2590 viewport.getColumnSelection().clear();
2591 viewport.setSearchResults(null);
2592 alignPanel.getIdPanel().getIdCanvas().searchResults = null;
2593 // JAL-2034 - should delegate to
2594 // alignPanel to decide if overview needs
2596 alignPanel.paintAlignment(false, false);
2597 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
2598 viewport.sendSelection();
2608 public void invertSequenceMenuItem_actionPerformed(ActionEvent e)
2610 SequenceGroup sg = viewport.getSelectionGroup();
2614 selectAllSequenceMenuItem_actionPerformed(null);
2619 for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++)
2621 sg.addOrRemove(viewport.getAlignment().getSequenceAt(i), false);
2623 // JAL-2034 - should delegate to
2624 // alignPanel to decide if overview needs
2627 alignPanel.paintAlignment(true, false);
2628 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
2629 viewport.sendSelection();
2633 public void invertColSel_actionPerformed(ActionEvent e)
2635 viewport.invertColumnSelection();
2636 alignPanel.paintAlignment(true, false);
2637 viewport.sendSelection();
2647 public void remove2LeftMenuItem_actionPerformed(ActionEvent e)
2649 trimAlignment(true);
2659 public void remove2RightMenuItem_actionPerformed(ActionEvent e)
2661 trimAlignment(false);
2664 void trimAlignment(boolean trimLeft)
2666 ColumnSelection colSel = viewport.getColumnSelection();
2669 if (!colSel.isEmpty())
2673 column = colSel.getMin();
2677 column = colSel.getMax();
2681 if (viewport.getSelectionGroup() != null)
2683 seqs = viewport.getSelectionGroup()
2684 .getSequencesAsArray(viewport.getHiddenRepSequences());
2688 seqs = viewport.getAlignment().getSequencesArray();
2691 TrimRegionCommand trimRegion;
2694 trimRegion = new TrimRegionCommand("Remove Left", true, seqs,
2695 column, viewport.getAlignment());
2696 viewport.getRanges().setStartRes(0);
2700 trimRegion = new TrimRegionCommand("Remove Right", false, seqs,
2701 column, viewport.getAlignment());
2704 setStatus(MessageManager.formatMessage("label.removed_columns",
2706 { Integer.valueOf(trimRegion.getSize()).toString() }));
2708 addHistoryItem(trimRegion);
2710 for (SequenceGroup sg : viewport.getAlignment().getGroups())
2712 if ((trimLeft && !sg.adjustForRemoveLeft(column))
2713 || (!trimLeft && !sg.adjustForRemoveRight(column)))
2715 viewport.getAlignment().deleteGroup(sg);
2719 viewport.firePropertyChange("alignment", null,
2720 viewport.getAlignment().getSequences());
2731 public void removeGappedColumnMenuItem_actionPerformed(ActionEvent e)
2733 int start = 0, end = viewport.getAlignment().getWidth() - 1;
2736 if (viewport.getSelectionGroup() != null)
2738 seqs = viewport.getSelectionGroup()
2739 .getSequencesAsArray(viewport.getHiddenRepSequences());
2740 start = viewport.getSelectionGroup().getStartRes();
2741 end = viewport.getSelectionGroup().getEndRes();
2745 seqs = viewport.getAlignment().getSequencesArray();
2748 RemoveGapColCommand removeGapCols = new RemoveGapColCommand(
2749 "Remove Gapped Columns", seqs, start, end,
2750 viewport.getAlignment());
2752 addHistoryItem(removeGapCols);
2754 setStatus(MessageManager.formatMessage("label.removed_empty_columns",
2756 { Integer.valueOf(removeGapCols.getSize()).toString() }));
2758 // This is to maintain viewport position on first residue
2759 // of first sequence
2760 SequenceI seq = viewport.getAlignment().getSequenceAt(0);
2761 ViewportRanges ranges = viewport.getRanges();
2762 int startRes = seq.findPosition(ranges.getStartRes());
2763 // ShiftList shifts;
2764 // viewport.getAlignment().removeGaps(shifts=new ShiftList());
2765 // edit.alColumnChanges=shifts.getInverse();
2766 // if (viewport.hasHiddenColumns)
2767 // viewport.getColumnSelection().compensateForEdits(shifts);
2768 ranges.setStartRes(seq.findIndex(startRes) - 1);
2769 viewport.firePropertyChange("alignment", null,
2770 viewport.getAlignment().getSequences());
2781 public void removeAllGapsMenuItem_actionPerformed(ActionEvent e)
2783 int start = 0, end = viewport.getAlignment().getWidth() - 1;
2786 if (viewport.getSelectionGroup() != null)
2788 seqs = viewport.getSelectionGroup()
2789 .getSequencesAsArray(viewport.getHiddenRepSequences());
2790 start = viewport.getSelectionGroup().getStartRes();
2791 end = viewport.getSelectionGroup().getEndRes();
2795 seqs = viewport.getAlignment().getSequencesArray();
2798 // This is to maintain viewport position on first residue
2799 // of first sequence
2800 SequenceI seq = viewport.getAlignment().getSequenceAt(0);
2801 int startRes = seq.findPosition(viewport.getRanges().getStartRes());
2803 addHistoryItem(new RemoveGapsCommand("Remove Gaps", seqs, start, end,
2804 viewport.getAlignment()));
2806 viewport.getRanges().setStartRes(seq.findIndex(startRes) - 1);
2808 viewport.firePropertyChange("alignment", null,
2809 viewport.getAlignment().getSequences());
2820 public void padGapsMenuitem_actionPerformed(ActionEvent e)
2822 viewport.setPadGaps(padGapsMenuitem.isSelected());
2823 viewport.firePropertyChange("alignment", null,
2824 viewport.getAlignment().getSequences());
2828 * Opens a Finder dialog
2833 public void findMenuItem_actionPerformed(ActionEvent e)
2835 new Finder(alignPanel, false, null);
2839 * Create a new view of the current alignment.
2842 public void newView_actionPerformed(ActionEvent e)
2844 newView(null, true);
2848 * Creates and shows a new view of the current alignment.
2851 * title of newly created view; if null, one will be generated
2852 * @param copyAnnotation
2853 * if true then duplicate all annnotation, groups and settings
2854 * @return new alignment panel, already displayed.
2856 public AlignmentPanel newView(String viewTitle, boolean copyAnnotation)
2859 * Create a new AlignmentPanel (with its own, new Viewport)
2861 AlignmentPanel newap = new jalview.project.Jalview2XML()
2862 .copyAlignPanel(alignPanel);
2863 if (!copyAnnotation)
2866 * remove all groups and annotation except for the automatic stuff
2868 newap.av.getAlignment().deleteAllGroups();
2869 newap.av.getAlignment().deleteAllAnnotations(false);
2872 newap.av.setGatherViewsHere(false);
2874 if (viewport.getViewName() == null)
2876 viewport.setViewName(
2877 MessageManager.getString("label.view_name_original"));
2881 * Views share the same edits undo and redo stacks
2883 newap.av.setHistoryList(viewport.getHistoryList());
2884 newap.av.setRedoList(viewport.getRedoList());
2887 * copy any visualisation settings that are not saved in the project
2889 newap.av.setColourAppliesToAllGroups(
2890 viewport.getColourAppliesToAllGroups());
2893 * Views share the same mappings; need to deregister any new mappings
2894 * created by copyAlignPanel, and register the new reference to the shared
2897 newap.av.replaceMappings(viewport.getAlignment());
2900 * start up cDNA consensus (if applicable) now mappings are in place
2902 if (newap.av.initComplementConsensus())
2904 newap.refresh(true); // adjust layout of annotations
2907 newap.av.setViewName(getNewViewName(viewTitle));
2909 addAlignmentPanel(newap, true);
2910 newap.alignmentChanged();
2912 if (alignPanels.size() == 2)
2914 viewport.setGatherViewsHere(true);
2916 tabbedPane.setSelectedIndex(tabbedPane.getTabCount() - 1);
2921 * Make a new name for the view, ensuring it is unique within the current
2922 * sequenceSetId. (This used to be essential for Jalview Project archives, but
2923 * these now use viewId. Unique view names are still desirable for usability.)
2928 protected String getNewViewName(String viewTitle)
2930 int index = Desktop.getViewCount(viewport.getSequenceSetId());
2931 boolean addFirstIndex = false;
2932 if (viewTitle == null || viewTitle.trim().length() == 0)
2934 viewTitle = MessageManager.getString("action.view");
2935 addFirstIndex = true;
2939 index = 1;// we count from 1 if given a specific name
2941 String newViewName = viewTitle + ((addFirstIndex) ? " " + index : "");
2943 List<Component> comps = PaintRefresher.components
2944 .get(viewport.getSequenceSetId());
2946 List<String> existingNames = getExistingViewNames(comps);
2948 while (existingNames.contains(newViewName))
2950 newViewName = viewTitle + " " + (++index);
2956 * Returns a list of distinct view names found in the given list of
2957 * components. View names are held on the viewport of an AlignmentPanel.
2962 protected List<String> getExistingViewNames(List<Component> comps)
2964 List<String> existingNames = new ArrayList<>();
2965 for (Component comp : comps)
2967 if (comp instanceof AlignmentPanel)
2969 AlignmentPanel ap = (AlignmentPanel) comp;
2970 if (!existingNames.contains(ap.av.getViewName()))
2972 existingNames.add(ap.av.getViewName());
2976 return existingNames;
2980 * Explode tabbed views into separate windows.
2983 public void expandViews_actionPerformed(ActionEvent e)
2985 Desktop.explodeViews(this);
2989 * Gather views in separate windows back into a tabbed presentation.
2992 public void gatherViews_actionPerformed(ActionEvent e)
2994 Desktop.instance.gatherViews(this);
3004 public void font_actionPerformed(ActionEvent e)
3006 new FontChooser(alignPanel);
3016 protected void seqLimit_actionPerformed(ActionEvent e)
3018 viewport.setShowJVSuffix(seqLimits.isSelected());
3020 alignPanel.getIdPanel().getIdCanvas()
3021 .setPreferredSize(alignPanel.calculateIdWidth());
3022 alignPanel.paintAlignment(true, false);
3026 public void idRightAlign_actionPerformed(ActionEvent e)
3028 viewport.setRightAlignIds(idRightAlign.isSelected());
3029 alignPanel.paintAlignment(false, false);
3033 public void centreColumnLabels_actionPerformed(ActionEvent e)
3035 viewport.setCentreColumnLabels(centreColumnLabelsMenuItem.getState());
3036 alignPanel.paintAlignment(false, false);
3042 * @see jalview.jbgui.GAlignFrame#followHighlight_actionPerformed()
3045 protected void followHighlight_actionPerformed()
3048 * Set the 'follow' flag on the Viewport (and scroll to position if now
3051 final boolean state = this.followHighlightMenuItem.getState();
3052 viewport.setFollowHighlight(state);
3055 alignPanel.scrollToPosition(viewport.getSearchResults());
3066 protected void colourTextMenuItem_actionPerformed(ActionEvent e)
3068 viewport.setColourText(colourTextMenuItem.isSelected());
3069 alignPanel.paintAlignment(false, false);
3079 public void wrapMenuItem_actionPerformed(ActionEvent e)
3081 scaleAbove.setVisible(wrapMenuItem.isSelected());
3082 scaleLeft.setVisible(wrapMenuItem.isSelected());
3083 scaleRight.setVisible(wrapMenuItem.isSelected());
3084 viewport.setWrapAlignment(wrapMenuItem.isSelected());
3085 alignPanel.updateLayout();
3089 public void showAllSeqs_actionPerformed(ActionEvent e)
3091 viewport.showAllHiddenSeqs();
3095 public void showAllColumns_actionPerformed(ActionEvent e)
3097 viewport.showAllHiddenColumns();
3098 alignPanel.paintAlignment(true, true);
3099 viewport.sendSelection();
3103 public void hideSelSequences_actionPerformed(ActionEvent e)
3105 viewport.hideAllSelectedSeqs();
3109 * called by key handler and the hide all/show all menu items
3114 protected void toggleHiddenRegions(boolean toggleSeqs, boolean toggleCols)
3117 boolean hide = false;
3118 SequenceGroup sg = viewport.getSelectionGroup();
3119 if (!toggleSeqs && !toggleCols)
3121 // Hide everything by the current selection - this is a hack - we do the
3122 // invert and then hide
3123 // first check that there will be visible columns after the invert.
3124 if (viewport.hasSelectedColumns() || (sg != null && sg.getSize() > 0
3125 && sg.getStartRes() <= sg.getEndRes()))
3127 // now invert the sequence set, if required - empty selection implies
3128 // that no hiding is required.
3131 invertSequenceMenuItem_actionPerformed(null);
3132 sg = viewport.getSelectionGroup();
3136 viewport.expandColSelection(sg, true);
3137 // finally invert the column selection and get the new sequence
3139 invertColSel_actionPerformed(null);
3146 if (sg != null && sg.getSize() != viewport.getAlignment().getHeight())
3148 hideSelSequences_actionPerformed(null);
3151 else if (!(toggleCols && viewport.hasSelectedColumns()))
3153 showAllSeqs_actionPerformed(null);
3159 if (viewport.hasSelectedColumns())
3161 hideSelColumns_actionPerformed(null);
3164 viewport.setSelectionGroup(sg);
3169 showAllColumns_actionPerformed(null);
3178 * jalview.jbgui.GAlignFrame#hideAllButSelection_actionPerformed(java.awt.
3179 * event.ActionEvent)
3182 public void hideAllButSelection_actionPerformed(ActionEvent e)
3184 toggleHiddenRegions(false, false);
3185 viewport.sendSelection();
3192 * jalview.jbgui.GAlignFrame#hideAllSelection_actionPerformed(java.awt.event
3196 public void hideAllSelection_actionPerformed(ActionEvent e)
3198 SequenceGroup sg = viewport.getSelectionGroup();
3199 viewport.expandColSelection(sg, false);
3200 viewport.hideAllSelectedSeqs();
3201 viewport.hideSelectedColumns();
3202 alignPanel.updateLayout();
3203 alignPanel.paintAlignment(true, true);
3204 viewport.sendSelection();
3211 * jalview.jbgui.GAlignFrame#showAllhidden_actionPerformed(java.awt.event.
3215 public void showAllhidden_actionPerformed(ActionEvent e)
3217 viewport.showAllHiddenColumns();
3218 viewport.showAllHiddenSeqs();
3219 alignPanel.paintAlignment(true, true);
3220 viewport.sendSelection();
3224 public void hideSelColumns_actionPerformed(ActionEvent e)
3226 viewport.hideSelectedColumns();
3227 alignPanel.updateLayout();
3228 alignPanel.paintAlignment(true, true);
3229 viewport.sendSelection();
3233 public void hiddenMarkers_actionPerformed(ActionEvent e)
3235 viewport.setShowHiddenMarkers(hiddenMarkers.isSelected());
3246 protected void scaleAbove_actionPerformed(ActionEvent e)
3248 viewport.setScaleAboveWrapped(scaleAbove.isSelected());
3249 alignPanel.updateLayout();
3250 alignPanel.paintAlignment(true, false);
3260 protected void scaleLeft_actionPerformed(ActionEvent e)
3262 viewport.setScaleLeftWrapped(scaleLeft.isSelected());
3263 alignPanel.updateLayout();
3264 alignPanel.paintAlignment(true, false);
3274 protected void scaleRight_actionPerformed(ActionEvent e)
3276 viewport.setScaleRightWrapped(scaleRight.isSelected());
3277 alignPanel.updateLayout();
3278 alignPanel.paintAlignment(true, false);
3288 public void viewBoxesMenuItem_actionPerformed(ActionEvent e)
3290 viewport.setShowBoxes(viewBoxesMenuItem.isSelected());
3291 alignPanel.paintAlignment(false, false);
3301 public void viewTextMenuItem_actionPerformed(ActionEvent e)
3303 viewport.setShowText(viewTextMenuItem.isSelected());
3304 alignPanel.paintAlignment(false, false);
3314 protected void renderGapsMenuItem_actionPerformed(ActionEvent e)
3316 viewport.setRenderGaps(renderGapsMenuItem.isSelected());
3317 alignPanel.paintAlignment(false, false);
3320 public FeatureSettings featureSettings;
3323 public FeatureSettingsControllerI getFeatureSettingsUI()
3325 return featureSettings;
3329 public void featureSettings_actionPerformed(ActionEvent e)
3331 showFeatureSettingsUI();
3335 public FeatureSettingsControllerI showFeatureSettingsUI()
3337 if (featureSettings != null)
3339 featureSettings.closeOldSettings();
3340 featureSettings = null;
3342 if (!showSeqFeatures.isSelected())
3344 // make sure features are actually displayed
3345 showSeqFeatures.setSelected(true);
3346 showSeqFeatures_actionPerformed(null);
3348 featureSettings = new FeatureSettings(this);
3349 return featureSettings;
3353 * Set or clear 'Show Sequence Features'
3359 public void showSeqFeatures_actionPerformed(ActionEvent evt)
3361 viewport.setShowSequenceFeatures(showSeqFeatures.isSelected());
3362 alignPanel.paintAlignment(true, true);
3366 * Action on toggle of the 'Show annotations' menu item. This shows or hides
3367 * the annotations panel as a whole.
3369 * The options to show/hide all annotations should be enabled when the panel
3370 * is shown, and disabled when the panel is hidden.
3375 public void annotationPanelMenuItem_actionPerformed(ActionEvent e)
3377 final boolean setVisible = annotationPanelMenuItem.isSelected();
3378 viewport.setShowAnnotation(setVisible);
3379 this.showAllSeqAnnotations.setEnabled(setVisible);
3380 this.hideAllSeqAnnotations.setEnabled(setVisible);
3381 this.showAllAlAnnotations.setEnabled(setVisible);
3382 this.hideAllAlAnnotations.setEnabled(setVisible);
3383 alignPanel.updateLayout();
3387 public void alignmentProperties()
3390 StringBuffer contents = new AlignmentProperties(viewport.getAlignment())
3393 String content = MessageManager.formatMessage("label.html_content",
3395 { contents.toString() });
3398 if (Platform.isJS())
3400 JLabel textLabel = new JLabel();
3401 textLabel.setText(content);
3402 textLabel.setBackground(Color.WHITE);
3404 pane = new JPanel(new BorderLayout());
3405 ((JPanel) pane).setOpaque(true);
3406 pane.setBackground(Color.WHITE);
3407 ((JPanel) pane).add(textLabel, BorderLayout.NORTH);
3416 JEditorPane editPane = new JEditorPane("text/html", "");
3417 editPane.setEditable(false);
3418 editPane.setText(content);
3422 JInternalFrame frame = new JInternalFrame();
3424 frame.getContentPane().add(new JScrollPane(pane));
3426 Desktop.addInternalFrame(frame, MessageManager
3427 .formatMessage("label.alignment_properties", new Object[]
3428 { getTitle() }), 500, 400);
3438 public void overviewMenuItem_actionPerformed(ActionEvent e)
3440 if (alignPanel.overviewPanel != null)
3445 JInternalFrame frame = new JInternalFrame();
3446 final OverviewPanel overview = new OverviewPanel(alignPanel);
3447 frame.setContentPane(overview);
3448 Desktop.addInternalFrame(frame, MessageManager
3449 .formatMessage("label.overview_params", new Object[]
3450 { this.getTitle() }), true, frame.getWidth(), frame.getHeight(),
3452 frame.setFrameIcon(null);
3454 frame.setLayer(JLayeredPane.PALETTE_LAYER);
3455 frame.addInternalFrameListener(
3456 new javax.swing.event.InternalFrameAdapter()
3459 public void internalFrameClosed(
3460 javax.swing.event.InternalFrameEvent evt)
3463 alignPanel.setOverviewPanel(null);
3466 if (getKeyListeners().length > 0)
3468 frame.addKeyListener(getKeyListeners()[0]);
3471 alignPanel.setOverviewPanel(overview);
3475 public void textColour_actionPerformed()
3477 new TextColourChooser().chooseColour(alignPanel, null);
3481 * public void covariationColour_actionPerformed() {
3483 * CovariationColourScheme(viewport.getAlignment().getAlignmentAnnotation
3487 public void annotationColour_actionPerformed()
3489 new AnnotationColourChooser(viewport, alignPanel);
3493 public void annotationColumn_actionPerformed(ActionEvent e)
3495 new AnnotationColumnChooser(viewport, alignPanel);
3499 * Action on the user checking or unchecking the option to apply the selected
3500 * colour scheme to all groups. If unchecked, groups may have their own
3501 * independent colour schemes.
3506 public void applyToAllGroups_actionPerformed(boolean selected)
3508 viewport.setColourAppliesToAllGroups(selected);
3512 * Action on user selecting a colour from the colour menu
3515 * the name (not the menu item label!) of the colour scheme
3518 public void changeColour_actionPerformed(String name)
3521 * 'User Defined' opens a panel to configure or load a
3522 * user-defined colour scheme
3524 if (ResidueColourScheme.USER_DEFINED_MENU.equals(name))
3526 new UserDefinedColours(alignPanel);
3531 * otherwise set the chosen colour scheme (or null for 'None')
3533 ColourSchemeI cs = ColourSchemes.getInstance().getColourScheme(name,
3534 viewport, viewport.getAlignment(),
3535 viewport.getHiddenRepSequences());
3540 * Actions on setting or changing the alignment colour scheme
3545 public void changeColour(ColourSchemeI cs)
3547 // TODO: pull up to controller method
3548 ColourMenuHelper.setColourSelected(colourMenu, cs);
3550 viewport.setGlobalColourScheme(cs);
3552 alignPanel.paintAlignment(true, true);
3556 * Show the PID threshold slider panel
3559 protected void modifyPID_actionPerformed()
3561 SliderPanel.setPIDSliderSource(alignPanel, viewport.getResidueShading(),
3562 alignPanel.getViewName());
3563 SliderPanel.showPIDSlider();
3567 * Show the Conservation slider panel
3570 protected void modifyConservation_actionPerformed()
3572 SliderPanel.setConservationSlider(alignPanel,
3573 viewport.getResidueShading(), alignPanel.getViewName());
3574 SliderPanel.showConservationSlider();
3578 * Action on selecting or deselecting (Colour) By Conservation
3581 public void conservationMenuItem_actionPerformed(boolean selected)
3583 modifyConservation.setEnabled(selected);
3584 viewport.setConservationSelected(selected);
3585 viewport.getResidueShading().setConservationApplied(selected);
3587 changeColour(viewport.getGlobalColourScheme());
3590 modifyConservation_actionPerformed();
3594 SliderPanel.hideConservationSlider();
3599 * Action on selecting or deselecting (Colour) Above PID Threshold
3602 public void abovePIDThreshold_actionPerformed(boolean selected)
3604 modifyPID.setEnabled(selected);
3605 viewport.setAbovePIDThreshold(selected);
3608 viewport.getResidueShading().setThreshold(0,
3609 viewport.isIgnoreGapsConsensus());
3612 changeColour(viewport.getGlobalColourScheme());
3615 modifyPID_actionPerformed();
3619 SliderPanel.hidePIDSlider();
3630 public void sortPairwiseMenuItem_actionPerformed(ActionEvent e)
3632 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
3633 AlignmentSorter.sortByPID(viewport.getAlignment(),
3634 viewport.getAlignment().getSequenceAt(0));
3635 addHistoryItem(new OrderCommand("Pairwise Sort", oldOrder,
3636 viewport.getAlignment()));
3637 alignPanel.paintAlignment(true, false);
3647 public void sortIDMenuItem_actionPerformed(ActionEvent e)
3649 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
3650 AlignmentSorter.sortByID(viewport.getAlignment());
3652 new OrderCommand("ID Sort", oldOrder, viewport.getAlignment()));
3653 alignPanel.paintAlignment(true, false);
3663 public void sortLengthMenuItem_actionPerformed(ActionEvent e)
3665 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
3666 AlignmentSorter.sortByLength(viewport.getAlignment());
3667 addHistoryItem(new OrderCommand("Length Sort", oldOrder,
3668 viewport.getAlignment()));
3669 alignPanel.paintAlignment(true, false);
3679 public void sortGroupMenuItem_actionPerformed(ActionEvent e)
3681 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
3682 AlignmentSorter.sortByGroup(viewport.getAlignment());
3683 addHistoryItem(new OrderCommand("Group Sort", oldOrder,
3684 viewport.getAlignment()));
3686 alignPanel.paintAlignment(true, false);
3696 public void removeRedundancyMenuItem_actionPerformed(ActionEvent e)
3698 new RedundancyPanel(alignPanel, this);
3708 public void pairwiseAlignmentMenuItem_actionPerformed(ActionEvent e)
3710 if ((viewport.getSelectionGroup() == null)
3711 || (viewport.getSelectionGroup().getSize() < 2))
3713 JvOptionPane.showInternalMessageDialog(this,
3714 MessageManager.getString(
3715 "label.you_must_select_least_two_sequences"),
3716 MessageManager.getString("label.invalid_selection"),
3717 JvOptionPane.WARNING_MESSAGE);
3721 JInternalFrame frame = new JInternalFrame();
3722 frame.setContentPane(new PairwiseAlignPanel(viewport));
3723 Desktop.addInternalFrame(frame,
3724 MessageManager.getString("action.pairwise_alignment"), 600,
3730 public void autoCalculate_actionPerformed(ActionEvent e)
3732 viewport.autoCalculateConsensus = autoCalculate.isSelected();
3733 if (viewport.autoCalculateConsensus)
3735 viewport.firePropertyChange("alignment", null,
3736 viewport.getAlignment().getSequences());
3741 public void sortByTreeOption_actionPerformed(ActionEvent e)
3743 viewport.sortByTree = sortByTree.isSelected();
3747 protected void listenToViewSelections_actionPerformed(ActionEvent e)
3749 viewport.followSelection = listenToViewSelections.isSelected();
3753 * Constructs a tree panel and adds it to the desktop
3756 * tree type (NJ or AV)
3758 * name of score model used to compute the tree
3760 * parameters for the distance or similarity calculation
3762 void newTreePanel(String type, String modelName,
3763 SimilarityParamsI options)
3765 String frameTitle = "";
3768 boolean onSelection = false;
3769 if (viewport.getSelectionGroup() != null
3770 && viewport.getSelectionGroup().getSize() > 0)
3772 SequenceGroup sg = viewport.getSelectionGroup();
3774 /* Decide if the selection is a column region */
3775 for (SequenceI _s : sg.getSequences())
3777 if (_s.getLength() < sg.getEndRes())
3779 JvOptionPane.showMessageDialog(Desktop.desktop,
3780 MessageManager.getString(
3781 "label.selected_region_to_tree_may_only_contain_residues_or_gaps"),
3782 MessageManager.getString(
3783 "label.sequences_selection_not_aligned"),
3784 JvOptionPane.WARNING_MESSAGE);
3793 if (viewport.getAlignment().getHeight() < 2)
3799 tp = new TreePanel(alignPanel, type, modelName, options);
3800 frameTitle = tp.getPanelTitle() + (onSelection ? " on region" : "");
3802 frameTitle += " from ";
3804 if (viewport.getViewName() != null)
3806 frameTitle += viewport.getViewName() + " of ";
3809 frameTitle += this.title;
3811 Desktop.addInternalFrame(tp, frameTitle, 600, 500);
3822 public void addSortByOrderMenuItem(String title,
3823 final AlignmentOrder order)
3825 final JMenuItem item = new JMenuItem(MessageManager
3826 .formatMessage("action.by_title_param", new Object[]
3829 item.addActionListener(new java.awt.event.ActionListener()
3832 public void actionPerformed(ActionEvent e)
3834 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
3836 // TODO: JBPNote - have to map order entries to curent SequenceI
3838 AlignmentSorter.sortBy(viewport.getAlignment(), order);
3840 addHistoryItem(new OrderCommand(order.getName(), oldOrder,
3841 viewport.getAlignment()));
3843 alignPanel.paintAlignment(true, false);
3849 * Add a new sort by annotation score menu item
3852 * the menu to add the option to
3854 * the label used to retrieve scores for each sequence on the
3857 public void addSortByAnnotScoreMenuItem(JMenu sort,
3858 final String scoreLabel)
3860 final JMenuItem item = new JMenuItem(scoreLabel);
3862 item.addActionListener(new java.awt.event.ActionListener()
3865 public void actionPerformed(ActionEvent e)
3867 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
3868 AlignmentSorter.sortByAnnotationScore(scoreLabel,
3869 viewport.getAlignment());// ,viewport.getSelectionGroup());
3870 addHistoryItem(new OrderCommand("Sort by " + scoreLabel, oldOrder,
3871 viewport.getAlignment()));
3872 alignPanel.paintAlignment(true, false);
3878 * last hash for alignment's annotation array - used to minimise cost of
3881 protected int _annotationScoreVectorHash;
3884 * search the alignment and rebuild the sort by annotation score submenu the
3885 * last alignment annotation vector hash is stored to minimize cost of
3886 * rebuilding in subsequence calls.
3890 public void buildSortByAnnotationScoresMenu()
3892 if (viewport.getAlignment().getAlignmentAnnotation() == null)
3897 if (viewport.getAlignment().getAlignmentAnnotation()
3898 .hashCode() != _annotationScoreVectorHash)
3900 sortByAnnotScore.removeAll();
3901 // almost certainly a quicker way to do this - but we keep it simple
3902 Hashtable<String, String> scoreSorts = new Hashtable<>();
3903 AlignmentAnnotation aann[];
3904 for (SequenceI sqa : viewport.getAlignment().getSequences())
3906 aann = sqa.getAnnotation();
3907 for (int i = 0; aann != null && i < aann.length; i++)
3909 if (aann[i].hasScore() && aann[i].sequenceRef != null)
3911 scoreSorts.put(aann[i].label, aann[i].label);
3915 Enumeration<String> labels = scoreSorts.keys();
3916 while (labels.hasMoreElements())
3918 addSortByAnnotScoreMenuItem(sortByAnnotScore, labels.nextElement());
3920 sortByAnnotScore.setVisible(scoreSorts.size() > 0);
3923 _annotationScoreVectorHash = viewport.getAlignment()
3924 .getAlignmentAnnotation().hashCode();
3929 * Maintain the Order by->Displayed Tree menu. Creates a new menu item for a
3930 * TreePanel with an appropriate <code>jalview.analysis.AlignmentSorter</code>
3931 * call. Listeners are added to remove the menu item when the treePanel is
3932 * closed, and adjust the tree leaf to sequence mapping when the alignment is
3936 public void buildTreeSortMenu()
3938 sortByTreeMenu.removeAll();
3940 List<Component> comps = PaintRefresher.components
3941 .get(viewport.getSequenceSetId());
3942 List<TreePanel> treePanels = new ArrayList<>();
3943 for (Component comp : comps)
3945 if (comp instanceof TreePanel)
3947 treePanels.add((TreePanel) comp);
3951 if (treePanels.size() < 1)
3953 sortByTreeMenu.setVisible(false);
3957 sortByTreeMenu.setVisible(true);
3959 for (final TreePanel tp : treePanels)
3961 final JMenuItem item = new JMenuItem(tp.getTitle());
3962 item.addActionListener(new java.awt.event.ActionListener()
3965 public void actionPerformed(ActionEvent e)
3967 tp.sortByTree_actionPerformed();
3968 addHistoryItem(tp.sortAlignmentIn(alignPanel));
3973 sortByTreeMenu.add(item);
3977 public boolean sortBy(AlignmentOrder alorder, String undoname)
3979 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
3980 AlignmentSorter.sortBy(viewport.getAlignment(), alorder);
3981 if (undoname != null)
3983 addHistoryItem(new OrderCommand(undoname, oldOrder,
3984 viewport.getAlignment()));
3986 alignPanel.paintAlignment(true, false);
3991 * Work out whether the whole set of sequences or just the selected set will
3992 * be submitted for multiple alignment.
3995 public jalview.datamodel.AlignmentView gatherSequencesForAlignment()
3997 // Now, check we have enough sequences
3998 AlignmentView msa = null;
4000 if ((viewport.getSelectionGroup() != null)
4001 && (viewport.getSelectionGroup().getSize() > 1))
4003 // JBPNote UGLY! To prettify, make SequenceGroup and Alignment conform to
4004 // some common interface!
4006 * SequenceGroup seqs = viewport.getSelectionGroup(); int sz; msa = new
4007 * SequenceI[sz = seqs.getSize(false)];
4009 * for (int i = 0; i < sz; i++) { msa[i] = (SequenceI)
4010 * seqs.getSequenceAt(i); }
4012 msa = viewport.getAlignmentView(true);
4014 else if (viewport.getSelectionGroup() != null
4015 && viewport.getSelectionGroup().getSize() == 1)
4017 int option = JvOptionPane.showConfirmDialog(this,
4018 MessageManager.getString("warn.oneseq_msainput_selection"),
4019 MessageManager.getString("label.invalid_selection"),
4020 JvOptionPane.OK_CANCEL_OPTION);
4021 if (option == JvOptionPane.OK_OPTION)
4023 msa = viewport.getAlignmentView(false);
4028 msa = viewport.getAlignmentView(false);
4034 * Decides what is submitted to a secondary structure prediction service: the
4035 * first sequence in the alignment, or in the current selection, or, if the
4036 * alignment is 'aligned' (ie padded with gaps), then the currently selected
4037 * region or the whole alignment. (where the first sequence in the set is the
4038 * one that the prediction will be for).
4040 public AlignmentView gatherSeqOrMsaForSecStrPrediction()
4042 AlignmentView seqs = null;
4044 if ((viewport.getSelectionGroup() != null)
4045 && (viewport.getSelectionGroup().getSize() > 0))
4047 seqs = viewport.getAlignmentView(true);
4051 seqs = viewport.getAlignmentView(false);
4053 // limit sequences - JBPNote in future - could spawn multiple prediction
4055 // TODO: viewport.getAlignment().isAligned is a global state - the local
4056 // selection may well be aligned - we preserve 2.0.8 behaviour for moment.
4057 if (!viewport.getAlignment().isAligned(false))
4059 seqs.setSequences(new SeqCigar[] { seqs.getSequences()[0] });
4060 // TODO: if seqs.getSequences().length>1 then should really have warned
4074 protected void loadTreeMenuItem_actionPerformed(ActionEvent e)
4076 // Pick the tree file
4077 JalviewFileChooser chooser = new JalviewFileChooser(
4078 Cache.getProperty("LAST_DIRECTORY"));
4079 chooser.setFileView(new JalviewFileView());
4080 chooser.setDialogTitle(
4081 MessageManager.getString("label.select_newick_like_tree_file"));
4082 chooser.setToolTipText(
4083 MessageManager.getString("label.load_tree_file"));
4085 chooser.setResponseHandler(0, () -> {
4086 String filePath = chooser.getSelectedFile().getPath();
4087 Cache.setProperty("LAST_DIRECTORY", filePath);
4088 NewickFile fin = null;
4091 fin = new NewickFile(new FileParse(chooser.getSelectedFile(),
4092 DataSourceType.FILE));
4093 viewport.setCurrentTree(showNewickTree(fin, filePath).getTree());
4094 } catch (Exception ex)
4096 JvOptionPane.showMessageDialog(Desktop.desktop, ex.getMessage(),
4097 MessageManager.getString("label.problem_reading_tree_file"),
4098 JvOptionPane.WARNING_MESSAGE);
4099 ex.printStackTrace();
4101 if (fin != null && fin.hasWarningMessage())
4103 JvOptionPane.showMessageDialog(Desktop.desktop,
4104 fin.getWarningMessage(),
4106 .getString("label.possible_problem_with_tree_file"),
4107 JvOptionPane.WARNING_MESSAGE);
4111 chooser.showOpenDialog(this);
4114 public TreePanel showNewickTree(NewickFile nf, String treeTitle)
4116 return showNewickTree(nf, treeTitle, 600, 500, 4, 5);
4119 public TreePanel showNewickTree(NewickFile nf, String treeTitle, int w,
4120 int h, int x, int y)
4122 return showNewickTree(nf, treeTitle, null, w, h, x, y);
4126 * Add a treeviewer for the tree extracted from a Newick file object to the
4127 * current alignment view
4134 * Associated alignment input data (or null)
4143 * @return TreePanel handle
4145 public TreePanel showNewickTree(NewickFile nf, String treeTitle,
4146 AlignmentView input, int w, int h, int x, int y)
4148 TreePanel tp = null;
4154 if (nf.getTree() != null)
4156 tp = new TreePanel(alignPanel, nf, treeTitle, input);
4162 tp.setLocation(x, y);
4165 Desktop.addInternalFrame(tp, treeTitle, w, h);
4167 } catch (Exception ex)
4169 ex.printStackTrace();
4175 private boolean buildingMenu = false;
4178 * Generates menu items and listener event actions for web service clients
4181 public void BuildWebServiceMenu()
4183 while (buildingMenu)
4187 System.err.println("Waiting for building menu to finish.");
4189 } catch (Exception e)
4193 final AlignFrame me = this;
4194 buildingMenu = true;
4195 new Thread(new Runnable()
4200 final List<JMenuItem> legacyItems = new ArrayList<>();
4203 // System.err.println("Building ws menu again "
4204 // + Thread.currentThread());
4205 // TODO: add support for context dependent disabling of services based
4207 // alignment and current selection
4208 // TODO: add additional serviceHandle parameter to specify abstract
4210 // class independently of AbstractName
4211 // TODO: add in rediscovery GUI function to restart discoverer
4212 // TODO: group services by location as well as function and/or
4214 // object broker mechanism.
4215 final Vector<JMenu> wsmenu = new Vector<>();
4216 final IProgressIndicator af = me;
4219 * do not i18n these strings - they are hard-coded in class
4220 * compbio.data.msa.Category, Jws2Discoverer.isRecalculable() and
4221 * SequenceAnnotationWSClient.initSequenceAnnotationWSClient()
4223 final JMenu msawsmenu = new JMenu("Alignment");
4224 final JMenu secstrmenu = new JMenu(
4225 "Secondary Structure Prediction");
4226 final JMenu seqsrchmenu = new JMenu("Sequence Database Search");
4227 final JMenu analymenu = new JMenu("Analysis");
4228 final JMenu dismenu = new JMenu("Protein Disorder");
4229 // JAL-940 - only show secondary structure prediction services from
4230 // the legacy server
4231 if (// Cache.getDefault("SHOW_JWS1_SERVICES", true)
4233 Discoverer.services != null && (Discoverer.services.size() > 0))
4235 // TODO: refactor to allow list of AbstractName/Handler bindings to
4237 // stored or retrieved from elsewhere
4238 // No MSAWS used any more:
4239 // Vector msaws = null; // (Vector)
4240 // Discoverer.services.get("MsaWS");
4241 Vector<ServiceHandle> secstrpr = Discoverer.services
4243 if (secstrpr != null)
4245 // Add any secondary structure prediction services
4246 for (int i = 0, j = secstrpr.size(); i < j; i++)
4248 final ext.vamsas.ServiceHandle sh = secstrpr.get(i);
4249 jalview.ws.WSMenuEntryProviderI impl = jalview.ws.jws1.Discoverer
4250 .getServiceClient(sh);
4251 int p = secstrmenu.getItemCount();
4252 impl.attachWSMenuEntry(secstrmenu, me);
4253 int q = secstrmenu.getItemCount();
4254 for (int litm = p; litm < q; litm++)
4256 legacyItems.add(secstrmenu.getItem(litm));
4262 // Add all submenus in the order they should appear on the web
4264 wsmenu.add(msawsmenu);
4265 wsmenu.add(secstrmenu);
4266 wsmenu.add(dismenu);
4267 wsmenu.add(analymenu);
4268 // No search services yet
4269 // wsmenu.add(seqsrchmenu);
4271 javax.swing.SwingUtilities.invokeLater(new Runnable()
4278 webService.removeAll();
4279 // first, add discovered services onto the webservices menu
4280 if (wsmenu.size() > 0)
4282 for (int i = 0, j = wsmenu.size(); i < j; i++)
4284 webService.add(wsmenu.get(i));
4289 webService.add(me.webServiceNoServices);
4291 // TODO: move into separate menu builder class.
4293 // logic for 2.11.1.4 is
4294 // always look to see if there is a discover. if there isn't
4295 // we can't show any Jws2 services
4296 // if there are services available, show them - regardless of
4297 // the 'show JWS2 preference'
4298 // if the discoverer is running then say so
4299 // otherwise offer to trigger discovery if 'show JWS2' is not
4301 Jws2Discoverer jws2servs = Jws2Discoverer.getDiscoverer();
4302 if (jws2servs != null)
4304 if (jws2servs.hasServices())
4306 jws2servs.attachWSMenuEntry(webService, me);
4307 for (Jws2Instance sv : jws2servs.getServices())
4309 if (sv.description.toLowerCase(Locale.ROOT)
4312 for (JMenuItem jmi : legacyItems)
4314 jmi.setVisible(false);
4320 if (jws2servs.isRunning())
4322 JMenuItem tm = new JMenuItem(
4323 "Still discovering JABA Services");
4324 tm.setEnabled(false);
4327 else if (!Cache.getDefault("SHOW_JWS2_SERVICES", true))
4329 JMenuItem enableJws2 = new JMenuItem(
4330 "Discover Web Services");
4331 enableJws2.setToolTipText(
4332 "Select to start JABA Web Service discovery (or enable option in Web Service preferences)");
4333 enableJws2.setEnabled(true);
4334 enableJws2.addActionListener(new ActionListener()
4338 public void actionPerformed(ActionEvent e)
4340 // start service discoverer, but ignore preference
4341 Desktop.instance.startServiceDiscovery(false,
4345 webService.add(enableJws2);
4349 build_urlServiceMenu(me.webService);
4350 build_fetchdbmenu(webService);
4351 for (JMenu item : wsmenu)
4353 if (item.getItemCount() == 0)
4355 item.setEnabled(false);
4359 item.setEnabled(true);
4362 } catch (Exception e)
4365 "Exception during web service menu building process.",
4370 } catch (Exception e)
4373 buildingMenu = false;
4380 * construct any groupURL type service menu entries.
4384 protected void build_urlServiceMenu(JMenu webService)
4386 // TODO: remove this code when 2.7 is released
4387 // DEBUG - alignmentView
4389 * JMenuItem testAlView = new JMenuItem("Test AlignmentView"); final
4390 * AlignFrame af = this; testAlView.addActionListener(new ActionListener() {
4392 * @Override public void actionPerformed(ActionEvent e) {
4393 * jalview.datamodel.AlignmentView
4394 * .testSelectionViews(af.viewport.getAlignment(),
4395 * af.viewport.getColumnSelection(), af.viewport.selectionGroup); }
4397 * }); webService.add(testAlView);
4399 // TODO: refactor to RestClient discoverer and merge menu entries for
4400 // rest-style services with other types of analysis/calculation service
4401 // SHmmr test client - still being implemented.
4402 // DEBUG - alignmentView
4404 for (jalview.ws.rest.RestClient client : jalview.ws.rest.RestClient
4407 client.attachWSMenuEntry(
4408 JvSwingUtils.findOrCreateMenu(webService, client.getAction()),
4414 * Searches the alignment sequences for xRefs and builds the Show
4415 * Cross-References menu (formerly called Show Products), with database
4416 * sources for which cross-references are found (protein sources for a
4417 * nucleotide alignment and vice versa)
4419 * @return true if Show Cross-references menu should be enabled
4421 public boolean canShowProducts()
4423 SequenceI[] seqs = viewport.getAlignment().getSequencesArray();
4424 AlignmentI dataset = viewport.getAlignment().getDataset();
4426 showProducts.removeAll();
4427 final boolean dna = viewport.getAlignment().isNucleotide();
4429 if (seqs == null || seqs.length == 0)
4431 // nothing to see here.
4435 boolean showp = false;
4438 List<String> ptypes = new CrossRef(seqs, dataset)
4439 .findXrefSourcesForSequences(dna);
4441 for (final String source : ptypes)
4444 final AlignFrame af = this;
4445 JMenuItem xtype = new JMenuItem(source);
4446 xtype.addActionListener(new ActionListener()
4449 public void actionPerformed(ActionEvent e)
4451 showProductsFor(af.viewport.getSequenceSelection(), dna,
4455 showProducts.add(xtype);
4457 showProducts.setVisible(showp);
4458 showProducts.setEnabled(showp);
4459 } catch (Exception e)
4462 "canShowProducts threw an exception - please report to help@jalview.org",
4470 * Finds and displays cross-references for the selected sequences (protein
4471 * products for nucleotide sequences, dna coding sequences for peptides).
4474 * the sequences to show cross-references for
4476 * true if from a nucleotide alignment (so showing proteins)
4478 * the database to show cross-references for
4480 protected void showProductsFor(final SequenceI[] sel, final boolean _odna,
4481 final String source)
4483 new Thread(CrossRefAction.getHandlerFor(sel, _odna, source, this))
4488 * Construct and display a new frame containing the translation of this
4489 * frame's DNA sequences to their aligned protein (amino acid) equivalents.
4492 public void showTranslation_actionPerformed(GeneticCodeI codeTable)
4494 AlignmentI al = null;
4497 Dna dna = new Dna(viewport, viewport.getViewAsVisibleContigs(true));
4499 al = dna.translateCdna(codeTable);
4500 } catch (Exception ex)
4502 Console.error("Exception during translation. Please report this !",
4504 final String msg = MessageManager.getString(
4505 "label.error_when_translating_sequences_submit_bug_report");
4506 final String errorTitle = MessageManager
4507 .getString("label.implementation_error")
4508 + MessageManager.getString("label.translation_failed");
4509 JvOptionPane.showMessageDialog(Desktop.desktop, msg, errorTitle,
4510 JvOptionPane.ERROR_MESSAGE);
4513 if (al == null || al.getHeight() == 0)
4515 final String msg = MessageManager.getString(
4516 "label.select_at_least_three_bases_in_at_least_one_sequence_to_cDNA_translation");
4517 final String errorTitle = MessageManager
4518 .getString("label.translation_failed");
4519 JvOptionPane.showMessageDialog(Desktop.desktop, msg, errorTitle,
4520 JvOptionPane.WARNING_MESSAGE);
4524 AlignFrame af = new AlignFrame(al, DEFAULT_WIDTH, DEFAULT_HEIGHT);
4525 af.setFileFormat(this.currentFileFormat);
4526 final String newTitle = MessageManager
4527 .formatMessage("label.translation_of_params", new Object[]
4528 { this.getTitle(), codeTable.getId() });
4529 af.setTitle(newTitle);
4530 if (Cache.getDefault(Preferences.ENABLE_SPLIT_FRAME, true))
4532 final SequenceI[] seqs = viewport.getSelectionAsNewSequence();
4533 viewport.openSplitFrame(af, new Alignment(seqs));
4537 Desktop.addInternalFrame(af, newTitle, DEFAULT_WIDTH,
4544 * Set the file format
4548 public void setFileFormat(FileFormatI format)
4550 this.currentFileFormat = format;
4554 * Try to load a features file onto the alignment.
4557 * contents or path to retrieve file or a File object
4559 * access mode of file (see jalview.io.AlignFile)
4560 * @return true if features file was parsed correctly.
4562 public boolean parseFeaturesFile(Object file, DataSourceType sourceType)
4565 return avc.parseFeaturesFile(file, sourceType,
4566 Cache.getDefault("RELAXEDSEQIDMATCHING", false));
4571 public void refreshFeatureUI(boolean enableIfNecessary)
4573 // note - currently this is only still here rather than in the controller
4574 // because of the featureSettings hard reference that is yet to be
4576 if (enableIfNecessary)
4578 viewport.setShowSequenceFeatures(true);
4579 showSeqFeatures.setSelected(true);
4585 public void dragEnter(DropTargetDragEvent evt)
4590 public void dragExit(DropTargetEvent evt)
4595 public void dragOver(DropTargetDragEvent evt)
4600 public void dropActionChanged(DropTargetDragEvent evt)
4605 public void drop(DropTargetDropEvent evt)
4607 // JAL-1552 - acceptDrop required before getTransferable call for
4608 // Java's Transferable for native dnd
4609 evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
4610 Transferable t = evt.getTransferable();
4612 final AlignFrame thisaf = this;
4613 final List<Object> files = new ArrayList<>();
4614 List<DataSourceType> protocols = new ArrayList<>();
4618 Desktop.transferFromDropTarget(files, protocols, evt, t);
4619 } catch (Exception e)
4621 e.printStackTrace();
4625 new Thread(new Runnable()
4632 // check to see if any of these files have names matching sequences
4635 SequenceIdMatcher idm = new SequenceIdMatcher(
4636 viewport.getAlignment().getSequencesArray());
4638 * Object[] { String,SequenceI}
4640 ArrayList<Object[]> filesmatched = new ArrayList<>();
4641 ArrayList<Object> filesnotmatched = new ArrayList<>();
4642 for (int i = 0; i < files.size(); i++)
4645 Object file = files.get(i);
4646 String fileName = file.toString();
4648 DataSourceType protocol = (file instanceof File
4649 ? DataSourceType.FILE
4650 : FormatAdapter.checkProtocol(fileName));
4651 if (protocol == DataSourceType.FILE)
4654 if (file instanceof File)
4657 Platform.cacheFileData(fl);
4661 fl = new File(fileName);
4663 pdbfn = fl.getName();
4665 else if (protocol == DataSourceType.URL)
4667 URL url = new URL(fileName);
4668 pdbfn = url.getFile();
4670 if (pdbfn.length() > 0)
4672 // attempt to find a match in the alignment
4673 SequenceI[] mtch = idm.findAllIdMatches(pdbfn);
4674 int l = 0, c = pdbfn.indexOf(".");
4675 while (mtch == null && c != -1)
4680 } while ((c = pdbfn.indexOf(".", l)) > l);
4683 pdbfn = pdbfn.substring(0, l);
4685 mtch = idm.findAllIdMatches(pdbfn);
4692 type = new IdentifyFile().identify(file, protocol);
4693 } catch (Exception ex)
4697 if (type != null && type.isStructureFile())
4699 filesmatched.add(new Object[] { file, protocol, mtch });
4703 // File wasn't named like one of the sequences or wasn't a PDB
4705 filesnotmatched.add(file);
4709 if (filesmatched.size() > 0)
4711 boolean autoAssociate = Cache
4712 .getDefault("AUTOASSOCIATE_PDBANDSEQS", false);
4715 String msg = MessageManager.formatMessage(
4716 "label.automatically_associate_structure_files_with_sequences_same_name",
4718 { Integer.valueOf(filesmatched.size())
4720 String ttl = MessageManager.getString(
4721 "label.automatically_associate_structure_files_by_name");
4722 int choice = JvOptionPane.showConfirmDialog(thisaf, msg,
4723 ttl, JvOptionPane.YES_NO_OPTION);
4724 autoAssociate = choice == JvOptionPane.YES_OPTION;
4728 for (Object[] fm : filesmatched)
4730 // try and associate
4731 // TODO: may want to set a standard ID naming formalism for
4732 // associating PDB files which have no IDs.
4733 for (SequenceI toassoc : (SequenceI[]) fm[2])
4735 PDBEntry pe = new AssociatePdbFileWithSeq()
4736 .associatePdbWithSeq(fm[0].toString(),
4737 (DataSourceType) fm[1], toassoc, false,
4741 System.err.println("Associated file : "
4742 + (fm[0].toString()) + " with "
4743 + toassoc.getDisplayId(true));
4747 // TODO: do we need to update overview ? only if features are
4749 alignPanel.paintAlignment(true, false);
4755 * add declined structures as sequences
4757 for (Object[] o : filesmatched)
4759 filesnotmatched.add(o[0]);
4763 if (filesnotmatched.size() > 0)
4765 if (assocfiles > 0 && (Cache.getDefault(
4766 "AUTOASSOCIATE_PDBANDSEQS_IGNOREOTHERS", false)
4767 || JvOptionPane.showConfirmDialog(thisaf,
4768 "<html>" + MessageManager.formatMessage(
4769 "label.ignore_unmatched_dropped_files_info",
4772 filesnotmatched.size())
4775 MessageManager.getString(
4776 "label.ignore_unmatched_dropped_files"),
4777 JvOptionPane.YES_NO_OPTION) == JvOptionPane.YES_OPTION))
4781 for (Object fn : filesnotmatched)
4783 loadJalviewDataFile(fn, null, null, null);
4787 } catch (Exception ex)
4789 ex.printStackTrace();
4797 * Attempt to load a "dropped" file or URL string, by testing in turn for
4799 * <li>an Annotation file</li>
4800 * <li>a JNet file</li>
4801 * <li>a features file</li>
4802 * <li>else try to interpret as an alignment file</li>
4806 * either a filename or a URL string.
4808 public void loadJalviewDataFile(Object file, DataSourceType sourceType,
4809 FileFormatI format, SequenceI assocSeq)
4811 // BH 2018 was String file
4814 if (sourceType == null)
4816 sourceType = FormatAdapter.checkProtocol(file);
4818 // if the file isn't identified, or not positively identified as some
4819 // other filetype (PFAM is default unidentified alignment file type) then
4820 // try to parse as annotation.
4821 boolean isAnnotation = (format == null
4822 || FileFormat.Pfam.equals(format))
4823 ? new AnnotationFile().annotateAlignmentView(viewport,
4829 // first see if its a T-COFFEE score file
4830 TCoffeeScoreFile tcf = null;
4833 tcf = new TCoffeeScoreFile(file, sourceType);
4836 if (tcf.annotateAlignment(viewport.getAlignment(), true))
4840 new TCoffeeColourScheme(viewport.getAlignment()));
4841 isAnnotation = true;
4842 setStatus(MessageManager.getString(
4843 "label.successfully_pasted_tcoffee_scores_to_alignment"));
4847 // some problem - if no warning its probable that the ID matching
4848 // process didn't work
4849 JvOptionPane.showMessageDialog(Desktop.desktop,
4850 tcf.getWarningMessage() == null
4851 ? MessageManager.getString(
4852 "label.check_file_matches_sequence_ids_alignment")
4853 : tcf.getWarningMessage(),
4854 MessageManager.getString(
4855 "label.problem_reading_tcoffee_score_file"),
4856 JvOptionPane.WARNING_MESSAGE);
4863 } catch (Exception x)
4866 "Exception when processing data source as T-COFFEE score file",
4872 // try to see if its a JNet 'concise' style annotation file *before*
4874 // try to parse it as a features file
4877 format = new IdentifyFile().identify(file, sourceType);
4879 if (FileFormat.ScoreMatrix == format)
4881 ScoreMatrixFile sm = new ScoreMatrixFile(
4882 new FileParse(file, sourceType));
4884 // todo: i18n this message
4885 setStatus(MessageManager.formatMessage(
4886 "label.successfully_loaded_matrix",
4887 sm.getMatrixName()));
4889 else if (FileFormat.Jnet.equals(format))
4891 JPredFile predictions = new JPredFile(file, sourceType);
4892 new JnetAnnotationMaker();
4893 JnetAnnotationMaker.add_annotation(predictions,
4894 viewport.getAlignment(), 0, false);
4895 viewport.getAlignment().setupJPredAlignment();
4896 isAnnotation = true;
4898 // else if (IdentifyFile.FeaturesFile.equals(format))
4899 else if (FileFormat.Features.equals(format))
4901 if (parseFeaturesFile(file, sourceType))
4903 SplitFrame splitFrame = (SplitFrame) getSplitViewContainer();
4904 if (splitFrame != null)
4906 splitFrame.repaint();
4910 alignPanel.paintAlignment(true, true);
4916 new FileLoader().LoadFile(viewport, file, sourceType, format);
4923 alignPanel.adjustAnnotationHeight();
4924 viewport.updateSequenceIdColours();
4925 buildSortByAnnotationScoresMenu();
4926 alignPanel.paintAlignment(true, true);
4928 } catch (Exception ex)
4930 ex.printStackTrace();
4931 } catch (OutOfMemoryError oom)
4936 } catch (Exception x)
4941 + (sourceType != null
4942 ? (sourceType == DataSourceType.PASTE
4944 : "using " + sourceType + " from "
4948 ? "(parsing as '" + format + "' file)"
4950 oom, Desktop.desktop);
4955 * Method invoked by the ChangeListener on the tabbed pane, in other words
4956 * when a different tabbed pane is selected by the user or programmatically.
4959 public void tabSelectionChanged(int index)
4963 alignPanel = alignPanels.get(index);
4964 viewport = alignPanel.av;
4965 avc.setViewportAndAlignmentPanel(viewport, alignPanel);
4966 setMenusFromViewport(viewport);
4967 if (featureSettings != null && featureSettings.isOpen()
4968 && featureSettings.fr.getViewport() != viewport)
4970 if (viewport.isShowSequenceFeatures())
4972 // refresh the featureSettings to reflect UI change
4973 showFeatureSettingsUI();
4977 // close feature settings for this view.
4978 featureSettings.close();
4985 * 'focus' any colour slider that is open to the selected viewport
4987 if (viewport.getConservationSelected())
4989 SliderPanel.setConservationSlider(alignPanel,
4990 viewport.getResidueShading(), alignPanel.getViewName());
4994 SliderPanel.hideConservationSlider();
4996 if (viewport.getAbovePIDThreshold())
4998 SliderPanel.setPIDSliderSource(alignPanel,
4999 viewport.getResidueShading(), alignPanel.getViewName());
5003 SliderPanel.hidePIDSlider();
5007 * If there is a frame linked to this one in a SplitPane, switch it to the
5008 * same view tab index. No infinite recursion of calls should happen, since
5009 * tabSelectionChanged() should not get invoked on setting the selected
5010 * index to an unchanged value. Guard against setting an invalid index
5011 * before the new view peer tab has been created.
5013 final AlignViewportI peer = viewport.getCodingComplement();
5016 AlignFrame linkedAlignFrame = ((AlignViewport) peer)
5017 .getAlignPanel().alignFrame;
5018 if (linkedAlignFrame.tabbedPane.getTabCount() > index)
5020 linkedAlignFrame.tabbedPane.setSelectedIndex(index);
5026 * On right mouse click on view tab, prompt for and set new view name.
5029 public void tabbedPane_mousePressed(MouseEvent e)
5031 if (e.isPopupTrigger())
5033 String msg = MessageManager.getString("label.enter_view_name");
5034 String ttl = tabbedPane.getTitleAt(tabbedPane.getSelectedIndex());
5035 String reply = JvOptionPane.showInputDialog(msg, ttl);
5039 viewport.setViewName(reply);
5040 // TODO warn if reply is in getExistingViewNames()?
5041 tabbedPane.setTitleAt(tabbedPane.getSelectedIndex(), reply);
5046 public AlignViewport getCurrentView()
5052 * Open the dialog for regex description parsing.
5055 protected void extractScores_actionPerformed(ActionEvent e)
5057 ParseProperties pp = new jalview.analysis.ParseProperties(
5058 viewport.getAlignment());
5059 // TODO: verify regex and introduce GUI dialog for version 2.5
5060 // if (pp.getScoresFromDescription("col", "score column ",
5061 // "\\W*([-+]?\\d*\\.?\\d*e?-?\\d*)\\W+([-+]?\\d*\\.?\\d*e?-?\\d*)",
5063 if (pp.getScoresFromDescription("description column",
5064 "score in description column ", "\\W*([-+eE0-9.]+)", true) > 0)
5066 buildSortByAnnotationScoresMenu();
5074 * jalview.jbgui.GAlignFrame#showDbRefs_actionPerformed(java.awt.event.ActionEvent
5078 protected void showDbRefs_actionPerformed(ActionEvent e)
5080 viewport.setShowDBRefs(showDbRefsMenuitem.isSelected());
5086 * @seejalview.jbgui.GAlignFrame#showNpFeats_actionPerformed(java.awt.event.
5090 protected void showNpFeats_actionPerformed(ActionEvent e)
5092 viewport.setShowNPFeats(showNpFeatsMenuitem.isSelected());
5096 * find the viewport amongst the tabs in this alignment frame and close that
5101 public boolean closeView(AlignViewportI av)
5105 this.closeMenuItem_actionPerformed(false);
5108 Component[] comp = tabbedPane.getComponents();
5109 for (int i = 0; comp != null && i < comp.length; i++)
5111 if (comp[i] instanceof AlignmentPanel)
5113 if (((AlignmentPanel) comp[i]).av == av)
5116 closeView((AlignmentPanel) comp[i]);
5124 protected void build_fetchdbmenu(JMenu webService)
5126 // Temporary hack - DBRef Fetcher always top level ws entry.
5127 // TODO We probably want to store a sequence database checklist in
5128 // preferences and have checkboxes.. rather than individual sources selected
5130 final JMenu rfetch = new JMenu(
5131 MessageManager.getString("action.fetch_db_references"));
5132 rfetch.setToolTipText(MessageManager.getString(
5133 "label.retrieve_parse_sequence_database_records_alignment_or_selected_sequences"));
5134 webService.add(rfetch);
5136 final JCheckBoxMenuItem trimrs = new JCheckBoxMenuItem(
5137 MessageManager.getString("option.trim_retrieved_seqs"));
5138 trimrs.setToolTipText(
5139 MessageManager.getString("label.trim_retrieved_sequences"));
5141 Cache.getDefault(DBRefFetcher.TRIM_RETRIEVED_SEQUENCES, true));
5142 trimrs.addActionListener(new ActionListener()
5145 public void actionPerformed(ActionEvent e)
5147 trimrs.setSelected(trimrs.isSelected());
5148 Cache.setProperty(DBRefFetcher.TRIM_RETRIEVED_SEQUENCES,
5149 Boolean.valueOf(trimrs.isSelected()).toString());
5153 JMenuItem fetchr = new JMenuItem(
5154 MessageManager.getString("label.standard_databases"));
5155 fetchr.setToolTipText(
5156 MessageManager.getString("label.fetch_embl_uniprot"));
5157 fetchr.addActionListener(new ActionListener()
5161 public void actionPerformed(ActionEvent e)
5163 new Thread(new Runnable()
5168 boolean isNucleotide = alignPanel.alignFrame.getViewport()
5169 .getAlignment().isNucleotide();
5170 DBRefFetcher dbRefFetcher = new DBRefFetcher(
5171 alignPanel.av.getSequenceSelection(),
5172 alignPanel.alignFrame, null,
5173 alignPanel.alignFrame.featureSettings, isNucleotide);
5174 dbRefFetcher.addListener(new FetchFinishedListenerI()
5177 public void finished()
5180 for (FeatureSettingsModelI srcSettings : dbRefFetcher
5181 .getFeatureSettingsModels())
5184 alignPanel.av.mergeFeaturesStyle(srcSettings);
5186 AlignFrame.this.setMenusForViewport();
5189 dbRefFetcher.fetchDBRefs(false);
5197 new Thread(new Runnable()
5202 final jalview.ws.SequenceFetcher sf = jalview.gui.SequenceFetcher
5203 .getSequenceFetcherSingleton();
5204 javax.swing.SwingUtilities.invokeLater(new Runnable()
5209 String[] dbclasses = sf.getNonAlignmentSources();
5210 List<DbSourceProxy> otherdb;
5211 JMenu dfetch = new JMenu();
5212 JMenu ifetch = new JMenu();
5213 JMenuItem fetchr = null;
5214 int comp = 0, icomp = 0, mcomp = 15;
5215 String mname = null;
5217 for (String dbclass : dbclasses)
5219 otherdb = sf.getSourceProxy(dbclass);
5220 // add a single entry for this class, or submenu allowing 'fetch
5222 if (otherdb == null || otherdb.size() < 1)
5228 mname = "From " + dbclass;
5230 if (otherdb.size() == 1)
5232 final DbSourceProxy[] dassource = otherdb
5233 .toArray(new DbSourceProxy[0]);
5234 DbSourceProxy src = otherdb.get(0);
5235 fetchr = new JMenuItem(src.getDbSource());
5236 fetchr.addActionListener(new ActionListener()
5240 public void actionPerformed(ActionEvent e)
5242 new Thread(new Runnable()
5248 boolean isNucleotide = alignPanel.alignFrame
5249 .getViewport().getAlignment()
5251 DBRefFetcher dbRefFetcher = new DBRefFetcher(
5252 alignPanel.av.getSequenceSelection(),
5253 alignPanel.alignFrame, dassource,
5254 alignPanel.alignFrame.featureSettings,
5257 .addListener(new FetchFinishedListenerI()
5260 public void finished()
5262 FeatureSettingsModelI srcSettings = dassource[0]
5263 .getFeatureColourScheme();
5264 alignPanel.av.mergeFeaturesStyle(
5266 AlignFrame.this.setMenusForViewport();
5269 dbRefFetcher.fetchDBRefs(false);
5275 fetchr.setToolTipText(JvSwingUtils.wrapTooltip(true,
5276 MessageManager.formatMessage(
5277 "label.fetch_retrieve_from", new Object[]
5278 { src.getDbName() })));
5284 final DbSourceProxy[] dassource = otherdb
5285 .toArray(new DbSourceProxy[0]);
5287 DbSourceProxy src = otherdb.get(0);
5288 fetchr = new JMenuItem(MessageManager
5289 .formatMessage("label.fetch_all_param", new Object[]
5290 { src.getDbSource() }));
5291 fetchr.addActionListener(new ActionListener()
5294 public void actionPerformed(ActionEvent e)
5296 new Thread(new Runnable()
5302 boolean isNucleotide = alignPanel.alignFrame
5303 .getViewport().getAlignment()
5305 DBRefFetcher dbRefFetcher = new DBRefFetcher(
5306 alignPanel.av.getSequenceSelection(),
5307 alignPanel.alignFrame, dassource,
5308 alignPanel.alignFrame.featureSettings,
5311 .addListener(new FetchFinishedListenerI()
5314 public void finished()
5316 AlignFrame.this.setMenusForViewport();
5319 dbRefFetcher.fetchDBRefs(false);
5325 fetchr.setToolTipText(JvSwingUtils.wrapTooltip(true,
5326 MessageManager.formatMessage(
5327 "label.fetch_retrieve_from_all_sources",
5329 { Integer.valueOf(otherdb.size())
5331 src.getDbSource(), src.getDbName() })));
5334 // and then build the rest of the individual menus
5335 ifetch = new JMenu(MessageManager.formatMessage(
5336 "label.source_from_db_source", new Object[]
5337 { src.getDbSource() }));
5339 String imname = null;
5341 for (DbSourceProxy sproxy : otherdb)
5343 String dbname = sproxy.getDbName();
5344 String sname = dbname.length() > 5
5345 ? dbname.substring(0, 5) + "..."
5347 String msname = dbname.length() > 10
5348 ? dbname.substring(0, 10) + "..."
5352 imname = MessageManager
5353 .formatMessage("label.from_msname", new Object[]
5356 fetchr = new JMenuItem(msname);
5357 final DbSourceProxy[] dassrc = { sproxy };
5358 fetchr.addActionListener(new ActionListener()
5362 public void actionPerformed(ActionEvent e)
5364 new Thread(new Runnable()
5370 boolean isNucleotide = alignPanel.alignFrame
5371 .getViewport().getAlignment()
5373 DBRefFetcher dbRefFetcher = new DBRefFetcher(
5374 alignPanel.av.getSequenceSelection(),
5375 alignPanel.alignFrame, dassrc,
5376 alignPanel.alignFrame.featureSettings,
5379 .addListener(new FetchFinishedListenerI()
5382 public void finished()
5384 AlignFrame.this.setMenusForViewport();
5387 dbRefFetcher.fetchDBRefs(false);
5393 fetchr.setToolTipText(
5394 "<html>" + MessageManager.formatMessage(
5395 "label.fetch_retrieve_from", new Object[]
5399 if (++icomp >= mcomp || i == (otherdb.size()))
5401 ifetch.setText(MessageManager.formatMessage(
5402 "label.source_to_target", imname, sname));
5404 ifetch = new JMenu();
5412 if (comp >= mcomp || dbi >= (dbclasses.length))
5414 dfetch.setText(MessageManager.formatMessage(
5415 "label.source_to_target", mname, dbclass));
5417 dfetch = new JMenu();
5430 * Left justify the whole alignment.
5433 protected void justifyLeftMenuItem_actionPerformed(ActionEvent e)
5435 AlignmentI al = viewport.getAlignment();
5437 viewport.firePropertyChange("alignment", null, al);
5441 * Right justify the whole alignment.
5444 protected void justifyRightMenuItem_actionPerformed(ActionEvent e)
5446 AlignmentI al = viewport.getAlignment();
5448 viewport.firePropertyChange("alignment", null, al);
5452 public void setShowSeqFeatures(boolean b)
5454 showSeqFeatures.setSelected(b);
5455 viewport.setShowSequenceFeatures(b);
5462 * jalview.jbgui.GAlignFrame#showUnconservedMenuItem_actionPerformed(java.
5463 * awt.event.ActionEvent)
5466 protected void showUnconservedMenuItem_actionPerformed(ActionEvent e)
5468 viewport.setShowUnconserved(showNonconservedMenuItem.getState());
5469 alignPanel.paintAlignment(false, false);
5476 * jalview.jbgui.GAlignFrame#showGroupConsensus_actionPerformed(java.awt.event
5480 protected void showGroupConsensus_actionPerformed(ActionEvent e)
5482 viewport.setShowGroupConsensus(showGroupConsensus.getState());
5483 alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
5491 * jalview.jbgui.GAlignFrame#showGroupConservation_actionPerformed(java.awt
5492 * .event.ActionEvent)
5495 protected void showGroupConservation_actionPerformed(ActionEvent e)
5497 viewport.setShowGroupConservation(showGroupConservation.getState());
5498 alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
5505 * jalview.jbgui.GAlignFrame#showConsensusHistogram_actionPerformed(java.awt
5506 * .event.ActionEvent)
5509 protected void showConsensusHistogram_actionPerformed(ActionEvent e)
5511 viewport.setShowConsensusHistogram(showConsensusHistogram.getState());
5512 alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
5519 * jalview.jbgui.GAlignFrame#showConsensusProfile_actionPerformed(java.awt
5520 * .event.ActionEvent)
5523 protected void showSequenceLogo_actionPerformed(ActionEvent e)
5525 viewport.setShowSequenceLogo(showSequenceLogo.getState());
5526 alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
5530 protected void normaliseSequenceLogo_actionPerformed(ActionEvent e)
5532 showSequenceLogo.setState(true);
5533 viewport.setShowSequenceLogo(true);
5534 viewport.setNormaliseSequenceLogo(normaliseSequenceLogo.getState());
5535 alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
5539 protected void applyAutoAnnotationSettings_actionPerformed(ActionEvent e)
5541 alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
5548 * jalview.jbgui.GAlignFrame#makeGrpsFromSelection_actionPerformed(java.awt
5549 * .event.ActionEvent)
5552 protected void makeGrpsFromSelection_actionPerformed(ActionEvent e)
5554 if (avc.makeGroupsFromSelection())
5556 PaintRefresher.Refresh(this, viewport.getSequenceSetId());
5557 alignPanel.updateAnnotation();
5558 alignPanel.paintAlignment(true,
5559 viewport.needToUpdateStructureViews());
5563 public void clearAlignmentSeqRep()
5565 // TODO refactor alignmentseqrep to controller
5566 if (viewport.getAlignment().hasSeqrep())
5568 viewport.getAlignment().setSeqrep(null);
5569 PaintRefresher.Refresh(this, viewport.getSequenceSetId());
5570 alignPanel.updateAnnotation();
5571 alignPanel.paintAlignment(true, true);
5576 protected void createGroup_actionPerformed(ActionEvent e)
5578 if (avc.createGroup())
5580 if (applyAutoAnnotationSettings.isSelected())
5582 alignPanel.updateAnnotation(true, false);
5584 alignPanel.alignmentChanged();
5589 protected void unGroup_actionPerformed(ActionEvent e)
5593 alignPanel.alignmentChanged();
5598 * make the given alignmentPanel the currently selected tab
5600 * @param alignmentPanel
5602 public void setDisplayedView(AlignmentPanel alignmentPanel)
5604 if (!viewport.getSequenceSetId()
5605 .equals(alignmentPanel.av.getSequenceSetId()))
5607 throw new Error(MessageManager.getString(
5608 "error.implementation_error_cannot_show_view_alignment_frame"));
5610 if (tabbedPane != null && tabbedPane.getTabCount() > 0 && alignPanels
5611 .indexOf(alignmentPanel) != tabbedPane.getSelectedIndex())
5613 tabbedPane.setSelectedIndex(alignPanels.indexOf(alignmentPanel));
5618 * Action on selection of menu options to Show or Hide annotations.
5621 * @param forSequences
5622 * update sequence-related annotations
5623 * @param forAlignment
5624 * update non-sequence-related annotations
5627 protected void setAnnotationsVisibility(boolean visible,
5628 boolean forSequences, boolean forAlignment)
5630 AlignmentAnnotation[] anns = alignPanel.getAlignment()
5631 .getAlignmentAnnotation();
5636 for (AlignmentAnnotation aa : anns)
5639 * don't display non-positional annotations on an alignment
5641 if (aa.annotations == null)
5645 boolean apply = (aa.sequenceRef == null && forAlignment)
5646 || (aa.sequenceRef != null && forSequences);
5649 aa.visible = visible;
5652 alignPanel.validateAnnotationDimensions(true);
5653 alignPanel.alignmentChanged();
5657 * Store selected annotation sort order for the view and repaint.
5660 protected void sortAnnotations_actionPerformed()
5662 this.alignPanel.av.setSortAnnotationsBy(getAnnotationSortOrder());
5664 .setShowAutocalculatedAbove(isShowAutoCalculatedAbove());
5665 alignPanel.paintAlignment(false, false);
5670 * @return alignment panels in this alignment frame
5672 public List<? extends AlignmentViewPanel> getAlignPanels()
5674 // alignPanels is never null
5675 // return alignPanels == null ? Arrays.asList(alignPanel) : alignPanels;
5680 * Open a new alignment window, with the cDNA associated with this (protein)
5681 * alignment, aligned as is the protein.
5683 protected void viewAsCdna_actionPerformed()
5685 // TODO no longer a menu action - refactor as required
5686 final AlignmentI alignment = getViewport().getAlignment();
5687 List<AlignedCodonFrame> mappings = alignment.getCodonFrames();
5688 if (mappings == null)
5692 List<SequenceI> cdnaSeqs = new ArrayList<>();
5693 for (SequenceI aaSeq : alignment.getSequences())
5695 for (AlignedCodonFrame acf : mappings)
5697 SequenceI dnaSeq = acf.getDnaForAaSeq(aaSeq.getDatasetSequence());
5701 * There is a cDNA mapping for this protein sequence - add to new
5702 * alignment. It will share the same dataset sequence as other mapped
5703 * cDNA (no new mappings need to be created).
5705 final Sequence newSeq = new Sequence(dnaSeq);
5706 newSeq.setDatasetSequence(dnaSeq);
5707 cdnaSeqs.add(newSeq);
5711 if (cdnaSeqs.size() == 0)
5713 // show a warning dialog no mapped cDNA
5716 AlignmentI cdna = new Alignment(
5717 cdnaSeqs.toArray(new SequenceI[cdnaSeqs.size()]));
5718 GAlignFrame alignFrame = new AlignFrame(cdna, AlignFrame.DEFAULT_WIDTH,
5719 AlignFrame.DEFAULT_HEIGHT);
5720 cdna.alignAs(alignment);
5721 String newtitle = "cDNA " + MessageManager.getString("label.for") + " "
5723 Desktop.addInternalFrame(alignFrame, newtitle, AlignFrame.DEFAULT_WIDTH,
5724 AlignFrame.DEFAULT_HEIGHT);
5728 * Set visibility of dna/protein complement view (available when shown in a
5734 protected void showComplement_actionPerformed(boolean show)
5736 SplitContainerI sf = getSplitViewContainer();
5739 sf.setComplementVisible(this, show);
5744 * Generate the reverse (optionally complemented) of the selected sequences,
5745 * and add them to the alignment
5748 protected void showReverse_actionPerformed(boolean complement)
5750 AlignmentI al = null;
5753 Dna dna = new Dna(viewport, viewport.getViewAsVisibleContigs(true));
5754 al = dna.reverseCdna(complement);
5755 viewport.addAlignment(al, "");
5756 addHistoryItem(new EditCommand(
5757 MessageManager.getString("label.add_sequences"), Action.PASTE,
5758 al.getSequencesArray(), 0, al.getWidth(),
5759 viewport.getAlignment()));
5760 } catch (Exception ex)
5762 System.err.println(ex.getMessage());
5768 * Try to run a script in the Groovy console, having first ensured that this
5769 * AlignFrame is set as currentAlignFrame in Desktop, to allow the script to
5770 * be targeted at this alignment.
5773 protected void runGroovy_actionPerformed()
5775 Jalview.setCurrentAlignFrame(this);
5776 groovy.ui.Console console = Desktop.getGroovyConsole();
5777 if (console != null)
5781 console.runScript();
5782 } catch (Exception ex)
5784 System.err.println((ex.toString()));
5785 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
5786 MessageManager.getString("label.couldnt_run_groovy_script"),
5787 MessageManager.getString("label.groovy_support_failed"),
5788 JvOptionPane.ERROR_MESSAGE);
5793 System.err.println("Can't run Groovy script as console not found");
5798 * Hides columns containing (or not containing) a specified feature, provided
5799 * that would not leave all columns hidden
5801 * @param featureType
5802 * @param columnsContaining
5805 public boolean hideFeatureColumns(String featureType,
5806 boolean columnsContaining)
5808 boolean notForHiding = avc.markColumnsContainingFeatures(
5809 columnsContaining, false, false, featureType);
5812 if (avc.markColumnsContainingFeatures(!columnsContaining, false,
5813 false, featureType))
5815 getViewport().hideSelectedColumns();
5823 protected void selectHighlightedColumns_actionPerformed(
5824 ActionEvent actionEvent)
5826 // include key modifier check in case user selects from menu
5827 avc.markHighlightedColumns(
5828 (actionEvent.getModifiers() & ActionEvent.ALT_MASK) != 0, true,
5829 (actionEvent.getModifiers() & (ActionEvent.META_MASK
5830 | ActionEvent.CTRL_MASK)) != 0);
5834 protected void copyHighlightedColumns_actionPerformed(
5835 ActionEvent actionEvent)
5837 avc.copyHighlightedRegionsToClipboard();
5841 * Rebuilds the Colour menu, including any user-defined colours which have
5842 * been loaded either on startup or during the session
5844 public void buildColourMenu()
5846 colourMenu.removeAll();
5848 colourMenu.add(applyToAllGroups);
5849 colourMenu.add(textColour);
5850 colourMenu.addSeparator();
5852 ButtonGroup bg = ColourMenuHelper.addMenuItems(colourMenu, this,
5853 viewport.getAlignment(), false);
5855 colourMenu.add(annotationColour);
5856 bg.add(annotationColour);
5857 colourMenu.addSeparator();
5858 colourMenu.add(conservationMenuItem);
5859 colourMenu.add(modifyConservation);
5860 colourMenu.add(abovePIDThreshold);
5861 colourMenu.add(modifyPID);
5863 ColourSchemeI colourScheme = viewport.getGlobalColourScheme();
5864 ColourMenuHelper.setColourSelected(colourMenu, colourScheme);
5868 * Open a dialog (if not already open) that allows the user to select and
5869 * calculate PCA or Tree analysis
5871 protected void openTreePcaDialog()
5873 if (alignPanel.getCalculationDialog() == null)
5875 new CalculationChooser(AlignFrame.this);
5880 protected void loadVcf_actionPerformed()
5882 JalviewFileChooser chooser = new JalviewFileChooser(
5883 Cache.getProperty("LAST_DIRECTORY"));
5884 chooser.setFileView(new JalviewFileView());
5885 chooser.setDialogTitle(MessageManager.getString("label.load_vcf_file"));
5886 chooser.setToolTipText(MessageManager.getString("label.load_vcf_file"));
5887 final AlignFrame us = this;
5888 chooser.setResponseHandler(0, () -> {
5889 String choice = chooser.getSelectedFile().getPath();
5890 Cache.setProperty("LAST_DIRECTORY", choice);
5891 SequenceI[] seqs = viewport.getAlignment().getSequencesArray();
5892 new VCFLoader(choice).loadVCF(seqs, us);
5895 chooser.showOpenDialog(null);
5899 private Rectangle lastFeatureSettingsBounds = null;
5902 public void setFeatureSettingsGeometry(Rectangle bounds)
5904 lastFeatureSettingsBounds = bounds;
5908 public Rectangle getFeatureSettingsGeometry()
5910 return lastFeatureSettingsBounds;
5914 class PrintThread extends Thread
5918 public PrintThread(AlignmentPanel ap)
5923 static PageFormat pf;
5928 PrinterJob printJob = PrinterJob.getPrinterJob();
5932 printJob.setPrintable(ap, pf);
5936 printJob.setPrintable(ap);
5939 if (printJob.printDialog())
5944 } catch (Exception PrintException)
5946 PrintException.printStackTrace();