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();
162 JMenuItem textColour = new JMenuItem();
164 JMenu jMenu1 = new JMenu();
166 JMenuItem pdbStructureDialog = new JMenuItem();
168 JMenu rnaStructureMenu = new JMenu();
170 JMenuItem editSequence = new JMenuItem();
172 JMenu groupLinksMenu;
174 JMenuItem hideInsertions = new JMenuItem();
177 * Creates a new PopupMenu object.
184 public PopupMenu(final AlignmentPanel ap, Sequence seq,
187 this(ap, seq, links, null);
197 public PopupMenu(final AlignmentPanel ap, final SequenceI seq,
198 List<String> links, List<String> groupLinks)
200 // /////////////////////////////////////////////////////////
201 // If this is activated from the sequence panel, the user may want to
202 // edit or annotate a particular residue. Therefore display the residue menu
204 // If from the IDPanel, we must display the sequence menu
205 // ////////////////////////////////////////////////////////
209 for (String ff : FileFormats.getInstance().getWritableFormats(true))
211 JMenuItem item = new JMenuItem(ff);
213 item.addActionListener(new ActionListener()
216 public void actionPerformed(ActionEvent e)
218 outputText_actionPerformed(e);
222 outputMenu.add(item);
226 * Build menus for annotation types that may be shown or hidden, and for
227 * 'reference annotations' that may be added to the alignment. First for the
228 * currently selected sequence (if there is one):
230 final List<SequenceI> selectedSequence = (seq == null
231 ? Collections.<SequenceI> emptyList() : Arrays.asList(seq));
233 buildAnnotationTypesMenus(seqShowAnnotationsMenu,
234 seqHideAnnotationsMenu, selectedSequence);
235 configureReferenceAnnotationsMenu(seqAddReferenceAnnotations,
239 * And repeat for the current selection group (if there is one):
241 final List<SequenceI> selectedGroup = (ap.av.getSelectionGroup() == null
242 ? Collections.<SequenceI> emptyList()
243 : ap.av.getSelectionGroup().getSequences());
244 buildAnnotationTypesMenus(groupShowAnnotationsMenu,
245 groupHideAnnotationsMenu, selectedGroup);
246 configureReferenceAnnotationsMenu(groupAddReferenceAnnotations,
252 } catch (Exception e)
260 sequenceMenu.setText(sequence.getName());
261 if (seq == ap.av.getAlignment().getSeqrep())
263 makeReferenceSeq.setText(
264 MessageManager.getString("action.unmark_as_reference"));
268 makeReferenceSeq.setText(
269 MessageManager.getString("action.set_as_reference"));
272 if (!ap.av.getAlignment().isNucleotide())
274 remove(rnaStructureMenu);
278 int origCount = rnaStructureMenu.getItemCount();
280 * add menu items to 2D-render any alignment or sequence secondary
281 * structure annotation
283 AlignmentAnnotation[] aas = ap.av.getAlignment()
284 .getAlignmentAnnotation();
287 for (final AlignmentAnnotation aa : aas)
289 if (aa.isValidStruc() && aa.sequenceRef == null)
292 * valid alignment RNA secondary structure annotation
294 menuItem = new JMenuItem();
295 menuItem.setText(MessageManager.formatMessage(
296 "label.2d_rna_structure_line", new Object[]
298 menuItem.addActionListener(new ActionListener()
301 public void actionPerformed(ActionEvent e)
303 new AppVarna(seq, aa, ap);
306 rnaStructureMenu.add(menuItem);
311 if (seq.getAnnotation() != null)
313 AlignmentAnnotation seqAnns[] = seq.getAnnotation();
314 for (final AlignmentAnnotation aa : seqAnns)
316 if (aa.isValidStruc())
319 * valid sequence RNA secondary structure annotation
321 // TODO: make rnastrucF a bit more nice
322 menuItem = new JMenuItem();
323 menuItem.setText(MessageManager.formatMessage(
324 "label.2d_rna_sequence_name", new Object[]
326 menuItem.addActionListener(new ActionListener()
329 public void actionPerformed(ActionEvent e)
331 // TODO: VARNA does'nt print gaps in the sequence
332 new AppVarna(seq, aa, ap);
335 rnaStructureMenu.add(menuItem);
339 if (rnaStructureMenu.getItemCount() == origCount)
341 remove(rnaStructureMenu);
345 menuItem = new JMenuItem(
346 MessageManager.getString("action.hide_sequences"));
347 menuItem.addActionListener(new ActionListener()
350 public void actionPerformed(ActionEvent e)
352 hideSequences(false);
357 if (sequence.isHMMConsensusSequence())
359 JMenuItem selectHMM = new JCheckBoxMenuItem();
360 selectHMM.setText(MessageManager.getString("label.select_hmm"));
361 selectHMM.addActionListener(new ActionListener()
365 public void actionPerformed(ActionEvent e)
367 selectHMM_actionPerformed(e);
374 if (ap.av.getSelectionGroup() != null
375 && ap.av.getSelectionGroup().getSize() > 1)
377 menuItem = new JMenuItem(MessageManager
378 .formatMessage("label.represent_group_with", new Object[]
380 menuItem.addActionListener(new ActionListener()
383 public void actionPerformed(ActionEvent e)
388 sequenceMenu.add(menuItem);
391 if (ap.av.hasHiddenRows())
393 final int index = ap.av.getAlignment().findIndex(seq);
395 if (ap.av.adjustForHiddenSeqs(index)
396 - ap.av.adjustForHiddenSeqs(index - 1) > 1)
398 menuItem = new JMenuItem(
399 MessageManager.getString("action.reveal_sequences"));
400 menuItem.addActionListener(new ActionListener()
403 public void actionPerformed(ActionEvent e)
405 ap.av.showSequence(index);
406 if (ap.overviewPanel != null)
408 ap.overviewPanel.updateOverviewImage();
416 // for the case when no sequences are even visible
417 if (ap.av.hasHiddenRows())
420 menuItem = new JMenuItem(
421 MessageManager.getString("action.reveal_all"));
422 menuItem.addActionListener(new ActionListener()
425 public void actionPerformed(ActionEvent e)
427 ap.av.showAllHiddenSeqs();
428 if (ap.overviewPanel != null)
430 ap.overviewPanel.updateOverviewImage();
439 SequenceGroup sg = ap.av.getSelectionGroup();
440 boolean isDefinedGroup = (sg != null)
441 ? ap.av.getAlignment().getGroups().contains(sg)
444 if (sg != null && sg.getSize() > 0)
446 groupName.setText(MessageManager
447 .getString("label.edit_name_and_description_current_group"));
449 ColourMenuHelper.setColourSelected(colourMenu, sg.getColourScheme());
451 conservationMenuItem.setEnabled(!sg.isNucleotide());
455 if (sg.cs.conservationApplied())
457 conservationMenuItem.setSelected(true);
459 if (sg.cs.getThreshold() > 0)
461 abovePIDColour.setSelected(true);
464 modifyConservation.setEnabled(conservationMenuItem.isSelected());
465 modifyPID.setEnabled(abovePIDColour.isSelected());
466 displayNonconserved.setSelected(sg.getShowNonconserved());
467 showText.setSelected(sg.getDisplayText());
468 showColourText.setSelected(sg.getColourText());
469 showBoxes.setSelected(sg.getDisplayBoxes());
470 // add any groupURLs to the groupURL submenu and make it visible
471 if (groupLinks != null && groupLinks.size() > 0)
473 buildGroupURLMenu(sg, groupLinks);
475 // Add a 'show all structures' for the current selection
476 Hashtable<String, PDBEntry> pdbe = new Hashtable<>(),
477 reppdb = new Hashtable<>();
478 SequenceI sqass = null;
479 for (SequenceI sq : ap.av.getSequenceSelection())
481 Vector<PDBEntry> pes = sq.getDatasetSequence().getAllPDBEntries();
482 if (pes != null && pes.size() > 0)
484 reppdb.put(pes.get(0).getId(), pes.get(0));
485 for (PDBEntry pe : pes)
487 pdbe.put(pe.getId(), pe);
497 final PDBEntry[] pe = pdbe.values()
498 .toArray(new PDBEntry[pdbe.size()]),
499 pr = reppdb.values().toArray(new PDBEntry[reppdb.size()]);
500 final JMenuItem gpdbview, rpdbview;
505 groupMenu.setVisible(false);
506 editMenu.setVisible(false);
511 createGroupMenuItem.setVisible(true);
512 unGroupMenuItem.setVisible(false);
513 jMenu1.setText(MessageManager.getString("action.edit_new_group"));
517 createGroupMenuItem.setVisible(false);
518 unGroupMenuItem.setVisible(true);
519 jMenu1.setText(MessageManager.getString("action.edit_group"));
524 sequenceMenu.setVisible(false);
525 pdbStructureDialog.setVisible(false);
526 rnaStructureMenu.setVisible(false);
529 if (links != null && links.size() > 0)
531 addFeatureLinks(seq, links);
536 * Adds a 'Link' menu item with a sub-menu item for each hyperlink provided.
541 void addFeatureLinks(final SequenceI seq, List<String> links)
543 JMenu linkMenu = new JMenu(MessageManager.getString("action.link"));
544 Map<String, List<String>> linkset = new LinkedHashMap<>();
546 for (String link : links)
548 UrlLink urlLink = null;
551 urlLink = new UrlLink(link);
552 } catch (Exception foo)
554 Cache.log.error("Exception for URLLink '" + link + "'", foo);
558 if (!urlLink.isValid())
560 Cache.log.error(urlLink.getInvalidMessage());
564 urlLink.createLinksFromSeq(seq, linkset);
567 addshowLinks(linkMenu, linkset.values());
569 // disable link menu if there are no valid entries
570 if (linkMenu.getItemCount() > 0)
572 linkMenu.setEnabled(true);
576 linkMenu.setEnabled(false);
579 if (sequence != null)
581 sequenceMenu.add(linkMenu);
591 * Add annotation types to 'Show annotations' and/or 'Hide annotations' menus.
592 * "All" is added first, followed by a separator. Then add any annotation
593 * types associated with the current selection. Separate menus are built for
594 * the selected sequence group (if any), and the selected sequence.
596 * Some annotation rows are always rendered together - these can be identified
597 * by a common graphGroup property > -1. Only one of each group will be marked
598 * as visible (to avoid duplication of the display). For such groups we add a
599 * composite type name, e.g.
601 * IUPredWS (Long), IUPredWS (Short)
605 protected void buildAnnotationTypesMenus(JMenu showMenu, JMenu hideMenu,
606 List<SequenceI> forSequences)
608 showMenu.removeAll();
609 hideMenu.removeAll();
611 final List<String> all = Arrays
613 { MessageManager.getString("label.all") });
614 addAnnotationTypeToShowHide(showMenu, forSequences, "", all, true,
616 addAnnotationTypeToShowHide(hideMenu, forSequences, "", all, true,
618 showMenu.addSeparator();
619 hideMenu.addSeparator();
621 final AlignmentAnnotation[] annotations = ap.getAlignment()
622 .getAlignmentAnnotation();
625 * Find shown/hidden annotations types, distinguished by source (calcId),
626 * and grouped by graphGroup. Using LinkedHashMap means we will retrieve in
627 * the insertion order, which is the order of the annotations on the
630 Map<String, List<List<String>>> shownTypes = new LinkedHashMap<>();
631 Map<String, List<List<String>>> hiddenTypes = new LinkedHashMap<>();
632 AlignmentAnnotationUtils.getShownHiddenTypes(shownTypes, hiddenTypes,
633 AlignmentAnnotationUtils.asList(annotations), forSequences);
635 for (String calcId : hiddenTypes.keySet())
637 for (List<String> type : hiddenTypes.get(calcId))
639 addAnnotationTypeToShowHide(showMenu, forSequences, calcId, type,
643 // grey out 'show annotations' if none are hidden
644 showMenu.setEnabled(!hiddenTypes.isEmpty());
646 for (String calcId : shownTypes.keySet())
648 for (List<String> type : shownTypes.get(calcId))
650 addAnnotationTypeToShowHide(hideMenu, forSequences, calcId, type,
654 // grey out 'hide annotations' if none are shown
655 hideMenu.setEnabled(!shownTypes.isEmpty());
659 * Returns a list of sequences - either the current selection group (if there
660 * is one), else the specified single sequence.
665 protected List<SequenceI> getSequenceScope(SequenceI seq)
667 List<SequenceI> forSequences = null;
668 final SequenceGroup selectionGroup = ap.av.getSelectionGroup();
669 if (selectionGroup != null && selectionGroup.getSize() > 0)
671 forSequences = selectionGroup.getSequences();
675 forSequences = seq == null ? Collections.<SequenceI> emptyList()
676 : Arrays.asList(seq);
682 * Add one annotation type to the 'Show Annotations' or 'Hide Annotations'
685 * @param showOrHideMenu
687 * @param forSequences
688 * the sequences whose annotations may be shown or hidden
693 * if true this is a special label meaning 'All'
694 * @param actionIsShow
695 * if true, the select menu item action is to show the annotation
698 protected void addAnnotationTypeToShowHide(JMenu showOrHideMenu,
699 final List<SequenceI> forSequences, String calcId,
700 final List<String> types, final boolean allTypes,
701 final boolean actionIsShow)
703 String label = types.toString(); // [a, b, c]
704 label = label.substring(1, label.length() - 1); // a, b, c
705 final JMenuItem item = new JMenuItem(label);
706 item.setToolTipText(calcId);
707 item.addActionListener(new ActionListener()
710 public void actionPerformed(ActionEvent e)
712 AlignmentUtils.showOrHideSequenceAnnotations(ap.getAlignment(),
713 types, forSequences, allTypes, actionIsShow);
717 showOrHideMenu.add(item);
720 private void buildGroupURLMenu(SequenceGroup sg, List<String> groupLinks)
723 // TODO: usability: thread off the generation of group url content so root
725 // sequence only URLs
726 // ID/regex match URLs
727 groupLinksMenu = new JMenu(
728 MessageManager.getString("action.group_link"));
729 // three types of url that might be created.
730 JMenu[] linkMenus = new JMenu[] { null,
731 new JMenu(MessageManager.getString("action.ids")),
732 new JMenu(MessageManager.getString("action.sequences")),
733 new JMenu(MessageManager.getString("action.ids_sequences")) };
735 SequenceI[] seqs = ap.av.getSelectionAsNewSequence();
736 String[][] idandseqs = GroupUrlLink.formStrings(seqs);
737 Hashtable<String, Object[]> commonDbrefs = new Hashtable<>();
738 for (int sq = 0; sq < seqs.length; sq++)
741 int start = seqs[sq].findPosition(sg.getStartRes()),
742 end = seqs[sq].findPosition(sg.getEndRes());
743 // just collect ids from dataset sequence
744 // TODO: check if IDs collected from selecton group intersects with the
745 // current selection, too
746 SequenceI sqi = seqs[sq];
747 while (sqi.getDatasetSequence() != null)
749 sqi = sqi.getDatasetSequence();
751 DBRefEntry[] dbr = sqi.getDBRefs();
752 if (dbr != null && dbr.length > 0)
754 for (int d = 0; d < dbr.length; d++)
756 String src = dbr[d].getSource(); // jalview.util.DBRefUtils.getCanonicalName(dbr[d].getSource()).toUpperCase();
757 Object[] sarray = commonDbrefs.get(src);
760 sarray = new Object[2];
761 sarray[0] = new int[] { 0 };
762 sarray[1] = new String[seqs.length];
764 commonDbrefs.put(src, sarray);
767 if (((String[]) sarray[1])[sq] == null)
769 if (!dbr[d].hasMap() || (dbr[d].getMap()
770 .locateMappedRange(start, end) != null))
772 ((String[]) sarray[1])[sq] = dbr[d].getAccessionId();
773 ((int[]) sarray[0])[0]++;
779 // now create group links for all distinct ID/sequence sets.
780 boolean addMenu = false; // indicates if there are any group links to give
782 for (String link : groupLinks)
784 GroupUrlLink urlLink = null;
787 urlLink = new GroupUrlLink(link);
788 } catch (Exception foo)
790 Cache.log.error("Exception for GroupURLLink '" + link + "'", foo);
794 if (!urlLink.isValid())
796 Cache.log.error(urlLink.getInvalidMessage());
799 final String label = urlLink.getLabel();
800 boolean usingNames = false;
801 // Now see which parts of the group apply for this URL
802 String ltarget = urlLink.getTarget(); // jalview.util.DBRefUtils.getCanonicalName(urlLink.getTarget());
803 Object[] idset = commonDbrefs.get(ltarget.toUpperCase());
804 String[] seqstr, ids; // input to makeUrl
807 int numinput = ((int[]) idset[0])[0];
808 String[] allids = ((String[]) idset[1]);
809 seqstr = new String[numinput];
810 ids = new String[numinput];
811 for (int sq = 0, idcount = 0; sq < seqs.length; sq++)
813 if (allids[sq] != null)
815 ids[idcount] = allids[sq];
816 seqstr[idcount++] = idandseqs[1][sq];
822 // just use the id/seq set
823 seqstr = idandseqs[1];
827 // and try and make the groupURL!
829 Object[] urlset = null;
832 urlset = urlLink.makeUrlStubs(ids, seqstr,
833 "FromJalview" + System.currentTimeMillis(), false);
834 } catch (UrlStringTooLongException e)
839 int type = urlLink.getGroupURLType() & 3;
840 // first two bits ofurlLink type bitfield are sequenceids and sequences
841 // TODO: FUTURE: ensure the groupURL menu structure can be generalised
842 addshowLink(linkMenus[type],
843 label + (((type & 1) == 1)
844 ? ("(" + (usingNames ? "Names" : ltarget) + ")")
852 groupLinksMenu = new JMenu(
853 MessageManager.getString("action.group_link"));
854 for (int m = 0; m < linkMenus.length; m++)
856 if (linkMenus[m] != null
857 && linkMenus[m].getMenuComponentCount() > 0)
859 groupLinksMenu.add(linkMenus[m]);
863 groupMenu.add(groupLinksMenu);
867 private void addshowLinks(JMenu linkMenu,
868 Collection<List<String>> linkset)
870 for (List<String> linkstrset : linkset)
872 // split linkstr into label and url
873 addshowLink(linkMenu, linkstrset.get(1), linkstrset.get(3));
878 * add a show URL menu item to the given linkMenu
882 * - menu label string
886 private void addshowLink(JMenu linkMenu, String label, final String url)
888 JMenuItem item = new JMenuItem(label);
889 item.setToolTipText(MessageManager.formatMessage("label.open_url_param",
892 item.addActionListener(new ActionListener()
895 public void actionPerformed(ActionEvent e)
897 new Thread(new Runnable()
914 * add a late bound groupURL item to the given linkMenu
918 * - menu label string
919 * @param urlgenerator
920 * GroupURLLink used to generate URL
922 * Object array returned from the makeUrlStubs function.
924 private void addshowLink(JMenu linkMenu, String label,
925 final GroupUrlLink urlgenerator, final Object[] urlstub)
927 JMenuItem item = new JMenuItem(label);
928 item.setToolTipText(MessageManager
929 .formatMessage("label.open_url_seqs_param", new Object[]
930 { urlgenerator.getUrl_prefix(),
931 urlgenerator.getNumberInvolved(urlstub) }));
932 // TODO: put in info about what is being sent.
933 item.addActionListener(new ActionListener()
936 public void actionPerformed(ActionEvent e)
938 new Thread(new Runnable()
946 showLink(urlgenerator.constructFrom(urlstub));
947 } catch (UrlStringTooLongException e2)
965 private void jbInit() throws Exception
967 groupMenu.setText(MessageManager.getString("label.selection"));
968 groupName.setText(MessageManager.getString("label.name"));
969 groupName.addActionListener(new ActionListener()
972 public void actionPerformed(ActionEvent e)
974 groupName_actionPerformed();
977 sequenceMenu.setText(MessageManager.getString("label.sequence"));
978 sequenceName.setText(
979 MessageManager.getString("label.edit_name_description"));
980 sequenceName.addActionListener(new ActionListener()
983 public void actionPerformed(ActionEvent e)
985 sequenceName_actionPerformed();
989 .setText(MessageManager.getString("action.choose_annotations"));
990 chooseAnnotations.addActionListener(new ActionListener()
993 public void actionPerformed(ActionEvent e)
995 chooseAnnotations_actionPerformed(e);
999 .setText(MessageManager.getString("label.sequence_details"));
1000 sequenceDetails.addActionListener(new ActionListener()
1003 public void actionPerformed(ActionEvent e)
1005 sequenceDetails_actionPerformed();
1009 .setText(MessageManager.getString("label.sequence_details"));
1010 sequenceSelDetails.addActionListener(new ActionListener()
1013 public void actionPerformed(ActionEvent e)
1015 sequenceSelectionDetails_actionPerformed();
1020 .setText(MessageManager.getString("action.remove_group"));
1021 unGroupMenuItem.addActionListener(new ActionListener()
1024 public void actionPerformed(ActionEvent e)
1026 unGroupMenuItem_actionPerformed();
1030 .setText(MessageManager.getString("action.create_group"));
1031 createGroupMenuItem.addActionListener(new ActionListener()
1034 public void actionPerformed(ActionEvent e)
1036 createGroupMenuItem_actionPerformed();
1040 outline.setText(MessageManager.getString("action.border_colour"));
1041 outline.addActionListener(new ActionListener()
1044 public void actionPerformed(ActionEvent e)
1046 outline_actionPerformed();
1049 showBoxes.setText(MessageManager.getString("action.boxes"));
1050 showBoxes.setState(true);
1051 showBoxes.addActionListener(new ActionListener()
1054 public void actionPerformed(ActionEvent e)
1056 showBoxes_actionPerformed();
1059 showText.setText(MessageManager.getString("action.text"));
1060 showText.setState(true);
1061 showText.addActionListener(new ActionListener()
1064 public void actionPerformed(ActionEvent e)
1066 showText_actionPerformed();
1069 showColourText.setText(MessageManager.getString("label.colour_text"));
1070 showColourText.addActionListener(new ActionListener()
1073 public void actionPerformed(ActionEvent e)
1075 showColourText_actionPerformed();
1079 .setText(MessageManager.getString("label.show_non_conserved"));
1080 displayNonconserved.setState(true);
1081 displayNonconserved.addActionListener(new ActionListener()
1084 public void actionPerformed(ActionEvent e)
1086 showNonconserved_actionPerformed();
1089 editMenu.setText(MessageManager.getString("action.edit"));
1090 cut.setText(MessageManager.getString("action.cut"));
1091 cut.addActionListener(new ActionListener()
1094 public void actionPerformed(ActionEvent e)
1096 cut_actionPerformed();
1099 upperCase.setText(MessageManager.getString("label.to_upper_case"));
1100 upperCase.addActionListener(new ActionListener()
1103 public void actionPerformed(ActionEvent e)
1108 copy.setText(MessageManager.getString("action.copy"));
1109 copy.addActionListener(new ActionListener()
1112 public void actionPerformed(ActionEvent e)
1114 copy_actionPerformed();
1117 lowerCase.setText(MessageManager.getString("label.to_lower_case"));
1118 lowerCase.addActionListener(new ActionListener()
1121 public void actionPerformed(ActionEvent e)
1126 toggle.setText(MessageManager.getString("label.toggle_case"));
1127 toggle.addActionListener(new ActionListener()
1130 public void actionPerformed(ActionEvent e)
1136 MessageManager.getString("label.out_to_textbox") + "...");
1137 seqShowAnnotationsMenu
1138 .setText(MessageManager.getString("label.show_annotations"));
1139 seqHideAnnotationsMenu
1140 .setText(MessageManager.getString("label.hide_annotations"));
1141 groupShowAnnotationsMenu
1142 .setText(MessageManager.getString("label.show_annotations"));
1143 groupHideAnnotationsMenu
1144 .setText(MessageManager.getString("label.hide_annotations"));
1145 sequenceFeature.setText(
1146 MessageManager.getString("label.create_sequence_feature"));
1147 sequenceFeature.addActionListener(new ActionListener()
1150 public void actionPerformed(ActionEvent e)
1152 sequenceFeature_actionPerformed();
1155 jMenu1.setText(MessageManager.getString("label.group"));
1156 pdbStructureDialog.setText(
1157 MessageManager.getString("label.show_pdbstruct_dialog"));
1158 pdbStructureDialog.addActionListener(new ActionListener()
1161 public void actionPerformed(ActionEvent actionEvent)
1163 SequenceI[] selectedSeqs = new SequenceI[] { sequence };
1164 if (ap.av.getSelectionGroup() != null)
1166 selectedSeqs = ap.av.getSequenceSelection();
1168 new StructureChooser(selectedSeqs, sequence, ap);
1173 .setText(MessageManager.getString("label.view_rna_structure"));
1175 // colStructureMenu.setText("Colour By Structure");
1176 editSequence.setText(
1177 MessageManager.getString("label.edit_sequence") + "...");
1178 editSequence.addActionListener(new ActionListener()
1181 public void actionPerformed(ActionEvent actionEvent)
1183 editSequence_actionPerformed(actionEvent);
1186 makeReferenceSeq.setText(
1187 MessageManager.getString("label.mark_as_representative"));
1188 makeReferenceSeq.addActionListener(new ActionListener()
1192 public void actionPerformed(ActionEvent actionEvent)
1194 makeReferenceSeq_actionPerformed(actionEvent);
1199 .setText(MessageManager.getString("label.hide_insertions"));
1200 hideInsertions.addActionListener(new ActionListener()
1204 public void actionPerformed(ActionEvent e)
1206 hideInsertions_actionPerformed(e);
1210 groupMenu.add(sequenceSelDetails);
1213 add(rnaStructureMenu);
1214 add(pdbStructureDialog);
1215 if (sequence != null)
1217 add(hideInsertions);
1219 // annotations configuration panel suppressed for now
1220 // groupMenu.add(chooseAnnotations);
1223 * Add show/hide annotations to the Sequence menu, and to the Selection menu
1224 * (if a selection group is in force).
1226 sequenceMenu.add(seqShowAnnotationsMenu);
1227 sequenceMenu.add(seqHideAnnotationsMenu);
1228 sequenceMenu.add(seqAddReferenceAnnotations);
1229 groupMenu.add(groupShowAnnotationsMenu);
1230 groupMenu.add(groupHideAnnotationsMenu);
1231 groupMenu.add(groupAddReferenceAnnotations);
1232 groupMenu.add(editMenu);
1233 groupMenu.add(outputMenu);
1234 groupMenu.add(sequenceFeature);
1235 groupMenu.add(createGroupMenuItem);
1236 groupMenu.add(unGroupMenuItem);
1237 groupMenu.add(jMenu1);
1238 sequenceMenu.add(sequenceName);
1239 sequenceMenu.add(sequenceDetails);
1240 sequenceMenu.add(makeReferenceSeq);
1247 editMenu.add(editSequence);
1248 editMenu.add(upperCase);
1249 editMenu.add(lowerCase);
1250 editMenu.add(toggle);
1251 // JBPNote: These shouldn't be added here - should appear in a generic
1252 // 'apply web service to this sequence menu'
1253 // pdbMenu.add(RNAFold);
1254 // pdbMenu.add(ContraFold);
1255 jMenu1.add(groupName);
1256 jMenu1.add(colourMenu);
1257 jMenu1.add(showBoxes);
1258 jMenu1.add(showText);
1259 jMenu1.add(showColourText);
1260 jMenu1.add(outline);
1261 jMenu1.add(displayNonconserved);
1265 protected void selectHMM_actionPerformed(ActionEvent e)
1267 SequenceI hmm = ap.av.getSequenceSelection()[0];
1268 ap.alignFrame.setSelectedHMMSequence(hmm);
1272 * Constructs the entries for the colour menu
1274 protected void initColourMenu()
1276 colourMenu.setText(MessageManager.getString("label.group_colour"));
1277 textColour.setText(MessageManager.getString("label.text_colour"));
1278 textColour.addActionListener(new ActionListener()
1281 public void actionPerformed(ActionEvent e)
1283 textColour_actionPerformed();
1287 abovePIDColour.setText(
1288 MessageManager.getString("label.above_identity_threshold"));
1289 abovePIDColour.addActionListener(new ActionListener()
1292 public void actionPerformed(ActionEvent e)
1294 abovePIDColour_actionPerformed(abovePIDColour.isSelected());
1299 MessageManager.getString("label.modify_identity_threshold"));
1300 modifyPID.addActionListener(new ActionListener()
1303 public void actionPerformed(ActionEvent e)
1305 modifyPID_actionPerformed();
1309 conservationMenuItem
1310 .setText(MessageManager.getString("action.by_conservation"));
1311 conservationMenuItem.addActionListener(new ActionListener()
1314 public void actionPerformed(ActionEvent e)
1316 conservationMenuItem_actionPerformed(
1317 conservationMenuItem.isSelected());
1321 modifyConservation.setText(MessageManager
1322 .getString("label.modify_conservation_threshold"));
1323 modifyConservation.addActionListener(new ActionListener()
1326 public void actionPerformed(ActionEvent e)
1328 modifyConservation_actionPerformed();
1334 * Builds the group colour sub-menu, including any user-defined colours which
1335 * were loaded at startup or during the Jalview session
1337 protected void buildColourMenu()
1339 SequenceGroup sg = ap.av.getSelectionGroup();
1343 * popup menu with no sequence group scope
1347 colourMenu.removeAll();
1348 colourMenu.add(textColour);
1349 colourMenu.addSeparator();
1351 ColourMenuHelper.addMenuItems(colourMenu, this, sg, false);
1353 colourMenu.addSeparator();
1354 colourMenu.add(conservationMenuItem);
1355 colourMenu.add(modifyConservation);
1356 colourMenu.add(abovePIDColour);
1357 colourMenu.add(modifyPID);
1360 protected void modifyConservation_actionPerformed()
1362 SequenceGroup sg = getGroup();
1365 SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
1366 SliderPanel.showConservationSlider();
1370 protected void modifyPID_actionPerformed()
1372 SequenceGroup sg = getGroup();
1375 // int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
1377 // sg.cs.setThreshold(threshold, ap.av.isIgnoreGapsConsensus());
1378 SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup().getName());
1379 SliderPanel.showPIDSlider();
1384 * Check for any annotations on the underlying dataset sequences (for the
1385 * current selection group) which are not 'on the alignment'.If any are found,
1386 * enable the option to add them to the alignment. The criteria for 'on the
1387 * alignment' is finding an alignment annotation on the alignment, matched on
1388 * calcId, label and sequenceRef.
1390 * A tooltip is also constructed that displays the source (calcId) and type
1391 * (label) of the annotations that can be added.
1394 * @param forSequences
1396 protected void configureReferenceAnnotationsMenu(JMenuItem menuItem,
1397 List<SequenceI> forSequences)
1399 menuItem.setEnabled(false);
1402 * Temporary store to hold distinct calcId / type pairs for the tooltip.
1403 * Using TreeMap means calcIds are shown in alphabetical order.
1405 SortedMap<String, String> tipEntries = new TreeMap<>();
1406 final Map<SequenceI, List<AlignmentAnnotation>> candidates = new LinkedHashMap<>();
1407 AlignmentI al = this.ap.av.getAlignment();
1408 AlignmentUtils.findAddableReferenceAnnotations(forSequences, tipEntries,
1410 if (!candidates.isEmpty())
1412 StringBuilder tooltip = new StringBuilder(64);
1413 tooltip.append(MessageManager.getString("label.add_annotations_for"));
1416 * Found annotations that could be added. Enable the menu item, and
1417 * configure its tooltip and action.
1419 menuItem.setEnabled(true);
1420 for (String calcId : tipEntries.keySet())
1422 tooltip.append("<br/>" + calcId + "/" + tipEntries.get(calcId));
1424 String tooltipText = JvSwingUtils.wrapTooltip(true,
1425 tooltip.toString());
1426 menuItem.setToolTipText(tooltipText);
1428 menuItem.addActionListener(new ActionListener()
1431 public void actionPerformed(ActionEvent e)
1433 addReferenceAnnotations_actionPerformed(candidates);
1440 * Add annotations to the sequences and to the alignment.
1443 * a map whose keys are sequences on the alignment, and values a list
1444 * of annotations to add to each sequence
1446 protected void addReferenceAnnotations_actionPerformed(
1447 Map<SequenceI, List<AlignmentAnnotation>> candidates)
1449 final SequenceGroup selectionGroup = this.ap.av.getSelectionGroup();
1450 final AlignmentI alignment = this.ap.getAlignment();
1451 AlignmentUtils.addReferenceAnnotations(candidates, alignment,
1456 protected void makeReferenceSeq_actionPerformed(ActionEvent actionEvent)
1458 if (!ap.av.getAlignment().hasSeqrep())
1460 // initialise the display flags so the user sees something happen
1461 ap.av.setDisplayReferenceSeq(true);
1462 ap.av.setColourByReferenceSeq(true);
1463 ap.av.getAlignment().setSeqrep(sequence);
1467 if (ap.av.getAlignment().getSeqrep() == sequence)
1469 ap.av.getAlignment().setSeqrep(null);
1473 ap.av.getAlignment().setSeqrep(sequence);
1479 protected void hideInsertions_actionPerformed(ActionEvent actionEvent)
1482 HiddenColumns hidden = new HiddenColumns();
1483 BitSet inserts = new BitSet(), mask = new BitSet();
1485 // set mask to preserve existing hidden columns outside selected group
1486 if (ap.av.hasHiddenColumns())
1488 ap.av.getAlignment().getHiddenColumns().markHiddenRegions(mask);
1491 boolean markedPopup = false;
1492 // mark inserts in current selection
1493 if (ap.av.getSelectionGroup() != null)
1495 // mark just the columns in the selection group to be hidden
1496 inserts.set(ap.av.getSelectionGroup().getStartRes(),
1497 ap.av.getSelectionGroup().getEndRes() + 1);
1499 // and clear that part of the mask
1500 mask.andNot(inserts);
1502 // now clear columns without gaps
1503 for (SequenceI sq : ap.av.getSelectionGroup().getSequences())
1509 inserts.and(sq.getInsertionsAsBits());
1514 // initially, mark all columns to be hidden
1515 inserts.set(0, ap.av.getAlignment().getWidth());
1517 // and clear out old hidden regions completely
1521 // now mark for sequence under popup if we haven't already done it
1522 if (!markedPopup && sequence != null)
1524 inserts.and(sequence.getInsertionsAsBits());
1527 // finally, preserve hidden regions outside selection
1530 // and set hidden columns accordingly
1531 hidden.hideMarkedBits(inserts);
1533 ap.av.getAlignment().setHiddenColumns(hidden);
1537 protected void sequenceSelectionDetails_actionPerformed()
1539 createSequenceDetailsReport(ap.av.getSequenceSelection());
1542 protected void sequenceDetails_actionPerformed()
1544 createSequenceDetailsReport(new SequenceI[] { sequence });
1547 public void createSequenceDetailsReport(SequenceI[] sequences)
1549 CutAndPasteHtmlTransfer cap = new CutAndPasteHtmlTransfer();
1550 StringBuilder contents = new StringBuilder(128);
1551 for (SequenceI seq : sequences)
1553 contents.append("<p><h2>" + MessageManager.formatMessage(
1554 "label.create_sequence_details_report_annotation_for",
1556 { seq.getDisplayId(true) }) + "</h2></p><p>");
1557 new SequenceAnnotationReport(null).createSequenceAnnotationReport(
1558 contents, seq, true, true,
1559 (ap.getSeqPanel().seqCanvas.fr != null)
1560 ? ap.getSeqPanel().seqCanvas.fr.getMinMax()
1562 contents.append("</p>");
1564 cap.setText("<html>" + contents.toString() + "</html>");
1566 Desktop.addInternalFrame(cap,
1567 MessageManager.formatMessage("label.sequence_details_for",
1568 (sequences.length == 1 ? new Object[]
1569 { sequences[0].getDisplayId(true) }
1572 .getString("label.selection") })),
1577 protected void showNonconserved_actionPerformed()
1579 getGroup().setShowNonconserved(displayNonconserved.isSelected());
1584 * call to refresh view after settings change
1588 ap.updateAnnotation();
1589 ap.paintAlignment(true);
1591 PaintRefresher.Refresh(this, ap.av.getSequenceSetId());
1595 * protected void covariationColour_actionPerformed() { getGroup().cs = new
1596 * CovariationColourScheme(sequence.getAnnotation()[0]); refresh(); }
1606 public void abovePIDColour_actionPerformed(boolean selected)
1608 SequenceGroup sg = getGroup();
1616 sg.cs.setConsensus(AAFrequency.calculate(
1617 sg.getSequences(ap.av.getHiddenRepSequences()),
1618 sg.getStartRes(), sg.getEndRes() + 1));
1620 int threshold = SliderPanel.setPIDSliderSource(ap,
1621 sg.getGroupColourScheme(), getGroup().getName());
1623 sg.cs.setThreshold(threshold, ap.av.isIgnoreGapsConsensus());
1625 SliderPanel.showPIDSlider();
1628 // remove PIDColouring
1630 sg.cs.setThreshold(0, ap.av.isIgnoreGapsConsensus());
1631 SliderPanel.hidePIDSlider();
1633 modifyPID.setEnabled(selected);
1639 * Open a panel where the user can choose which types of sequence annotation
1644 protected void chooseAnnotations_actionPerformed(ActionEvent e)
1646 // todo correct way to guard against opening a duplicate panel?
1647 new AnnotationChooser(ap);
1656 public void conservationMenuItem_actionPerformed(boolean selected)
1658 SequenceGroup sg = getGroup();
1666 // JBPNote: Conservation name shouldn't be i18n translated
1667 Conservation c = new Conservation("Group",
1668 sg.getSequences(ap.av.getHiddenRepSequences()),
1669 sg.getStartRes(), sg.getEndRes() + 1);
1672 c.verdict(false, ap.av.getConsPercGaps());
1673 sg.cs.setConservation(c);
1675 SliderPanel.setConservationSlider(ap, sg.getGroupColourScheme(),
1677 SliderPanel.showConservationSlider();
1680 // remove ConservationColouring
1682 sg.cs.setConservation(null);
1683 SliderPanel.hideConservationSlider();
1685 modifyConservation.setEnabled(selected);
1696 protected void groupName_actionPerformed()
1699 SequenceGroup sg = getGroup();
1700 EditNameDialog dialog = new EditNameDialog(sg.getName(),
1701 sg.getDescription(),
1702 " " + MessageManager.getString("label.group_name") + " ",
1703 MessageManager.getString("label.group_description") + " ",
1704 MessageManager.getString("label.edit_group_name_description"),
1712 sg.setName(dialog.getName());
1713 sg.setDescription(dialog.getDescription());
1718 * Get selection group - adding it to the alignment if necessary.
1720 * @return sequence group to operate on
1722 SequenceGroup getGroup()
1724 SequenceGroup sg = ap.av.getSelectionGroup();
1725 // this method won't add a new group if it already exists
1728 ap.av.getAlignment().addGroup(sg);
1740 void sequenceName_actionPerformed()
1742 EditNameDialog dialog = new EditNameDialog(sequence.getName(),
1743 sequence.getDescription(),
1744 " " + MessageManager.getString("label.sequence_name")
1746 MessageManager.getString("label.sequence_description") + " ",
1747 MessageManager.getString(
1748 "label.edit_sequence_name_description"),
1756 if (dialog.getName() != null)
1758 if (dialog.getName().indexOf(" ") > -1)
1760 JvOptionPane.showMessageDialog(ap,
1762 .getString("label.spaces_converted_to_backslashes"),
1764 .getString("label.no_spaces_allowed_sequence_name"),
1765 JvOptionPane.WARNING_MESSAGE);
1768 sequence.setName(dialog.getName().replace(' ', '_'));
1769 ap.paintAlignment(false);
1772 sequence.setDescription(dialog.getDescription());
1774 ap.av.firePropertyChange("alignment", null,
1775 ap.av.getAlignment().getSequences());
1785 void unGroupMenuItem_actionPerformed()
1787 SequenceGroup sg = ap.av.getSelectionGroup();
1788 ap.av.getAlignment().deleteGroup(sg);
1789 ap.av.setSelectionGroup(null);
1793 void createGroupMenuItem_actionPerformed()
1795 getGroup(); // implicitly creates group - note - should apply defaults / use
1796 // standard alignment window logic for this
1806 protected void outline_actionPerformed()
1808 SequenceGroup sg = getGroup();
1809 Color col = JColorChooser.showDialog(this,
1810 MessageManager.getString("label.select_outline_colour"),
1815 sg.setOutlineColour(col);
1827 public void showBoxes_actionPerformed()
1829 getGroup().setDisplayBoxes(showBoxes.isSelected());
1839 public void showText_actionPerformed()
1841 getGroup().setDisplayText(showText.isSelected());
1851 public void showColourText_actionPerformed()
1853 getGroup().setColourText(showColourText.isSelected());
1857 public void showLink(String url)
1861 jalview.util.BrowserLauncher.openURL(url);
1862 } catch (Exception ex)
1864 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
1865 MessageManager.getString("label.web_browser_not_found_unix"),
1866 MessageManager.getString("label.web_browser_not_found"),
1867 JvOptionPane.WARNING_MESSAGE);
1869 ex.printStackTrace();
1873 void hideSequences(boolean representGroup)
1875 ap.av.hideSequences(sequence, representGroup);
1878 public void copy_actionPerformed()
1880 ap.alignFrame.copy_actionPerformed(null);
1883 public void cut_actionPerformed()
1885 ap.alignFrame.cut_actionPerformed(null);
1888 void changeCase(ActionEvent e)
1890 Object source = e.getSource();
1891 SequenceGroup sg = ap.av.getSelectionGroup();
1895 List<int[]> startEnd = ap.av.getVisibleRegionBoundaries(
1896 sg.getStartRes(), sg.getEndRes() + 1);
1901 if (source == toggle)
1903 description = MessageManager.getString("label.toggle_case");
1904 caseChange = ChangeCaseCommand.TOGGLE_CASE;
1906 else if (source == upperCase)
1908 description = MessageManager.getString("label.to_upper_case");
1909 caseChange = ChangeCaseCommand.TO_UPPER;
1913 description = MessageManager.getString("label.to_lower_case");
1914 caseChange = ChangeCaseCommand.TO_LOWER;
1917 ChangeCaseCommand caseCommand = new ChangeCaseCommand(description,
1918 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
1919 startEnd, caseChange);
1921 ap.alignFrame.addHistoryItem(caseCommand);
1923 ap.av.firePropertyChange("alignment", null,
1924 ap.av.getAlignment().getSequences());
1929 public void outputText_actionPerformed(ActionEvent e)
1931 CutAndPasteTransfer cap = new CutAndPasteTransfer();
1932 cap.setForInput(null);
1933 Desktop.addInternalFrame(cap, MessageManager
1934 .formatMessage("label.alignment_output_command", new Object[]
1935 { e.getActionCommand() }), 600, 500);
1937 String[] omitHidden = null;
1939 System.out.println("PROMPT USER HERE"); // TODO: decide if a prompt happens
1940 // or we simply trust the user wants
1941 // wysiwig behaviour
1943 FileFormatI fileFormat = FileFormats.getInstance()
1944 .forName(e.getActionCommand());
1946 new FormatAdapter(ap).formatSequences(fileFormat, ap, true));
1949 public void sequenceFeature_actionPerformed()
1951 SequenceGroup sg = ap.av.getSelectionGroup();
1957 List<SequenceI> seqs = new ArrayList<>();
1958 List<SequenceFeature> features = new ArrayList<>();
1961 * assemble dataset sequences, and template new sequence features,
1962 * for the amend features dialog
1964 int gSize = sg.getSize();
1965 for (int i = 0; i < gSize; i++)
1967 int start = sg.getSequenceAt(i).findPosition(sg.getStartRes());
1968 int end = sg.findEndRes(sg.getSequenceAt(i));
1971 seqs.add(sg.getSequenceAt(i).getDatasetSequence());
1973 new SequenceFeature(null, null, null, start, end, null));
1978 * an entirely gapped region will generate empty lists of sequence / features
1980 if (!seqs.isEmpty())
1982 if (ap.getSeqPanel().seqCanvas.getFeatureRenderer()
1983 .amendFeatures(seqs, features, true, ap))
1985 ap.alignFrame.setShowSeqFeatures(true);
1986 ap.highlightSearchResults(null);
1991 public void textColour_actionPerformed()
1993 SequenceGroup sg = getGroup();
1996 new TextColourChooser().chooseColour(ap, sg);
2000 public void colourByStructure(String pdbid)
2002 Annotation[] anots = ap.av.getStructureSelectionManager()
2003 .colourSequenceFromStructure(sequence, pdbid);
2005 AlignmentAnnotation an = new AlignmentAnnotation("Structure",
2006 "Coloured by " + pdbid, anots);
2008 ap.av.getAlignment().addAnnotation(an);
2009 an.createSequenceMapping(sequence, 0, true);
2010 // an.adjustForAlignment();
2011 ap.av.getAlignment().setAnnotationIndex(an, 0);
2013 ap.adjustAnnotationHeight();
2015 sequence.addAlignmentAnnotation(an);
2019 public void editSequence_actionPerformed(ActionEvent actionEvent)
2021 SequenceGroup sg = ap.av.getSelectionGroup();
2025 if (sequence == null)
2027 sequence = sg.getSequenceAt(0);
2030 EditNameDialog dialog = new EditNameDialog(
2031 sequence.getSequenceAsString(sg.getStartRes(),
2032 sg.getEndRes() + 1),
2033 null, MessageManager.getString("label.edit_sequence"), null,
2034 MessageManager.getString("label.edit_sequence"),
2039 EditCommand editCommand = new EditCommand(
2040 MessageManager.getString("label.edit_sequences"),
2042 dialog.getName().replace(' ', ap.av.getGapCharacter()),
2043 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
2044 sg.getStartRes(), sg.getEndRes() + 1, ap.av.getAlignment());
2046 ap.alignFrame.addHistoryItem(editCommand);
2048 ap.av.firePropertyChange("alignment", null,
2049 ap.av.getAlignment().getSequences());
2055 * Action on user selecting an item from the colour menu (that does not have
2056 * its bespoke action handler)
2061 public void changeColour_actionPerformed(String colourSchemeName)
2063 SequenceGroup sg = getGroup();
2065 * switch to the chosen colour scheme (or null for None)
2067 ColourSchemeI colourScheme = ColourSchemes.getInstance()
2068 .getColourScheme(colourSchemeName, sg,
2069 ap.av.getHiddenRepSequences());
2070 sg.setColourScheme(colourScheme);
2071 if (colourScheme instanceof Blosum62ColourScheme
2072 || colourScheme instanceof PIDColourScheme)
2074 sg.cs.setConsensus(AAFrequency.calculate(
2075 sg.getSequences(ap.av.getHiddenRepSequences()),
2076 sg.getStartRes(), sg.getEndRes() + 1));