2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 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.
21 package jalview.appletgui;
26 import java.awt.event.*;
28 import jalview.analysis.*;
29 import jalview.commands.*;
30 import jalview.datamodel.*;
31 import jalview.schemes.*;
32 import jalview.util.MessageManager;
33 import jalview.util.UrlLink;
34 import jalview.io.AppletFormatAdapter;
35 import jalview.io.SequenceAnnotationReport;
37 public class APopupMenu extends java.awt.PopupMenu implements
38 ActionListener, ItemListener
40 Menu groupMenu = new Menu();
42 MenuItem editGroupName = new MenuItem();
44 protected MenuItem clustalColour = new MenuItem();
46 protected MenuItem zappoColour = new MenuItem();
48 protected MenuItem taylorColour = new MenuItem();
50 protected MenuItem hydrophobicityColour = new MenuItem();
52 protected MenuItem helixColour = new MenuItem();
54 protected MenuItem strandColour = new MenuItem();
56 protected MenuItem turnColour = new MenuItem();
58 protected MenuItem buriedColour = new MenuItem();
60 protected CheckboxMenuItem abovePIDColour = new CheckboxMenuItem();
62 protected MenuItem userDefinedColour = new MenuItem();
64 protected MenuItem PIDColour = new MenuItem();
66 protected MenuItem BLOSUM62Colour = new MenuItem();
68 MenuItem noColourmenuItem = new MenuItem();
70 protected CheckboxMenuItem conservationMenuItem = new CheckboxMenuItem();
72 final AlignmentPanel ap;
74 MenuItem unGroupMenuItem = new MenuItem();
76 MenuItem createGroupMenuItem = new MenuItem();
78 MenuItem nucleotideMenuItem = new MenuItem();
80 Menu colourMenu = new Menu();
82 CheckboxMenuItem showBoxes = new CheckboxMenuItem();
84 CheckboxMenuItem showText = new CheckboxMenuItem();
86 CheckboxMenuItem showColourText = new CheckboxMenuItem();
88 CheckboxMenuItem displayNonconserved = new CheckboxMenuItem();
90 Menu editMenu = new Menu(MessageManager.getString("action.edit"));
92 MenuItem copy = new MenuItem(
93 MessageManager.getString("label.jalview_copy"));
95 MenuItem cut = new MenuItem(MessageManager.getString("label.jalview_cut"));
97 MenuItem toUpper = new MenuItem(
98 MessageManager.getString("label.to_upper_case"));
100 MenuItem toLower = new MenuItem(
101 MessageManager.getString("label.to_lower_case"));
103 MenuItem toggleCase = new MenuItem(
104 MessageManager.getString("label.toggle_case"));
106 Menu outputmenu = new Menu();
108 Menu seqMenu = new Menu();
110 MenuItem pdb = new MenuItem();
112 MenuItem hideSeqs = new MenuItem();
114 MenuItem repGroup = new MenuItem();
116 MenuItem sequenceName = new MenuItem(
117 MessageManager.getString("label.edit_name_description"));
119 MenuItem sequenceFeature = new MenuItem(
120 MessageManager.getString("label.create_sequence_feature"));
122 MenuItem editSequence = new MenuItem(
123 MessageManager.getString("label.edit_sequence"));
125 MenuItem sequenceDetails = new MenuItem(
126 MessageManager.getString("label.sequence_details") + "...");
128 MenuItem selSeqDetails = new MenuItem(
129 MessageManager.getString("label.sequence_details") + "...");
133 MenuItem revealAll = new MenuItem();
135 MenuItem revealSeq = new MenuItem();
138 * index of sequence to be revealed
140 int revealSeq_index = -1;
142 Menu menu1 = new Menu();
144 public APopupMenu(AlignmentPanel apanel, final Sequence seq, Vector links)
146 // /////////////////////////////////////////////////////////
147 // If this is activated from the sequence panel, the user may want to
148 // edit or annotate a particular residue. Therefore display the residue menu
150 // If from the IDPanel, we must display the sequence menu
151 // ////////////////////////////////////////////////////////
159 } catch (Exception e)
164 for (int i = 0; i < jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS.length; i++)
166 MenuItem item = new MenuItem(
167 jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS[i]);
169 item.addActionListener(this);
170 outputmenu.add(item);
173 SequenceGroup sg = ap.av.getSelectionGroup();
175 if (sg != null && sg.getSize() > 0)
177 editGroupName.setLabel(MessageManager.formatMessage(
178 "label.name_param", new String[]
180 showText.setState(sg.getDisplayText());
181 showColourText.setState(sg.getColourText());
182 showBoxes.setState(sg.getDisplayBoxes());
183 displayNonconserved.setState(sg.getShowNonconserved());
184 if (!ap.av.getAlignment().getGroups().contains(sg))
186 menu1.setLabel(MessageManager.getString("action.edit_new_group"));
187 groupMenu.remove(unGroupMenuItem);
191 menu1.setLabel(MessageManager.getString("action.edit_group"));
192 groupMenu.remove(createGroupMenuItem);
202 if (links != null && links.size() > 0)
204 Menu linkMenu = new Menu(MessageManager.getString("action.link"));
206 for (int i = 0; i < links.size(); i++)
208 link = links.elementAt(i).toString();
209 UrlLink urlLink = new UrlLink(link);
210 if (!urlLink.isValid())
212 System.err.println(urlLink.getInvalidMessage());
215 final String target = urlLink.getTarget(); // link.substring(0,
216 // link.indexOf("|"));
217 final String label = urlLink.getLabel();
218 if (seq != null && urlLink.isDynamic())
221 // collect matching db-refs
222 DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(
223 seq.getDBRef(), new String[]
225 // collect id string too
226 String id = seq.getName();
227 String descr = seq.getDescription();
228 if (descr != null && descr.length() < 1)
234 for (int r = 0; r < dbr.length; r++)
236 if (id != null && dbr[r].getAccessionId().equals(id))
238 // suppress duplicate link creation for the bare sequence ID
239 // string with this link
242 // create Bare ID link for this RUL
243 String[] urls = urlLink.makeUrls(dbr[r].getAccessionId(),
247 for (int u = 0; u < urls.length; u += 2)
249 addshowLink(linkMenu, label + "|" + urls[u], urls[u + 1]);
256 // create Bare ID link for this RUL
257 String[] urls = urlLink.makeUrls(id, true);
260 for (int u = 0; u < urls.length; u += 2)
262 addshowLink(linkMenu, label, urls[u + 1]);
265 // addshowLink(linkMenu, target, url_pref + id + url_suff);
267 // Now construct URLs from description but only try to do it for regex
269 if (descr != null && urlLink.getRegexReplace() != null)
271 // create link for this URL from description only if regex matches
272 String[] urls = urlLink.makeUrls(descr, true);
275 for (int u = 0; u < urls.length; u += 2)
277 addshowLink(linkMenu, label, urls[u + 1]);
284 addshowLink(linkMenu, target, urlLink.getUrl_prefix()); // link.substring(link.lastIndexOf("|")+1));
289 * if (link.indexOf("$SEQUENCE_ID$") > -1) { // Substitute SEQUENCE_ID
290 * string and any matching database reference accessions String url_pref
291 * = link.substring(link.indexOf("|") + 1,
292 * link.indexOf("$SEQUENCE_ID$"));
294 * String url_suff = link.substring(link.indexOf("$SEQUENCE_ID$") + 13);
295 * // collect matching db-refs DBRefEntry[] dbr =
296 * jalview.util.DBRefUtils.selectRefs(seq.getDBRef(), new
297 * String[]{target}); // collect id string too String id =
298 * seq.getName(); if (id.indexOf("|") > -1) { id =
299 * id.substring(id.lastIndexOf("|") + 1); } if (dbr!=null) { for (int
300 * r=0;r<dbr.length; r++) { if (dbr[r].getAccessionId().equals(id)) { //
301 * suppress duplicate link creation for the bare sequence ID string with
302 * this link id = null; } addshowLink(linkMenu,
303 * dbr[r].getSource()+"|"+dbr[r].getAccessionId(), target,
304 * url_pref+dbr[r].getAccessionId()+url_suff); } } if (id!=null) { //
305 * create Bare ID link for this RUL addshowLink(linkMenu, target,
306 * url_pref + id + url_suff); } } else { addshowLink(linkMenu, target,
307 * link.substring(link.lastIndexOf("|")+1)); }
310 if (linkMenu.getItemCount() > 0)
314 seqMenu.add(linkMenu);
322 // TODO: add group link menu entry here
325 seqMenu.setLabel(seq.getName());
326 repGroup.setLabel(MessageManager.formatMessage(
327 "label.represent_group_with", new String[]
335 if (!ap.av.hasHiddenRows())
342 final int index = ap.av.getAlignment().findIndex(seq);
344 if (ap.av.adjustForHiddenSeqs(index)
345 - ap.av.adjustForHiddenSeqs(index - 1) > 1)
347 revealSeq_index = index;
357 * add a show URL menu item to the given linkMenu
361 * - menu label string
365 private void addshowLink(Menu linkMenu, final String target,
368 addshowLink(linkMenu, target, target, url);
372 * add a show URL menu item to the given linkMenu
376 * - URL target window
378 * - menu label string
382 private void addshowLink(Menu linkMenu, final String target,
383 final String label, final String url)
385 MenuItem item = new MenuItem(label);
386 item.addActionListener(new java.awt.event.ActionListener()
388 public void actionPerformed(ActionEvent e)
390 ap.alignFrame.showURL(url, target);
396 public void itemStateChanged(ItemEvent evt)
398 if (evt.getSource() == abovePIDColour)
400 abovePIDColour_itemStateChanged();
402 else if (evt.getSource() == showColourText)
404 showColourText_itemStateChanged();
406 else if (evt.getSource() == showText)
408 showText_itemStateChanged();
410 else if (evt.getSource() == showBoxes)
412 showBoxes_itemStateChanged();
414 else if (evt.getSource() == displayNonconserved)
416 this.showNonconserved_itemStateChanged();
420 public void actionPerformed(ActionEvent evt)
422 Object source = evt.getSource();
423 if (source == clustalColour)
425 clustalColour_actionPerformed();
427 else if (source == zappoColour)
429 zappoColour_actionPerformed();
431 else if (source == taylorColour)
433 taylorColour_actionPerformed();
435 else if (source == hydrophobicityColour)
437 hydrophobicityColour_actionPerformed();
439 else if (source == helixColour)
441 helixColour_actionPerformed();
443 else if (source == strandColour)
445 strandColour_actionPerformed();
447 else if (source == turnColour)
449 turnColour_actionPerformed();
451 else if (source == buriedColour)
453 buriedColour_actionPerformed();
455 else if (source == nucleotideMenuItem)
457 nucleotideMenuItem_actionPerformed();
460 else if (source == userDefinedColour)
462 userDefinedColour_actionPerformed();
464 else if (source == PIDColour)
466 PIDColour_actionPerformed();
468 else if (source == BLOSUM62Colour)
470 BLOSUM62Colour_actionPerformed();
472 else if (source == noColourmenuItem)
474 noColourmenuItem_actionPerformed();
476 else if (source == conservationMenuItem)
478 conservationMenuItem_itemStateChanged();
480 else if (source == unGroupMenuItem)
482 unGroupMenuItem_actionPerformed();
485 else if (source == createGroupMenuItem)
487 createGroupMenuItem_actionPerformed();
490 else if (source == sequenceName)
494 else if (source == sequenceDetails)
496 showSequenceDetails();
498 else if (source == selSeqDetails)
500 showSequenceSelectionDetails();
502 else if (source == pdb)
506 else if (source == hideSeqs)
508 hideSequences(false);
510 else if (source == repGroup)
514 else if (source == revealSeq)
516 ap.av.showSequence(revealSeq_index);
518 else if (source == revealAll)
520 ap.av.showAllHiddenSeqs();
523 else if (source == editGroupName)
525 EditNameDialog dialog = new EditNameDialog(getGroup().getName(),
526 getGroup().getDescription(), " Group Name",
527 "Group Description", ap.alignFrame,
528 "Edit Group Name / Description", 500, 100, true);
532 getGroup().setName(dialog.getName().replace(' ', '_'));
533 getGroup().setDescription(dialog.getDescription());
537 else if (source == copy)
539 ap.alignFrame.copy_actionPerformed();
541 else if (source == cut)
543 ap.alignFrame.cut_actionPerformed();
545 else if (source == editSequence)
547 SequenceGroup sg = ap.av.getSelectionGroup();
552 seq = (Sequence) sg.getSequenceAt(0);
554 EditNameDialog dialog = new EditNameDialog(seq.getSequenceAsString(
555 sg.getStartRes(), sg.getEndRes() + 1), null,
556 "Edit Sequence ", null,
558 ap.alignFrame, "Edit Sequence", 500, 100, true);
562 EditCommand editCommand = new EditCommand(MessageManager.getString("label.edit_sequences"),
563 EditCommand.REPLACE, dialog.getName().replace(' ',
564 ap.av.getGapCharacter()),
565 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
566 sg.getStartRes(), sg.getEndRes() + 1,
567 ap.av.getAlignment());
569 ap.alignFrame.addHistoryItem(editCommand);
571 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
576 else if (source == toUpper || source == toLower || source == toggleCase)
578 SequenceGroup sg = ap.av.getSelectionGroup();
579 Vector regions = new Vector();
582 int[][] startEnd = ap.av.getVisibleRegionBoundaries(
583 sg.getStartRes(), sg.getEndRes() + 1);
588 if (source == toggleCase)
590 description = "Toggle Case";
591 caseChange = ChangeCaseCommand.TOGGLE_CASE;
593 else if (source == toUpper)
595 description = "To Upper Case";
596 caseChange = ChangeCaseCommand.TO_UPPER;
600 description = "To Lower Case";
601 caseChange = ChangeCaseCommand.TO_LOWER;
604 ChangeCaseCommand caseCommand = new ChangeCaseCommand(description,
605 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
606 startEnd, caseChange);
608 ap.alignFrame.addHistoryItem(caseCommand);
610 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
615 else if (source == sequenceFeature)
617 SequenceGroup sg = ap.av.getSelectionGroup();
623 int rsize = 0, gSize = sg.getSize();
624 SequenceI[] rseqs, seqs = new SequenceI[gSize];
625 SequenceFeature[] tfeatures, features = new SequenceFeature[gSize];
627 for (int i = 0; i < gSize; i++)
629 int start = sg.getSequenceAt(i).findPosition(sg.getStartRes());
630 int end = sg.findEndRes(sg.getSequenceAt(i));
633 seqs[rsize] = sg.getSequenceAt(i);
634 features[rsize] = new SequenceFeature(null, null, null, start,
639 rseqs = new SequenceI[rsize];
640 tfeatures = new SequenceFeature[rsize];
641 System.arraycopy(seqs, 0, rseqs, 0, rsize);
642 System.arraycopy(features, 0, tfeatures, 0, rsize);
643 features = tfeatures;
646 if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs,
649 ap.alignFrame.sequenceFeatures.setState(true);
650 ap.av.showSequenceFeatures(true);
651 ap.highlightSearchResults(null);
661 void outputText(ActionEvent e)
663 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, ap.alignFrame);
665 Frame frame = new Frame();
667 jalview.bin.JalviewLite.addFrame(frame, MessageManager.formatMessage(
668 "label.selection_output_command", new String[]
669 { e.getActionCommand() }), 600, 500);
670 // JBPNote: getSelectionAsNewSequence behaviour has changed - this method
671 // now returns a full copy of sequence data
672 // TODO consider using getSequenceSelection instead here
674 cap.setText(new jalview.io.AppletFormatAdapter().formatSequences(
675 e.getActionCommand(),
676 ap.av.showJVSuffix, ap.av, true));
680 protected void showSequenceSelectionDetails()
682 createSequenceDetailsReport(ap.av.getSequenceSelection());
685 protected void showSequenceDetails()
687 createSequenceDetailsReport(new SequenceI[]
691 public void createSequenceDetailsReport(SequenceI[] sequences)
694 CutAndPasteTransfer cap = new CutAndPasteTransfer(false, ap.alignFrame);
696 StringBuffer contents = new StringBuffer();
697 for (SequenceI seq : sequences)
699 contents.append(MessageManager.formatMessage(
700 "label.annotation_for_displayid", new String[]
701 { seq.getDisplayId(true) }));
702 new SequenceAnnotationReport(null)
703 .createSequenceAnnotationReport(
709 (ap.seqPanel.seqCanvas.fr != null) ? ap.seqPanel.seqCanvas.fr.minmax
711 contents.append("</p>");
713 Frame frame = new Frame();
715 jalview.bin.JalviewLite.addFrame(frame, "Sequence Details for "
716 + (sequences.length == 1 ? sequences[0].getDisplayId(true)
717 : "Selection"), 600, 500);
718 cap.setText(MessageManager.formatMessage("label.html_content",
720 { contents.toString() }));
725 EditNameDialog dialog = new EditNameDialog(seq.getName(),
726 seq.getDescription(), " Sequence Name",
727 "Sequence Description", ap.alignFrame,
728 "Edit Sequence Name / Description", 500, 100, true);
732 seq.setName(dialog.getName());
733 seq.setDescription(dialog.getDescription());
734 ap.paintAlignment(false);
740 if (seq.getPDBId() != null)
742 PDBEntry entry = (PDBEntry) seq.getPDBId().firstElement();
744 if (ap.av.applet.jmolAvailable)
745 new jalview.appletgui.AppletJmol(entry, new Sequence[]
746 { seq }, null, ap, AppletFormatAdapter.URL);
748 new MCview.AppletPDBViewer(entry, new Sequence[]
749 { seq }, null, ap, AppletFormatAdapter.URL);
754 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, ap.alignFrame);
755 cap.setText(MessageManager.getString("label.paste_pdb_file"));
756 cap.setPDBImport(seq);
757 Frame frame = new Frame();
759 jalview.bin.JalviewLite.addFrame(frame, MessageManager.formatMessage(
760 "label.paste_pdb_file_for_sequence", new String[]
761 { seq.getName() }), 400, 300);
765 private void jbInit() throws Exception
767 groupMenu.setLabel(MessageManager.getString("label.selection"));
768 sequenceFeature.addActionListener(this);
770 editGroupName.addActionListener(this);
771 unGroupMenuItem.setLabel(MessageManager
772 .getString("action.remove_group"));
773 unGroupMenuItem.addActionListener(this);
775 createGroupMenuItem.setLabel(MessageManager
776 .getString("action.create_group"));
777 createGroupMenuItem.addActionListener(this);
779 nucleotideMenuItem.setLabel(MessageManager
780 .getString("label.nucleotide"));
781 nucleotideMenuItem.addActionListener(this);
782 conservationMenuItem.addItemListener(this);
783 abovePIDColour.addItemListener(this);
784 colourMenu.setLabel(MessageManager.getString("label.group_colour"));
785 showBoxes.setLabel(MessageManager.getString("action.boxes"));
786 showBoxes.setState(true);
787 showBoxes.addItemListener(this);
788 sequenceName.addActionListener(this);
789 sequenceDetails.addActionListener(this);
790 selSeqDetails.addActionListener(this);
791 displayNonconserved.setLabel(MessageManager
792 .getString("label.show_non_conversed"));
793 displayNonconserved.setState(false);
794 displayNonconserved.addItemListener(this);
795 showText.setLabel(MessageManager.getString("action.text"));
796 showText.addItemListener(this);
797 showColourText.setLabel(MessageManager.getString("label.colour_text"));
798 showColourText.addItemListener(this);
799 outputmenu.setLabel(MessageManager.getString("label.out_to_textbox"));
800 seqMenu.setLabel(MessageManager.getString("label.sequence"));
801 pdb.setLabel(MessageManager.getString("label.view_pdb_structure"));
802 hideSeqs.setLabel(MessageManager.getString("action.hide_sequences"));
803 repGroup.setLabel(MessageManager.formatMessage(
804 "label.represent_group_with", new String[]
806 revealAll.setLabel(MessageManager.getString("action.reveal_all"));
807 revealSeq.setLabel(MessageManager.getString("action.reveal_sequences"));
808 menu1.setLabel(MessageManager.getString("label.group") + ":");
814 // groupMenu.add(selSeqDetails);
815 groupMenu.add(editMenu);
816 groupMenu.add(outputmenu);
817 groupMenu.add(sequenceFeature);
818 groupMenu.add(createGroupMenuItem);
819 groupMenu.add(unGroupMenuItem);
820 groupMenu.add(menu1);
822 colourMenu.add(noColourmenuItem);
823 colourMenu.add(clustalColour);
824 colourMenu.add(BLOSUM62Colour);
825 colourMenu.add(PIDColour);
826 colourMenu.add(zappoColour);
827 colourMenu.add(taylorColour);
828 colourMenu.add(hydrophobicityColour);
829 colourMenu.add(helixColour);
830 colourMenu.add(strandColour);
831 colourMenu.add(turnColour);
832 colourMenu.add(buriedColour);
833 colourMenu.add(nucleotideMenuItem);
834 colourMenu.add(userDefinedColour);
835 colourMenu.addSeparator();
836 colourMenu.add(abovePIDColour);
837 colourMenu.add(conservationMenuItem);
839 noColourmenuItem.setLabel(MessageManager.getString("label.none"));
840 noColourmenuItem.addActionListener(this);
842 clustalColour.setLabel(MessageManager.getString("label.clustalx_colours"));
843 clustalColour.addActionListener(this);
844 zappoColour.setLabel(MessageManager.getString("label.zappo"));
845 zappoColour.addActionListener(this);
846 taylorColour.setLabel(MessageManager.getString("label.taylor"));
847 taylorColour.addActionListener(this);
848 hydrophobicityColour.setLabel(MessageManager.getString("label.hydrophobicity"));
849 hydrophobicityColour.addActionListener(this);
850 helixColour.setLabel(MessageManager.getString("label.helix_propensity"));
851 helixColour.addActionListener(this);
852 strandColour.setLabel(MessageManager.getString("label.strand_propensity"));
853 strandColour.addActionListener(this);
854 turnColour.setLabel(MessageManager.getString("label.turn_propensity"));
855 turnColour.addActionListener(this);
856 buriedColour.setLabel(MessageManager.getString("label.buried_index"));
857 buriedColour.addActionListener(this);
858 abovePIDColour.setLabel(MessageManager.getString("label.above_identity_percentage"));
860 userDefinedColour.setLabel(MessageManager.getString("action.user_defined"));
861 userDefinedColour.addActionListener(this);
862 PIDColour.setLabel(MessageManager.getString("action.percentage_identity"));
863 PIDColour.addActionListener(this);
864 BLOSUM62Colour.setLabel("BLOSUM62");
865 BLOSUM62Colour.addActionListener(this);
866 conservationMenuItem.setLabel(MessageManager.getString("label.conservation"));
869 copy.addActionListener(this);
871 cut.addActionListener(this);
873 editMenu.add(editSequence);
874 editSequence.addActionListener(this);
876 editMenu.add(toUpper);
877 toUpper.addActionListener(this);
878 editMenu.add(toLower);
879 toLower.addActionListener(this);
880 editMenu.add(toggleCase);
881 seqMenu.add(sequenceName);
882 // seqMenu.add(sequenceDetails);
884 if (!ap.av.applet.useXtrnalSviewer)
888 seqMenu.add(repGroup);
889 menu1.add(editGroupName);
890 menu1.add(colourMenu);
891 menu1.add(showBoxes);
893 menu1.add(showColourText);
894 menu1.add(displayNonconserved);
895 toggleCase.addActionListener(this);
896 pdb.addActionListener(this);
897 hideSeqs.addActionListener(this);
898 repGroup.addActionListener(this);
899 revealAll.addActionListener(this);
900 revealSeq.addActionListener(this);
905 ap.paintAlignment(true);
908 protected void clustalColour_actionPerformed()
910 SequenceGroup sg = getGroup();
911 sg.cs = new ClustalxColourScheme(sg, ap.av.getHiddenRepSequences());
915 protected void zappoColour_actionPerformed()
917 getGroup().cs = new ZappoColourScheme();
921 protected void taylorColour_actionPerformed()
923 getGroup().cs = new TaylorColourScheme();
927 protected void hydrophobicityColour_actionPerformed()
929 getGroup().cs = new HydrophobicColourScheme();
933 protected void helixColour_actionPerformed()
935 getGroup().cs = new HelixColourScheme();
939 protected void strandColour_actionPerformed()
941 getGroup().cs = new StrandColourScheme();
945 protected void turnColour_actionPerformed()
947 getGroup().cs = new TurnColourScheme();
951 protected void buriedColour_actionPerformed()
953 getGroup().cs = new BuriedColourScheme();
957 public void nucleotideMenuItem_actionPerformed()
959 getGroup().cs = new NucleotideColourScheme();
963 protected void abovePIDColour_itemStateChanged()
965 SequenceGroup sg = getGroup();
971 if (abovePIDColour.getState())
973 sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(ap.av
974 .getHiddenRepSequences()), 0, ap.av.getAlignment().getWidth()));
975 int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
978 sg.cs.setThreshold(threshold, ap.av.getIgnoreGapsConsensus());
980 SliderPanel.showPIDSlider();
984 // remove PIDColouring
986 sg.cs.setThreshold(0, ap.av.getIgnoreGapsConsensus());
993 protected void userDefinedColour_actionPerformed()
995 new UserDefinedColours(ap, getGroup());
998 protected void PIDColour_actionPerformed()
1000 SequenceGroup sg = getGroup();
1001 sg.cs = new PIDColourScheme();
1002 sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(ap.av
1003 .getHiddenRepSequences()), 0, ap.av.getAlignment().getWidth()));
1007 protected void BLOSUM62Colour_actionPerformed()
1009 SequenceGroup sg = getGroup();
1011 sg.cs = new Blosum62ColourScheme();
1013 sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(ap.av
1014 .getHiddenRepSequences()), 0, ap.av.getAlignment().getWidth()));
1019 protected void noColourmenuItem_actionPerformed()
1021 getGroup().cs = null;
1025 protected void conservationMenuItem_itemStateChanged()
1027 SequenceGroup sg = getGroup();
1033 if (conservationMenuItem.getState())
1036 sg.cs.setConservation(Conservation.calculateConservation("Group",
1037 ResidueProperties.propHash, 3, sg.getSequences(ap.av
1038 .getHiddenRepSequences()), 0, ap.av.getAlignment()
1039 .getWidth(), false, ap.av.getConsPercGaps(), false));
1040 SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
1041 SliderPanel.showConservationSlider();
1044 // remove ConservationColouring
1046 sg.cs.setConservation(null);
1052 SequenceGroup getGroup()
1054 SequenceGroup sg = ap.av.getSelectionGroup();
1056 // this method won't add a new group if it already exists
1059 ap.av.getAlignment().addGroup(sg);
1065 void unGroupMenuItem_actionPerformed()
1067 SequenceGroup sg = ap.av.getSelectionGroup();
1068 ap.av.getAlignment().deleteGroup(sg);
1069 ap.av.setSelectionGroup(null);
1070 ap.paintAlignment(true);
1073 void createGroupMenuItem_actionPerformed()
1075 getGroup(); // implicitly create group
1079 public void showColourText_itemStateChanged()
1081 getGroup().setColourText(showColourText.getState());
1085 public void showText_itemStateChanged()
1087 getGroup().setDisplayText(showText.getState());
1091 public void showNonconserved_itemStateChanged()
1093 getGroup().setShowNonconserved(this.displayNonconserved.getState());
1097 public void showBoxes_itemStateChanged()
1099 getGroup().setDisplayBoxes(showBoxes.getState());
1103 void hideSequences(boolean representGroup)
1105 SequenceGroup sg = ap.av.getSelectionGroup();
1106 if (sg == null || sg.getSize() < 1)
1108 ap.av.hideSequence(new SequenceI[]
1113 ap.av.setSelectionGroup(null);
1117 ap.av.hideRepSequences(seq, sg);
1122 int gsize = sg.getSize();
1125 hseqs = new SequenceI[gsize];
1128 for (int i = 0; i < gsize; i++)
1130 hseqs[index++] = sg.getSequenceAt(i);
1133 ap.av.hideSequence(hseqs);
1134 ap.av.sendSelection();