Merge branch 'develop' into features/JAL-2360colourSchemeApplicability
[jalview.git] / src / jalview / appletgui / APopupMenu.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.appletgui;
22
23 import jalview.analysis.AAFrequency;
24 import jalview.analysis.AlignmentAnnotationUtils;
25 import jalview.analysis.AlignmentUtils;
26 import jalview.analysis.Conservation;
27 import jalview.bin.JalviewLite;
28 import jalview.commands.ChangeCaseCommand;
29 import jalview.commands.EditCommand;
30 import jalview.commands.EditCommand.Action;
31 import jalview.datamodel.AlignmentAnnotation;
32 import jalview.datamodel.AlignmentI;
33 import jalview.datamodel.PDBEntry;
34 import jalview.datamodel.SequenceFeature;
35 import jalview.datamodel.SequenceGroup;
36 import jalview.datamodel.SequenceI;
37 import jalview.io.AppletFormatAdapter;
38 import jalview.io.DataSourceType;
39 import jalview.io.FileFormatI;
40 import jalview.io.FileFormats;
41 import jalview.io.SequenceAnnotationReport;
42 import jalview.schemes.Blosum62ColourScheme;
43 import jalview.schemes.BuriedColourScheme;
44 import jalview.schemes.ClustalxColourScheme;
45 import jalview.schemes.ColourSchemeI;
46 import jalview.schemes.HelixColourScheme;
47 import jalview.schemes.HydrophobicColourScheme;
48 import jalview.schemes.JalviewColourScheme;
49 import jalview.schemes.NucleotideColourScheme;
50 import jalview.schemes.PIDColourScheme;
51 import jalview.schemes.PurinePyrimidineColourScheme;
52 import jalview.schemes.StrandColourScheme;
53 import jalview.schemes.TaylorColourScheme;
54 import jalview.schemes.TurnColourScheme;
55 import jalview.schemes.ZappoColourScheme;
56 import jalview.util.MessageManager;
57 import jalview.util.UrlLink;
58
59 import java.awt.CheckboxMenuItem;
60 import java.awt.Frame;
61 import java.awt.Menu;
62 import java.awt.MenuItem;
63 import java.awt.event.ActionEvent;
64 import java.awt.event.ActionListener;
65 import java.awt.event.ItemEvent;
66 import java.awt.event.ItemListener;
67 import java.util.Arrays;
68 import java.util.Collection;
69 import java.util.Collections;
70 import java.util.LinkedHashMap;
71 import java.util.List;
72 import java.util.Map;
73 import java.util.SortedMap;
74 import java.util.TreeMap;
75 import java.util.Vector;
76
77 public class APopupMenu extends java.awt.PopupMenu implements
78         ActionListener, ItemListener
79 {
80   Menu groupMenu = new Menu();
81
82   MenuItem editGroupName = new MenuItem();
83
84   CheckboxMenuItem noColour = new CheckboxMenuItem();
85
86   protected CheckboxMenuItem clustalColour = new CheckboxMenuItem();
87
88   protected CheckboxMenuItem zappoColour = new CheckboxMenuItem();
89
90   protected CheckboxMenuItem taylorColour = new CheckboxMenuItem();
91
92   protected CheckboxMenuItem hydrophobicityColour = new CheckboxMenuItem();
93
94   protected CheckboxMenuItem helixColour = new CheckboxMenuItem();
95
96   protected CheckboxMenuItem strandColour = new CheckboxMenuItem();
97
98   protected CheckboxMenuItem turnColour = new CheckboxMenuItem();
99
100   protected CheckboxMenuItem buriedColour = new CheckboxMenuItem();
101
102   protected CheckboxMenuItem PIDColour = new CheckboxMenuItem();
103
104   protected CheckboxMenuItem BLOSUM62Colour = new CheckboxMenuItem();
105
106   CheckboxMenuItem nucleotideColour = new CheckboxMenuItem();
107
108   CheckboxMenuItem purinePyrimidineColour = new CheckboxMenuItem();
109
110   protected MenuItem userDefinedColour = new MenuItem();
111
112   protected CheckboxMenuItem abovePIDColour = new CheckboxMenuItem();
113
114   MenuItem modifyPID = new MenuItem();
115
116   protected CheckboxMenuItem conservationColour = new CheckboxMenuItem();
117
118   MenuItem modifyConservation = new MenuItem();
119
120   MenuItem noColourmenuItem = new MenuItem();
121
122   final AlignmentPanel ap;
123
124   MenuItem unGroupMenuItem = new MenuItem();
125
126   MenuItem createGroupMenuItem = new MenuItem();
127
128   Menu colourMenu = new Menu();
129
130   CheckboxMenuItem showBoxes = new CheckboxMenuItem();
131
132   CheckboxMenuItem showText = new CheckboxMenuItem();
133
134   CheckboxMenuItem showColourText = new CheckboxMenuItem();
135
136   CheckboxMenuItem displayNonconserved = new CheckboxMenuItem();
137
138   Menu seqShowAnnotationsMenu = new Menu(
139           MessageManager.getString("label.show_annotations"));
140
141   Menu seqHideAnnotationsMenu = new Menu(
142           MessageManager.getString("label.hide_annotations"));
143
144   MenuItem seqAddReferenceAnnotations = new MenuItem(
145           MessageManager.getString("label.add_reference_annotations"));
146
147   Menu groupShowAnnotationsMenu = new Menu(
148           MessageManager.getString("label.show_annotations"));
149
150   Menu groupHideAnnotationsMenu = new Menu(
151           MessageManager.getString("label.hide_annotations"));
152
153   MenuItem groupAddReferenceAnnotations = new MenuItem(
154           MessageManager.getString("label.add_reference_annotations"));
155
156   Menu editMenu = new Menu(MessageManager.getString("action.edit"));
157
158   MenuItem copy = new MenuItem(MessageManager.getString("action.copy"));
159
160   MenuItem cut = new MenuItem(MessageManager.getString("action.cut"));
161
162   MenuItem toUpper = new MenuItem(
163           MessageManager.getString("label.to_upper_case"));
164
165   MenuItem toLower = new MenuItem(
166           MessageManager.getString("label.to_lower_case"));
167
168   MenuItem toggleCase = new MenuItem(
169           MessageManager.getString("label.toggle_case"));
170
171   Menu outputmenu = new Menu();
172
173   Menu seqMenu = new Menu();
174
175   MenuItem pdb = new MenuItem();
176
177   MenuItem hideSeqs = new MenuItem();
178
179   MenuItem repGroup = new MenuItem();
180
181   MenuItem sequenceName = new MenuItem(
182           MessageManager.getString("label.edit_name_description"));
183
184   MenuItem sequenceFeature = new MenuItem(
185           MessageManager.getString("label.create_sequence_feature"));
186
187   MenuItem editSequence = new MenuItem(
188           MessageManager.getString("label.edit_sequence"));
189
190   MenuItem sequenceDetails = new MenuItem(
191           MessageManager.getString("label.sequence_details"));
192
193   MenuItem selSeqDetails = new MenuItem(
194           MessageManager.getString("label.sequence_details"));
195
196   MenuItem makeReferenceSeq = new MenuItem();
197
198   SequenceI seq;
199
200   MenuItem revealAll = new MenuItem();
201
202   MenuItem revealSeq = new MenuItem();
203
204   /**
205    * index of sequence to be revealed
206    */
207   int revealSeq_index = -1;
208
209   Menu menu1 = new Menu();
210
211   public APopupMenu(AlignmentPanel apanel, final SequenceI seq,
212           Vector<String> links)
213   {
214     // /////////////////////////////////////////////////////////
215     // If this is activated from the sequence panel, the user may want to
216     // edit or annotate a particular residue. Therefore display the residue menu
217     //
218     // If from the IDPanel, we must display the sequence menu
219     // ////////////////////////////////////////////////////////
220
221     this.ap = apanel;
222     this.seq = seq;
223
224     try
225     {
226       jbInit();
227     } catch (Exception e)
228     {
229       e.printStackTrace();
230     }
231
232     for (String ff : FileFormats.getInstance().getWritableFormats(true))
233     {
234       MenuItem item = new MenuItem(ff);
235
236       item.addActionListener(this);
237       outputmenu.add(item);
238     }
239
240     buildAnnotationSubmenus();
241
242     SequenceGroup sg = ap.av.getSelectionGroup();
243     if (sg != null && sg.getSize() > 0)
244     {
245       editGroupName.setLabel(MessageManager.formatMessage(
246               "label.name_param", new Object[] { sg.getName() }));
247       showText.setState(sg.getDisplayText());
248       showColourText.setState(sg.getColourText());
249       showBoxes.setState(sg.getDisplayBoxes());
250       displayNonconserved.setState(sg.getShowNonconserved());
251       if (!ap.av.getAlignment().getGroups().contains(sg))
252       {
253         menu1.setLabel(MessageManager.getString("action.edit_new_group"));
254         groupMenu.remove(unGroupMenuItem);
255       }
256       else
257       {
258         menu1.setLabel(MessageManager.getString("action.edit_group"));
259         groupMenu.remove(createGroupMenuItem);
260         if (sg.cs != null)
261         {
262           abovePIDColour.setState(sg.cs.getThreshold() > 0);
263           conservationColour.setState(sg.cs.conservationApplied());
264           modifyPID.setEnabled(abovePIDColour.getState());
265           modifyConservation.setEnabled(conservationColour.getState());
266         }
267       }
268       setSelectedColour(sg.cs);
269     }
270     else
271     {
272       remove(hideSeqs);
273       remove(groupMenu);
274     }
275
276     if (links != null && links.size() > 0)
277     {
278       addFeatureLinks(seq, links);
279     }
280
281     // TODO: add group link menu entry here
282     if (seq != null)
283     {
284       seqMenu.setLabel(seq.getName());
285       if (seq == ap.av.getAlignment().getSeqrep())
286       {
287         makeReferenceSeq.setLabel(MessageManager
288                 .getString("action.unmark_as_reference"));// Unmark
289                                                           // representative");
290       }
291       else
292       {
293         makeReferenceSeq.setLabel(MessageManager
294                 .getString("action.set_as_reference")); // );
295       }
296       repGroup.setLabel(MessageManager.formatMessage(
297               "label.represent_group_with", new Object[] { seq.getName() }));
298     }
299     else
300     {
301       remove(seqMenu);
302     }
303
304     if (!ap.av.hasHiddenRows())
305     {
306       remove(revealAll);
307       remove(revealSeq);
308     }
309     else
310     {
311       final int index = ap.av.getAlignment().findIndex(seq);
312
313       if (ap.av.adjustForHiddenSeqs(index)
314               - ap.av.adjustForHiddenSeqs(index - 1) > 1)
315       {
316         revealSeq_index = index;
317       }
318       else
319       {
320         remove(revealSeq);
321       }
322     }
323   }
324
325   /**
326    * Select the menu item (if any) matching the current colour scheme. This
327    * works by matching the menu item name (not display text) to the canonical
328    * name of the colour scheme.
329    * 
330    * @param cs
331    */
332   protected void setSelectedColour(ColourSchemeI cs)
333   {
334     if (cs == null)
335     {
336       noColour.setState(true);
337     }
338     else
339     {
340       for (int i = 0; i < colourMenu.getItemCount(); i++)
341       {
342         MenuItem item = colourMenu.getItem(i);
343         if (item instanceof CheckboxMenuItem)
344         {
345           if (cs.getSchemeName().equals(item.getName()))
346           {
347             ((CheckboxMenuItem) item).setState(true);
348           }
349         }
350       }
351     }
352   }
353
354   /**
355    * Adds a 'Link' menu item with a sub-menu item for each hyperlink provided.
356    * 
357    * @param seq
358    * @param links
359    */
360   void addFeatureLinks(final SequenceI seq, List<String> links)
361   {
362     Menu linkMenu = new Menu(MessageManager.getString("action.link"));
363     Map<String, List<String>> linkset = new LinkedHashMap<String, List<String>>();
364
365     for (String link : links)
366     {
367       UrlLink urlLink = null;
368       try
369       {
370         urlLink = new UrlLink(link);
371       } catch (Exception foo)
372       {
373         System.err.println("Exception for URLLink '" + link + "': "
374                 + foo.getMessage());
375         continue;
376       }
377
378       if (!urlLink.isValid())
379       {
380         System.err.println(urlLink.getInvalidMessage());
381         continue;
382       }
383
384       urlLink.createLinksFromSeq(seq, linkset);
385     }
386
387     addshowLinks(linkMenu, linkset.values());
388
389     // disable link menu if there are no valid entries
390     if (linkMenu.getItemCount() > 0)
391     {
392       linkMenu.setEnabled(true);
393     }
394     else
395     {
396       linkMenu.setEnabled(false);
397     }
398
399     if (seq != null)
400     {
401       seqMenu.add(linkMenu);
402     }
403     else
404     {
405       add(linkMenu);
406     }
407
408   }
409
410   private void addshowLinks(Menu linkMenu, Collection<List<String>> linkset)
411   {
412     for (List<String> linkstrset : linkset)
413     {
414       // split linkstr into label and url
415       addshowLink(linkMenu, linkstrset.get(1), linkstrset.get(3));
416     }
417   }
418
419   /**
420    * Build menus for annotation types that may be shown or hidden, and for
421    * 'reference annotations' that may be added to the alignment.
422    */
423   private void buildAnnotationSubmenus()
424   {
425     /*
426      * First for the currently selected sequence (if there is one):
427      */
428     final List<SequenceI> selectedSequence = (seq == null ? Collections
429             .<SequenceI> emptyList() : Arrays.asList(seq));
430     buildAnnotationTypesMenus(seqShowAnnotationsMenu,
431             seqHideAnnotationsMenu, selectedSequence);
432     configureReferenceAnnotationsMenu(seqAddReferenceAnnotations,
433             selectedSequence);
434
435     /*
436      * and repeat for the current selection group (if there is one):
437      */
438     final List<SequenceI> selectedGroup = (ap.av.getSelectionGroup() == null ? Collections
439             .<SequenceI> emptyList() : ap.av.getSelectionGroup()
440             .getSequences());
441     buildAnnotationTypesMenus(groupShowAnnotationsMenu,
442             groupHideAnnotationsMenu, selectedGroup);
443     configureReferenceAnnotationsMenu(groupAddReferenceAnnotations,
444             selectedGroup);
445   }
446
447   /**
448    * Determine whether or not to enable 'add reference annotations' menu item.
449    * It is enable if there are any annotations, on any of the selected
450    * sequences, which are not yet on the alignment (visible or not).
451    * 
452    * @param menu
453    * @param forSequences
454    */
455   private void configureReferenceAnnotationsMenu(MenuItem menuItem,
456           List<SequenceI> forSequences)
457   {
458     menuItem.setEnabled(false);
459
460     /*
461      * Temporary store to hold distinct calcId / type pairs for the tooltip.
462      * Using TreeMap means calcIds are shown in alphabetical order.
463      */
464     SortedMap<String, String> tipEntries = new TreeMap<String, String>();
465     final Map<SequenceI, List<AlignmentAnnotation>> candidates = new LinkedHashMap<SequenceI, List<AlignmentAnnotation>>();
466     AlignmentI al = this.ap.av.getAlignment();
467     AlignmentUtils.findAddableReferenceAnnotations(forSequences,
468             tipEntries, candidates, al);
469     if (!candidates.isEmpty())
470     {
471       StringBuilder tooltip = new StringBuilder(64);
472       tooltip.append(MessageManager.getString("label.add_annotations_for"));
473
474       /*
475        * Found annotations that could be added. Enable the menu item, and
476        * configure its action.
477        */
478       menuItem.setEnabled(true);
479
480       menuItem.addActionListener(new ActionListener()
481       {
482         @Override
483         public void actionPerformed(ActionEvent e)
484         {
485           addReferenceAnnotations_actionPerformed(candidates);
486         }
487       });
488     }
489   }
490
491   /**
492    * Add annotations to the sequences and to the alignment.
493    * 
494    * @param candidates
495    *          a map whose keys are sequences on the alignment, and values a list
496    *          of annotations to add to each sequence
497    */
498   protected void addReferenceAnnotations_actionPerformed(
499           Map<SequenceI, List<AlignmentAnnotation>> candidates)
500   {
501     final SequenceGroup selectionGroup = this.ap.av.getSelectionGroup();
502     final AlignmentI alignment = this.ap.getAlignment();
503     AlignmentUtils.addReferenceAnnotations(candidates, alignment,
504             selectionGroup);
505     refresh();
506   }
507
508   /**
509    * add a show URL menu item to the given linkMenu
510    * 
511    * @param linkMenu
512    * @param target
513    *          - menu label string
514    * @param url
515    *          - url to open
516    */
517   private void addshowLink(Menu linkMenu, final String target,
518           final String url)
519   {
520     addshowLink(linkMenu, target, target, url);
521   }
522
523   /**
524    * add a show URL menu item to the given linkMenu
525    * 
526    * @param linkMenu
527    * @param target
528    *          - URL target window
529    * @param label
530    *          - menu label string
531    * @param url
532    *          - url to open
533    */
534   private void addshowLink(Menu linkMenu, final String target,
535           final String label, final String url)
536   {
537     MenuItem item = new MenuItem(label);
538     item.addActionListener(new java.awt.event.ActionListener()
539     {
540       @Override
541       public void actionPerformed(ActionEvent e)
542       {
543         ap.alignFrame.showURL(url, target);
544       }
545     });
546     linkMenu.add(item);
547   }
548
549   /**
550    * Actions on selecting / unselecting a checkbox menu item
551    */
552   @Override
553   public void itemStateChanged(ItemEvent evt)
554   {
555     Object source = evt.getSource();
556     if (source == noColour)
557     {
558       noColourmenuItem_actionPerformed();
559     }
560     else if (source == clustalColour)
561     {
562       clustalColour_actionPerformed();
563     }
564     else if (source == BLOSUM62Colour)
565     {
566       BLOSUM62Colour_actionPerformed();
567     }
568     else if (source == PIDColour)
569     {
570       PIDColour_actionPerformed();
571     }
572     else if (source == zappoColour)
573     {
574       zappoColour_actionPerformed();
575     }
576     else if (source == taylorColour)
577     {
578       taylorColour_actionPerformed();
579     }
580     else if (source == hydrophobicityColour)
581     {
582       hydrophobicityColour_actionPerformed();
583     }
584     else if (source == helixColour)
585     {
586       helixColour_actionPerformed();
587     }
588     else if (source == strandColour)
589     {
590       strandColour_actionPerformed();
591     }
592     else if (source == turnColour)
593     {
594       turnColour_actionPerformed();
595     }
596     else if (source == buriedColour)
597     {
598       buriedColour_actionPerformed();
599     }
600     else if (source == nucleotideColour)
601     {
602       nucleotideMenuItem_actionPerformed();
603     }
604     else if (source == purinePyrimidineColour)
605     {
606       purinePyrimidineColour_actionPerformed();
607     }
608     else if (source == abovePIDColour)
609     {
610       abovePIDColour_itemStateChanged();
611     }
612     else if (source == conservationColour)
613     {
614       conservationMenuItem_itemStateChanged();
615     }
616     else if (source == showColourText)
617     {
618       showColourText_itemStateChanged();
619     }
620     else if (source == showText)
621     {
622       showText_itemStateChanged();
623     }
624     else if (source == showBoxes)
625     {
626       showBoxes_itemStateChanged();
627     }
628     else if (source == displayNonconserved)
629     {
630       this.showNonconserved_itemStateChanged();
631     }
632   }
633
634   /**
635    * Actions on clicking a menu item
636    */
637   @Override
638   public void actionPerformed(ActionEvent evt)
639   {
640     Object source = evt.getSource();
641     if (source == userDefinedColour)
642     {
643       userDefinedColour_actionPerformed();
644     }
645     else if (source == modifyConservation)
646     {
647       conservationMenuItem_itemStateChanged();
648     }
649     else if (source == modifyPID)
650     {
651       abovePIDColour_itemStateChanged();
652     }
653     else if (source == unGroupMenuItem)
654     {
655       unGroupMenuItem_actionPerformed();
656     }
657
658     else if (source == createGroupMenuItem)
659     {
660       createGroupMenuItem_actionPerformed();
661     }
662
663     else if (source == sequenceName)
664     {
665       editName();
666     }
667     else if (source == makeReferenceSeq)
668     {
669       makeReferenceSeq_actionPerformed();
670     }
671     else if (source == sequenceDetails)
672     {
673       showSequenceDetails();
674     }
675     else if (source == selSeqDetails)
676     {
677       showSequenceSelectionDetails();
678     }
679     else if (source == pdb)
680     {
681       addPDB();
682     }
683     else if (source == hideSeqs)
684     {
685       hideSequences(false);
686     }
687     else if (source == repGroup)
688     {
689       hideSequences(true);
690     }
691     else if (source == revealSeq)
692     {
693       ap.av.showSequence(revealSeq_index);
694     }
695     else if (source == revealAll)
696     {
697       ap.av.showAllHiddenSeqs();
698     }
699
700     else if (source == editGroupName)
701     {
702       EditNameDialog dialog = new EditNameDialog(getGroup().getName(),
703               getGroup().getDescription(), "       Group Name",
704               "Group Description", ap.alignFrame,
705               "Edit Group Name / Description", 500, 100, true);
706
707       if (dialog.accept)
708       {
709         getGroup().setName(dialog.getName().replace(' ', '_'));
710         getGroup().setDescription(dialog.getDescription());
711       }
712
713     }
714     else if (source == copy)
715     {
716       ap.alignFrame.copy_actionPerformed();
717     }
718     else if (source == cut)
719     {
720       ap.alignFrame.cut_actionPerformed();
721     }
722     else if (source == editSequence)
723     {
724       SequenceGroup sg = ap.av.getSelectionGroup();
725
726       if (sg != null)
727       {
728         if (seq == null)
729         {
730           seq = sg.getSequenceAt(0);
731         }
732
733         EditNameDialog dialog = new EditNameDialog(seq.getSequenceAsString(
734                 sg.getStartRes(), sg.getEndRes() + 1), null,
735                 "Edit Sequence ", null,
736
737                 ap.alignFrame, "Edit Sequence", 500, 100, true);
738
739         if (dialog.accept)
740         {
741           EditCommand editCommand = new EditCommand(
742                   MessageManager.getString("label.edit_sequences"),
743                   Action.REPLACE, dialog.getName().replace(' ',
744                           ap.av.getGapCharacter()),
745                   sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
746                   sg.getStartRes(), sg.getEndRes() + 1,
747                   ap.av.getAlignment());
748
749           ap.alignFrame.addHistoryItem(editCommand);
750
751           ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
752                   .getSequences());
753         }
754       }
755     }
756     else if (source == toUpper || source == toLower || source == toggleCase)
757     {
758       SequenceGroup sg = ap.av.getSelectionGroup();
759       if (sg != null)
760       {
761         List<int[]> startEnd = ap.av.getVisibleRegionBoundaries(
762                 sg.getStartRes(), sg.getEndRes() + 1);
763
764         String description;
765         int caseChange;
766
767         if (source == toggleCase)
768         {
769           description = "Toggle Case";
770           caseChange = ChangeCaseCommand.TOGGLE_CASE;
771         }
772         else if (source == toUpper)
773         {
774           description = "To Upper Case";
775           caseChange = ChangeCaseCommand.TO_UPPER;
776         }
777         else
778         {
779           description = "To Lower Case";
780           caseChange = ChangeCaseCommand.TO_LOWER;
781         }
782
783         ChangeCaseCommand caseCommand = new ChangeCaseCommand(description,
784                 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
785                 startEnd, caseChange);
786
787         ap.alignFrame.addHistoryItem(caseCommand);
788
789         ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
790                 .getSequences());
791
792       }
793     }
794     else if (source == sequenceFeature)
795     {
796       SequenceGroup sg = ap.av.getSelectionGroup();
797       if (sg == null)
798       {
799         return;
800       }
801
802       int rsize = 0, gSize = sg.getSize();
803       SequenceI[] rseqs, seqs = new SequenceI[gSize];
804       SequenceFeature[] tfeatures, features = new SequenceFeature[gSize];
805
806       for (int i = 0; i < gSize; i++)
807       {
808         int start = sg.getSequenceAt(i).findPosition(sg.getStartRes());
809         int end = sg.findEndRes(sg.getSequenceAt(i));
810         if (start <= end)
811         {
812           seqs[rsize] = sg.getSequenceAt(i);
813           features[rsize] = new SequenceFeature(null, null, null, start,
814                   end, "Jalview");
815           rsize++;
816         }
817       }
818       rseqs = new SequenceI[rsize];
819       tfeatures = new SequenceFeature[rsize];
820       System.arraycopy(seqs, 0, rseqs, 0, rsize);
821       System.arraycopy(features, 0, tfeatures, 0, rsize);
822       features = tfeatures;
823       seqs = rseqs;
824
825       if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs,
826               features, true, ap))
827       {
828         ap.alignFrame.sequenceFeatures.setState(true);
829         ap.av.setShowSequenceFeatures(true);
830         ;
831         ap.highlightSearchResults(null);
832       }
833     }
834     else
835     {
836       outputText(evt);
837     }
838
839   }
840
841   void outputText(ActionEvent e)
842   {
843     CutAndPasteTransfer cap = new CutAndPasteTransfer(true, ap.alignFrame);
844
845     Frame frame = new Frame();
846     frame.add(cap);
847     JalviewLite.addFrame(frame, MessageManager.formatMessage(
848             "label.selection_output_command",
849             new Object[] { e.getActionCommand() }), 600, 500);
850     // JBPNote: getSelectionAsNewSequence behaviour has changed - this method
851     // now returns a full copy of sequence data
852     // TODO consider using getSequenceSelection instead here
853
854     FileFormatI fileFormat = FileFormats.getInstance().forName(
855             e.getActionCommand());
856     cap.setText(new AppletFormatAdapter().formatSequences(fileFormat,
857             ap.av.getShowJVSuffix(), ap, true));
858
859   }
860
861   protected void showSequenceSelectionDetails()
862   {
863     createSequenceDetailsReport(ap.av.getSequenceSelection());
864   }
865
866   protected void showSequenceDetails()
867   {
868     createSequenceDetailsReport(new SequenceI[] { seq });
869   }
870
871   public void createSequenceDetailsReport(SequenceI[] sequences)
872   {
873
874     CutAndPasteTransfer cap = new CutAndPasteTransfer(false, ap.alignFrame);
875
876     StringBuilder contents = new StringBuilder(128);
877     for (SequenceI seq : sequences)
878     {
879       contents.append(MessageManager.formatMessage(
880               "label.annotation_for_displayid",
881               new Object[] { seq.getDisplayId(true) }));
882       new SequenceAnnotationReport(null).createSequenceAnnotationReport(
883               contents,
884               seq,
885               true,
886               true,
887               (ap.seqPanel.seqCanvas.fr != null) ? ap.seqPanel.seqCanvas.fr
888                       .getMinMax() : null);
889       contents.append("</p>");
890     }
891     Frame frame = new Frame();
892     frame.add(cap);
893     jalview.bin.JalviewLite.addFrame(frame, "Sequence Details for "
894             + (sequences.length == 1 ? sequences[0].getDisplayId(true)
895                     : "Selection"), 600, 500);
896     cap.setText(MessageManager.formatMessage("label.html_content",
897             new Object[] { contents.toString() }));
898   }
899
900   void editName()
901   {
902     EditNameDialog dialog = new EditNameDialog(seq.getName(),
903             seq.getDescription(), "       Sequence Name",
904             "Sequence Description", ap.alignFrame,
905             "Edit Sequence Name / Description", 500, 100, true);
906
907     if (dialog.accept)
908     {
909       seq.setName(dialog.getName());
910       seq.setDescription(dialog.getDescription());
911       ap.paintAlignment(false);
912     }
913   }
914
915   void addPDB()
916   {
917     Vector<PDBEntry> pdbs = seq.getAllPDBEntries();
918     if (pdbs != null && !pdbs.isEmpty())
919     {
920       PDBEntry entry = pdbs.firstElement();
921
922       if (ap.av.applet.jmolAvailable)
923       {
924         new AppletJmol(entry, new SequenceI[] { seq }, null, ap,
925                 DataSourceType.URL);
926       }
927       else
928       {
929         new MCview.AppletPDBViewer(entry, new SequenceI[] { seq }, null,
930                 ap, DataSourceType.URL);
931       }
932
933     }
934     else
935     {
936       CutAndPasteTransfer cap = new CutAndPasteTransfer(true, ap.alignFrame);
937       cap.setText(MessageManager.getString("label.paste_pdb_file"));
938       cap.setPDBImport(seq);
939       Frame frame = new Frame();
940       frame.add(cap);
941       JalviewLite.addFrame(frame, MessageManager.formatMessage(
942               "label.paste_pdb_file_for_sequence",
943               new Object[] { seq.getName() }), 400, 300);
944     }
945   }
946
947   private void jbInit() throws Exception
948   {
949     groupMenu.setLabel(MessageManager.getString("label.selection"));
950     sequenceFeature.addActionListener(this);
951
952     editGroupName.addActionListener(this);
953     unGroupMenuItem.setLabel(MessageManager
954             .getString("action.remove_group"));
955     unGroupMenuItem.addActionListener(this);
956
957     createGroupMenuItem.setLabel(MessageManager
958             .getString("action.create_group"));
959     createGroupMenuItem.addActionListener(this);
960
961     colourMenu.setLabel(MessageManager.getString("label.group_colour"));
962     showBoxes.setLabel(MessageManager.getString("action.boxes"));
963     showBoxes.setState(true);
964     showBoxes.addItemListener(this);
965     sequenceName.addActionListener(this);
966     sequenceDetails.addActionListener(this);
967     selSeqDetails.addActionListener(this);
968     displayNonconserved.setLabel(MessageManager
969             .getString("label.show_non_conserved"));
970     displayNonconserved.setState(false);
971     displayNonconserved.addItemListener(this);
972     showText.setLabel(MessageManager.getString("action.text"));
973     showText.addItemListener(this);
974     showColourText.setLabel(MessageManager.getString("label.colour_text"));
975     showColourText.addItemListener(this);
976     outputmenu.setLabel(MessageManager.getString("label.out_to_textbox"));
977     seqMenu.setLabel(MessageManager.getString("label.sequence"));
978     pdb.setLabel(MessageManager.getString("label.view_pdb_structure"));
979     hideSeqs.setLabel(MessageManager.getString("action.hide_sequences"));
980     repGroup.setLabel(MessageManager.formatMessage(
981             "label.represent_group_with", new Object[] { "" }));
982     revealAll.setLabel(MessageManager.getString("action.reveal_all"));
983     revealSeq.setLabel(MessageManager.getString("action.reveal_sequences"));
984     menu1.setLabel(MessageManager.getString("label.group:"));
985     add(groupMenu);
986     this.add(seqMenu);
987     this.add(hideSeqs);
988     this.add(revealSeq);
989     this.add(revealAll);
990     // groupMenu.add(selSeqDetails);
991     groupMenu.add(groupShowAnnotationsMenu);
992     groupMenu.add(groupHideAnnotationsMenu);
993     groupMenu.add(groupAddReferenceAnnotations);
994     groupMenu.add(editMenu);
995     groupMenu.add(outputmenu);
996     groupMenu.add(sequenceFeature);
997     groupMenu.add(createGroupMenuItem);
998     groupMenu.add(unGroupMenuItem);
999     groupMenu.add(menu1);
1000
1001     colourMenu.add(noColour);
1002     colourMenu.add(clustalColour);
1003     colourMenu.add(BLOSUM62Colour);
1004     colourMenu.add(PIDColour);
1005     colourMenu.add(zappoColour);
1006     colourMenu.add(taylorColour);
1007     colourMenu.add(hydrophobicityColour);
1008     colourMenu.add(helixColour);
1009     colourMenu.add(strandColour);
1010     colourMenu.add(turnColour);
1011     colourMenu.add(buriedColour);
1012     colourMenu.add(nucleotideColour);
1013     colourMenu.add(purinePyrimidineColour);
1014     colourMenu.add(userDefinedColour);
1015     colourMenu.addSeparator();
1016     colourMenu.add(conservationColour);
1017     colourMenu.add(modifyConservation);
1018     colourMenu.add(abovePIDColour);
1019     colourMenu.add(modifyPID);
1020
1021     noColour.setLabel(MessageManager.getString("label.none"));
1022     noColour.addItemListener(this);
1023
1024     /*
1025      * setName allows setSelectedColour to do its thing
1026      */
1027     clustalColour.setLabel(MessageManager
1028             .getString("label.colourScheme_clustal"));
1029     clustalColour.setName(JalviewColourScheme.Clustal.toString());
1030     clustalColour.addItemListener(this);
1031     BLOSUM62Colour.setLabel(MessageManager
1032             .getString("label.colourScheme_blosum62"));
1033     BLOSUM62Colour.setName(JalviewColourScheme.Blosum62.toString());
1034     BLOSUM62Colour.addItemListener(this);
1035     PIDColour.setLabel(MessageManager
1036             .getString("label.colourScheme_%_identity"));
1037     PIDColour.setName(JalviewColourScheme.PID.toString());
1038     PIDColour.addItemListener(this);
1039     zappoColour.setLabel(MessageManager
1040             .getString("label.colourScheme_zappo"));
1041     zappoColour.setName(JalviewColourScheme.Zappo.toString());
1042     zappoColour.addItemListener(this);
1043     taylorColour.setLabel(MessageManager
1044             .getString("label.colourScheme_taylor"));
1045     taylorColour.setName(JalviewColourScheme.Taylor.toString());
1046     taylorColour.addItemListener(this);
1047     hydrophobicityColour.setLabel(MessageManager
1048             .getString("label.colourScheme_hydrophobic"));
1049     hydrophobicityColour
1050             .setName(JalviewColourScheme.Hydrophobic.toString());
1051     hydrophobicityColour.addItemListener(this);
1052     helixColour.setLabel(MessageManager
1053             .getString("label.colourScheme_helix_propensity"));
1054     helixColour.setName(JalviewColourScheme.Helix.toString());
1055     helixColour.addItemListener(this);
1056     strandColour.setLabel(MessageManager
1057             .getString("label.colourScheme_strand_propensity"));
1058     strandColour.setName(JalviewColourScheme.Strand.toString());
1059     strandColour.addItemListener(this);
1060     turnColour.setLabel(MessageManager
1061             .getString("label.colourScheme_turn_propensity"));
1062     turnColour.setName(JalviewColourScheme.Turn.toString());
1063     turnColour.addItemListener(this);
1064     buriedColour.setLabel(MessageManager
1065             .getString("label.colourScheme_buried_index"));
1066     buriedColour.setName(JalviewColourScheme.Buried.toString());
1067     buriedColour.addItemListener(this);
1068     nucleotideColour.setLabel(MessageManager
1069             .getString("label.colourScheme_nucleotide"));
1070     nucleotideColour.setName(JalviewColourScheme.Nucleotide.toString());
1071     nucleotideColour.addItemListener(this);
1072     purinePyrimidineColour.setLabel(MessageManager
1073             .getString("label.colourScheme_purine/pyrimidine"));
1074     purinePyrimidineColour.setName(JalviewColourScheme.PurinePyrimidine
1075             .toString());
1076     purinePyrimidineColour.addItemListener(this);
1077
1078     userDefinedColour.setLabel(MessageManager
1079             .getString("action.user_defined"));
1080     userDefinedColour.addActionListener(this);
1081
1082     abovePIDColour.setLabel(MessageManager
1083             .getString("label.above_identity_threshold"));
1084     abovePIDColour.addItemListener(this);
1085     modifyPID.setLabel(MessageManager
1086             .getString("label.modify_identity_threshold"));
1087     modifyPID.addActionListener(this);
1088     conservationColour.setLabel(MessageManager
1089             .getString("action.by_conservation"));
1090     conservationColour.addItemListener(this);
1091     modifyConservation.setLabel(MessageManager
1092             .getString("label.modify_conservation_threshold"));
1093     modifyConservation.addActionListener(this);
1094
1095     PIDColour.addActionListener(this);
1096     BLOSUM62Colour.addActionListener(this);
1097
1098     editMenu.add(copy);
1099     copy.addActionListener(this);
1100     editMenu.add(cut);
1101     cut.addActionListener(this);
1102
1103     editMenu.add(editSequence);
1104     editSequence.addActionListener(this);
1105
1106     editMenu.add(toUpper);
1107     toUpper.addActionListener(this);
1108     editMenu.add(toLower);
1109     toLower.addActionListener(this);
1110     editMenu.add(toggleCase);
1111     seqMenu.add(seqShowAnnotationsMenu);
1112     seqMenu.add(seqHideAnnotationsMenu);
1113     seqMenu.add(seqAddReferenceAnnotations);
1114     seqMenu.add(sequenceName);
1115     seqMenu.add(makeReferenceSeq);
1116     // seqMenu.add(sequenceDetails);
1117
1118     if (!ap.av.applet.useXtrnalSviewer)
1119     {
1120       seqMenu.add(pdb);
1121     }
1122     seqMenu.add(repGroup);
1123     menu1.add(editGroupName);
1124     menu1.add(colourMenu);
1125     menu1.add(showBoxes);
1126     menu1.add(showText);
1127     menu1.add(showColourText);
1128     menu1.add(displayNonconserved);
1129     toggleCase.addActionListener(this);
1130     pdb.addActionListener(this);
1131     hideSeqs.addActionListener(this);
1132     repGroup.addActionListener(this);
1133     revealAll.addActionListener(this);
1134     revealSeq.addActionListener(this);
1135     makeReferenceSeq.addActionListener(this);
1136   }
1137
1138   void refresh()
1139   {
1140     ap.paintAlignment(true);
1141   }
1142
1143   protected void clustalColour_actionPerformed()
1144   {
1145     SequenceGroup sg = getGroup();
1146     sg.cs = new ClustalxColourScheme(sg, ap.av.getHiddenRepSequences());
1147     refresh();
1148   }
1149
1150   protected void zappoColour_actionPerformed()
1151   {
1152     getGroup().cs = new ZappoColourScheme();
1153     refresh();
1154   }
1155
1156   protected void taylorColour_actionPerformed()
1157   {
1158     getGroup().cs = new TaylorColourScheme();
1159     refresh();
1160   }
1161
1162   protected void hydrophobicityColour_actionPerformed()
1163   {
1164     getGroup().cs = new HydrophobicColourScheme();
1165     refresh();
1166   }
1167
1168   protected void helixColour_actionPerformed()
1169   {
1170     getGroup().cs = new HelixColourScheme();
1171     refresh();
1172   }
1173
1174   protected void strandColour_actionPerformed()
1175   {
1176     getGroup().cs = new StrandColourScheme();
1177     refresh();
1178   }
1179
1180   protected void turnColour_actionPerformed()
1181   {
1182     getGroup().cs = new TurnColourScheme();
1183     refresh();
1184   }
1185
1186   protected void buriedColour_actionPerformed()
1187   {
1188     getGroup().cs = new BuriedColourScheme();
1189     refresh();
1190   }
1191
1192   public void nucleotideMenuItem_actionPerformed()
1193   {
1194     getGroup().cs = new NucleotideColourScheme();
1195     refresh();
1196   }
1197
1198   public void purinePyrimidineColour_actionPerformed()
1199   {
1200     getGroup().cs = new PurinePyrimidineColourScheme();
1201     refresh();
1202   }
1203
1204   protected void abovePIDColour_itemStateChanged()
1205   {
1206     SequenceGroup sg = getGroup();
1207     if (sg.cs == null)
1208     {
1209       return;
1210     }
1211
1212     if (abovePIDColour.getState())
1213     {
1214       sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(ap.av
1215               .getHiddenRepSequences()), 0, ap.av.getAlignment().getWidth()));
1216       int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
1217               .getName());
1218
1219       sg.cs.setThreshold(threshold, ap.av.isIgnoreGapsConsensus());
1220
1221       SliderPanel.showPIDSlider();
1222
1223     }
1224     else
1225     // remove PIDColouring
1226     {
1227       SliderPanel.hidePIDSlider();
1228       sg.cs.setThreshold(0, ap.av.isIgnoreGapsConsensus());
1229     }
1230     modifyPID.setEnabled(abovePIDColour.getState());
1231     refresh();
1232   }
1233
1234   protected void userDefinedColour_actionPerformed()
1235   {
1236     new UserDefinedColours(ap, getGroup());
1237   }
1238
1239   protected void PIDColour_actionPerformed()
1240   {
1241     SequenceGroup sg = getGroup();
1242     sg.cs = new PIDColourScheme();
1243     sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(ap.av
1244             .getHiddenRepSequences()), 0, ap.av.getAlignment().getWidth()));
1245     refresh();
1246   }
1247
1248   protected void BLOSUM62Colour_actionPerformed()
1249   {
1250     SequenceGroup sg = getGroup();
1251
1252     sg.cs = new Blosum62ColourScheme();
1253
1254     sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(ap.av
1255             .getHiddenRepSequences()), 0, ap.av.getAlignment().getWidth()));
1256
1257     refresh();
1258   }
1259
1260   protected void noColourmenuItem_actionPerformed()
1261   {
1262     getGroup().cs = null;
1263     refresh();
1264   }
1265
1266   protected void conservationMenuItem_itemStateChanged()
1267   {
1268     SequenceGroup sg = getGroup();
1269     if (sg.cs == null)
1270     {
1271       return;
1272     }
1273
1274     if (conservationColour.getState())
1275     {
1276       sg.cs.setConservation(Conservation.calculateConservation("Group", sg
1277               .getSequences(ap.av.getHiddenRepSequences()), 0, ap.av
1278               .getAlignment().getWidth(), false, ap.av.getConsPercGaps(),
1279               false));
1280       SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
1281       SliderPanel.showConservationSlider();
1282     }
1283     else
1284     // remove ConservationColouring
1285     {
1286       SliderPanel.hideConservationSlider();
1287       sg.cs.setConservation(null);
1288     }
1289     modifyConservation.setEnabled(conservationColour.getState());
1290     refresh();
1291   }
1292
1293   SequenceGroup getGroup()
1294   {
1295     SequenceGroup sg = ap.av.getSelectionGroup();
1296
1297     // this method won't add a new group if it already exists
1298     if (sg != null)
1299     {
1300       ap.av.getAlignment().addGroup(sg);
1301     }
1302
1303     return sg;
1304   }
1305
1306   void unGroupMenuItem_actionPerformed()
1307   {
1308     SequenceGroup sg = ap.av.getSelectionGroup();
1309     ap.av.getAlignment().deleteGroup(sg);
1310     ap.av.setSelectionGroup(null);
1311     ap.paintAlignment(true);
1312   }
1313
1314   void createGroupMenuItem_actionPerformed()
1315   {
1316     getGroup(); // implicitly create group
1317     refresh();
1318   }
1319
1320   public void showColourText_itemStateChanged()
1321   {
1322     getGroup().setColourText(showColourText.getState());
1323     refresh();
1324   }
1325
1326   public void showText_itemStateChanged()
1327   {
1328     getGroup().setDisplayText(showText.getState());
1329     refresh();
1330   }
1331
1332   public void makeReferenceSeq_actionPerformed()
1333   {
1334     if (!ap.av.getAlignment().hasSeqrep())
1335     {
1336       // initialise the display flags so the user sees something happen
1337       ap.av.setDisplayReferenceSeq(true);
1338       ap.av.setColourByReferenceSeq(true);
1339       ap.av.getAlignment().setSeqrep(seq);
1340     }
1341     else
1342     {
1343       if (ap.av.getAlignment().getSeqrep() == seq)
1344       {
1345         ap.av.getAlignment().setSeqrep(null);
1346       }
1347       else
1348       {
1349         ap.av.getAlignment().setSeqrep(seq);
1350       }
1351     }
1352     refresh();
1353   }
1354
1355   public void showNonconserved_itemStateChanged()
1356   {
1357     getGroup().setShowNonconserved(this.displayNonconserved.getState());
1358     refresh();
1359   }
1360
1361   public void showBoxes_itemStateChanged()
1362   {
1363     getGroup().setDisplayBoxes(showBoxes.getState());
1364     refresh();
1365   }
1366
1367   void hideSequences(boolean representGroup)
1368   {
1369     ap.av.hideSequences(seq, representGroup);
1370   }
1371
1372   /**
1373    * Add annotation types to 'Show annotations' and/or 'Hide annotations' menus.
1374    * "All" is added first, followed by a separator. Then add any annotation
1375    * types associated with the current selection. Separate menus are built for
1376    * the selected sequence group (if any), and the selected sequence.
1377    * <p>
1378    * Some annotation rows are always rendered together - these can be identified
1379    * by a common graphGroup property > -1. Only one of each group will be marked
1380    * as visible (to avoid duplication of the display). For such groups we add a
1381    * composite type name, e.g.
1382    * <p>
1383    * IUPredWS (Long), IUPredWS (Short)
1384    * 
1385    * @param seq
1386    */
1387   protected void buildAnnotationTypesMenus(Menu showMenu, Menu hideMenu,
1388           List<SequenceI> forSequences)
1389   {
1390     showMenu.removeAll();
1391     hideMenu.removeAll();
1392
1393     final List<String> all = Arrays.asList(new String[] { MessageManager
1394             .getString("label.all") });
1395     addAnnotationTypeToShowHide(showMenu, forSequences, "", all, true, true);
1396     addAnnotationTypeToShowHide(hideMenu, forSequences, "", all, true,
1397             false);
1398     showMenu.addSeparator();
1399     hideMenu.addSeparator();
1400
1401     final AlignmentAnnotation[] annotations = ap.getAlignment()
1402             .getAlignmentAnnotation();
1403
1404     /*
1405      * Find shown/hidden annotations types, distinguished by source (calcId),
1406      * and grouped by graphGroup. Using LinkedHashMap means we will retrieve in
1407      * the insertion order, which is the order of the annotations on the
1408      * alignment.
1409      */
1410     Map<String, List<List<String>>> shownTypes = new LinkedHashMap<String, List<List<String>>>();
1411     Map<String, List<List<String>>> hiddenTypes = new LinkedHashMap<String, List<List<String>>>();
1412     AlignmentAnnotationUtils.getShownHiddenTypes(shownTypes, hiddenTypes,
1413             AlignmentAnnotationUtils.asList(annotations), forSequences);
1414
1415     for (String calcId : hiddenTypes.keySet())
1416     {
1417       for (List<String> type : hiddenTypes.get(calcId))
1418       {
1419         addAnnotationTypeToShowHide(showMenu, forSequences, calcId, type,
1420                 false, true);
1421       }
1422     }
1423     // grey out 'show annotations' if none are hidden
1424     showMenu.setEnabled(!hiddenTypes.isEmpty());
1425
1426     for (String calcId : shownTypes.keySet())
1427     {
1428       for (List<String> type : shownTypes.get(calcId))
1429       {
1430         addAnnotationTypeToShowHide(hideMenu, forSequences, calcId, type,
1431                 false, false);
1432       }
1433     }
1434     // grey out 'hide annotations' if none are shown
1435     hideMenu.setEnabled(!shownTypes.isEmpty());
1436   }
1437
1438   /**
1439    * Add one annotation type to the 'Show Annotations' or 'Hide Annotations'
1440    * menus.
1441    * 
1442    * @param showOrHideMenu
1443    *          the menu to add to
1444    * @param forSequences
1445    *          the sequences whose annotations may be shown or hidden
1446    * @param calcId
1447    * @param types
1448    *          the label to add
1449    * @param allTypes
1450    *          if true this is a special label meaning 'All'
1451    * @param actionIsShow
1452    *          if true, the select menu item action is to show the annotation
1453    *          type, else hide
1454    */
1455   protected void addAnnotationTypeToShowHide(Menu showOrHideMenu,
1456           final List<SequenceI> forSequences, String calcId,
1457           final List<String> types, final boolean allTypes,
1458           final boolean actionIsShow)
1459   {
1460     String label = types.toString(); // [a, b, c]
1461     label = label.substring(1, label.length() - 1);
1462     final MenuItem item = new MenuItem(label);
1463     item.addActionListener(new java.awt.event.ActionListener()
1464     {
1465       @Override
1466       public void actionPerformed(ActionEvent e)
1467       {
1468         AlignmentUtils.showOrHideSequenceAnnotations(ap.getAlignment(),
1469                 types, forSequences, allTypes, actionIsShow);
1470         refresh();
1471       }
1472     });
1473     showOrHideMenu.add(item);
1474   }
1475
1476 }