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.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 JMenuItem modifyPID = new JMenuItem();
92 protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem();
94 protected JMenuItem modifyConservation = new JMenuItem();
98 JMenu sequenceMenu = new JMenu();
100 JMenuItem sequenceName = new JMenuItem();
102 JMenuItem sequenceDetails = new JMenuItem();
104 JMenuItem sequenceSelDetails = new JMenuItem();
106 JMenuItem makeReferenceSeq = new JMenuItem();
108 JMenuItem chooseAnnotations = new JMenuItem();
112 JMenuItem createGroupMenuItem = new JMenuItem();
114 JMenuItem unGroupMenuItem = new JMenuItem();
116 JMenuItem outline = new JMenuItem();
118 JMenu colourMenu = new JMenu();
120 JCheckBoxMenuItem showBoxes = new JCheckBoxMenuItem();
122 JCheckBoxMenuItem showText = new JCheckBoxMenuItem();
124 JCheckBoxMenuItem showColourText = new JCheckBoxMenuItem();
126 JCheckBoxMenuItem displayNonconserved = new JCheckBoxMenuItem();
128 JMenu editMenu = new JMenu();
130 JMenuItem cut = new JMenuItem();
132 JMenuItem copy = new JMenuItem();
134 JMenuItem upperCase = new JMenuItem();
136 JMenuItem lowerCase = new JMenuItem();
138 JMenuItem toggle = new JMenuItem();
140 JMenu pdbMenu = new JMenu();
142 JMenu outputMenu = new JMenu();
144 JMenu seqShowAnnotationsMenu = new JMenu();
146 JMenu seqHideAnnotationsMenu = new JMenu();
148 JMenuItem seqAddReferenceAnnotations = new JMenuItem(
149 MessageManager.getString("label.add_reference_annotations"));
151 JMenu groupShowAnnotationsMenu = new JMenu();
153 JMenu groupHideAnnotationsMenu = new JMenu();
155 JMenuItem groupAddReferenceAnnotations = new JMenuItem(
156 MessageManager.getString("label.add_reference_annotations"));
158 JMenuItem sequenceFeature = new JMenuItem();
160 JMenuItem textColour = new JMenuItem();
162 JMenu jMenu1 = new JMenu();
164 JMenuItem pdbStructureDialog = new JMenuItem();
166 JMenu rnaStructureMenu = new JMenu();
168 JMenuItem editSequence = new JMenuItem();
170 JMenu groupLinksMenu;
172 JMenuItem hideInsertions = new JMenuItem();
175 * Creates a new PopupMenu object.
182 public PopupMenu(final AlignmentPanel ap, Sequence seq, List<String> links)
184 this(ap, seq, links, null);
194 public PopupMenu(final AlignmentPanel ap, final SequenceI seq,
195 List<String> links, List<String> groupLinks)
197 // /////////////////////////////////////////////////////////
198 // If this is activated from the sequence panel, the user may want to
199 // edit or annotate a particular residue. Therefore display the residue menu
201 // If from the IDPanel, we must display the sequence menu
202 // ////////////////////////////////////////////////////////
206 for (String ff : FileFormats.getInstance().getWritableFormats(true))
208 JMenuItem item = new JMenuItem(ff);
210 item.addActionListener(new ActionListener()
213 public void actionPerformed(ActionEvent e)
215 outputText_actionPerformed(e);
219 outputMenu.add(item);
223 * Build menus for annotation types that may be shown or hidden, and for
224 * 'reference annotations' that may be added to the alignment. First for the
225 * currently selected sequence (if there is one):
227 final List<SequenceI> selectedSequence = (seq == null ? Collections
228 .<SequenceI> emptyList() : Arrays.asList(seq));
229 buildAnnotationTypesMenus(seqShowAnnotationsMenu,
230 seqHideAnnotationsMenu, selectedSequence);
231 configureReferenceAnnotationsMenu(seqAddReferenceAnnotations,
235 * And repeat for the current selection group (if there is one):
237 final List<SequenceI> selectedGroup = (ap.av.getSelectionGroup() == null ? Collections
238 .<SequenceI> emptyList() : ap.av.getSelectionGroup()
240 buildAnnotationTypesMenus(groupShowAnnotationsMenu,
241 groupHideAnnotationsMenu, selectedGroup);
242 configureReferenceAnnotationsMenu(groupAddReferenceAnnotations,
248 } catch (Exception e)
256 sequenceMenu.setText(sequence.getName());
257 if (seq == ap.av.getAlignment().getSeqrep())
259 makeReferenceSeq.setText(MessageManager
260 .getString("action.unmark_as_reference"));
264 makeReferenceSeq.setText(MessageManager
265 .getString("action.set_as_reference"));
268 if (!ap.av.getAlignment().isNucleotide())
270 remove(rnaStructureMenu);
274 int origCount = rnaStructureMenu.getItemCount();
276 * add menu items to 2D-render any alignment or sequence secondary
277 * structure annotation
279 AlignmentAnnotation[] aas = ap.av.getAlignment()
280 .getAlignmentAnnotation();
283 for (final AlignmentAnnotation aa : aas)
285 if (aa.isValidStruc() && aa.sequenceRef == null)
288 * valid alignment RNA secondary structure annotation
290 menuItem = new JMenuItem();
291 menuItem.setText(MessageManager.formatMessage(
292 "label.2d_rna_structure_line",
293 new Object[] { aa.label }));
294 menuItem.addActionListener(new ActionListener()
297 public void actionPerformed(ActionEvent e)
299 new AppVarna(seq, aa, ap);
302 rnaStructureMenu.add(menuItem);
307 if (seq.getAnnotation() != null)
309 AlignmentAnnotation seqAnns[] = seq.getAnnotation();
310 for (final AlignmentAnnotation aa : seqAnns)
312 if (aa.isValidStruc())
315 * valid sequence RNA secondary structure annotation
317 // TODO: make rnastrucF a bit more nice
318 menuItem = new JMenuItem();
319 menuItem.setText(MessageManager.formatMessage(
320 "label.2d_rna_sequence_name",
321 new Object[] { seq.getName() }));
322 menuItem.addActionListener(new ActionListener()
325 public void actionPerformed(ActionEvent e)
327 // TODO: VARNA does'nt print gaps in the sequence
328 new AppVarna(seq, aa, ap);
331 rnaStructureMenu.add(menuItem);
335 if (rnaStructureMenu.getItemCount() == origCount)
337 remove(rnaStructureMenu);
341 menuItem = new JMenuItem(
342 MessageManager.getString("action.hide_sequences"));
343 menuItem.addActionListener(new ActionListener()
346 public void actionPerformed(ActionEvent e)
348 hideSequences(false);
353 if (ap.av.getSelectionGroup() != null
354 && ap.av.getSelectionGroup().getSize() > 1)
356 menuItem = new JMenuItem(MessageManager.formatMessage(
357 "label.represent_group_with",
358 new Object[] { seq.getName() }));
359 menuItem.addActionListener(new ActionListener()
362 public void actionPerformed(ActionEvent e)
367 sequenceMenu.add(menuItem);
370 if (ap.av.hasHiddenRows())
372 final int index = ap.av.getAlignment().findIndex(seq);
374 if (ap.av.adjustForHiddenSeqs(index)
375 - ap.av.adjustForHiddenSeqs(index - 1) > 1)
377 menuItem = new JMenuItem(
378 MessageManager.getString("action.reveal_sequences"));
379 menuItem.addActionListener(new ActionListener()
382 public void actionPerformed(ActionEvent e)
384 ap.av.showSequence(index);
385 if (ap.overviewPanel != null)
387 ap.overviewPanel.updateOverviewImage();
395 // for the case when no sequences are even visible
396 if (ap.av.hasHiddenRows())
399 menuItem = new JMenuItem(
400 MessageManager.getString("action.reveal_all"));
401 menuItem.addActionListener(new ActionListener()
404 public void actionPerformed(ActionEvent e)
406 ap.av.showAllHiddenSeqs();
407 if (ap.overviewPanel != null)
409 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.cs);
432 if (sg.cs.conservationApplied())
434 conservationMenuItem.setSelected(true);
436 if (sg.cs.getThreshold() > 0)
438 abovePIDColour.setSelected(true);
441 modifyConservation.setEnabled(conservationMenuItem.isSelected());
442 modifyPID.setEnabled(abovePIDColour.isSelected());
443 displayNonconserved.setSelected(sg.getShowNonconserved());
444 showText.setSelected(sg.getDisplayText());
445 showColourText.setSelected(sg.getColourText());
446 showBoxes.setSelected(sg.getDisplayBoxes());
447 // add any groupURLs to the groupURL submenu and make it visible
448 if (groupLinks != null && groupLinks.size() > 0)
450 buildGroupURLMenu(sg, groupLinks);
452 // Add a 'show all structures' for the current selection
453 Hashtable<String, PDBEntry> pdbe = new Hashtable<String, PDBEntry>(), reppdb = new Hashtable<String, PDBEntry>();
454 SequenceI sqass = null;
455 for (SequenceI sq : ap.av.getSequenceSelection())
457 Vector<PDBEntry> pes = sq.getDatasetSequence().getAllPDBEntries();
458 if (pes != null && pes.size() > 0)
460 reppdb.put(pes.get(0).getId(), pes.get(0));
461 for (PDBEntry pe : pes)
463 pdbe.put(pe.getId(), pe);
473 final PDBEntry[] pe = pdbe.values().toArray(
474 new PDBEntry[pdbe.size()]), pr = reppdb.values().toArray(
475 new PDBEntry[reppdb.size()]);
476 final JMenuItem gpdbview, rpdbview;
481 groupMenu.setVisible(false);
482 editMenu.setVisible(false);
487 createGroupMenuItem.setVisible(true);
488 unGroupMenuItem.setVisible(false);
489 jMenu1.setText(MessageManager.getString("action.edit_new_group"));
493 createGroupMenuItem.setVisible(false);
494 unGroupMenuItem.setVisible(true);
495 jMenu1.setText(MessageManager.getString("action.edit_group"));
500 sequenceMenu.setVisible(false);
501 pdbStructureDialog.setVisible(false);
502 rnaStructureMenu.setVisible(false);
505 if (links != null && links.size() > 0)
507 addFeatureLinks(seq, links);
512 * Adds a 'Link' menu item with a sub-menu item for each hyperlink provided.
517 void addFeatureLinks(final SequenceI seq, List<String> links)
519 JMenu linkMenu = new JMenu(MessageManager.getString("action.link"));
520 Map<String, List<String>> linkset = new LinkedHashMap<String, List<String>>();
522 for (String link : links)
524 UrlLink urlLink = null;
527 urlLink = new UrlLink(link);
528 } catch (Exception foo)
530 Cache.log.error("Exception for URLLink '" + link + "'", foo);
534 if (!urlLink.isValid())
536 Cache.log.error(urlLink.getInvalidMessage());
540 urlLink.createLinksFromSeq(seq, linkset);
543 addshowLinks(linkMenu, linkset.values());
545 // disable link menu if there are no valid entries
546 if (linkMenu.getItemCount() > 0)
548 linkMenu.setEnabled(true);
552 linkMenu.setEnabled(false);
555 if (sequence != null)
557 sequenceMenu.add(linkMenu);
567 * Add annotation types to 'Show annotations' and/or 'Hide annotations' menus.
568 * "All" is added first, followed by a separator. Then add any annotation
569 * types associated with the current selection. Separate menus are built for
570 * the selected sequence group (if any), and the selected sequence.
572 * Some annotation rows are always rendered together - these can be identified
573 * by a common graphGroup property > -1. Only one of each group will be marked
574 * as visible (to avoid duplication of the display). For such groups we add a
575 * composite type name, e.g.
577 * IUPredWS (Long), IUPredWS (Short)
581 protected void buildAnnotationTypesMenus(JMenu showMenu, JMenu hideMenu,
582 List<SequenceI> forSequences)
584 showMenu.removeAll();
585 hideMenu.removeAll();
587 final List<String> all = Arrays.asList(new String[] { MessageManager
588 .getString("label.all") });
589 addAnnotationTypeToShowHide(showMenu, forSequences, "", all, true, true);
590 addAnnotationTypeToShowHide(hideMenu, forSequences, "", all, true,
592 showMenu.addSeparator();
593 hideMenu.addSeparator();
595 final AlignmentAnnotation[] annotations = ap.getAlignment()
596 .getAlignmentAnnotation();
599 * Find shown/hidden annotations types, distinguished by source (calcId),
600 * and grouped by graphGroup. Using LinkedHashMap means we will retrieve in
601 * the insertion order, which is the order of the annotations on the
604 Map<String, List<List<String>>> shownTypes = new LinkedHashMap<String, List<List<String>>>();
605 Map<String, List<List<String>>> hiddenTypes = new LinkedHashMap<String, List<List<String>>>();
606 AlignmentAnnotationUtils.getShownHiddenTypes(shownTypes, hiddenTypes,
607 AlignmentAnnotationUtils.asList(annotations), forSequences);
609 for (String calcId : hiddenTypes.keySet())
611 for (List<String> type : hiddenTypes.get(calcId))
613 addAnnotationTypeToShowHide(showMenu, forSequences, calcId, type,
617 // grey out 'show annotations' if none are hidden
618 showMenu.setEnabled(!hiddenTypes.isEmpty());
620 for (String calcId : shownTypes.keySet())
622 for (List<String> type : shownTypes.get(calcId))
624 addAnnotationTypeToShowHide(hideMenu, forSequences, calcId, type,
628 // grey out 'hide annotations' if none are shown
629 hideMenu.setEnabled(!shownTypes.isEmpty());
633 * Returns a list of sequences - either the current selection group (if there
634 * is one), else the specified single sequence.
639 protected List<SequenceI> getSequenceScope(SequenceI seq)
641 List<SequenceI> forSequences = null;
642 final SequenceGroup selectionGroup = ap.av.getSelectionGroup();
643 if (selectionGroup != null && selectionGroup.getSize() > 0)
645 forSequences = selectionGroup.getSequences();
649 forSequences = seq == null ? Collections.<SequenceI> emptyList()
650 : Arrays.asList(seq);
656 * Add one annotation type to the 'Show Annotations' or 'Hide Annotations'
659 * @param showOrHideMenu
661 * @param forSequences
662 * the sequences whose annotations may be shown or hidden
667 * if true this is a special label meaning 'All'
668 * @param actionIsShow
669 * if true, the select menu item action is to show the annotation
672 protected void addAnnotationTypeToShowHide(JMenu showOrHideMenu,
673 final List<SequenceI> forSequences, String calcId,
674 final List<String> types, final boolean allTypes,
675 final boolean actionIsShow)
677 String label = types.toString(); // [a, b, c]
678 label = label.substring(1, label.length() - 1); // a, b, c
679 final JMenuItem item = new JMenuItem(label);
680 item.setToolTipText(calcId);
681 item.addActionListener(new ActionListener()
684 public void actionPerformed(ActionEvent e)
686 AlignmentUtils.showOrHideSequenceAnnotations(ap.getAlignment(),
687 types, forSequences, allTypes, actionIsShow);
691 showOrHideMenu.add(item);
694 private void buildGroupURLMenu(SequenceGroup sg, List<String> groupLinks)
697 // TODO: usability: thread off the generation of group url content so root
699 // sequence only URLs
700 // ID/regex match URLs
701 groupLinksMenu = new JMenu(
702 MessageManager.getString("action.group_link"));
703 // three types of url that might be created.
704 JMenu[] linkMenus = new JMenu[] { null,
705 new JMenu(MessageManager.getString("action.ids")),
706 new JMenu(MessageManager.getString("action.sequences")),
707 new JMenu(MessageManager.getString("action.ids_sequences")) };
709 SequenceI[] seqs = ap.av.getSelectionAsNewSequence();
710 String[][] idandseqs = GroupUrlLink.formStrings(seqs);
711 Hashtable<String, Object[]> commonDbrefs = new Hashtable<String, Object[]>();
712 for (int sq = 0; sq < seqs.length; sq++)
715 int start = seqs[sq].findPosition(sg.getStartRes()), end = seqs[sq]
716 .findPosition(sg.getEndRes());
717 // just collect ids from dataset sequence
718 // TODO: check if IDs collected from selecton group intersects with the
719 // current selection, too
720 SequenceI sqi = seqs[sq];
721 while (sqi.getDatasetSequence() != null)
723 sqi = sqi.getDatasetSequence();
725 DBRefEntry[] dbr = sqi.getDBRefs();
726 if (dbr != null && dbr.length > 0)
728 for (int d = 0; d < dbr.length; d++)
730 String src = dbr[d].getSource(); // jalview.util.DBRefUtils.getCanonicalName(dbr[d].getSource()).toUpperCase();
731 Object[] sarray = commonDbrefs.get(src);
734 sarray = new Object[2];
735 sarray[0] = new int[] { 0 };
736 sarray[1] = new String[seqs.length];
738 commonDbrefs.put(src, sarray);
741 if (((String[]) sarray[1])[sq] == null)
744 || (dbr[d].getMap().locateMappedRange(start, end) != null))
746 ((String[]) sarray[1])[sq] = dbr[d].getAccessionId();
747 ((int[]) sarray[0])[0]++;
753 // now create group links for all distinct ID/sequence sets.
754 boolean addMenu = false; // indicates if there are any group links to give
756 for (String link : groupLinks)
758 GroupUrlLink urlLink = null;
761 urlLink = new GroupUrlLink(link);
762 } catch (Exception foo)
764 Cache.log.error("Exception for GroupURLLink '" + link + "'", foo);
768 if (!urlLink.isValid())
770 Cache.log.error(urlLink.getInvalidMessage());
773 final String label = urlLink.getLabel();
774 boolean usingNames = false;
775 // Now see which parts of the group apply for this URL
776 String ltarget = urlLink.getTarget(); // jalview.util.DBRefUtils.getCanonicalName(urlLink.getTarget());
777 Object[] idset = commonDbrefs.get(ltarget.toUpperCase());
778 String[] seqstr, ids; // input to makeUrl
781 int numinput = ((int[]) idset[0])[0];
782 String[] allids = ((String[]) idset[1]);
783 seqstr = new String[numinput];
784 ids = new String[numinput];
785 for (int sq = 0, idcount = 0; sq < seqs.length; sq++)
787 if (allids[sq] != null)
789 ids[idcount] = allids[sq];
790 seqstr[idcount++] = idandseqs[1][sq];
796 // just use the id/seq set
797 seqstr = idandseqs[1];
801 // and try and make the groupURL!
803 Object[] urlset = null;
806 urlset = urlLink.makeUrlStubs(ids, seqstr,
807 "FromJalview" + System.currentTimeMillis(), false);
808 } catch (UrlStringTooLongException e)
813 int type = urlLink.getGroupURLType() & 3;
814 // first two bits ofurlLink type bitfield are sequenceids and sequences
815 // TODO: FUTURE: ensure the groupURL menu structure can be generalised
816 addshowLink(linkMenus[type], label
817 + (((type & 1) == 1) ? ("("
818 + (usingNames ? "Names" : ltarget) + ")") : ""),
825 groupLinksMenu = new JMenu(
826 MessageManager.getString("action.group_link"));
827 for (int m = 0; m < linkMenus.length; m++)
829 if (linkMenus[m] != null
830 && linkMenus[m].getMenuComponentCount() > 0)
832 groupLinksMenu.add(linkMenus[m]);
836 groupMenu.add(groupLinksMenu);
840 private void addshowLinks(JMenu linkMenu, Collection<List<String>> linkset)
842 for (List<String> linkstrset : linkset)
844 // split linkstr into label and url
845 addshowLink(linkMenu, linkstrset.get(1), linkstrset.get(3));
850 * add a show URL menu item to the given linkMenu
854 * - menu label string
858 private void addshowLink(JMenu linkMenu, String label, final String url)
860 JMenuItem item = new JMenuItem(label);
861 item.setToolTipText(MessageManager.formatMessage(
862 "label.open_url_param", new Object[] { url }));
863 item.addActionListener(new ActionListener()
866 public void actionPerformed(ActionEvent e)
868 new Thread(new Runnable()
885 * add a late bound groupURL item to the given linkMenu
889 * - menu label string
890 * @param urlgenerator
891 * GroupURLLink used to generate URL
893 * Object array returned from the makeUrlStubs function.
895 private void addshowLink(JMenu linkMenu, String label,
896 final GroupUrlLink urlgenerator, final Object[] urlstub)
898 JMenuItem item = new JMenuItem(label);
899 item.setToolTipText(MessageManager.formatMessage(
900 "label.open_url_seqs_param",
901 new Object[] { urlgenerator.getUrl_prefix(),
902 urlgenerator.getNumberInvolved(urlstub) }));
903 // TODO: put in info about what is being sent.
904 item.addActionListener(new ActionListener()
907 public void actionPerformed(ActionEvent e)
909 new Thread(new Runnable()
917 showLink(urlgenerator.constructFrom(urlstub));
918 } catch (UrlStringTooLongException e2)
936 private void jbInit() throws Exception
938 groupMenu.setText(MessageManager.getString("label.selection"));
939 groupName.setText(MessageManager.getString("label.name"));
940 groupName.addActionListener(new ActionListener()
943 public void actionPerformed(ActionEvent e)
945 groupName_actionPerformed();
948 sequenceMenu.setText(MessageManager.getString("label.sequence"));
949 sequenceName.setText(MessageManager
950 .getString("label.edit_name_description"));
951 sequenceName.addActionListener(new ActionListener()
954 public void actionPerformed(ActionEvent e)
956 sequenceName_actionPerformed();
959 chooseAnnotations.setText(MessageManager
960 .getString("action.choose_annotations"));
961 chooseAnnotations.addActionListener(new ActionListener()
964 public void actionPerformed(ActionEvent e)
966 chooseAnnotations_actionPerformed(e);
969 sequenceDetails.setText(MessageManager
970 .getString("label.sequence_details"));
971 sequenceDetails.addActionListener(new ActionListener()
974 public void actionPerformed(ActionEvent e)
976 sequenceDetails_actionPerformed();
979 sequenceSelDetails.setText(MessageManager
980 .getString("label.sequence_details"));
981 sequenceSelDetails.addActionListener(new ActionListener()
984 public void actionPerformed(ActionEvent e)
986 sequenceSelectionDetails_actionPerformed();
991 .setText(MessageManager.getString("action.remove_group"));
992 unGroupMenuItem.addActionListener(new ActionListener()
995 public void actionPerformed(ActionEvent e)
997 unGroupMenuItem_actionPerformed();
1000 createGroupMenuItem.setText(MessageManager
1001 .getString("action.create_group"));
1002 createGroupMenuItem.addActionListener(new ActionListener()
1005 public void actionPerformed(ActionEvent e)
1007 createGroupMenuItem_actionPerformed();
1011 outline.setText(MessageManager.getString("action.border_colour"));
1012 outline.addActionListener(new ActionListener()
1015 public void actionPerformed(ActionEvent e)
1017 outline_actionPerformed();
1020 showBoxes.setText(MessageManager.getString("action.boxes"));
1021 showBoxes.setState(true);
1022 showBoxes.addActionListener(new ActionListener()
1025 public void actionPerformed(ActionEvent e)
1027 showBoxes_actionPerformed();
1030 showText.setText(MessageManager.getString("action.text"));
1031 showText.setState(true);
1032 showText.addActionListener(new ActionListener()
1035 public void actionPerformed(ActionEvent e)
1037 showText_actionPerformed();
1040 showColourText.setText(MessageManager.getString("label.colour_text"));
1041 showColourText.addActionListener(new ActionListener()
1044 public void actionPerformed(ActionEvent e)
1046 showColourText_actionPerformed();
1049 displayNonconserved.setText(MessageManager
1050 .getString("label.show_non_conserved"));
1051 displayNonconserved.setState(true);
1052 displayNonconserved.addActionListener(new ActionListener()
1055 public void actionPerformed(ActionEvent e)
1057 showNonconserved_actionPerformed();
1060 editMenu.setText(MessageManager.getString("action.edit"));
1061 cut.setText(MessageManager.getString("action.cut"));
1062 cut.addActionListener(new ActionListener()
1065 public void actionPerformed(ActionEvent e)
1067 cut_actionPerformed();
1070 upperCase.setText(MessageManager.getString("label.to_upper_case"));
1071 upperCase.addActionListener(new ActionListener()
1074 public void actionPerformed(ActionEvent e)
1079 copy.setText(MessageManager.getString("action.copy"));
1080 copy.addActionListener(new ActionListener()
1083 public void actionPerformed(ActionEvent e)
1085 copy_actionPerformed();
1088 lowerCase.setText(MessageManager.getString("label.to_lower_case"));
1089 lowerCase.addActionListener(new ActionListener()
1092 public void actionPerformed(ActionEvent e)
1097 toggle.setText(MessageManager.getString("label.toggle_case"));
1098 toggle.addActionListener(new ActionListener()
1101 public void actionPerformed(ActionEvent e)
1106 outputMenu.setText(MessageManager.getString("label.out_to_textbox")
1108 seqShowAnnotationsMenu.setText(MessageManager
1109 .getString("label.show_annotations"));
1110 seqHideAnnotationsMenu.setText(MessageManager
1111 .getString("label.hide_annotations"));
1112 groupShowAnnotationsMenu.setText(MessageManager
1113 .getString("label.show_annotations"));
1114 groupHideAnnotationsMenu.setText(MessageManager
1115 .getString("label.hide_annotations"));
1116 sequenceFeature.setText(MessageManager
1117 .getString("label.create_sequence_feature"));
1118 sequenceFeature.addActionListener(new ActionListener()
1121 public void actionPerformed(ActionEvent e)
1123 sequenceFeature_actionPerformed();
1126 jMenu1.setText(MessageManager.getString("label.group"));
1127 pdbStructureDialog.setText(MessageManager
1128 .getString("label.show_pdbstruct_dialog"));
1129 pdbStructureDialog.addActionListener(new ActionListener()
1132 public void actionPerformed(ActionEvent actionEvent)
1134 SequenceI[] selectedSeqs = new SequenceI[] { sequence };
1135 if (ap.av.getSelectionGroup() != null)
1137 selectedSeqs = ap.av.getSequenceSelection();
1139 new StructureChooser(selectedSeqs, sequence, ap);
1143 rnaStructureMenu.setText(MessageManager
1144 .getString("label.view_rna_structure"));
1146 // colStructureMenu.setText("Colour By Structure");
1147 editSequence.setText(MessageManager.getString("label.edit_sequence")
1149 editSequence.addActionListener(new ActionListener()
1152 public void actionPerformed(ActionEvent actionEvent)
1154 editSequence_actionPerformed(actionEvent);
1157 makeReferenceSeq.setText(MessageManager
1158 .getString("label.mark_as_representative"));
1159 makeReferenceSeq.addActionListener(new ActionListener()
1163 public void actionPerformed(ActionEvent actionEvent)
1165 makeReferenceSeq_actionPerformed(actionEvent);
1169 hideInsertions.setText(MessageManager
1170 .getString("label.hide_insertions"));
1171 hideInsertions.addActionListener(new ActionListener()
1175 public void actionPerformed(ActionEvent e)
1177 hideInsertions_actionPerformed(e);
1181 * annotationMenuItem.setText("By Annotation");
1182 * annotationMenuItem.addActionListener(new ActionListener() { public void
1183 * actionPerformed(ActionEvent actionEvent) {
1184 * annotationMenuItem_actionPerformed(actionEvent); } });
1186 groupMenu.add(sequenceSelDetails);
1189 add(rnaStructureMenu);
1190 add(pdbStructureDialog);
1191 if (sequence != null)
1193 add(hideInsertions);
1195 // annotations configuration panel suppressed for now
1196 // groupMenu.add(chooseAnnotations);
1199 * Add show/hide annotations to the Sequence menu, and to the Selection menu
1200 * (if a selection group is in force).
1202 sequenceMenu.add(seqShowAnnotationsMenu);
1203 sequenceMenu.add(seqHideAnnotationsMenu);
1204 sequenceMenu.add(seqAddReferenceAnnotations);
1205 groupMenu.add(groupShowAnnotationsMenu);
1206 groupMenu.add(groupHideAnnotationsMenu);
1207 groupMenu.add(groupAddReferenceAnnotations);
1208 groupMenu.add(editMenu);
1209 groupMenu.add(outputMenu);
1210 groupMenu.add(sequenceFeature);
1211 groupMenu.add(createGroupMenuItem);
1212 groupMenu.add(unGroupMenuItem);
1213 groupMenu.add(jMenu1);
1214 sequenceMenu.add(sequenceName);
1215 sequenceMenu.add(sequenceDetails);
1216 sequenceMenu.add(makeReferenceSeq);
1223 editMenu.add(editSequence);
1224 editMenu.add(upperCase);
1225 editMenu.add(lowerCase);
1226 editMenu.add(toggle);
1227 // JBPNote: These shouldn't be added here - should appear in a generic
1228 // 'apply web service to this sequence menu'
1229 // pdbMenu.add(RNAFold);
1230 // pdbMenu.add(ContraFold);
1231 jMenu1.add(groupName);
1232 jMenu1.add(colourMenu);
1233 jMenu1.add(showBoxes);
1234 jMenu1.add(showText);
1235 jMenu1.add(showColourText);
1236 jMenu1.add(outline);
1237 jMenu1.add(displayNonconserved);
1241 * Constructs the entries for the colour menu
1243 protected void initColourMenu()
1245 colourMenu.setText(MessageManager.getString("label.group_colour"));
1246 textColour.setText(MessageManager.getString("label.text_colour"));
1247 textColour.addActionListener(new ActionListener()
1250 public void actionPerformed(ActionEvent e)
1252 textColour_actionPerformed();
1256 abovePIDColour.setText(MessageManager
1257 .getString("label.above_identity_threshold"));
1258 abovePIDColour.addActionListener(new ActionListener()
1261 public void actionPerformed(ActionEvent e)
1263 abovePIDColour_actionPerformed();
1267 modifyPID.setText(MessageManager
1268 .getString("label.modify_identity_threshold"));
1269 modifyPID.addActionListener(new ActionListener()
1272 public void actionPerformed(ActionEvent e)
1274 modifyPID_actionPerformed();
1278 conservationMenuItem.setText(MessageManager
1279 .getString("action.by_conservation"));
1280 conservationMenuItem.addActionListener(new ActionListener()
1283 public void actionPerformed(ActionEvent e)
1285 conservationMenuItem_actionPerformed();
1289 modifyConservation.setText(MessageManager
1290 .getString("label.modify_conservation_threshold"));
1291 modifyConservation.addActionListener(new ActionListener()
1294 public void actionPerformed(ActionEvent e)
1296 modifyConservation_actionPerformed();
1302 * Builds the group colour sub-menu, including any user-defined colours which
1303 * were loaded at startup or during the Jalview session
1305 protected void buildColourMenu()
1307 SequenceGroup sg = ap.av.getSelectionGroup();
1311 * popup menu with no sequence group scope
1315 colourMenu.removeAll();
1316 colourMenu.add(textColour);
1317 colourMenu.addSeparator();
1319 ColourMenuHelper.addMenuItems(colourMenu, this, sg, false);
1321 colourMenu.addSeparator();
1322 colourMenu.add(conservationMenuItem);
1323 colourMenu.add(modifyConservation);
1324 colourMenu.add(abovePIDColour);
1325 colourMenu.add(modifyPID);
1328 protected void modifyConservation_actionPerformed()
1330 SequenceGroup sg = getGroup();
1333 SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
1334 SliderPanel.showConservationSlider();
1338 protected void modifyPID_actionPerformed()
1340 SequenceGroup sg = getGroup();
1343 // int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
1345 // sg.cs.setThreshold(threshold, ap.av.isIgnoreGapsConsensus());
1346 SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
1348 SliderPanel.showPIDSlider();
1353 * Check for any annotations on the underlying dataset sequences (for the
1354 * current selection group) which are not 'on the alignment'.If any are found,
1355 * enable the option to add them to the alignment. The criteria for 'on the
1356 * alignment' is finding an alignment annotation on the alignment, matched on
1357 * calcId, label and sequenceRef.
1359 * A tooltip is also constructed that displays the source (calcId) and type
1360 * (label) of the annotations that can be added.
1363 * @param forSequences
1365 protected void configureReferenceAnnotationsMenu(JMenuItem menuItem,
1366 List<SequenceI> forSequences)
1368 menuItem.setEnabled(false);
1371 * Temporary store to hold distinct calcId / type pairs for the tooltip.
1372 * Using TreeMap means calcIds are shown in alphabetical order.
1374 SortedMap<String, String> tipEntries = new TreeMap<String, String>();
1375 final Map<SequenceI, List<AlignmentAnnotation>> candidates = new LinkedHashMap<SequenceI, List<AlignmentAnnotation>>();
1376 AlignmentI al = this.ap.av.getAlignment();
1377 AlignmentUtils.findAddableReferenceAnnotations(forSequences,
1378 tipEntries, candidates, al);
1379 if (!candidates.isEmpty())
1381 StringBuilder tooltip = new StringBuilder(64);
1382 tooltip.append(MessageManager.getString("label.add_annotations_for"));
1385 * Found annotations that could be added. Enable the menu item, and
1386 * configure its tooltip and action.
1388 menuItem.setEnabled(true);
1389 for (String calcId : tipEntries.keySet())
1391 tooltip.append("<br/>" + calcId + "/" + tipEntries.get(calcId));
1393 String tooltipText = JvSwingUtils.wrapTooltip(true,
1394 tooltip.toString());
1395 menuItem.setToolTipText(tooltipText);
1397 menuItem.addActionListener(new ActionListener()
1400 public void actionPerformed(ActionEvent e)
1402 addReferenceAnnotations_actionPerformed(candidates);
1409 * Add annotations to the sequences and to the alignment.
1412 * a map whose keys are sequences on the alignment, and values a list
1413 * of annotations to add to each sequence
1415 protected void addReferenceAnnotations_actionPerformed(
1416 Map<SequenceI, List<AlignmentAnnotation>> candidates)
1418 final SequenceGroup selectionGroup = this.ap.av.getSelectionGroup();
1419 final AlignmentI alignment = this.ap.getAlignment();
1420 AlignmentUtils.addReferenceAnnotations(candidates, alignment,
1425 protected void makeReferenceSeq_actionPerformed(ActionEvent actionEvent)
1427 if (!ap.av.getAlignment().hasSeqrep())
1429 // initialise the display flags so the user sees something happen
1430 ap.av.setDisplayReferenceSeq(true);
1431 ap.av.setColourByReferenceSeq(true);
1432 ap.av.getAlignment().setSeqrep(sequence);
1436 if (ap.av.getAlignment().getSeqrep() == sequence)
1438 ap.av.getAlignment().setSeqrep(null);
1442 ap.av.getAlignment().setSeqrep(sequence);
1448 protected void hideInsertions_actionPerformed(ActionEvent actionEvent)
1450 if (sequence != null)
1452 ColumnSelection cs = ap.av.getColumnSelection();
1455 cs = new ColumnSelection();
1457 cs.hideInsertionsFor(sequence);
1458 ap.av.setColumnSelection(cs);
1463 protected void sequenceSelectionDetails_actionPerformed()
1465 createSequenceDetailsReport(ap.av.getSequenceSelection());
1468 protected void sequenceDetails_actionPerformed()
1470 createSequenceDetailsReport(new SequenceI[] { sequence });
1473 public void createSequenceDetailsReport(SequenceI[] sequences)
1475 CutAndPasteHtmlTransfer cap = new CutAndPasteHtmlTransfer();
1476 StringBuilder contents = new StringBuilder(128);
1477 for (SequenceI seq : sequences)
1479 contents.append("<p><h2>"
1482 "label.create_sequence_details_report_annotation_for",
1483 new Object[] { seq.getDisplayId(true) })
1485 new SequenceAnnotationReport(null)
1486 .createSequenceAnnotationReport(
1491 (ap.getSeqPanel().seqCanvas.fr != null) ? ap
1492 .getSeqPanel().seqCanvas.fr.getMinMax()
1494 contents.append("</p>");
1496 cap.setText("<html>" + contents.toString() + "</html>");
1498 Desktop.addInternalFrame(cap, MessageManager.formatMessage(
1499 "label.sequence_details_for",
1500 (sequences.length == 1 ? new Object[] { sequences[0]
1501 .getDisplayId(true) } : new Object[] { MessageManager
1502 .getString("label.selection") })), 500, 400);
1506 protected void showNonconserved_actionPerformed()
1508 getGroup().setShowNonconserved(displayNonconserved.isSelected());
1513 * call to refresh view after settings change
1517 ap.updateAnnotation();
1518 ap.paintAlignment(true);
1520 PaintRefresher.Refresh(this, ap.av.getSequenceSetId());
1524 * protected void covariationColour_actionPerformed() { getGroup().cs = new
1525 * CovariationColourScheme(sequence.getAnnotation()[0]); refresh(); }
1533 protected void abovePIDColour_actionPerformed()
1535 SequenceGroup sg = getGroup();
1541 boolean selected = abovePIDColour.isSelected();
1544 sg.cs.setConsensus(AAFrequency.calculate(
1545 sg.getSequences(ap.av.getHiddenRepSequences()),
1546 sg.getStartRes(), sg.getEndRes() + 1));
1548 int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
1551 sg.cs.setThreshold(threshold, ap.av.isIgnoreGapsConsensus());
1553 SliderPanel.showPIDSlider();
1556 // remove PIDColouring
1558 sg.cs.setThreshold(0, ap.av.isIgnoreGapsConsensus());
1559 SliderPanel.hidePIDSlider();
1561 modifyPID.setEnabled(selected);
1567 * Open a panel where the user can choose which types of sequence annotation
1572 protected void chooseAnnotations_actionPerformed(ActionEvent e)
1574 // todo correct way to guard against opening a duplicate panel?
1575 new AnnotationChooser(ap);
1584 protected void conservationMenuItem_actionPerformed()
1586 SequenceGroup sg = getGroup();
1592 boolean selected = conservationMenuItem.isSelected();
1595 // JBPNote: Conservation name shouldn't be i18n translated
1596 Conservation c = new Conservation("Group", sg.getSequences(ap.av
1597 .getHiddenRepSequences()), sg.getStartRes(),
1598 sg.getEndRes() + 1);
1601 c.verdict(false, ap.av.getConsPercGaps());
1603 sg.cs.setConservation(c);
1605 SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
1606 SliderPanel.showConservationSlider();
1609 // remove ConservationColouring
1611 sg.cs.setConservation(null);
1612 SliderPanel.hideConservationSlider();
1614 modifyConservation.setEnabled(selected);
1619 public void annotationMenuItem_actionPerformed(ActionEvent actionEvent)
1621 SequenceGroup sg = getGroup();
1627 AnnotationColourGradient acg = new AnnotationColourGradient(
1628 sequence.getAnnotation()[0], null,
1629 AnnotationColourGradient.NO_THRESHOLD);
1631 acg.setPredefinedColours(true);
1643 protected void groupName_actionPerformed()
1646 SequenceGroup sg = getGroup();
1647 EditNameDialog dialog = new EditNameDialog(sg.getName(),
1648 sg.getDescription(), " "
1649 + MessageManager.getString("label.group_name") + " ",
1650 MessageManager.getString("label.group_description") + " ",
1651 MessageManager.getString("label.edit_group_name_description"),
1659 sg.setName(dialog.getName());
1660 sg.setDescription(dialog.getDescription());
1665 * Get selection group - adding it to the alignment if necessary.
1667 * @return sequence group to operate on
1669 SequenceGroup getGroup()
1671 SequenceGroup sg = ap.av.getSelectionGroup();
1672 // this method won't add a new group if it already exists
1675 ap.av.getAlignment().addGroup(sg);
1687 void sequenceName_actionPerformed()
1689 EditNameDialog dialog = new EditNameDialog(sequence.getName(),
1690 sequence.getDescription(),
1691 " " + MessageManager.getString("label.sequence_name")
1693 MessageManager.getString("label.sequence_description") + " ",
1695 .getString("label.edit_sequence_name_description"),
1703 if (dialog.getName() != null)
1705 if (dialog.getName().indexOf(" ") > -1)
1711 .getString("label.spaces_converted_to_backslashes"),
1713 .getString("label.no_spaces_allowed_sequence_name"),
1714 JvOptionPane.WARNING_MESSAGE);
1717 sequence.setName(dialog.getName().replace(' ', '_'));
1718 ap.paintAlignment(false);
1721 sequence.setDescription(dialog.getDescription());
1723 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1734 void unGroupMenuItem_actionPerformed()
1736 SequenceGroup sg = ap.av.getSelectionGroup();
1737 ap.av.getAlignment().deleteGroup(sg);
1738 ap.av.setSelectionGroup(null);
1742 void createGroupMenuItem_actionPerformed()
1744 getGroup(); // implicitly creates group - note - should apply defaults / use
1745 // standard alignment window logic for this
1755 protected void outline_actionPerformed()
1757 SequenceGroup sg = getGroup();
1758 Color col = JColorChooser.showDialog(this,
1759 MessageManager.getString("label.select_outline_colour"),
1764 sg.setOutlineColour(col);
1776 public void showBoxes_actionPerformed()
1778 getGroup().setDisplayBoxes(showBoxes.isSelected());
1788 public void showText_actionPerformed()
1790 getGroup().setDisplayText(showText.isSelected());
1800 public void showColourText_actionPerformed()
1802 getGroup().setColourText(showColourText.isSelected());
1806 public void showLink(String url)
1810 jalview.util.BrowserLauncher.openURL(url);
1811 } catch (Exception ex)
1813 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
1814 MessageManager.getString("label.web_browser_not_found_unix"),
1815 MessageManager.getString("label.web_browser_not_found"),
1816 JvOptionPane.WARNING_MESSAGE);
1818 ex.printStackTrace();
1822 void hideSequences(boolean representGroup)
1824 ap.av.hideSequences(sequence, representGroup);
1827 public void copy_actionPerformed()
1829 ap.alignFrame.copy_actionPerformed(null);
1832 public void cut_actionPerformed()
1834 ap.alignFrame.cut_actionPerformed(null);
1837 void changeCase(ActionEvent e)
1839 Object source = e.getSource();
1840 SequenceGroup sg = ap.av.getSelectionGroup();
1844 List<int[]> startEnd = ap.av.getVisibleRegionBoundaries(
1845 sg.getStartRes(), sg.getEndRes() + 1);
1850 if (source == toggle)
1852 description = MessageManager.getString("label.toggle_case");
1853 caseChange = ChangeCaseCommand.TOGGLE_CASE;
1855 else if (source == upperCase)
1857 description = MessageManager.getString("label.to_upper_case");
1858 caseChange = ChangeCaseCommand.TO_UPPER;
1862 description = MessageManager.getString("label.to_lower_case");
1863 caseChange = ChangeCaseCommand.TO_LOWER;
1866 ChangeCaseCommand caseCommand = new ChangeCaseCommand(description,
1867 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
1868 startEnd, caseChange);
1870 ap.alignFrame.addHistoryItem(caseCommand);
1872 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1878 public void outputText_actionPerformed(ActionEvent e)
1880 CutAndPasteTransfer cap = new CutAndPasteTransfer();
1881 cap.setForInput(null);
1882 Desktop.addInternalFrame(cap, MessageManager.formatMessage(
1883 "label.alignment_output_command",
1884 new Object[] { e.getActionCommand() }), 600, 500);
1886 String[] omitHidden = null;
1888 System.out.println("PROMPT USER HERE"); // TODO: decide if a prompt happens
1889 // or we simply trust the user wants
1890 // wysiwig behaviour
1892 FileFormatI fileFormat = FileFormats.getInstance().forName(e.getActionCommand());
1893 cap.setText(new FormatAdapter(ap).formatSequences(fileFormat, ap, true));
1896 public void sequenceFeature_actionPerformed()
1898 SequenceGroup sg = ap.av.getSelectionGroup();
1904 int rsize = 0, gSize = sg.getSize();
1905 SequenceI[] rseqs, seqs = new SequenceI[gSize];
1906 SequenceFeature[] tfeatures, features = new SequenceFeature[gSize];
1908 for (int i = 0; i < gSize; i++)
1910 int start = sg.getSequenceAt(i).findPosition(sg.getStartRes());
1911 int end = sg.findEndRes(sg.getSequenceAt(i));
1914 seqs[rsize] = sg.getSequenceAt(i).getDatasetSequence();
1915 features[rsize] = new SequenceFeature(null, null, null, start, end,
1920 rseqs = new SequenceI[rsize];
1921 tfeatures = new SequenceFeature[rsize];
1922 System.arraycopy(seqs, 0, rseqs, 0, rsize);
1923 System.arraycopy(features, 0, tfeatures, 0, rsize);
1924 features = tfeatures;
1926 if (ap.getSeqPanel().seqCanvas.getFeatureRenderer().amendFeatures(seqs,
1927 features, true, ap))
1929 ap.alignFrame.setShowSeqFeatures(true);
1930 ap.highlightSearchResults(null);
1934 public void textColour_actionPerformed()
1936 SequenceGroup sg = getGroup();
1939 new TextColourChooser().chooseColour(ap, sg);
1943 public void colourByStructure(String pdbid)
1945 Annotation[] anots = ap.av.getStructureSelectionManager()
1946 .colourSequenceFromStructure(sequence, pdbid);
1948 AlignmentAnnotation an = new AlignmentAnnotation("Structure",
1949 "Coloured by " + pdbid, anots);
1951 ap.av.getAlignment().addAnnotation(an);
1952 an.createSequenceMapping(sequence, 0, true);
1953 // an.adjustForAlignment();
1954 ap.av.getAlignment().setAnnotationIndex(an, 0);
1956 ap.adjustAnnotationHeight();
1958 sequence.addAlignmentAnnotation(an);
1962 public void editSequence_actionPerformed(ActionEvent actionEvent)
1964 SequenceGroup sg = ap.av.getSelectionGroup();
1968 if (sequence == null)
1970 sequence = sg.getSequenceAt(0);
1973 EditNameDialog dialog = new EditNameDialog(
1974 sequence.getSequenceAsString(sg.getStartRes(),
1975 sg.getEndRes() + 1), null,
1976 MessageManager.getString("label.edit_sequence"), null,
1977 MessageManager.getString("label.edit_sequence"),
1982 EditCommand editCommand = new EditCommand(
1983 MessageManager.getString("label.edit_sequences"),
1984 Action.REPLACE, dialog.getName().replace(' ',
1985 ap.av.getGapCharacter()),
1986 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
1987 sg.getStartRes(), sg.getEndRes() + 1, ap.av.getAlignment());
1989 ap.alignFrame.addHistoryItem(editCommand);
1991 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1998 * Action on user selecting an item from the colour menu (that does not have
1999 * its bespoke action handler)
2002 public void changeColour_actionPerformed(String colourSchemeName)
2004 SequenceGroup sg = getGroup();
2005 if (ResidueColourScheme.USER_DEFINED.equals(colourSchemeName))
2008 * open a panel to load or configure a user-defined colour scheme
2010 new UserDefinedColours(ap, sg);
2015 * switch to the chosen colour scheme (or null for None)
2017 sg.cs = ColourSchemes.getInstance().getColourScheme(colourSchemeName,
2018 sg, ap.av.getHiddenRepSequences());
2019 if (sg.cs instanceof Blosum62ColourScheme
2020 || sg.cs instanceof PIDColourScheme)
2022 sg.cs.setConsensus(AAFrequency.calculate(
2023 sg.getSequences(ap.av.getHiddenRepSequences()),
2024 sg.getStartRes(), sg.getEndRes() + 1));