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.HiddenMarkovModel;
37 import jalview.datamodel.PDBEntry;
38 import jalview.datamodel.Sequence;
39 import jalview.datamodel.SequenceFeature;
40 import jalview.datamodel.SequenceGroup;
41 import jalview.datamodel.SequenceI;
42 import jalview.gui.ColourMenuHelper.ColourChangeListener;
43 import jalview.hmmer.HMMBuildThread;
44 import jalview.io.FileFormatI;
45 import jalview.io.FileFormats;
46 import jalview.io.FormatAdapter;
47 import jalview.io.SequenceAnnotationReport;
48 import jalview.schemes.Blosum62ColourScheme;
49 import jalview.schemes.ColourSchemeI;
50 import jalview.schemes.ColourSchemes;
51 import jalview.schemes.PIDColourScheme;
52 import jalview.util.GroupUrlLink;
53 import jalview.util.GroupUrlLink.UrlStringTooLongException;
54 import jalview.util.MessageManager;
55 import jalview.util.UrlLink;
57 import java.awt.Color;
58 import java.awt.event.ActionEvent;
59 import java.awt.event.ActionListener;
60 import java.util.ArrayList;
61 import java.util.Arrays;
62 import java.util.Collection;
63 import java.util.Collections;
64 import java.util.Hashtable;
65 import java.util.LinkedHashMap;
66 import java.util.List;
68 import java.util.SortedMap;
69 import java.util.TreeMap;
70 import java.util.Vector;
72 import javax.swing.JCheckBoxMenuItem;
73 import javax.swing.JColorChooser;
74 import javax.swing.JMenu;
75 import javax.swing.JMenuItem;
76 import javax.swing.JPopupMenu;
82 * @version $Revision: 1.118 $
84 public class PopupMenu extends JPopupMenu implements ColourChangeListener
86 JMenu groupMenu = new JMenu();
88 JMenuItem groupName = new JMenuItem();
90 protected JCheckBoxMenuItem abovePIDColour = new JCheckBoxMenuItem();
92 protected JMenuItem modifyPID = new JMenuItem();
94 protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem();
96 protected JMenuItem modifyConservation = new JMenuItem();
100 JMenu sequenceMenu = new JMenu();
102 JMenuItem sequenceName = new JMenuItem();
104 JMenuItem sequenceDetails = new JMenuItem();
106 JMenuItem sequenceSelDetails = new JMenuItem();
108 JMenuItem makeReferenceSeq = new JMenuItem();
110 JMenuItem chooseAnnotations = new JMenuItem();
114 JMenuItem createGroupMenuItem = new JMenuItem();
116 JMenuItem unGroupMenuItem = new JMenuItem();
118 JMenuItem outline = new JMenuItem();
120 JMenu colourMenu = new JMenu();
122 JCheckBoxMenuItem showBoxes = new JCheckBoxMenuItem();
124 JCheckBoxMenuItem showText = new JCheckBoxMenuItem();
126 JCheckBoxMenuItem showColourText = new JCheckBoxMenuItem();
128 JCheckBoxMenuItem displayNonconserved = new JCheckBoxMenuItem();
130 JMenu editMenu = new JMenu();
132 JMenuItem cut = new JMenuItem();
134 JMenuItem copy = new JMenuItem();
136 JMenuItem upperCase = new JMenuItem();
138 JMenuItem lowerCase = new JMenuItem();
140 JMenuItem toggle = new JMenuItem();
142 JMenu pdbMenu = new JMenu();
144 JMenu outputMenu = new JMenu();
146 JMenu seqShowAnnotationsMenu = new JMenu();
148 JMenu seqHideAnnotationsMenu = new JMenu();
150 JMenuItem seqAddReferenceAnnotations = new JMenuItem(
151 MessageManager.getString("label.add_reference_annotations"));
153 JMenu groupShowAnnotationsMenu = new JMenu();
155 JMenu groupHideAnnotationsMenu = new JMenu();
157 JMenuItem groupAddReferenceAnnotations = new JMenuItem(
158 MessageManager.getString("label.add_reference_annotations"));
160 JMenuItem sequenceFeature = new JMenuItem();
162 JMenuItem hmmBuildGroup = new JMenuItem();
164 JMenuItem textColour = new JMenuItem();
166 JMenu jMenu1 = new JMenu();
168 JMenuItem pdbStructureDialog = new JMenuItem();
170 JMenu rnaStructureMenu = new JMenu();
172 JMenuItem editSequence = new JMenuItem();
174 JMenu groupLinksMenu;
176 JMenuItem hideInsertions = new JMenuItem();
179 * Creates a new PopupMenu object.
186 public PopupMenu(final AlignmentPanel ap, Sequence seq,
189 this(ap, seq, links, null);
199 public PopupMenu(final AlignmentPanel ap, final SequenceI seq,
200 List<String> links, List<String> groupLinks)
202 // /////////////////////////////////////////////////////////
203 // If this is activated from the sequence panel, the user may want to
204 // edit or annotate a particular residue. Therefore display the residue menu
206 // If from the IDPanel, we must display the sequence menu
207 // ////////////////////////////////////////////////////////
211 for (String ff : FileFormats.getInstance().getWritableFormats(true))
213 JMenuItem item = new JMenuItem(ff);
215 item.addActionListener(new ActionListener()
218 public void actionPerformed(ActionEvent e)
220 outputText_actionPerformed(e);
224 outputMenu.add(item);
228 * Build menus for annotation types that may be shown or hidden, and for
229 * 'reference annotations' that may be added to the alignment. First for the
230 * currently selected sequence (if there is one):
232 final List<SequenceI> selectedSequence = (seq == null
233 ? Collections.<SequenceI> emptyList() : Arrays.asList(seq));
234 buildAnnotationTypesMenus(seqShowAnnotationsMenu,
235 seqHideAnnotationsMenu, selectedSequence);
236 configureReferenceAnnotationsMenu(seqAddReferenceAnnotations,
240 * And repeat for the current selection group (if there is one):
242 final List<SequenceI> selectedGroup = (ap.av.getSelectionGroup() == null
243 ? Collections.<SequenceI> emptyList()
244 : ap.av.getSelectionGroup().getSequences());
245 buildAnnotationTypesMenus(groupShowAnnotationsMenu,
246 groupHideAnnotationsMenu, selectedGroup);
247 configureReferenceAnnotationsMenu(groupAddReferenceAnnotations,
253 } catch (Exception e)
261 sequenceMenu.setText(sequence.getName());
262 if (seq == ap.av.getAlignment().getSeqrep())
264 makeReferenceSeq.setText(
265 MessageManager.getString("action.unmark_as_reference"));
269 makeReferenceSeq.setText(
270 MessageManager.getString("action.set_as_reference"));
273 if (!ap.av.getAlignment().isNucleotide())
275 remove(rnaStructureMenu);
279 int origCount = rnaStructureMenu.getItemCount();
281 * add menu items to 2D-render any alignment or sequence secondary
282 * structure annotation
284 AlignmentAnnotation[] aas = ap.av.getAlignment()
285 .getAlignmentAnnotation();
288 for (final AlignmentAnnotation aa : aas)
290 if (aa.isValidStruc() && aa.sequenceRef == null)
293 * valid alignment RNA secondary structure annotation
295 menuItem = new JMenuItem();
296 menuItem.setText(MessageManager.formatMessage(
297 "label.2d_rna_structure_line",
300 menuItem.addActionListener(new ActionListener()
303 public void actionPerformed(ActionEvent e)
305 new AppVarna(seq, aa, ap);
308 rnaStructureMenu.add(menuItem);
313 if (seq.getAnnotation() != null)
315 AlignmentAnnotation seqAnns[] = seq.getAnnotation();
316 for (final AlignmentAnnotation aa : seqAnns)
318 if (aa.isValidStruc())
321 * valid sequence RNA secondary structure annotation
323 // TODO: make rnastrucF a bit more nice
324 menuItem = new JMenuItem();
325 menuItem.setText(MessageManager.formatMessage(
326 "label.2d_rna_sequence_name",
329 menuItem.addActionListener(new ActionListener()
332 public void actionPerformed(ActionEvent e)
334 // TODO: VARNA does'nt print gaps in the sequence
335 new AppVarna(seq, aa, ap);
338 rnaStructureMenu.add(menuItem);
342 if (rnaStructureMenu.getItemCount() == origCount)
344 remove(rnaStructureMenu);
348 menuItem = new JMenuItem(
349 MessageManager.getString("action.hide_sequences"));
350 menuItem.addActionListener(new ActionListener()
353 public void actionPerformed(ActionEvent e)
355 hideSequences(false);
360 if (sequence.isHMMConsensusSequence())
362 JMenuItem selectHMM = new JCheckBoxMenuItem();
363 selectHMM.setText(MessageManager.getString("label.select_hmm"));
364 selectHMM.addActionListener(new ActionListener()
368 public void actionPerformed(ActionEvent e)
370 selectHMM_actionPerformed(e);
376 if (ap.av.getSelectionGroup() != null
377 && ap.av.getSelectionGroup().getSize() > 1)
379 menuItem = new JMenuItem(
380 MessageManager.formatMessage("label.represent_group_with",
383 menuItem.addActionListener(new ActionListener()
386 public void actionPerformed(ActionEvent e)
391 sequenceMenu.add(menuItem);
394 if (ap.av.hasHiddenRows())
396 final int index = ap.av.getAlignment().findIndex(seq);
398 if (ap.av.adjustForHiddenSeqs(index)
399 - ap.av.adjustForHiddenSeqs(index - 1) > 1)
401 menuItem = new JMenuItem(
402 MessageManager.getString("action.reveal_sequences"));
403 menuItem.addActionListener(new ActionListener()
406 public void actionPerformed(ActionEvent e)
408 ap.av.showSequence(index);
409 if (ap.overviewPanel != null)
411 ap.overviewPanel.updateOverviewImage();
419 // for the case when no sequences are even visible
420 if (ap.av.hasHiddenRows())
423 menuItem = new JMenuItem(
424 MessageManager.getString("action.reveal_all"));
425 menuItem.addActionListener(new ActionListener()
428 public void actionPerformed(ActionEvent e)
430 ap.av.showAllHiddenSeqs();
431 if (ap.overviewPanel != null)
433 ap.overviewPanel.updateOverviewImage();
442 SequenceGroup sg = ap.av.getSelectionGroup();
443 boolean isDefinedGroup = (sg != null)
444 ? ap.av.getAlignment().getGroups().contains(sg) : false;
446 if (sg != null && sg.getSize() > 0)
448 groupName.setText(MessageManager
449 .getString("label.edit_name_and_description_current_group"));
451 ColourMenuHelper.setColourSelected(colourMenu, sg.getColourScheme());
453 conservationMenuItem.setEnabled(!sg.isNucleotide());
457 if (sg.cs.conservationApplied())
459 conservationMenuItem.setSelected(true);
461 if (sg.cs.getThreshold() > 0)
463 abovePIDColour.setSelected(true);
466 modifyConservation.setEnabled(conservationMenuItem.isSelected());
467 modifyPID.setEnabled(abovePIDColour.isSelected());
468 displayNonconserved.setSelected(sg.getShowNonconserved());
469 showText.setSelected(sg.getDisplayText());
470 showColourText.setSelected(sg.getColourText());
471 showBoxes.setSelected(sg.getDisplayBoxes());
472 // add any groupURLs to the groupURL submenu and make it visible
473 if (groupLinks != null && groupLinks.size() > 0)
475 buildGroupURLMenu(sg, groupLinks);
477 // Add a 'show all structures' for the current selection
478 Hashtable<String, PDBEntry> pdbe = new Hashtable<>(),
479 reppdb = new Hashtable<>();
480 SequenceI sqass = null;
481 for (SequenceI sq : ap.av.getSequenceSelection())
483 Vector<PDBEntry> pes = sq.getDatasetSequence().getAllPDBEntries();
484 if (pes != null && pes.size() > 0)
486 reppdb.put(pes.get(0).getId(), pes.get(0));
487 for (PDBEntry pe : pes)
489 pdbe.put(pe.getId(), pe);
499 final PDBEntry[] pe = pdbe.values()
500 .toArray(new PDBEntry[pdbe.size()]),
501 pr = reppdb.values().toArray(new PDBEntry[reppdb.size()]);
502 final JMenuItem gpdbview, rpdbview;
507 groupMenu.setVisible(false);
508 editMenu.setVisible(false);
513 createGroupMenuItem.setVisible(true);
514 unGroupMenuItem.setVisible(false);
515 jMenu1.setText(MessageManager.getString("action.edit_new_group"));
519 createGroupMenuItem.setVisible(false);
520 unGroupMenuItem.setVisible(true);
521 jMenu1.setText(MessageManager.getString("action.edit_group"));
526 sequenceMenu.setVisible(false);
527 pdbStructureDialog.setVisible(false);
528 rnaStructureMenu.setVisible(false);
531 if (links != null && links.size() > 0)
533 addFeatureLinks(seq, links);
538 * Adds a 'Link' menu item with a sub-menu item for each hyperlink provided.
543 void addFeatureLinks(final SequenceI seq, List<String> links)
545 JMenu linkMenu = new JMenu(MessageManager.getString("action.link"));
546 Map<String, List<String>> linkset = new LinkedHashMap<>();
548 for (String link : links)
550 UrlLink urlLink = null;
553 urlLink = new UrlLink(link);
554 } catch (Exception foo)
556 Cache.log.error("Exception for URLLink '" + link + "'", foo);
560 if (!urlLink.isValid())
562 Cache.log.error(urlLink.getInvalidMessage());
566 urlLink.createLinksFromSeq(seq, linkset);
569 addshowLinks(linkMenu, linkset.values());
571 // disable link menu if there are no valid entries
572 if (linkMenu.getItemCount() > 0)
574 linkMenu.setEnabled(true);
578 linkMenu.setEnabled(false);
581 if (sequence != null)
583 sequenceMenu.add(linkMenu);
593 * Add annotation types to 'Show annotations' and/or 'Hide annotations' menus.
594 * "All" is added first, followed by a separator. Then add any annotation
595 * types associated with the current selection. Separate menus are built for
596 * the selected sequence group (if any), and the selected sequence.
598 * Some annotation rows are always rendered together - these can be identified
599 * by a common graphGroup property > -1. Only one of each group will be marked
600 * as visible (to avoid duplication of the display). For such groups we add a
601 * composite type name, e.g.
603 * IUPredWS (Long), IUPredWS (Short)
607 protected void buildAnnotationTypesMenus(JMenu showMenu, JMenu hideMenu,
608 List<SequenceI> forSequences)
610 showMenu.removeAll();
611 hideMenu.removeAll();
613 final List<String> all = Arrays
615 { MessageManager.getString("label.all") });
616 addAnnotationTypeToShowHide(showMenu, forSequences, "", all, true,
618 addAnnotationTypeToShowHide(hideMenu, forSequences, "", all, true,
620 showMenu.addSeparator();
621 hideMenu.addSeparator();
623 final AlignmentAnnotation[] annotations = ap.getAlignment()
624 .getAlignmentAnnotation();
627 * Find shown/hidden annotations types, distinguished by source (calcId),
628 * and grouped by graphGroup. Using LinkedHashMap means we will retrieve in
629 * the insertion order, which is the order of the annotations on the
632 Map<String, List<List<String>>> shownTypes = new LinkedHashMap<>();
633 Map<String, List<List<String>>> hiddenTypes = new LinkedHashMap<>();
634 AlignmentAnnotationUtils.getShownHiddenTypes(shownTypes, hiddenTypes,
635 AlignmentAnnotationUtils.asList(annotations), forSequences);
637 for (String calcId : hiddenTypes.keySet())
639 for (List<String> type : hiddenTypes.get(calcId))
641 addAnnotationTypeToShowHide(showMenu, forSequences, calcId, type,
645 // grey out 'show annotations' if none are hidden
646 showMenu.setEnabled(!hiddenTypes.isEmpty());
648 for (String calcId : shownTypes.keySet())
650 for (List<String> type : shownTypes.get(calcId))
652 addAnnotationTypeToShowHide(hideMenu, forSequences, calcId, type,
656 // grey out 'hide annotations' if none are shown
657 hideMenu.setEnabled(!shownTypes.isEmpty());
661 * Returns a list of sequences - either the current selection group (if there
662 * is one), else the specified single sequence.
667 protected List<SequenceI> getSequenceScope(SequenceI seq)
669 List<SequenceI> forSequences = null;
670 final SequenceGroup selectionGroup = ap.av.getSelectionGroup();
671 if (selectionGroup != null && selectionGroup.getSize() > 0)
673 forSequences = selectionGroup.getSequences();
677 forSequences = seq == null ? Collections.<SequenceI> emptyList()
678 : Arrays.asList(seq);
684 * Add one annotation type to the 'Show Annotations' or 'Hide Annotations'
687 * @param showOrHideMenu
689 * @param forSequences
690 * the sequences whose annotations may be shown or hidden
695 * if true this is a special label meaning 'All'
696 * @param actionIsShow
697 * if true, the select menu item action is to show the annotation
700 protected void addAnnotationTypeToShowHide(JMenu showOrHideMenu,
701 final List<SequenceI> forSequences, String calcId,
702 final List<String> types, final boolean allTypes,
703 final boolean actionIsShow)
705 String label = types.toString(); // [a, b, c]
706 label = label.substring(1, label.length() - 1); // a, b, c
707 final JMenuItem item = new JMenuItem(label);
708 item.setToolTipText(calcId);
709 item.addActionListener(new ActionListener()
712 public void actionPerformed(ActionEvent e)
714 AlignmentUtils.showOrHideSequenceAnnotations(ap.getAlignment(),
715 types, forSequences, allTypes, actionIsShow);
719 showOrHideMenu.add(item);
722 private void buildGroupURLMenu(SequenceGroup sg, List<String> groupLinks)
725 // TODO: usability: thread off the generation of group url content so root
727 // sequence only URLs
728 // ID/regex match URLs
729 groupLinksMenu = new JMenu(
730 MessageManager.getString("action.group_link"));
731 // three types of url that might be created.
732 JMenu[] linkMenus = new JMenu[] { null,
733 new JMenu(MessageManager.getString("action.ids")),
734 new JMenu(MessageManager.getString("action.sequences")),
735 new JMenu(MessageManager.getString("action.ids_sequences")) };
737 SequenceI[] seqs = ap.av.getSelectionAsNewSequence();
738 String[][] idandseqs = GroupUrlLink.formStrings(seqs);
739 Hashtable<String, Object[]> commonDbrefs = new Hashtable<>();
740 for (int sq = 0; sq < seqs.length; sq++)
743 int start = seqs[sq].findPosition(sg.getStartRes()),
744 end = seqs[sq].findPosition(sg.getEndRes());
745 // just collect ids from dataset sequence
746 // TODO: check if IDs collected from selecton group intersects with the
747 // current selection, too
748 SequenceI sqi = seqs[sq];
749 while (sqi.getDatasetSequence() != null)
751 sqi = sqi.getDatasetSequence();
753 DBRefEntry[] dbr = sqi.getDBRefs();
754 if (dbr != null && dbr.length > 0)
756 for (int d = 0; d < dbr.length; d++)
758 String src = dbr[d].getSource(); // jalview.util.DBRefUtils.getCanonicalName(dbr[d].getSource()).toUpperCase();
759 Object[] sarray = commonDbrefs.get(src);
762 sarray = new Object[2];
763 sarray[0] = new int[] { 0 };
764 sarray[1] = new String[seqs.length];
766 commonDbrefs.put(src, sarray);
769 if (((String[]) sarray[1])[sq] == null)
771 if (!dbr[d].hasMap() || (dbr[d].getMap()
772 .locateMappedRange(start, end) != null))
774 ((String[]) sarray[1])[sq] = dbr[d].getAccessionId();
775 ((int[]) sarray[0])[0]++;
781 // now create group links for all distinct ID/sequence sets.
782 boolean addMenu = false; // indicates if there are any group links to give
784 for (String link : groupLinks)
786 GroupUrlLink urlLink = null;
789 urlLink = new GroupUrlLink(link);
790 } catch (Exception foo)
792 Cache.log.error("Exception for GroupURLLink '" + link + "'", foo);
796 if (!urlLink.isValid())
798 Cache.log.error(urlLink.getInvalidMessage());
801 final String label = urlLink.getLabel();
802 boolean usingNames = false;
803 // Now see which parts of the group apply for this URL
804 String ltarget = urlLink.getTarget(); // jalview.util.DBRefUtils.getCanonicalName(urlLink.getTarget());
805 Object[] idset = commonDbrefs.get(ltarget.toUpperCase());
806 String[] seqstr, ids; // input to makeUrl
809 int numinput = ((int[]) idset[0])[0];
810 String[] allids = ((String[]) idset[1]);
811 seqstr = new String[numinput];
812 ids = new String[numinput];
813 for (int sq = 0, idcount = 0; sq < seqs.length; sq++)
815 if (allids[sq] != null)
817 ids[idcount] = allids[sq];
818 seqstr[idcount++] = idandseqs[1][sq];
824 // just use the id/seq set
825 seqstr = idandseqs[1];
829 // and try and make the groupURL!
831 Object[] urlset = null;
834 urlset = urlLink.makeUrlStubs(ids, seqstr,
835 "FromJalview" + System.currentTimeMillis(), false);
836 } catch (UrlStringTooLongException e)
841 int type = urlLink.getGroupURLType() & 3;
842 // first two bits ofurlLink type bitfield are sequenceids and sequences
843 // TODO: FUTURE: ensure the groupURL menu structure can be generalised
844 addshowLink(linkMenus[type], label + (((type & 1) == 1)
845 ? ("(" + (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);
929 MessageManager.formatMessage("label.open_url_seqs_param",
931 { urlgenerator.getUrl_prefix(),
932 urlgenerator.getNumberInvolved(urlstub) }));
933 // TODO: put in info about what is being sent.
934 item.addActionListener(new ActionListener()
937 public void actionPerformed(ActionEvent e)
939 new Thread(new Runnable()
947 showLink(urlgenerator.constructFrom(urlstub));
948 } catch (UrlStringTooLongException e2)
966 private void jbInit() throws Exception
968 groupMenu.setText(MessageManager.getString("label.selection"));
969 groupName.setText(MessageManager.getString("label.name"));
970 groupName.addActionListener(new ActionListener()
973 public void actionPerformed(ActionEvent e)
975 groupName_actionPerformed();
978 sequenceMenu.setText(MessageManager.getString("label.sequence"));
979 sequenceName.setText(
980 MessageManager.getString("label.edit_name_description"));
981 sequenceName.addActionListener(new ActionListener()
984 public void actionPerformed(ActionEvent e)
986 sequenceName_actionPerformed();
990 .setText(MessageManager.getString("action.choose_annotations"));
991 chooseAnnotations.addActionListener(new ActionListener()
994 public void actionPerformed(ActionEvent e)
996 chooseAnnotations_actionPerformed(e);
1000 .setText(MessageManager.getString("label.sequence_details"));
1001 sequenceDetails.addActionListener(new ActionListener()
1004 public void actionPerformed(ActionEvent e)
1006 sequenceDetails_actionPerformed();
1010 .setText(MessageManager.getString("label.sequence_details"));
1011 sequenceSelDetails.addActionListener(new ActionListener()
1014 public void actionPerformed(ActionEvent e)
1016 sequenceSelectionDetails_actionPerformed();
1021 .setText(MessageManager.getString("action.remove_group"));
1022 unGroupMenuItem.addActionListener(new ActionListener()
1025 public void actionPerformed(ActionEvent e)
1027 unGroupMenuItem_actionPerformed();
1031 .setText(MessageManager.getString("action.create_group"));
1032 createGroupMenuItem.addActionListener(new ActionListener()
1035 public void actionPerformed(ActionEvent e)
1037 createGroupMenuItem_actionPerformed();
1041 outline.setText(MessageManager.getString("action.border_colour"));
1042 outline.addActionListener(new ActionListener()
1045 public void actionPerformed(ActionEvent e)
1047 outline_actionPerformed();
1050 showBoxes.setText(MessageManager.getString("action.boxes"));
1051 showBoxes.setState(true);
1052 showBoxes.addActionListener(new ActionListener()
1055 public void actionPerformed(ActionEvent e)
1057 showBoxes_actionPerformed();
1060 showText.setText(MessageManager.getString("action.text"));
1061 showText.setState(true);
1062 showText.addActionListener(new ActionListener()
1065 public void actionPerformed(ActionEvent e)
1067 showText_actionPerformed();
1070 showColourText.setText(MessageManager.getString("label.colour_text"));
1071 showColourText.addActionListener(new ActionListener()
1074 public void actionPerformed(ActionEvent e)
1076 showColourText_actionPerformed();
1080 .setText(MessageManager.getString("label.show_non_conserved"));
1081 displayNonconserved.setState(true);
1082 displayNonconserved.addActionListener(new ActionListener()
1085 public void actionPerformed(ActionEvent e)
1087 showNonconserved_actionPerformed();
1090 editMenu.setText(MessageManager.getString("action.edit"));
1091 cut.setText(MessageManager.getString("action.cut"));
1092 cut.addActionListener(new ActionListener()
1095 public void actionPerformed(ActionEvent e)
1097 cut_actionPerformed();
1100 upperCase.setText(MessageManager.getString("label.to_upper_case"));
1101 upperCase.addActionListener(new ActionListener()
1104 public void actionPerformed(ActionEvent e)
1109 copy.setText(MessageManager.getString("action.copy"));
1110 copy.addActionListener(new ActionListener()
1113 public void actionPerformed(ActionEvent e)
1115 copy_actionPerformed();
1118 lowerCase.setText(MessageManager.getString("label.to_lower_case"));
1119 lowerCase.addActionListener(new ActionListener()
1122 public void actionPerformed(ActionEvent e)
1127 toggle.setText(MessageManager.getString("label.toggle_case"));
1128 toggle.addActionListener(new ActionListener()
1131 public void actionPerformed(ActionEvent e)
1137 MessageManager.getString("label.out_to_textbox") + "...");
1138 seqShowAnnotationsMenu
1139 .setText(MessageManager.getString("label.show_annotations"));
1140 seqHideAnnotationsMenu
1141 .setText(MessageManager.getString("label.hide_annotations"));
1142 groupShowAnnotationsMenu
1143 .setText(MessageManager.getString("label.show_annotations"));
1144 groupHideAnnotationsMenu
1145 .setText(MessageManager.getString("label.hide_annotations"));
1146 sequenceFeature.setText(
1147 MessageManager.getString("label.create_sequence_feature"));
1148 sequenceFeature.addActionListener(new ActionListener()
1151 public void actionPerformed(ActionEvent e)
1153 sequenceFeature_actionPerformed();
1156 hmmBuildGroup.setText(MessageManager.getString("label.group_hmmbuild"));
1157 hmmBuildGroup.addActionListener(new ActionListener()
1160 public void actionPerformed(ActionEvent e)
1162 hmmBuildGroup_actionPerformed();
1165 jMenu1.setText(MessageManager.getString("label.group"));
1166 pdbStructureDialog.setText(
1167 MessageManager.getString("label.show_pdbstruct_dialog"));
1168 pdbStructureDialog.addActionListener(new ActionListener()
1171 public void actionPerformed(ActionEvent actionEvent)
1173 SequenceI[] selectedSeqs = new SequenceI[] { sequence };
1174 if (ap.av.getSelectionGroup() != null)
1176 selectedSeqs = ap.av.getSequenceSelection();
1178 new StructureChooser(selectedSeqs, sequence, ap);
1183 .setText(MessageManager.getString("label.view_rna_structure"));
1185 // colStructureMenu.setText("Colour By Structure");
1186 editSequence.setText(
1187 MessageManager.getString("label.edit_sequence") + "...");
1188 editSequence.addActionListener(new ActionListener()
1191 public void actionPerformed(ActionEvent actionEvent)
1193 editSequence_actionPerformed(actionEvent);
1196 makeReferenceSeq.setText(
1197 MessageManager.getString("label.mark_as_representative"));
1198 makeReferenceSeq.addActionListener(new ActionListener()
1202 public void actionPerformed(ActionEvent actionEvent)
1204 makeReferenceSeq_actionPerformed(actionEvent);
1209 .setText(MessageManager.getString("label.hide_insertions"));
1210 hideInsertions.addActionListener(new ActionListener()
1214 public void actionPerformed(ActionEvent e)
1216 hideInsertions_actionPerformed(e);
1220 groupMenu.add(sequenceSelDetails);
1223 add(rnaStructureMenu);
1224 add(pdbStructureDialog);
1225 if (sequence != null)
1227 add(hideInsertions);
1229 // annotations configuration panel suppressed for now
1230 // groupMenu.add(chooseAnnotations);
1233 * Add show/hide annotations to the Sequence menu, and to the Selection menu
1234 * (if a selection group is in force).
1236 sequenceMenu.add(seqShowAnnotationsMenu);
1237 sequenceMenu.add(seqHideAnnotationsMenu);
1238 sequenceMenu.add(seqAddReferenceAnnotations);
1239 groupMenu.add(groupShowAnnotationsMenu);
1240 groupMenu.add(groupHideAnnotationsMenu);
1241 groupMenu.add(groupAddReferenceAnnotations);
1242 groupMenu.add(editMenu);
1243 groupMenu.add(outputMenu);
1244 groupMenu.add(sequenceFeature);
1245 groupMenu.add(createGroupMenuItem);
1246 groupMenu.add(unGroupMenuItem);
1247 groupMenu.add(jMenu1);
1248 sequenceMenu.add(sequenceName);
1249 sequenceMenu.add(sequenceDetails);
1250 sequenceMenu.add(makeReferenceSeq);
1257 editMenu.add(editSequence);
1258 editMenu.add(upperCase);
1259 editMenu.add(lowerCase);
1260 editMenu.add(toggle);
1261 // JBPNote: These shouldn't be added here - should appear in a generic
1262 // 'apply web service to this sequence menu'
1263 // pdbMenu.add(RNAFold);
1264 // pdbMenu.add(ContraFold);
1265 jMenu1.add(groupName);
1266 jMenu1.add(colourMenu);
1267 jMenu1.add(showBoxes);
1268 jMenu1.add(showText);
1269 jMenu1.add(showColourText);
1270 jMenu1.add(outline);
1271 jMenu1.add(displayNonconserved);
1274 protected void hmmBuildGroup_actionPerformed()
1276 new Thread(new HMMBuildThread(ap.alignFrame)).start();
1281 protected void selectHMM_actionPerformed(ActionEvent e)
1283 HiddenMarkovModel hmm = ap.av.getSequenceSelection()[0].getHMM();
1284 ap.av.setSelectedHMM(hmm);
1288 * Constructs the entries for the colour menu
1290 protected void initColourMenu()
1292 colourMenu.setText(MessageManager.getString("label.group_colour"));
1293 textColour.setText(MessageManager.getString("label.text_colour"));
1294 textColour.addActionListener(new ActionListener()
1297 public void actionPerformed(ActionEvent e)
1299 textColour_actionPerformed();
1303 abovePIDColour.setText(
1304 MessageManager.getString("label.above_identity_threshold"));
1305 abovePIDColour.addActionListener(new ActionListener()
1308 public void actionPerformed(ActionEvent e)
1310 abovePIDColour_actionPerformed(abovePIDColour.isSelected());
1315 MessageManager.getString("label.modify_identity_threshold"));
1316 modifyPID.addActionListener(new ActionListener()
1319 public void actionPerformed(ActionEvent e)
1321 modifyPID_actionPerformed();
1325 conservationMenuItem
1326 .setText(MessageManager.getString("action.by_conservation"));
1327 conservationMenuItem.addActionListener(new ActionListener()
1330 public void actionPerformed(ActionEvent e)
1332 conservationMenuItem_actionPerformed(
1333 conservationMenuItem.isSelected());
1337 modifyConservation.setText(MessageManager
1338 .getString("label.modify_conservation_threshold"));
1339 modifyConservation.addActionListener(new ActionListener()
1342 public void actionPerformed(ActionEvent e)
1344 modifyConservation_actionPerformed();
1350 * Builds the group colour sub-menu, including any user-defined colours which
1351 * were loaded at startup or during the Jalview session
1353 protected void buildColourMenu()
1355 SequenceGroup sg = ap.av.getSelectionGroup();
1359 * popup menu with no sequence group scope
1363 colourMenu.removeAll();
1364 colourMenu.add(textColour);
1365 colourMenu.addSeparator();
1367 ColourMenuHelper.addMenuItems(colourMenu, this, sg, false);
1369 colourMenu.addSeparator();
1370 colourMenu.add(conservationMenuItem);
1371 colourMenu.add(modifyConservation);
1372 colourMenu.add(abovePIDColour);
1373 colourMenu.add(modifyPID);
1376 protected void modifyConservation_actionPerformed()
1378 SequenceGroup sg = getGroup();
1381 SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
1382 SliderPanel.showConservationSlider();
1386 protected void modifyPID_actionPerformed()
1388 SequenceGroup sg = getGroup();
1391 // int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
1393 // sg.cs.setThreshold(threshold, ap.av.isIgnoreGapsConsensus());
1394 SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup().getName());
1395 SliderPanel.showPIDSlider();
1400 * Check for any annotations on the underlying dataset sequences (for the
1401 * current selection group) which are not 'on the alignment'.If any are found,
1402 * enable the option to add them to the alignment. The criteria for 'on the
1403 * alignment' is finding an alignment annotation on the alignment, matched on
1404 * calcId, label and sequenceRef.
1406 * A tooltip is also constructed that displays the source (calcId) and type
1407 * (label) of the annotations that can be added.
1410 * @param forSequences
1412 protected void configureReferenceAnnotationsMenu(JMenuItem menuItem,
1413 List<SequenceI> forSequences)
1415 menuItem.setEnabled(false);
1418 * Temporary store to hold distinct calcId / type pairs for the tooltip.
1419 * Using TreeMap means calcIds are shown in alphabetical order.
1421 SortedMap<String, String> tipEntries = new TreeMap<>();
1422 final Map<SequenceI, List<AlignmentAnnotation>> candidates = new LinkedHashMap<>();
1423 AlignmentI al = this.ap.av.getAlignment();
1424 AlignmentUtils.findAddableReferenceAnnotations(forSequences, tipEntries,
1426 if (!candidates.isEmpty())
1428 StringBuilder tooltip = new StringBuilder(64);
1429 tooltip.append(MessageManager.getString("label.add_annotations_for"));
1432 * Found annotations that could be added. Enable the menu item, and
1433 * configure its tooltip and action.
1435 menuItem.setEnabled(true);
1436 for (String calcId : tipEntries.keySet())
1438 tooltip.append("<br/>" + calcId + "/" + tipEntries.get(calcId));
1440 String tooltipText = JvSwingUtils.wrapTooltip(true,
1441 tooltip.toString());
1442 menuItem.setToolTipText(tooltipText);
1444 menuItem.addActionListener(new ActionListener()
1447 public void actionPerformed(ActionEvent e)
1449 addReferenceAnnotations_actionPerformed(candidates);
1456 * Add annotations to the sequences and to the alignment.
1459 * a map whose keys are sequences on the alignment, and values a list
1460 * of annotations to add to each sequence
1462 protected void addReferenceAnnotations_actionPerformed(
1463 Map<SequenceI, List<AlignmentAnnotation>> candidates)
1465 final SequenceGroup selectionGroup = this.ap.av.getSelectionGroup();
1466 final AlignmentI alignment = this.ap.getAlignment();
1467 AlignmentUtils.addReferenceAnnotations(candidates, alignment,
1472 protected void makeReferenceSeq_actionPerformed(ActionEvent actionEvent)
1474 if (!ap.av.getAlignment().hasSeqrep())
1476 // initialise the display flags so the user sees something happen
1477 ap.av.setDisplayReferenceSeq(true);
1478 ap.av.setColourByReferenceSeq(true);
1479 ap.av.getAlignment().setSeqrep(sequence);
1483 if (ap.av.getAlignment().getSeqrep() == sequence)
1485 ap.av.getAlignment().setSeqrep(null);
1489 ap.av.getAlignment().setSeqrep(sequence);
1495 protected void hideInsertions_actionPerformed(ActionEvent actionEvent)
1497 if (sequence != null)
1499 /* ColumnSelection cs = ap.av.getColumnSelection();
1502 cs = new ColumnSelection();
1504 cs.hideInsertionsFor(sequence);
1505 ap.av.setColumnSelection(cs);*/
1507 HiddenColumns hidden = ap.av.getAlignment().getHiddenColumns();
1510 hidden = new HiddenColumns();
1512 hidden.hideInsertionsFor(sequence);
1513 ap.av.getAlignment().setHiddenColumns(hidden);
1518 protected void sequenceSelectionDetails_actionPerformed()
1520 createSequenceDetailsReport(ap.av.getSequenceSelection());
1523 protected void sequenceDetails_actionPerformed()
1525 createSequenceDetailsReport(new SequenceI[] { sequence });
1528 public void createSequenceDetailsReport(SequenceI[] sequences)
1530 CutAndPasteHtmlTransfer cap = new CutAndPasteHtmlTransfer();
1531 StringBuilder contents = new StringBuilder(128);
1532 for (SequenceI seq : sequences)
1534 contents.append("<p><h2>"
1535 + MessageManager.formatMessage(
1536 "label.create_sequence_details_report_annotation_for",
1538 { seq.getDisplayId(true) })
1540 new SequenceAnnotationReport(null)
1541 .createSequenceAnnotationReport(contents, seq, true, true,
1542 (ap.getSeqPanel().seqCanvas.fr != null)
1543 ? ap.getSeqPanel().seqCanvas.fr.getMinMax()
1545 contents.append("</p>");
1547 cap.setText("<html>" + contents.toString() + "</html>");
1549 Desktop.addInternalFrame(cap, MessageManager.formatMessage(
1550 "label.sequence_details_for",
1551 (sequences.length == 1
1553 { sequences[0].getDisplayId(true) }
1555 { MessageManager.getString("label.selection") })), 500, 400);
1559 protected void showNonconserved_actionPerformed()
1561 getGroup().setShowNonconserved(displayNonconserved.isSelected());
1566 * call to refresh view after settings change
1570 ap.updateAnnotation();
1571 ap.paintAlignment(true);
1573 PaintRefresher.Refresh(this, ap.av.getSequenceSetId());
1577 * protected void covariationColour_actionPerformed() { getGroup().cs = new
1578 * CovariationColourScheme(sequence.getAnnotation()[0]); refresh(); }
1588 public void abovePIDColour_actionPerformed(boolean selected)
1590 SequenceGroup sg = getGroup();
1598 sg.cs.setConsensus(AAFrequency.calculate(
1599 sg.getSequences(ap.av.getHiddenRepSequences()),
1600 sg.getStartRes(), sg.getEndRes() + 1));
1602 int threshold = SliderPanel.setPIDSliderSource(ap,
1603 sg.getGroupColourScheme(), getGroup().getName());
1605 sg.cs.setThreshold(threshold, ap.av.isIgnoreGapsConsensus());
1607 SliderPanel.showPIDSlider();
1610 // remove PIDColouring
1612 sg.cs.setThreshold(0, ap.av.isIgnoreGapsConsensus());
1613 SliderPanel.hidePIDSlider();
1615 modifyPID.setEnabled(selected);
1621 * Open a panel where the user can choose which types of sequence annotation
1626 protected void chooseAnnotations_actionPerformed(ActionEvent e)
1628 // todo correct way to guard against opening a duplicate panel?
1629 new AnnotationChooser(ap);
1638 public void conservationMenuItem_actionPerformed(boolean selected)
1640 SequenceGroup sg = getGroup();
1648 // JBPNote: Conservation name shouldn't be i18n translated
1649 Conservation c = new Conservation("Group",
1650 sg.getSequences(ap.av.getHiddenRepSequences()),
1651 sg.getStartRes(), sg.getEndRes() + 1);
1654 c.verdict(false, ap.av.getConsPercGaps());
1655 sg.cs.setConservation(c);
1657 SliderPanel.setConservationSlider(ap, sg.getGroupColourScheme(),
1659 SliderPanel.showConservationSlider();
1662 // remove ConservationColouring
1664 sg.cs.setConservation(null);
1665 SliderPanel.hideConservationSlider();
1667 modifyConservation.setEnabled(selected);
1678 protected void groupName_actionPerformed()
1681 SequenceGroup sg = getGroup();
1682 EditNameDialog dialog = new EditNameDialog(sg.getName(),
1683 sg.getDescription(),
1684 " " + MessageManager.getString("label.group_name") + " ",
1685 MessageManager.getString("label.group_description") + " ",
1686 MessageManager.getString("label.edit_group_name_description"),
1694 sg.setName(dialog.getName());
1695 sg.setDescription(dialog.getDescription());
1700 * Get selection group - adding it to the alignment if necessary.
1702 * @return sequence group to operate on
1704 SequenceGroup getGroup()
1706 SequenceGroup sg = ap.av.getSelectionGroup();
1707 // this method won't add a new group if it already exists
1710 ap.av.getAlignment().addGroup(sg);
1722 void sequenceName_actionPerformed()
1724 EditNameDialog dialog = new EditNameDialog(sequence.getName(),
1725 sequence.getDescription(),
1726 " " + MessageManager.getString("label.sequence_name")
1728 MessageManager.getString("label.sequence_description") + " ",
1730 .getString("label.edit_sequence_name_description"),
1738 if (dialog.getName() != null)
1740 if (dialog.getName().indexOf(" ") > -1)
1742 JvOptionPane.showMessageDialog(ap,
1744 .getString("label.spaces_converted_to_backslashes"),
1746 .getString("label.no_spaces_allowed_sequence_name"),
1747 JvOptionPane.WARNING_MESSAGE);
1750 sequence.setName(dialog.getName().replace(' ', '_'));
1751 ap.paintAlignment(false);
1754 sequence.setDescription(dialog.getDescription());
1756 ap.av.firePropertyChange("alignment", null,
1757 ap.av.getAlignment().getSequences());
1767 void unGroupMenuItem_actionPerformed()
1769 SequenceGroup sg = ap.av.getSelectionGroup();
1770 ap.av.getAlignment().deleteGroup(sg);
1771 ap.av.setSelectionGroup(null);
1775 void createGroupMenuItem_actionPerformed()
1777 getGroup(); // implicitly creates group - note - should apply defaults / use
1778 // standard alignment window logic for this
1788 protected void outline_actionPerformed()
1790 SequenceGroup sg = getGroup();
1791 Color col = JColorChooser.showDialog(this,
1792 MessageManager.getString("label.select_outline_colour"),
1797 sg.setOutlineColour(col);
1809 public void showBoxes_actionPerformed()
1811 getGroup().setDisplayBoxes(showBoxes.isSelected());
1821 public void showText_actionPerformed()
1823 getGroup().setDisplayText(showText.isSelected());
1833 public void showColourText_actionPerformed()
1835 getGroup().setColourText(showColourText.isSelected());
1839 public void showLink(String url)
1843 jalview.util.BrowserLauncher.openURL(url);
1844 } catch (Exception ex)
1846 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
1847 MessageManager.getString("label.web_browser_not_found_unix"),
1848 MessageManager.getString("label.web_browser_not_found"),
1849 JvOptionPane.WARNING_MESSAGE);
1851 ex.printStackTrace();
1855 void hideSequences(boolean representGroup)
1857 ap.av.hideSequences(sequence, representGroup);
1860 public void copy_actionPerformed()
1862 ap.alignFrame.copy_actionPerformed(null);
1865 public void cut_actionPerformed()
1867 ap.alignFrame.cut_actionPerformed(null);
1870 void changeCase(ActionEvent e)
1872 Object source = e.getSource();
1873 SequenceGroup sg = ap.av.getSelectionGroup();
1877 List<int[]> startEnd = ap.av.getVisibleRegionBoundaries(
1878 sg.getStartRes(), sg.getEndRes() + 1);
1883 if (source == toggle)
1885 description = MessageManager.getString("label.toggle_case");
1886 caseChange = ChangeCaseCommand.TOGGLE_CASE;
1888 else if (source == upperCase)
1890 description = MessageManager.getString("label.to_upper_case");
1891 caseChange = ChangeCaseCommand.TO_UPPER;
1895 description = MessageManager.getString("label.to_lower_case");
1896 caseChange = ChangeCaseCommand.TO_LOWER;
1899 ChangeCaseCommand caseCommand = new ChangeCaseCommand(description,
1900 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
1901 startEnd, caseChange);
1903 ap.alignFrame.addHistoryItem(caseCommand);
1905 ap.av.firePropertyChange("alignment", null,
1906 ap.av.getAlignment().getSequences());
1911 public void outputText_actionPerformed(ActionEvent e)
1913 CutAndPasteTransfer cap = new CutAndPasteTransfer();
1914 cap.setForInput(null);
1915 Desktop.addInternalFrame(cap,
1916 MessageManager.formatMessage("label.alignment_output_command",
1918 { e.getActionCommand() }), 600, 500);
1920 String[] omitHidden = null;
1922 System.out.println("PROMPT USER HERE"); // TODO: decide if a prompt happens
1923 // or we simply trust the user wants
1924 // wysiwig behaviour
1926 FileFormatI fileFormat = FileFormats.getInstance()
1927 .forName(e.getActionCommand());
1929 new FormatAdapter(ap).formatSequences(fileFormat, ap, true));
1932 public void sequenceFeature_actionPerformed()
1934 SequenceGroup sg = ap.av.getSelectionGroup();
1940 List<SequenceI> seqs = new ArrayList<>();
1941 List<SequenceFeature> features = new ArrayList<>();
1944 * assemble dataset sequences, and template new sequence features,
1945 * for the amend features dialog
1947 int gSize = sg.getSize();
1948 for (int i = 0; i < gSize; i++)
1950 int start = sg.getSequenceAt(i).findPosition(sg.getStartRes());
1951 int end = sg.findEndRes(sg.getSequenceAt(i));
1954 seqs.add(sg.getSequenceAt(i).getDatasetSequence());
1956 new SequenceFeature(null, null, null, start, end, null));
1960 if (ap.getSeqPanel().seqCanvas.getFeatureRenderer().amendFeatures(seqs,
1961 features, true, ap))
1963 ap.alignFrame.setShowSeqFeatures(true);
1964 ap.highlightSearchResults(null);
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));