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.FileFormat;
43 import jalview.io.FileFormatI;
44 import jalview.io.FormatAdapter;
45 import jalview.io.SequenceAnnotationReport;
46 import jalview.schemes.AnnotationColourGradient;
47 import jalview.schemes.Blosum62ColourScheme;
48 import jalview.schemes.ColourSchemes;
49 import jalview.schemes.PIDColourScheme;
50 import jalview.schemes.ResidueColourScheme;
51 import jalview.util.GroupUrlLink;
52 import jalview.util.GroupUrlLink.UrlStringTooLongException;
53 import jalview.util.MessageManager;
54 import jalview.util.UrlLink;
56 import java.awt.Color;
57 import java.awt.event.ActionEvent;
58 import java.awt.event.ActionListener;
59 import java.util.Arrays;
60 import java.util.Collection;
61 import java.util.Collections;
62 import java.util.Hashtable;
63 import java.util.LinkedHashMap;
64 import java.util.List;
66 import java.util.SortedMap;
67 import java.util.TreeMap;
68 import java.util.Vector;
70 import javax.swing.JCheckBoxMenuItem;
71 import javax.swing.JColorChooser;
72 import javax.swing.JMenu;
73 import javax.swing.JMenuItem;
74 import javax.swing.JPopupMenu;
80 * @version $Revision: 1.118 $
82 public class PopupMenu extends JPopupMenu implements ColourChangeListener
84 JMenu groupMenu = new JMenu();
86 JMenuItem groupName = new JMenuItem();
88 protected JCheckBoxMenuItem abovePIDColour = new JCheckBoxMenuItem();
90 protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem();
94 JMenu sequenceMenu = new JMenu();
96 JMenuItem sequenceName = new JMenuItem();
98 JMenuItem sequenceDetails = new JMenuItem();
100 JMenuItem sequenceSelDetails = new JMenuItem();
102 JMenuItem makeReferenceSeq = new JMenuItem();
104 JMenuItem chooseAnnotations = new JMenuItem();
108 JMenuItem createGroupMenuItem = new JMenuItem();
110 JMenuItem unGroupMenuItem = new JMenuItem();
112 JMenuItem outline = new JMenuItem();
114 JMenu colourMenu = new JMenu();
116 JCheckBoxMenuItem showBoxes = new JCheckBoxMenuItem();
118 JCheckBoxMenuItem showText = new JCheckBoxMenuItem();
120 JCheckBoxMenuItem showColourText = new JCheckBoxMenuItem();
122 JCheckBoxMenuItem displayNonconserved = new JCheckBoxMenuItem();
124 JMenu editMenu = new JMenu();
126 JMenuItem cut = new JMenuItem();
128 JMenuItem copy = new JMenuItem();
130 JMenuItem upperCase = new JMenuItem();
132 JMenuItem lowerCase = new JMenuItem();
134 JMenuItem toggle = new JMenuItem();
136 JMenu pdbMenu = new JMenu();
138 JMenu outputMenu = new JMenu();
140 JMenu seqShowAnnotationsMenu = new JMenu();
142 JMenu seqHideAnnotationsMenu = new JMenu();
144 JMenuItem seqAddReferenceAnnotations = new JMenuItem(
145 MessageManager.getString("label.add_reference_annotations"));
147 JMenu groupShowAnnotationsMenu = new JMenu();
149 JMenu groupHideAnnotationsMenu = new JMenu();
151 JMenuItem groupAddReferenceAnnotations = new JMenuItem(
152 MessageManager.getString("label.add_reference_annotations"));
154 JMenuItem sequenceFeature = new JMenuItem();
156 JMenuItem textColour = new JMenuItem();
158 JMenu jMenu1 = new JMenu();
160 JMenuItem pdbStructureDialog = new JMenuItem();
162 JMenu rnaStructureMenu = new JMenu();
164 JMenuItem editSequence = new JMenuItem();
166 JMenu groupLinksMenu;
168 JMenuItem hideInsertions = new JMenuItem();
171 * Creates a new PopupMenu object.
178 public PopupMenu(final AlignmentPanel ap, Sequence seq, List<String> links)
180 this(ap, seq, links, null);
190 public PopupMenu(final AlignmentPanel ap, final SequenceI seq,
191 List<String> links, List<String> groupLinks)
193 // /////////////////////////////////////////////////////////
194 // If this is activated from the sequence panel, the user may want to
195 // edit or annotate a particular residue. Therefore display the residue menu
197 // If from the IDPanel, we must display the sequence menu
198 // ////////////////////////////////////////////////////////
202 for (String ff : FileFormat.getWritableFormats(true))
204 JMenuItem item = new JMenuItem(ff);
206 item.addActionListener(new ActionListener()
209 public void actionPerformed(ActionEvent e)
211 outputText_actionPerformed(e);
215 outputMenu.add(item);
219 * Build menus for annotation types that may be shown or hidden, and for
220 * 'reference annotations' that may be added to the alignment. First for the
221 * currently selected sequence (if there is one):
223 final List<SequenceI> selectedSequence = (seq == null ? Collections
224 .<SequenceI> emptyList() : Arrays.asList(seq));
225 buildAnnotationTypesMenus(seqShowAnnotationsMenu,
226 seqHideAnnotationsMenu, selectedSequence);
227 configureReferenceAnnotationsMenu(seqAddReferenceAnnotations,
231 * And repeat for the current selection group (if there is one):
233 final List<SequenceI> selectedGroup = (ap.av.getSelectionGroup() == null ? Collections
234 .<SequenceI> emptyList() : ap.av.getSelectionGroup()
236 buildAnnotationTypesMenus(groupShowAnnotationsMenu,
237 groupHideAnnotationsMenu, selectedGroup);
238 configureReferenceAnnotationsMenu(groupAddReferenceAnnotations,
244 } catch (Exception e)
252 sequenceMenu.setText(sequence.getName());
253 if (seq == ap.av.getAlignment().getSeqrep())
255 makeReferenceSeq.setText(MessageManager
256 .getString("action.unmark_as_reference"));
260 makeReferenceSeq.setText(MessageManager
261 .getString("action.set_as_reference"));
264 if (!ap.av.getAlignment().isNucleotide())
266 remove(rnaStructureMenu);
270 int origCount = rnaStructureMenu.getItemCount();
272 * add menu items to 2D-render any alignment or sequence secondary
273 * structure annotation
275 AlignmentAnnotation[] aas = ap.av.getAlignment()
276 .getAlignmentAnnotation();
279 for (final AlignmentAnnotation aa : aas)
281 if (aa.isValidStruc() && aa.sequenceRef == null)
284 * valid alignment RNA secondary structure annotation
286 menuItem = new JMenuItem();
287 menuItem.setText(MessageManager.formatMessage(
288 "label.2d_rna_structure_line",
289 new Object[] { aa.label }));
290 menuItem.addActionListener(new ActionListener()
293 public void actionPerformed(ActionEvent e)
295 new AppVarna(seq, aa, ap);
298 rnaStructureMenu.add(menuItem);
303 if (seq.getAnnotation() != null)
305 AlignmentAnnotation seqAnns[] = seq.getAnnotation();
306 for (final AlignmentAnnotation aa : seqAnns)
308 if (aa.isValidStruc())
311 * valid sequence RNA secondary structure annotation
313 // TODO: make rnastrucF a bit more nice
314 menuItem = new JMenuItem();
315 menuItem.setText(MessageManager.formatMessage(
316 "label.2d_rna_sequence_name",
317 new Object[] { seq.getName() }));
318 menuItem.addActionListener(new ActionListener()
321 public void actionPerformed(ActionEvent e)
323 // TODO: VARNA does'nt print gaps in the sequence
324 new AppVarna(seq, aa, ap);
327 rnaStructureMenu.add(menuItem);
331 if (rnaStructureMenu.getItemCount() == origCount)
333 remove(rnaStructureMenu);
337 menuItem = new JMenuItem(
338 MessageManager.getString("action.hide_sequences"));
339 menuItem.addActionListener(new ActionListener()
342 public void actionPerformed(ActionEvent e)
344 hideSequences(false);
349 if (ap.av.getSelectionGroup() != null
350 && ap.av.getSelectionGroup().getSize() > 1)
352 menuItem = new JMenuItem(MessageManager.formatMessage(
353 "label.represent_group_with",
354 new Object[] { seq.getName() }));
355 menuItem.addActionListener(new ActionListener()
358 public void actionPerformed(ActionEvent e)
363 sequenceMenu.add(menuItem);
366 if (ap.av.hasHiddenRows())
368 final int index = ap.av.getAlignment().findIndex(seq);
370 if (ap.av.adjustForHiddenSeqs(index)
371 - ap.av.adjustForHiddenSeqs(index - 1) > 1)
373 menuItem = new JMenuItem(
374 MessageManager.getString("action.reveal_sequences"));
375 menuItem.addActionListener(new ActionListener()
378 public void actionPerformed(ActionEvent e)
380 ap.av.showSequence(index);
381 if (ap.overviewPanel != null)
383 ap.overviewPanel.updateOverviewImage();
391 // for the case when no sequences are even visible
392 if (ap.av.hasHiddenRows())
395 menuItem = new JMenuItem(
396 MessageManager.getString("action.reveal_all"));
397 menuItem.addActionListener(new ActionListener()
400 public void actionPerformed(ActionEvent e)
402 ap.av.showAllHiddenSeqs();
403 if (ap.overviewPanel != null)
405 ap.overviewPanel.updateOverviewImage();
415 SequenceGroup sg = ap.av.getSelectionGroup();
416 boolean isDefinedGroup = (sg != null) ? ap.av.getAlignment()
417 .getGroups().contains(sg) : false;
419 if (sg != null && sg.getSize() > 0)
421 groupName.setText(MessageManager
422 .getString("label.edit_name_and_description_current_group"));
424 ColourMenuHelper.setColourSelected(colourMenu, sg.cs);
426 if (sg.cs != null && sg.cs.conservationApplied())
428 conservationMenuItem.setSelected(true);
430 displayNonconserved.setSelected(sg.getShowNonconserved());
431 showText.setSelected(sg.getDisplayText());
432 showColourText.setSelected(sg.getColourText());
433 showBoxes.setSelected(sg.getDisplayBoxes());
434 // add any groupURLs to the groupURL submenu and make it visible
435 if (groupLinks != null && groupLinks.size() > 0)
437 buildGroupURLMenu(sg, groupLinks);
439 // Add a 'show all structures' for the current selection
440 Hashtable<String, PDBEntry> pdbe = new Hashtable<String, PDBEntry>(), reppdb = new Hashtable<String, PDBEntry>();
441 SequenceI sqass = null;
442 for (SequenceI sq : ap.av.getSequenceSelection())
444 Vector<PDBEntry> pes = sq.getDatasetSequence().getAllPDBEntries();
445 if (pes != null && pes.size() > 0)
447 reppdb.put(pes.get(0).getId(), pes.get(0));
448 for (PDBEntry pe : pes)
450 pdbe.put(pe.getId(), pe);
460 final PDBEntry[] pe = pdbe.values().toArray(
461 new PDBEntry[pdbe.size()]), pr = reppdb.values().toArray(
462 new PDBEntry[reppdb.size()]);
463 final JMenuItem gpdbview, rpdbview;
468 groupMenu.setVisible(false);
469 editMenu.setVisible(false);
474 createGroupMenuItem.setVisible(true);
475 unGroupMenuItem.setVisible(false);
476 jMenu1.setText(MessageManager.getString("action.edit_new_group"));
480 createGroupMenuItem.setVisible(false);
481 unGroupMenuItem.setVisible(true);
482 jMenu1.setText(MessageManager.getString("action.edit_group"));
487 sequenceMenu.setVisible(false);
488 pdbStructureDialog.setVisible(false);
489 rnaStructureMenu.setVisible(false);
492 if (links != null && links.size() > 0)
494 addFeatureLinks(seq, links);
499 * Adds a 'Link' menu item with a sub-menu item for each hyperlink provided.
504 void addFeatureLinks(final SequenceI seq, List<String> links)
506 JMenu linkMenu = new JMenu(MessageManager.getString("action.link"));
507 Map<String, List<String>> linkset = new LinkedHashMap<String, List<String>>();
509 for (String link : links)
511 UrlLink urlLink = null;
514 urlLink = new UrlLink(link);
515 } catch (Exception foo)
517 Cache.log.error("Exception for URLLink '" + link + "'", foo);
521 if (!urlLink.isValid())
523 Cache.log.error(urlLink.getInvalidMessage());
527 urlLink.createLinksFromSeq(seq, linkset);
530 addshowLinks(linkMenu, linkset.values());
532 // disable link menu if there are no valid entries
533 if (linkMenu.getItemCount() > 0)
535 linkMenu.setEnabled(true);
539 linkMenu.setEnabled(false);
542 if (sequence != null)
544 sequenceMenu.add(linkMenu);
556 * Add annotation types to 'Show annotations' and/or 'Hide annotations' menus.
557 * "All" is added first, followed by a separator. Then add any annotation
558 * types associated with the current selection. Separate menus are built for
559 * the selected sequence group (if any), and the selected sequence.
561 * Some annotation rows are always rendered together - these can be identified
562 * by a common graphGroup property > -1. Only one of each group will be marked
563 * as visible (to avoid duplication of the display). For such groups we add a
564 * composite type name, e.g.
566 * IUPredWS (Long), IUPredWS (Short)
570 protected void buildAnnotationTypesMenus(JMenu showMenu, JMenu hideMenu,
571 List<SequenceI> forSequences)
573 showMenu.removeAll();
574 hideMenu.removeAll();
576 final List<String> all = Arrays.asList(new String[] { MessageManager
577 .getString("label.all") });
578 addAnnotationTypeToShowHide(showMenu, forSequences, "", all, true, true);
579 addAnnotationTypeToShowHide(hideMenu, forSequences, "", all, true,
581 showMenu.addSeparator();
582 hideMenu.addSeparator();
584 final AlignmentAnnotation[] annotations = ap.getAlignment()
585 .getAlignmentAnnotation();
588 * Find shown/hidden annotations types, distinguished by source (calcId),
589 * and grouped by graphGroup. Using LinkedHashMap means we will retrieve in
590 * the insertion order, which is the order of the annotations on the
593 Map<String, List<List<String>>> shownTypes = new LinkedHashMap<String, List<List<String>>>();
594 Map<String, List<List<String>>> hiddenTypes = new LinkedHashMap<String, List<List<String>>>();
595 AlignmentAnnotationUtils.getShownHiddenTypes(shownTypes, hiddenTypes,
596 AlignmentAnnotationUtils.asList(annotations), forSequences);
598 for (String calcId : hiddenTypes.keySet())
600 for (List<String> type : hiddenTypes.get(calcId))
602 addAnnotationTypeToShowHide(showMenu, forSequences, calcId, type,
606 // grey out 'show annotations' if none are hidden
607 showMenu.setEnabled(!hiddenTypes.isEmpty());
609 for (String calcId : shownTypes.keySet())
611 for (List<String> type : shownTypes.get(calcId))
613 addAnnotationTypeToShowHide(hideMenu, forSequences, calcId, type,
617 // grey out 'hide annotations' if none are shown
618 hideMenu.setEnabled(!shownTypes.isEmpty());
622 * Returns a list of sequences - either the current selection group (if there
623 * is one), else the specified single sequence.
628 protected List<SequenceI> getSequenceScope(SequenceI seq)
630 List<SequenceI> forSequences = null;
631 final SequenceGroup selectionGroup = ap.av.getSelectionGroup();
632 if (selectionGroup != null && selectionGroup.getSize() > 0)
634 forSequences = selectionGroup.getSequences();
638 forSequences = seq == null ? Collections.<SequenceI> emptyList()
639 : Arrays.asList(seq);
645 * Add one annotation type to the 'Show Annotations' or 'Hide Annotations'
648 * @param showOrHideMenu
650 * @param forSequences
651 * the sequences whose annotations may be shown or hidden
656 * if true this is a special label meaning 'All'
657 * @param actionIsShow
658 * if true, the select menu item action is to show the annotation
661 protected void addAnnotationTypeToShowHide(JMenu showOrHideMenu,
662 final List<SequenceI> forSequences, String calcId,
663 final List<String> types, final boolean allTypes,
664 final boolean actionIsShow)
666 String label = types.toString(); // [a, b, c]
667 label = label.substring(1, label.length() - 1); // a, b, c
668 final JMenuItem item = new JMenuItem(label);
669 item.setToolTipText(calcId);
670 item.addActionListener(new ActionListener()
673 public void actionPerformed(ActionEvent e)
675 AlignmentUtils.showOrHideSequenceAnnotations(ap.getAlignment(),
676 types, forSequences, allTypes, actionIsShow);
680 showOrHideMenu.add(item);
683 private void buildGroupURLMenu(SequenceGroup sg, List<String> groupLinks)
686 // TODO: usability: thread off the generation of group url content so root
688 // sequence only URLs
689 // ID/regex match URLs
690 groupLinksMenu = new JMenu(
691 MessageManager.getString("action.group_link"));
692 // three types of url that might be created.
693 JMenu[] linkMenus = new JMenu[] { null,
694 new JMenu(MessageManager.getString("action.ids")),
695 new JMenu(MessageManager.getString("action.sequences")),
696 new JMenu(MessageManager.getString("action.ids_sequences")) };
698 SequenceI[] seqs = ap.av.getSelectionAsNewSequence();
699 String[][] idandseqs = GroupUrlLink.formStrings(seqs);
700 Hashtable<String, Object[]> commonDbrefs = new Hashtable<String, Object[]>();
701 for (int sq = 0; sq < seqs.length; sq++)
704 int start = seqs[sq].findPosition(sg.getStartRes()), end = seqs[sq]
705 .findPosition(sg.getEndRes());
706 // just collect ids from dataset sequence
707 // TODO: check if IDs collected from selecton group intersects with the
708 // current selection, too
709 SequenceI sqi = seqs[sq];
710 while (sqi.getDatasetSequence() != null)
712 sqi = sqi.getDatasetSequence();
714 DBRefEntry[] dbr = sqi.getDBRefs();
715 if (dbr != null && dbr.length > 0)
717 for (int d = 0; d < dbr.length; d++)
719 String src = dbr[d].getSource(); // jalview.util.DBRefUtils.getCanonicalName(dbr[d].getSource()).toUpperCase();
720 Object[] sarray = commonDbrefs.get(src);
723 sarray = new Object[2];
724 sarray[0] = new int[] { 0 };
725 sarray[1] = new String[seqs.length];
727 commonDbrefs.put(src, sarray);
730 if (((String[]) sarray[1])[sq] == null)
733 || (dbr[d].getMap().locateMappedRange(start, end) != null))
735 ((String[]) sarray[1])[sq] = dbr[d].getAccessionId();
736 ((int[]) sarray[0])[0]++;
742 // now create group links for all distinct ID/sequence sets.
743 boolean addMenu = false; // indicates if there are any group links to give
745 for (String link : groupLinks)
747 GroupUrlLink urlLink = null;
750 urlLink = new GroupUrlLink(link);
751 } catch (Exception foo)
753 Cache.log.error("Exception for GroupURLLink '" + link + "'", foo);
757 if (!urlLink.isValid())
759 Cache.log.error(urlLink.getInvalidMessage());
762 final String label = urlLink.getLabel();
763 boolean usingNames = false;
764 // Now see which parts of the group apply for this URL
765 String ltarget = urlLink.getTarget(); // jalview.util.DBRefUtils.getCanonicalName(urlLink.getTarget());
766 Object[] idset = commonDbrefs.get(ltarget.toUpperCase());
767 String[] seqstr, ids; // input to makeUrl
770 int numinput = ((int[]) idset[0])[0];
771 String[] allids = ((String[]) idset[1]);
772 seqstr = new String[numinput];
773 ids = new String[numinput];
774 for (int sq = 0, idcount = 0; sq < seqs.length; sq++)
776 if (allids[sq] != null)
778 ids[idcount] = allids[sq];
779 seqstr[idcount++] = idandseqs[1][sq];
785 // just use the id/seq set
786 seqstr = idandseqs[1];
790 // and try and make the groupURL!
792 Object[] urlset = null;
795 urlset = urlLink.makeUrlStubs(ids, seqstr,
796 "FromJalview" + System.currentTimeMillis(), false);
797 } catch (UrlStringTooLongException e)
802 int type = urlLink.getGroupURLType() & 3;
803 // first two bits ofurlLink type bitfield are sequenceids and sequences
804 // TODO: FUTURE: ensure the groupURL menu structure can be generalised
805 addshowLink(linkMenus[type], label
806 + (((type & 1) == 1) ? ("("
807 + (usingNames ? "Names" : ltarget) + ")") : ""),
814 groupLinksMenu = new JMenu(
815 MessageManager.getString("action.group_link"));
816 for (int m = 0; m < linkMenus.length; m++)
818 if (linkMenus[m] != null
819 && linkMenus[m].getMenuComponentCount() > 0)
821 groupLinksMenu.add(linkMenus[m]);
825 groupMenu.add(groupLinksMenu);
829 private void addshowLinks(JMenu linkMenu, Collection<List<String>> linkset)
831 for (List<String> linkstrset : linkset)
833 // split linkstr into label and url
834 addshowLink(linkMenu, linkstrset.get(1), linkstrset.get(3));
839 * add a show URL menu item to the given linkMenu
843 * - menu label string
847 private void addshowLink(JMenu linkMenu, String label, final String url)
849 JMenuItem item = new JMenuItem(label);
850 item.setToolTipText(MessageManager.formatMessage(
851 "label.open_url_param", new Object[] { url }));
852 item.addActionListener(new ActionListener()
855 public void actionPerformed(ActionEvent e)
857 new Thread(new Runnable()
874 * add a late bound groupURL item to the given linkMenu
878 * - menu label string
879 * @param urlgenerator
880 * GroupURLLink used to generate URL
882 * Object array returned from the makeUrlStubs function.
884 private void addshowLink(JMenu linkMenu, String label,
885 final GroupUrlLink urlgenerator, final Object[] urlstub)
887 JMenuItem item = new JMenuItem(label);
888 item.setToolTipText(MessageManager.formatMessage(
889 "label.open_url_seqs_param",
890 new Object[] { urlgenerator.getUrl_prefix(),
891 urlgenerator.getNumberInvolved(urlstub) }));
892 // TODO: put in info about what is being sent.
893 item.addActionListener(new ActionListener()
896 public void actionPerformed(ActionEvent e)
898 new Thread(new Runnable()
906 showLink(urlgenerator.constructFrom(urlstub));
907 } catch (UrlStringTooLongException e2)
925 private void jbInit() throws Exception
927 groupMenu.setText(MessageManager.getString("label.selection"));
928 groupName.setText(MessageManager.getString("label.name"));
929 groupName.addActionListener(new ActionListener()
932 public void actionPerformed(ActionEvent e)
934 groupName_actionPerformed();
937 sequenceMenu.setText(MessageManager.getString("label.sequence"));
938 sequenceName.setText(MessageManager
939 .getString("label.edit_name_description"));
940 sequenceName.addActionListener(new ActionListener()
943 public void actionPerformed(ActionEvent e)
945 sequenceName_actionPerformed();
948 chooseAnnotations.setText(MessageManager
949 .getString("action.choose_annotations"));
950 chooseAnnotations.addActionListener(new ActionListener()
953 public void actionPerformed(ActionEvent e)
955 chooseAnnotations_actionPerformed(e);
958 sequenceDetails.setText(MessageManager
959 .getString("label.sequence_details"));
960 sequenceDetails.addActionListener(new ActionListener()
963 public void actionPerformed(ActionEvent e)
965 sequenceDetails_actionPerformed();
968 sequenceSelDetails.setText(MessageManager
969 .getString("label.sequence_details"));
970 sequenceSelDetails.addActionListener(new ActionListener()
973 public void actionPerformed(ActionEvent e)
975 sequenceSelectionDetails_actionPerformed();
979 .setText(MessageManager.getString("action.remove_group"));
980 unGroupMenuItem.addActionListener(new ActionListener()
983 public void actionPerformed(ActionEvent e)
985 unGroupMenuItem_actionPerformed();
988 createGroupMenuItem.setText(MessageManager
989 .getString("action.create_group"));
990 createGroupMenuItem.addActionListener(new ActionListener()
993 public void actionPerformed(ActionEvent e)
995 createGroupMenuItem_actionPerformed();
999 outline.setText(MessageManager.getString("action.border_colour"));
1000 outline.addActionListener(new ActionListener()
1003 public void actionPerformed(ActionEvent e)
1005 outline_actionPerformed();
1008 showBoxes.setText(MessageManager.getString("action.boxes"));
1009 showBoxes.setState(true);
1010 showBoxes.addActionListener(new ActionListener()
1013 public void actionPerformed(ActionEvent e)
1015 showBoxes_actionPerformed();
1018 showText.setText(MessageManager.getString("action.text"));
1019 showText.setState(true);
1020 showText.addActionListener(new ActionListener()
1023 public void actionPerformed(ActionEvent e)
1025 showText_actionPerformed();
1028 showColourText.setText(MessageManager.getString("label.colour_text"));
1029 showColourText.addActionListener(new ActionListener()
1032 public void actionPerformed(ActionEvent e)
1034 showColourText_actionPerformed();
1037 displayNonconserved.setText(MessageManager
1038 .getString("label.show_non_conserved"));
1039 displayNonconserved.setState(true);
1040 displayNonconserved.addActionListener(new ActionListener()
1043 public void actionPerformed(ActionEvent e)
1045 showNonconserved_actionPerformed();
1048 editMenu.setText(MessageManager.getString("action.edit"));
1049 cut.setText(MessageManager.getString("action.cut"));
1050 cut.addActionListener(new ActionListener()
1053 public void actionPerformed(ActionEvent e)
1055 cut_actionPerformed();
1058 upperCase.setText(MessageManager.getString("label.to_upper_case"));
1059 upperCase.addActionListener(new ActionListener()
1062 public void actionPerformed(ActionEvent e)
1067 copy.setText(MessageManager.getString("action.copy"));
1068 copy.addActionListener(new ActionListener()
1071 public void actionPerformed(ActionEvent e)
1073 copy_actionPerformed();
1076 lowerCase.setText(MessageManager.getString("label.to_lower_case"));
1077 lowerCase.addActionListener(new ActionListener()
1080 public void actionPerformed(ActionEvent e)
1085 toggle.setText(MessageManager.getString("label.toggle_case"));
1086 toggle.addActionListener(new ActionListener()
1089 public void actionPerformed(ActionEvent e)
1094 outputMenu.setText(MessageManager.getString("label.out_to_textbox")
1096 seqShowAnnotationsMenu.setText(MessageManager
1097 .getString("label.show_annotations"));
1098 seqHideAnnotationsMenu.setText(MessageManager
1099 .getString("label.hide_annotations"));
1100 groupShowAnnotationsMenu.setText(MessageManager
1101 .getString("label.show_annotations"));
1102 groupHideAnnotationsMenu.setText(MessageManager
1103 .getString("label.hide_annotations"));
1104 sequenceFeature.setText(MessageManager
1105 .getString("label.create_sequence_feature"));
1106 sequenceFeature.addActionListener(new ActionListener()
1109 public void actionPerformed(ActionEvent e)
1111 sequenceFeature_actionPerformed();
1114 jMenu1.setText(MessageManager.getString("label.group"));
1115 pdbStructureDialog.setText(MessageManager
1116 .getString("label.show_pdbstruct_dialog"));
1117 pdbStructureDialog.addActionListener(new ActionListener()
1120 public void actionPerformed(ActionEvent actionEvent)
1122 SequenceI[] selectedSeqs = new SequenceI[] { sequence };
1123 if (ap.av.getSelectionGroup() != null)
1125 selectedSeqs = ap.av.getSequenceSelection();
1127 new StructureChooser(selectedSeqs, sequence, ap);
1131 rnaStructureMenu.setText(MessageManager
1132 .getString("label.view_rna_structure"));
1134 // colStructureMenu.setText("Colour By Structure");
1135 editSequence.setText(MessageManager.getString("label.edit_sequence")
1137 editSequence.addActionListener(new ActionListener()
1140 public void actionPerformed(ActionEvent actionEvent)
1142 editSequence_actionPerformed(actionEvent);
1145 makeReferenceSeq.setText(MessageManager
1146 .getString("label.mark_as_representative"));
1147 makeReferenceSeq.addActionListener(new ActionListener()
1151 public void actionPerformed(ActionEvent actionEvent)
1153 makeReferenceSeq_actionPerformed(actionEvent);
1157 hideInsertions.setText(MessageManager
1158 .getString("label.hide_insertions"));
1159 hideInsertions.addActionListener(new ActionListener()
1163 public void actionPerformed(ActionEvent e)
1165 hideInsertions_actionPerformed(e);
1169 * annotationMenuItem.setText("By Annotation");
1170 * annotationMenuItem.addActionListener(new ActionListener() { public void
1171 * actionPerformed(ActionEvent actionEvent) {
1172 * annotationMenuItem_actionPerformed(actionEvent); } });
1174 groupMenu.add(sequenceSelDetails);
1177 add(rnaStructureMenu);
1178 add(pdbStructureDialog);
1179 if (sequence != null)
1181 add(hideInsertions);
1183 // annotations configuration panel suppressed for now
1184 // groupMenu.add(chooseAnnotations);
1187 * Add show/hide annotations to the Sequence menu, and to the Selection menu
1188 * (if a selection group is in force).
1190 sequenceMenu.add(seqShowAnnotationsMenu);
1191 sequenceMenu.add(seqHideAnnotationsMenu);
1192 sequenceMenu.add(seqAddReferenceAnnotations);
1193 groupMenu.add(groupShowAnnotationsMenu);
1194 groupMenu.add(groupHideAnnotationsMenu);
1195 groupMenu.add(groupAddReferenceAnnotations);
1196 groupMenu.add(editMenu);
1197 groupMenu.add(outputMenu);
1198 groupMenu.add(sequenceFeature);
1199 groupMenu.add(createGroupMenuItem);
1200 groupMenu.add(unGroupMenuItem);
1201 groupMenu.add(jMenu1);
1202 sequenceMenu.add(sequenceName);
1203 sequenceMenu.add(sequenceDetails);
1204 sequenceMenu.add(makeReferenceSeq);
1211 editMenu.add(editSequence);
1212 editMenu.add(upperCase);
1213 editMenu.add(lowerCase);
1214 editMenu.add(toggle);
1215 // JBPNote: These shouldn't be added here - should appear in a generic
1216 // 'apply web service to this sequence menu'
1217 // pdbMenu.add(RNAFold);
1218 // pdbMenu.add(ContraFold);
1219 jMenu1.add(groupName);
1220 jMenu1.add(colourMenu);
1221 jMenu1.add(showBoxes);
1222 jMenu1.add(showText);
1223 jMenu1.add(showColourText);
1224 jMenu1.add(outline);
1225 jMenu1.add(displayNonconserved);
1229 * Constructs the entries for the colour menu
1231 protected void initColourMenu()
1233 colourMenu.setText(MessageManager.getString("label.group_colour"));
1234 textColour.setText(MessageManager.getString("label.text_colour"));
1235 textColour.addActionListener(new ActionListener()
1238 public void actionPerformed(ActionEvent e)
1240 textColour_actionPerformed();
1243 abovePIDColour.setText(MessageManager
1244 .getString("label.above_identity_threshold"));
1245 abovePIDColour.addActionListener(new ActionListener()
1248 public void actionPerformed(ActionEvent e)
1250 abovePIDColour_actionPerformed();
1254 conservationMenuItem.setText(MessageManager
1255 .getString("action.by_conservation"));
1256 conservationMenuItem.addActionListener(new ActionListener()
1259 public void actionPerformed(ActionEvent e)
1261 conservationMenuItem_actionPerformed();
1267 * Builds the group colour sub-menu, including any user-defined colours which
1268 * were loaded at startup or during the Jalview session
1270 protected void buildColourMenu()
1272 SequenceGroup sg = ap.av.getSelectionGroup();
1276 * popup menu with no sequence group scope
1280 colourMenu.removeAll();
1281 colourMenu.add(textColour);
1282 colourMenu.addSeparator();
1284 ColourMenuHelper.addMenuItems(colourMenu, this, sg, false);
1286 colourMenu.addSeparator();
1287 colourMenu.add(conservationMenuItem);
1288 colourMenu.add(abovePIDColour);
1292 * Check for any annotations on the underlying dataset sequences (for the
1293 * current selection group) which are not 'on the alignment'.If any are found,
1294 * enable the option to add them to the alignment. The criteria for 'on the
1295 * alignment' is finding an alignment annotation on the alignment, matched on
1296 * calcId, label and sequenceRef.
1298 * A tooltip is also constructed that displays the source (calcId) and type
1299 * (label) of the annotations that can be added.
1302 * @param forSequences
1304 protected void configureReferenceAnnotationsMenu(JMenuItem menuItem,
1305 List<SequenceI> forSequences)
1307 menuItem.setEnabled(false);
1310 * Temporary store to hold distinct calcId / type pairs for the tooltip.
1311 * Using TreeMap means calcIds are shown in alphabetical order.
1313 SortedMap<String, String> tipEntries = new TreeMap<String, String>();
1314 final Map<SequenceI, List<AlignmentAnnotation>> candidates = new LinkedHashMap<SequenceI, List<AlignmentAnnotation>>();
1315 AlignmentI al = this.ap.av.getAlignment();
1316 AlignmentUtils.findAddableReferenceAnnotations(forSequences,
1317 tipEntries, candidates, al);
1318 if (!candidates.isEmpty())
1320 StringBuilder tooltip = new StringBuilder(64);
1321 tooltip.append(MessageManager.getString("label.add_annotations_for"));
1324 * Found annotations that could be added. Enable the menu item, and
1325 * configure its tooltip and action.
1327 menuItem.setEnabled(true);
1328 for (String calcId : tipEntries.keySet())
1330 tooltip.append("<br/>" + calcId + "/" + tipEntries.get(calcId));
1332 String tooltipText = JvSwingUtils.wrapTooltip(true,
1333 tooltip.toString());
1334 menuItem.setToolTipText(tooltipText);
1336 menuItem.addActionListener(new ActionListener()
1339 public void actionPerformed(ActionEvent e)
1341 addReferenceAnnotations_actionPerformed(candidates);
1348 * Add annotations to the sequences and to the alignment.
1351 * a map whose keys are sequences on the alignment, and values a list
1352 * of annotations to add to each sequence
1354 protected void addReferenceAnnotations_actionPerformed(
1355 Map<SequenceI, List<AlignmentAnnotation>> candidates)
1357 final SequenceGroup selectionGroup = this.ap.av.getSelectionGroup();
1358 final AlignmentI alignment = this.ap.getAlignment();
1359 AlignmentUtils.addReferenceAnnotations(candidates, alignment,
1364 protected void makeReferenceSeq_actionPerformed(ActionEvent actionEvent)
1366 if (!ap.av.getAlignment().hasSeqrep())
1368 // initialise the display flags so the user sees something happen
1369 ap.av.setDisplayReferenceSeq(true);
1370 ap.av.setColourByReferenceSeq(true);
1371 ap.av.getAlignment().setSeqrep(sequence);
1375 if (ap.av.getAlignment().getSeqrep() == sequence)
1377 ap.av.getAlignment().setSeqrep(null);
1381 ap.av.getAlignment().setSeqrep(sequence);
1387 protected void hideInsertions_actionPerformed(ActionEvent actionEvent)
1389 if (sequence != null)
1391 ColumnSelection cs = ap.av.getColumnSelection();
1394 cs = new ColumnSelection();
1396 cs.hideInsertionsFor(sequence);
1397 ap.av.setColumnSelection(cs);
1402 protected void sequenceSelectionDetails_actionPerformed()
1404 createSequenceDetailsReport(ap.av.getSequenceSelection());
1407 protected void sequenceDetails_actionPerformed()
1409 createSequenceDetailsReport(new SequenceI[] { sequence });
1412 public void createSequenceDetailsReport(SequenceI[] sequences)
1414 CutAndPasteHtmlTransfer cap = new CutAndPasteHtmlTransfer();
1415 StringBuilder contents = new StringBuilder(128);
1416 for (SequenceI seq : sequences)
1418 contents.append("<p><h2>"
1421 "label.create_sequence_details_report_annotation_for",
1422 new Object[] { seq.getDisplayId(true) })
1424 new SequenceAnnotationReport(null)
1425 .createSequenceAnnotationReport(
1430 (ap.getSeqPanel().seqCanvas.fr != null) ? ap
1431 .getSeqPanel().seqCanvas.fr.getMinMax()
1433 contents.append("</p>");
1435 cap.setText("<html>" + contents.toString() + "</html>");
1437 Desktop.addInternalFrame(cap, MessageManager.formatMessage(
1438 "label.sequence_details_for",
1439 (sequences.length == 1 ? new Object[] { sequences[0]
1440 .getDisplayId(true) } : new Object[] { MessageManager
1441 .getString("label.selection") })), 500, 400);
1445 protected void showNonconserved_actionPerformed()
1447 getGroup().setShowNonconserved(displayNonconserved.isSelected());
1452 * call to refresh view after settings change
1456 ap.updateAnnotation();
1457 ap.paintAlignment(true);
1459 PaintRefresher.Refresh(this, ap.av.getSequenceSetId());
1463 * protected void covariationColour_actionPerformed() { getGroup().cs = new
1464 * CovariationColourScheme(sequence.getAnnotation()[0]); refresh(); }
1472 protected void abovePIDColour_actionPerformed()
1474 SequenceGroup sg = getGroup();
1480 if (abovePIDColour.isSelected())
1482 sg.cs.setConsensus(AAFrequency.calculate(
1483 sg.getSequences(ap.av.getHiddenRepSequences()),
1484 sg.getStartRes(), sg.getEndRes() + 1));
1486 int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
1489 sg.cs.setThreshold(threshold, ap.av.isIgnoreGapsConsensus());
1491 SliderPanel.showPIDSlider();
1494 // remove PIDColouring
1496 sg.cs.setThreshold(0, ap.av.isIgnoreGapsConsensus());
1503 * Open a panel where the user can choose which types of sequence annotation
1508 protected void chooseAnnotations_actionPerformed(ActionEvent e)
1510 // todo correct way to guard against opening a duplicate panel?
1511 new AnnotationChooser(ap);
1520 protected void conservationMenuItem_actionPerformed()
1522 SequenceGroup sg = getGroup();
1528 if (conservationMenuItem.isSelected())
1530 // JBPNote: Conservation name shouldn't be i18n translated
1531 Conservation c = new Conservation("Group", sg.getSequences(ap.av
1532 .getHiddenRepSequences()), sg.getStartRes(),
1533 sg.getEndRes() + 1);
1536 c.verdict(false, ap.av.getConsPercGaps());
1538 sg.cs.setConservation(c);
1540 SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
1541 SliderPanel.showConservationSlider();
1544 // remove ConservationColouring
1546 sg.cs.setConservation(null);
1552 public void annotationMenuItem_actionPerformed(ActionEvent actionEvent)
1554 SequenceGroup sg = getGroup();
1560 AnnotationColourGradient acg = new AnnotationColourGradient(
1561 sequence.getAnnotation()[0], null,
1562 AnnotationColourGradient.NO_THRESHOLD);
1564 acg.setPredefinedColours(true);
1576 protected void groupName_actionPerformed()
1579 SequenceGroup sg = getGroup();
1580 EditNameDialog dialog = new EditNameDialog(sg.getName(),
1581 sg.getDescription(), " "
1582 + MessageManager.getString("label.group_name") + " ",
1583 MessageManager.getString("label.group_description") + " ",
1584 MessageManager.getString("label.edit_group_name_description"),
1592 sg.setName(dialog.getName());
1593 sg.setDescription(dialog.getDescription());
1598 * Get selection group - adding it to the alignment if necessary.
1600 * @return sequence group to operate on
1602 SequenceGroup getGroup()
1604 SequenceGroup sg = ap.av.getSelectionGroup();
1605 // this method won't add a new group if it already exists
1608 ap.av.getAlignment().addGroup(sg);
1620 void sequenceName_actionPerformed()
1622 EditNameDialog dialog = new EditNameDialog(sequence.getName(),
1623 sequence.getDescription(),
1624 " " + MessageManager.getString("label.sequence_name")
1626 MessageManager.getString("label.sequence_description") + " ",
1628 .getString("label.edit_sequence_name_description"),
1636 if (dialog.getName() != null)
1638 if (dialog.getName().indexOf(" ") > -1)
1644 .getString("label.spaces_converted_to_backslashes"),
1646 .getString("label.no_spaces_allowed_sequence_name"),
1647 JvOptionPane.WARNING_MESSAGE);
1650 sequence.setName(dialog.getName().replace(' ', '_'));
1651 ap.paintAlignment(false);
1654 sequence.setDescription(dialog.getDescription());
1656 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1667 void unGroupMenuItem_actionPerformed()
1669 SequenceGroup sg = ap.av.getSelectionGroup();
1670 ap.av.getAlignment().deleteGroup(sg);
1671 ap.av.setSelectionGroup(null);
1675 void createGroupMenuItem_actionPerformed()
1677 getGroup(); // implicitly creates group - note - should apply defaults / use
1678 // standard alignment window logic for this
1688 protected void outline_actionPerformed()
1690 SequenceGroup sg = getGroup();
1691 Color col = JColorChooser.showDialog(this,
1692 MessageManager.getString("label.select_outline_colour"),
1697 sg.setOutlineColour(col);
1709 public void showBoxes_actionPerformed()
1711 getGroup().setDisplayBoxes(showBoxes.isSelected());
1721 public void showText_actionPerformed()
1723 getGroup().setDisplayText(showText.isSelected());
1733 public void showColourText_actionPerformed()
1735 getGroup().setColourText(showColourText.isSelected());
1739 public void showLink(String url)
1743 jalview.util.BrowserLauncher.openURL(url);
1744 } catch (Exception ex)
1746 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
1747 MessageManager.getString("label.web_browser_not_found_unix"),
1748 MessageManager.getString("label.web_browser_not_found"),
1749 JvOptionPane.WARNING_MESSAGE);
1751 ex.printStackTrace();
1755 void hideSequences(boolean representGroup)
1757 ap.av.hideSequences(sequence, representGroup);
1760 public void copy_actionPerformed()
1762 ap.alignFrame.copy_actionPerformed(null);
1765 public void cut_actionPerformed()
1767 ap.alignFrame.cut_actionPerformed(null);
1770 void changeCase(ActionEvent e)
1772 Object source = e.getSource();
1773 SequenceGroup sg = ap.av.getSelectionGroup();
1777 List<int[]> startEnd = ap.av.getVisibleRegionBoundaries(
1778 sg.getStartRes(), sg.getEndRes() + 1);
1783 if (source == toggle)
1785 description = MessageManager.getString("label.toggle_case");
1786 caseChange = ChangeCaseCommand.TOGGLE_CASE;
1788 else if (source == upperCase)
1790 description = MessageManager.getString("label.to_upper_case");
1791 caseChange = ChangeCaseCommand.TO_UPPER;
1795 description = MessageManager.getString("label.to_lower_case");
1796 caseChange = ChangeCaseCommand.TO_LOWER;
1799 ChangeCaseCommand caseCommand = new ChangeCaseCommand(description,
1800 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
1801 startEnd, caseChange);
1803 ap.alignFrame.addHistoryItem(caseCommand);
1805 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1811 public void outputText_actionPerformed(ActionEvent e)
1813 CutAndPasteTransfer cap = new CutAndPasteTransfer();
1814 cap.setForInput(null);
1815 Desktop.addInternalFrame(cap, MessageManager.formatMessage(
1816 "label.alignment_output_command",
1817 new Object[] { e.getActionCommand() }), 600, 500);
1819 String[] omitHidden = null;
1821 System.out.println("PROMPT USER HERE"); // TODO: decide if a prompt happens
1822 // or we simply trust the user wants
1823 // wysiwig behaviour
1825 FileFormatI fileFormat = FileFormat.forName(e.getActionCommand());
1826 cap.setText(new FormatAdapter(ap).formatSequences(fileFormat, ap, true));
1829 public void sequenceFeature_actionPerformed()
1831 SequenceGroup sg = ap.av.getSelectionGroup();
1837 int rsize = 0, gSize = sg.getSize();
1838 SequenceI[] rseqs, seqs = new SequenceI[gSize];
1839 SequenceFeature[] tfeatures, features = new SequenceFeature[gSize];
1841 for (int i = 0; i < gSize; i++)
1843 int start = sg.getSequenceAt(i).findPosition(sg.getStartRes());
1844 int end = sg.findEndRes(sg.getSequenceAt(i));
1847 seqs[rsize] = sg.getSequenceAt(i).getDatasetSequence();
1848 features[rsize] = new SequenceFeature(null, null, null, start, end,
1853 rseqs = new SequenceI[rsize];
1854 tfeatures = new SequenceFeature[rsize];
1855 System.arraycopy(seqs, 0, rseqs, 0, rsize);
1856 System.arraycopy(features, 0, tfeatures, 0, rsize);
1857 features = tfeatures;
1859 if (ap.getSeqPanel().seqCanvas.getFeatureRenderer().amendFeatures(seqs,
1860 features, true, ap))
1862 ap.alignFrame.setShowSeqFeatures(true);
1863 ap.highlightSearchResults(null);
1867 public void textColour_actionPerformed()
1869 SequenceGroup sg = getGroup();
1872 new TextColourChooser().chooseColour(ap, sg);
1876 public void colourByStructure(String pdbid)
1878 Annotation[] anots = ap.av.getStructureSelectionManager()
1879 .colourSequenceFromStructure(sequence, pdbid);
1881 AlignmentAnnotation an = new AlignmentAnnotation("Structure",
1882 "Coloured by " + pdbid, anots);
1884 ap.av.getAlignment().addAnnotation(an);
1885 an.createSequenceMapping(sequence, 0, true);
1886 // an.adjustForAlignment();
1887 ap.av.getAlignment().setAnnotationIndex(an, 0);
1889 ap.adjustAnnotationHeight();
1891 sequence.addAlignmentAnnotation(an);
1895 public void editSequence_actionPerformed(ActionEvent actionEvent)
1897 SequenceGroup sg = ap.av.getSelectionGroup();
1901 if (sequence == null)
1903 sequence = sg.getSequenceAt(0);
1906 EditNameDialog dialog = new EditNameDialog(
1907 sequence.getSequenceAsString(sg.getStartRes(),
1908 sg.getEndRes() + 1), null,
1909 MessageManager.getString("label.edit_sequence"), null,
1910 MessageManager.getString("label.edit_sequence"),
1915 EditCommand editCommand = new EditCommand(
1916 MessageManager.getString("label.edit_sequences"),
1917 Action.REPLACE, dialog.getName().replace(' ',
1918 ap.av.getGapCharacter()),
1919 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
1920 sg.getStartRes(), sg.getEndRes() + 1, ap.av.getAlignment());
1922 ap.alignFrame.addHistoryItem(editCommand);
1924 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1931 * Action on user selecting an item from the colour menu (that does not have
1932 * its bespoke action handler)
1935 public void changeColour_actionPerformed(String colourSchemeName)
1937 SequenceGroup sg = getGroup();
1938 if (ResidueColourScheme.USER_DEFINED.equals(colourSchemeName))
1941 * open a panel to load or configure a user-defined colour scheme
1943 new UserDefinedColours(ap, sg);
1948 * switch to the chosen colour scheme (or null for None)
1950 sg.cs = ColourSchemes.getInstance().getColourScheme(colourSchemeName,
1951 sg, ap.av.getHiddenRepSequences());
1952 if (sg.cs instanceof Blosum62ColourScheme
1953 || sg.cs instanceof PIDColourScheme)
1955 sg.cs.setConsensus(AAFrequency.calculate(
1956 sg.getSequences(ap.av.getHiddenRepSequences()),
1957 sg.getStartRes(), sg.getEndRes() + 1));