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