Merge branch 'Jalview-JS/develop.JAL-3446.ctrlDown' into
[jalview.git] / src / jalview / jbgui / GAlignFrame.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
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.
11  *  
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.
16  * 
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.
20  */
21 package jalview.jbgui;
22
23 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
24 import jalview.analysis.GeneticCodeI;
25 import jalview.analysis.GeneticCodes;
26 import jalview.api.SplitContainerI;
27 import jalview.bin.Cache;
28 import jalview.gui.JvSwingUtils;
29 import jalview.gui.PaintRefresher;
30 import jalview.gui.Preferences;
31 import jalview.gui.TreePanel;
32 import jalview.io.FileFormats;
33 import jalview.schemes.ResidueColourScheme;
34 import jalview.util.MessageManager;
35 import jalview.util.Platform;
36
37 import java.awt.BorderLayout;
38 import java.awt.Color;
39 import java.awt.Component;
40 import java.awt.GridLayout;
41 import java.awt.event.ActionEvent;
42 import java.awt.event.ActionListener;
43 import java.awt.event.FocusAdapter;
44 import java.awt.event.FocusEvent;
45 import java.awt.event.InputEvent;
46 import java.awt.event.KeyEvent;
47 import java.awt.event.MouseAdapter;
48 import java.awt.event.MouseEvent;
49 import java.util.ArrayList;
50 import java.util.HashMap;
51 import java.util.List;
52 import java.util.Map;
53
54 import javax.swing.BorderFactory;
55 import javax.swing.ButtonGroup;
56 import javax.swing.JCheckBoxMenuItem;
57 import javax.swing.JInternalFrame;
58 import javax.swing.JLabel;
59 import javax.swing.JMenu;
60 import javax.swing.JMenuBar;
61 import javax.swing.JMenuItem;
62 import javax.swing.JPanel;
63 import javax.swing.JRadioButtonMenuItem;
64 import javax.swing.JTabbedPane;
65 import javax.swing.KeyStroke;
66 import javax.swing.event.ChangeEvent;
67 import javax.swing.event.MenuEvent;
68 import javax.swing.event.MenuListener;
69
70 @SuppressWarnings("serial")
71 public class GAlignFrame extends JInternalFrame
72 {
73   protected JMenuBar alignFrameMenuBar = new JMenuBar();
74
75   protected JMenuItem closeMenuItem = new JMenuItem();
76
77   public JMenu webService = new JMenu();// BH 2019 was protected, but not
78                                         // sufficient for AlignFrame thread run
79
80   public JMenuItem webServiceNoServices;// BH 2019 was protected, but not
81                                         // sufficient for AlignFrame thread run
82
83   protected JCheckBoxMenuItem viewBoxesMenuItem = new JCheckBoxMenuItem();
84
85   protected JCheckBoxMenuItem viewTextMenuItem = new JCheckBoxMenuItem();
86
87   protected JMenu sortByAnnotScore = new JMenu();
88
89   public JLabel statusBar = new JLabel(); // BH 2019 was protected, but not
90                                           // sufficient for
91                                           // AlignFrame.printWriter
92
93   protected JMenu outputTextboxMenu = new JMenu();
94
95   protected JCheckBoxMenuItem annotationPanelMenuItem = new JCheckBoxMenuItem();
96
97   protected JCheckBoxMenuItem colourTextMenuItem = new JCheckBoxMenuItem();
98
99   protected JCheckBoxMenuItem showNonconservedMenuItem = new JCheckBoxMenuItem();
100
101   protected JMenuItem undoMenuItem = new JMenuItem();
102
103   protected JMenuItem redoMenuItem = new JMenuItem();
104
105   protected JCheckBoxMenuItem wrapMenuItem = new JCheckBoxMenuItem();
106
107   protected JCheckBoxMenuItem renderGapsMenuItem = new JCheckBoxMenuItem();
108
109   public JCheckBoxMenuItem showSeqFeatures = new JCheckBoxMenuItem();
110
111   JMenuItem copy = new JMenuItem();
112
113   JMenuItem cut = new JMenuItem();
114
115   JMenu pasteMenu = new JMenu();
116
117   protected JCheckBoxMenuItem seqLimits = new JCheckBoxMenuItem();
118
119   protected JCheckBoxMenuItem scaleAbove = new JCheckBoxMenuItem();
120
121   protected JCheckBoxMenuItem scaleLeft = new JCheckBoxMenuItem();
122
123   protected JCheckBoxMenuItem scaleRight = new JCheckBoxMenuItem();
124
125   protected JCheckBoxMenuItem applyToAllGroups;
126
127   protected JMenu colourMenu = new JMenu();
128
129   protected JMenuItem textColour;
130
131   protected JCheckBoxMenuItem conservationMenuItem;
132
133   protected JMenuItem modifyConservation;
134
135   protected JCheckBoxMenuItem abovePIDThreshold;
136
137   protected JMenuItem modifyPID;
138
139   protected JRadioButtonMenuItem annotationColour;
140
141   protected JMenu sortByTreeMenu = new JMenu();
142
143   protected JMenu sort = new JMenu();
144
145   protected JMenuItem calculateTree = new JMenuItem();
146
147   protected JCheckBoxMenuItem padGapsMenuitem = new JCheckBoxMenuItem();
148
149   protected JCheckBoxMenuItem showNpFeatsMenuitem = new JCheckBoxMenuItem();
150
151   protected JCheckBoxMenuItem showDbRefsMenuitem = new JCheckBoxMenuItem();
152
153   protected JMenu showTranslation = new JMenu();
154
155   protected JMenuItem showReverse = new JMenuItem();
156
157   protected JMenuItem showReverseComplement = new JMenuItem();
158
159   protected JMenu showProducts = new JMenu();
160
161   protected JMenuItem runGroovy = new JMenuItem();
162
163   protected JMenuItem loadVcf;
164
165   protected JCheckBoxMenuItem autoCalculate = new JCheckBoxMenuItem();
166
167   protected JCheckBoxMenuItem sortByTree = new JCheckBoxMenuItem();
168
169   protected JCheckBoxMenuItem listenToViewSelections = new JCheckBoxMenuItem();
170
171   protected JPanel statusPanel = new JPanel();
172
173   protected JMenuItem showAllSeqAnnotations = new JMenuItem();
174
175   protected JMenuItem hideAllSeqAnnotations = new JMenuItem();
176
177   protected JMenuItem showAllAlAnnotations = new JMenuItem();
178
179   protected JMenuItem hideAllAlAnnotations = new JMenuItem();
180
181   protected JCheckBoxMenuItem showComplementMenuItem = new JCheckBoxMenuItem();
182
183   protected JCheckBoxMenuItem hiddenMarkers = new JCheckBoxMenuItem();
184
185   protected JTabbedPane tabbedPane = new JTabbedPane();
186
187   protected JMenuItem reload = new JMenuItem();
188
189   protected JMenu formatMenu = new JMenu();
190
191   protected JCheckBoxMenuItem idRightAlign = new JCheckBoxMenuItem();
192
193   protected JCheckBoxMenuItem centreColumnLabelsMenuItem = new JCheckBoxMenuItem();
194
195   protected JCheckBoxMenuItem followHighlightMenuItem = new JCheckBoxMenuItem();
196
197   protected JMenuItem gatherViews = new JMenuItem();
198
199   protected JMenuItem expandViews = new JMenuItem();
200
201   protected JCheckBoxMenuItem showGroupConsensus = new JCheckBoxMenuItem();
202
203   protected JCheckBoxMenuItem showGroupConservation = new JCheckBoxMenuItem();
204
205   protected JCheckBoxMenuItem showConsensusHistogram = new JCheckBoxMenuItem();
206
207   protected JCheckBoxMenuItem showSequenceLogo = new JCheckBoxMenuItem();
208
209   protected JCheckBoxMenuItem normaliseSequenceLogo = new JCheckBoxMenuItem();
210
211   protected JCheckBoxMenuItem applyAutoAnnotationSettings = new JCheckBoxMenuItem();
212
213   protected JMenuItem openFeatureSettings;
214
215   private SequenceAnnotationOrder annotationSortOrder;
216
217   private boolean showAutoCalculatedAbove = false;
218
219   private Map<KeyStroke, JMenuItem> accelerators = new HashMap<>();
220
221   private SplitContainerI splitFrame;
222
223   public GAlignFrame()
224   {
225     try
226     {
227
228       // for Web-page embedding using id=align-frame-div
229       setName(Platform.getAppID("alignment"));
230
231
232       jbInit();
233       setJMenuBar(alignFrameMenuBar);
234
235       // dynamically fill save as menu with available formats
236       for (String ff : FileFormats.getInstance().getWritableFormats(true))
237       {
238         JMenuItem item = new JMenuItem(ff);
239
240         item.addActionListener(new ActionListener()
241         {
242           @Override
243           public void actionPerformed(ActionEvent e)
244           {
245             outputText_actionPerformed(e.getActionCommand());
246           }
247         });
248
249         outputTextboxMenu.add(item);
250       }
251     } catch (Exception e)
252     {
253       System.err.println(e.toString());
254     }
255
256     if (Platform.allowMnemonics()) // was "not mac and not JS"
257     {
258       closeMenuItem.setMnemonic('C');
259       outputTextboxMenu.setMnemonic('T');
260       undoMenuItem.setMnemonic('Z');
261       redoMenuItem.setMnemonic('0');
262       copy.setMnemonic('C');
263       cut.setMnemonic('U');
264       pasteMenu.setMnemonic('P');
265       reload.setMnemonic('R');
266     }
267   }
268
269   private void jbInit() throws Exception
270   {
271     initColourMenu();
272
273     JMenuItem saveAs = new JMenuItem(
274             MessageManager.getString("action.save_as"));
275     ActionListener al = new ActionListener()
276     {
277       @Override
278       public void actionPerformed(ActionEvent e)
279       {
280         saveAs_actionPerformed();
281       }
282     };
283
284     // FIXME getDefaultToolkit throws an exception in Headless mode
285     KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_S, Platform.SHORTCUT_KEY_MASK | InputEvent.SHIFT_DOWN_MASK,
286             false);
287     addMenuActionAndAccelerator(keyStroke, saveAs, al);
288
289     closeMenuItem.setText(MessageManager.getString("action.close"));
290     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_W, Platform.SHORTCUT_KEY_MASK, false);
291     al = new ActionListener()
292     {
293       @Override
294       public void actionPerformed(ActionEvent e)
295       {
296         closeMenuItem_actionPerformed(false);
297       }
298     };
299     addMenuActionAndAccelerator(keyStroke, closeMenuItem, al);
300
301     JMenu editMenu = new JMenu(MessageManager.getString("action.edit"));
302     JMenu viewMenu = new JMenu(MessageManager.getString("action.view"));
303     JMenu annotationsMenu = new JMenu(
304             MessageManager.getString("action.annotations"));
305     JMenu showMenu = new JMenu(MessageManager.getString("action.show"));
306     colourMenu.setText(MessageManager.getString("action.colour"));
307     JMenu calculateMenu = new JMenu(
308             MessageManager.getString("action.calculate"));
309     webService.setText(MessageManager.getString("action.web_service"));
310     JMenuItem selectAllSequenceMenuItem = new JMenuItem(
311             MessageManager.getString("action.select_all"));
312     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_A,
313             Platform.SHORTCUT_KEY_MASK, false);
314     al = new ActionListener()
315     {
316       @Override
317       public void actionPerformed(ActionEvent e)
318       {
319         selectAllSequenceMenuItem_actionPerformed(e);
320       }
321     };
322     addMenuActionAndAccelerator(keyStroke, selectAllSequenceMenuItem, al);
323
324     JMenuItem deselectAllSequenceMenuItem = new JMenuItem(
325             MessageManager.getString("action.deselect_all"));
326     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
327     al = new ActionListener()
328     {
329       @Override
330       public void actionPerformed(ActionEvent e)
331       {
332         deselectAllSequenceMenuItem_actionPerformed(e);
333       }
334     };
335     addMenuActionAndAccelerator(keyStroke, deselectAllSequenceMenuItem, al);
336
337     JMenuItem invertSequenceMenuItem = new JMenuItem(
338             MessageManager.getString("action.invert_sequence_selection"));
339     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_I,
340             Platform.SHORTCUT_KEY_MASK, false);
341     al = new ActionListener()
342     {
343       @Override
344       public void actionPerformed(ActionEvent e)
345       {
346         invertSequenceMenuItem_actionPerformed(e);
347       }
348     };
349     addMenuActionAndAccelerator(keyStroke, invertSequenceMenuItem, al);
350
351     JMenuItem grpsFromSelection = new JMenuItem(
352             MessageManager.getString("action.make_groups_selection"));
353     grpsFromSelection.addActionListener(new ActionListener()
354     {
355       @Override
356       public void actionPerformed(ActionEvent e)
357       {
358         makeGrpsFromSelection_actionPerformed(e);
359       }
360     });
361     JMenuItem expandAlignment = new JMenuItem(
362             MessageManager.getString("action.view_flanking_regions"));
363     expandAlignment.setToolTipText(
364             MessageManager.getString("label.view_flanking_regions"));
365     expandAlignment.addActionListener(new ActionListener()
366     {
367       @Override
368       public void actionPerformed(ActionEvent e)
369       {
370         expand_newalign(e);
371       }
372     });
373     JMenuItem remove2LeftMenuItem = new JMenuItem(
374             MessageManager.getString("action.remove_left"));
375     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_L,
376             Platform.SHORTCUT_KEY_MASK, false);
377     al = new ActionListener()
378     {
379       @Override
380       public void actionPerformed(ActionEvent e)
381       {
382         remove2LeftMenuItem_actionPerformed(e);
383       }
384     };
385     addMenuActionAndAccelerator(keyStroke, remove2LeftMenuItem, al);
386
387     JMenuItem remove2RightMenuItem = new JMenuItem(
388             MessageManager.getString("action.remove_right"));
389     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_R,
390             Platform.SHORTCUT_KEY_MASK, false);
391     al = new ActionListener()
392     {
393       @Override
394       public void actionPerformed(ActionEvent e)
395       {
396         remove2RightMenuItem_actionPerformed(e);
397       }
398     };
399     addMenuActionAndAccelerator(keyStroke, remove2RightMenuItem, al);
400
401     JMenuItem removeGappedColumnMenuItem = new JMenuItem(
402             MessageManager.getString("action.remove_empty_columns"));
403     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_E,
404             Platform.SHORTCUT_KEY_MASK, false);
405     al = new ActionListener()
406     {
407       @Override
408       public void actionPerformed(ActionEvent e)
409       {
410         removeGappedColumnMenuItem_actionPerformed(e);
411       }
412     };
413     addMenuActionAndAccelerator(keyStroke, removeGappedColumnMenuItem, al);
414
415     JMenuItem removeAllGapsMenuItem = new JMenuItem(
416             MessageManager.getString("action.remove_all_gaps"));
417     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_E,
418             Platform.SHORTCUT_KEY_MASK
419                     | InputEvent.SHIFT_DOWN_MASK,
420             false);
421     al = new ActionListener()
422     {
423       @Override
424       public void actionPerformed(ActionEvent e)
425       {
426         removeAllGapsMenuItem_actionPerformed(e);
427       }
428     };
429     addMenuActionAndAccelerator(keyStroke, removeAllGapsMenuItem, al);
430
431     JMenuItem justifyLeftMenuItem = new JMenuItem(
432             MessageManager.getString("action.left_justify_alignment"));
433     justifyLeftMenuItem.addActionListener(new ActionListener()
434     {
435       @Override
436       public void actionPerformed(ActionEvent e)
437       {
438         justifyLeftMenuItem_actionPerformed(e);
439       }
440     });
441     JMenuItem justifyRightMenuItem = new JMenuItem(
442             MessageManager.getString("action.right_justify_alignment"));
443     justifyRightMenuItem.addActionListener(new ActionListener()
444     {
445       @Override
446       public void actionPerformed(ActionEvent e)
447       {
448         justifyRightMenuItem_actionPerformed(e);
449       }
450     });
451     viewBoxesMenuItem.setText(MessageManager.getString("action.boxes"));
452     viewBoxesMenuItem.setState(true);
453     viewBoxesMenuItem.addActionListener(new ActionListener()
454     {
455       @Override
456       public void actionPerformed(ActionEvent e)
457       {
458         viewBoxesMenuItem_actionPerformed(e);
459       }
460     });
461     viewTextMenuItem.setText(MessageManager.getString("action.text"));
462     viewTextMenuItem.setState(true);
463     viewTextMenuItem.addActionListener(new ActionListener()
464     {
465       @Override
466       public void actionPerformed(ActionEvent e)
467       {
468         viewTextMenuItem_actionPerformed(e);
469       }
470     });
471     showNonconservedMenuItem
472             .setText(MessageManager.getString("label.show_non_conserved"));
473     showNonconservedMenuItem.setState(false);
474     showNonconservedMenuItem.addActionListener(new ActionListener()
475     {
476       @Override
477       public void actionPerformed(ActionEvent e)
478       {
479         showUnconservedMenuItem_actionPerformed(e);
480       }
481     });
482     JMenuItem sortPairwiseMenuItem = new JMenuItem(
483             MessageManager.getString("action.by_pairwise_id"));
484     sortPairwiseMenuItem.addActionListener(new ActionListener()
485     {
486       @Override
487       public void actionPerformed(ActionEvent e)
488       {
489         sortPairwiseMenuItem_actionPerformed(e);
490       }
491     });
492     JMenuItem sortIDMenuItem = new JMenuItem(
493             MessageManager.getString("action.by_id"));
494     sortIDMenuItem.addActionListener(new ActionListener()
495     {
496       @Override
497       public void actionPerformed(ActionEvent e)
498       {
499         sortIDMenuItem_actionPerformed(e);
500       }
501     });
502     JMenuItem sortLengthMenuItem = new JMenuItem(
503             MessageManager.getString("action.by_length"));
504     sortLengthMenuItem.addActionListener(new ActionListener()
505     {
506       @Override
507       public void actionPerformed(ActionEvent e)
508       {
509         sortLengthMenuItem_actionPerformed(e);
510       }
511     });
512     JMenuItem sortGroupMenuItem = new JMenuItem(
513             MessageManager.getString("action.by_group"));
514     sortGroupMenuItem.addActionListener(new ActionListener()
515     {
516       @Override
517       public void actionPerformed(ActionEvent e)
518       {
519         sortGroupMenuItem_actionPerformed(e);
520       }
521     });
522
523     JMenuItem removeRedundancyMenuItem = new JMenuItem(
524             MessageManager.getString("action.remove_redundancy"));
525     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_D,
526             Platform.SHORTCUT_KEY_MASK, false);
527     al = new ActionListener()
528     {
529       @Override
530       public void actionPerformed(ActionEvent e)
531       {
532         removeRedundancyMenuItem_actionPerformed(e);
533       }
534     };
535     addMenuActionAndAccelerator(keyStroke, removeRedundancyMenuItem, al);
536
537     JMenuItem pairwiseAlignmentMenuItem = new JMenuItem(
538             MessageManager.getString("action.pairwise_alignment"));
539     pairwiseAlignmentMenuItem.addActionListener(new ActionListener()
540     {
541       @Override
542       public void actionPerformed(ActionEvent e)
543       {
544         pairwiseAlignmentMenuItem_actionPerformed(e);
545       }
546     });
547
548     this.getContentPane().setLayout(new BorderLayout());
549     alignFrameMenuBar.setFont(new java.awt.Font("Verdana", 0, 11));
550     statusBar.setBackground(Color.white);
551     statusBar.setFont(new java.awt.Font("Verdana", 0, 11));
552     statusBar.setBorder(BorderFactory.createLineBorder(Color.black));
553     statusBar.setText(MessageManager.getString("label.status_bar"));
554     outputTextboxMenu
555             .setText(MessageManager.getString("label.out_to_textbox"));
556
557     annotationPanelMenuItem.setActionCommand("");
558     annotationPanelMenuItem
559             .setText(MessageManager.getString("label.show_annotations"));
560     annotationPanelMenuItem
561             .setState(Cache.getDefault("SHOW_ANNOTATIONS", true));
562     annotationPanelMenuItem.addActionListener(new ActionListener()
563     {
564       @Override
565       public void actionPerformed(ActionEvent e)
566       {
567         annotationPanelMenuItem_actionPerformed(e);
568       }
569     });
570     showAllAlAnnotations.setText(
571             MessageManager.getString("label.show_all_al_annotations"));
572     final boolean isAnnotationPanelShown = annotationPanelMenuItem
573             .getState();
574     showAllAlAnnotations.setEnabled(isAnnotationPanelShown);
575     showAllAlAnnotations.addActionListener(new ActionListener()
576     {
577       @Override
578       public void actionPerformed(ActionEvent e)
579       {
580         showAllAnnotations_actionPerformed(false, true);
581       }
582     });
583     hideAllAlAnnotations.setText(
584             MessageManager.getString("label.hide_all_al_annotations"));
585     hideAllAlAnnotations.setEnabled(isAnnotationPanelShown);
586     hideAllAlAnnotations.addActionListener(new ActionListener()
587     {
588       @Override
589       public void actionPerformed(ActionEvent e)
590       {
591         hideAllAnnotations_actionPerformed(false, true);
592       }
593     });
594     showAllSeqAnnotations.setText(
595             MessageManager.getString("label.show_all_seq_annotations"));
596     showAllSeqAnnotations.setEnabled(isAnnotationPanelShown);
597     showAllSeqAnnotations.addActionListener(new ActionListener()
598     {
599       @Override
600       public void actionPerformed(ActionEvent e)
601       {
602         showAllAnnotations_actionPerformed(true, false);
603       }
604     });
605     hideAllSeqAnnotations.setText(
606             MessageManager.getString("label.hide_all_seq_annotations"));
607     hideAllSeqAnnotations.setEnabled(isAnnotationPanelShown);
608     hideAllSeqAnnotations.addActionListener(new ActionListener()
609     {
610       @Override
611       public void actionPerformed(ActionEvent e)
612       {
613         hideAllAnnotations_actionPerformed(true, false);
614       }
615     });
616     SequenceAnnotationOrder sortAnnotationsBy = SequenceAnnotationOrder
617             .valueOf(Cache.getDefault(Preferences.SORT_ANNOTATIONS,
618                     SequenceAnnotationOrder.NONE.name()));
619     final JCheckBoxMenuItem sortAnnBySequence = new JCheckBoxMenuItem(
620             MessageManager.getString("label.sort_annotations_by_sequence"));
621     final JCheckBoxMenuItem sortAnnByLabel = new JCheckBoxMenuItem(
622             MessageManager.getString("label.sort_annotations_by_label"));
623
624     sortAnnBySequence.setSelected(
625             sortAnnotationsBy == SequenceAnnotationOrder.SEQUENCE_AND_LABEL);
626     sortAnnBySequence.addActionListener(new ActionListener()
627     {
628       @Override
629       public void actionPerformed(ActionEvent e)
630       {
631         boolean newState = sortAnnBySequence.getState();
632         sortAnnByLabel.setSelected(false);
633         setAnnotationSortOrder(
634                 newState ? SequenceAnnotationOrder.SEQUENCE_AND_LABEL
635                         : SequenceAnnotationOrder.NONE);
636         sortAnnotations_actionPerformed();
637       }
638     });
639     sortAnnByLabel.setSelected(
640             sortAnnotationsBy == SequenceAnnotationOrder.LABEL_AND_SEQUENCE);
641     sortAnnByLabel.addActionListener(new ActionListener()
642     {
643       @Override
644       public void actionPerformed(ActionEvent e)
645       {
646         boolean newState = sortAnnByLabel.getState();
647         sortAnnBySequence.setSelected(false);
648         setAnnotationSortOrder(
649                 newState ? SequenceAnnotationOrder.LABEL_AND_SEQUENCE
650                         : SequenceAnnotationOrder.NONE);
651         sortAnnotations_actionPerformed();
652       }
653     });
654     colourTextMenuItem = new JCheckBoxMenuItem(
655             MessageManager.getString("label.colour_text"));
656     colourTextMenuItem.addActionListener(new ActionListener()
657     {
658       @Override
659       public void actionPerformed(ActionEvent e)
660       {
661         colourTextMenuItem_actionPerformed(e);
662       }
663     });
664
665     JMenuItem htmlMenuItem = new JMenuItem(
666             MessageManager.getString("label.html"));
667     htmlMenuItem.addActionListener(new ActionListener()
668     {
669       @Override
670       public void actionPerformed(ActionEvent e)
671       {
672         htmlMenuItem_actionPerformed(e);
673       }
674     });
675
676     JMenuItem createBioJS = new JMenuItem(
677             MessageManager.getString("label.biojs_html_export"));
678     createBioJS.addActionListener(new java.awt.event.ActionListener()
679     {
680       @Override
681       public void actionPerformed(ActionEvent e)
682       {
683         bioJSMenuItem_actionPerformed(e);
684       }
685     });
686
687     JMenuItem overviewMenuItem = new JMenuItem(
688             MessageManager.getString("label.overview_window"));
689     overviewMenuItem.addActionListener(new ActionListener()
690     {
691       @Override
692       public void actionPerformed(ActionEvent e)
693       {
694         overviewMenuItem_actionPerformed(e);
695       }
696     });
697
698     undoMenuItem.setEnabled(false);
699     undoMenuItem.setText(MessageManager.getString("action.undo"));
700     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_Z,
701             Platform.SHORTCUT_KEY_MASK, false);
702     al = new ActionListener()
703     {
704       @Override
705       public void actionPerformed(ActionEvent e)
706       {
707         undoMenuItem_actionPerformed(e);
708       }
709     };
710     addMenuActionAndAccelerator(keyStroke, undoMenuItem, al);
711
712     redoMenuItem.setEnabled(false);
713     redoMenuItem.setText(MessageManager.getString("action.redo"));
714     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_Y,
715             Platform.SHORTCUT_KEY_MASK, false);
716     al = new ActionListener()
717     {
718       @Override
719       public void actionPerformed(ActionEvent e)
720       {
721         redoMenuItem_actionPerformed(e);
722       }
723     };
724     addMenuActionAndAccelerator(keyStroke, redoMenuItem, al);
725
726     wrapMenuItem.setText(MessageManager.getString("label.wrap"));
727     wrapMenuItem.addActionListener(new ActionListener()
728     {
729       @Override
730       public void actionPerformed(ActionEvent e)
731       {
732         wrapMenuItem_actionPerformed(e);
733       }
734     });
735
736     JMenuItem printMenuItem = new JMenuItem(
737             MessageManager.getString("action.print"));
738     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_P,
739             Platform.SHORTCUT_KEY_MASK, false);
740     al = new ActionListener()
741     {
742       @Override
743       public void actionPerformed(ActionEvent e)
744       {
745         printMenuItem_actionPerformed(e);
746       }
747     };
748     addMenuActionAndAccelerator(keyStroke, printMenuItem, al);
749
750     renderGapsMenuItem
751             .setText(MessageManager.getString("action.show_gaps"));
752     renderGapsMenuItem.setState(true);
753     renderGapsMenuItem.addActionListener(new ActionListener()
754     {
755       @Override
756       public void actionPerformed(ActionEvent e)
757       {
758         renderGapsMenuItem_actionPerformed(e);
759       }
760     });
761
762     JMenuItem findMenuItem = new JMenuItem(
763             MessageManager.getString("action.find"));
764     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_F,
765             Platform.SHORTCUT_KEY_MASK, false);
766     findMenuItem.setToolTipText(JvSwingUtils.wrapTooltip(true,
767             MessageManager.getString("label.find_tip")));
768     al = new ActionListener()
769     {
770       @Override
771       public void actionPerformed(ActionEvent e)
772       {
773         findMenuItem_actionPerformed(e);
774       }
775     };
776     addMenuActionAndAccelerator(keyStroke, findMenuItem, al);
777
778     showSeqFeatures.setText(
779             MessageManager.getString("label.show_sequence_features"));
780     showSeqFeatures.addActionListener(new ActionListener()
781     {
782       @Override
783       public void actionPerformed(ActionEvent actionEvent)
784       {
785         showSeqFeatures_actionPerformed(actionEvent);
786       }
787     });
788     /*
789      * showSeqFeaturesHeight.setText("Vary Sequence Feature Height");
790      * showSeqFeaturesHeight.addActionListener(new ActionListener() { public
791      * void actionPerformed(ActionEvent actionEvent) {
792      * showSeqFeaturesHeight_actionPerformed(actionEvent); } });
793      */
794     showDbRefsMenuitem
795             .setText(MessageManager.getString("label.show_database_refs"));
796     showDbRefsMenuitem.addActionListener(new ActionListener()
797     {
798
799       @Override
800       public void actionPerformed(ActionEvent e)
801       {
802         showDbRefs_actionPerformed(e);
803       }
804
805     });
806     showNpFeatsMenuitem.setText(
807             MessageManager.getString("label.show_non_positional_features"));
808     showNpFeatsMenuitem.addActionListener(new ActionListener()
809     {
810
811       @Override
812       public void actionPerformed(ActionEvent e)
813       {
814         showNpFeats_actionPerformed(e);
815       }
816
817     });
818     showGroupConservation
819             .setText(MessageManager.getString("label.group_conservation"));
820     showGroupConservation.addActionListener(new ActionListener()
821     {
822
823       @Override
824       public void actionPerformed(ActionEvent e)
825       {
826         showGroupConservation_actionPerformed(e);
827       }
828
829     });
830
831     showGroupConsensus
832             .setText(MessageManager.getString("label.group_consensus"));
833     showGroupConsensus.addActionListener(new ActionListener()
834     {
835
836       @Override
837       public void actionPerformed(ActionEvent e)
838       {
839         showGroupConsensus_actionPerformed(e);
840       }
841
842     });
843     showConsensusHistogram.setText(
844             MessageManager.getString("label.show_consensus_histogram"));
845     showConsensusHistogram.addActionListener(new ActionListener()
846     {
847
848       @Override
849       public void actionPerformed(ActionEvent e)
850       {
851         showConsensusHistogram_actionPerformed(e);
852       }
853
854     });
855     showSequenceLogo
856             .setText(MessageManager.getString("label.show_consensus_logo"));
857     showSequenceLogo.addActionListener(new ActionListener()
858     {
859
860       @Override
861       public void actionPerformed(ActionEvent e)
862       {
863         showSequenceLogo_actionPerformed(e);
864       }
865
866     });
867     normaliseSequenceLogo
868             .setText(MessageManager.getString("label.norm_consensus_logo"));
869     normaliseSequenceLogo.addActionListener(new ActionListener()
870     {
871
872       @Override
873       public void actionPerformed(ActionEvent e)
874       {
875         normaliseSequenceLogo_actionPerformed(e);
876       }
877
878     });
879     applyAutoAnnotationSettings
880             .setText(MessageManager.getString("label.apply_all_groups"));
881     applyAutoAnnotationSettings.setState(false);
882     applyAutoAnnotationSettings.setVisible(true);
883     applyAutoAnnotationSettings.addActionListener(new ActionListener()
884     {
885       @Override
886       public void actionPerformed(ActionEvent e)
887       {
888         applyAutoAnnotationSettings_actionPerformed(e);
889       }
890     });
891
892     ButtonGroup buttonGroup = new ButtonGroup();
893     final JRadioButtonMenuItem showAutoFirst = new JRadioButtonMenuItem(
894             MessageManager.getString("label.show_first"));
895     final JRadioButtonMenuItem showAutoLast = new JRadioButtonMenuItem(
896             MessageManager.getString("label.show_last"));
897     buttonGroup.add(showAutoFirst);
898     buttonGroup.add(showAutoLast);
899     final boolean autoFirst = Cache
900             .getDefault(Preferences.SHOW_AUTOCALC_ABOVE, false);
901     showAutoFirst.setSelected(autoFirst);
902     setShowAutoCalculatedAbove(autoFirst);
903     showAutoFirst.addActionListener(new ActionListener()
904     {
905       @Override
906       public void actionPerformed(ActionEvent e)
907       {
908         setShowAutoCalculatedAbove(showAutoFirst.isSelected());
909         sortAnnotations_actionPerformed();
910       }
911     });
912     showAutoLast.setSelected(!showAutoFirst.isSelected());
913     showAutoLast.addActionListener(new ActionListener()
914     {
915       @Override
916       public void actionPerformed(ActionEvent e)
917       {
918         setShowAutoCalculatedAbove(!showAutoLast.isSelected());
919         sortAnnotations_actionPerformed();
920       }
921     });
922
923     JMenuItem deleteGroups = new JMenuItem(
924             MessageManager.getString("action.undefine_groups"));
925     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_U,
926             Platform.SHORTCUT_KEY_MASK, false);
927     al = new ActionListener()
928     {
929       @Override
930       public void actionPerformed(ActionEvent e)
931       {
932         deleteGroups_actionPerformed(e);
933       }
934     };
935     addMenuActionAndAccelerator(keyStroke, deleteGroups, al);
936
937     JMenuItem annotationColumn = new JMenuItem(
938             MessageManager.getString("action.select_by_annotation"));
939     annotationColumn.addActionListener(new ActionListener()
940     {
941       @Override
942       public void actionPerformed(ActionEvent e)
943       {
944         annotationColumn_actionPerformed(e);
945       }
946     });
947
948     JMenuItem createGroup = new JMenuItem(
949             MessageManager.getString("action.create_group"));
950     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_G,
951             Platform.SHORTCUT_KEY_MASK, false);
952     al = new ActionListener()
953     {
954       @Override
955       public void actionPerformed(ActionEvent e)
956       {
957         createGroup_actionPerformed(e);
958       }
959     };
960     addMenuActionAndAccelerator(keyStroke, createGroup, al);
961
962     JMenuItem unGroup = new JMenuItem(
963             MessageManager.getString("action.remove_group"));
964     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_G,
965             Platform.SHORTCUT_KEY_MASK
966                     | InputEvent.SHIFT_DOWN_MASK,
967             false);
968     al = new ActionListener()
969     {
970       @Override
971       public void actionPerformed(ActionEvent e)
972       {
973         unGroup_actionPerformed(e);
974       }
975     };
976     addMenuActionAndAccelerator(keyStroke, unGroup, al);
977
978     copy.setText(MessageManager.getString("action.copy"));
979     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_C,
980             Platform.SHORTCUT_KEY_MASK, false);
981
982     al = new ActionListener()
983     {
984       @Override
985       public void actionPerformed(ActionEvent e)
986       {
987         copy_actionPerformed();
988       }
989     };
990     addMenuActionAndAccelerator(keyStroke, copy, al);
991
992     cut.setText(MessageManager.getString("action.cut"));
993     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_X,
994             Platform.SHORTCUT_KEY_MASK, false);
995     al = new ActionListener()
996     {
997       @Override
998       public void actionPerformed(ActionEvent e)
999       {
1000         cut_actionPerformed();
1001       }
1002     };
1003     addMenuActionAndAccelerator(keyStroke, cut, al);
1004
1005     JMenuItem delete = new JMenuItem(
1006             MessageManager.getString("action.delete"));
1007     delete.addActionListener(new ActionListener()
1008     {
1009       @Override
1010       public void actionPerformed(ActionEvent e)
1011       {
1012         delete_actionPerformed();
1013       }
1014     });
1015
1016     pasteMenu.setText(MessageManager.getString("action.paste"));
1017     JMenuItem pasteNew = new JMenuItem(
1018             MessageManager.getString("label.to_new_alignment"));
1019     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_V,
1020             Platform.SHORTCUT_KEY_MASK
1021                     | InputEvent.SHIFT_DOWN_MASK,
1022             false);
1023     al = new ActionListener()
1024     {
1025       @Override
1026       public void actionPerformed(ActionEvent e)
1027       {
1028         pasteNew_actionPerformed(e);
1029       }
1030     };
1031     addMenuActionAndAccelerator(keyStroke, pasteNew, al);
1032
1033     JMenuItem pasteThis = new JMenuItem(
1034             MessageManager.getString("label.to_this_alignment"));
1035     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_V,
1036             Platform.SHORTCUT_KEY_MASK, false);
1037     al = new ActionListener()
1038     {
1039       @Override
1040       public void actionPerformed(ActionEvent e)
1041       {
1042         pasteThis_actionPerformed(e);
1043       }
1044     };
1045     addMenuActionAndAccelerator(keyStroke, pasteThis, al);
1046
1047     JMenuItem createPNG = new JMenuItem("PNG");
1048     createPNG.addActionListener(new ActionListener()
1049     {
1050       @Override
1051       public void actionPerformed(ActionEvent e)
1052       {
1053         createPNG(null);
1054       }
1055     });
1056     createPNG.setActionCommand(
1057             MessageManager.getString("label.save_png_image"));
1058
1059     JMenuItem font = new JMenuItem(MessageManager.getString("action.font"));
1060     font.addActionListener(new ActionListener()
1061     {
1062       @Override
1063       public void actionPerformed(ActionEvent e)
1064       {
1065         font_actionPerformed(e);
1066       }
1067     });
1068     seqLimits.setText(
1069             MessageManager.getString("label.show_sequence_limits"));
1070     seqLimits.setState(jalview.bin.Cache.getDefault("SHOW_JVSUFFIX", true));
1071     seqLimits.addActionListener(new ActionListener()
1072     {
1073       @Override
1074       public void actionPerformed(ActionEvent e)
1075       {
1076         seqLimit_actionPerformed(e);
1077       }
1078     });
1079     JMenuItem epsFile = new JMenuItem("EPS");
1080     epsFile.addActionListener(new ActionListener()
1081     {
1082       @Override
1083       public void actionPerformed(ActionEvent e)
1084       {
1085         createEPS(null);
1086       }
1087     });
1088
1089     JMenuItem createSVG = new JMenuItem("SVG");
1090     createSVG.addActionListener(new ActionListener()
1091     {
1092       @Override
1093       public void actionPerformed(ActionEvent e)
1094       {
1095         createSVG(null);
1096       }
1097     });
1098
1099     JMenuItem loadTreeMenuItem = new JMenuItem(
1100             MessageManager.getString("label.load_associated_tree"));
1101     loadTreeMenuItem.setActionCommand(
1102             MessageManager.getString("label.load_tree_for_sequence_set"));
1103     loadTreeMenuItem.addActionListener(new ActionListener()
1104     {
1105       @Override
1106       public void actionPerformed(ActionEvent e)
1107       {
1108         loadTreeMenuItem_actionPerformed(e);
1109       }
1110     });
1111
1112     scaleAbove.setVisible(false);
1113     scaleAbove.setText(MessageManager.getString("action.scale_above"));
1114     scaleAbove.addActionListener(new ActionListener()
1115     {
1116       @Override
1117       public void actionPerformed(ActionEvent e)
1118       {
1119         scaleAbove_actionPerformed(e);
1120       }
1121     });
1122     scaleLeft.setVisible(false);
1123     scaleLeft.setSelected(true);
1124     scaleLeft.setText(MessageManager.getString("action.scale_left"));
1125     scaleLeft.addActionListener(new ActionListener()
1126     {
1127       @Override
1128       public void actionPerformed(ActionEvent e)
1129       {
1130         scaleLeft_actionPerformed(e);
1131       }
1132     });
1133     scaleRight.setVisible(false);
1134     scaleRight.setSelected(true);
1135     scaleRight.setText(MessageManager.getString("action.scale_right"));
1136     scaleRight.addActionListener(new ActionListener()
1137     {
1138       @Override
1139       public void actionPerformed(ActionEvent e)
1140       {
1141         scaleRight_actionPerformed(e);
1142       }
1143     });
1144     centreColumnLabelsMenuItem.setVisible(true);
1145     centreColumnLabelsMenuItem.setState(false);
1146     centreColumnLabelsMenuItem.setText(
1147             MessageManager.getString("label.centre_column_labels"));
1148     centreColumnLabelsMenuItem.addActionListener(new ActionListener()
1149     {
1150       @Override
1151       public void actionPerformed(ActionEvent e)
1152       {
1153         centreColumnLabels_actionPerformed(e);
1154       }
1155     });
1156     followHighlightMenuItem.setVisible(true);
1157     followHighlightMenuItem.setState(true);
1158     followHighlightMenuItem
1159             .setText(MessageManager.getString("label.automatic_scrolling"));
1160     followHighlightMenuItem.addActionListener(new ActionListener()
1161     {
1162
1163       @Override
1164       public void actionPerformed(ActionEvent e)
1165       {
1166         followHighlight_actionPerformed();
1167       }
1168
1169     });
1170
1171     sortByTreeMenu
1172             .setText(MessageManager.getString("action.by_tree_order"));
1173     sort.setText(MessageManager.getString("action.sort"));
1174     sort.addMenuListener(new MenuListener()
1175     {
1176       @Override
1177       public void menuSelected(MenuEvent e)
1178       {
1179         enableSortMenuOptions();
1180       }
1181
1182       @Override
1183       public void menuDeselected(MenuEvent e)
1184       {
1185       }
1186
1187       @Override
1188       public void menuCanceled(MenuEvent e)
1189       {
1190       }
1191     });
1192     sortByTreeMenu.addMenuListener(new MenuListener()
1193     {
1194       @Override
1195       public void menuSelected(MenuEvent e)
1196       {
1197         buildTreeSortMenu();
1198       }
1199
1200       @Override
1201       public void menuDeselected(MenuEvent e)
1202       {
1203       }
1204
1205       @Override
1206       public void menuCanceled(MenuEvent e)
1207       {
1208       }
1209     });
1210     sortByAnnotScore
1211             .setText(MessageManager.getString("label.sort_by_score"));
1212     sort.add(sortByAnnotScore);
1213     sort.addMenuListener(new javax.swing.event.MenuListener()
1214     {
1215
1216       @Override
1217       public void menuCanceled(MenuEvent e)
1218       {
1219       }
1220
1221       @Override
1222       public void menuDeselected(MenuEvent e)
1223       {
1224       }
1225
1226       @Override
1227       public void menuSelected(MenuEvent e)
1228       {
1229         buildSortByAnnotationScoresMenu();
1230       }
1231     });
1232     sortByAnnotScore.setVisible(false);
1233
1234     calculateTree
1235             .setText(MessageManager.getString("action.calculate_tree_pca"));
1236
1237     padGapsMenuitem.setText(MessageManager.getString("label.pad_gaps"));
1238     padGapsMenuitem
1239             .setState(jalview.bin.Cache.getDefault("PAD_GAPS", false));
1240     padGapsMenuitem.addActionListener(new ActionListener()
1241     {
1242       @Override
1243       public void actionPerformed(ActionEvent e)
1244       {
1245         padGapsMenuitem_actionPerformed(e);
1246       }
1247     });
1248     JMenuItem vamsasStore = new JMenuItem(
1249             MessageManager.getString("label.vamsas_store"));
1250     vamsasStore.setVisible(false);
1251     vamsasStore.addActionListener(new ActionListener()
1252     {
1253       @Override
1254       public void actionPerformed(ActionEvent e)
1255       {
1256         vamsasStore_actionPerformed(e);
1257       }
1258     });
1259
1260     /*
1261      * Translate as cDNA with sub-menu of translation tables
1262      */
1263     showTranslation
1264             .setText(MessageManager.getString("label.translate_cDNA"));
1265     boolean first = true;
1266     for (final GeneticCodeI table : GeneticCodes.getInstance()
1267             .getCodeTables())
1268     {
1269       JMenuItem item = new JMenuItem(table.getId() + " " + table.getName());
1270       showTranslation.add(item);
1271       item.addActionListener(new ActionListener()
1272       {
1273         @Override
1274         public void actionPerformed(ActionEvent e)
1275         {
1276           showTranslation_actionPerformed(table);
1277         }
1278       });
1279       if (first)
1280       {
1281         showTranslation.addSeparator();
1282       }
1283       first = false;
1284     }
1285
1286     showReverse.setText(MessageManager.getString("label.reverse"));
1287     showReverse.addActionListener(new ActionListener()
1288     {
1289       @Override
1290       public void actionPerformed(ActionEvent e)
1291       {
1292         showReverse_actionPerformed(false);
1293       }
1294     });
1295     showReverseComplement
1296             .setText(MessageManager.getString("label.reverse_complement"));
1297     showReverseComplement.addActionListener(new ActionListener()
1298     {
1299       @Override
1300       public void actionPerformed(ActionEvent e)
1301       {
1302         showReverse_actionPerformed(true);
1303       }
1304     });
1305
1306     JMenuItem extractScores = new JMenuItem(
1307             MessageManager.getString("label.extract_scores"));
1308     extractScores.addActionListener(new ActionListener()
1309     {
1310       @Override
1311       public void actionPerformed(ActionEvent e)
1312       {
1313         extractScores_actionPerformed(e);
1314       }
1315     });
1316     extractScores.setVisible(true);
1317     // JBPNote: TODO: make gui for regex based score extraction
1318
1319     // for show products actions see AlignFrame.canShowProducts
1320     showProducts.setText(MessageManager.getString("label.get_cross_refs"));
1321
1322     runGroovy.setText(MessageManager.getString("label.run_groovy"));
1323     runGroovy.setToolTipText(
1324             MessageManager.getString("label.run_groovy_tip"));
1325     runGroovy.addActionListener(new ActionListener()
1326     {
1327       @Override
1328       public void actionPerformed(ActionEvent e)
1329       {
1330         runGroovy_actionPerformed();
1331       }
1332     });
1333
1334     openFeatureSettings = new JMenuItem(
1335             MessageManager.getString("action.feature_settings"));
1336     openFeatureSettings.addActionListener(new ActionListener()
1337     {
1338       @Override
1339       public void actionPerformed(ActionEvent e)
1340       {
1341         featureSettings_actionPerformed(e);
1342       }
1343     });
1344
1345     /*
1346      * add sub-menu of database we can fetch from
1347      */
1348     JMenuItem fetchSequence = new JMenuItem(
1349             MessageManager.getString("label.fetch_sequences"));
1350     fetchSequence.addActionListener(new ActionListener()
1351     {
1352       @Override
1353       public void actionPerformed(ActionEvent e)
1354       {
1355         fetchSequence_actionPerformed();
1356       }
1357     });
1358
1359     JMenuItem associatedData = new JMenuItem(
1360             MessageManager.getString("label.load_features_annotations"));
1361     associatedData.addActionListener(new ActionListener()
1362     {
1363       @Override
1364       public void actionPerformed(ActionEvent e)
1365       {
1366         associatedData_actionPerformed(e);
1367       }
1368     });
1369     loadVcf = new JMenuItem(
1370             MessageManager.getString("label.load_vcf_file"));
1371     loadVcf.setToolTipText(MessageManager.getString("label.load_vcf"));
1372     loadVcf.addActionListener(new ActionListener()
1373     {
1374       @Override
1375       public void actionPerformed(ActionEvent e)
1376       {
1377         loadVcf_actionPerformed();
1378       }
1379     });
1380     autoCalculate.setText(
1381             MessageManager.getString("label.autocalculate_consensus"));
1382     autoCalculate.setState(
1383             jalview.bin.Cache.getDefault("AUTO_CALC_CONSENSUS", true));
1384     autoCalculate.addActionListener(new ActionListener()
1385     {
1386       @Override
1387       public void actionPerformed(ActionEvent e)
1388       {
1389         autoCalculate_actionPerformed(e);
1390       }
1391     });
1392     sortByTree.setText(
1393             MessageManager.getString("label.sort_alignment_new_tree"));
1394     sortByTree.setToolTipText("<html>" + MessageManager.getString(
1395             "label.enable_automatically_sort_alignment_when_open_new_tree"));
1396     sortByTree
1397             .setState(jalview.bin.Cache.getDefault("SORT_BY_TREE", false));
1398     sortByTree.addActionListener(new ActionListener()
1399     {
1400       @Override
1401       public void actionPerformed(ActionEvent e)
1402       {
1403         sortByTreeOption_actionPerformed(e);
1404       }
1405     });
1406
1407     listenToViewSelections.setText(
1408             MessageManager.getString("label.listen_for_selections"));
1409     listenToViewSelections
1410             .setToolTipText("<html>" + MessageManager.getString(
1411                     "label.selections_mirror_selections_made_same_sequences_other_views"));
1412     listenToViewSelections.setState(false);
1413     listenToViewSelections.addActionListener(new ActionListener()
1414     {
1415       @Override
1416       public void actionPerformed(ActionEvent e)
1417       {
1418         listenToViewSelections_actionPerformed(e);
1419       }
1420     });
1421
1422     JMenu addSequenceMenu = new JMenu(
1423             MessageManager.getString("label.add_sequences"));
1424     JMenuItem addFromFile = new JMenuItem(
1425             MessageManager.getString("label.from_file"));
1426     addFromFile.addActionListener(new ActionListener()
1427     {
1428       @Override
1429       public void actionPerformed(ActionEvent e)
1430       {
1431         addFromFile_actionPerformed(e);
1432       }
1433     });
1434     JMenuItem addFromText = new JMenuItem(
1435             MessageManager.getString("label.from_textbox"));
1436     addFromText.addActionListener(new ActionListener()
1437     {
1438       @Override
1439       public void actionPerformed(ActionEvent e)
1440       {
1441         addFromText_actionPerformed(e);
1442       }
1443     });
1444     JMenuItem addFromURL = new JMenuItem(
1445             MessageManager.getString("label.from_url"));
1446     addFromURL.addActionListener(new ActionListener()
1447     {
1448       @Override
1449       public void actionPerformed(ActionEvent e)
1450       {
1451         addFromURL_actionPerformed(e);
1452       }
1453     });
1454     JMenuItem exportFeatures = new JMenuItem(
1455             MessageManager.getString("label.export_features"));
1456     exportFeatures.addActionListener(new ActionListener()
1457     {
1458       @Override
1459       public void actionPerformed(ActionEvent e)
1460       {
1461         exportFeatures_actionPerformed(e);
1462       }
1463     });
1464     JMenuItem exportAnnotations = new JMenuItem(
1465             MessageManager.getString("label.export_annotations"));
1466     exportAnnotations.addActionListener(new ActionListener()
1467     {
1468       @Override
1469       public void actionPerformed(ActionEvent e)
1470       {
1471         exportAnnotations_actionPerformed(e);
1472       }
1473     });
1474     statusPanel.setLayout(new GridLayout());
1475     JMenuItem showAllSeqs = new JMenuItem(
1476             MessageManager.getString("label.all_sequences"));
1477     showAllSeqs.setToolTipText(
1478             MessageManager.getString("label.toggle_sequence_visibility"));
1479     showAllSeqs.addActionListener(new ActionListener()
1480     {
1481       @Override
1482       public void actionPerformed(ActionEvent e)
1483       {
1484         showAllSeqs_actionPerformed(e);
1485       }
1486     });
1487     JMenuItem showAllColumns = new JMenuItem(
1488             MessageManager.getString("label.all_columns"));
1489     showAllColumns.setToolTipText(
1490             MessageManager.getString("label.toggle_columns_visibility"));
1491     showAllColumns.addActionListener(new ActionListener()
1492     {
1493       @Override
1494       public void actionPerformed(ActionEvent e)
1495       {
1496         showAllColumns_actionPerformed(e);
1497       }
1498     });
1499     JMenu hideMenu = new JMenu(MessageManager.getString("action.hide"));
1500     JMenuItem hideSelSequences = new JMenuItem(
1501             MessageManager.getString("label.selected_sequences"));
1502     hideSelSequences.setToolTipText(
1503             MessageManager.getString("label.toggle_sequence_visibility"));
1504     hideSelSequences.addActionListener(new ActionListener()
1505     {
1506       @Override
1507       public void actionPerformed(ActionEvent e)
1508       {
1509         hideSelSequences_actionPerformed(e);
1510       }
1511     });
1512     JMenuItem hideSelColumns = new JMenuItem(
1513             MessageManager.getString("label.selected_columns"));
1514     hideSelColumns.setToolTipText(
1515             MessageManager.getString("label.toggle_columns_visibility"));
1516     hideSelColumns.addActionListener(new ActionListener()
1517     {
1518       @Override
1519       public void actionPerformed(ActionEvent e)
1520       {
1521         hideSelColumns_actionPerformed(e);
1522       }
1523     });
1524     JMenuItem hideAllSelection = new JMenuItem(
1525             MessageManager.getString("label.selected_region"));
1526     hideAllSelection.addActionListener(new ActionListener()
1527     {
1528       @Override
1529       public void actionPerformed(ActionEvent e)
1530       {
1531         hideAllSelection_actionPerformed(e);
1532       }
1533     });
1534     // TODO: should be hidden if no selection exists.
1535     JMenuItem hideAllButSelection = new JMenuItem(
1536             MessageManager.getString("label.all_but_selected_region"));
1537     hideAllButSelection.addActionListener(new ActionListener()
1538     {
1539       @Override
1540       public void actionPerformed(ActionEvent e)
1541       {
1542         hideAllButSelection_actionPerformed(e);
1543       }
1544     });
1545     JMenuItem showAllhidden = new JMenuItem(
1546             MessageManager.getString("label.all_sequences_columns"));
1547     showAllhidden.setToolTipText(MessageManager
1548             .getString("label.toggles_visibility_hidden_selected_regions"));
1549     showAllhidden.addActionListener(new ActionListener()
1550     {
1551       @Override
1552       public void actionPerformed(ActionEvent e)
1553       {
1554         showAllhidden_actionPerformed(e);
1555       }
1556     });
1557     hiddenMarkers.setText(
1558             MessageManager.getString("action.show_hidden_markers"));
1559     hiddenMarkers.addActionListener(new ActionListener()
1560     {
1561       @Override
1562       public void actionPerformed(ActionEvent e)
1563       {
1564         hiddenMarkers_actionPerformed(e);
1565       }
1566     });
1567
1568     JMenuItem invertColSel = new JMenuItem(
1569             MessageManager.getString("action.invert_column_selection"));
1570     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_I,
1571             Platform.SHORTCUT_KEY_MASK
1572                     | InputEvent.ALT_DOWN_MASK,
1573             false);
1574     al = new ActionListener()
1575     {
1576       @Override
1577       public void actionPerformed(ActionEvent e)
1578       {
1579         invertColSel_actionPerformed(e);
1580       }
1581     };
1582     addMenuActionAndAccelerator(keyStroke, invertColSel, al);
1583
1584     showComplementMenuItem.setVisible(false);
1585     showComplementMenuItem.addActionListener(new ActionListener()
1586     {
1587       @Override
1588       public void actionPerformed(ActionEvent e)
1589       {
1590         showComplement_actionPerformed(showComplementMenuItem.getState());
1591       }
1592     });
1593
1594     tabbedPane.addChangeListener(new javax.swing.event.ChangeListener()
1595     {
1596       @Override
1597       public void stateChanged(ChangeEvent evt)
1598       {
1599         JTabbedPane pane = (JTabbedPane) evt.getSource();
1600         int sel = pane.getSelectedIndex();
1601         tabSelectionChanged(sel);
1602       }
1603     });
1604     tabbedPane.addMouseListener(new MouseAdapter()
1605     {
1606       @Override
1607       public void mousePressed(MouseEvent e)
1608       {
1609         if (e.isPopupTrigger()) // Mac
1610         {
1611           tabbedPane_mousePressed(e);
1612         }
1613       }
1614
1615       @Override
1616       public void mouseReleased(MouseEvent e)
1617       {
1618         if (e.isPopupTrigger()) // Windows
1619         {
1620           tabbedPane_mousePressed(e);
1621         }
1622       }
1623     });
1624     tabbedPane.addFocusListener(new FocusAdapter()
1625     {
1626       @Override
1627       public void focusGained(FocusEvent e)
1628       {
1629         tabbedPane_focusGained(e);
1630       }
1631     });
1632
1633     JMenuItem save = new JMenuItem(MessageManager.getString("action.save"));
1634     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_S,
1635             Platform.SHORTCUT_KEY_MASK, false);
1636     al = new ActionListener()
1637     {
1638       @Override
1639       public void actionPerformed(ActionEvent e)
1640       {
1641         save_actionPerformed(e);
1642       }
1643     };
1644     addMenuActionAndAccelerator(keyStroke, save, al);
1645
1646     reload.setEnabled(false);
1647     reload.setText(MessageManager.getString("action.reload"));
1648     reload.addActionListener(new ActionListener()
1649     {
1650       @Override
1651       public void actionPerformed(ActionEvent e)
1652       {
1653         reload_actionPerformed(e);
1654       }
1655     });
1656
1657     JMenuItem newView = new JMenuItem(
1658             MessageManager.getString("action.new_view"));
1659     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_T,
1660             Platform.SHORTCUT_KEY_MASK, false);
1661     al = new ActionListener()
1662     {
1663       @Override
1664       public void actionPerformed(ActionEvent e)
1665       {
1666         newView_actionPerformed(e);
1667       }
1668     };
1669     addMenuActionAndAccelerator(keyStroke, newView, al);
1670
1671     tabbedPane.setToolTipText("<html><i>"
1672             + MessageManager.getString("label.rename_tab_eXpand_reGroup")
1673             + "</i></html>");
1674
1675     formatMenu.setText(MessageManager.getString("action.format"));
1676     JMenu selectMenu = new JMenu(MessageManager.getString("action.select"));
1677
1678     idRightAlign.setText(
1679             MessageManager.getString("label.right_align_sequence_id"));
1680     idRightAlign.addActionListener(new ActionListener()
1681     {
1682       @Override
1683       public void actionPerformed(ActionEvent e)
1684       {
1685         idRightAlign_actionPerformed(e);
1686       }
1687     });
1688
1689     gatherViews.setEnabled(false);
1690     gatherViews.setText(MessageManager.getString("action.gather_views"));
1691     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_G, 0, false);
1692     al = new ActionListener()
1693     {
1694       @Override
1695       public void actionPerformed(ActionEvent e)
1696       {
1697         gatherViews_actionPerformed(e);
1698       }
1699     };
1700     addMenuActionAndAccelerator(keyStroke, gatherViews, al);
1701
1702     expandViews.setEnabled(false);
1703     expandViews.setText(MessageManager.getString("action.expand_views"));
1704     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_X, 0, false);
1705     al = new ActionListener()
1706     {
1707       @Override
1708       public void actionPerformed(ActionEvent e)
1709       {
1710         expandViews_actionPerformed(e);
1711       }
1712     };
1713     addMenuActionAndAccelerator(keyStroke, expandViews, al);
1714
1715     JMenuItem pageSetup = new JMenuItem(
1716             MessageManager.getString("action.page_setup"));
1717     pageSetup.addActionListener(new ActionListener()
1718     {
1719       @Override
1720       public void actionPerformed(ActionEvent e)
1721       {
1722         pageSetup_actionPerformed(e);
1723       }
1724     });
1725     JMenuItem alignmentProperties = new JMenuItem(
1726             MessageManager.getString("label.alignment_props"));
1727     alignmentProperties.addActionListener(new ActionListener()
1728     {
1729       @Override
1730       public void actionPerformed(ActionEvent actionEvent)
1731       {
1732         alignmentProperties();
1733       }
1734     });
1735     JMenuItem selectHighlighted = new JMenuItem(
1736             MessageManager.getString("action.select_highlighted_columns"));
1737     selectHighlighted.setToolTipText(JvSwingUtils.wrapTooltip(true, 
1738             MessageManager.getString("tooltip.select_highlighted_columns")));
1739     al = new ActionListener()
1740     {
1741       @Override
1742       public void actionPerformed(ActionEvent actionEvent)
1743       {
1744         selectHighlightedColumns_actionPerformed(actionEvent);
1745       }
1746     };
1747     selectHighlighted.addActionListener(al);
1748     JMenu tooltipSettingsMenu = new JMenu(
1749             MessageManager.getString("label.sequence_id_tooltip"));
1750     JMenu autoAnnMenu = new JMenu(
1751             MessageManager.getString("label.autocalculated_annotation"));
1752
1753     JMenu exportImageMenu = new JMenu(
1754             MessageManager.getString("label.export_image"));
1755     JMenu fileMenu = new JMenu(MessageManager.getString("action.file"));
1756     alignFrameMenuBar.add(fileMenu);
1757     alignFrameMenuBar.add(editMenu);
1758     alignFrameMenuBar.add(selectMenu);
1759     alignFrameMenuBar.add(viewMenu);
1760     alignFrameMenuBar.add(annotationsMenu);
1761     alignFrameMenuBar.add(formatMenu);
1762     alignFrameMenuBar.add(colourMenu);
1763     alignFrameMenuBar.add(calculateMenu);
1764     if (!Platform.isJS())
1765     {
1766       alignFrameMenuBar.add(webService);
1767     }
1768
1769     fileMenu.add(fetchSequence);
1770     fileMenu.add(addSequenceMenu);
1771     fileMenu.add(reload);
1772     fileMenu.addSeparator();
1773     fileMenu.add(vamsasStore);
1774     fileMenu.add(save);
1775     fileMenu.add(saveAs);
1776     fileMenu.add(outputTextboxMenu);
1777     fileMenu.add(pageSetup);
1778     fileMenu.add(printMenuItem);
1779     fileMenu.addSeparator();
1780     fileMenu.add(exportImageMenu);
1781     fileMenu.add(exportFeatures);
1782     fileMenu.add(exportAnnotations);
1783     fileMenu.add(loadTreeMenuItem);
1784     fileMenu.add(associatedData);
1785     if (!Platform.isJS())
1786     {
1787       fileMenu.add(loadVcf);
1788     }
1789     fileMenu.addSeparator();
1790     fileMenu.add(closeMenuItem);
1791
1792     pasteMenu.add(pasteNew);
1793     pasteMenu.add(pasteThis);
1794     editMenu.add(undoMenuItem);
1795     editMenu.add(redoMenuItem);
1796     editMenu.add(cut);
1797     editMenu.add(copy);
1798     editMenu.add(pasteMenu);
1799     editMenu.add(delete);
1800     editMenu.addSeparator();
1801     editMenu.add(remove2LeftMenuItem);
1802     editMenu.add(remove2RightMenuItem);
1803     editMenu.add(removeGappedColumnMenuItem);
1804     editMenu.add(removeAllGapsMenuItem);
1805     editMenu.add(removeRedundancyMenuItem);
1806     editMenu.addSeparator();
1807     // dont add these yet in the CVS build - they cannot be undone!
1808     // Excluded from Jalview 2.5 release - undo needs to be implemented.
1809     // editMenu.add(justifyLeftMenuItem);
1810     // editMenu.add(justifyRightMenuItem);
1811     // editMenu.addSeparator();
1812     editMenu.add(padGapsMenuitem);
1813
1814     showMenu.add(showAllColumns);
1815     showMenu.add(showAllSeqs);
1816     showMenu.add(showAllhidden);
1817     hideMenu.add(hideSelColumns);
1818     hideMenu.add(hideSelSequences);
1819     hideMenu.add(hideAllSelection);
1820     hideMenu.add(hideAllButSelection);
1821     viewMenu.add(newView);
1822     viewMenu.add(expandViews);
1823     viewMenu.add(gatherViews);
1824     viewMenu.addSeparator();
1825     viewMenu.add(showMenu);
1826     viewMenu.add(hideMenu);
1827     viewMenu.add(showComplementMenuItem);
1828     viewMenu.addSeparator();
1829     viewMenu.add(followHighlightMenuItem);
1830     viewMenu.addSeparator();
1831     viewMenu.add(showSeqFeatures);
1832     // viewMenu.add(showSeqFeaturesHeight);
1833     viewMenu.add(openFeatureSettings);
1834     tooltipSettingsMenu.add(showDbRefsMenuitem);
1835     tooltipSettingsMenu.add(showNpFeatsMenuitem);
1836     viewMenu.add(tooltipSettingsMenu);
1837     viewMenu.addSeparator();
1838     viewMenu.add(alignmentProperties);
1839     viewMenu.addSeparator();
1840     viewMenu.add(overviewMenuItem);
1841
1842     annotationsMenu.add(annotationPanelMenuItem);
1843     annotationsMenu.addSeparator();
1844     annotationsMenu.add(showAllAlAnnotations);
1845     annotationsMenu.add(hideAllAlAnnotations);
1846     annotationsMenu.addSeparator();
1847     annotationsMenu.add(showAllSeqAnnotations);
1848     annotationsMenu.add(hideAllSeqAnnotations);
1849     annotationsMenu.add(sortAnnBySequence);
1850     annotationsMenu.add(sortAnnByLabel);
1851     annotationsMenu.addSeparator();
1852     autoAnnMenu.add(showAutoFirst);
1853     autoAnnMenu.add(showAutoLast);
1854     autoAnnMenu.addSeparator();
1855     autoAnnMenu.add(applyAutoAnnotationSettings);
1856     autoAnnMenu.add(showConsensusHistogram);
1857     autoAnnMenu.add(showSequenceLogo);
1858     autoAnnMenu.add(normaliseSequenceLogo);
1859     autoAnnMenu.addSeparator();
1860     autoAnnMenu.add(showGroupConservation);
1861     autoAnnMenu.add(showGroupConsensus);
1862     annotationsMenu.add(autoAnnMenu);
1863
1864     sort.add(sortIDMenuItem);
1865     sort.add(sortLengthMenuItem);
1866     sort.add(sortGroupMenuItem);
1867     sort.add(sortPairwiseMenuItem);
1868     sort.add(sortByTreeMenu);
1869     calculateMenu.add(sort);
1870     calculateMenu.add(calculateTree);
1871     calculateMenu.addSeparator();
1872     calculateMenu.add(pairwiseAlignmentMenuItem);
1873     calculateMenu.addSeparator();
1874     calculateMenu.add(showTranslation);
1875     calculateMenu.add(showReverse);
1876     calculateMenu.add(showReverseComplement);
1877     calculateMenu.add(showProducts);
1878     calculateMenu.add(autoCalculate);
1879     calculateMenu.add(sortByTree);
1880     calculateMenu.addSeparator();
1881     calculateMenu.add(expandAlignment);
1882     calculateMenu.add(extractScores);
1883     if (!Platform.isJS())
1884     {
1885       calculateMenu.addSeparator();
1886       calculateMenu.add(runGroovy);
1887     }
1888
1889     webServiceNoServices = new JMenuItem(
1890             MessageManager.getString("label.no_services"));
1891     webService.add(webServiceNoServices);
1892     if (!Platform.isJS())
1893     {
1894       exportImageMenu.add(htmlMenuItem);
1895     }
1896     exportImageMenu.add(epsFile);
1897     exportImageMenu.add(createPNG);
1898     if (!Platform.isJS())
1899     {
1900       exportImageMenu.add(createBioJS);
1901       exportImageMenu.add(createSVG);
1902     }
1903     addSequenceMenu.add(addFromFile);
1904     addSequenceMenu.add(addFromText);
1905     addSequenceMenu.add(addFromURL);
1906     this.getContentPane().add(statusPanel, java.awt.BorderLayout.SOUTH);
1907     statusPanel.add(statusBar, null);
1908     this.getContentPane().add(tabbedPane, java.awt.BorderLayout.CENTER);
1909
1910     formatMenu.add(font);
1911     formatMenu.addSeparator();
1912     formatMenu.add(wrapMenuItem);
1913     formatMenu.add(scaleAbove);
1914     formatMenu.add(scaleLeft);
1915     formatMenu.add(scaleRight);
1916     formatMenu.add(seqLimits);
1917     formatMenu.add(idRightAlign);
1918     formatMenu.add(hiddenMarkers);
1919     formatMenu.add(viewBoxesMenuItem);
1920     formatMenu.add(viewTextMenuItem);
1921     formatMenu.add(colourTextMenuItem);
1922     formatMenu.add(renderGapsMenuItem);
1923     formatMenu.add(centreColumnLabelsMenuItem);
1924     formatMenu.add(showNonconservedMenuItem);
1925     selectMenu.add(findMenuItem);
1926     selectMenu.addSeparator();
1927     selectMenu.add(selectAllSequenceMenuItem);
1928     selectMenu.add(deselectAllSequenceMenuItem);
1929     selectMenu.add(invertSequenceMenuItem);
1930     selectMenu.add(invertColSel);
1931     selectMenu.add(createGroup);
1932     selectMenu.add(unGroup);
1933     selectMenu.add(grpsFromSelection);
1934     selectMenu.add(deleteGroups);
1935     selectMenu.add(annotationColumn);
1936     selectMenu.add(selectHighlighted);
1937     // TODO - determine if the listenToViewSelections button is needed : see bug
1938     // JAL-574
1939     // selectMenu.addSeparator();
1940     // selectMenu.add(listenToViewSelections);
1941   }
1942
1943   protected void enableSortMenuOptions()
1944   {
1945   }
1946   
1947   protected void loadVcf_actionPerformed()
1948   {
1949   }
1950
1951   /**
1952    * Constructs the entries on the Colour menu (but does not add them to the
1953    * menu).
1954    */
1955   protected void initColourMenu()
1956   {
1957     applyToAllGroups = new JCheckBoxMenuItem(
1958             MessageManager.getString("label.apply_colour_to_all_groups"));
1959     applyToAllGroups.addActionListener(new ActionListener()
1960     {
1961       @Override
1962       public void actionPerformed(ActionEvent e)
1963       {
1964         applyToAllGroups_actionPerformed(applyToAllGroups.isSelected());
1965       }
1966     });
1967
1968     textColour = new JMenuItem(
1969             MessageManager.getString("label.text_colour"));
1970     textColour.addActionListener(new ActionListener()
1971     {
1972       @Override
1973       public void actionPerformed(ActionEvent e)
1974       {
1975         textColour_actionPerformed();
1976       }
1977     });
1978
1979     conservationMenuItem = new JCheckBoxMenuItem(
1980             MessageManager.getString("action.by_conservation"));
1981     conservationMenuItem.addActionListener(new ActionListener()
1982     {
1983       @Override
1984       public void actionPerformed(ActionEvent e)
1985       {
1986         conservationMenuItem_actionPerformed(
1987                 conservationMenuItem.isSelected());
1988       }
1989     });
1990
1991     abovePIDThreshold = new JCheckBoxMenuItem(
1992             MessageManager.getString("label.above_identity_threshold"));
1993     abovePIDThreshold.addActionListener(new ActionListener()
1994     {
1995       @Override
1996       public void actionPerformed(ActionEvent e)
1997       {
1998         abovePIDThreshold_actionPerformed(abovePIDThreshold.isSelected());
1999       }
2000     });
2001     modifyPID = new JMenuItem(
2002             MessageManager.getString("label.modify_identity_threshold"));
2003     modifyPID.addActionListener(new ActionListener()
2004     {
2005       @Override
2006       public void actionPerformed(ActionEvent e)
2007       {
2008         modifyPID_actionPerformed();
2009       }
2010     });
2011     modifyConservation = new JMenuItem(MessageManager
2012             .getString("label.modify_conservation_threshold"));
2013     modifyConservation.addActionListener(new ActionListener()
2014     {
2015       @Override
2016       public void actionPerformed(ActionEvent e)
2017       {
2018         modifyConservation_actionPerformed();
2019       }
2020     });
2021
2022     annotationColour = new JRadioButtonMenuItem(
2023             MessageManager.getString("action.by_annotation"));
2024     annotationColour.setName(ResidueColourScheme.ANNOTATION_COLOUR);
2025     annotationColour.addActionListener(new ActionListener()
2026     {
2027       @Override
2028       public void actionPerformed(ActionEvent e)
2029       {
2030         annotationColour_actionPerformed();
2031       }
2032     });
2033   }
2034
2035   protected void selectHighlightedColumns_actionPerformed(
2036           ActionEvent actionEvent)
2037   {
2038     // TODO Auto-generated method stub
2039
2040   }
2041
2042   /**
2043    * Generate the reverse sequence (or reverse complement if the flag is true)
2044    * and add it to the alignment
2045    * 
2046    * @param complement
2047    */
2048   protected void showReverse_actionPerformed(boolean complement)
2049   {
2050   }
2051
2052   /**
2053    * Try to run script in a Groovy console, having first ensured that this
2054    * alignframe is set as currentAlignFrame in Desktop
2055    */
2056   protected void runGroovy_actionPerformed()
2057   {
2058
2059   }
2060
2061   /**
2062    * Adds the given action listener and key accelerator to the given menu item.
2063    * Also saves in a lookup table to support lookup of action by key stroke.
2064    * 
2065    * @param keyStroke
2066    * @param menuItem
2067    * @param actionListener
2068    */
2069   protected void addMenuActionAndAccelerator(KeyStroke keyStroke,
2070           JMenuItem menuItem, ActionListener actionListener)
2071   {
2072     menuItem.setAccelerator(keyStroke);
2073     accelerators.put(keyStroke, menuItem);
2074     menuItem.addActionListener(actionListener);
2075   }
2076
2077   /**
2078    * Action on clicking sort annotations by type.
2079    * 
2080    * @param sortOrder
2081    */
2082   protected void sortAnnotations_actionPerformed()
2083   {
2084   }
2085
2086   /**
2087    * Action on clicking Show all annotations.
2088    * 
2089    * @param forSequences
2090    *          update sequence-related annotations
2091    * @param forAlignment
2092    *          update non-sequence-related annotations
2093    */
2094   protected void showAllAnnotations_actionPerformed(boolean forSequences,
2095           boolean forAlignment)
2096   {
2097     setAnnotationsVisibility(true, forSequences, forAlignment);
2098   }
2099
2100   /**
2101    * Action on clicking Hide all annotations.
2102    * 
2103    * @param forSequences
2104    *          update sequence-related annotations
2105    * @param forAlignment
2106    *          update non-sequence-related annotations
2107    */
2108   protected void hideAllAnnotations_actionPerformed(boolean forSequences,
2109           boolean forAlignment)
2110   {
2111     setAnnotationsVisibility(false, forSequences, forAlignment);
2112   }
2113
2114   /**
2115    * Set the visibility of annotations to true or false. Can act on
2116    * sequence-related annotations, or alignment-related, or both.
2117    * 
2118    * @param visible
2119    * @param forSequences
2120    *          update sequence-related annotations
2121    * @param forAlignment
2122    *          update non-sequence-related annotations
2123    */
2124   protected void setAnnotationsVisibility(boolean visible,
2125           boolean forSequences, boolean forAlignment)
2126   {
2127
2128   }
2129
2130   protected void normaliseSequenceLogo_actionPerformed(ActionEvent e)
2131   {
2132     // TODO Auto-generated method stub
2133
2134   }
2135
2136   protected void listenToViewSelections_actionPerformed(ActionEvent e)
2137   {
2138     // TODO Auto-generated method stub
2139
2140   }
2141
2142   protected void showAllhidden_actionPerformed(ActionEvent e)
2143   {
2144     // TODO Auto-generated method stub
2145
2146   }
2147
2148   protected void hideAllButSelection_actionPerformed(ActionEvent e)
2149   {
2150     // TODO Auto-generated method stub
2151
2152   }
2153
2154   protected void hideAllSelection_actionPerformed(ActionEvent e)
2155   {
2156     // TODO Auto-generated method stub
2157
2158   }
2159
2160   protected void applyAutoAnnotationSettings_actionPerformed(ActionEvent e)
2161   {
2162     // TODO Auto-generated method stub
2163
2164   }
2165
2166   protected void showConsensusHistogram_actionPerformed(ActionEvent e)
2167   {
2168     // TODO Auto-generated method stub
2169
2170   }
2171
2172   protected void showSequenceLogo_actionPerformed(ActionEvent e)
2173   {
2174     // TODO Auto-generated method stub
2175
2176   }
2177
2178   protected void makeGrpsFromSelection_actionPerformed(ActionEvent e)
2179   {
2180     // TODO Auto-generated method stub
2181
2182   }
2183
2184   protected void showGroupConsensus_actionPerformed(ActionEvent e)
2185   {
2186     // TODO Auto-generated method stub
2187
2188   }
2189
2190   protected void showGroupConservation_actionPerformed(ActionEvent e)
2191   {
2192     // TODO Auto-generated method stub
2193
2194   }
2195
2196   protected void showUnconservedMenuItem_actionPerformed(ActionEvent e)
2197   {
2198     // TODO Auto-generated method stub
2199
2200   }
2201
2202   protected void justifyRightMenuItem_actionPerformed(ActionEvent e)
2203   {
2204     // TODO Auto-generated method stub
2205
2206   }
2207
2208   protected void justifyLeftMenuItem_actionPerformed(ActionEvent e)
2209   {
2210     // TODO Auto-generated method stub
2211
2212   }
2213
2214   protected void followHighlight_actionPerformed()
2215   {
2216     // TODO Auto-generated method stub
2217
2218   }
2219
2220   protected void showNpFeats_actionPerformed(ActionEvent e)
2221   {
2222     // TODO Auto-generated method stub
2223
2224   }
2225
2226   protected void showDbRefs_actionPerformed(ActionEvent e)
2227   {
2228     // TODO Auto-generated method stub
2229
2230   }
2231
2232   protected void centreColumnLabels_actionPerformed(ActionEvent e)
2233   {
2234   }
2235
2236   protected void buildSortByAnnotationScoresMenu()
2237   {
2238   }
2239
2240   protected void extractScores_actionPerformed(ActionEvent e)
2241   {
2242   }
2243
2244   protected void outputText_actionPerformed(String formatName)
2245   {
2246   }
2247
2248   public void addFromFile_actionPerformed(ActionEvent e)
2249   {
2250
2251   }
2252
2253   public void addFromText_actionPerformed(ActionEvent e)
2254   {
2255
2256   }
2257
2258   public void addFromURL_actionPerformed(ActionEvent e)
2259   {
2260
2261   }
2262
2263   public void exportFeatures_actionPerformed(ActionEvent e)
2264   {
2265
2266   }
2267
2268   public void exportAnnotations_actionPerformed(ActionEvent e)
2269   {
2270
2271   }
2272
2273   protected void htmlMenuItem_actionPerformed(ActionEvent e)
2274   {
2275   }
2276
2277   protected void bioJSMenuItem_actionPerformed(ActionEvent e)
2278   {
2279
2280   }
2281
2282   protected void closeMenuItem_actionPerformed(boolean b)
2283   {
2284   }
2285
2286   protected void redoMenuItem_actionPerformed(ActionEvent e)
2287   {
2288   }
2289
2290   protected void undoMenuItem_actionPerformed(ActionEvent e)
2291   {
2292   }
2293
2294   protected void selectAllSequenceMenuItem_actionPerformed(ActionEvent e)
2295   {
2296   }
2297
2298   protected void deselectAllSequenceMenuItem_actionPerformed(ActionEvent e)
2299   {
2300   }
2301
2302   protected void invertSequenceMenuItem_actionPerformed(ActionEvent e)
2303   {
2304   }
2305
2306   protected void remove2LeftMenuItem_actionPerformed(ActionEvent e)
2307   {
2308   }
2309
2310   protected void remove2RightMenuItem_actionPerformed(ActionEvent e)
2311   {
2312   }
2313
2314   protected void removeGappedColumnMenuItem_actionPerformed(ActionEvent e)
2315   {
2316   }
2317
2318   protected void removeAllGapsMenuItem_actionPerformed(ActionEvent e)
2319   {
2320   }
2321
2322   protected void wrapMenuItem_actionPerformed(ActionEvent e)
2323   {
2324   }
2325
2326   protected void viewBoxesMenuItem_actionPerformed(ActionEvent e)
2327   {
2328   }
2329
2330   protected void viewTextMenuItem_actionPerformed(ActionEvent e)
2331   {
2332   }
2333
2334   protected void colourTextMenuItem_actionPerformed(ActionEvent e)
2335   {
2336   }
2337
2338   protected void annotationPanelMenuItem_actionPerformed(ActionEvent e)
2339   {
2340   }
2341
2342   protected void overviewMenuItem_actionPerformed(ActionEvent e)
2343   {
2344   }
2345
2346   protected void sortPairwiseMenuItem_actionPerformed(ActionEvent e)
2347   {
2348   }
2349
2350   protected void sortIDMenuItem_actionPerformed(ActionEvent e)
2351   {
2352   }
2353
2354   protected void sortLengthMenuItem_actionPerformed(ActionEvent e)
2355   {
2356   }
2357
2358   protected void sortGroupMenuItem_actionPerformed(ActionEvent e)
2359   {
2360   }
2361
2362   protected void removeRedundancyMenuItem_actionPerformed(ActionEvent e)
2363   {
2364   }
2365
2366   protected void pairwiseAlignmentMenuItem_actionPerformed(ActionEvent e)
2367   {
2368   }
2369
2370   protected void neighbourTreeMenuItem_actionPerformed(ActionEvent e)
2371   {
2372   }
2373
2374   protected void conservationMenuItem_actionPerformed(boolean selected)
2375   {
2376   }
2377
2378   protected void printMenuItem_actionPerformed(ActionEvent e)
2379   {
2380   }
2381
2382   protected void renderGapsMenuItem_actionPerformed(ActionEvent e)
2383   {
2384   }
2385
2386   protected void findMenuItem_actionPerformed(ActionEvent e)
2387   {
2388   }
2389
2390   protected void abovePIDThreshold_actionPerformed(boolean selected)
2391   {
2392   }
2393
2394   public void showSeqFeatures_actionPerformed(ActionEvent actionEvent)
2395   {
2396   }
2397
2398   protected void deleteGroups_actionPerformed(ActionEvent e)
2399   {
2400   }
2401
2402   protected void createGroup_actionPerformed(ActionEvent e)
2403   {
2404   }
2405
2406   protected void unGroup_actionPerformed(ActionEvent e)
2407   {
2408   }
2409
2410   protected void copy_actionPerformed()
2411   {
2412   }
2413
2414   protected void cut_actionPerformed()
2415   {
2416   }
2417
2418   protected void delete_actionPerformed()
2419   {
2420   }
2421
2422   protected void pasteNew_actionPerformed(ActionEvent e)
2423   {
2424   }
2425
2426   protected void pasteThis_actionPerformed(ActionEvent e)
2427   {
2428   }
2429
2430   protected void applyToAllGroups_actionPerformed(boolean selected)
2431   {
2432   }
2433
2434   public void createPNG(java.io.File f)
2435   {
2436   }
2437
2438   protected void font_actionPerformed(ActionEvent e)
2439   {
2440   }
2441
2442   protected void seqLimit_actionPerformed(ActionEvent e)
2443   {
2444   }
2445
2446   public void seqDBRef_actionPerformed(ActionEvent e)
2447   {
2448
2449   }
2450
2451   public void createEPS(java.io.File f)
2452   {
2453   }
2454
2455   public void createSVG(java.io.File f)
2456   {
2457
2458   }
2459
2460   protected void loadTreeMenuItem_actionPerformed(ActionEvent e)
2461   {
2462
2463   }
2464
2465   /**
2466    * Template method to handle the 'load T-Coffee scores' menu event.
2467    * <p>
2468    * Subclasses override this method to provide a custom action.
2469    * 
2470    * @param event
2471    *          The raised event
2472    */
2473   protected void loadScores_actionPerformed(ActionEvent event)
2474   {
2475
2476   }
2477
2478   protected void jpred_actionPerformed(ActionEvent e)
2479   {
2480   }
2481
2482   protected void scaleAbove_actionPerformed(ActionEvent e)
2483   {
2484   }
2485
2486   protected void scaleLeft_actionPerformed(ActionEvent e)
2487   {
2488   }
2489
2490   protected void scaleRight_actionPerformed(ActionEvent e)
2491   {
2492   }
2493
2494   protected void modifyPID_actionPerformed()
2495   {
2496   }
2497
2498   protected void modifyConservation_actionPerformed()
2499   {
2500   }
2501
2502   protected void saveAs_actionPerformed()
2503   {
2504   }
2505
2506   protected void padGapsMenuitem_actionPerformed(ActionEvent e)
2507   {
2508   }
2509
2510   public void vamsasStore_actionPerformed(ActionEvent e)
2511   {
2512
2513   }
2514
2515   public void vamsasLoad_actionPerformed(ActionEvent e)
2516   {
2517
2518   }
2519
2520   public void showTranslation_actionPerformed(GeneticCodeI codeTable)
2521   {
2522
2523   }
2524
2525   public void featureSettings_actionPerformed(ActionEvent e)
2526   {
2527
2528   }
2529
2530   public void fetchSequence_actionPerformed()
2531   {
2532
2533   }
2534
2535   public void smoothFont_actionPerformed(ActionEvent e)
2536   {
2537
2538   }
2539
2540   public void annotationColour_actionPerformed()
2541   {
2542   }
2543
2544   public void annotationColumn_actionPerformed(ActionEvent e)
2545   {
2546   }
2547
2548   public void associatedData_actionPerformed(ActionEvent e)
2549   {
2550
2551   }
2552
2553   public void autoCalculate_actionPerformed(ActionEvent e)
2554   {
2555
2556   }
2557
2558   public void sortByTreeOption_actionPerformed(ActionEvent e)
2559   {
2560
2561   }
2562
2563   public void showAllSeqs_actionPerformed(ActionEvent e)
2564   {
2565
2566   }
2567
2568   public void showAllColumns_actionPerformed(ActionEvent e)
2569   {
2570
2571   }
2572
2573   public void hideSelSequences_actionPerformed(ActionEvent e)
2574   {
2575
2576   }
2577
2578   public void hideSelColumns_actionPerformed(ActionEvent e)
2579   {
2580
2581   }
2582
2583   public void hiddenMarkers_actionPerformed(ActionEvent e)
2584   {
2585
2586   }
2587
2588   public void findPdbId_actionPerformed(ActionEvent e)
2589   {
2590
2591   }
2592
2593   public void enterPdbId_actionPerformed(ActionEvent e)
2594   {
2595
2596   }
2597
2598   public void pdbFile_actionPerformed(ActionEvent e)
2599   {
2600
2601   }
2602
2603   public void invertColSel_actionPerformed(ActionEvent e)
2604   {
2605
2606   }
2607
2608   public void tabSelectionChanged(int sel)
2609   {
2610
2611   }
2612
2613   public void tabbedPane_mousePressed(MouseEvent e)
2614   {
2615
2616   }
2617
2618   public void tabbedPane_focusGained(FocusEvent e)
2619   {
2620     requestFocus();
2621   }
2622
2623   public void save_actionPerformed(ActionEvent e)
2624   {
2625
2626   }
2627
2628   public void reload_actionPerformed(ActionEvent e)
2629   {
2630
2631   }
2632
2633   public void newView_actionPerformed(ActionEvent e)
2634   {
2635
2636   }
2637
2638   public void textColour_actionPerformed()
2639   {
2640
2641   }
2642
2643   public void idRightAlign_actionPerformed(ActionEvent e)
2644   {
2645
2646   }
2647
2648   public void expandViews_actionPerformed(ActionEvent e)
2649   {
2650
2651   }
2652
2653   public void gatherViews_actionPerformed(ActionEvent e)
2654   {
2655
2656   }
2657
2658   public void buildTreeSortMenu()
2659   {
2660
2661   }
2662
2663   public void pageSetup_actionPerformed(ActionEvent e)
2664   {
2665
2666   }
2667
2668   public void alignmentProperties()
2669   {
2670
2671   }
2672
2673   protected void expand_newalign(ActionEvent e)
2674   {
2675     // TODO Auto-generated method stub
2676
2677   }
2678
2679   protected boolean isShowAutoCalculatedAbove()
2680   {
2681     return showAutoCalculatedAbove;
2682   }
2683
2684   protected void setShowAutoCalculatedAbove(boolean showAutoCalculatedAbove)
2685   {
2686     this.showAutoCalculatedAbove = showAutoCalculatedAbove;
2687   }
2688
2689   protected SequenceAnnotationOrder getAnnotationSortOrder()
2690   {
2691     return annotationSortOrder;
2692   }
2693
2694   protected void setAnnotationSortOrder(
2695           SequenceAnnotationOrder annotationSortOrder)
2696   {
2697     this.annotationSortOrder = annotationSortOrder;
2698   }
2699
2700   public Map<KeyStroke, JMenuItem> getAccelerators()
2701   {
2702     return this.accelerators;
2703   }
2704
2705   /**
2706    * Returns the selected index of the tabbed pane, or -1 if none selected
2707    * (including the case where the tabbed pane has not been made visible).
2708    * 
2709    * @return
2710    */
2711   public int getTabIndex()
2712   {
2713     return tabbedPane.getSelectedIndex();
2714   }
2715
2716   public JPanel getStatusPanel()
2717   {
2718     return statusPanel;
2719   }
2720
2721   /**
2722    * Sets a reference to the containing split frame. Also makes the 'toggle
2723    * split view' menu item visible and checked.
2724    * 
2725    * @param sf
2726    */
2727   public void setSplitFrame(SplitContainerI sf)
2728   {
2729     this.splitFrame = sf;
2730     if (sf != null)
2731     {
2732       this.showComplementMenuItem.setVisible(true);
2733       this.showComplementMenuItem.setState(true);
2734     }
2735   }
2736
2737   public SplitContainerI getSplitViewContainer()
2738   {
2739     return this.splitFrame;
2740   }
2741
2742   protected void showComplement_actionPerformed(boolean complement)
2743   {
2744   }
2745   
2746
2747 }