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.Component;
25 import java.awt.GridLayout;
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.ItemEvent;
40 import java.awt.event.ItemListener;
41 import java.awt.event.KeyAdapter;
42 import java.awt.event.KeyEvent;
43 import java.awt.event.MouseAdapter;
44 import java.awt.event.MouseEvent;
45 import java.awt.print.PageFormat;
46 import java.awt.print.PrinterJob;
47 import java.beans.PropertyChangeEvent;
50 import java.util.ArrayList;
51 import java.util.Arrays;
52 import java.util.Deque;
53 import java.util.Enumeration;
54 import java.util.Hashtable;
55 import java.util.List;
57 import java.util.Vector;
59 import javax.swing.JButton;
60 import javax.swing.JCheckBoxMenuItem;
61 import javax.swing.JEditorPane;
62 import javax.swing.JInternalFrame;
63 import javax.swing.JLabel;
64 import javax.swing.JLayeredPane;
65 import javax.swing.JMenu;
66 import javax.swing.JMenuItem;
67 import javax.swing.JOptionPane;
68 import javax.swing.JPanel;
69 import javax.swing.JProgressBar;
70 import javax.swing.JRadioButtonMenuItem;
71 import javax.swing.JScrollPane;
72 import javax.swing.SwingUtilities;
74 import jalview.analysis.AAFrequency;
75 import jalview.analysis.AlignmentSorter;
76 import jalview.analysis.AlignmentUtils;
77 import jalview.analysis.Conservation;
78 import jalview.analysis.CrossRef;
79 import jalview.analysis.Dna;
80 import jalview.analysis.ParseProperties;
81 import jalview.analysis.SequenceIdMatcher;
82 import jalview.api.AlignViewControllerGuiI;
83 import jalview.api.AlignViewControllerI;
84 import jalview.api.AlignViewportI;
85 import jalview.api.AlignmentViewPanel;
86 import jalview.api.SplitContainerI;
87 import jalview.api.ViewStyleI;
88 import jalview.api.analysis.ScoreModelI;
89 import jalview.bin.Cache;
90 import jalview.commands.CommandI;
91 import jalview.commands.EditCommand;
92 import jalview.commands.EditCommand.Action;
93 import jalview.commands.OrderCommand;
94 import jalview.commands.RemoveGapColCommand;
95 import jalview.commands.RemoveGapsCommand;
96 import jalview.commands.SlideSequencesCommand;
97 import jalview.commands.TrimRegionCommand;
98 import jalview.datamodel.AlignedCodonFrame;
99 import jalview.datamodel.Alignment;
100 import jalview.datamodel.AlignmentAnnotation;
101 import jalview.datamodel.AlignmentI;
102 import jalview.datamodel.AlignmentOrder;
103 import jalview.datamodel.AlignmentView;
104 import jalview.datamodel.ColumnSelection;
105 import jalview.datamodel.PDBEntry;
106 import jalview.datamodel.SeqCigar;
107 import jalview.datamodel.Sequence;
108 import jalview.datamodel.SequenceGroup;
109 import jalview.datamodel.SequenceI;
110 import jalview.gui.ViewSelectionMenu.ViewSetProvider;
111 import jalview.io.AlignmentProperties;
112 import jalview.io.AnnotationFile;
113 import jalview.io.BioJsHTMLOutput;
114 import jalview.io.FeaturesFile;
115 import jalview.io.FileLoader;
116 import jalview.io.FormatAdapter;
117 import jalview.io.HtmlSvgOutput;
118 import jalview.io.IdentifyFile;
119 import jalview.io.JalviewFileChooser;
120 import jalview.io.JalviewFileView;
121 import jalview.io.JnetAnnotationMaker;
122 import jalview.io.NewickFile;
123 import jalview.io.TCoffeeScoreFile;
124 import jalview.jbgui.GAlignFrame;
125 import jalview.schemes.Blosum62ColourScheme;
126 import jalview.schemes.BuriedColourScheme;
127 import jalview.schemes.ClustalxColourScheme;
128 import jalview.schemes.ColourSchemeI;
129 import jalview.schemes.ColourSchemeProperty;
130 import jalview.schemes.HelixColourScheme;
131 import jalview.schemes.HydrophobicColourScheme;
132 import jalview.schemes.NucleotideColourScheme;
133 import jalview.schemes.PIDColourScheme;
134 import jalview.schemes.PurinePyrimidineColourScheme;
135 import jalview.schemes.RNAHelicesColourChooser;
136 import jalview.schemes.ResidueProperties;
137 import jalview.schemes.StrandColourScheme;
138 import jalview.schemes.TCoffeeColourScheme;
139 import jalview.schemes.TaylorColourScheme;
140 import jalview.schemes.TurnColourScheme;
141 import jalview.schemes.UserColourScheme;
142 import jalview.schemes.ZappoColourScheme;
143 import jalview.structure.StructureSelectionManager;
144 import jalview.util.MessageManager;
145 import jalview.viewmodel.AlignmentViewport;
146 import jalview.ws.jws1.Discoverer;
147 import jalview.ws.jws2.Jws2Discoverer;
148 import jalview.ws.jws2.jabaws2.Jws2Instance;
149 import jalview.ws.seqfetcher.DbSourceProxy;
155 * @version $Revision$
157 public class AlignFrame extends GAlignFrame implements DropTargetListener,
158 IProgressIndicator, AlignViewControllerGuiI
161 public static final int DEFAULT_WIDTH = 700;
163 public static final int DEFAULT_HEIGHT = 500;
166 * The currently displayed panel (selected tabbed view if more than one)
168 public AlignmentPanel alignPanel;
170 AlignViewport viewport;
172 public AlignViewControllerI avc;
174 List<AlignmentPanel> alignPanels = new ArrayList<AlignmentPanel>();
177 * Last format used to load or save alignments in this window
179 String currentFileFormat = null;
182 * Current filename for this alignment
184 String fileName = null;
187 * Creates a new AlignFrame object with specific width and height.
193 public AlignFrame(AlignmentI al, int width, int height)
195 this(al, null, width, height);
199 * Creates a new AlignFrame object with specific width, height and
205 * @param sequenceSetId
207 public AlignFrame(AlignmentI al, int width, int height,
208 String sequenceSetId)
210 this(al, null, width, height, sequenceSetId);
214 * Creates a new AlignFrame object with specific width, height and
220 * @param sequenceSetId
223 public AlignFrame(AlignmentI al, int width, int height,
224 String sequenceSetId, String viewId)
226 this(al, null, width, height, sequenceSetId, viewId);
230 * new alignment window with hidden columns
234 * @param hiddenColumns
235 * ColumnSelection or null
237 * Width of alignment frame
241 public AlignFrame(AlignmentI al, ColumnSelection hiddenColumns,
242 int width, int height)
244 this(al, hiddenColumns, width, height, null);
248 * Create alignment frame for al with hiddenColumns, a specific width and
249 * height, and specific sequenceId
252 * @param hiddenColumns
255 * @param sequenceSetId
258 public AlignFrame(AlignmentI al, ColumnSelection hiddenColumns,
259 int width, int height, String sequenceSetId)
261 this(al, hiddenColumns, width, height, sequenceSetId, null);
265 * Create alignment frame for al with hiddenColumns, a specific width and
266 * height, and specific sequenceId
269 * @param hiddenColumns
272 * @param sequenceSetId
277 public AlignFrame(AlignmentI al, ColumnSelection hiddenColumns,
278 int width, int height, String sequenceSetId, String viewId)
280 setSize(width, height);
282 if (al.getDataset() == null)
287 viewport = new AlignViewport(al, hiddenColumns, sequenceSetId, viewId);
289 alignPanel = new AlignmentPanel(this, viewport);
292 addAlignmentPanel(alignPanel, true);
297 * Make a new AlignFrame from existing alignmentPanels
304 public AlignFrame(AlignmentPanel ap)
308 addAlignmentPanel(ap, false);
313 * initalise the alignframe from the underlying viewport data and the
318 avc = new jalview.controller.AlignViewController(this, viewport,
320 if (viewport.getAlignmentConservationAnnotation() == null)
322 BLOSUM62Colour.setEnabled(false);
323 conservationMenuItem.setEnabled(false);
324 modifyConservation.setEnabled(false);
325 // PIDColour.setEnabled(false);
326 // abovePIDThreshold.setEnabled(false);
327 // modifyPID.setEnabled(false);
330 String sortby = jalview.bin.Cache.getDefault("SORT_ALIGNMENT",
333 if (sortby.equals("Id"))
335 sortIDMenuItem_actionPerformed(null);
337 else if (sortby.equals("Pairwise Identity"))
339 sortPairwiseMenuItem_actionPerformed(null);
342 if (Desktop.desktop != null)
344 this.setDropTarget(new java.awt.dnd.DropTarget(this, this));
345 addServiceListeners();
346 setGUINucleotide(viewport.getAlignment().isNucleotide());
349 setMenusFromViewport(viewport);
350 buildSortByAnnotationScoresMenu();
353 if (viewport.getWrapAlignment())
355 wrapMenuItem_actionPerformed(null);
358 if (jalview.bin.Cache.getDefault("SHOW_OVERVIEW", false))
360 this.overviewMenuItem_actionPerformed(null);
365 final List<AlignmentPanel> selviews = new ArrayList<AlignmentPanel>();
366 final List<AlignmentPanel> origview = new ArrayList<AlignmentPanel>();
367 ViewSelectionMenu vsel = new ViewSelectionMenu("Transfer colours from",
368 new ViewSetProvider()
372 public AlignmentPanel[] getAllAlignmentPanels()
375 origview.add(alignPanel);
376 return Desktop.getAlignmentPanels(null);
378 }, selviews, new ItemListener()
382 public void itemStateChanged(ItemEvent e)
384 if (origview.size() > 0)
386 ViewStyleI vs = selviews.get(0).getAlignViewport()
388 origview.get(0).getAlignViewport().setViewStyle(vs);
389 AlignViewportI complement = origview.get(0)
390 .getAlignViewport().getCodingComplement();
391 if (complement != null)
393 AlignFrame af = Desktop.getAlignFrameFor(complement);
394 if (complement.isNucleotide())
396 complement.setViewStyle(vs);
397 vs.setCharWidth(vs.getCharWidth() / 3);
401 int rw = vs.getCharWidth();
402 vs.setCharWidth(rw * 3);
403 complement.setViewStyle(vs);
406 af.alignPanel.updateLayout();
407 af.setMenusForViewport();
409 origview.get(0).updateLayout();
410 origview.get(0).setSelected(true);
411 origview.get(0).alignFrame.setMenusForViewport();
416 formatMenu.add(vsel);
421 * Change the filename and format for the alignment, and enable the 'reload'
422 * button functionality.
429 public void setFileName(String file, String format)
432 setFileFormat(format);
433 reload.setEnabled(true);
437 * Add a KeyListener with handlers for various KeyPressed and KeyReleased
440 void addKeyListener()
442 addKeyListener(new KeyAdapter()
445 public void keyPressed(KeyEvent evt)
447 if (viewport.cursorMode
448 && ((evt.getKeyCode() >= KeyEvent.VK_0 && evt.getKeyCode() <= KeyEvent.VK_9) || (evt
449 .getKeyCode() >= KeyEvent.VK_NUMPAD0 && evt
450 .getKeyCode() <= KeyEvent.VK_NUMPAD9))
451 && Character.isDigit(evt.getKeyChar()))
453 alignPanel.getSeqPanel().numberPressed(evt.getKeyChar());
456 switch (evt.getKeyCode())
459 case 27: // escape key
460 deselectAllSequenceMenuItem_actionPerformed(null);
464 case KeyEvent.VK_DOWN:
465 if (evt.isAltDown() || !viewport.cursorMode)
467 moveSelectedSequences(false);
469 if (viewport.cursorMode)
471 alignPanel.getSeqPanel().moveCursor(0, 1);
476 if (evt.isAltDown() || !viewport.cursorMode)
478 moveSelectedSequences(true);
480 if (viewport.cursorMode)
482 alignPanel.getSeqPanel().moveCursor(0, -1);
487 case KeyEvent.VK_LEFT:
488 if (evt.isAltDown() || !viewport.cursorMode)
490 slideSequences(false, alignPanel.getSeqPanel().getKeyboardNo1());
494 alignPanel.getSeqPanel().moveCursor(-1, 0);
499 case KeyEvent.VK_RIGHT:
500 if (evt.isAltDown() || !viewport.cursorMode)
502 slideSequences(true, alignPanel.getSeqPanel().getKeyboardNo1());
506 alignPanel.getSeqPanel().moveCursor(1, 0);
510 case KeyEvent.VK_SPACE:
511 if (viewport.cursorMode)
513 alignPanel.getSeqPanel().insertGapAtCursor(evt.isControlDown()
514 || evt.isShiftDown() || evt.isAltDown());
518 // case KeyEvent.VK_A:
519 // if (viewport.cursorMode)
521 // alignPanel.seqPanel.insertNucAtCursor(false,"A");
522 // //System.out.println("A");
526 * case KeyEvent.VK_CLOSE_BRACKET: if (viewport.cursorMode) {
527 * System.out.println("closing bracket"); } break;
529 case KeyEvent.VK_DELETE:
530 case KeyEvent.VK_BACK_SPACE:
531 if (!viewport.cursorMode)
533 cut_actionPerformed(null);
537 alignPanel.getSeqPanel().deleteGapAtCursor(evt.isControlDown()
538 || evt.isShiftDown() || evt.isAltDown());
544 if (viewport.cursorMode)
546 alignPanel.getSeqPanel().setCursorRow();
550 if (viewport.cursorMode && !evt.isControlDown())
552 alignPanel.getSeqPanel().setCursorColumn();
556 if (viewport.cursorMode)
558 alignPanel.getSeqPanel().setCursorPosition();
562 case KeyEvent.VK_ENTER:
563 case KeyEvent.VK_COMMA:
564 if (viewport.cursorMode)
566 alignPanel.getSeqPanel().setCursorRowAndColumn();
571 if (viewport.cursorMode)
573 alignPanel.getSeqPanel().setSelectionAreaAtCursor(true);
577 if (viewport.cursorMode)
579 alignPanel.getSeqPanel().setSelectionAreaAtCursor(false);
584 viewport.cursorMode = !viewport.cursorMode;
585 statusBar.setText(MessageManager.formatMessage(
586 "label.keyboard_editing_mode", new String[]
587 { (viewport.cursorMode ? "on" : "off") }));
588 if (viewport.cursorMode)
590 alignPanel.getSeqPanel().seqCanvas.cursorX = viewport.startRes;
591 alignPanel.getSeqPanel().seqCanvas.cursorY = viewport.startSeq;
593 alignPanel.getSeqPanel().seqCanvas.repaint();
599 Help.showHelpWindow();
600 } catch (Exception ex)
602 ex.printStackTrace();
607 boolean toggleSeqs = !evt.isControlDown();
608 boolean toggleCols = !evt.isShiftDown();
609 toggleHiddenRegions(toggleSeqs, toggleCols);
612 case KeyEvent.VK_PAGE_UP:
613 if (viewport.getWrapAlignment())
615 alignPanel.scrollUp(true);
619 alignPanel.setScrollValues(viewport.startRes, viewport.startSeq
620 - viewport.endSeq + viewport.startSeq);
623 case KeyEvent.VK_PAGE_DOWN:
624 if (viewport.getWrapAlignment())
626 alignPanel.scrollUp(false);
630 alignPanel.setScrollValues(viewport.startRes, viewport.startSeq
631 + viewport.endSeq - viewport.startSeq);
638 public void keyReleased(KeyEvent evt)
640 switch (evt.getKeyCode())
642 case KeyEvent.VK_LEFT:
643 if (evt.isAltDown() || !viewport.cursorMode)
645 viewport.firePropertyChange("alignment", null, viewport
646 .getAlignment().getSequences());
650 case KeyEvent.VK_RIGHT:
651 if (evt.isAltDown() || !viewport.cursorMode)
653 viewport.firePropertyChange("alignment", null, viewport
654 .getAlignment().getSequences());
662 public void addAlignmentPanel(final AlignmentPanel ap, boolean newPanel)
664 ap.alignFrame = this;
665 avc = new jalview.controller.AlignViewController(this, viewport,
670 PaintRefresher.Register(ap, ap.av.getSequenceSetId());
672 int aSize = alignPanels.size();
674 tabbedPane.setVisible(aSize > 1 || ap.av.viewName != null);
676 if (aSize == 1 && ap.av.viewName == null)
678 this.getContentPane().add(ap, BorderLayout.CENTER);
684 setInitialTabVisible();
687 expandViews.setEnabled(true);
688 gatherViews.setEnabled(true);
689 tabbedPane.addTab(ap.av.viewName, ap);
691 ap.setVisible(false);
696 if (ap.av.isPadGaps())
698 ap.av.getAlignment().padGaps();
700 ap.av.updateConservation(ap);
701 ap.av.updateConsensus(ap);
702 ap.av.updateStrucConsensus(ap);
706 public void setInitialTabVisible()
708 expandViews.setEnabled(true);
709 gatherViews.setEnabled(true);
710 tabbedPane.setVisible(true);
711 AlignmentPanel first = alignPanels.get(0);
712 tabbedPane.addTab(first.av.viewName, first);
713 this.getContentPane().add(tabbedPane, BorderLayout.CENTER);
716 public AlignViewport getViewport()
721 /* Set up intrinsic listeners for dynamically generated GUI bits. */
722 private void addServiceListeners()
724 final java.beans.PropertyChangeListener thisListener;
725 Desktop.instance.addJalviewPropertyChangeListener("services",
726 thisListener = new java.beans.PropertyChangeListener()
729 public void propertyChange(PropertyChangeEvent evt)
731 // // System.out.println("Discoverer property change.");
732 // if (evt.getPropertyName().equals("services"))
734 SwingUtilities.invokeLater(new Runnable()
741 .println("Rebuild WS Menu for service change");
742 BuildWebServiceMenu();
749 addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
752 public void internalFrameClosed(
753 javax.swing.event.InternalFrameEvent evt)
755 System.out.println("deregistering discoverer listener");
756 Desktop.instance.removeJalviewPropertyChangeListener("services",
758 closeMenuItem_actionPerformed(true);
761 // Finally, build the menu once to get current service state
762 new Thread(new Runnable()
767 BuildWebServiceMenu();
773 * Configure menu items that vary according to whether the alignment is
774 * nucleotide or protein
778 public void setGUINucleotide(boolean nucleotide)
780 showTranslation.setVisible(nucleotide);
781 conservationMenuItem.setEnabled(!nucleotide);
782 modifyConservation.setEnabled(!nucleotide);
783 showGroupConservation.setEnabled(!nucleotide);
784 rnahelicesColour.setEnabled(nucleotide);
785 purinePyrimidineColour.setEnabled(nucleotide);
786 showComplementMenuItem.setText(MessageManager
787 .getString(nucleotide ? "label.protein" : "label.nucleotide"));
788 setColourSelected(jalview.bin.Cache.getDefault(
789 nucleotide ? Preferences.DEFAULT_COLOUR_NUC
790 : Preferences.DEFAULT_COLOUR_PROT, "None"));
794 * set up menus for the current viewport. This may be called after any
795 * operation that affects the data in the current view (selection changed,
796 * etc) to update the menus to reflect the new state.
798 public void setMenusForViewport()
800 setMenusFromViewport(viewport);
804 * Need to call this method when tabs are selected for multiple views, or when
805 * loading from Jalview2XML.java
810 void setMenusFromViewport(AlignViewport av)
812 padGapsMenuitem.setSelected(av.isPadGaps());
813 colourTextMenuItem.setSelected(av.isShowColourText());
814 abovePIDThreshold.setSelected(av.getAbovePIDThreshold());
815 conservationMenuItem.setSelected(av.getConservationSelected());
816 seqLimits.setSelected(av.getShowJVSuffix());
817 idRightAlign.setSelected(av.isRightAlignIds());
818 centreColumnLabelsMenuItem.setState(av.isCentreColumnLabels());
819 renderGapsMenuItem.setSelected(av.isRenderGaps());
820 wrapMenuItem.setSelected(av.getWrapAlignment());
821 scaleAbove.setVisible(av.getWrapAlignment());
822 scaleLeft.setVisible(av.getWrapAlignment());
823 scaleRight.setVisible(av.getWrapAlignment());
824 annotationPanelMenuItem.setState(av.isShowAnnotation());
826 * Show/hide annotations only enabled if annotation panel is shown
828 showAllSeqAnnotations.setEnabled(annotationPanelMenuItem.getState());
829 hideAllSeqAnnotations.setEnabled(annotationPanelMenuItem.getState());
830 showAllAlAnnotations.setEnabled(annotationPanelMenuItem.getState());
831 hideAllAlAnnotations.setEnabled(annotationPanelMenuItem.getState());
832 viewBoxesMenuItem.setSelected(av.getShowBoxes());
833 viewTextMenuItem.setSelected(av.getShowText());
834 showNonconservedMenuItem.setSelected(av.getShowUnconserved());
835 showGroupConsensus.setSelected(av.isShowGroupConsensus());
836 showGroupConservation.setSelected(av.isShowGroupConservation());
837 showConsensusHistogram.setSelected(av.isShowConsensusHistogram());
838 showSequenceLogo.setSelected(av.isShowSequenceLogo());
839 normaliseSequenceLogo.setSelected(av.isNormaliseSequenceLogo());
841 setColourSelected(ColourSchemeProperty.getColourName(av
842 .getGlobalColourScheme()));
844 showSeqFeatures.setSelected(av.isShowSequenceFeatures());
845 hiddenMarkers.setState(av.getShowHiddenMarkers());
846 applyToAllGroups.setState(av.getColourAppliesToAllGroups());
847 showNpFeatsMenuitem.setSelected(av.isShowNPFeats());
848 showDbRefsMenuitem.setSelected(av.isShowDBRefs());
849 autoCalculate.setSelected(av.autoCalculateConsensus);
850 sortByTree.setSelected(av.sortByTree);
851 listenToViewSelections.setSelected(av.followSelection);
852 rnahelicesColour.setEnabled(av.getAlignment().hasRNAStructure());
854 .setSelected(av.getGlobalColourScheme() instanceof jalview.schemes.RNAHelicesColour);
855 setShowProductsEnabled();
859 // methods for implementing IProgressIndicator
860 // need to refactor to a reusable stub class
861 Hashtable progressBars, progressBarHandlers;
866 * @see jalview.gui.IProgressIndicator#setProgressBar(java.lang.String, long)
869 public void setProgressBar(String message, long id)
871 if (progressBars == null)
873 progressBars = new Hashtable();
874 progressBarHandlers = new Hashtable();
877 JPanel progressPanel;
878 Long lId = new Long(id);
879 GridLayout layout = (GridLayout) statusPanel.getLayout();
880 if (progressBars.get(lId) != null)
882 progressPanel = (JPanel) progressBars.get(new Long(id));
883 statusPanel.remove(progressPanel);
884 progressBars.remove(lId);
885 progressPanel = null;
888 statusBar.setText(message);
890 if (progressBarHandlers.contains(lId))
892 progressBarHandlers.remove(lId);
894 layout.setRows(layout.getRows() - 1);
898 progressPanel = new JPanel(new BorderLayout(10, 5));
900 JProgressBar progressBar = new JProgressBar();
901 progressBar.setIndeterminate(true);
903 progressPanel.add(new JLabel(message), BorderLayout.WEST);
904 progressPanel.add(progressBar, BorderLayout.CENTER);
906 layout.setRows(layout.getRows() + 1);
907 statusPanel.add(progressPanel);
909 progressBars.put(lId, progressPanel);
912 // setMenusForViewport();
917 public void registerHandler(final long id,
918 final IProgressIndicatorHandler handler)
920 if (progressBarHandlers == null || !progressBars.contains(new Long(id)))
922 throw new Error(MessageManager.getString("error.call_setprogressbar_before_registering_handler"));
924 progressBarHandlers.put(new Long(id), handler);
925 final JPanel progressPanel = (JPanel) progressBars.get(new Long(id));
926 if (handler.canCancel())
928 JButton cancel = new JButton(
929 MessageManager.getString("action.cancel"));
930 final IProgressIndicator us = this;
931 cancel.addActionListener(new ActionListener()
935 public void actionPerformed(ActionEvent e)
937 handler.cancelActivity(id);
938 us.setProgressBar(MessageManager.formatMessage("label.cancelled_params", new Object[]{((JLabel) progressPanel.getComponent(0)).getText()}), id);
941 progressPanel.add(cancel, BorderLayout.EAST);
947 * @return true if any progress bars are still active
950 public boolean operationInProgress()
952 if (progressBars != null && progressBars.size() > 0)
960 public void setStatus(String text)
962 statusBar.setText(text);
966 * Added so Castor Mapping file can obtain Jalview Version
968 public String getVersion()
970 return jalview.bin.Cache.getProperty("VERSION");
973 public FeatureRenderer getFeatureRenderer()
975 return alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer();
979 public void fetchSequence_actionPerformed(ActionEvent e)
981 new SequenceFetcher(this);
985 public void addFromFile_actionPerformed(ActionEvent e)
987 Desktop.instance.inputLocalFileMenuItem_actionPerformed(viewport);
991 public void reload_actionPerformed(ActionEvent e)
993 if (fileName != null)
995 // TODO: JAL-1108 - ensure all associated frames are closed regardless of
996 // originating file's format
997 // TODO: work out how to recover feature settings for correct view(s) when
999 if (currentFileFormat.equals("Jalview"))
1001 JInternalFrame[] frames = Desktop.desktop.getAllFrames();
1002 for (int i = 0; i < frames.length; i++)
1004 if (frames[i] instanceof AlignFrame && frames[i] != this
1005 && ((AlignFrame) frames[i]).fileName != null
1006 && ((AlignFrame) frames[i]).fileName.equals(fileName))
1010 frames[i].setSelected(true);
1011 Desktop.instance.closeAssociatedWindows();
1012 } catch (java.beans.PropertyVetoException ex)
1018 Desktop.instance.closeAssociatedWindows();
1020 FileLoader loader = new FileLoader();
1021 String protocol = fileName.startsWith("http:") ? "URL" : "File";
1022 loader.LoadFile(viewport, fileName, protocol, currentFileFormat);
1026 Rectangle bounds = this.getBounds();
1028 FileLoader loader = new FileLoader();
1029 String protocol = fileName.startsWith("http:") ? "URL" : "File";
1030 AlignFrame newframe = loader.LoadFileWaitTillLoaded(fileName,
1031 protocol, currentFileFormat);
1033 newframe.setBounds(bounds);
1034 if (featureSettings != null && featureSettings.isShowing())
1036 final Rectangle fspos = featureSettings.frame.getBounds();
1037 // TODO: need a 'show feature settings' function that takes bounds -
1038 // need to refactor Desktop.addFrame
1039 newframe.featureSettings_actionPerformed(null);
1040 final FeatureSettings nfs = newframe.featureSettings;
1041 SwingUtilities.invokeLater(new Runnable()
1046 nfs.frame.setBounds(fspos);
1049 this.featureSettings.close();
1050 this.featureSettings = null;
1052 this.closeMenuItem_actionPerformed(true);
1058 public void addFromText_actionPerformed(ActionEvent e)
1060 Desktop.instance.inputTextboxMenuItem_actionPerformed(viewport);
1064 public void addFromURL_actionPerformed(ActionEvent e)
1066 Desktop.instance.inputURLMenuItem_actionPerformed(viewport);
1070 public void save_actionPerformed(ActionEvent e)
1072 if (fileName == null
1073 || (currentFileFormat == null || !jalview.io.FormatAdapter
1074 .isValidIOFormat(currentFileFormat, true))
1075 || fileName.startsWith("http"))
1077 saveAs_actionPerformed(null);
1081 saveAlignment(fileName, currentFileFormat);
1092 public void saveAs_actionPerformed(ActionEvent e)
1094 JalviewFileChooser chooser = new JalviewFileChooser(
1095 jalview.bin.Cache.getProperty("LAST_DIRECTORY"),
1096 jalview.io.AppletFormatAdapter.WRITABLE_EXTENSIONS,
1097 jalview.io.AppletFormatAdapter.WRITABLE_FNAMES,
1098 currentFileFormat, false);
1100 chooser.setFileView(new JalviewFileView());
1101 chooser.setDialogTitle(MessageManager.getString("label.save_alignment_to_file"));
1102 chooser.setToolTipText(MessageManager.getString("action.save"));
1104 int value = chooser.showSaveDialog(this);
1106 if (value == JalviewFileChooser.APPROVE_OPTION)
1108 currentFileFormat = chooser.getSelectedFormat();
1109 while (currentFileFormat == null)
1112 .showInternalMessageDialog(
1115 .getString("label.select_file_format_before_saving"),
1117 .getString("label.file_format_not_specified"),
1118 JOptionPane.WARNING_MESSAGE);
1119 currentFileFormat = chooser.getSelectedFormat();
1120 value = chooser.showSaveDialog(this);
1121 if (value != JalviewFileChooser.APPROVE_OPTION)
1127 fileName = chooser.getSelectedFile().getPath();
1129 jalview.bin.Cache.setProperty("DEFAULT_FILE_FORMAT",
1132 jalview.bin.Cache.setProperty("LAST_DIRECTORY", fileName);
1133 if (currentFileFormat.indexOf(" ") > -1)
1135 currentFileFormat = currentFileFormat.substring(0,
1136 currentFileFormat.indexOf(" "));
1138 saveAlignment(fileName, currentFileFormat);
1142 public boolean saveAlignment(String file, String format)
1144 boolean success = true;
1146 if (format.equalsIgnoreCase("Jalview"))
1148 String shortName = title;
1150 if (shortName.indexOf(java.io.File.separatorChar) > -1)
1152 shortName = shortName.substring(shortName
1153 .lastIndexOf(java.io.File.separatorChar) + 1);
1157 * First save any linked Chimera session.
1159 Desktop.instance.saveChimeraSessions(file);
1161 success = new Jalview2XML().saveAlignment(this, file, shortName);
1163 statusBar.setText(MessageManager.formatMessage(
1164 "label.successfully_saved_to_file_in_format", new Object[]
1165 { fileName, format }));
1170 if (!jalview.io.AppletFormatAdapter.isValidFormat(format, true))
1172 warningMessage("Cannot save file " + fileName + " using format "
1173 + format, "Alignment output format not supported");
1174 saveAs_actionPerformed(null);
1175 // JBPNote need to have a raise_gui flag here
1179 String[] omitHidden = null;
1181 if (viewport.hasHiddenColumns())
1183 int reply = JOptionPane
1184 .showInternalConfirmDialog(
1187 .getString("label.alignment_contains_hidden_columns"),
1189 .getString("action.save_omit_hidden_columns"),
1190 JOptionPane.YES_NO_OPTION,
1191 JOptionPane.QUESTION_MESSAGE);
1193 if (reply == JOptionPane.YES_OPTION)
1195 omitHidden = viewport.getViewAsString(false);
1198 FormatAdapter f = new FormatAdapter();
1199 String output = f.formatSequences(format,
1200 viewport.getAlignment(), // class cast exceptions will
1201 // occur in the distant future
1202 omitHidden, f.getCacheSuffixDefault(format),
1203 viewport.getColumnSelection());
1213 java.io.PrintWriter out = new java.io.PrintWriter(
1214 new java.io.FileWriter(file));
1218 this.setTitle(file);
1219 statusBar.setText(MessageManager.formatMessage(
1220 "label.successfully_saved_to_file_in_format",
1222 { fileName, format }));
1223 } catch (Exception ex)
1226 ex.printStackTrace();
1233 JOptionPane.showInternalMessageDialog(this, MessageManager
1234 .formatMessage("label.couldnt_save_file", new Object[]
1235 { fileName }), MessageManager
1236 .getString("label.error_saving_file"),
1237 JOptionPane.WARNING_MESSAGE);
1243 private void warningMessage(String warning, String title)
1245 if (new jalview.util.Platform().isHeadless())
1247 System.err.println("Warning: " + title + "\nWarning: " + warning);
1252 JOptionPane.showInternalMessageDialog(this, warning, title,
1253 JOptionPane.WARNING_MESSAGE);
1265 protected void outputText_actionPerformed(ActionEvent e)
1267 String[] omitHidden = null;
1269 if (viewport.hasHiddenColumns())
1271 int reply = JOptionPane
1272 .showInternalConfirmDialog(
1275 .getString("label.alignment_contains_hidden_columns"),
1277 .getString("action.save_omit_hidden_columns"),
1278 JOptionPane.YES_NO_OPTION,
1279 JOptionPane.QUESTION_MESSAGE);
1281 if (reply == JOptionPane.YES_OPTION)
1283 omitHidden = viewport.getViewAsString(false);
1287 CutAndPasteTransfer cap = new CutAndPasteTransfer();
1288 cap.setForInput(null);
1292 cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(),
1293 viewport.getAlignment(), omitHidden,
1294 viewport.getColumnSelection()));
1295 Desktop.addInternalFrame(cap, MessageManager.formatMessage(
1296 "label.alignment_output_command", new Object[]
1297 { e.getActionCommand() }), 600, 500);
1298 } catch (OutOfMemoryError oom)
1300 new OOMWarning("Outputting alignment as " + e.getActionCommand(), oom);
1313 protected void htmlMenuItem_actionPerformed(ActionEvent e)
1315 // new HTMLOutput(alignPanel,
1316 // alignPanel.getSeqPanel().seqCanvas.getSequenceRenderer(),
1317 // alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer());
1318 new HtmlSvgOutput(null, alignPanel);
1322 public void bioJSMenuItem_actionPerformed(ActionEvent e)
1324 new BioJsHTMLOutput(alignPanel,
1325 alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer());
1327 public void createImageMap(File file, String image)
1329 alignPanel.makePNGImageMap(file, image);
1339 public void createPNG(File f)
1341 alignPanel.makePNG(f);
1351 public void createEPS(File f)
1353 alignPanel.makeEPS(f);
1356 public void createSVG(File f)
1358 alignPanel.makeSVG(f);
1361 public void pageSetup_actionPerformed(ActionEvent e)
1363 PrinterJob printJob = PrinterJob.getPrinterJob();
1364 PrintThread.pf = printJob.pageDialog(printJob.defaultPage());
1374 public void printMenuItem_actionPerformed(ActionEvent e)
1376 // Putting in a thread avoids Swing painting problems
1377 PrintThread thread = new PrintThread(alignPanel);
1382 public void exportFeatures_actionPerformed(ActionEvent e)
1384 new AnnotationExporter().exportFeatures(alignPanel);
1388 public void exportAnnotations_actionPerformed(ActionEvent e)
1390 new AnnotationExporter().exportAnnotations(alignPanel);
1394 public void associatedData_actionPerformed(ActionEvent e)
1396 // Pick the tree file
1397 JalviewFileChooser chooser = new JalviewFileChooser(
1398 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
1399 chooser.setFileView(new JalviewFileView());
1400 chooser.setDialogTitle(MessageManager
1401 .getString("label.load_jalview_annotations"));
1402 chooser.setToolTipText(MessageManager
1403 .getString("label.load_jalview_annotations"));
1405 int value = chooser.showOpenDialog(null);
1407 if (value == JalviewFileChooser.APPROVE_OPTION)
1409 String choice = chooser.getSelectedFile().getPath();
1410 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
1411 loadJalviewDataFile(choice, null, null, null);
1417 * Close the current view or all views in the alignment frame. If the frame
1418 * only contains one view then the alignment will be removed from memory.
1420 * @param closeAllTabs
1423 public void closeMenuItem_actionPerformed(boolean closeAllTabs)
1425 if (alignPanels != null && alignPanels.size() < 2)
1427 closeAllTabs = true;
1432 if (alignPanels != null)
1436 if (this.isClosed())
1438 // really close all the windows - otherwise wait till
1439 // setClosed(true) is called
1440 for (int i = 0; i < alignPanels.size(); i++)
1442 AlignmentPanel ap = alignPanels.get(i);
1449 closeView(alignPanel);
1455 this.setClosed(true);
1457 } catch (Exception ex)
1459 ex.printStackTrace();
1464 * Close the specified panel and close up tabs appropriately.
1466 * @param panelToClose
1468 public void closeView(AlignmentPanel panelToClose)
1470 int index = tabbedPane.getSelectedIndex();
1471 int closedindex = tabbedPane.indexOfComponent(panelToClose);
1472 alignPanels.remove(panelToClose);
1473 panelToClose.closePanel();
1474 panelToClose = null;
1476 tabbedPane.removeTabAt(closedindex);
1477 tabbedPane.validate();
1479 if (index > closedindex || index == tabbedPane.getTabCount())
1481 // modify currently selected tab index if necessary.
1485 this.tabSelectionChanged(index);
1491 void updateEditMenuBar()
1494 if (viewport.getHistoryList().size() > 0)
1496 undoMenuItem.setEnabled(true);
1497 CommandI command = viewport.getHistoryList().peek();
1498 undoMenuItem.setText(MessageManager.formatMessage(
1499 "label.undo_command", new Object[]
1500 { command.getDescription() }));
1504 undoMenuItem.setEnabled(false);
1505 undoMenuItem.setText(MessageManager.getString("action.undo"));
1508 if (viewport.getRedoList().size() > 0)
1510 redoMenuItem.setEnabled(true);
1512 CommandI command = viewport.getRedoList().peek();
1513 redoMenuItem.setText(MessageManager.formatMessage(
1514 "label.redo_command", new Object[]
1515 { command.getDescription() }));
1519 redoMenuItem.setEnabled(false);
1520 redoMenuItem.setText(MessageManager.getString("action.redo"));
1524 public void addHistoryItem(CommandI command)
1526 if (command.getSize() > 0)
1528 viewport.addToHistoryList(command);
1529 viewport.clearRedoList();
1530 updateEditMenuBar();
1531 viewport.updateHiddenColumns();
1532 // viewport.hasHiddenColumns = (viewport.getColumnSelection() != null
1533 // && viewport.getColumnSelection().getHiddenColumns() != null &&
1534 // viewport.getColumnSelection()
1535 // .getHiddenColumns().size() > 0);
1541 * @return alignment objects for all views
1543 AlignmentI[] getViewAlignments()
1545 if (alignPanels != null)
1547 AlignmentI[] als = new AlignmentI[alignPanels.size()];
1549 for (AlignmentPanel ap : alignPanels)
1551 als[i++] = ap.av.getAlignment();
1555 if (viewport != null)
1557 return new AlignmentI[]
1558 { viewport.getAlignment() };
1570 protected void undoMenuItem_actionPerformed(ActionEvent e)
1572 if (viewport.getHistoryList().isEmpty())
1576 CommandI command = viewport.getHistoryList().pop();
1577 viewport.addToRedoList(command);
1578 command.undoCommand(getViewAlignments());
1580 AlignmentViewport originalSource = getOriginatingSource(command);
1581 updateEditMenuBar();
1583 if (originalSource != null)
1585 if (originalSource != viewport)
1588 .warn("Implementation worry: mismatch of viewport origin for undo");
1590 originalSource.updateHiddenColumns();
1591 // originalSource.hasHiddenColumns = (viewport.getColumnSelection() !=
1593 // && viewport.getColumnSelection().getHiddenColumns() != null &&
1594 // viewport.getColumnSelection()
1595 // .getHiddenColumns().size() > 0);
1596 originalSource.firePropertyChange("alignment", null, originalSource
1597 .getAlignment().getSequences());
1608 protected void redoMenuItem_actionPerformed(ActionEvent e)
1610 if (viewport.getRedoList().size() < 1)
1615 CommandI command = viewport.getRedoList().pop();
1616 viewport.addToHistoryList(command);
1617 command.doCommand(getViewAlignments());
1619 AlignmentViewport originalSource = getOriginatingSource(command);
1620 updateEditMenuBar();
1622 if (originalSource != null)
1625 if (originalSource != viewport)
1628 .warn("Implementation worry: mismatch of viewport origin for redo");
1630 originalSource.updateHiddenColumns();
1631 // originalSource.hasHiddenColumns = (viewport.getColumnSelection() !=
1633 // && viewport.getColumnSelection().getHiddenColumns() != null &&
1634 // viewport.getColumnSelection()
1635 // .getHiddenColumns().size() > 0);
1636 originalSource.firePropertyChange("alignment", null, originalSource
1637 .getAlignment().getSequences());
1641 AlignmentViewport getOriginatingSource(CommandI command)
1643 AlignmentViewport originalSource = null;
1644 // For sequence removal and addition, we need to fire
1645 // the property change event FROM the viewport where the
1646 // original alignment was altered
1647 AlignmentI al = null;
1648 if (command instanceof EditCommand)
1650 EditCommand editCommand = (EditCommand) command;
1651 al = editCommand.getAlignment();
1652 List<Component> comps = PaintRefresher.components.get(viewport
1653 .getSequenceSetId());
1655 for (Component comp : comps)
1657 if (comp instanceof AlignmentPanel)
1659 if (al == ((AlignmentPanel) comp).av.getAlignment())
1661 originalSource = ((AlignmentPanel) comp).av;
1668 if (originalSource == null)
1670 // The original view is closed, we must validate
1671 // the current view against the closed view first
1674 PaintRefresher.validateSequences(al, viewport.getAlignment());
1677 originalSource = viewport;
1680 return originalSource;
1689 public void moveSelectedSequences(boolean up)
1691 SequenceGroup sg = viewport.getSelectionGroup();
1697 viewport.getAlignment().moveSelectedSequencesByOne(sg,
1698 viewport.getHiddenRepSequences(), up);
1699 alignPanel.paintAlignment(true);
1702 synchronized void slideSequences(boolean right, int size)
1704 List<SequenceI> sg = new ArrayList<SequenceI>();
1705 if (viewport.cursorMode)
1707 sg.add(viewport.getAlignment().getSequenceAt(
1708 alignPanel.getSeqPanel().seqCanvas.cursorY));
1710 else if (viewport.getSelectionGroup() != null
1711 && viewport.getSelectionGroup().getSize() != viewport
1712 .getAlignment().getHeight())
1714 sg = viewport.getSelectionGroup().getSequences(
1715 viewport.getHiddenRepSequences());
1723 List<SequenceI> invertGroup = new ArrayList<SequenceI>();
1725 for (SequenceI seq : viewport.getAlignment().getSequences())
1727 if (!sg.contains(seq))
1729 invertGroup.add(seq);
1733 SequenceI[] seqs1 = sg.toArray(new SequenceI[0]);
1735 SequenceI[] seqs2 = new SequenceI[invertGroup.size()];
1736 for (int i = 0; i < invertGroup.size(); i++)
1738 seqs2[i] = invertGroup.get(i);
1741 SlideSequencesCommand ssc;
1744 ssc = new SlideSequencesCommand("Slide Sequences", seqs2, seqs1,
1745 size, viewport.getGapCharacter());
1749 ssc = new SlideSequencesCommand("Slide Sequences", seqs1, seqs2,
1750 size, viewport.getGapCharacter());
1753 int groupAdjustment = 0;
1754 if (ssc.getGapsInsertedBegin() && right)
1756 if (viewport.cursorMode)
1758 alignPanel.getSeqPanel().moveCursor(size, 0);
1762 groupAdjustment = size;
1765 else if (!ssc.getGapsInsertedBegin() && !right)
1767 if (viewport.cursorMode)
1769 alignPanel.getSeqPanel().moveCursor(-size, 0);
1773 groupAdjustment = -size;
1777 if (groupAdjustment != 0)
1779 viewport.getSelectionGroup().setStartRes(
1780 viewport.getSelectionGroup().getStartRes() + groupAdjustment);
1781 viewport.getSelectionGroup().setEndRes(
1782 viewport.getSelectionGroup().getEndRes() + groupAdjustment);
1785 boolean appendHistoryItem = false;
1786 Deque<CommandI> historyList = viewport.getHistoryList();
1787 if (historyList != null
1788 && historyList.size() > 0
1789 && historyList.peek() instanceof SlideSequencesCommand)
1791 appendHistoryItem = ssc
1792 .appendSlideCommand((SlideSequencesCommand) historyList
1796 if (!appendHistoryItem)
1798 addHistoryItem(ssc);
1811 protected void copy_actionPerformed(ActionEvent e)
1814 if (viewport.getSelectionGroup() == null)
1818 // TODO: preserve the ordering of displayed alignment annotation in any
1819 // internal paste (particularly sequence associated annotation)
1820 SequenceI[] seqs = viewport.getSelectionAsNewSequence();
1821 String[] omitHidden = null;
1823 if (viewport.hasHiddenColumns())
1825 omitHidden = viewport.getViewAsString(true);
1828 String output = new FormatAdapter().formatSequences("Fasta", seqs,
1831 StringSelection ss = new StringSelection(output);
1835 jalview.gui.Desktop.internalCopy = true;
1836 // Its really worth setting the clipboard contents
1837 // to empty before setting the large StringSelection!!
1838 Toolkit.getDefaultToolkit().getSystemClipboard()
1839 .setContents(new StringSelection(""), null);
1841 Toolkit.getDefaultToolkit().getSystemClipboard()
1842 .setContents(ss, Desktop.instance);
1843 } catch (OutOfMemoryError er)
1845 new OOMWarning("copying region", er);
1849 ArrayList<int[]> hiddenColumns = null;
1850 if (viewport.hasHiddenColumns())
1852 hiddenColumns = new ArrayList<int[]>();
1853 int hiddenOffset = viewport.getSelectionGroup().getStartRes(), hiddenCutoff = viewport
1854 .getSelectionGroup().getEndRes();
1855 for (int[] region : viewport.getColumnSelection().getHiddenColumns())
1857 if (region[0] >= hiddenOffset && region[1] <= hiddenCutoff)
1859 hiddenColumns.add(new int[]
1860 { region[0] - hiddenOffset, region[1] - hiddenOffset });
1865 Desktop.jalviewClipboard = new Object[]
1866 { seqs, viewport.getAlignment().getDataset(), hiddenColumns };
1867 statusBar.setText(MessageManager.formatMessage(
1868 "label.copied_sequences_to_clipboard", new Object[]
1869 { Integer.valueOf(seqs.length).toString() }));
1879 protected void pasteNew_actionPerformed(ActionEvent e)
1891 protected void pasteThis_actionPerformed(ActionEvent e)
1897 * Paste contents of Jalview clipboard
1899 * @param newAlignment
1900 * true to paste to a new alignment, otherwise add to this.
1902 void paste(boolean newAlignment)
1904 boolean externalPaste = true;
1907 Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
1908 Transferable contents = c.getContents(this);
1910 if (contents == null)
1918 str = (String) contents.getTransferData(DataFlavor.stringFlavor);
1919 if (str.length() < 1)
1924 format = new IdentifyFile().Identify(str, "Paste");
1926 } catch (OutOfMemoryError er)
1928 new OOMWarning("Out of memory pasting sequences!!", er);
1932 SequenceI[] sequences;
1933 boolean annotationAdded = false;
1934 AlignmentI alignment = null;
1936 if (Desktop.jalviewClipboard != null)
1938 // The clipboard was filled from within Jalview, we must use the
1940 // And dataset from the copied alignment
1941 SequenceI[] newseq = (SequenceI[]) Desktop.jalviewClipboard[0];
1942 // be doubly sure that we create *new* sequence objects.
1943 sequences = new SequenceI[newseq.length];
1944 for (int i = 0; i < newseq.length; i++)
1946 sequences[i] = new Sequence(newseq[i]);
1948 alignment = new Alignment(sequences);
1949 externalPaste = false;
1953 // parse the clipboard as an alignment.
1954 alignment = new FormatAdapter().readFile(str, "Paste", format);
1955 sequences = alignment.getSequencesArray();
1959 ArrayList<Integer> newGraphGroups = new ArrayList<Integer>();
1965 if (Desktop.jalviewClipboard != null)
1967 // dataset is inherited
1968 alignment.setDataset((Alignment) Desktop.jalviewClipboard[1]);
1972 // new dataset is constructed
1973 alignment.setDataset(null);
1975 alwidth = alignment.getWidth() + 1;
1979 AlignmentI pastedal = alignment; // preserve pasted alignment object
1980 // Add pasted sequences and dataset into existing alignment.
1981 alignment = viewport.getAlignment();
1982 alwidth = alignment.getWidth() + 1;
1983 // decide if we need to import sequences from an existing dataset
1984 boolean importDs = Desktop.jalviewClipboard != null
1985 && Desktop.jalviewClipboard[1] != alignment.getDataset();
1986 // importDs==true instructs us to copy over new dataset sequences from
1987 // an existing alignment
1988 Vector newDs = (importDs) ? new Vector() : null; // used to create
1989 // minimum dataset set
1991 for (int i = 0; i < sequences.length; i++)
1995 newDs.addElement(null);
1997 SequenceI ds = sequences[i].getDatasetSequence(); // null for a simple
1999 if (importDs && ds != null)
2001 if (!newDs.contains(ds))
2003 newDs.setElementAt(ds, i);
2004 ds = new Sequence(ds);
2005 // update with new dataset sequence
2006 sequences[i].setDatasetSequence(ds);
2010 ds = sequences[newDs.indexOf(ds)].getDatasetSequence();
2015 // copy and derive new dataset sequence
2016 sequences[i] = sequences[i].deriveSequence();
2017 alignment.getDataset().addSequence(
2018 sequences[i].getDatasetSequence());
2019 // TODO: avoid creation of duplicate dataset sequences with a
2020 // 'contains' method using SequenceI.equals()/SequenceI.contains()
2022 alignment.addSequence(sequences[i]); // merges dataset
2026 newDs.clear(); // tidy up
2028 if (alignment.getAlignmentAnnotation() != null)
2030 for (AlignmentAnnotation alan : alignment
2031 .getAlignmentAnnotation())
2033 if (alan.graphGroup > fgroup)
2035 fgroup = alan.graphGroup;
2039 if (pastedal.getAlignmentAnnotation() != null)
2041 // Add any annotation attached to alignment.
2042 AlignmentAnnotation[] alann = pastedal.getAlignmentAnnotation();
2043 for (int i = 0; i < alann.length; i++)
2045 annotationAdded = true;
2046 if (alann[i].sequenceRef == null && !alann[i].autoCalculated)
2048 AlignmentAnnotation newann = new AlignmentAnnotation(alann[i]);
2049 if (newann.graphGroup > -1)
2051 if (newGraphGroups.size() <= newann.graphGroup
2052 || newGraphGroups.get(newann.graphGroup) == null)
2054 for (int q = newGraphGroups.size(); q <= newann.graphGroup; q++)
2056 newGraphGroups.add(q, null);
2058 newGraphGroups.set(newann.graphGroup, new Integer(
2061 newann.graphGroup = newGraphGroups.get(newann.graphGroup)
2065 newann.padAnnotation(alwidth);
2066 alignment.addAnnotation(newann);
2076 addHistoryItem(new EditCommand(
2077 MessageManager.getString("label.add_sequences"),
2079 sequences, 0, alignment.getWidth(), alignment));
2081 // Add any annotations attached to sequences
2082 for (int i = 0; i < sequences.length; i++)
2084 if (sequences[i].getAnnotation() != null)
2086 AlignmentAnnotation newann;
2087 for (int a = 0; a < sequences[i].getAnnotation().length; a++)
2089 annotationAdded = true;
2090 newann = sequences[i].getAnnotation()[a];
2091 newann.adjustForAlignment();
2092 newann.padAnnotation(alwidth);
2093 if (newann.graphGroup > -1)
2095 if (newann.graphGroup > -1)
2097 if (newGraphGroups.size() <= newann.graphGroup
2098 || newGraphGroups.get(newann.graphGroup) == null)
2100 for (int q = newGraphGroups.size(); q <= newann.graphGroup; q++)
2102 newGraphGroups.add(q, null);
2104 newGraphGroups.set(newann.graphGroup, new Integer(
2107 newann.graphGroup = newGraphGroups.get(newann.graphGroup)
2111 alignment.addAnnotation(sequences[i].getAnnotation()[a]); // annotation
2116 .setAnnotationIndex(sequences[i].getAnnotation()[a], a);
2123 // propagate alignment changed.
2124 viewport.setEndSeq(alignment.getHeight());
2125 if (annotationAdded)
2127 // Duplicate sequence annotation in all views.
2128 AlignmentI[] alview = this.getViewAlignments();
2129 for (int i = 0; i < sequences.length; i++)
2131 AlignmentAnnotation sann[] = sequences[i].getAnnotation();
2136 for (int avnum = 0; avnum < alview.length; avnum++)
2138 if (alview[avnum] != alignment)
2140 // duplicate in a view other than the one with input focus
2141 int avwidth = alview[avnum].getWidth() + 1;
2142 // this relies on sann being preserved after we
2143 // modify the sequence's annotation array for each duplication
2144 for (int a = 0; a < sann.length; a++)
2146 AlignmentAnnotation newann = new AlignmentAnnotation(
2148 sequences[i].addAlignmentAnnotation(newann);
2149 newann.padAnnotation(avwidth);
2150 alview[avnum].addAnnotation(newann); // annotation was
2151 // duplicated earlier
2152 // TODO JAL-1145 graphGroups are not updated for sequence
2153 // annotation added to several views. This may cause
2155 alview[avnum].setAnnotationIndex(newann, a);
2160 buildSortByAnnotationScoresMenu();
2162 viewport.firePropertyChange("alignment", null,
2163 alignment.getSequences());
2164 if (alignPanels != null)
2166 for (AlignmentPanel ap : alignPanels)
2168 ap.validateAnnotationDimensions(false);
2173 alignPanel.validateAnnotationDimensions(false);
2179 AlignFrame af = new AlignFrame(alignment, DEFAULT_WIDTH,
2181 String newtitle = new String("Copied sequences");
2183 if (Desktop.jalviewClipboard != null
2184 && Desktop.jalviewClipboard[2] != null)
2186 List<int[]> hc = (List<int[]>) Desktop.jalviewClipboard[2];
2187 for (int[] region : hc)
2189 af.viewport.hideColumns(region[0], region[1]);
2193 // >>>This is a fix for the moment, until a better solution is
2195 af.alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer()
2197 alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer());
2199 // TODO: maintain provenance of an alignment, rather than just make the
2200 // title a concatenation of operations.
2203 if (title.startsWith("Copied sequences"))
2209 newtitle = newtitle.concat("- from " + title);
2214 newtitle = new String("Pasted sequences");
2217 Desktop.addInternalFrame(af, newtitle, DEFAULT_WIDTH,
2222 } catch (Exception ex)
2224 ex.printStackTrace();
2225 System.out.println("Exception whilst pasting: " + ex);
2226 // could be anything being pasted in here
2232 protected void expand_newalign(ActionEvent e)
2236 AlignmentI alignment = AlignmentUtils.expandContext(getViewport()
2237 .getAlignment(), -1);
2238 AlignFrame af = new AlignFrame(alignment, DEFAULT_WIDTH,
2240 String newtitle = new String("Flanking alignment");
2242 if (Desktop.jalviewClipboard != null
2243 && Desktop.jalviewClipboard[2] != null)
2245 List<int[]> hc = (List<int[]>) Desktop.jalviewClipboard[2];
2246 for (int region[] : hc)
2248 af.viewport.hideColumns(region[0], region[1]);
2252 // >>>This is a fix for the moment, until a better solution is
2254 af.alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer()
2256 alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer());
2258 // TODO: maintain provenance of an alignment, rather than just make the
2259 // title a concatenation of operations.
2261 if (title.startsWith("Copied sequences"))
2267 newtitle = newtitle.concat("- from " + title);
2271 Desktop.addInternalFrame(af, newtitle, DEFAULT_WIDTH, DEFAULT_HEIGHT);
2273 } catch (Exception ex)
2275 ex.printStackTrace();
2276 System.out.println("Exception whilst pasting: " + ex);
2277 // could be anything being pasted in here
2278 } catch (OutOfMemoryError oom)
2280 new OOMWarning("Viewing flanking region of alignment", oom);
2291 protected void cut_actionPerformed(ActionEvent e)
2293 copy_actionPerformed(null);
2294 delete_actionPerformed(null);
2304 protected void delete_actionPerformed(ActionEvent evt)
2307 SequenceGroup sg = viewport.getSelectionGroup();
2314 * If the cut affects all sequences, warn, remove highlighted columns
2316 if (sg.getSize() == viewport.getAlignment().getHeight())
2318 int confirm = JOptionPane.showConfirmDialog(this,
2319 MessageManager.getString("warn.delete_all"), // $NON-NLS-1$
2320 MessageManager.getString("label.delete_all"), // $NON-NLS-1$
2321 JOptionPane.OK_CANCEL_OPTION);
2323 if (confirm == JOptionPane.CANCEL_OPTION
2324 || confirm == JOptionPane.CLOSED_OPTION)
2328 viewport.getColumnSelection().removeElements(sg.getStartRes(),
2329 sg.getEndRes() + 1);
2332 SequenceI[] cut = sg.getSequences()
2333 .toArray(new SequenceI[sg.getSize()]);
2335 addHistoryItem(new EditCommand(
2336 MessageManager.getString("label.cut_sequences"), Action.CUT,
2337 cut, sg.getStartRes(), sg.getEndRes() - sg.getStartRes() + 1,
2338 viewport.getAlignment()));
2340 viewport.setSelectionGroup(null);
2341 viewport.sendSelection();
2342 viewport.getAlignment().deleteGroup(sg);
2344 viewport.firePropertyChange("alignment", null, viewport.getAlignment()
2346 if (viewport.getAlignment().getHeight() < 1)
2350 this.setClosed(true);
2351 } catch (Exception ex)
2364 protected void deleteGroups_actionPerformed(ActionEvent e)
2366 if (avc.deleteGroups())
2368 PaintRefresher.Refresh(this, viewport.getSequenceSetId());
2369 alignPanel.updateAnnotation();
2370 alignPanel.paintAlignment(true);
2381 public void selectAllSequenceMenuItem_actionPerformed(ActionEvent e)
2383 SequenceGroup sg = new SequenceGroup();
2385 for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++)
2387 sg.addSequence(viewport.getAlignment().getSequenceAt(i), false);
2390 sg.setEndRes(viewport.getAlignment().getWidth() - 1);
2391 viewport.setSelectionGroup(sg);
2392 viewport.sendSelection();
2393 alignPanel.paintAlignment(true);
2394 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
2404 public void deselectAllSequenceMenuItem_actionPerformed(ActionEvent e)
2406 if (viewport.cursorMode)
2408 alignPanel.getSeqPanel().keyboardNo1 = null;
2409 alignPanel.getSeqPanel().keyboardNo2 = null;
2411 viewport.setSelectionGroup(null);
2412 viewport.getColumnSelection().clear();
2413 viewport.setSelectionGroup(null);
2414 alignPanel.getSeqPanel().seqCanvas.highlightSearchResults(null);
2415 alignPanel.getIdPanel().getIdCanvas().searchResults = null;
2416 alignPanel.paintAlignment(true);
2417 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
2418 viewport.sendSelection();
2428 public void invertSequenceMenuItem_actionPerformed(ActionEvent e)
2430 SequenceGroup sg = viewport.getSelectionGroup();
2434 selectAllSequenceMenuItem_actionPerformed(null);
2439 for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++)
2441 sg.addOrRemove(viewport.getAlignment().getSequenceAt(i), false);
2444 alignPanel.paintAlignment(true);
2445 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
2446 viewport.sendSelection();
2450 public void invertColSel_actionPerformed(ActionEvent e)
2452 viewport.invertColumnSelection();
2453 alignPanel.paintAlignment(true);
2454 viewport.sendSelection();
2464 public void remove2LeftMenuItem_actionPerformed(ActionEvent e)
2466 trimAlignment(true);
2476 public void remove2RightMenuItem_actionPerformed(ActionEvent e)
2478 trimAlignment(false);
2481 void trimAlignment(boolean trimLeft)
2483 ColumnSelection colSel = viewport.getColumnSelection();
2486 if (colSel.size() > 0)
2490 column = colSel.getMin();
2494 column = colSel.getMax();
2498 if (viewport.getSelectionGroup() != null)
2500 seqs = viewport.getSelectionGroup().getSequencesAsArray(
2501 viewport.getHiddenRepSequences());
2505 seqs = viewport.getAlignment().getSequencesArray();
2508 TrimRegionCommand trimRegion;
2511 trimRegion = new TrimRegionCommand("Remove Left",
2512 TrimRegionCommand.TRIM_LEFT, seqs, column,
2513 viewport.getAlignment(), viewport.getColumnSelection(),
2514 viewport.getSelectionGroup());
2515 viewport.setStartRes(0);
2519 trimRegion = new TrimRegionCommand("Remove Right",
2520 TrimRegionCommand.TRIM_RIGHT, seqs, column,
2521 viewport.getAlignment(), viewport.getColumnSelection(),
2522 viewport.getSelectionGroup());
2525 statusBar.setText(MessageManager.formatMessage(
2526 "label.removed_columns", new String[]
2527 { Integer.valueOf(trimRegion.getSize()).toString() }));
2529 addHistoryItem(trimRegion);
2531 for (SequenceGroup sg : viewport.getAlignment().getGroups())
2533 if ((trimLeft && !sg.adjustForRemoveLeft(column))
2534 || (!trimLeft && !sg.adjustForRemoveRight(column)))
2536 viewport.getAlignment().deleteGroup(sg);
2540 viewport.firePropertyChange("alignment", null, viewport
2541 .getAlignment().getSequences());
2552 public void removeGappedColumnMenuItem_actionPerformed(ActionEvent e)
2554 int start = 0, end = viewport.getAlignment().getWidth() - 1;
2557 if (viewport.getSelectionGroup() != null)
2559 seqs = viewport.getSelectionGroup().getSequencesAsArray(
2560 viewport.getHiddenRepSequences());
2561 start = viewport.getSelectionGroup().getStartRes();
2562 end = viewport.getSelectionGroup().getEndRes();
2566 seqs = viewport.getAlignment().getSequencesArray();
2569 RemoveGapColCommand removeGapCols = new RemoveGapColCommand(
2570 "Remove Gapped Columns", seqs, start, end,
2571 viewport.getAlignment());
2573 addHistoryItem(removeGapCols);
2575 statusBar.setText(MessageManager.formatMessage(
2576 "label.removed_empty_columns", new Object[]
2577 { Integer.valueOf(removeGapCols.getSize()).toString() }));
2579 // This is to maintain viewport position on first residue
2580 // of first sequence
2581 SequenceI seq = viewport.getAlignment().getSequenceAt(0);
2582 int startRes = seq.findPosition(viewport.startRes);
2583 // ShiftList shifts;
2584 // viewport.getAlignment().removeGaps(shifts=new ShiftList());
2585 // edit.alColumnChanges=shifts.getInverse();
2586 // if (viewport.hasHiddenColumns)
2587 // viewport.getColumnSelection().compensateForEdits(shifts);
2588 viewport.setStartRes(seq.findIndex(startRes) - 1);
2589 viewport.firePropertyChange("alignment", null, viewport.getAlignment()
2601 public void removeAllGapsMenuItem_actionPerformed(ActionEvent e)
2603 int start = 0, end = viewport.getAlignment().getWidth() - 1;
2606 if (viewport.getSelectionGroup() != null)
2608 seqs = viewport.getSelectionGroup().getSequencesAsArray(
2609 viewport.getHiddenRepSequences());
2610 start = viewport.getSelectionGroup().getStartRes();
2611 end = viewport.getSelectionGroup().getEndRes();
2615 seqs = viewport.getAlignment().getSequencesArray();
2618 // This is to maintain viewport position on first residue
2619 // of first sequence
2620 SequenceI seq = viewport.getAlignment().getSequenceAt(0);
2621 int startRes = seq.findPosition(viewport.startRes);
2623 addHistoryItem(new RemoveGapsCommand("Remove Gaps", seqs, start, end,
2624 viewport.getAlignment()));
2626 viewport.setStartRes(seq.findIndex(startRes) - 1);
2628 viewport.firePropertyChange("alignment", null, viewport.getAlignment()
2640 public void padGapsMenuitem_actionPerformed(ActionEvent e)
2642 viewport.setPadGaps(padGapsMenuitem.isSelected());
2643 viewport.firePropertyChange("alignment", null, viewport.getAlignment()
2654 public void findMenuItem_actionPerformed(ActionEvent e)
2660 * Create a new view of the current alignment.
2663 public void newView_actionPerformed(ActionEvent e)
2665 newView(null, true);
2669 * Creates and shows a new view of the current alignment.
2672 * title of newly created view; if null, one will be generated
2673 * @param copyAnnotation
2674 * if true then duplicate all annnotation, groups and settings
2675 * @return new alignment panel, already displayed.
2677 public AlignmentPanel newView(String viewTitle, boolean copyAnnotation)
2680 * Create a new AlignmentPanel (with its own, new Viewport)
2682 AlignmentPanel newap = new Jalview2XML().copyAlignPanel(alignPanel,
2684 if (!copyAnnotation)
2687 * remove all groups and annotation except for the automatic stuff
2689 newap.av.getAlignment().deleteAllGroups();
2690 newap.av.getAlignment().deleteAllAnnotations(false);
2693 newap.av.setGatherViewsHere(false);
2695 if (viewport.viewName == null)
2697 viewport.viewName = MessageManager
2698 .getString("label.view_name_original");
2702 * Views share the same edits, undo and redo stacks, mappings.
2704 newap.av.setHistoryList(viewport.getHistoryList());
2705 newap.av.setRedoList(viewport.getRedoList());
2706 newap.av.getAlignment().setCodonFrames(
2707 viewport.getAlignment().getCodonFrames());
2709 newap.av.viewName = getNewViewName(viewTitle);
2711 addAlignmentPanel(newap, true);
2712 newap.alignmentChanged();
2714 if (alignPanels.size() == 2)
2716 viewport.setGatherViewsHere(true);
2718 tabbedPane.setSelectedIndex(tabbedPane.getTabCount() - 1);
2723 * Make a new name for the view, ensuring it is unique within the current
2724 * sequenceSetId. (This used to be essential for Jalview Project archives, but
2725 * these now use viewId. Unique view names are still desirable for usability.)
2730 protected String getNewViewName(String viewTitle)
2732 int index = Desktop.getViewCount(viewport.getSequenceSetId());
2733 boolean addFirstIndex = false;
2734 if (viewTitle == null || viewTitle.trim().length() == 0)
2736 viewTitle = MessageManager.getString("action.view");
2737 addFirstIndex = true;
2741 index = 1;// we count from 1 if given a specific name
2743 String newViewName = viewTitle + ((addFirstIndex) ? " " + index : "");
2745 List<Component> comps = PaintRefresher.components.get(viewport
2746 .getSequenceSetId());
2748 List<String> existingNames = getExistingViewNames(comps);
2750 while (existingNames.contains(newViewName))
2752 newViewName = viewTitle + " " + (++index);
2758 * Returns a list of distinct view names found in the given list of
2759 * components. View names are held on the viewport of an AlignmentPanel.
2764 protected List<String> getExistingViewNames(List<Component> comps)
2766 List<String> existingNames = new ArrayList<String>();
2767 for (Component comp : comps)
2769 if (comp instanceof AlignmentPanel)
2771 AlignmentPanel ap = (AlignmentPanel) comp;
2772 if (!existingNames.contains(ap.av.viewName))
2774 existingNames.add(ap.av.viewName);
2778 return existingNames;
2782 * Explode tabbed views into separate windows.
2785 public void expandViews_actionPerformed(ActionEvent e)
2787 Desktop.instance.explodeViews(this);
2791 * Gather views in separate windows back into a tabbed presentation.
2794 public void gatherViews_actionPerformed(ActionEvent e)
2796 Desktop.instance.gatherViews(this);
2806 public void font_actionPerformed(ActionEvent e)
2808 new FontChooser(alignPanel);
2818 protected void seqLimit_actionPerformed(ActionEvent e)
2820 viewport.setShowJVSuffix(seqLimits.isSelected());
2822 alignPanel.getIdPanel().getIdCanvas().setPreferredSize(alignPanel
2823 .calculateIdWidth());
2824 alignPanel.paintAlignment(true);
2828 public void idRightAlign_actionPerformed(ActionEvent e)
2830 viewport.setRightAlignIds(idRightAlign.isSelected());
2831 alignPanel.paintAlignment(true);
2835 public void centreColumnLabels_actionPerformed(ActionEvent e)
2837 viewport.setCentreColumnLabels(centreColumnLabelsMenuItem.getState());
2838 alignPanel.paintAlignment(true);
2844 * @see jalview.jbgui.GAlignFrame#followHighlight_actionPerformed()
2847 protected void followHighlight_actionPerformed()
2850 * Set the 'follow' flag on the Viewport (and scroll to position if now
2853 final boolean state = this.followHighlightMenuItem.getState();
2854 viewport.setFollowHighlight(state);
2857 alignPanel.scrollToPosition(
2858 alignPanel.getSeqPanel().seqCanvas.searchResults, false);
2869 protected void colourTextMenuItem_actionPerformed(ActionEvent e)
2871 viewport.setColourText(colourTextMenuItem.isSelected());
2872 alignPanel.paintAlignment(true);
2882 public void wrapMenuItem_actionPerformed(ActionEvent e)
2884 scaleAbove.setVisible(wrapMenuItem.isSelected());
2885 scaleLeft.setVisible(wrapMenuItem.isSelected());
2886 scaleRight.setVisible(wrapMenuItem.isSelected());
2887 viewport.setWrapAlignment(wrapMenuItem.isSelected());
2888 alignPanel.updateLayout();
2892 public void showAllSeqs_actionPerformed(ActionEvent e)
2894 viewport.showAllHiddenSeqs();
2898 public void showAllColumns_actionPerformed(ActionEvent e)
2900 viewport.showAllHiddenColumns();
2905 public void hideSelSequences_actionPerformed(ActionEvent e)
2907 viewport.hideAllSelectedSeqs();
2908 // alignPanel.paintAlignment(true);
2912 * called by key handler and the hide all/show all menu items
2917 private void toggleHiddenRegions(boolean toggleSeqs, boolean toggleCols)
2920 boolean hide = false;
2921 SequenceGroup sg = viewport.getSelectionGroup();
2922 if (!toggleSeqs && !toggleCols)
2924 // Hide everything by the current selection - this is a hack - we do the
2925 // invert and then hide
2926 // first check that there will be visible columns after the invert.
2927 if ((viewport.getColumnSelection() != null
2928 && viewport.getColumnSelection().getSelected() != null && viewport
2929 .getColumnSelection().getSelected().size() > 0)
2930 || (sg != null && sg.getSize() > 0 && sg.getStartRes() <= sg
2933 // now invert the sequence set, if required - empty selection implies
2934 // that no hiding is required.
2937 invertSequenceMenuItem_actionPerformed(null);
2938 sg = viewport.getSelectionGroup();
2942 viewport.expandColSelection(sg, true);
2943 // finally invert the column selection and get the new sequence
2945 invertColSel_actionPerformed(null);
2952 if (sg != null && sg.getSize() != viewport.getAlignment().getHeight())
2954 hideSelSequences_actionPerformed(null);
2957 else if (!(toggleCols && viewport.getColumnSelection().getSelected()
2960 showAllSeqs_actionPerformed(null);
2966 if (viewport.getColumnSelection().getSelected().size() > 0)
2968 hideSelColumns_actionPerformed(null);
2971 viewport.setSelectionGroup(sg);
2976 showAllColumns_actionPerformed(null);
2985 * jalview.jbgui.GAlignFrame#hideAllButSelection_actionPerformed(java.awt.
2986 * event.ActionEvent)
2989 public void hideAllButSelection_actionPerformed(ActionEvent e)
2991 toggleHiddenRegions(false, false);
2998 * jalview.jbgui.GAlignFrame#hideAllSelection_actionPerformed(java.awt.event
3002 public void hideAllSelection_actionPerformed(ActionEvent e)
3004 SequenceGroup sg = viewport.getSelectionGroup();
3005 viewport.expandColSelection(sg, false);
3006 viewport.hideAllSelectedSeqs();
3007 viewport.hideSelectedColumns();
3008 alignPanel.paintAlignment(true);
3015 * jalview.jbgui.GAlignFrame#showAllhidden_actionPerformed(java.awt.event.
3019 public void showAllhidden_actionPerformed(ActionEvent e)
3021 viewport.showAllHiddenColumns();
3022 viewport.showAllHiddenSeqs();
3023 alignPanel.paintAlignment(true);
3027 public void hideSelColumns_actionPerformed(ActionEvent e)
3029 viewport.hideSelectedColumns();
3030 alignPanel.paintAlignment(true);
3034 public void hiddenMarkers_actionPerformed(ActionEvent e)
3036 viewport.setShowHiddenMarkers(hiddenMarkers.isSelected());
3047 protected void scaleAbove_actionPerformed(ActionEvent e)
3049 viewport.setScaleAboveWrapped(scaleAbove.isSelected());
3050 alignPanel.paintAlignment(true);
3060 protected void scaleLeft_actionPerformed(ActionEvent e)
3062 viewport.setScaleLeftWrapped(scaleLeft.isSelected());
3063 alignPanel.paintAlignment(true);
3073 protected void scaleRight_actionPerformed(ActionEvent e)
3075 viewport.setScaleRightWrapped(scaleRight.isSelected());
3076 alignPanel.paintAlignment(true);
3086 public void viewBoxesMenuItem_actionPerformed(ActionEvent e)
3088 viewport.setShowBoxes(viewBoxesMenuItem.isSelected());
3089 alignPanel.paintAlignment(true);
3099 public void viewTextMenuItem_actionPerformed(ActionEvent e)
3101 viewport.setShowText(viewTextMenuItem.isSelected());
3102 alignPanel.paintAlignment(true);
3112 protected void renderGapsMenuItem_actionPerformed(ActionEvent e)
3114 viewport.setRenderGaps(renderGapsMenuItem.isSelected());
3115 alignPanel.paintAlignment(true);
3118 public FeatureSettings featureSettings;
3121 public void featureSettings_actionPerformed(ActionEvent e)
3123 if (featureSettings != null)
3125 featureSettings.close();
3126 featureSettings = null;
3128 if (!showSeqFeatures.isSelected())
3130 // make sure features are actually displayed
3131 showSeqFeatures.setSelected(true);
3132 showSeqFeatures_actionPerformed(null);
3134 featureSettings = new FeatureSettings(this);
3138 * Set or clear 'Show Sequence Features'
3144 public void showSeqFeatures_actionPerformed(ActionEvent evt)
3146 viewport.setShowSequenceFeatures(showSeqFeatures.isSelected());
3147 alignPanel.paintAlignment(true);
3148 if (alignPanel.getOverviewPanel() != null)
3150 alignPanel.getOverviewPanel().updateOverviewImage();
3155 * Set or clear 'Show Sequence Features'
3161 public void showSeqFeaturesHeight_actionPerformed(ActionEvent evt)
3163 viewport.setShowSequenceFeaturesHeight(showSeqFeaturesHeight
3165 if (viewport.isShowSequenceFeaturesHeight())
3167 // ensure we're actually displaying features
3168 viewport.setShowSequenceFeatures(true);
3169 showSeqFeatures.setSelected(true);
3171 alignPanel.paintAlignment(true);
3172 if (alignPanel.getOverviewPanel() != null)
3174 alignPanel.getOverviewPanel().updateOverviewImage();
3179 * Action on toggle of the 'Show annotations' menu item. This shows or hides
3180 * the annotations panel as a whole.
3182 * The options to show/hide all annotations should be enabled when the panel
3183 * is shown, and disabled when the panel is hidden.
3188 public void annotationPanelMenuItem_actionPerformed(ActionEvent e)
3190 final boolean setVisible = annotationPanelMenuItem.isSelected();
3191 viewport.setShowAnnotation(setVisible);
3192 this.showAllSeqAnnotations.setEnabled(setVisible);
3193 this.hideAllSeqAnnotations.setEnabled(setVisible);
3194 this.showAllAlAnnotations.setEnabled(setVisible);
3195 this.hideAllAlAnnotations.setEnabled(setVisible);
3196 alignPanel.updateLayout();
3200 public void alignmentProperties()
3202 JEditorPane editPane = new JEditorPane("text/html", "");
3203 editPane.setEditable(false);
3204 StringBuffer contents = new AlignmentProperties(viewport.getAlignment())
3206 editPane.setText(MessageManager.formatMessage("label.html_content",
3208 { contents.toString() }));
3209 JInternalFrame frame = new JInternalFrame();
3210 frame.getContentPane().add(new JScrollPane(editPane));
3212 Desktop.addInternalFrame(frame, MessageManager.formatMessage(
3213 "label.alignment_properties", new Object[]
3214 { getTitle() }), 500, 400);
3224 public void overviewMenuItem_actionPerformed(ActionEvent e)
3226 if (alignPanel.overviewPanel != null)
3231 JInternalFrame frame = new JInternalFrame();
3232 OverviewPanel overview = new OverviewPanel(alignPanel);
3233 frame.setContentPane(overview);
3234 Desktop.addInternalFrame(frame, MessageManager.formatMessage(
3235 "label.overview_params", new Object[]
3236 { this.getTitle() }), frame.getWidth(), frame.getHeight());
3238 frame.setLayer(JLayeredPane.PALETTE_LAYER);
3239 frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
3242 public void internalFrameClosed(
3243 javax.swing.event.InternalFrameEvent evt)
3245 alignPanel.setOverviewPanel(null);
3249 alignPanel.setOverviewPanel(overview);
3253 public void textColour_actionPerformed(ActionEvent e)
3255 new TextColourChooser().chooseColour(alignPanel, null);
3265 protected void noColourmenuItem_actionPerformed(ActionEvent e)
3277 public void clustalColour_actionPerformed(ActionEvent e)
3279 changeColour(new ClustalxColourScheme(viewport.getAlignment(),
3280 viewport.getHiddenRepSequences()));
3290 public void zappoColour_actionPerformed(ActionEvent e)
3292 changeColour(new ZappoColourScheme());
3302 public void taylorColour_actionPerformed(ActionEvent e)
3304 changeColour(new TaylorColourScheme());
3314 public void hydrophobicityColour_actionPerformed(ActionEvent e)
3316 changeColour(new HydrophobicColourScheme());
3326 public void helixColour_actionPerformed(ActionEvent e)
3328 changeColour(new HelixColourScheme());
3338 public void strandColour_actionPerformed(ActionEvent e)
3340 changeColour(new StrandColourScheme());
3350 public void turnColour_actionPerformed(ActionEvent e)
3352 changeColour(new TurnColourScheme());
3362 public void buriedColour_actionPerformed(ActionEvent e)
3364 changeColour(new BuriedColourScheme());
3374 public void nucleotideColour_actionPerformed(ActionEvent e)
3376 changeColour(new NucleotideColourScheme());
3380 public void purinePyrimidineColour_actionPerformed(ActionEvent e)
3382 changeColour(new PurinePyrimidineColourScheme());
3386 * public void covariationColour_actionPerformed(ActionEvent e) {
3388 * CovariationColourScheme(viewport.getAlignment().getAlignmentAnnotation
3392 public void annotationColour_actionPerformed(ActionEvent e)
3394 new AnnotationColourChooser(viewport, alignPanel);
3398 public void annotationColumn_actionPerformed(ActionEvent e)
3400 new AnnotationColumnChooser(viewport, alignPanel);
3404 public void rnahelicesColour_actionPerformed(ActionEvent e)
3406 new RNAHelicesColourChooser(viewport, alignPanel);
3416 protected void applyToAllGroups_actionPerformed(ActionEvent e)
3418 viewport.setColourAppliesToAllGroups(applyToAllGroups.isSelected());
3427 public void changeColour(ColourSchemeI cs)
3429 // TODO: compare with applet and pull up to model method
3434 if (viewport.getAbovePIDThreshold())
3436 threshold = SliderPanel.setPIDSliderSource(alignPanel, cs,
3438 cs.setThreshold(threshold, viewport.isIgnoreGapsConsensus());
3442 cs.setThreshold(0, viewport.isIgnoreGapsConsensus());
3445 if (viewport.getConservationSelected())
3448 Alignment al = (Alignment) viewport.getAlignment();
3449 Conservation c = new Conservation("All",
3450 ResidueProperties.propHash, 3, al.getSequences(), 0,
3454 c.verdict(false, viewport.getConsPercGaps());
3456 cs.setConservation(c);
3458 cs.setConservationInc(SliderPanel.setConservationSlider(alignPanel,
3463 cs.setConservation(null);
3466 cs.setConsensus(viewport.getSequenceConsensusHash());
3469 viewport.setGlobalColourScheme(cs);
3471 if (viewport.getColourAppliesToAllGroups())
3474 for (SequenceGroup sg : viewport.getAlignment().getGroups())
3482 if (cs instanceof ClustalxColourScheme)
3484 sg.cs = new ClustalxColourScheme(sg,
3485 viewport.getHiddenRepSequences());
3487 else if (cs instanceof UserColourScheme)
3489 sg.cs = new UserColourScheme(((UserColourScheme) cs).getColours());
3495 sg.cs = cs.getClass().newInstance();
3496 } catch (Exception ex)
3501 if (viewport.getAbovePIDThreshold()
3502 || cs instanceof PIDColourScheme
3503 || cs instanceof Blosum62ColourScheme)
3505 sg.cs.setThreshold(threshold, viewport.isIgnoreGapsConsensus());
3507 sg.cs.setConsensus(AAFrequency.calculate(
3508 sg.getSequences(viewport.getHiddenRepSequences()),
3509 sg.getStartRes(), sg.getEndRes() + 1));
3513 sg.cs.setThreshold(0, viewport.isIgnoreGapsConsensus());
3516 if (viewport.getConservationSelected())
3518 Conservation c = new Conservation("Group",
3519 ResidueProperties.propHash, 3, sg.getSequences(viewport
3520 .getHiddenRepSequences()), sg.getStartRes(),
3521 sg.getEndRes() + 1);
3523 c.verdict(false, viewport.getConsPercGaps());
3524 sg.cs.setConservation(c);
3528 sg.cs.setConservation(null);
3533 if (alignPanel.getOverviewPanel() != null)
3535 alignPanel.getOverviewPanel().updateOverviewImage();
3538 alignPanel.paintAlignment(true);
3548 protected void modifyPID_actionPerformed(ActionEvent e)
3550 if (viewport.getAbovePIDThreshold()
3551 && viewport.getGlobalColourScheme() != null)
3553 SliderPanel.setPIDSliderSource(alignPanel,
3554 viewport.getGlobalColourScheme(), "Background");
3555 SliderPanel.showPIDSlider();
3566 protected void modifyConservation_actionPerformed(ActionEvent e)
3568 if (viewport.getConservationSelected()
3569 && viewport.getGlobalColourScheme() != null)
3571 SliderPanel.setConservationSlider(alignPanel,
3572 viewport.getGlobalColourScheme(), "Background");
3573 SliderPanel.showConservationSlider();
3584 protected void conservationMenuItem_actionPerformed(ActionEvent e)
3586 viewport.setConservationSelected(conservationMenuItem.isSelected());
3588 viewport.setAbovePIDThreshold(false);
3589 abovePIDThreshold.setSelected(false);
3591 changeColour(viewport.getGlobalColourScheme());
3593 modifyConservation_actionPerformed(null);
3603 public void abovePIDThreshold_actionPerformed(ActionEvent e)
3605 viewport.setAbovePIDThreshold(abovePIDThreshold.isSelected());
3607 conservationMenuItem.setSelected(false);
3608 viewport.setConservationSelected(false);
3610 changeColour(viewport.getGlobalColourScheme());
3612 modifyPID_actionPerformed(null);
3622 public void userDefinedColour_actionPerformed(ActionEvent e)
3624 if (e.getActionCommand().equals(
3625 MessageManager.getString("action.user_defined")))
3627 new UserDefinedColours(alignPanel, null);
3631 UserColourScheme udc = (UserColourScheme) UserDefinedColours
3632 .getUserColourSchemes().get(e.getActionCommand());
3638 public void updateUserColourMenu()
3641 Component[] menuItems = colourMenu.getMenuComponents();
3642 int iSize = menuItems.length;
3643 for (int i = 0; i < iSize; i++)
3645 if (menuItems[i].getName() != null
3646 && menuItems[i].getName().equals("USER_DEFINED"))
3648 colourMenu.remove(menuItems[i]);
3652 if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null)
3654 java.util.Enumeration userColours = jalview.gui.UserDefinedColours
3655 .getUserColourSchemes().keys();
3657 while (userColours.hasMoreElements())
3659 final JRadioButtonMenuItem radioItem = new JRadioButtonMenuItem(
3660 userColours.nextElement().toString());
3661 radioItem.setName("USER_DEFINED");
3662 radioItem.addMouseListener(new MouseAdapter()
3665 public void mousePressed(MouseEvent evt)
3667 if (evt.isControlDown()
3668 || SwingUtilities.isRightMouseButton(evt))
3670 radioItem.removeActionListener(radioItem.getActionListeners()[0]);
3672 int option = JOptionPane.showInternalConfirmDialog(
3673 jalview.gui.Desktop.desktop,
3675 .getString("label.remove_from_default_list"),
3677 .getString("label.remove_user_defined_colour"),
3678 JOptionPane.YES_NO_OPTION);
3679 if (option == JOptionPane.YES_OPTION)
3681 jalview.gui.UserDefinedColours
3682 .removeColourFromDefaults(radioItem.getText());
3683 colourMenu.remove(radioItem);
3687 radioItem.addActionListener(new ActionListener()
3690 public void actionPerformed(ActionEvent evt)
3692 userDefinedColour_actionPerformed(evt);
3699 radioItem.addActionListener(new ActionListener()
3702 public void actionPerformed(ActionEvent evt)
3704 userDefinedColour_actionPerformed(evt);
3708 colourMenu.insert(radioItem, 15);
3709 colours.add(radioItem);
3721 public void PIDColour_actionPerformed(ActionEvent e)
3723 changeColour(new PIDColourScheme());
3733 public void BLOSUM62Colour_actionPerformed(ActionEvent e)
3735 changeColour(new Blosum62ColourScheme());
3745 public void sortPairwiseMenuItem_actionPerformed(ActionEvent e)
3747 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
3748 AlignmentSorter.sortByPID(viewport.getAlignment(), viewport
3749 .getAlignment().getSequenceAt(0), null);
3750 addHistoryItem(new OrderCommand("Pairwise Sort", oldOrder,
3751 viewport.getAlignment()));
3752 alignPanel.paintAlignment(true);
3762 public void sortIDMenuItem_actionPerformed(ActionEvent e)
3764 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
3765 AlignmentSorter.sortByID(viewport.getAlignment());
3766 addHistoryItem(new OrderCommand("ID Sort", oldOrder,
3767 viewport.getAlignment()));
3768 alignPanel.paintAlignment(true);
3778 public void sortLengthMenuItem_actionPerformed(ActionEvent e)
3780 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
3781 AlignmentSorter.sortByLength(viewport.getAlignment());
3782 addHistoryItem(new OrderCommand("Length Sort", oldOrder,
3783 viewport.getAlignment()));
3784 alignPanel.paintAlignment(true);
3794 public void sortGroupMenuItem_actionPerformed(ActionEvent e)
3796 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
3797 AlignmentSorter.sortByGroup(viewport.getAlignment());
3798 addHistoryItem(new OrderCommand("Group Sort", oldOrder,
3799 viewport.getAlignment()));
3801 alignPanel.paintAlignment(true);
3811 public void removeRedundancyMenuItem_actionPerformed(ActionEvent e)
3813 new RedundancyPanel(alignPanel, this);
3823 public void pairwiseAlignmentMenuItem_actionPerformed(ActionEvent e)
3825 if ((viewport.getSelectionGroup() == null)
3826 || (viewport.getSelectionGroup().getSize() < 2))
3828 JOptionPane.showInternalMessageDialog(this, MessageManager
3829 .getString("label.you_must_select_least_two_sequences"),
3830 MessageManager.getString("label.invalid_selection"),
3831 JOptionPane.WARNING_MESSAGE);
3835 JInternalFrame frame = new JInternalFrame();
3836 frame.setContentPane(new PairwiseAlignPanel(viewport));
3837 Desktop.addInternalFrame(frame,
3838 MessageManager.getString("action.pairwise_alignment"), 600,
3850 public void PCAMenuItem_actionPerformed(ActionEvent e)
3852 if (((viewport.getSelectionGroup() != null)
3853 && (viewport.getSelectionGroup().getSize() < 4) && (viewport
3854 .getSelectionGroup().getSize() > 0))
3855 || (viewport.getAlignment().getHeight() < 4))
3858 .showInternalMessageDialog(
3861 .getString("label.principal_component_analysis_must_take_least_four_input_sequences"),
3863 .getString("label.sequence_selection_insufficient"),
3864 JOptionPane.WARNING_MESSAGE);
3869 new PCAPanel(alignPanel);
3873 public void autoCalculate_actionPerformed(ActionEvent e)
3875 viewport.autoCalculateConsensus = autoCalculate.isSelected();
3876 if (viewport.autoCalculateConsensus)
3878 viewport.firePropertyChange("alignment", null, viewport
3879 .getAlignment().getSequences());
3884 public void sortByTreeOption_actionPerformed(ActionEvent e)
3886 viewport.sortByTree = sortByTree.isSelected();
3890 protected void listenToViewSelections_actionPerformed(ActionEvent e)
3892 viewport.followSelection = listenToViewSelections.isSelected();
3902 public void averageDistanceTreeMenuItem_actionPerformed(ActionEvent e)
3904 newTreePanel("AV", "PID", "Average distance tree using PID");
3914 public void neighbourTreeMenuItem_actionPerformed(ActionEvent e)
3916 newTreePanel("NJ", "PID", "Neighbour joining tree using PID");
3926 protected void njTreeBlosumMenuItem_actionPerformed(ActionEvent e)
3928 newTreePanel("NJ", "BL", "Neighbour joining tree using BLOSUM62");
3938 protected void avTreeBlosumMenuItem_actionPerformed(ActionEvent e)
3940 newTreePanel("AV", "BL", "Average distance tree using BLOSUM62");
3953 void newTreePanel(String type, String pwType, String title)
3957 if (viewport.getSelectionGroup() != null
3958 && viewport.getSelectionGroup().getSize() > 0)
3960 if (viewport.getSelectionGroup().getSize() < 3)
3966 .getString("label.you_need_more_two_sequences_selected_build_tree"),
3968 .getString("label.not_enough_sequences"),
3969 JOptionPane.WARNING_MESSAGE);
3973 SequenceGroup sg = viewport.getSelectionGroup();
3975 /* Decide if the selection is a column region */
3976 for (SequenceI _s : sg.getSequences())
3978 if (_s.getLength() < sg.getEndRes())
3984 .getString("label.selected_region_to_tree_may_only_contain_residues_or_gaps"),
3986 .getString("label.sequences_selection_not_aligned"),
3987 JOptionPane.WARNING_MESSAGE);
3993 title = title + " on region";
3994 tp = new TreePanel(alignPanel, type, pwType);
3998 // are the visible sequences aligned?
3999 if (!viewport.getAlignment().isAligned(false))
4005 .getString("label.sequences_must_be_aligned_before_creating_tree"),
4007 .getString("label.sequences_not_aligned"),
4008 JOptionPane.WARNING_MESSAGE);
4013 if (viewport.getAlignment().getHeight() < 2)
4018 tp = new TreePanel(alignPanel, type, pwType);
4023 if (viewport.viewName != null)
4025 title += viewport.viewName + " of ";
4028 title += this.title;
4030 Desktop.addInternalFrame(tp, title, 600, 500);
4041 public void addSortByOrderMenuItem(String title,
4042 final AlignmentOrder order)
4044 final JMenuItem item = new JMenuItem(MessageManager.formatMessage("action.by_title_param", new Object[]{title}));
4046 item.addActionListener(new java.awt.event.ActionListener()
4049 public void actionPerformed(ActionEvent e)
4051 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
4053 // TODO: JBPNote - have to map order entries to curent SequenceI
4055 AlignmentSorter.sortBy(viewport.getAlignment(), order);
4057 addHistoryItem(new OrderCommand(order.getName(), oldOrder, viewport
4060 alignPanel.paintAlignment(true);
4066 * Add a new sort by annotation score menu item
4069 * the menu to add the option to
4071 * the label used to retrieve scores for each sequence on the
4074 public void addSortByAnnotScoreMenuItem(JMenu sort,
4075 final String scoreLabel)
4077 final JMenuItem item = new JMenuItem(scoreLabel);
4079 item.addActionListener(new java.awt.event.ActionListener()
4082 public void actionPerformed(ActionEvent e)
4084 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
4085 AlignmentSorter.sortByAnnotationScore(scoreLabel,
4086 viewport.getAlignment());// ,viewport.getSelectionGroup());
4087 addHistoryItem(new OrderCommand("Sort by " + scoreLabel, oldOrder,
4088 viewport.getAlignment()));
4089 alignPanel.paintAlignment(true);
4095 * last hash for alignment's annotation array - used to minimise cost of
4098 protected int _annotationScoreVectorHash;
4101 * search the alignment and rebuild the sort by annotation score submenu the
4102 * last alignment annotation vector hash is stored to minimize cost of
4103 * rebuilding in subsequence calls.
4107 public void buildSortByAnnotationScoresMenu()
4109 if (viewport.getAlignment().getAlignmentAnnotation() == null)
4114 if (viewport.getAlignment().getAlignmentAnnotation().hashCode() != _annotationScoreVectorHash)
4116 sortByAnnotScore.removeAll();
4117 // almost certainly a quicker way to do this - but we keep it simple
4118 Hashtable scoreSorts = new Hashtable();
4119 AlignmentAnnotation aann[];
4120 for (SequenceI sqa : viewport.getAlignment().getSequences())
4122 aann = sqa.getAnnotation();
4123 for (int i = 0; aann != null && i < aann.length; i++)
4125 if (aann[i].hasScore() && aann[i].sequenceRef != null)
4127 scoreSorts.put(aann[i].label, aann[i].label);
4131 Enumeration labels = scoreSorts.keys();
4132 while (labels.hasMoreElements())
4134 addSortByAnnotScoreMenuItem(sortByAnnotScore,
4135 (String) labels.nextElement());
4137 sortByAnnotScore.setVisible(scoreSorts.size() > 0);
4140 _annotationScoreVectorHash = viewport.getAlignment()
4141 .getAlignmentAnnotation().hashCode();
4146 * Maintain the Order by->Displayed Tree menu. Creates a new menu item for a
4147 * TreePanel with an appropriate <code>jalview.analysis.AlignmentSorter</code>
4148 * call. Listeners are added to remove the menu item when the treePanel is
4149 * closed, and adjust the tree leaf to sequence mapping when the alignment is
4153 * Displayed tree window.
4155 * SortBy menu item title.
4158 public void buildTreeMenu()
4160 calculateTree.removeAll();
4161 // build the calculate menu
4163 for (final String type : new String[]
4166 String treecalcnm = MessageManager.getString("label.tree_calc_"
4167 + type.toLowerCase());
4168 for (final String pwtype : ResidueProperties.scoreMatrices.keySet())
4170 JMenuItem tm = new JMenuItem();
4171 ScoreModelI sm = ResidueProperties.scoreMatrices.get(pwtype);
4172 if (sm.isProtein() == !viewport.getAlignment().isNucleotide())
4174 String smn = MessageManager.getStringOrReturn(
4175 "label.score_model_", sm.getName());
4176 final String title = MessageManager.formatMessage(
4177 "label.treecalc_title", treecalcnm, smn);
4178 tm.setText(title);//
4179 tm.addActionListener(new java.awt.event.ActionListener()
4182 public void actionPerformed(ActionEvent e)
4184 newTreePanel(type, pwtype, title);
4187 calculateTree.add(tm);
4192 sortByTreeMenu.removeAll();
4194 List<Component> comps = PaintRefresher.components.get(viewport
4195 .getSequenceSetId());
4196 List<TreePanel> treePanels = new ArrayList<TreePanel>();
4197 for (Component comp : comps)
4199 if (comp instanceof TreePanel)
4201 treePanels.add((TreePanel) comp);
4205 if (treePanels.size() < 1)
4207 sortByTreeMenu.setVisible(false);
4211 sortByTreeMenu.setVisible(true);
4213 for (final TreePanel tp : treePanels)
4215 final JMenuItem item = new JMenuItem(tp.getTitle());
4216 item.addActionListener(new java.awt.event.ActionListener()
4219 public void actionPerformed(ActionEvent e)
4221 tp.sortByTree_actionPerformed();
4222 addHistoryItem(tp.sortAlignmentIn(alignPanel));
4227 sortByTreeMenu.add(item);
4231 public boolean sortBy(AlignmentOrder alorder, String undoname)
4233 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
4234 AlignmentSorter.sortBy(viewport.getAlignment(), alorder);
4235 if (undoname != null)
4237 addHistoryItem(new OrderCommand(undoname, oldOrder,
4238 viewport.getAlignment()));
4240 alignPanel.paintAlignment(true);
4245 * Work out whether the whole set of sequences or just the selected set will
4246 * be submitted for multiple alignment.
4249 public jalview.datamodel.AlignmentView gatherSequencesForAlignment()
4251 // Now, check we have enough sequences
4252 AlignmentView msa = null;
4254 if ((viewport.getSelectionGroup() != null)
4255 && (viewport.getSelectionGroup().getSize() > 1))
4257 // JBPNote UGLY! To prettify, make SequenceGroup and Alignment conform to
4258 // some common interface!
4260 * SequenceGroup seqs = viewport.getSelectionGroup(); int sz; msa = new
4261 * SequenceI[sz = seqs.getSize(false)];
4263 * for (int i = 0; i < sz; i++) { msa[i] = (SequenceI)
4264 * seqs.getSequenceAt(i); }
4266 msa = viewport.getAlignmentView(true);
4268 else if (viewport.getSelectionGroup() != null
4269 && viewport.getSelectionGroup().getSize() == 1)
4271 int option = JOptionPane.showConfirmDialog(this,
4272 MessageManager.getString("warn.oneseq_msainput_selection"),
4273 MessageManager.getString("label.invalid_selection"),
4274 JOptionPane.OK_CANCEL_OPTION);
4275 if (option == JOptionPane.OK_OPTION)
4277 msa = viewport.getAlignmentView(false);
4282 msa = viewport.getAlignmentView(false);
4288 * Decides what is submitted to a secondary structure prediction service: the
4289 * first sequence in the alignment, or in the current selection, or, if the
4290 * alignment is 'aligned' (ie padded with gaps), then the currently selected
4291 * region or the whole alignment. (where the first sequence in the set is the
4292 * one that the prediction will be for).
4294 public AlignmentView gatherSeqOrMsaForSecStrPrediction()
4296 AlignmentView seqs = null;
4298 if ((viewport.getSelectionGroup() != null)
4299 && (viewport.getSelectionGroup().getSize() > 0))
4301 seqs = viewport.getAlignmentView(true);
4305 seqs = viewport.getAlignmentView(false);
4307 // limit sequences - JBPNote in future - could spawn multiple prediction
4309 // TODO: viewport.getAlignment().isAligned is a global state - the local
4310 // selection may well be aligned - we preserve 2.0.8 behaviour for moment.
4311 if (!viewport.getAlignment().isAligned(false))
4313 seqs.setSequences(new SeqCigar[]
4314 { seqs.getSequences()[0] });
4315 // TODO: if seqs.getSequences().length>1 then should really have warned
4329 protected void loadTreeMenuItem_actionPerformed(ActionEvent e)
4331 // Pick the tree file
4332 JalviewFileChooser chooser = new JalviewFileChooser(
4333 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
4334 chooser.setFileView(new JalviewFileView());
4335 chooser.setDialogTitle(MessageManager
4336 .getString("label.select_newick_like_tree_file"));
4337 chooser.setToolTipText(MessageManager.getString("label.load_tree_file"));
4339 int value = chooser.showOpenDialog(null);
4341 if (value == JalviewFileChooser.APPROVE_OPTION)
4343 String choice = chooser.getSelectedFile().getPath();
4344 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
4345 jalview.io.NewickFile fin = null;
4348 fin = new jalview.io.NewickFile(choice, "File");
4349 viewport.setCurrentTree(ShowNewickTree(fin, choice).getTree());
4350 } catch (Exception ex)
4357 .getString("label.problem_reading_tree_file"),
4358 JOptionPane.WARNING_MESSAGE);
4359 ex.printStackTrace();
4361 if (fin != null && fin.hasWarningMessage())
4363 JOptionPane.showMessageDialog(Desktop.desktop, fin
4364 .getWarningMessage(), MessageManager
4365 .getString("label.possible_problem_with_tree_file"),
4366 JOptionPane.WARNING_MESSAGE);
4372 protected void tcoffeeColorScheme_actionPerformed(ActionEvent e)
4374 changeColour(new TCoffeeColourScheme(alignPanel.getAlignment()));
4377 public TreePanel ShowNewickTree(NewickFile nf, String title)
4379 return ShowNewickTree(nf, title, 600, 500, 4, 5);
4382 public TreePanel ShowNewickTree(NewickFile nf, String title,
4383 AlignmentView input)
4385 return ShowNewickTree(nf, title, input, 600, 500, 4, 5);
4388 public TreePanel ShowNewickTree(NewickFile nf, String title, int w,
4389 int h, int x, int y)
4391 return ShowNewickTree(nf, title, null, w, h, x, y);
4395 * Add a treeviewer for the tree extracted from a newick file object to the
4396 * current alignment view
4403 * Associated alignment input data (or null)
4412 * @return TreePanel handle
4414 public TreePanel ShowNewickTree(NewickFile nf, String title,
4415 AlignmentView input, int w, int h, int x, int y)
4417 TreePanel tp = null;
4423 if (nf.getTree() != null)
4425 tp = new TreePanel(alignPanel, "FromFile", title, nf, input);
4431 tp.setLocation(x, y);
4434 Desktop.addInternalFrame(tp, title, w, h);
4436 } catch (Exception ex)
4438 ex.printStackTrace();
4444 private boolean buildingMenu = false;
4447 * Generates menu items and listener event actions for web service clients
4450 public void BuildWebServiceMenu()
4452 while (buildingMenu)
4456 System.err.println("Waiting for building menu to finish.");
4458 } catch (Exception e)
4462 final AlignFrame me = this;
4463 buildingMenu = true;
4464 new Thread(new Runnable()
4469 final List<JMenuItem> legacyItems = new ArrayList<JMenuItem>();
4472 System.err.println("Building ws menu again "
4473 + Thread.currentThread());
4474 // TODO: add support for context dependent disabling of services based
4476 // alignment and current selection
4477 // TODO: add additional serviceHandle parameter to specify abstract
4479 // class independently of AbstractName
4480 // TODO: add in rediscovery GUI function to restart discoverer
4481 // TODO: group services by location as well as function and/or
4483 // object broker mechanism.
4484 final Vector<JMenu> wsmenu = new Vector<JMenu>();
4485 final IProgressIndicator af = me;
4486 final JMenu msawsmenu = new JMenu("Alignment");
4487 final JMenu secstrmenu = new JMenu(
4488 "Secondary Structure Prediction");
4489 final JMenu seqsrchmenu = new JMenu("Sequence Database Search");
4490 final JMenu analymenu = new JMenu("Analysis");
4491 final JMenu dismenu = new JMenu("Protein Disorder");
4492 // final JMenu msawsmenu = new
4493 // JMenu(MessageManager.getString("label.alignment"));
4494 // final JMenu secstrmenu = new
4495 // JMenu(MessageManager.getString("label.secondary_structure_prediction"));
4496 // final JMenu seqsrchmenu = new
4497 // JMenu(MessageManager.getString("label.sequence_database_search"));
4498 // final JMenu analymenu = new
4499 // JMenu(MessageManager.getString("label.analysis"));
4500 // final JMenu dismenu = new
4501 // JMenu(MessageManager.getString("label.protein_disorder"));
4502 // JAL-940 - only show secondary structure prediction services from
4503 // the legacy server
4504 if (// Cache.getDefault("SHOW_JWS1_SERVICES", true)
4506 Discoverer.services != null && (Discoverer.services.size() > 0))
4508 // TODO: refactor to allow list of AbstractName/Handler bindings to
4510 // stored or retrieved from elsewhere
4511 // No MSAWS used any more:
4512 // Vector msaws = null; // (Vector)
4513 // Discoverer.services.get("MsaWS");
4514 Vector secstrpr = (Vector) Discoverer.services
4516 if (secstrpr != null)
4518 // Add any secondary structure prediction services
4519 for (int i = 0, j = secstrpr.size(); i < j; i++)
4521 final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) secstrpr
4523 jalview.ws.WSMenuEntryProviderI impl = jalview.ws.jws1.Discoverer
4524 .getServiceClient(sh);
4525 int p = secstrmenu.getItemCount();
4526 impl.attachWSMenuEntry(secstrmenu, me);
4527 int q = secstrmenu.getItemCount();
4528 for (int litm = p; litm < q; litm++)
4530 legacyItems.add(secstrmenu.getItem(litm));
4536 // Add all submenus in the order they should appear on the web
4538 wsmenu.add(msawsmenu);
4539 wsmenu.add(secstrmenu);
4540 wsmenu.add(dismenu);
4541 wsmenu.add(analymenu);
4542 // No search services yet
4543 // wsmenu.add(seqsrchmenu);
4545 javax.swing.SwingUtilities.invokeLater(new Runnable()
4552 webService.removeAll();
4553 // first, add discovered services onto the webservices menu
4554 if (wsmenu.size() > 0)
4556 for (int i = 0, j = wsmenu.size(); i < j; i++)
4558 webService.add(wsmenu.get(i));
4563 webService.add(me.webServiceNoServices);
4565 // TODO: move into separate menu builder class.
4566 boolean new_sspred = false;
4567 if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
4569 Jws2Discoverer jws2servs = Jws2Discoverer.getDiscoverer();
4570 if (jws2servs != null)
4572 if (jws2servs.hasServices())
4574 jws2servs.attachWSMenuEntry(webService, me);
4575 for (Jws2Instance sv : jws2servs.getServices())
4577 if (sv.description.toLowerCase().contains("jpred"))
4579 for (JMenuItem jmi : legacyItems)
4581 jmi.setVisible(false);
4587 if (jws2servs.isRunning())
4589 JMenuItem tm = new JMenuItem(
4590 "Still discovering JABA Services");
4591 tm.setEnabled(false);
4596 build_urlServiceMenu(me.webService);
4597 build_fetchdbmenu(webService);
4598 for (JMenu item : wsmenu)
4600 if (item.getItemCount() == 0)
4602 item.setEnabled(false);
4606 item.setEnabled(true);
4609 } catch (Exception e)
4612 .debug("Exception during web service menu building process.",
4617 } catch (Exception e)
4620 buildingMenu = false;
4627 * construct any groupURL type service menu entries.
4631 private void build_urlServiceMenu(JMenu webService)
4633 // TODO: remove this code when 2.7 is released
4634 // DEBUG - alignmentView
4636 * JMenuItem testAlView = new JMenuItem("Test AlignmentView"); final
4637 * AlignFrame af = this; testAlView.addActionListener(new ActionListener() {
4639 * @Override public void actionPerformed(ActionEvent e) {
4640 * jalview.datamodel.AlignmentView
4641 * .testSelectionViews(af.viewport.getAlignment(),
4642 * af.viewport.getColumnSelection(), af.viewport.selectionGroup); }
4644 * }); webService.add(testAlView);
4646 // TODO: refactor to RestClient discoverer and merge menu entries for
4647 // rest-style services with other types of analysis/calculation service
4648 // SHmmr test client - still being implemented.
4649 // DEBUG - alignmentView
4651 for (jalview.ws.rest.RestClient client : jalview.ws.rest.RestClient
4654 client.attachWSMenuEntry(
4655 JvSwingUtils.findOrCreateMenu(webService, client.getAction()),
4661 * public void vamsasStore_actionPerformed(ActionEvent e) { JalviewFileChooser
4662 * chooser = new JalviewFileChooser(jalview.bin.Cache.
4663 * getProperty("LAST_DIRECTORY"));
4665 * chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle("Export
4666 * to Vamsas file"); chooser.setToolTipText("Export");
4668 * int value = chooser.showSaveDialog(this);
4670 * if (value == JalviewFileChooser.APPROVE_OPTION) {
4671 * jalview.io.VamsasDatastore vs = new jalview.io.VamsasDatastore(viewport);
4672 * //vs.store(chooser.getSelectedFile().getAbsolutePath() ); vs.storeJalview(
4673 * chooser.getSelectedFile().getAbsolutePath(), this); } }
4676 * prototype of an automatically enabled/disabled analysis function
4679 protected void setShowProductsEnabled()
4681 SequenceI[] selection = viewport.getSequenceSelection();
4682 if (canShowProducts(selection, viewport.getSelectionGroup() != null,
4683 viewport.getAlignment().getDataset()))
4685 showProducts.setEnabled(true);
4690 showProducts.setEnabled(false);
4695 * search selection for sequence xRef products and build the show products
4700 * @return true if showProducts menu should be enabled.
4702 public boolean canShowProducts(SequenceI[] selection,
4703 boolean isRegionSelection, Alignment dataset)
4705 boolean showp = false;
4708 showProducts.removeAll();
4709 final boolean dna = viewport.getAlignment().isNucleotide();
4710 final Alignment ds = dataset;
4711 String[] ptypes = (selection == null || selection.length == 0) ? null
4712 : CrossRef.findSequenceXrefTypes(dna, selection, dataset);
4714 // CrossRef.buildXProductsList(viewport.getAlignment().isNucleotide(),
4715 // selection, dataset, true);
4716 final SequenceI[] sel = selection;
4717 for (int t = 0; ptypes != null && t < ptypes.length; t++)
4720 final boolean isRegSel = isRegionSelection;
4721 final AlignFrame af = this;
4722 final String source = ptypes[t];
4723 JMenuItem xtype = new JMenuItem(ptypes[t]);
4724 xtype.addActionListener(new ActionListener()
4728 public void actionPerformed(ActionEvent e)
4730 // TODO: new thread for this call with vis-delay
4731 af.showProductsFor(af.viewport.getSequenceSelection(),
4732 isRegSel, dna, source);
4736 showProducts.add(xtype);
4738 showProducts.setVisible(showp);
4739 showProducts.setEnabled(showp);
4740 } catch (Exception e)
4742 jalview.bin.Cache.log
4743 .warn("canTranslate threw an exception - please report to help@jalview.org",
4750 protected void showProductsFor(final SequenceI[] sel,
4751 final boolean isRegSel, final boolean dna, final String source)
4753 Runnable foo = new Runnable()
4759 final long sttime = System.currentTimeMillis();
4760 AlignFrame.this.setProgressBar(MessageManager.formatMessage(
4761 "status.searching_for_sequences_from", new Object[]
4762 { source }), sttime);
4765 // update our local dataset reference
4766 Alignment ds = AlignFrame.this.getViewport().getAlignment()
4768 Alignment prods = CrossRef
4769 .findXrefSequences(sel, dna, source, ds);
4772 SequenceI[] sprods = new SequenceI[prods.getHeight()];
4773 for (int s = 0; s < sprods.length; s++)
4775 sprods[s] = (prods.getSequenceAt(s)).deriveSequence();
4776 if (ds.getSequences() == null
4777 || !ds.getSequences().contains(
4778 sprods[s].getDatasetSequence()))
4780 ds.addSequence(sprods[s].getDatasetSequence());
4782 sprods[s].updatePDBIds();
4784 Alignment al = new Alignment(sprods);
4788 * Copy dna-to-protein mappings to new alignment
4790 // TODO 1: no mappings are set up for EMBL product
4791 // TODO 2: if they were, should add them to protein alignment, not
4793 Set<AlignedCodonFrame> cf = prods.getCodonFrames();
4794 for (AlignedCodonFrame acf : cf)
4796 al.addCodonFrame(acf);
4798 AlignFrame naf = new AlignFrame(al, DEFAULT_WIDTH,
4800 String newtitle = "" + ((dna) ? "Proteins" : "Nucleotides")
4801 + " for " + ((isRegSel) ? "selected region of " : "")
4803 naf.setTitle(newtitle);
4805 // temporary flag until SplitFrame is released
4806 boolean asSplitFrame = Cache.getDefault(
4807 Preferences.ENABLE_SPLIT_FRAME, false);
4811 * Make a copy of this alignment (sharing the same dataset
4812 * sequences). If we are DNA, drop introns and update mappings
4814 AlignmentI copyAlignment = null;
4815 final SequenceI[] sequenceSelection = AlignFrame.this.viewport
4816 .getSequenceSelection();
4819 copyAlignment = AlignmentUtils.makeExonAlignment(
4820 sequenceSelection, cf);
4821 al.getCodonFrames().clear();
4822 al.getCodonFrames().addAll(cf);
4823 final StructureSelectionManager ssm = StructureSelectionManager
4824 .getStructureSelectionManager(Desktop.instance);
4825 ssm.addMappings(cf);
4829 copyAlignment = new Alignment(new Alignment(
4830 sequenceSelection));
4832 AlignFrame copyThis = new AlignFrame(copyAlignment,
4833 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
4834 copyThis.setTitle(AlignFrame.this.getTitle());
4835 // SplitFrame with dna above, protein below
4836 SplitFrame sf = new SplitFrame(dna ? copyThis : naf,
4837 dna ? naf : copyThis);
4838 naf.setVisible(true);
4839 copyThis.setVisible(true);
4840 String linkedTitle = MessageManager
4841 .getString("label.linked_view_title");
4842 Desktop.addInternalFrame(sf, linkedTitle, -1, -1);
4846 Desktop.addInternalFrame(naf, newtitle, DEFAULT_WIDTH,
4852 System.err.println("No Sequences generated for xRef type "
4855 } catch (Exception e)
4857 jalview.bin.Cache.log.error(
4858 "Exception when finding crossreferences", e);
4859 } catch (OutOfMemoryError e)
4861 new OOMWarning("whilst fetching crossreferences", e);
4864 jalview.bin.Cache.log.error("Error when finding crossreferences",
4867 AlignFrame.this.setProgressBar(MessageManager.formatMessage(
4868 "status.finished_searching_for_sequences_from",
4875 Thread frunner = new Thread(foo);
4879 public boolean canShowTranslationProducts(SequenceI[] selection,
4880 AlignmentI alignment)
4885 return (jalview.analysis.Dna.canTranslate(selection,
4886 viewport.getViewAsVisibleContigs(true)));
4887 } catch (Exception e)
4889 jalview.bin.Cache.log
4890 .warn("canTranslate threw an exception - please report to help@jalview.org",
4897 * Construct and display a new frame containing the translation of this
4898 * frame's DNA sequences to their aligned protein (amino acid) equivalents.
4901 public void showTranslation_actionPerformed(ActionEvent e)
4903 AlignmentI al = null;
4906 Dna dna = new Dna(viewport, viewport.getViewAsVisibleContigs(true));
4908 al = dna.translateCdna();
4909 } catch (Exception ex)
4911 jalview.bin.Cache.log.error(
4912 "Exception during translation. Please report this !", ex);
4913 final String msg = MessageManager
4914 .getString("label.error_when_translating_sequences_submit_bug_report");
4915 final String title = MessageManager
4916 .getString("label.implementation_error")
4917 + MessageManager.getString("translation_failed");
4918 JOptionPane.showMessageDialog(Desktop.desktop, msg, title,
4919 JOptionPane.ERROR_MESSAGE);
4922 if (al == null || al.getHeight() == 0)
4924 final String msg = MessageManager
4925 .getString("label.select_at_least_three_bases_in_at_least_one_sequence_to_cDNA_translation");
4926 final String title = MessageManager
4927 .getString("label.translation_failed");
4928 JOptionPane.showMessageDialog(Desktop.desktop, msg, title,
4929 JOptionPane.WARNING_MESSAGE);
4933 AlignFrame af = new AlignFrame(al, DEFAULT_WIDTH, DEFAULT_HEIGHT);
4934 af.setFileFormat(this.currentFileFormat);
4935 final String newTitle = MessageManager.formatMessage(
4936 "label.translation_of_params", new Object[]
4937 { this.getTitle() });
4938 af.setTitle(newTitle);
4939 if (Cache.getDefault(Preferences.ENABLE_SPLIT_FRAME, false))
4941 final SequenceI[] seqs = viewport.getSelectionAsNewSequence();
4942 viewport.openSplitFrame(af, new Alignment(seqs),
4943 al.getCodonFrames());
4947 Desktop.addInternalFrame(af, newTitle, DEFAULT_WIDTH,
4954 * Set the file format
4958 public void setFileFormat(String fileFormat)
4960 this.currentFileFormat = fileFormat;
4964 * Try to load a features file onto the alignment.
4967 * contents or path to retrieve file
4969 * access mode of file (see jalview.io.AlignFile)
4970 * @return true if features file was parsed corectly.
4972 public boolean parseFeaturesFile(String file, String type)
4974 boolean featuresFile = false;
4977 featuresFile = new FeaturesFile(file, type).parse(viewport
4978 .getAlignment().getDataset(), alignPanel.getSeqPanel().seqCanvas
4979 .getFeatureRenderer().getFeatureColours(), false,
4980 jalview.bin.Cache.getDefault("RELAXEDSEQIDMATCHING", false));
4981 } catch (Exception ex)
4983 ex.printStackTrace();
4988 viewport.setShowSequenceFeatures(true);
4989 showSeqFeatures.setSelected(true);
4990 if (alignPanel.getSeqPanel().seqCanvas.fr != null)
4992 // update the min/max ranges where necessary
4993 alignPanel.getSeqPanel().seqCanvas.fr.findAllFeatures(true);
4995 if (featureSettings != null)
4997 featureSettings.setTableData();
4999 alignPanel.paintAlignment(true);
5002 return featuresFile;
5006 public void dragEnter(DropTargetDragEvent evt)
5011 public void dragExit(DropTargetEvent evt)
5016 public void dragOver(DropTargetDragEvent evt)
5021 public void dropActionChanged(DropTargetDragEvent evt)
5026 public void drop(DropTargetDropEvent evt)
5028 Transferable t = evt.getTransferable();
5029 java.util.List files = null;
5033 DataFlavor uriListFlavor = new DataFlavor(
5034 "text/uri-list;class=java.lang.String");
5035 if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor))
5037 // Works on Windows and MacOSX
5038 evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
5039 files = (java.util.List) t
5040 .getTransferData(DataFlavor.javaFileListFlavor);
5042 else if (t.isDataFlavorSupported(uriListFlavor))
5044 // This is used by Unix drag system
5045 evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
5046 String data = (String) t.getTransferData(uriListFlavor);
5047 files = new java.util.ArrayList(1);
5048 for (java.util.StringTokenizer st = new java.util.StringTokenizer(
5049 data, "\r\n"); st.hasMoreTokens();)
5051 String s = st.nextToken();
5052 if (s.startsWith("#"))
5054 // the line is a comment (as per the RFC 2483)
5058 java.net.URI uri = new java.net.URI(s);
5059 // check to see if we can handle this kind of URI
5060 if (uri.getScheme().toLowerCase().startsWith("http"))
5062 files.add(uri.toString());
5066 // otherwise preserve old behaviour: catch all for file objects
5067 java.io.File file = new java.io.File(uri);
5068 files.add(file.toString());
5072 } catch (Exception e)
5074 e.printStackTrace();
5080 // check to see if any of these files have names matching sequences in
5082 SequenceIdMatcher idm = new SequenceIdMatcher(viewport
5083 .getAlignment().getSequencesArray());
5085 * Object[] { String,SequenceI}
5087 ArrayList<Object[]> filesmatched = new ArrayList<Object[]>();
5088 ArrayList<String> filesnotmatched = new ArrayList<String>();
5089 for (int i = 0; i < files.size(); i++)
5091 String file = files.get(i).toString();
5093 String protocol = FormatAdapter.checkProtocol(file);
5094 if (protocol == jalview.io.FormatAdapter.FILE)
5096 File fl = new File(file);
5097 pdbfn = fl.getName();
5099 else if (protocol == jalview.io.FormatAdapter.URL)
5101 URL url = new URL(file);
5102 pdbfn = url.getFile();
5104 if (pdbfn.length() > 0)
5106 // attempt to find a match in the alignment
5107 SequenceI[] mtch = idm.findAllIdMatches(pdbfn);
5108 int l = 0, c = pdbfn.indexOf(".");
5109 while (mtch == null && c != -1)
5114 } while ((c = pdbfn.indexOf(".", l)) > l);
5117 pdbfn = pdbfn.substring(0, l);
5119 mtch = idm.findAllIdMatches(pdbfn);
5126 type = new IdentifyFile().Identify(file, protocol);
5127 } catch (Exception ex)
5133 if (type.equalsIgnoreCase("PDB"))
5135 filesmatched.add(new Object[]
5136 { file, protocol, mtch });
5141 // File wasn't named like one of the sequences or wasn't a PDB file.
5142 filesnotmatched.add(file);
5146 if (filesmatched.size() > 0)
5148 if (Cache.getDefault("AUTOASSOCIATE_PDBANDSEQS", false)
5154 "label.automatically_associate_pdb_files_with_sequences_same_name",
5161 .getString("label.automatically_associate_pdb_files_by_name"),
5162 JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)
5165 for (Object[] fm : filesmatched)
5167 // try and associate
5168 // TODO: may want to set a standard ID naming formalism for
5169 // associating PDB files which have no IDs.
5170 for (SequenceI toassoc : (SequenceI[]) fm[2])
5172 PDBEntry pe = new AssociatePdbFileWithSeq()
5173 .associatePdbWithSeq((String) fm[0],
5174 (String) fm[1], toassoc, false,
5178 System.err.println("Associated file : "
5179 + ((String) fm[0]) + " with "
5180 + toassoc.getDisplayId(true));
5184 alignPanel.paintAlignment(true);
5188 if (filesnotmatched.size() > 0)
5191 && (Cache.getDefault(
5192 "AUTOASSOCIATE_PDBANDSEQS_IGNOREOTHERS", false) || JOptionPane
5195 "<html>"+MessageManager
5197 "label.ignore_unmatched_dropped_files_info",
5202 .toString() })+"</html>",
5204 .getString("label.ignore_unmatched_dropped_files"),
5205 JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION))
5209 for (String fn : filesnotmatched)
5211 loadJalviewDataFile(fn, null, null, null);
5215 } catch (Exception ex)
5217 ex.printStackTrace();
5223 * Attempt to load a "dropped" file or URL string: First by testing whether
5224 * it's and Annotation file, then a JNet file, and finally a features file. If
5225 * all are false then the user may have dropped an alignment file onto this
5229 * either a filename or a URL string.
5231 public void loadJalviewDataFile(String file, String protocol,
5232 String format, SequenceI assocSeq)
5236 if (protocol == null)
5238 protocol = jalview.io.FormatAdapter.checkProtocol(file);
5240 // if the file isn't identified, or not positively identified as some
5241 // other filetype (PFAM is default unidentified alignment file type) then
5242 // try to parse as annotation.
5243 boolean isAnnotation = (format == null || format
5244 .equalsIgnoreCase("PFAM")) ? new AnnotationFile()
5245 .annotateAlignmentView(viewport, file, protocol)
5250 // first see if its a T-COFFEE score file
5251 TCoffeeScoreFile tcf = null;
5254 tcf = new TCoffeeScoreFile(file, protocol);
5257 if (tcf.annotateAlignment(viewport.getAlignment(), true))
5259 tcoffeeColour.setEnabled(true);
5260 tcoffeeColour.setSelected(true);
5261 changeColour(new TCoffeeColourScheme(viewport.getAlignment()));
5262 isAnnotation = true;
5264 .setText(MessageManager
5265 .getString("label.successfully_pasted_tcoffee_scores_to_alignment"));
5269 // some problem - if no warning its probable that the ID matching
5270 // process didn't work
5274 tcf.getWarningMessage() == null ? MessageManager
5275 .getString("label.check_file_matches_sequence_ids_alignment")
5276 : tcf.getWarningMessage(),
5278 .getString("label.problem_reading_tcoffee_score_file"),
5279 JOptionPane.WARNING_MESSAGE);
5286 } catch (Exception x)
5289 .debug("Exception when processing data source as T-COFFEE score file",
5295 // try to see if its a JNet 'concise' style annotation file *before*
5297 // try to parse it as a features file
5300 format = new IdentifyFile().Identify(file, protocol);
5302 if (format.equalsIgnoreCase("JnetFile"))
5304 jalview.io.JPredFile predictions = new jalview.io.JPredFile(
5306 new JnetAnnotationMaker();
5307 JnetAnnotationMaker.add_annotation(predictions,
5308 viewport.getAlignment(), 0, false);
5309 SequenceI repseq = viewport.getAlignment().getSequenceAt(0);
5310 viewport.getAlignment().setSeqrep(repseq);
5311 ColumnSelection cs = new ColumnSelection();
5312 cs.hideInsertionsFor(repseq);
5313 viewport.setColumnSelection(cs);
5314 isAnnotation = true;
5319 * if (format.equalsIgnoreCase("PDB")) {
5321 * String pdbfn = ""; // try to match up filename with sequence id
5322 * try { if (protocol == jalview.io.FormatAdapter.FILE) { File fl =
5323 * new File(file); pdbfn = fl.getName(); } else if (protocol ==
5324 * jalview.io.FormatAdapter.URL) { URL url = new URL(file); pdbfn =
5325 * url.getFile(); } } catch (Exception e) { } ; if (assocSeq ==
5326 * null) { SequenceIdMatcher idm = new SequenceIdMatcher(viewport
5327 * .getAlignment().getSequencesArray()); if (pdbfn.length() > 0) {
5328 * // attempt to find a match in the alignment SequenceI mtch =
5329 * idm.findIdMatch(pdbfn); int l = 0, c = pdbfn.indexOf("."); while
5330 * (mtch == null && c != -1) { while ((c = pdbfn.indexOf(".", l)) >
5331 * l) { l = c; } if (l > -1) { pdbfn = pdbfn.substring(0, l); } mtch
5332 * = idm.findIdMatch(pdbfn); } if (mtch != null) { // try and
5333 * associate // prompt ? PDBEntry pe = new AssociatePdbFileWithSeq()
5334 * .associatePdbWithSeq(file, protocol, mtch, true); if (pe != null)
5335 * { System.err.println("Associated file : " + file + " with " +
5336 * mtch.getDisplayId(true)); alignPanel.paintAlignment(true); } } //
5337 * TODO: maybe need to load as normal otherwise return; } }
5339 // try to parse it as a features file
5340 boolean isGroupsFile = parseFeaturesFile(file, protocol);
5341 // if it wasn't a features file then we just treat it as a general
5342 // alignment file to load into the current view.
5345 new FileLoader().LoadFile(viewport, file, protocol, format);
5349 alignPanel.paintAlignment(true);
5357 alignPanel.adjustAnnotationHeight();
5358 viewport.updateSequenceIdColours();
5359 buildSortByAnnotationScoresMenu();
5360 alignPanel.paintAlignment(true);
5362 } catch (Exception ex)
5364 ex.printStackTrace();
5365 } catch (OutOfMemoryError oom)
5370 } catch (Exception x)
5376 + (protocol != null ? (protocol.equals(FormatAdapter.PASTE) ? "from clipboard."
5377 : "using " + protocol + " from " + file)
5379 + (format != null ? "(parsing as '" + format
5380 + "' file)" : ""), oom, Desktop.desktop);
5385 * Method invoked by the ChangeListener on the tabbed pane, in other words
5386 * when a different tabbed pane is selected by the user or programmatically.
5389 public void tabSelectionChanged(int index)
5393 alignPanel = alignPanels.get(index);
5394 viewport = alignPanel.av;
5395 avc.setViewportAndAlignmentPanel(viewport, alignPanel);
5396 setMenusFromViewport(viewport);
5400 * If there is a frame linked to this one in a SplitPane, switch it to the
5401 * same view tab index. No infinite recursion of calls should happen, since
5402 * tabSelectionChanged() should not get invoked on setting the selected
5403 * index to an unchanged value. Guard against setting an invalid index
5404 * before the new view peer tab has been created.
5406 final AlignViewportI peer = viewport.getCodingComplement();
5409 AlignFrame linkedAlignFrame = ((AlignViewport) peer).getAlignPanel().alignFrame;
5410 if (linkedAlignFrame.tabbedPane.getTabCount() > index)
5412 linkedAlignFrame.tabbedPane.setSelectedIndex(index);
5418 * On right mouse click on view tab, prompt for and set new view name.
5421 public void tabbedPane_mousePressed(MouseEvent e)
5423 if (SwingUtilities.isRightMouseButton(e))
5425 String msg = MessageManager.getString("label.enter_view_name");
5426 String reply = JOptionPane.showInternalInputDialog(this, msg, msg,
5427 JOptionPane.QUESTION_MESSAGE);
5431 viewport.viewName = reply;
5432 // TODO warn if reply is in getExistingViewNames()?
5433 tabbedPane.setTitleAt(tabbedPane.getSelectedIndex(), reply);
5438 public AlignViewport getCurrentView()
5444 * Open the dialog for regex description parsing.
5447 protected void extractScores_actionPerformed(ActionEvent e)
5449 ParseProperties pp = new jalview.analysis.ParseProperties(
5450 viewport.getAlignment());
5451 // TODO: verify regex and introduce GUI dialog for version 2.5
5452 // if (pp.getScoresFromDescription("col", "score column ",
5453 // "\\W*([-+]?\\d*\\.?\\d*e?-?\\d*)\\W+([-+]?\\d*\\.?\\d*e?-?\\d*)",
5455 if (pp.getScoresFromDescription("description column",
5456 "score in description column ", "\\W*([-+eE0-9.]+)", true) > 0)
5458 buildSortByAnnotationScoresMenu();
5466 * jalview.jbgui.GAlignFrame#showDbRefs_actionPerformed(java.awt.event.ActionEvent
5470 protected void showDbRefs_actionPerformed(ActionEvent e)
5472 viewport.setShowDBRefs(showDbRefsMenuitem.isSelected());
5478 * @seejalview.jbgui.GAlignFrame#showNpFeats_actionPerformed(java.awt.event.
5482 protected void showNpFeats_actionPerformed(ActionEvent e)
5484 viewport.setShowNPFeats(showNpFeatsMenuitem.isSelected());
5488 * find the viewport amongst the tabs in this alignment frame and close that
5493 public boolean closeView(AlignViewportI av)
5497 this.closeMenuItem_actionPerformed(false);
5500 Component[] comp = tabbedPane.getComponents();
5501 for (int i = 0; comp != null && i < comp.length; i++)
5503 if (comp[i] instanceof AlignmentPanel)
5505 if (((AlignmentPanel) comp[i]).av == av)
5508 closeView((AlignmentPanel) comp[i]);
5516 protected void build_fetchdbmenu(JMenu webService)
5518 // Temporary hack - DBRef Fetcher always top level ws entry.
5519 // TODO We probably want to store a sequence database checklist in
5520 // preferences and have checkboxes.. rather than individual sources selected
5522 final JMenu rfetch = new JMenu(
5523 MessageManager.getString("action.fetch_db_references"));
5524 rfetch.setToolTipText(MessageManager
5525 .getString("label.retrieve_parse_sequence_database_records_alignment_or_selected_sequences"));
5526 webService.add(rfetch);
5528 final JCheckBoxMenuItem trimrs = new JCheckBoxMenuItem(
5529 MessageManager.getString("option.trim_retrieved_seqs"));
5530 trimrs.setToolTipText(MessageManager
5531 .getString("label.trim_retrieved_sequences"));
5532 trimrs.setSelected(Cache.getDefault("TRIM_FETCHED_DATASET_SEQS", true));
5533 trimrs.addActionListener(new ActionListener()
5536 public void actionPerformed(ActionEvent e)
5538 trimrs.setSelected(trimrs.isSelected());
5539 Cache.setProperty("TRIM_FETCHED_DATASET_SEQS",
5540 Boolean.valueOf(trimrs.isSelected()).toString());
5544 JMenuItem fetchr = new JMenuItem(
5545 MessageManager.getString("label.standard_databases"));
5546 fetchr.setToolTipText(MessageManager
5547 .getString("label.fetch_embl_uniprot"));
5548 fetchr.addActionListener(new ActionListener()
5552 public void actionPerformed(ActionEvent e)
5554 new Thread(new Runnable()
5560 new jalview.ws.DBRefFetcher(alignPanel.av
5561 .getSequenceSelection(), alignPanel.alignFrame)
5562 .fetchDBRefs(false);
5570 final AlignFrame me = this;
5571 new Thread(new Runnable()
5576 final jalview.ws.SequenceFetcher sf = SequenceFetcher
5577 .getSequenceFetcherSingleton(me);
5578 javax.swing.SwingUtilities.invokeLater(new Runnable()
5583 String[] dbclasses = sf.getOrderedSupportedSources();
5584 // sf.getDbInstances(jalview.ws.dbsources.DasSequenceSource.class);
5585 // jalview.util.QuickSort.sort(otherdb, otherdb);
5586 List<DbSourceProxy> otherdb;
5587 JMenu dfetch = new JMenu();
5588 JMenu ifetch = new JMenu();
5589 JMenuItem fetchr = null;
5590 int comp = 0, icomp = 0, mcomp = 15;
5591 String mname = null;
5593 for (String dbclass : dbclasses)
5595 otherdb = sf.getSourceProxy(dbclass);
5596 // add a single entry for this class, or submenu allowing 'fetch
5598 if (otherdb == null || otherdb.size() < 1)
5602 // List<DbSourceProxy> dbs=otherdb;
5603 // otherdb=new ArrayList<DbSourceProxy>();
5604 // for (DbSourceProxy db:dbs)
5606 // if (!db.isA(DBRefSource.ALIGNMENTDB)
5610 mname = "From " + dbclass;
5612 if (otherdb.size() == 1)
5614 final DbSourceProxy[] dassource = otherdb
5615 .toArray(new DbSourceProxy[0]);
5616 DbSourceProxy src = otherdb.get(0);
5617 fetchr = new JMenuItem(src.getDbSource());
5618 fetchr.addActionListener(new ActionListener()
5622 public void actionPerformed(ActionEvent e)
5624 new Thread(new Runnable()
5630 new jalview.ws.DBRefFetcher(alignPanel.av
5631 .getSequenceSelection(),
5632 alignPanel.alignFrame, dassource)
5633 .fetchDBRefs(false);
5639 fetchr.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager.formatMessage("label.fetch_retrieve_from", new Object[]{src.getDbName()})));
5645 final DbSourceProxy[] dassource = otherdb
5646 .toArray(new DbSourceProxy[0]);
5648 DbSourceProxy src = otherdb.get(0);
5649 fetchr = new JMenuItem(MessageManager.formatMessage(
5650 "label.fetch_all_param", new Object[]
5651 { src.getDbSource() }));
5652 fetchr.addActionListener(new ActionListener()
5655 public void actionPerformed(ActionEvent e)
5657 new Thread(new Runnable()
5663 new jalview.ws.DBRefFetcher(alignPanel.av
5664 .getSequenceSelection(),
5665 alignPanel.alignFrame, dassource)
5666 .fetchDBRefs(false);
5672 fetchr.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager.formatMessage("label.fetch_retrieve_from_all_sources", new Object[]{Integer.valueOf(otherdb.size()).toString(), src.getDbSource(), src.getDbName()})));
5675 // and then build the rest of the individual menus
5676 ifetch = new JMenu(MessageManager.formatMessage("label.source_from_db_source", new Object[]{src.getDbSource()}));
5678 String imname = null;
5680 for (DbSourceProxy sproxy : otherdb)
5682 String dbname = sproxy.getDbName();
5683 String sname = dbname.length() > 5 ? dbname.substring(0,
5684 5) + "..." : dbname;
5685 String msname = dbname.length() > 10 ? dbname.substring(
5686 0, 10) + "..." : dbname;
5689 imname = MessageManager.formatMessage("label.from_msname", new Object[]{sname});
5691 fetchr = new JMenuItem(msname);
5692 final DbSourceProxy[] dassrc =
5694 fetchr.addActionListener(new ActionListener()
5698 public void actionPerformed(ActionEvent e)
5700 new Thread(new Runnable()
5706 new jalview.ws.DBRefFetcher(alignPanel.av
5707 .getSequenceSelection(),
5708 alignPanel.alignFrame, dassrc)
5709 .fetchDBRefs(false);
5715 fetchr.setToolTipText("<html>"
5716 + MessageManager.formatMessage("label.fetch_retrieve_from", new Object[]{dbname}));
5719 if (++icomp >= mcomp || i == (otherdb.size()))
5721 ifetch.setText(MessageManager.formatMessage(
5722 "label.source_to_target", imname, sname));
5724 ifetch = new JMenu();
5732 if (comp >= mcomp || dbi >= (dbclasses.length))
5734 dfetch.setText(MessageManager.formatMessage(
5735 "label.source_to_target", mname, dbclass));
5737 dfetch = new JMenu();
5750 * Left justify the whole alignment.
5753 protected void justifyLeftMenuItem_actionPerformed(ActionEvent e)
5755 AlignmentI al = viewport.getAlignment();
5757 viewport.firePropertyChange("alignment", null, al);
5761 * Right justify the whole alignment.
5764 protected void justifyRightMenuItem_actionPerformed(ActionEvent e)
5766 AlignmentI al = viewport.getAlignment();
5768 viewport.firePropertyChange("alignment", null, al);
5771 public void setShowSeqFeatures(boolean b)
5773 showSeqFeatures.setSelected(true);
5774 viewport.setShowSequenceFeatures(true);
5781 * jalview.jbgui.GAlignFrame#showUnconservedMenuItem_actionPerformed(java.
5782 * awt.event.ActionEvent)
5785 protected void showUnconservedMenuItem_actionPerformed(ActionEvent e)
5787 viewport.setShowUnconserved(showNonconservedMenuItem.getState());
5788 alignPanel.paintAlignment(true);
5795 * jalview.jbgui.GAlignFrame#showGroupConsensus_actionPerformed(java.awt.event
5799 protected void showGroupConsensus_actionPerformed(ActionEvent e)
5801 viewport.setShowGroupConsensus(showGroupConsensus.getState());
5802 alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
5810 * jalview.jbgui.GAlignFrame#showGroupConservation_actionPerformed(java.awt
5811 * .event.ActionEvent)
5814 protected void showGroupConservation_actionPerformed(ActionEvent e)
5816 viewport.setShowGroupConservation(showGroupConservation.getState());
5817 alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
5824 * jalview.jbgui.GAlignFrame#showConsensusHistogram_actionPerformed(java.awt
5825 * .event.ActionEvent)
5828 protected void showConsensusHistogram_actionPerformed(ActionEvent e)
5830 viewport.setShowConsensusHistogram(showConsensusHistogram.getState());
5831 alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
5838 * jalview.jbgui.GAlignFrame#showConsensusProfile_actionPerformed(java.awt
5839 * .event.ActionEvent)
5842 protected void showSequenceLogo_actionPerformed(ActionEvent e)
5844 viewport.setShowSequenceLogo(showSequenceLogo.getState());
5845 alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
5849 protected void normaliseSequenceLogo_actionPerformed(ActionEvent e)
5851 showSequenceLogo.setState(true);
5852 viewport.setShowSequenceLogo(true);
5853 viewport.setNormaliseSequenceLogo(normaliseSequenceLogo.getState());
5854 alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
5858 protected void applyAutoAnnotationSettings_actionPerformed(ActionEvent e)
5860 alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
5867 * jalview.jbgui.GAlignFrame#makeGrpsFromSelection_actionPerformed(java.awt
5868 * .event.ActionEvent)
5871 protected void makeGrpsFromSelection_actionPerformed(ActionEvent e)
5873 if (avc.makeGroupsFromSelection())
5875 PaintRefresher.Refresh(this, viewport.getSequenceSetId());
5876 alignPanel.updateAnnotation();
5877 alignPanel.paintAlignment(true);
5880 public void clearAlignmentSeqRep()
5882 // TODO refactor alignmentseqrep to controller
5883 if (viewport.getAlignment().hasSeqrep()) {
5884 viewport.getAlignment().setSeqrep(null);
5885 PaintRefresher.Refresh(this, viewport.getSequenceSetId());
5886 alignPanel.updateAnnotation();
5887 alignPanel.paintAlignment(true);
5892 protected void createGroup_actionPerformed(ActionEvent e)
5894 if (avc.createGroup())
5896 alignPanel.alignmentChanged();
5901 protected void unGroup_actionPerformed(ActionEvent e)
5905 alignPanel.alignmentChanged();
5910 * make the given alignmentPanel the currently selected tab
5912 * @param alignmentPanel
5914 public void setDisplayedView(AlignmentPanel alignmentPanel)
5916 if (!viewport.getSequenceSetId().equals(
5917 alignmentPanel.av.getSequenceSetId()))
5919 throw new Error(MessageManager.getString("error.implementation_error_cannot_show_view_alignment_frame"));
5921 if (tabbedPane != null
5922 && tabbedPane.getTabCount() > 0
5923 && alignPanels.indexOf(alignmentPanel) != tabbedPane
5924 .getSelectedIndex())
5926 tabbedPane.setSelectedIndex(alignPanels.indexOf(alignmentPanel));
5931 * Action on selection of menu options to Show or Hide annotations.
5934 * @param forSequences
5935 * update sequence-related annotations
5936 * @param forAlignment
5937 * update non-sequence-related annotations
5940 protected void setAnnotationsVisibility(boolean visible,
5941 boolean forSequences, boolean forAlignment)
5943 for (AlignmentAnnotation aa : alignPanel.getAlignment()
5944 .getAlignmentAnnotation())
5946 boolean apply = (aa.sequenceRef == null && forAlignment)
5947 || (aa.sequenceRef != null && forSequences);
5950 aa.visible = visible;
5953 alignPanel.validateAnnotationDimensions(false);
5954 alignPanel.alignmentChanged();
5958 * Store selected annotation sort order for the view and repaint.
5961 protected void sortAnnotations_actionPerformed()
5963 this.alignPanel.av.setSortAnnotationsBy(getAnnotationSortOrder());
5965 .setShowAutocalculatedAbove(isShowAutoCalculatedAbove());
5966 alignPanel.paintAlignment(true);
5971 * @return alignment panels in this alignment frame
5973 public List<? extends AlignmentViewPanel> getAlignPanels()
5975 return alignPanels == null ? Arrays.asList(alignPanel)
5980 * Open a new alignment window, with the cDNA associated with this (protein)
5981 * alignment, aligned as is the protein.
5983 protected void viewAsCdna_actionPerformed()
5985 // TODO no longer a menu action - refactor as required
5986 final AlignmentI alignment = getViewport().getAlignment();
5987 Set<AlignedCodonFrame> mappings = alignment.getCodonFrames();
5988 if (mappings == null)
5992 List<SequenceI> cdnaSeqs = new ArrayList<SequenceI>();
5993 for (SequenceI aaSeq : alignment.getSequences()) {
5994 for (AlignedCodonFrame acf : mappings) {
5995 SequenceI dnaSeq = acf.getDnaForAaSeq(aaSeq.getDatasetSequence());
5999 * There is a cDNA mapping for this protein sequence - add to new
6000 * alignment. It will share the same dataset sequence as other mapped
6001 * cDNA (no new mappings need to be created).
6003 final Sequence newSeq = new Sequence(dnaSeq);
6004 newSeq.setDatasetSequence(dnaSeq);
6005 cdnaSeqs.add(newSeq);
6009 if (cdnaSeqs.size() == 0)
6011 // show a warning dialog no mapped cDNA
6014 AlignmentI cdna = new Alignment(cdnaSeqs.toArray(new SequenceI[cdnaSeqs
6016 AlignFrame alignFrame = new AlignFrame(cdna, AlignFrame.DEFAULT_WIDTH,
6017 AlignFrame.DEFAULT_HEIGHT);
6018 cdna.alignAs(alignment);
6019 String newtitle = "cDNA " + MessageManager.getString("label.for") + " "
6021 Desktop.addInternalFrame(alignFrame, newtitle,
6022 AlignFrame.DEFAULT_WIDTH,
6023 AlignFrame.DEFAULT_HEIGHT);
6027 * Set visibility of dna/protein complement view (available when shown in a
6033 protected void showComplement_actionPerformed(boolean show)
6035 SplitContainerI sf = getSplitViewContainer();
6037 sf.setComplementVisible(this, show);
6042 class PrintThread extends Thread
6046 public PrintThread(AlignmentPanel ap)
6051 static PageFormat pf;
6056 PrinterJob printJob = PrinterJob.getPrinterJob();
6060 printJob.setPrintable(ap, pf);
6064 printJob.setPrintable(ap);
6067 if (printJob.printDialog())
6072 } catch (Exception PrintException)
6074 PrintException.printStackTrace();