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.ColumnSelection;
35 import jalview.datamodel.DBRefEntry;
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.AnnotationColourGradient;
47 import jalview.schemes.Blosum62ColourScheme;
48 import jalview.schemes.ColourSchemeI;
49 import jalview.schemes.ColourSchemes;
50 import jalview.schemes.PIDColourScheme;
51 import jalview.schemes.ResidueColourScheme;
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.Arrays;
61 import java.util.Collection;
62 import java.util.Collections;
63 import java.util.Hashtable;
64 import java.util.LinkedHashMap;
65 import java.util.List;
67 import java.util.SortedMap;
68 import java.util.TreeMap;
69 import java.util.Vector;
71 import javax.swing.JCheckBoxMenuItem;
72 import javax.swing.JColorChooser;
73 import javax.swing.JMenu;
74 import javax.swing.JMenuItem;
75 import javax.swing.JPopupMenu;
81 * @version $Revision: 1.118 $
83 public class PopupMenu extends JPopupMenu implements ColourChangeListener
85 JMenu groupMenu = new JMenu();
87 JMenuItem groupName = new JMenuItem();
89 protected JCheckBoxMenuItem abovePIDColour = new JCheckBoxMenuItem();
91 protected JMenuItem modifyPID = new JMenuItem();
93 protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem();
95 protected JMenuItem modifyConservation = new JMenuItem();
99 JMenu sequenceMenu = new JMenu();
101 JMenuItem sequenceName = new JMenuItem();
103 JMenuItem sequenceDetails = new JMenuItem();
105 JMenuItem sequenceSelDetails = new JMenuItem();
107 JMenuItem makeReferenceSeq = new JMenuItem();
109 JMenuItem chooseAnnotations = new JMenuItem();
113 JMenuItem createGroupMenuItem = new JMenuItem();
115 JMenuItem unGroupMenuItem = new JMenuItem();
117 JMenuItem outline = new JMenuItem();
119 JMenu colourMenu = new JMenu();
121 JCheckBoxMenuItem showBoxes = new JCheckBoxMenuItem();
123 JCheckBoxMenuItem showText = new JCheckBoxMenuItem();
125 JCheckBoxMenuItem showColourText = new JCheckBoxMenuItem();
127 JCheckBoxMenuItem displayNonconserved = new JCheckBoxMenuItem();
129 JMenu editMenu = new JMenu();
131 JMenuItem cut = new JMenuItem();
133 JMenuItem copy = new JMenuItem();
135 JMenuItem upperCase = new JMenuItem();
137 JMenuItem lowerCase = new JMenuItem();
139 JMenuItem toggle = new JMenuItem();
141 JMenu pdbMenu = new JMenu();
143 JMenu outputMenu = new JMenu();
145 JMenu seqShowAnnotationsMenu = new JMenu();
147 JMenu seqHideAnnotationsMenu = new JMenu();
149 JMenuItem seqAddReferenceAnnotations = new JMenuItem(
150 MessageManager.getString("label.add_reference_annotations"));
152 JMenu groupShowAnnotationsMenu = new JMenu();
154 JMenu groupHideAnnotationsMenu = new JMenu();
156 JMenuItem groupAddReferenceAnnotations = new JMenuItem(
157 MessageManager.getString("label.add_reference_annotations"));
159 JMenuItem sequenceFeature = new JMenuItem();
161 JMenuItem textColour = new JMenuItem();
163 JMenu jMenu1 = new JMenu();
165 JMenuItem pdbStructureDialog = new JMenuItem();
167 JMenu rnaStructureMenu = new JMenu();
169 JMenuItem editSequence = new JMenuItem();
171 JMenu groupLinksMenu;
173 JMenuItem hideInsertions = new JMenuItem();
176 * Creates a new PopupMenu object.
183 public PopupMenu(final AlignmentPanel ap, Sequence seq, List<String> links)
185 this(ap, seq, links, null);
195 public PopupMenu(final AlignmentPanel ap, final SequenceI seq,
196 List<String> links, List<String> groupLinks)
198 // /////////////////////////////////////////////////////////
199 // If this is activated from the sequence panel, the user may want to
200 // edit or annotate a particular residue. Therefore display the residue menu
202 // If from the IDPanel, we must display the sequence menu
203 // ////////////////////////////////////////////////////////
207 for (String ff : FileFormats.getInstance().getWritableFormats(true))
209 JMenuItem item = new JMenuItem(ff);
211 item.addActionListener(new ActionListener()
214 public void actionPerformed(ActionEvent e)
216 outputText_actionPerformed(e);
220 outputMenu.add(item);
224 * Build menus for annotation types that may be shown or hidden, and for
225 * 'reference annotations' that may be added to the alignment. First for the
226 * currently selected sequence (if there is one):
228 final List<SequenceI> selectedSequence = (seq == null ? Collections
229 .<SequenceI> emptyList() : Arrays.asList(seq));
230 buildAnnotationTypesMenus(seqShowAnnotationsMenu,
231 seqHideAnnotationsMenu, selectedSequence);
232 configureReferenceAnnotationsMenu(seqAddReferenceAnnotations,
236 * And repeat for the current selection group (if there is one):
238 final List<SequenceI> selectedGroup = (ap.av.getSelectionGroup() == null ? Collections
239 .<SequenceI> emptyList() : ap.av.getSelectionGroup()
241 buildAnnotationTypesMenus(groupShowAnnotationsMenu,
242 groupHideAnnotationsMenu, selectedGroup);
243 configureReferenceAnnotationsMenu(groupAddReferenceAnnotations,
249 } catch (Exception e)
257 sequenceMenu.setText(sequence.getName());
258 if (seq == ap.av.getAlignment().getSeqrep())
260 makeReferenceSeq.setText(MessageManager
261 .getString("action.unmark_as_reference"));
265 makeReferenceSeq.setText(MessageManager
266 .getString("action.set_as_reference"));
269 if (!ap.av.getAlignment().isNucleotide())
271 remove(rnaStructureMenu);
275 int origCount = rnaStructureMenu.getItemCount();
277 * add menu items to 2D-render any alignment or sequence secondary
278 * structure annotation
280 AlignmentAnnotation[] aas = ap.av.getAlignment()
281 .getAlignmentAnnotation();
284 for (final AlignmentAnnotation aa : aas)
286 if (aa.isValidStruc() && aa.sequenceRef == null)
289 * valid alignment RNA secondary structure annotation
291 menuItem = new JMenuItem();
292 menuItem.setText(MessageManager.formatMessage(
293 "label.2d_rna_structure_line",
294 new Object[] { aa.label }));
295 menuItem.addActionListener(new ActionListener()
298 public void actionPerformed(ActionEvent e)
300 new AppVarna(seq, aa, ap);
303 rnaStructureMenu.add(menuItem);
308 if (seq.getAnnotation() != null)
310 AlignmentAnnotation seqAnns[] = seq.getAnnotation();
311 for (final AlignmentAnnotation aa : seqAnns)
313 if (aa.isValidStruc())
316 * valid sequence RNA secondary structure annotation
318 // TODO: make rnastrucF a bit more nice
319 menuItem = new JMenuItem();
320 menuItem.setText(MessageManager.formatMessage(
321 "label.2d_rna_sequence_name",
322 new Object[] { seq.getName() }));
323 menuItem.addActionListener(new ActionListener()
326 public void actionPerformed(ActionEvent e)
328 // TODO: VARNA does'nt print gaps in the sequence
329 new AppVarna(seq, aa, ap);
332 rnaStructureMenu.add(menuItem);
336 if (rnaStructureMenu.getItemCount() == origCount)
338 remove(rnaStructureMenu);
342 menuItem = new JMenuItem(
343 MessageManager.getString("action.hide_sequences"));
344 menuItem.addActionListener(new ActionListener()
347 public void actionPerformed(ActionEvent e)
349 hideSequences(false);
354 if (ap.av.getSelectionGroup() != null
355 && ap.av.getSelectionGroup().getSize() > 1)
357 menuItem = new JMenuItem(MessageManager.formatMessage(
358 "label.represent_group_with",
359 new Object[] { seq.getName() }));
360 menuItem.addActionListener(new ActionListener()
363 public void actionPerformed(ActionEvent e)
368 sequenceMenu.add(menuItem);
371 if (ap.av.hasHiddenRows())
373 final int index = ap.av.getAlignment().findIndex(seq);
375 if (ap.av.adjustForHiddenSeqs(index)
376 - ap.av.adjustForHiddenSeqs(index - 1) > 1)
378 menuItem = new JMenuItem(
379 MessageManager.getString("action.reveal_sequences"));
380 menuItem.addActionListener(new ActionListener()
383 public void actionPerformed(ActionEvent e)
385 ap.av.showSequence(index);
386 if (ap.overviewPanel != null)
388 ap.overviewPanel.updateOverviewImage();
396 // for the case when no sequences are even visible
397 if (ap.av.hasHiddenRows())
400 menuItem = new JMenuItem(
401 MessageManager.getString("action.reveal_all"));
402 menuItem.addActionListener(new ActionListener()
405 public void actionPerformed(ActionEvent e)
407 ap.av.showAllHiddenSeqs();
408 if (ap.overviewPanel != null)
410 ap.overviewPanel.updateOverviewImage();
419 SequenceGroup sg = ap.av.getSelectionGroup();
420 boolean isDefinedGroup = (sg != null) ? ap.av.getAlignment()
421 .getGroups().contains(sg) : false;
423 if (sg != null && sg.getSize() > 0)
425 groupName.setText(MessageManager
426 .getString("label.edit_name_and_description_current_group"));
428 ColourMenuHelper.setColourSelected(colourMenu, sg.getColourScheme());
430 conservationMenuItem.setEnabled(!sg.isNucleotide());
434 if (sg.cs.conservationApplied())
436 conservationMenuItem.setSelected(true);
438 if (sg.cs.getThreshold() > 0)
440 abovePIDColour.setSelected(true);
443 modifyConservation.setEnabled(conservationMenuItem.isSelected());
444 modifyPID.setEnabled(abovePIDColour.isSelected());
445 displayNonconserved.setSelected(sg.getShowNonconserved());
446 showText.setSelected(sg.getDisplayText());
447 showColourText.setSelected(sg.getColourText());
448 showBoxes.setSelected(sg.getDisplayBoxes());
449 // add any groupURLs to the groupURL submenu and make it visible
450 if (groupLinks != null && groupLinks.size() > 0)
452 buildGroupURLMenu(sg, groupLinks);
454 // Add a 'show all structures' for the current selection
455 Hashtable<String, PDBEntry> pdbe = new Hashtable<String, PDBEntry>(), reppdb = new Hashtable<String, PDBEntry>();
456 SequenceI sqass = null;
457 for (SequenceI sq : ap.av.getSequenceSelection())
459 Vector<PDBEntry> pes = sq.getDatasetSequence().getAllPDBEntries();
460 if (pes != null && pes.size() > 0)
462 reppdb.put(pes.get(0).getId(), pes.get(0));
463 for (PDBEntry pe : pes)
465 pdbe.put(pe.getId(), pe);
475 final PDBEntry[] pe = pdbe.values().toArray(
476 new PDBEntry[pdbe.size()]), pr = reppdb.values().toArray(
477 new PDBEntry[reppdb.size()]);
478 final JMenuItem gpdbview, rpdbview;
483 groupMenu.setVisible(false);
484 editMenu.setVisible(false);
489 createGroupMenuItem.setVisible(true);
490 unGroupMenuItem.setVisible(false);
491 jMenu1.setText(MessageManager.getString("action.edit_new_group"));
495 createGroupMenuItem.setVisible(false);
496 unGroupMenuItem.setVisible(true);
497 jMenu1.setText(MessageManager.getString("action.edit_group"));
502 sequenceMenu.setVisible(false);
503 pdbStructureDialog.setVisible(false);
504 rnaStructureMenu.setVisible(false);
507 if (links != null && links.size() > 0)
509 addFeatureLinks(seq, links);
514 * Adds a 'Link' menu item with a sub-menu item for each hyperlink provided.
519 void addFeatureLinks(final SequenceI seq, List<String> links)
521 JMenu linkMenu = new JMenu(MessageManager.getString("action.link"));
522 Map<String, List<String>> linkset = new LinkedHashMap<String, List<String>>();
524 for (String link : links)
526 UrlLink urlLink = null;
529 urlLink = new UrlLink(link);
530 } catch (Exception foo)
532 Cache.log.error("Exception for URLLink '" + link + "'", foo);
536 if (!urlLink.isValid())
538 Cache.log.error(urlLink.getInvalidMessage());
542 urlLink.createLinksFromSeq(seq, linkset);
545 addshowLinks(linkMenu, linkset.values());
547 // disable link menu if there are no valid entries
548 if (linkMenu.getItemCount() > 0)
550 linkMenu.setEnabled(true);
554 linkMenu.setEnabled(false);
557 if (sequence != null)
559 sequenceMenu.add(linkMenu);
569 * Add annotation types to 'Show annotations' and/or 'Hide annotations' menus.
570 * "All" is added first, followed by a separator. Then add any annotation
571 * types associated with the current selection. Separate menus are built for
572 * the selected sequence group (if any), and the selected sequence.
574 * Some annotation rows are always rendered together - these can be identified
575 * by a common graphGroup property > -1. Only one of each group will be marked
576 * as visible (to avoid duplication of the display). For such groups we add a
577 * composite type name, e.g.
579 * IUPredWS (Long), IUPredWS (Short)
583 protected void buildAnnotationTypesMenus(JMenu showMenu, JMenu hideMenu,
584 List<SequenceI> forSequences)
586 showMenu.removeAll();
587 hideMenu.removeAll();
589 final List<String> all = Arrays.asList(new String[] { MessageManager
590 .getString("label.all") });
591 addAnnotationTypeToShowHide(showMenu, forSequences, "", all, true, true);
592 addAnnotationTypeToShowHide(hideMenu, forSequences, "", all, true,
594 showMenu.addSeparator();
595 hideMenu.addSeparator();
597 final AlignmentAnnotation[] annotations = ap.getAlignment()
598 .getAlignmentAnnotation();
601 * Find shown/hidden annotations types, distinguished by source (calcId),
602 * and grouped by graphGroup. Using LinkedHashMap means we will retrieve in
603 * the insertion order, which is the order of the annotations on the
606 Map<String, List<List<String>>> shownTypes = new LinkedHashMap<String, List<List<String>>>();
607 Map<String, List<List<String>>> hiddenTypes = new LinkedHashMap<String, List<List<String>>>();
608 AlignmentAnnotationUtils.getShownHiddenTypes(shownTypes, hiddenTypes,
609 AlignmentAnnotationUtils.asList(annotations), forSequences);
611 for (String calcId : hiddenTypes.keySet())
613 for (List<String> type : hiddenTypes.get(calcId))
615 addAnnotationTypeToShowHide(showMenu, forSequences, calcId, type,
619 // grey out 'show annotations' if none are hidden
620 showMenu.setEnabled(!hiddenTypes.isEmpty());
622 for (String calcId : shownTypes.keySet())
624 for (List<String> type : shownTypes.get(calcId))
626 addAnnotationTypeToShowHide(hideMenu, forSequences, calcId, type,
630 // grey out 'hide annotations' if none are shown
631 hideMenu.setEnabled(!shownTypes.isEmpty());
635 * Returns a list of sequences - either the current selection group (if there
636 * is one), else the specified single sequence.
641 protected List<SequenceI> getSequenceScope(SequenceI seq)
643 List<SequenceI> forSequences = null;
644 final SequenceGroup selectionGroup = ap.av.getSelectionGroup();
645 if (selectionGroup != null && selectionGroup.getSize() > 0)
647 forSequences = selectionGroup.getSequences();
651 forSequences = seq == null ? Collections.<SequenceI> emptyList()
652 : Arrays.asList(seq);
658 * Add one annotation type to the 'Show Annotations' or 'Hide Annotations'
661 * @param showOrHideMenu
663 * @param forSequences
664 * the sequences whose annotations may be shown or hidden
669 * if true this is a special label meaning 'All'
670 * @param actionIsShow
671 * if true, the select menu item action is to show the annotation
674 protected void addAnnotationTypeToShowHide(JMenu showOrHideMenu,
675 final List<SequenceI> forSequences, String calcId,
676 final List<String> types, final boolean allTypes,
677 final boolean actionIsShow)
679 String label = types.toString(); // [a, b, c]
680 label = label.substring(1, label.length() - 1); // a, b, c
681 final JMenuItem item = new JMenuItem(label);
682 item.setToolTipText(calcId);
683 item.addActionListener(new ActionListener()
686 public void actionPerformed(ActionEvent e)
688 AlignmentUtils.showOrHideSequenceAnnotations(ap.getAlignment(),
689 types, forSequences, allTypes, actionIsShow);
693 showOrHideMenu.add(item);
696 private void buildGroupURLMenu(SequenceGroup sg, List<String> groupLinks)
699 // TODO: usability: thread off the generation of group url content so root
701 // sequence only URLs
702 // ID/regex match URLs
703 groupLinksMenu = new JMenu(
704 MessageManager.getString("action.group_link"));
705 // three types of url that might be created.
706 JMenu[] linkMenus = new JMenu[] { null,
707 new JMenu(MessageManager.getString("action.ids")),
708 new JMenu(MessageManager.getString("action.sequences")),
709 new JMenu(MessageManager.getString("action.ids_sequences")) };
711 SequenceI[] seqs = ap.av.getSelectionAsNewSequence();
712 String[][] idandseqs = GroupUrlLink.formStrings(seqs);
713 Hashtable<String, Object[]> commonDbrefs = new Hashtable<String, Object[]>();
714 for (int sq = 0; sq < seqs.length; sq++)
717 int start = seqs[sq].findPosition(sg.getStartRes()), end = seqs[sq]
718 .findPosition(sg.getEndRes());
719 // just collect ids from dataset sequence
720 // TODO: check if IDs collected from selecton group intersects with the
721 // current selection, too
722 SequenceI sqi = seqs[sq];
723 while (sqi.getDatasetSequence() != null)
725 sqi = sqi.getDatasetSequence();
727 DBRefEntry[] dbr = sqi.getDBRefs();
728 if (dbr != null && dbr.length > 0)
730 for (int d = 0; d < dbr.length; d++)
732 String src = dbr[d].getSource(); // jalview.util.DBRefUtils.getCanonicalName(dbr[d].getSource()).toUpperCase();
733 Object[] sarray = commonDbrefs.get(src);
736 sarray = new Object[2];
737 sarray[0] = new int[] { 0 };
738 sarray[1] = new String[seqs.length];
740 commonDbrefs.put(src, sarray);
743 if (((String[]) sarray[1])[sq] == null)
746 || (dbr[d].getMap().locateMappedRange(start, end) != null))
748 ((String[]) sarray[1])[sq] = dbr[d].getAccessionId();
749 ((int[]) sarray[0])[0]++;
755 // now create group links for all distinct ID/sequence sets.
756 boolean addMenu = false; // indicates if there are any group links to give
758 for (String link : groupLinks)
760 GroupUrlLink urlLink = null;
763 urlLink = new GroupUrlLink(link);
764 } catch (Exception foo)
766 Cache.log.error("Exception for GroupURLLink '" + link + "'", foo);
770 if (!urlLink.isValid())
772 Cache.log.error(urlLink.getInvalidMessage());
775 final String label = urlLink.getLabel();
776 boolean usingNames = false;
777 // Now see which parts of the group apply for this URL
778 String ltarget = urlLink.getTarget(); // jalview.util.DBRefUtils.getCanonicalName(urlLink.getTarget());
779 Object[] idset = commonDbrefs.get(ltarget.toUpperCase());
780 String[] seqstr, ids; // input to makeUrl
783 int numinput = ((int[]) idset[0])[0];
784 String[] allids = ((String[]) idset[1]);
785 seqstr = new String[numinput];
786 ids = new String[numinput];
787 for (int sq = 0, idcount = 0; sq < seqs.length; sq++)
789 if (allids[sq] != null)
791 ids[idcount] = allids[sq];
792 seqstr[idcount++] = idandseqs[1][sq];
798 // just use the id/seq set
799 seqstr = idandseqs[1];
803 // and try and make the groupURL!
805 Object[] urlset = null;
808 urlset = urlLink.makeUrlStubs(ids, seqstr,
809 "FromJalview" + System.currentTimeMillis(), false);
810 } catch (UrlStringTooLongException e)
815 int type = urlLink.getGroupURLType() & 3;
816 // first two bits ofurlLink type bitfield are sequenceids and sequences
817 // TODO: FUTURE: ensure the groupURL menu structure can be generalised
818 addshowLink(linkMenus[type], label
819 + (((type & 1) == 1) ? ("("
820 + (usingNames ? "Names" : ltarget) + ")") : ""),
827 groupLinksMenu = new JMenu(
828 MessageManager.getString("action.group_link"));
829 for (int m = 0; m < linkMenus.length; m++)
831 if (linkMenus[m] != null
832 && linkMenus[m].getMenuComponentCount() > 0)
834 groupLinksMenu.add(linkMenus[m]);
838 groupMenu.add(groupLinksMenu);
842 private void addshowLinks(JMenu linkMenu, Collection<List<String>> linkset)
844 for (List<String> linkstrset : linkset)
846 // split linkstr into label and url
847 addshowLink(linkMenu, linkstrset.get(1), linkstrset.get(3));
852 * add a show URL menu item to the given linkMenu
856 * - menu label string
860 private void addshowLink(JMenu linkMenu, String label, final String url)
862 JMenuItem item = new JMenuItem(label);
863 item.setToolTipText(MessageManager.formatMessage(
864 "label.open_url_param", new Object[] { url }));
865 item.addActionListener(new ActionListener()
868 public void actionPerformed(ActionEvent e)
870 new Thread(new Runnable()
887 * add a late bound groupURL item to the given linkMenu
891 * - menu label string
892 * @param urlgenerator
893 * GroupURLLink used to generate URL
895 * Object array returned from the makeUrlStubs function.
897 private void addshowLink(JMenu linkMenu, String label,
898 final GroupUrlLink urlgenerator, final Object[] urlstub)
900 JMenuItem item = new JMenuItem(label);
901 item.setToolTipText(MessageManager.formatMessage(
902 "label.open_url_seqs_param",
903 new Object[] { urlgenerator.getUrl_prefix(),
904 urlgenerator.getNumberInvolved(urlstub) }));
905 // TODO: put in info about what is being sent.
906 item.addActionListener(new ActionListener()
909 public void actionPerformed(ActionEvent e)
911 new Thread(new Runnable()
919 showLink(urlgenerator.constructFrom(urlstub));
920 } catch (UrlStringTooLongException e2)
938 private void jbInit() throws Exception
940 groupMenu.setText(MessageManager.getString("label.selection"));
941 groupName.setText(MessageManager.getString("label.name"));
942 groupName.addActionListener(new ActionListener()
945 public void actionPerformed(ActionEvent e)
947 groupName_actionPerformed();
950 sequenceMenu.setText(MessageManager.getString("label.sequence"));
951 sequenceName.setText(MessageManager
952 .getString("label.edit_name_description"));
953 sequenceName.addActionListener(new ActionListener()
956 public void actionPerformed(ActionEvent e)
958 sequenceName_actionPerformed();
961 chooseAnnotations.setText(MessageManager
962 .getString("action.choose_annotations"));
963 chooseAnnotations.addActionListener(new ActionListener()
966 public void actionPerformed(ActionEvent e)
968 chooseAnnotations_actionPerformed(e);
971 sequenceDetails.setText(MessageManager
972 .getString("label.sequence_details"));
973 sequenceDetails.addActionListener(new ActionListener()
976 public void actionPerformed(ActionEvent e)
978 sequenceDetails_actionPerformed();
981 sequenceSelDetails.setText(MessageManager
982 .getString("label.sequence_details"));
983 sequenceSelDetails.addActionListener(new ActionListener()
986 public void actionPerformed(ActionEvent e)
988 sequenceSelectionDetails_actionPerformed();
993 .setText(MessageManager.getString("action.remove_group"));
994 unGroupMenuItem.addActionListener(new ActionListener()
997 public void actionPerformed(ActionEvent e)
999 unGroupMenuItem_actionPerformed();
1002 createGroupMenuItem.setText(MessageManager
1003 .getString("action.create_group"));
1004 createGroupMenuItem.addActionListener(new ActionListener()
1007 public void actionPerformed(ActionEvent e)
1009 createGroupMenuItem_actionPerformed();
1013 outline.setText(MessageManager.getString("action.border_colour"));
1014 outline.addActionListener(new ActionListener()
1017 public void actionPerformed(ActionEvent e)
1019 outline_actionPerformed();
1022 showBoxes.setText(MessageManager.getString("action.boxes"));
1023 showBoxes.setState(true);
1024 showBoxes.addActionListener(new ActionListener()
1027 public void actionPerformed(ActionEvent e)
1029 showBoxes_actionPerformed();
1032 showText.setText(MessageManager.getString("action.text"));
1033 showText.setState(true);
1034 showText.addActionListener(new ActionListener()
1037 public void actionPerformed(ActionEvent e)
1039 showText_actionPerformed();
1042 showColourText.setText(MessageManager.getString("label.colour_text"));
1043 showColourText.addActionListener(new ActionListener()
1046 public void actionPerformed(ActionEvent e)
1048 showColourText_actionPerformed();
1051 displayNonconserved.setText(MessageManager
1052 .getString("label.show_non_conserved"));
1053 displayNonconserved.setState(true);
1054 displayNonconserved.addActionListener(new ActionListener()
1057 public void actionPerformed(ActionEvent e)
1059 showNonconserved_actionPerformed();
1062 editMenu.setText(MessageManager.getString("action.edit"));
1063 cut.setText(MessageManager.getString("action.cut"));
1064 cut.addActionListener(new ActionListener()
1067 public void actionPerformed(ActionEvent e)
1069 cut_actionPerformed();
1072 upperCase.setText(MessageManager.getString("label.to_upper_case"));
1073 upperCase.addActionListener(new ActionListener()
1076 public void actionPerformed(ActionEvent e)
1081 copy.setText(MessageManager.getString("action.copy"));
1082 copy.addActionListener(new ActionListener()
1085 public void actionPerformed(ActionEvent e)
1087 copy_actionPerformed();
1090 lowerCase.setText(MessageManager.getString("label.to_lower_case"));
1091 lowerCase.addActionListener(new ActionListener()
1094 public void actionPerformed(ActionEvent e)
1099 toggle.setText(MessageManager.getString("label.toggle_case"));
1100 toggle.addActionListener(new ActionListener()
1103 public void actionPerformed(ActionEvent e)
1108 outputMenu.setText(MessageManager.getString("label.out_to_textbox")
1110 seqShowAnnotationsMenu.setText(MessageManager
1111 .getString("label.show_annotations"));
1112 seqHideAnnotationsMenu.setText(MessageManager
1113 .getString("label.hide_annotations"));
1114 groupShowAnnotationsMenu.setText(MessageManager
1115 .getString("label.show_annotations"));
1116 groupHideAnnotationsMenu.setText(MessageManager
1117 .getString("label.hide_annotations"));
1118 sequenceFeature.setText(MessageManager
1119 .getString("label.create_sequence_feature"));
1120 sequenceFeature.addActionListener(new ActionListener()
1123 public void actionPerformed(ActionEvent e)
1125 sequenceFeature_actionPerformed();
1128 jMenu1.setText(MessageManager.getString("label.group"));
1129 pdbStructureDialog.setText(MessageManager
1130 .getString("label.show_pdbstruct_dialog"));
1131 pdbStructureDialog.addActionListener(new ActionListener()
1134 public void actionPerformed(ActionEvent actionEvent)
1136 SequenceI[] selectedSeqs = new SequenceI[] { sequence };
1137 if (ap.av.getSelectionGroup() != null)
1139 selectedSeqs = ap.av.getSequenceSelection();
1141 new StructureChooser(selectedSeqs, sequence, ap);
1145 rnaStructureMenu.setText(MessageManager
1146 .getString("label.view_rna_structure"));
1148 // colStructureMenu.setText("Colour By Structure");
1149 editSequence.setText(MessageManager.getString("label.edit_sequence")
1151 editSequence.addActionListener(new ActionListener()
1154 public void actionPerformed(ActionEvent actionEvent)
1156 editSequence_actionPerformed(actionEvent);
1159 makeReferenceSeq.setText(MessageManager
1160 .getString("label.mark_as_representative"));
1161 makeReferenceSeq.addActionListener(new ActionListener()
1165 public void actionPerformed(ActionEvent actionEvent)
1167 makeReferenceSeq_actionPerformed(actionEvent);
1171 hideInsertions.setText(MessageManager
1172 .getString("label.hide_insertions"));
1173 hideInsertions.addActionListener(new ActionListener()
1177 public void actionPerformed(ActionEvent e)
1179 hideInsertions_actionPerformed(e);
1183 * annotationMenuItem.setText("By Annotation");
1184 * annotationMenuItem.addActionListener(new ActionListener() { public void
1185 * actionPerformed(ActionEvent actionEvent) {
1186 * annotationMenuItem_actionPerformed(actionEvent); } });
1188 groupMenu.add(sequenceSelDetails);
1191 add(rnaStructureMenu);
1192 add(pdbStructureDialog);
1193 if (sequence != null)
1195 add(hideInsertions);
1197 // annotations configuration panel suppressed for now
1198 // groupMenu.add(chooseAnnotations);
1201 * Add show/hide annotations to the Sequence menu, and to the Selection menu
1202 * (if a selection group is in force).
1204 sequenceMenu.add(seqShowAnnotationsMenu);
1205 sequenceMenu.add(seqHideAnnotationsMenu);
1206 sequenceMenu.add(seqAddReferenceAnnotations);
1207 groupMenu.add(groupShowAnnotationsMenu);
1208 groupMenu.add(groupHideAnnotationsMenu);
1209 groupMenu.add(groupAddReferenceAnnotations);
1210 groupMenu.add(editMenu);
1211 groupMenu.add(outputMenu);
1212 groupMenu.add(sequenceFeature);
1213 groupMenu.add(createGroupMenuItem);
1214 groupMenu.add(unGroupMenuItem);
1215 groupMenu.add(jMenu1);
1216 sequenceMenu.add(sequenceName);
1217 sequenceMenu.add(sequenceDetails);
1218 sequenceMenu.add(makeReferenceSeq);
1225 editMenu.add(editSequence);
1226 editMenu.add(upperCase);
1227 editMenu.add(lowerCase);
1228 editMenu.add(toggle);
1229 // JBPNote: These shouldn't be added here - should appear in a generic
1230 // 'apply web service to this sequence menu'
1231 // pdbMenu.add(RNAFold);
1232 // pdbMenu.add(ContraFold);
1233 jMenu1.add(groupName);
1234 jMenu1.add(colourMenu);
1235 jMenu1.add(showBoxes);
1236 jMenu1.add(showText);
1237 jMenu1.add(showColourText);
1238 jMenu1.add(outline);
1239 jMenu1.add(displayNonconserved);
1243 * Constructs the entries for the colour menu
1245 protected void initColourMenu()
1247 colourMenu.setText(MessageManager.getString("label.group_colour"));
1248 textColour.setText(MessageManager.getString("label.text_colour"));
1249 textColour.addActionListener(new ActionListener()
1252 public void actionPerformed(ActionEvent e)
1254 textColour_actionPerformed();
1258 abovePIDColour.setText(MessageManager
1259 .getString("label.above_identity_threshold"));
1260 abovePIDColour.addActionListener(new ActionListener()
1263 public void actionPerformed(ActionEvent e)
1265 abovePIDColour_actionPerformed(abovePIDColour.isSelected());
1269 modifyPID.setText(MessageManager
1270 .getString("label.modify_identity_threshold"));
1271 modifyPID.addActionListener(new ActionListener()
1274 public void actionPerformed(ActionEvent e)
1276 modifyPID_actionPerformed();
1280 conservationMenuItem.setText(MessageManager
1281 .getString("action.by_conservation"));
1282 conservationMenuItem.addActionListener(new ActionListener()
1285 public void actionPerformed(ActionEvent e)
1287 conservationMenuItem_actionPerformed(conservationMenuItem
1292 modifyConservation.setText(MessageManager
1293 .getString("label.modify_conservation_threshold"));
1294 modifyConservation.addActionListener(new ActionListener()
1297 public void actionPerformed(ActionEvent e)
1299 modifyConservation_actionPerformed();
1305 * Builds the group colour sub-menu, including any user-defined colours which
1306 * were loaded at startup or during the Jalview session
1308 protected void buildColourMenu()
1310 SequenceGroup sg = ap.av.getSelectionGroup();
1314 * popup menu with no sequence group scope
1318 colourMenu.removeAll();
1319 colourMenu.add(textColour);
1320 colourMenu.addSeparator();
1322 ColourMenuHelper.addMenuItems(colourMenu, this, sg, false);
1324 colourMenu.addSeparator();
1325 colourMenu.add(conservationMenuItem);
1326 colourMenu.add(modifyConservation);
1327 colourMenu.add(abovePIDColour);
1328 colourMenu.add(modifyPID);
1331 protected void modifyConservation_actionPerformed()
1333 SequenceGroup sg = getGroup();
1336 SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
1337 SliderPanel.showConservationSlider();
1341 protected void modifyPID_actionPerformed()
1343 SequenceGroup sg = getGroup();
1346 // int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
1348 // sg.cs.setThreshold(threshold, ap.av.isIgnoreGapsConsensus());
1349 SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
1351 SliderPanel.showPIDSlider();
1356 * Check for any annotations on the underlying dataset sequences (for the
1357 * current selection group) which are not 'on the alignment'.If any are found,
1358 * enable the option to add them to the alignment. The criteria for 'on the
1359 * alignment' is finding an alignment annotation on the alignment, matched on
1360 * calcId, label and sequenceRef.
1362 * A tooltip is also constructed that displays the source (calcId) and type
1363 * (label) of the annotations that can be added.
1366 * @param forSequences
1368 protected void configureReferenceAnnotationsMenu(JMenuItem menuItem,
1369 List<SequenceI> forSequences)
1371 menuItem.setEnabled(false);
1374 * Temporary store to hold distinct calcId / type pairs for the tooltip.
1375 * Using TreeMap means calcIds are shown in alphabetical order.
1377 SortedMap<String, String> tipEntries = new TreeMap<String, String>();
1378 final Map<SequenceI, List<AlignmentAnnotation>> candidates = new LinkedHashMap<SequenceI, List<AlignmentAnnotation>>();
1379 AlignmentI al = this.ap.av.getAlignment();
1380 AlignmentUtils.findAddableReferenceAnnotations(forSequences,
1381 tipEntries, candidates, al);
1382 if (!candidates.isEmpty())
1384 StringBuilder tooltip = new StringBuilder(64);
1385 tooltip.append(MessageManager.getString("label.add_annotations_for"));
1388 * Found annotations that could be added. Enable the menu item, and
1389 * configure its tooltip and action.
1391 menuItem.setEnabled(true);
1392 for (String calcId : tipEntries.keySet())
1394 tooltip.append("<br/>" + calcId + "/" + tipEntries.get(calcId));
1396 String tooltipText = JvSwingUtils.wrapTooltip(true,
1397 tooltip.toString());
1398 menuItem.setToolTipText(tooltipText);
1400 menuItem.addActionListener(new ActionListener()
1403 public void actionPerformed(ActionEvent e)
1405 addReferenceAnnotations_actionPerformed(candidates);
1412 * Add annotations to the sequences and to the alignment.
1415 * a map whose keys are sequences on the alignment, and values a list
1416 * of annotations to add to each sequence
1418 protected void addReferenceAnnotations_actionPerformed(
1419 Map<SequenceI, List<AlignmentAnnotation>> candidates)
1421 final SequenceGroup selectionGroup = this.ap.av.getSelectionGroup();
1422 final AlignmentI alignment = this.ap.getAlignment();
1423 AlignmentUtils.addReferenceAnnotations(candidates, alignment,
1428 protected void makeReferenceSeq_actionPerformed(ActionEvent actionEvent)
1430 if (!ap.av.getAlignment().hasSeqrep())
1432 // initialise the display flags so the user sees something happen
1433 ap.av.setDisplayReferenceSeq(true);
1434 ap.av.setColourByReferenceSeq(true);
1435 ap.av.getAlignment().setSeqrep(sequence);
1439 if (ap.av.getAlignment().getSeqrep() == sequence)
1441 ap.av.getAlignment().setSeqrep(null);
1445 ap.av.getAlignment().setSeqrep(sequence);
1451 protected void hideInsertions_actionPerformed(ActionEvent actionEvent)
1453 if (sequence != null)
1455 ColumnSelection cs = ap.av.getColumnSelection();
1458 cs = new ColumnSelection();
1460 cs.hideInsertionsFor(sequence);
1461 ap.av.setColumnSelection(cs);
1466 protected void sequenceSelectionDetails_actionPerformed()
1468 createSequenceDetailsReport(ap.av.getSequenceSelection());
1471 protected void sequenceDetails_actionPerformed()
1473 createSequenceDetailsReport(new SequenceI[] { sequence });
1476 public void createSequenceDetailsReport(SequenceI[] sequences)
1478 CutAndPasteHtmlTransfer cap = new CutAndPasteHtmlTransfer();
1479 StringBuilder contents = new StringBuilder(128);
1480 for (SequenceI seq : sequences)
1482 contents.append("<p><h2>"
1485 "label.create_sequence_details_report_annotation_for",
1486 new Object[] { seq.getDisplayId(true) })
1488 new SequenceAnnotationReport(null)
1489 .createSequenceAnnotationReport(
1494 (ap.getSeqPanel().seqCanvas.fr != null) ? ap
1495 .getSeqPanel().seqCanvas.fr.getMinMax()
1497 contents.append("</p>");
1499 cap.setText("<html>" + contents.toString() + "</html>");
1501 Desktop.addInternalFrame(cap, MessageManager.formatMessage(
1502 "label.sequence_details_for",
1503 (sequences.length == 1 ? new Object[] { sequences[0]
1504 .getDisplayId(true) } : new Object[] { MessageManager
1505 .getString("label.selection") })), 500, 400);
1509 protected void showNonconserved_actionPerformed()
1511 getGroup().setShowNonconserved(displayNonconserved.isSelected());
1516 * call to refresh view after settings change
1520 ap.updateAnnotation();
1521 ap.paintAlignment(true);
1523 PaintRefresher.Refresh(this, ap.av.getSequenceSetId());
1527 * protected void covariationColour_actionPerformed() { getGroup().cs = new
1528 * CovariationColourScheme(sequence.getAnnotation()[0]); refresh(); }
1538 public void abovePIDColour_actionPerformed(boolean selected)
1540 SequenceGroup sg = getGroup();
1548 sg.cs.setConsensus(AAFrequency.calculate(
1549 sg.getSequences(ap.av.getHiddenRepSequences()),
1550 sg.getStartRes(), sg.getEndRes() + 1));
1552 int threshold = SliderPanel.setPIDSliderSource(ap,
1553 sg.getGroupColourScheme(), getGroup()
1556 sg.cs.setThreshold(threshold, ap.av.isIgnoreGapsConsensus());
1558 SliderPanel.showPIDSlider();
1561 // remove PIDColouring
1563 sg.cs.setThreshold(0, ap.av.isIgnoreGapsConsensus());
1564 SliderPanel.hidePIDSlider();
1566 modifyPID.setEnabled(selected);
1572 * Open a panel where the user can choose which types of sequence annotation
1577 protected void chooseAnnotations_actionPerformed(ActionEvent e)
1579 // todo correct way to guard against opening a duplicate panel?
1580 new AnnotationChooser(ap);
1589 public void conservationMenuItem_actionPerformed(boolean selected)
1591 SequenceGroup sg = getGroup();
1599 // JBPNote: Conservation name shouldn't be i18n translated
1600 Conservation c = new Conservation("Group", sg.getSequences(ap.av
1601 .getHiddenRepSequences()), sg.getStartRes(),
1602 sg.getEndRes() + 1);
1605 c.verdict(false, ap.av.getConsPercGaps());
1606 sg.cs.setConservation(c);
1608 SliderPanel.setConservationSlider(ap, sg.getGroupColourScheme(),
1610 SliderPanel.showConservationSlider();
1613 // remove ConservationColouring
1615 sg.cs.setConservation(null);
1616 SliderPanel.hideConservationSlider();
1618 modifyConservation.setEnabled(selected);
1623 public void annotationMenuItem_actionPerformed(ActionEvent actionEvent)
1625 SequenceGroup sg = getGroup();
1631 AnnotationColourGradient acg = new AnnotationColourGradient(
1632 sequence.getAnnotation()[0], null,
1633 AnnotationColourGradient.NO_THRESHOLD);
1635 acg.setPredefinedColours(true);
1636 sg.setColourScheme(acg);
1647 protected void groupName_actionPerformed()
1650 SequenceGroup sg = getGroup();
1651 EditNameDialog dialog = new EditNameDialog(sg.getName(),
1652 sg.getDescription(), " "
1653 + MessageManager.getString("label.group_name") + " ",
1654 MessageManager.getString("label.group_description") + " ",
1655 MessageManager.getString("label.edit_group_name_description"),
1663 sg.setName(dialog.getName());
1664 sg.setDescription(dialog.getDescription());
1669 * Get selection group - adding it to the alignment if necessary.
1671 * @return sequence group to operate on
1673 SequenceGroup getGroup()
1675 SequenceGroup sg = ap.av.getSelectionGroup();
1676 // this method won't add a new group if it already exists
1679 ap.av.getAlignment().addGroup(sg);
1691 void sequenceName_actionPerformed()
1693 EditNameDialog dialog = new EditNameDialog(sequence.getName(),
1694 sequence.getDescription(),
1695 " " + MessageManager.getString("label.sequence_name")
1697 MessageManager.getString("label.sequence_description") + " ",
1699 .getString("label.edit_sequence_name_description"),
1707 if (dialog.getName() != null)
1709 if (dialog.getName().indexOf(" ") > -1)
1715 .getString("label.spaces_converted_to_backslashes"),
1717 .getString("label.no_spaces_allowed_sequence_name"),
1718 JvOptionPane.WARNING_MESSAGE);
1721 sequence.setName(dialog.getName().replace(' ', '_'));
1722 ap.paintAlignment(false);
1725 sequence.setDescription(dialog.getDescription());
1727 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1738 void unGroupMenuItem_actionPerformed()
1740 SequenceGroup sg = ap.av.getSelectionGroup();
1741 ap.av.getAlignment().deleteGroup(sg);
1742 ap.av.setSelectionGroup(null);
1746 void createGroupMenuItem_actionPerformed()
1748 getGroup(); // implicitly creates group - note - should apply defaults / use
1749 // standard alignment window logic for this
1759 protected void outline_actionPerformed()
1761 SequenceGroup sg = getGroup();
1762 Color col = JColorChooser.showDialog(this,
1763 MessageManager.getString("label.select_outline_colour"),
1768 sg.setOutlineColour(col);
1780 public void showBoxes_actionPerformed()
1782 getGroup().setDisplayBoxes(showBoxes.isSelected());
1792 public void showText_actionPerformed()
1794 getGroup().setDisplayText(showText.isSelected());
1804 public void showColourText_actionPerformed()
1806 getGroup().setColourText(showColourText.isSelected());
1810 public void showLink(String url)
1814 jalview.util.BrowserLauncher.openURL(url);
1815 } catch (Exception ex)
1817 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
1818 MessageManager.getString("label.web_browser_not_found_unix"),
1819 MessageManager.getString("label.web_browser_not_found"),
1820 JvOptionPane.WARNING_MESSAGE);
1822 ex.printStackTrace();
1826 void hideSequences(boolean representGroup)
1828 ap.av.hideSequences(sequence, representGroup);
1831 public void copy_actionPerformed()
1833 ap.alignFrame.copy_actionPerformed(null);
1836 public void cut_actionPerformed()
1838 ap.alignFrame.cut_actionPerformed(null);
1841 void changeCase(ActionEvent e)
1843 Object source = e.getSource();
1844 SequenceGroup sg = ap.av.getSelectionGroup();
1848 List<int[]> startEnd = ap.av.getVisibleRegionBoundaries(
1849 sg.getStartRes(), sg.getEndRes() + 1);
1854 if (source == toggle)
1856 description = MessageManager.getString("label.toggle_case");
1857 caseChange = ChangeCaseCommand.TOGGLE_CASE;
1859 else if (source == upperCase)
1861 description = MessageManager.getString("label.to_upper_case");
1862 caseChange = ChangeCaseCommand.TO_UPPER;
1866 description = MessageManager.getString("label.to_lower_case");
1867 caseChange = ChangeCaseCommand.TO_LOWER;
1870 ChangeCaseCommand caseCommand = new ChangeCaseCommand(description,
1871 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
1872 startEnd, caseChange);
1874 ap.alignFrame.addHistoryItem(caseCommand);
1876 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1882 public void outputText_actionPerformed(ActionEvent e)
1884 CutAndPasteTransfer cap = new CutAndPasteTransfer();
1885 cap.setForInput(null);
1886 Desktop.addInternalFrame(cap, MessageManager.formatMessage(
1887 "label.alignment_output_command",
1888 new Object[] { e.getActionCommand() }), 600, 500);
1890 String[] omitHidden = null;
1892 System.out.println("PROMPT USER HERE"); // TODO: decide if a prompt happens
1893 // or we simply trust the user wants
1894 // wysiwig behaviour
1896 FileFormatI fileFormat = FileFormats.getInstance().forName(e.getActionCommand());
1897 cap.setText(new FormatAdapter(ap).formatSequences(fileFormat, ap, true));
1900 public void sequenceFeature_actionPerformed()
1902 SequenceGroup sg = ap.av.getSelectionGroup();
1908 int rsize = 0, gSize = sg.getSize();
1909 SequenceI[] rseqs, seqs = new SequenceI[gSize];
1910 SequenceFeature[] tfeatures, features = new SequenceFeature[gSize];
1912 for (int i = 0; i < gSize; i++)
1914 int start = sg.getSequenceAt(i).findPosition(sg.getStartRes());
1915 int end = sg.findEndRes(sg.getSequenceAt(i));
1918 seqs[rsize] = sg.getSequenceAt(i).getDatasetSequence();
1919 features[rsize] = new SequenceFeature(null, null, null, start, end,
1924 rseqs = new SequenceI[rsize];
1925 tfeatures = new SequenceFeature[rsize];
1926 System.arraycopy(seqs, 0, rseqs, 0, rsize);
1927 System.arraycopy(features, 0, tfeatures, 0, rsize);
1928 features = tfeatures;
1930 if (ap.getSeqPanel().seqCanvas.getFeatureRenderer().amendFeatures(seqs,
1931 features, true, ap))
1933 ap.alignFrame.setShowSeqFeatures(true);
1934 ap.highlightSearchResults(null);
1938 public void textColour_actionPerformed()
1940 SequenceGroup sg = getGroup();
1943 new TextColourChooser().chooseColour(ap, sg);
1947 public void colourByStructure(String pdbid)
1949 Annotation[] anots = ap.av.getStructureSelectionManager()
1950 .colourSequenceFromStructure(sequence, pdbid);
1952 AlignmentAnnotation an = new AlignmentAnnotation("Structure",
1953 "Coloured by " + pdbid, anots);
1955 ap.av.getAlignment().addAnnotation(an);
1956 an.createSequenceMapping(sequence, 0, true);
1957 // an.adjustForAlignment();
1958 ap.av.getAlignment().setAnnotationIndex(an, 0);
1960 ap.adjustAnnotationHeight();
1962 sequence.addAlignmentAnnotation(an);
1966 public void editSequence_actionPerformed(ActionEvent actionEvent)
1968 SequenceGroup sg = ap.av.getSelectionGroup();
1972 if (sequence == null)
1974 sequence = sg.getSequenceAt(0);
1977 EditNameDialog dialog = new EditNameDialog(
1978 sequence.getSequenceAsString(sg.getStartRes(),
1979 sg.getEndRes() + 1), null,
1980 MessageManager.getString("label.edit_sequence"), null,
1981 MessageManager.getString("label.edit_sequence"),
1986 EditCommand editCommand = new EditCommand(
1987 MessageManager.getString("label.edit_sequences"),
1988 Action.REPLACE, dialog.getName().replace(' ',
1989 ap.av.getGapCharacter()),
1990 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
1991 sg.getStartRes(), sg.getEndRes() + 1, ap.av.getAlignment());
1993 ap.alignFrame.addHistoryItem(editCommand);
1995 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
2002 * Action on user selecting an item from the colour menu (that does not have
2003 * its bespoke action handler)
2008 public void changeColour_actionPerformed(String colourSchemeName)
2010 SequenceGroup sg = getGroup();
2011 if (ResidueColourScheme.USER_DEFINED.equals(colourSchemeName))
2014 * open a panel to load or configure a user-defined colour scheme
2016 new UserDefinedColours(ap, sg);
2021 * switch to the chosen colour scheme (or null for None)
2023 ColourSchemeI colourScheme = ColourSchemes.getInstance().getColourScheme(
2024 colourSchemeName, sg, ap.av.getHiddenRepSequences());
2025 sg.setColourScheme(colourScheme);
2026 if (colourScheme instanceof Blosum62ColourScheme
2027 || colourScheme instanceof PIDColourScheme)
2029 sg.cs.setConsensus(AAFrequency.calculate(
2030 sg.getSequences(ap.av.getHiddenRepSequences()),
2031 sg.getStartRes(), sg.getEndRes() + 1));