2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import jalview.analysis.AAFrequency;
24 import jalview.analysis.AlignmentAnnotationUtils;
25 import jalview.analysis.AlignmentUtils;
26 import jalview.analysis.Conservation;
27 import jalview.bin.Cache;
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.Annotation;
34 import jalview.datamodel.DBRefEntry;
35 import jalview.datamodel.HiddenColumns;
36 import jalview.datamodel.PDBEntry;
37 import jalview.datamodel.Sequence;
38 import jalview.datamodel.SequenceFeature;
39 import jalview.datamodel.SequenceGroup;
40 import jalview.datamodel.SequenceI;
41 import jalview.gui.ColourMenuHelper.ColourChangeListener;
42 import jalview.io.FileFormatI;
43 import jalview.io.FileFormats;
44 import jalview.io.FormatAdapter;
45 import jalview.io.SequenceAnnotationReport;
46 import jalview.schemes.Blosum62ColourScheme;
47 import jalview.schemes.ColourSchemeI;
48 import jalview.schemes.ColourSchemes;
49 import jalview.schemes.PIDColourScheme;
50 import jalview.util.GroupUrlLink;
51 import jalview.util.GroupUrlLink.UrlStringTooLongException;
52 import jalview.util.MessageManager;
53 import jalview.util.UrlLink;
55 import java.awt.Color;
56 import java.awt.event.ActionEvent;
57 import java.awt.event.ActionListener;
58 import java.util.ArrayList;
59 import java.util.Arrays;
60 import java.util.BitSet;
61 import java.util.Collection;
62 import java.util.Collections;
63 import java.util.Hashtable;
64 import java.util.LinkedHashMap;
65 import java.util.List;
67 import java.util.SortedMap;
68 import java.util.TreeMap;
69 import java.util.Vector;
71 import javax.swing.JCheckBoxMenuItem;
72 import javax.swing.JColorChooser;
73 import javax.swing.JMenu;
74 import javax.swing.JMenuItem;
75 import javax.swing.JPopupMenu;
81 * @version $Revision: 1.118 $
83 public class PopupMenu extends JPopupMenu implements ColourChangeListener
85 JMenu groupMenu = new JMenu();
87 JMenuItem groupName = new JMenuItem();
89 protected JCheckBoxMenuItem abovePIDColour = new JCheckBoxMenuItem();
91 protected JMenuItem modifyPID = new JMenuItem();
93 protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem();
95 protected JMenuItem modifyConservation = new JMenuItem();
99 JMenu sequenceMenu = new JMenu();
101 JMenuItem sequenceName = new JMenuItem();
103 JMenuItem sequenceDetails = new JMenuItem();
105 JMenuItem sequenceSelDetails = new JMenuItem();
107 JMenuItem makeReferenceSeq = new JMenuItem();
109 JMenuItem chooseAnnotations = new JMenuItem();
113 JMenuItem createGroupMenuItem = new JMenuItem();
115 JMenuItem unGroupMenuItem = new JMenuItem();
117 JMenuItem outline = new JMenuItem();
119 JMenu colourMenu = new JMenu();
121 JCheckBoxMenuItem showBoxes = new JCheckBoxMenuItem();
123 JCheckBoxMenuItem showText = new JCheckBoxMenuItem();
125 JCheckBoxMenuItem showColourText = new JCheckBoxMenuItem();
127 JCheckBoxMenuItem displayNonconserved = new JCheckBoxMenuItem();
129 JMenu editMenu = new JMenu();
131 JMenuItem cut = new JMenuItem();
133 JMenuItem copy = new JMenuItem();
135 JMenuItem upperCase = new JMenuItem();
137 JMenuItem lowerCase = new JMenuItem();
139 JMenuItem toggle = new JMenuItem();
141 JMenu pdbMenu = new JMenu();
143 JMenu outputMenu = new JMenu();
145 JMenu seqShowAnnotationsMenu = new JMenu();
147 JMenu seqHideAnnotationsMenu = new JMenu();
149 JMenuItem seqAddReferenceAnnotations = new JMenuItem(
150 MessageManager.getString("label.add_reference_annotations"));
152 JMenu groupShowAnnotationsMenu = new JMenu();
154 JMenu groupHideAnnotationsMenu = new JMenu();
156 JMenuItem groupAddReferenceAnnotations = new JMenuItem(
157 MessageManager.getString("label.add_reference_annotations"));
159 JMenuItem sequenceFeature = new JMenuItem();
161 JMenuItem textColour = new JMenuItem();
163 JMenu jMenu1 = new JMenu();
165 JMenuItem pdbStructureDialog = new JMenuItem();
167 JMenu rnaStructureMenu = new JMenu();
169 JMenuItem editSequence = new JMenuItem();
171 JMenu groupLinksMenu;
173 JMenuItem hideInsertions = new JMenuItem();
176 * Creates a new PopupMenu object.
183 public PopupMenu(final AlignmentPanel ap, Sequence seq,
186 this(ap, seq, links, null);
196 public PopupMenu(final AlignmentPanel ap, final SequenceI seq,
197 List<String> links, List<String> groupLinks)
199 // /////////////////////////////////////////////////////////
200 // If this is activated from the sequence panel, the user may want to
201 // edit or annotate a particular residue. Therefore display the residue menu
203 // If from the IDPanel, we must display the sequence menu
204 // ////////////////////////////////////////////////////////
208 for (String ff : FileFormats.getInstance().getWritableFormats(true))
210 JMenuItem item = new JMenuItem(ff);
212 item.addActionListener(new ActionListener()
215 public void actionPerformed(ActionEvent e)
217 outputText_actionPerformed(e);
221 outputMenu.add(item);
225 * Build menus for annotation types that may be shown or hidden, and for
226 * 'reference annotations' that may be added to the alignment. First for the
227 * currently selected sequence (if there is one):
229 final List<SequenceI> selectedSequence = (seq == null
230 ? Collections.<SequenceI> emptyList()
231 : Arrays.asList(seq));
232 buildAnnotationTypesMenus(seqShowAnnotationsMenu,
233 seqHideAnnotationsMenu, selectedSequence);
234 configureReferenceAnnotationsMenu(seqAddReferenceAnnotations,
238 * And repeat for the current selection group (if there is one):
240 final List<SequenceI> selectedGroup = (ap.av.getSelectionGroup() == null
241 ? Collections.<SequenceI> emptyList()
242 : ap.av.getSelectionGroup().getSequences());
243 buildAnnotationTypesMenus(groupShowAnnotationsMenu,
244 groupHideAnnotationsMenu, selectedGroup);
245 configureReferenceAnnotationsMenu(groupAddReferenceAnnotations,
251 } catch (Exception e)
259 sequenceMenu.setText(sequence.getName());
260 if (seq == ap.av.getAlignment().getSeqrep())
262 makeReferenceSeq.setText(
263 MessageManager.getString("action.unmark_as_reference"));
267 makeReferenceSeq.setText(
268 MessageManager.getString("action.set_as_reference"));
271 if (!ap.av.getAlignment().isNucleotide())
273 remove(rnaStructureMenu);
277 int origCount = rnaStructureMenu.getItemCount();
279 * add menu items to 2D-render any alignment or sequence secondary
280 * structure annotation
282 AlignmentAnnotation[] aas = ap.av.getAlignment()
283 .getAlignmentAnnotation();
286 for (final AlignmentAnnotation aa : aas)
288 if (aa.isValidStruc() && aa.sequenceRef == null)
291 * valid alignment RNA secondary structure annotation
293 menuItem = new JMenuItem();
294 menuItem.setText(MessageManager.formatMessage(
295 "label.2d_rna_structure_line", new Object[]
297 menuItem.addActionListener(new ActionListener()
300 public void actionPerformed(ActionEvent e)
302 new AppVarna(seq, aa, ap);
305 rnaStructureMenu.add(menuItem);
310 if (seq.getAnnotation() != null)
312 AlignmentAnnotation seqAnns[] = seq.getAnnotation();
313 for (final AlignmentAnnotation aa : seqAnns)
315 if (aa.isValidStruc())
318 * valid sequence RNA secondary structure annotation
320 // TODO: make rnastrucF a bit more nice
321 menuItem = new JMenuItem();
322 menuItem.setText(MessageManager.formatMessage(
323 "label.2d_rna_sequence_name", new Object[]
325 menuItem.addActionListener(new ActionListener()
328 public void actionPerformed(ActionEvent e)
330 // TODO: VARNA does'nt print gaps in the sequence
331 new AppVarna(seq, aa, ap);
334 rnaStructureMenu.add(menuItem);
338 if (rnaStructureMenu.getItemCount() == origCount)
340 remove(rnaStructureMenu);
344 menuItem = new JMenuItem(
345 MessageManager.getString("action.hide_sequences"));
346 menuItem.addActionListener(new ActionListener()
349 public void actionPerformed(ActionEvent e)
351 hideSequences(false);
356 if (ap.av.getSelectionGroup() != null
357 && ap.av.getSelectionGroup().getSize() > 1)
359 menuItem = new JMenuItem(MessageManager
360 .formatMessage("label.represent_group_with", new Object[]
362 menuItem.addActionListener(new ActionListener()
365 public void actionPerformed(ActionEvent e)
370 sequenceMenu.add(menuItem);
373 if (ap.av.hasHiddenRows())
375 final int index = ap.av.getAlignment().findIndex(seq);
377 if (ap.av.adjustForHiddenSeqs(index)
378 - ap.av.adjustForHiddenSeqs(index - 1) > 1)
380 menuItem = new JMenuItem(
381 MessageManager.getString("action.reveal_sequences"));
382 menuItem.addActionListener(new ActionListener()
385 public void actionPerformed(ActionEvent e)
387 ap.av.showSequence(index);
388 if (ap.overviewPanel != null)
390 ap.overviewPanel.updateOverviewImage();
398 // for the case when no sequences are even visible
399 if (ap.av.hasHiddenRows())
402 menuItem = new JMenuItem(
403 MessageManager.getString("action.reveal_all"));
404 menuItem.addActionListener(new ActionListener()
407 public void actionPerformed(ActionEvent e)
409 ap.av.showAllHiddenSeqs();
410 if (ap.overviewPanel != null)
412 ap.overviewPanel.updateOverviewImage();
421 SequenceGroup sg = ap.av.getSelectionGroup();
422 boolean isDefinedGroup = (sg != null)
423 ? ap.av.getAlignment().getGroups().contains(sg)
426 if (sg != null && sg.getSize() > 0)
428 groupName.setText(MessageManager
429 .getString("label.edit_name_and_description_current_group"));
431 ColourMenuHelper.setColourSelected(colourMenu, sg.getColourScheme());
433 conservationMenuItem.setEnabled(!sg.isNucleotide());
437 if (sg.cs.conservationApplied())
439 conservationMenuItem.setSelected(true);
441 if (sg.cs.getThreshold() > 0)
443 abovePIDColour.setSelected(true);
446 modifyConservation.setEnabled(conservationMenuItem.isSelected());
447 modifyPID.setEnabled(abovePIDColour.isSelected());
448 displayNonconserved.setSelected(sg.getShowNonconserved());
449 showText.setSelected(sg.getDisplayText());
450 showColourText.setSelected(sg.getColourText());
451 showBoxes.setSelected(sg.getDisplayBoxes());
452 // add any groupURLs to the groupURL submenu and make it visible
453 if (groupLinks != null && groupLinks.size() > 0)
455 buildGroupURLMenu(sg, groupLinks);
457 // Add a 'show all structures' for the current selection
458 Hashtable<String, PDBEntry> pdbe = new Hashtable<>(), reppdb = new Hashtable<>();
460 SequenceI sqass = null;
461 for (SequenceI sq : ap.av.getSequenceSelection())
463 Vector<PDBEntry> pes = sq.getDatasetSequence().getAllPDBEntries();
464 if (pes != null && pes.size() > 0)
466 reppdb.put(pes.get(0).getId(), pes.get(0));
467 for (PDBEntry pe : pes)
469 pdbe.put(pe.getId(), pe);
479 final PDBEntry[] pe = pdbe.values()
480 .toArray(new PDBEntry[pdbe.size()]),
481 pr = reppdb.values().toArray(new PDBEntry[reppdb.size()]);
482 final JMenuItem gpdbview, rpdbview;
487 groupMenu.setVisible(false);
488 editMenu.setVisible(false);
493 createGroupMenuItem.setVisible(true);
494 unGroupMenuItem.setVisible(false);
495 jMenu1.setText(MessageManager.getString("action.edit_new_group"));
499 createGroupMenuItem.setVisible(false);
500 unGroupMenuItem.setVisible(true);
501 jMenu1.setText(MessageManager.getString("action.edit_group"));
506 sequenceMenu.setVisible(false);
507 pdbStructureDialog.setVisible(false);
508 rnaStructureMenu.setVisible(false);
511 if (links != null && links.size() > 0)
513 addFeatureLinks(seq, links);
518 * Adds a 'Link' menu item with a sub-menu item for each hyperlink provided.
523 void addFeatureLinks(final SequenceI seq, List<String> links)
525 JMenu linkMenu = new JMenu(MessageManager.getString("action.link"));
526 Map<String, List<String>> linkset = new LinkedHashMap<>();
528 for (String link : links)
530 UrlLink urlLink = null;
533 urlLink = new UrlLink(link);
534 } catch (Exception foo)
536 Cache.log.error("Exception for URLLink '" + link + "'", foo);
540 if (!urlLink.isValid())
542 Cache.log.error(urlLink.getInvalidMessage());
546 urlLink.createLinksFromSeq(seq, linkset);
549 addshowLinks(linkMenu, linkset.values());
551 // disable link menu if there are no valid entries
552 if (linkMenu.getItemCount() > 0)
554 linkMenu.setEnabled(true);
558 linkMenu.setEnabled(false);
561 if (sequence != null)
563 sequenceMenu.add(linkMenu);
573 * Add annotation types to 'Show annotations' and/or 'Hide annotations' menus.
574 * "All" is added first, followed by a separator. Then add any annotation
575 * types associated with the current selection. Separate menus are built for
576 * the selected sequence group (if any), and the selected sequence.
578 * Some annotation rows are always rendered together - these can be identified
579 * by a common graphGroup property > -1. Only one of each group will be marked
580 * as visible (to avoid duplication of the display). For such groups we add a
581 * composite type name, e.g.
583 * IUPredWS (Long), IUPredWS (Short)
587 protected void buildAnnotationTypesMenus(JMenu showMenu, JMenu hideMenu,
588 List<SequenceI> forSequences)
590 showMenu.removeAll();
591 hideMenu.removeAll();
593 final List<String> all = Arrays
595 { MessageManager.getString("label.all") });
596 addAnnotationTypeToShowHide(showMenu, forSequences, "", all, true,
598 addAnnotationTypeToShowHide(hideMenu, forSequences, "", all, true,
600 showMenu.addSeparator();
601 hideMenu.addSeparator();
603 final AlignmentAnnotation[] annotations = ap.getAlignment()
604 .getAlignmentAnnotation();
607 * Find shown/hidden annotations types, distinguished by source (calcId),
608 * and grouped by graphGroup. Using LinkedHashMap means we will retrieve in
609 * the insertion order, which is the order of the annotations on the
612 Map<String, List<List<String>>> shownTypes = new LinkedHashMap<>();
613 Map<String, List<List<String>>> hiddenTypes = new LinkedHashMap<>();
614 AlignmentAnnotationUtils.getShownHiddenTypes(shownTypes, hiddenTypes,
615 AlignmentAnnotationUtils.asList(annotations), forSequences);
617 for (String calcId : hiddenTypes.keySet())
619 for (List<String> type : hiddenTypes.get(calcId))
621 addAnnotationTypeToShowHide(showMenu, forSequences, calcId, type,
625 // grey out 'show annotations' if none are hidden
626 showMenu.setEnabled(!hiddenTypes.isEmpty());
628 for (String calcId : shownTypes.keySet())
630 for (List<String> type : shownTypes.get(calcId))
632 addAnnotationTypeToShowHide(hideMenu, forSequences, calcId, type,
636 // grey out 'hide annotations' if none are shown
637 hideMenu.setEnabled(!shownTypes.isEmpty());
641 * Returns a list of sequences - either the current selection group (if there
642 * is one), else the specified single sequence.
647 protected List<SequenceI> getSequenceScope(SequenceI seq)
649 List<SequenceI> forSequences = null;
650 final SequenceGroup selectionGroup = ap.av.getSelectionGroup();
651 if (selectionGroup != null && selectionGroup.getSize() > 0)
653 forSequences = selectionGroup.getSequences();
657 forSequences = seq == null ? Collections.<SequenceI> emptyList()
658 : Arrays.asList(seq);
664 * Add one annotation type to the 'Show Annotations' or 'Hide Annotations'
667 * @param showOrHideMenu
669 * @param forSequences
670 * the sequences whose annotations may be shown or hidden
675 * if true this is a special label meaning 'All'
676 * @param actionIsShow
677 * if true, the select menu item action is to show the annotation
680 protected void addAnnotationTypeToShowHide(JMenu showOrHideMenu,
681 final List<SequenceI> forSequences, String calcId,
682 final List<String> types, final boolean allTypes,
683 final boolean actionIsShow)
685 String label = types.toString(); // [a, b, c]
686 label = label.substring(1, label.length() - 1); // a, b, c
687 final JMenuItem item = new JMenuItem(label);
688 item.setToolTipText(calcId);
689 item.addActionListener(new ActionListener()
692 public void actionPerformed(ActionEvent e)
694 AlignmentUtils.showOrHideSequenceAnnotations(ap.getAlignment(),
695 types, forSequences, allTypes, actionIsShow);
699 showOrHideMenu.add(item);
702 private void buildGroupURLMenu(SequenceGroup sg, List<String> groupLinks)
705 // TODO: usability: thread off the generation of group url content so root
707 // sequence only URLs
708 // ID/regex match URLs
709 groupLinksMenu = new JMenu(
710 MessageManager.getString("action.group_link"));
711 // three types of url that might be created.
712 JMenu[] linkMenus = new JMenu[] { null,
713 new JMenu(MessageManager.getString("action.ids")),
714 new JMenu(MessageManager.getString("action.sequences")),
715 new JMenu(MessageManager.getString("action.ids_sequences")) };
717 SequenceI[] seqs = ap.av.getSelectionAsNewSequence();
718 String[][] idandseqs = GroupUrlLink.formStrings(seqs);
719 Hashtable<String, Object[]> commonDbrefs = new Hashtable<>();
720 for (int sq = 0; sq < seqs.length; sq++)
723 int start = seqs[sq].findPosition(sg.getStartRes()),
724 end = seqs[sq].findPosition(sg.getEndRes());
725 // just collect ids from dataset sequence
726 // TODO: check if IDs collected from selecton group intersects with the
727 // current selection, too
728 SequenceI sqi = seqs[sq];
729 while (sqi.getDatasetSequence() != null)
731 sqi = sqi.getDatasetSequence();
733 DBRefEntry[] dbr = sqi.getDBRefs();
734 if (dbr != null && dbr.length > 0)
736 for (int d = 0; d < dbr.length; d++)
738 String src = dbr[d].getSource(); // jalview.util.DBRefUtils.getCanonicalName(dbr[d].getSource()).toUpperCase();
739 Object[] sarray = commonDbrefs.get(src);
742 sarray = new Object[2];
743 sarray[0] = new int[] { 0 };
744 sarray[1] = new String[seqs.length];
746 commonDbrefs.put(src, sarray);
749 if (((String[]) sarray[1])[sq] == null)
751 if (!dbr[d].hasMap() || (dbr[d].getMap()
752 .locateMappedRange(start, end) != null))
754 ((String[]) sarray[1])[sq] = dbr[d].getAccessionId();
755 ((int[]) sarray[0])[0]++;
761 // now create group links for all distinct ID/sequence sets.
762 boolean addMenu = false; // indicates if there are any group links to give
764 for (String link : groupLinks)
766 GroupUrlLink urlLink = null;
769 urlLink = new GroupUrlLink(link);
770 } catch (Exception foo)
772 Cache.log.error("Exception for GroupURLLink '" + link + "'", foo);
776 if (!urlLink.isValid())
778 Cache.log.error(urlLink.getInvalidMessage());
781 final String label = urlLink.getLabel();
782 boolean usingNames = false;
783 // Now see which parts of the group apply for this URL
784 String ltarget = urlLink.getTarget(); // jalview.util.DBRefUtils.getCanonicalName(urlLink.getTarget());
785 Object[] idset = commonDbrefs.get(ltarget.toUpperCase());
786 String[] seqstr, ids; // input to makeUrl
789 int numinput = ((int[]) idset[0])[0];
790 String[] allids = ((String[]) idset[1]);
791 seqstr = new String[numinput];
792 ids = new String[numinput];
793 for (int sq = 0, idcount = 0; sq < seqs.length; sq++)
795 if (allids[sq] != null)
797 ids[idcount] = allids[sq];
798 seqstr[idcount++] = idandseqs[1][sq];
804 // just use the id/seq set
805 seqstr = idandseqs[1];
809 // and try and make the groupURL!
811 Object[] urlset = null;
814 urlset = urlLink.makeUrlStubs(ids, seqstr,
815 "FromJalview" + System.currentTimeMillis(), false);
816 } catch (UrlStringTooLongException e)
821 int type = urlLink.getGroupURLType() & 3;
822 // first two bits ofurlLink type bitfield are sequenceids and sequences
823 // TODO: FUTURE: ensure the groupURL menu structure can be generalised
824 addshowLink(linkMenus[type],
825 label + (((type & 1) == 1)
826 ? ("(" + (usingNames ? "Names" : ltarget) + ")")
834 groupLinksMenu = new JMenu(
835 MessageManager.getString("action.group_link"));
836 for (int m = 0; m < linkMenus.length; m++)
838 if (linkMenus[m] != null
839 && linkMenus[m].getMenuComponentCount() > 0)
841 groupLinksMenu.add(linkMenus[m]);
845 groupMenu.add(groupLinksMenu);
849 private void addshowLinks(JMenu linkMenu,
850 Collection<List<String>> linkset)
852 for (List<String> linkstrset : linkset)
854 // split linkstr into label and url
855 addshowLink(linkMenu, linkstrset.get(1), linkstrset.get(3));
860 * add a show URL menu item to the given linkMenu
864 * - menu label string
868 private void addshowLink(JMenu linkMenu, String label, final String url)
870 JMenuItem item = new JMenuItem(label);
871 item.setToolTipText(MessageManager.formatMessage("label.open_url_param",
874 item.addActionListener(new ActionListener()
877 public void actionPerformed(ActionEvent e)
879 new Thread(new Runnable()
896 * add a late bound groupURL item to the given linkMenu
900 * - menu label string
901 * @param urlgenerator
902 * GroupURLLink used to generate URL
904 * Object array returned from the makeUrlStubs function.
906 private void addshowLink(JMenu linkMenu, String label,
907 final GroupUrlLink urlgenerator, final Object[] urlstub)
909 JMenuItem item = new JMenuItem(label);
910 item.setToolTipText(MessageManager
911 .formatMessage("label.open_url_seqs_param", new Object[]
912 { urlgenerator.getUrl_prefix(),
913 urlgenerator.getNumberInvolved(urlstub) }));
914 // TODO: put in info about what is being sent.
915 item.addActionListener(new ActionListener()
918 public void actionPerformed(ActionEvent e)
920 new Thread(new Runnable()
928 showLink(urlgenerator.constructFrom(urlstub));
929 } catch (UrlStringTooLongException e2)
947 private void jbInit() throws Exception
949 groupMenu.setText(MessageManager.getString("label.selection"));
950 groupName.setText(MessageManager.getString("label.name"));
951 groupName.addActionListener(new ActionListener()
954 public void actionPerformed(ActionEvent e)
956 groupName_actionPerformed();
959 sequenceMenu.setText(MessageManager.getString("label.sequence"));
960 sequenceName.setText(
961 MessageManager.getString("label.edit_name_description"));
962 sequenceName.addActionListener(new ActionListener()
965 public void actionPerformed(ActionEvent e)
967 sequenceName_actionPerformed();
971 .setText(MessageManager.getString("action.choose_annotations"));
972 chooseAnnotations.addActionListener(new ActionListener()
975 public void actionPerformed(ActionEvent e)
977 chooseAnnotations_actionPerformed(e);
981 .setText(MessageManager.getString("label.sequence_details"));
982 sequenceDetails.addActionListener(new ActionListener()
985 public void actionPerformed(ActionEvent e)
987 sequenceDetails_actionPerformed();
991 .setText(MessageManager.getString("label.sequence_details"));
992 sequenceSelDetails.addActionListener(new ActionListener()
995 public void actionPerformed(ActionEvent e)
997 sequenceSelectionDetails_actionPerformed();
1002 .setText(MessageManager.getString("action.remove_group"));
1003 unGroupMenuItem.addActionListener(new ActionListener()
1006 public void actionPerformed(ActionEvent e)
1008 unGroupMenuItem_actionPerformed();
1012 .setText(MessageManager.getString("action.create_group"));
1013 createGroupMenuItem.addActionListener(new ActionListener()
1016 public void actionPerformed(ActionEvent e)
1018 createGroupMenuItem_actionPerformed();
1022 outline.setText(MessageManager.getString("action.border_colour"));
1023 outline.addActionListener(new ActionListener()
1026 public void actionPerformed(ActionEvent e)
1028 outline_actionPerformed();
1031 showBoxes.setText(MessageManager.getString("action.boxes"));
1032 showBoxes.setState(true);
1033 showBoxes.addActionListener(new ActionListener()
1036 public void actionPerformed(ActionEvent e)
1038 showBoxes_actionPerformed();
1041 showText.setText(MessageManager.getString("action.text"));
1042 showText.setState(true);
1043 showText.addActionListener(new ActionListener()
1046 public void actionPerformed(ActionEvent e)
1048 showText_actionPerformed();
1051 showColourText.setText(MessageManager.getString("label.colour_text"));
1052 showColourText.addActionListener(new ActionListener()
1055 public void actionPerformed(ActionEvent e)
1057 showColourText_actionPerformed();
1061 .setText(MessageManager.getString("label.show_non_conserved"));
1062 displayNonconserved.setState(true);
1063 displayNonconserved.addActionListener(new ActionListener()
1066 public void actionPerformed(ActionEvent e)
1068 showNonconserved_actionPerformed();
1071 editMenu.setText(MessageManager.getString("action.edit"));
1072 cut.setText(MessageManager.getString("action.cut"));
1073 cut.addActionListener(new ActionListener()
1076 public void actionPerformed(ActionEvent e)
1078 cut_actionPerformed();
1081 upperCase.setText(MessageManager.getString("label.to_upper_case"));
1082 upperCase.addActionListener(new ActionListener()
1085 public void actionPerformed(ActionEvent e)
1090 copy.setText(MessageManager.getString("action.copy"));
1091 copy.addActionListener(new ActionListener()
1094 public void actionPerformed(ActionEvent e)
1096 copy_actionPerformed();
1099 lowerCase.setText(MessageManager.getString("label.to_lower_case"));
1100 lowerCase.addActionListener(new ActionListener()
1103 public void actionPerformed(ActionEvent e)
1108 toggle.setText(MessageManager.getString("label.toggle_case"));
1109 toggle.addActionListener(new ActionListener()
1112 public void actionPerformed(ActionEvent e)
1118 MessageManager.getString("label.out_to_textbox") + "...");
1119 seqShowAnnotationsMenu
1120 .setText(MessageManager.getString("label.show_annotations"));
1121 seqHideAnnotationsMenu
1122 .setText(MessageManager.getString("label.hide_annotations"));
1123 groupShowAnnotationsMenu
1124 .setText(MessageManager.getString("label.show_annotations"));
1125 groupHideAnnotationsMenu
1126 .setText(MessageManager.getString("label.hide_annotations"));
1127 sequenceFeature.setText(
1128 MessageManager.getString("label.create_sequence_feature"));
1129 sequenceFeature.addActionListener(new ActionListener()
1132 public void actionPerformed(ActionEvent e)
1134 sequenceFeature_actionPerformed();
1137 jMenu1.setText(MessageManager.getString("label.group"));
1138 pdbStructureDialog.setText(
1139 MessageManager.getString("label.show_pdbstruct_dialog"));
1140 pdbStructureDialog.addActionListener(new ActionListener()
1143 public void actionPerformed(ActionEvent actionEvent)
1145 SequenceI[] selectedSeqs = new SequenceI[] { sequence };
1146 if (ap.av.getSelectionGroup() != null)
1148 selectedSeqs = ap.av.getSequenceSelection();
1150 new StructureChooser(selectedSeqs, sequence, ap);
1155 .setText(MessageManager.getString("label.view_rna_structure"));
1157 // colStructureMenu.setText("Colour By Structure");
1158 editSequence.setText(
1159 MessageManager.getString("label.edit_sequence") + "...");
1160 editSequence.addActionListener(new ActionListener()
1163 public void actionPerformed(ActionEvent actionEvent)
1165 editSequence_actionPerformed(actionEvent);
1168 makeReferenceSeq.setText(
1169 MessageManager.getString("label.mark_as_representative"));
1170 makeReferenceSeq.addActionListener(new ActionListener()
1174 public void actionPerformed(ActionEvent actionEvent)
1176 makeReferenceSeq_actionPerformed(actionEvent);
1181 .setText(MessageManager.getString("label.hide_insertions"));
1182 hideInsertions.addActionListener(new ActionListener()
1186 public void actionPerformed(ActionEvent e)
1188 hideInsertions_actionPerformed(e);
1192 groupMenu.add(sequenceSelDetails);
1195 add(rnaStructureMenu);
1196 add(pdbStructureDialog);
1197 if (sequence != null)
1199 add(hideInsertions);
1201 // annotations configuration panel suppressed for now
1202 // groupMenu.add(chooseAnnotations);
1205 * Add show/hide annotations to the Sequence menu, and to the Selection menu
1206 * (if a selection group is in force).
1208 sequenceMenu.add(seqShowAnnotationsMenu);
1209 sequenceMenu.add(seqHideAnnotationsMenu);
1210 sequenceMenu.add(seqAddReferenceAnnotations);
1211 groupMenu.add(groupShowAnnotationsMenu);
1212 groupMenu.add(groupHideAnnotationsMenu);
1213 groupMenu.add(groupAddReferenceAnnotations);
1214 groupMenu.add(editMenu);
1215 groupMenu.add(outputMenu);
1216 groupMenu.add(sequenceFeature);
1217 groupMenu.add(createGroupMenuItem);
1218 groupMenu.add(unGroupMenuItem);
1219 groupMenu.add(jMenu1);
1220 sequenceMenu.add(sequenceName);
1221 sequenceMenu.add(sequenceDetails);
1222 sequenceMenu.add(makeReferenceSeq);
1229 editMenu.add(editSequence);
1230 editMenu.add(upperCase);
1231 editMenu.add(lowerCase);
1232 editMenu.add(toggle);
1233 // JBPNote: These shouldn't be added here - should appear in a generic
1234 // 'apply web service to this sequence menu'
1235 // pdbMenu.add(RNAFold);
1236 // pdbMenu.add(ContraFold);
1237 jMenu1.add(groupName);
1238 jMenu1.add(colourMenu);
1239 jMenu1.add(showBoxes);
1240 jMenu1.add(showText);
1241 jMenu1.add(showColourText);
1242 jMenu1.add(outline);
1243 jMenu1.add(displayNonconserved);
1247 * Constructs the entries for the colour menu
1249 protected void initColourMenu()
1251 colourMenu.setText(MessageManager.getString("label.group_colour"));
1252 textColour.setText(MessageManager.getString("label.text_colour"));
1253 textColour.addActionListener(new ActionListener()
1256 public void actionPerformed(ActionEvent e)
1258 textColour_actionPerformed();
1262 abovePIDColour.setText(
1263 MessageManager.getString("label.above_identity_threshold"));
1264 abovePIDColour.addActionListener(new ActionListener()
1267 public void actionPerformed(ActionEvent e)
1269 abovePIDColour_actionPerformed(abovePIDColour.isSelected());
1274 MessageManager.getString("label.modify_identity_threshold"));
1275 modifyPID.addActionListener(new ActionListener()
1278 public void actionPerformed(ActionEvent e)
1280 modifyPID_actionPerformed();
1284 conservationMenuItem
1285 .setText(MessageManager.getString("action.by_conservation"));
1286 conservationMenuItem.addActionListener(new ActionListener()
1289 public void actionPerformed(ActionEvent e)
1291 conservationMenuItem_actionPerformed(
1292 conservationMenuItem.isSelected());
1296 modifyConservation.setText(MessageManager
1297 .getString("label.modify_conservation_threshold"));
1298 modifyConservation.addActionListener(new ActionListener()
1301 public void actionPerformed(ActionEvent e)
1303 modifyConservation_actionPerformed();
1309 * Builds the group colour sub-menu, including any user-defined colours which
1310 * were loaded at startup or during the Jalview session
1312 protected void buildColourMenu()
1314 SequenceGroup sg = ap.av.getSelectionGroup();
1318 * popup menu with no sequence group scope
1322 colourMenu.removeAll();
1323 colourMenu.add(textColour);
1324 colourMenu.addSeparator();
1326 ColourMenuHelper.addMenuItems(colourMenu, this, sg, false);
1328 colourMenu.addSeparator();
1329 colourMenu.add(conservationMenuItem);
1330 colourMenu.add(modifyConservation);
1331 colourMenu.add(abovePIDColour);
1332 colourMenu.add(modifyPID);
1335 protected void modifyConservation_actionPerformed()
1337 SequenceGroup sg = getGroup();
1340 SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
1341 SliderPanel.showConservationSlider();
1345 protected void modifyPID_actionPerformed()
1347 SequenceGroup sg = getGroup();
1350 // int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
1352 // sg.cs.setThreshold(threshold, ap.av.isIgnoreGapsConsensus());
1353 SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup().getName());
1354 SliderPanel.showPIDSlider();
1359 * Check for any annotations on the underlying dataset sequences (for the
1360 * current selection group) which are not 'on the alignment'.If any are found,
1361 * enable the option to add them to the alignment. The criteria for 'on the
1362 * alignment' is finding an alignment annotation on the alignment, matched on
1363 * calcId, label and sequenceRef.
1365 * A tooltip is also constructed that displays the source (calcId) and type
1366 * (label) of the annotations that can be added.
1369 * @param forSequences
1371 protected void configureReferenceAnnotationsMenu(JMenuItem menuItem,
1372 List<SequenceI> forSequences)
1374 menuItem.setEnabled(false);
1377 * Temporary store to hold distinct calcId / type pairs for the tooltip.
1378 * Using TreeMap means calcIds are shown in alphabetical order.
1380 SortedMap<String, String> tipEntries = new TreeMap<>();
1381 final Map<SequenceI, List<AlignmentAnnotation>> candidates = new LinkedHashMap<>();
1382 AlignmentI al = this.ap.av.getAlignment();
1383 AlignmentUtils.findAddableReferenceAnnotations(forSequences, tipEntries,
1385 if (!candidates.isEmpty())
1387 StringBuilder tooltip = new StringBuilder(64);
1388 tooltip.append(MessageManager.getString("label.add_annotations_for"));
1391 * Found annotations that could be added. Enable the menu item, and
1392 * configure its tooltip and action.
1394 menuItem.setEnabled(true);
1395 for (String calcId : tipEntries.keySet())
1397 tooltip.append("<br/>" + calcId + "/" + tipEntries.get(calcId));
1399 String tooltipText = JvSwingUtils.wrapTooltip(true,
1400 tooltip.toString());
1401 menuItem.setToolTipText(tooltipText);
1403 menuItem.addActionListener(new ActionListener()
1406 public void actionPerformed(ActionEvent e)
1408 addReferenceAnnotations_actionPerformed(candidates);
1415 * Add annotations to the sequences and to the alignment.
1418 * a map whose keys are sequences on the alignment, and values a list
1419 * of annotations to add to each sequence
1421 protected void addReferenceAnnotations_actionPerformed(
1422 Map<SequenceI, List<AlignmentAnnotation>> candidates)
1424 final SequenceGroup selectionGroup = this.ap.av.getSelectionGroup();
1425 final AlignmentI alignment = this.ap.getAlignment();
1426 AlignmentUtils.addReferenceAnnotations(candidates, alignment,
1431 protected void makeReferenceSeq_actionPerformed(ActionEvent actionEvent)
1433 if (!ap.av.getAlignment().hasSeqrep())
1435 // initialise the display flags so the user sees something happen
1436 ap.av.setDisplayReferenceSeq(true);
1437 ap.av.setColourByReferenceSeq(true);
1438 ap.av.getAlignment().setSeqrep(sequence);
1442 if (ap.av.getAlignment().getSeqrep() == sequence)
1444 ap.av.getAlignment().setSeqrep(null);
1448 ap.av.getAlignment().setSeqrep(sequence);
1454 protected void hideInsertions_actionPerformed(ActionEvent actionEvent)
1457 HiddenColumns hidden = new HiddenColumns();
1458 BitSet inserts = new BitSet(), mask = new BitSet();
1460 // set mask to preserve existing hidden columns outside selected group
1461 if (ap.av.hasHiddenColumns())
1463 ap.av.getAlignment().getHiddenColumns().markHiddenRegions(mask);
1466 boolean markedPopup = false;
1467 // mark inserts in current selection
1468 if (ap.av.getSelectionGroup() != null)
1470 // mark just the columns in the selection group to be hidden
1471 inserts.set(ap.av.getSelectionGroup().getStartRes(),
1472 ap.av.getSelectionGroup().getEndRes() + 1);
1474 // and clear that part of the mask
1475 mask.andNot(inserts);
1477 // now clear columns without gaps
1478 for (SequenceI sq : ap.av.getSelectionGroup().getSequences())
1484 inserts.and(sq.getInsertionsAsBits());
1489 // initially, mark all columns to be hidden
1490 inserts.set(0, ap.av.getAlignment().getWidth());
1492 // and clear out old hidden regions completely
1496 // now mark for sequence under popup if we haven't already done it
1497 if (!markedPopup && sequence != null)
1499 inserts.and(sequence.getInsertionsAsBits());
1502 // finally, preserve hidden regions outside selection
1505 // and set hidden columns accordingly
1506 hidden.hideMarkedBits(inserts);
1508 ap.av.getAlignment().setHiddenColumns(hidden);
1512 protected void sequenceSelectionDetails_actionPerformed()
1514 createSequenceDetailsReport(ap.av.getSequenceSelection());
1517 protected void sequenceDetails_actionPerformed()
1519 createSequenceDetailsReport(new SequenceI[] { sequence });
1522 public void createSequenceDetailsReport(SequenceI[] sequences)
1524 CutAndPasteHtmlTransfer cap = new CutAndPasteHtmlTransfer();
1525 StringBuilder contents = new StringBuilder(128);
1526 for (SequenceI seq : sequences)
1528 contents.append("<p><h2>" + MessageManager.formatMessage(
1529 "label.create_sequence_details_report_annotation_for",
1531 { seq.getDisplayId(true) }) + "</h2></p><p>");
1532 new SequenceAnnotationReport(null).createSequenceAnnotationReport(
1533 contents, seq, true, true,
1534 (ap.getSeqPanel().seqCanvas.fr != null)
1535 ? ap.getSeqPanel().seqCanvas.fr.getMinMax()
1537 contents.append("</p>");
1539 cap.setText("<html>" + contents.toString() + "</html>");
1541 Desktop.addInternalFrame(cap,
1542 MessageManager.formatMessage("label.sequence_details_for",
1543 (sequences.length == 1 ? new Object[]
1544 { sequences[0].getDisplayId(true) }
1547 .getString("label.selection") })),
1552 protected void showNonconserved_actionPerformed()
1554 getGroup().setShowNonconserved(displayNonconserved.isSelected());
1559 * call to refresh view after settings change
1563 ap.updateAnnotation();
1564 // removed paintAlignment(true) here:
1565 // updateAnnotation calls paintAlignment already, so don't need to call
1568 PaintRefresher.Refresh(this, ap.av.getSequenceSetId());
1572 * protected void covariationColour_actionPerformed() { getGroup().cs = new
1573 * CovariationColourScheme(sequence.getAnnotation()[0]); refresh(); }
1583 public void abovePIDColour_actionPerformed(boolean selected)
1585 SequenceGroup sg = getGroup();
1593 sg.cs.setConsensus(AAFrequency.calculate(
1594 sg.getSequences(ap.av.getHiddenRepSequences()),
1595 sg.getStartRes(), sg.getEndRes() + 1));
1597 int threshold = SliderPanel.setPIDSliderSource(ap,
1598 sg.getGroupColourScheme(), getGroup().getName());
1600 sg.cs.setThreshold(threshold, ap.av.isIgnoreGapsConsensus());
1602 SliderPanel.showPIDSlider();
1605 // remove PIDColouring
1607 sg.cs.setThreshold(0, ap.av.isIgnoreGapsConsensus());
1608 SliderPanel.hidePIDSlider();
1610 modifyPID.setEnabled(selected);
1616 * Open a panel where the user can choose which types of sequence annotation
1621 protected void chooseAnnotations_actionPerformed(ActionEvent e)
1623 // todo correct way to guard against opening a duplicate panel?
1624 new AnnotationChooser(ap);
1633 public void conservationMenuItem_actionPerformed(boolean selected)
1635 SequenceGroup sg = getGroup();
1643 // JBPNote: Conservation name shouldn't be i18n translated
1644 Conservation c = new Conservation("Group",
1645 sg.getSequences(ap.av.getHiddenRepSequences()),
1646 sg.getStartRes(), sg.getEndRes() + 1);
1649 c.verdict(false, ap.av.getConsPercGaps());
1650 sg.cs.setConservation(c);
1652 SliderPanel.setConservationSlider(ap, sg.getGroupColourScheme(),
1654 SliderPanel.showConservationSlider();
1657 // remove ConservationColouring
1659 sg.cs.setConservation(null);
1660 SliderPanel.hideConservationSlider();
1662 modifyConservation.setEnabled(selected);
1673 protected void groupName_actionPerformed()
1676 SequenceGroup sg = getGroup();
1677 EditNameDialog dialog = new EditNameDialog(sg.getName(),
1678 sg.getDescription(),
1679 " " + MessageManager.getString("label.group_name") + " ",
1680 MessageManager.getString("label.group_description") + " ",
1681 MessageManager.getString("label.edit_group_name_description"),
1689 sg.setName(dialog.getName());
1690 sg.setDescription(dialog.getDescription());
1695 * Get selection group - adding it to the alignment if necessary.
1697 * @return sequence group to operate on
1699 SequenceGroup getGroup()
1701 SequenceGroup sg = ap.av.getSelectionGroup();
1702 // this method won't add a new group if it already exists
1705 ap.av.getAlignment().addGroup(sg);
1717 void sequenceName_actionPerformed()
1719 EditNameDialog dialog = new EditNameDialog(sequence.getName(),
1720 sequence.getDescription(),
1721 " " + MessageManager.getString("label.sequence_name")
1723 MessageManager.getString("label.sequence_description") + " ",
1724 MessageManager.getString(
1725 "label.edit_sequence_name_description"),
1733 if (dialog.getName() != null)
1735 if (dialog.getName().indexOf(" ") > -1)
1737 JvOptionPane.showMessageDialog(ap,
1739 .getString("label.spaces_converted_to_backslashes"),
1741 .getString("label.no_spaces_allowed_sequence_name"),
1742 JvOptionPane.WARNING_MESSAGE);
1745 sequence.setName(dialog.getName().replace(' ', '_'));
1746 ap.paintAlignment(false);
1749 sequence.setDescription(dialog.getDescription());
1751 ap.av.firePropertyChange("alignment", null,
1752 ap.av.getAlignment().getSequences());
1762 void unGroupMenuItem_actionPerformed()
1764 SequenceGroup sg = ap.av.getSelectionGroup();
1765 ap.av.getAlignment().deleteGroup(sg);
1766 ap.av.setSelectionGroup(null);
1770 void createGroupMenuItem_actionPerformed()
1772 getGroup(); // implicitly creates group - note - should apply defaults / use
1773 // standard alignment window logic for this
1783 protected void outline_actionPerformed()
1785 SequenceGroup sg = getGroup();
1786 Color col = JColorChooser.showDialog(this,
1787 MessageManager.getString("label.select_outline_colour"),
1792 sg.setOutlineColour(col);
1804 public void showBoxes_actionPerformed()
1806 getGroup().setDisplayBoxes(showBoxes.isSelected());
1816 public void showText_actionPerformed()
1818 getGroup().setDisplayText(showText.isSelected());
1828 public void showColourText_actionPerformed()
1830 getGroup().setColourText(showColourText.isSelected());
1834 public void showLink(String url)
1838 jalview.util.BrowserLauncher.openURL(url);
1839 } catch (Exception ex)
1841 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
1842 MessageManager.getString("label.web_browser_not_found_unix"),
1843 MessageManager.getString("label.web_browser_not_found"),
1844 JvOptionPane.WARNING_MESSAGE);
1846 ex.printStackTrace();
1850 void hideSequences(boolean representGroup)
1852 ap.av.hideSequences(sequence, representGroup);
1855 public void copy_actionPerformed()
1857 ap.alignFrame.copy_actionPerformed(null);
1860 public void cut_actionPerformed()
1862 ap.alignFrame.cut_actionPerformed(null);
1865 void changeCase(ActionEvent e)
1867 Object source = e.getSource();
1868 SequenceGroup sg = ap.av.getSelectionGroup();
1872 List<int[]> startEnd = ap.av.getVisibleRegionBoundaries(
1873 sg.getStartRes(), sg.getEndRes() + 1);
1878 if (source == toggle)
1880 description = MessageManager.getString("label.toggle_case");
1881 caseChange = ChangeCaseCommand.TOGGLE_CASE;
1883 else if (source == upperCase)
1885 description = MessageManager.getString("label.to_upper_case");
1886 caseChange = ChangeCaseCommand.TO_UPPER;
1890 description = MessageManager.getString("label.to_lower_case");
1891 caseChange = ChangeCaseCommand.TO_LOWER;
1894 ChangeCaseCommand caseCommand = new ChangeCaseCommand(description,
1895 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
1896 startEnd, caseChange);
1898 ap.alignFrame.addHistoryItem(caseCommand);
1900 ap.av.firePropertyChange("alignment", null,
1901 ap.av.getAlignment().getSequences());
1906 public void outputText_actionPerformed(ActionEvent e)
1908 CutAndPasteTransfer cap = new CutAndPasteTransfer();
1909 cap.setForInput(null);
1910 Desktop.addInternalFrame(cap, MessageManager
1911 .formatMessage("label.alignment_output_command", new Object[]
1912 { e.getActionCommand() }), 600, 500);
1914 String[] omitHidden = null;
1916 System.out.println("PROMPT USER HERE"); // TODO: decide if a prompt happens
1917 // or we simply trust the user wants
1918 // wysiwig behaviour
1920 FileFormatI fileFormat = FileFormats.getInstance()
1921 .forName(e.getActionCommand());
1923 new FormatAdapter(ap).formatSequences(fileFormat, ap, true));
1926 public void sequenceFeature_actionPerformed()
1928 SequenceGroup sg = ap.av.getSelectionGroup();
1934 List<SequenceI> seqs = new ArrayList<>();
1935 List<SequenceFeature> features = new ArrayList<>();
1938 * assemble dataset sequences, and template new sequence features,
1939 * for the amend features dialog
1941 int gSize = sg.getSize();
1942 for (int i = 0; i < gSize; i++)
1944 int start = sg.getSequenceAt(i).findPosition(sg.getStartRes());
1945 int end = sg.findEndRes(sg.getSequenceAt(i));
1948 seqs.add(sg.getSequenceAt(i).getDatasetSequence());
1949 features.add(new SequenceFeature(null, null, start, end, null));
1954 * an entirely gapped region will generate empty lists of sequence / features
1956 if (!seqs.isEmpty())
1958 if (ap.getSeqPanel().seqCanvas.getFeatureRenderer()
1959 .amendFeatures(seqs, features, true, ap))
1961 ap.alignFrame.setShowSeqFeatures(true);
1962 ap.av.setSearchResults(null); // clear highlighting
1963 ap.repaint(); // draw new/amended features
1968 public void textColour_actionPerformed()
1970 SequenceGroup sg = getGroup();
1973 new TextColourChooser().chooseColour(ap, sg);
1977 public void colourByStructure(String pdbid)
1979 Annotation[] anots = ap.av.getStructureSelectionManager()
1980 .colourSequenceFromStructure(sequence, pdbid);
1982 AlignmentAnnotation an = new AlignmentAnnotation("Structure",
1983 "Coloured by " + pdbid, anots);
1985 ap.av.getAlignment().addAnnotation(an);
1986 an.createSequenceMapping(sequence, 0, true);
1987 // an.adjustForAlignment();
1988 ap.av.getAlignment().setAnnotationIndex(an, 0);
1990 ap.adjustAnnotationHeight();
1992 sequence.addAlignmentAnnotation(an);
1996 public void editSequence_actionPerformed(ActionEvent actionEvent)
1998 SequenceGroup sg = ap.av.getSelectionGroup();
2002 if (sequence == null)
2004 sequence = sg.getSequenceAt(0);
2007 EditNameDialog dialog = new EditNameDialog(
2008 sequence.getSequenceAsString(sg.getStartRes(),
2009 sg.getEndRes() + 1),
2010 null, MessageManager.getString("label.edit_sequence"), null,
2011 MessageManager.getString("label.edit_sequence"),
2016 EditCommand editCommand = new EditCommand(
2017 MessageManager.getString("label.edit_sequences"),
2019 dialog.getName().replace(' ', ap.av.getGapCharacter()),
2020 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
2021 sg.getStartRes(), sg.getEndRes() + 1, ap.av.getAlignment());
2023 ap.alignFrame.addHistoryItem(editCommand);
2025 ap.av.firePropertyChange("alignment", null,
2026 ap.av.getAlignment().getSequences());
2032 * Action on user selecting an item from the colour menu (that does not have
2033 * its bespoke action handler)
2038 public void changeColour_actionPerformed(String colourSchemeName)
2040 SequenceGroup sg = getGroup();
2042 * switch to the chosen colour scheme (or null for None)
2044 ColourSchemeI colourScheme = ColourSchemes.getInstance()
2045 .getColourScheme(colourSchemeName, sg,
2046 ap.av.getHiddenRepSequences());
2047 sg.setColourScheme(colourScheme);
2048 if (colourScheme instanceof Blosum62ColourScheme
2049 || colourScheme instanceof PIDColourScheme)
2051 sg.cs.setConsensus(AAFrequency.calculate(
2052 sg.getSequences(ap.av.getHiddenRepSequences()),
2053 sg.getStartRes(), sg.getEndRes() + 1));