2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
3 * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
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 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
18 package jalview.appletgui;
23 import java.awt.event.*;
25 import jalview.analysis.*;
26 import jalview.commands.*;
27 import jalview.datamodel.*;
28 import jalview.schemes.*;
29 import jalview.util.MessageManager;
30 import jalview.util.UrlLink;
31 import jalview.io.AppletFormatAdapter;
32 import jalview.io.SequenceAnnotationReport;
34 public class APopupMenu extends java.awt.PopupMenu implements
35 ActionListener, ItemListener
37 Menu groupMenu = new Menu();
39 MenuItem editGroupName = new MenuItem();
41 protected MenuItem clustalColour = new MenuItem();
43 protected MenuItem zappoColour = new MenuItem();
45 protected MenuItem taylorColour = new MenuItem();
47 protected MenuItem hydrophobicityColour = new MenuItem();
49 protected MenuItem helixColour = new MenuItem();
51 protected MenuItem strandColour = new MenuItem();
53 protected MenuItem turnColour = new MenuItem();
55 protected MenuItem buriedColour = new MenuItem();
57 protected CheckboxMenuItem abovePIDColour = new CheckboxMenuItem();
59 protected MenuItem userDefinedColour = new MenuItem();
61 protected MenuItem PIDColour = new MenuItem();
63 protected MenuItem BLOSUM62Colour = new MenuItem();
65 MenuItem noColourmenuItem = new MenuItem();
67 protected CheckboxMenuItem conservationMenuItem = new CheckboxMenuItem();
69 final AlignmentPanel ap;
71 MenuItem unGroupMenuItem = new MenuItem();
73 MenuItem nucleotideMenuItem = new MenuItem();
75 Menu colourMenu = new Menu();
77 CheckboxMenuItem showBoxes = new CheckboxMenuItem();
79 CheckboxMenuItem showText = new CheckboxMenuItem();
81 CheckboxMenuItem showColourText = new CheckboxMenuItem();
83 CheckboxMenuItem displayNonconserved = new CheckboxMenuItem();
85 Menu editMenu = new Menu(MessageManager.getString("action.edit"));
87 MenuItem copy = new MenuItem(MessageManager.getString("label.jalview_copy"));
89 MenuItem cut = new MenuItem(MessageManager.getString("label.jalview_cut"));
91 MenuItem toUpper = new MenuItem(MessageManager.getString("label.to_upper_case"));
93 MenuItem toLower = new MenuItem(MessageManager.getString("label.to_lower_case"));
95 MenuItem toggleCase = new MenuItem(MessageManager.getString("label.toggle_case"));
97 Menu outputmenu = new Menu();
99 Menu seqMenu = new Menu();
101 MenuItem pdb = new MenuItem();
103 MenuItem hideSeqs = new MenuItem();
105 MenuItem repGroup = new MenuItem();
107 MenuItem sequenceName = new MenuItem(MessageManager.getString("label.edit_name_description"));
109 MenuItem sequenceFeature = new MenuItem(MessageManager.getString("label.create_sequence_feature"));
111 MenuItem editSequence = new MenuItem(MessageManager.getString("label.edit_sequence"));
113 MenuItem sequenceDetails = new MenuItem(MessageManager.getString("label.sequence_details") + "...");
115 MenuItem selSeqDetails = new MenuItem(MessageManager.getString("label.sequence_details") + "...");
119 MenuItem revealAll = new MenuItem();
121 MenuItem revealSeq = new MenuItem();
124 * index of sequence to be revealed
126 int revealSeq_index = -1;
128 Menu menu1 = new Menu();
130 public APopupMenu(AlignmentPanel apanel, final Sequence seq, Vector links)
132 // /////////////////////////////////////////////////////////
133 // If this is activated from the sequence panel, the user may want to
134 // edit or annotate a particular residue. Therefore display the residue menu
136 // If from the IDPanel, we must display the sequence menu
137 // ////////////////////////////////////////////////////////
145 } catch (Exception e)
150 for (int i = 0; i < jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS.length; i++)
152 MenuItem item = new MenuItem(
153 jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS[i]);
155 item.addActionListener(this);
156 outputmenu.add(item);
159 SequenceGroup sg = ap.av.getSelectionGroup();
161 if (sg != null && sg.getSize() > 0)
163 editGroupName.setLabel(MessageManager.formatMessage("label.name_param", new String[]{sg.getName()}));
164 showText.setState(sg.getDisplayText());
165 showColourText.setState(sg.getColourText());
166 showBoxes.setState(sg.getDisplayBoxes());
167 displayNonconserved.setState(sg.getShowNonconserved());
168 if (!ap.av.getAlignment().getGroups().contains(sg))
170 groupMenu.remove(unGroupMenuItem);
180 if (links != null && links.size() > 0)
182 Menu linkMenu = new Menu(MessageManager.getString("action.link"));
184 for (int i = 0; i < links.size(); i++)
186 link = links.elementAt(i).toString();
187 UrlLink urlLink = new UrlLink(link);
188 if (!urlLink.isValid())
190 System.err.println(urlLink.getInvalidMessage());
193 final String target = urlLink.getTarget(); // link.substring(0,
194 // link.indexOf("|"));
195 final String label = urlLink.getLabel();
196 if (seq != null && urlLink.isDynamic())
199 // collect matching db-refs
200 DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(
201 seq.getDBRef(), new String[]
203 // collect id string too
204 String id = seq.getName();
205 String descr = seq.getDescription();
206 if (descr != null && descr.length() < 1)
212 for (int r = 0; r < dbr.length; r++)
214 if (id != null && dbr[r].getAccessionId().equals(id))
216 // suppress duplicate link creation for the bare sequence ID
217 // string with this link
220 // create Bare ID link for this RUL
221 String[] urls = urlLink.makeUrls(dbr[r].getAccessionId(),
225 for (int u = 0; u < urls.length; u += 2)
227 addshowLink(linkMenu, label + "|" + urls[u], urls[u + 1]);
234 // create Bare ID link for this RUL
235 String[] urls = urlLink.makeUrls(id, true);
238 for (int u = 0; u < urls.length; u += 2)
240 addshowLink(linkMenu, label, urls[u + 1]);
243 // addshowLink(linkMenu, target, url_pref + id + url_suff);
245 // Now construct URLs from description but only try to do it for regex
247 if (descr != null && urlLink.getRegexReplace() != null)
249 // create link for this URL from description only if regex matches
250 String[] urls = urlLink.makeUrls(descr, true);
253 for (int u = 0; u < urls.length; u += 2)
255 addshowLink(linkMenu, label, urls[u + 1]);
262 addshowLink(linkMenu, target, urlLink.getUrl_prefix()); // link.substring(link.lastIndexOf("|")+1));
267 * if (link.indexOf("$SEQUENCE_ID$") > -1) { // Substitute SEQUENCE_ID
268 * string and any matching database reference accessions String url_pref
269 * = link.substring(link.indexOf("|") + 1,
270 * link.indexOf("$SEQUENCE_ID$"));
272 * String url_suff = link.substring(link.indexOf("$SEQUENCE_ID$") + 13);
273 * // collect matching db-refs DBRefEntry[] dbr =
274 * jalview.util.DBRefUtils.selectRefs(seq.getDBRef(), new
275 * String[]{target}); // collect id string too String id =
276 * seq.getName(); if (id.indexOf("|") > -1) { id =
277 * id.substring(id.lastIndexOf("|") + 1); } if (dbr!=null) { for (int
278 * r=0;r<dbr.length; r++) { if (dbr[r].getAccessionId().equals(id)) { //
279 * suppress duplicate link creation for the bare sequence ID string with
280 * this link id = null; } addshowLink(linkMenu,
281 * dbr[r].getSource()+"|"+dbr[r].getAccessionId(), target,
282 * url_pref+dbr[r].getAccessionId()+url_suff); } } if (id!=null) { //
283 * create Bare ID link for this RUL addshowLink(linkMenu, target,
284 * url_pref + id + url_suff); } } else { addshowLink(linkMenu, target,
285 * link.substring(link.lastIndexOf("|")+1)); }
288 if (linkMenu.getItemCount() > 0)
292 seqMenu.add(linkMenu);
300 // TODO: add group link menu entry here
303 seqMenu.setLabel(seq.getName());
304 repGroup.setLabel(MessageManager.formatMessage("label.represent_group_with", new String[]{seq.getName()}));
311 if (!ap.av.hasHiddenRows())
318 final int index = ap.av.getAlignment().findIndex(seq);
320 if (ap.av.adjustForHiddenSeqs(index)
321 - ap.av.adjustForHiddenSeqs(index - 1) > 1)
323 revealSeq_index = index;
333 * add a show URL menu item to the given linkMenu
337 * - menu label string
341 private void addshowLink(Menu linkMenu, final String target,
344 addshowLink(linkMenu, target, target, url);
348 * add a show URL menu item to the given linkMenu
352 * - URL target window
354 * - menu label string
358 private void addshowLink(Menu linkMenu, final String target,
359 final String label, final String url)
361 MenuItem item = new MenuItem(label);
362 item.addActionListener(new java.awt.event.ActionListener()
364 public void actionPerformed(ActionEvent e)
366 ap.alignFrame.showURL(url, target);
372 public void itemStateChanged(ItemEvent evt)
374 if (evt.getSource() == abovePIDColour)
376 abovePIDColour_itemStateChanged();
378 else if (evt.getSource() == showColourText)
380 showColourText_itemStateChanged();
382 else if (evt.getSource() == showText)
384 showText_itemStateChanged();
386 else if (evt.getSource() == showBoxes)
388 showBoxes_itemStateChanged();
390 else if (evt.getSource() == displayNonconserved)
392 this.showNonconserved_itemStateChanged();
396 public void actionPerformed(ActionEvent evt)
398 Object source = evt.getSource();
399 if (source == clustalColour)
401 clustalColour_actionPerformed();
403 else if (source == zappoColour)
405 zappoColour_actionPerformed();
407 else if (source == taylorColour)
409 taylorColour_actionPerformed();
411 else if (source == hydrophobicityColour)
413 hydrophobicityColour_actionPerformed();
415 else if (source == helixColour)
417 helixColour_actionPerformed();
419 else if (source == strandColour)
421 strandColour_actionPerformed();
423 else if (source == turnColour)
425 turnColour_actionPerformed();
427 else if (source == buriedColour)
429 buriedColour_actionPerformed();
431 else if (source == nucleotideMenuItem)
433 nucleotideMenuItem_actionPerformed();
436 else if (source == userDefinedColour)
438 userDefinedColour_actionPerformed();
440 else if (source == PIDColour)
442 PIDColour_actionPerformed();
444 else if (source == BLOSUM62Colour)
446 BLOSUM62Colour_actionPerformed();
448 else if (source == noColourmenuItem)
450 noColourmenuItem_actionPerformed();
452 else if (source == conservationMenuItem)
454 conservationMenuItem_itemStateChanged();
456 else if (source == unGroupMenuItem)
458 unGroupMenuItem_actionPerformed();
461 else if (source == sequenceName)
465 else if (source == sequenceDetails)
467 showSequenceDetails();
469 else if (source == selSeqDetails)
471 showSequenceSelectionDetails();
473 else if (source == pdb)
477 else if (source == hideSeqs)
479 hideSequences(false);
481 else if (source == repGroup)
485 else if (source == revealSeq)
487 ap.av.showSequence(revealSeq_index);
489 else if (source == revealAll)
491 ap.av.showAllHiddenSeqs();
494 else if (source == editGroupName)
496 EditNameDialog dialog = new EditNameDialog(getGroup().getName(),
497 getGroup().getDescription(), " Group Name",
498 "Group Description", ap.alignFrame,
499 "Edit Group Name / Description", 500, 100, true);
503 getGroup().setName(dialog.getName().replace(' ', '_'));
504 getGroup().setDescription(dialog.getDescription());
508 else if (source == copy)
510 ap.alignFrame.copy_actionPerformed();
512 else if (source == cut)
514 ap.alignFrame.cut_actionPerformed();
516 else if (source == editSequence)
518 SequenceGroup sg = ap.av.getSelectionGroup();
523 seq = (Sequence) sg.getSequenceAt(0);
525 EditNameDialog dialog = new EditNameDialog(seq.getSequenceAsString(
526 sg.getStartRes(), sg.getEndRes() + 1), null,
527 "Edit Sequence ", null,
529 ap.alignFrame, "Edit Sequence", 500, 100, true);
533 EditCommand editCommand = new EditCommand("Edit Sequences",
534 EditCommand.REPLACE, dialog.getName().replace(' ',
535 ap.av.getGapCharacter()),
536 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
537 sg.getStartRes(), sg.getEndRes() + 1,
538 ap.av.getAlignment());
540 ap.alignFrame.addHistoryItem(editCommand);
542 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
547 else if (source == toUpper || source == toLower || source == toggleCase)
549 SequenceGroup sg = ap.av.getSelectionGroup();
550 Vector regions = new Vector();
553 int[][] startEnd = ap.av.getVisibleRegionBoundaries(
554 sg.getStartRes(), sg.getEndRes() + 1);
559 if (source == toggleCase)
561 description = "Toggle Case";
562 caseChange = ChangeCaseCommand.TOGGLE_CASE;
564 else if (source == toUpper)
566 description = "To Upper Case";
567 caseChange = ChangeCaseCommand.TO_UPPER;
571 description = "To Lower Case";
572 caseChange = ChangeCaseCommand.TO_LOWER;
575 ChangeCaseCommand caseCommand = new ChangeCaseCommand(description,
576 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
577 startEnd, caseChange);
579 ap.alignFrame.addHistoryItem(caseCommand);
581 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
586 else if (source == sequenceFeature)
588 SequenceGroup sg = ap.av.getSelectionGroup();
594 int rsize = 0, gSize = sg.getSize();
595 SequenceI[] rseqs, seqs = new SequenceI[gSize];
596 SequenceFeature[] tfeatures, features = new SequenceFeature[gSize];
598 for (int i = 0; i < gSize; i++)
600 int start = sg.getSequenceAt(i).findPosition(sg.getStartRes());
601 int end = sg.findEndRes(sg.getSequenceAt(i));
604 seqs[rsize] = sg.getSequenceAt(i);
605 features[rsize] = new SequenceFeature(null, null, null, start,
610 rseqs = new SequenceI[rsize];
611 tfeatures = new SequenceFeature[rsize];
612 System.arraycopy(seqs, 0, rseqs, 0, rsize);
613 System.arraycopy(features, 0, tfeatures, 0, rsize);
614 features = tfeatures;
617 if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs,
620 ap.alignFrame.sequenceFeatures.setState(true);
621 ap.av.showSequenceFeatures(true);
622 ap.highlightSearchResults(null);
632 void outputText(ActionEvent e)
634 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, ap.alignFrame);
636 Frame frame = new Frame();
638 jalview.bin.JalviewLite.addFrame(frame,
639 MessageManager.formatMessage("label.selection_output_command", new String[]{e.getActionCommand()}),600, 500);
640 // JBPNote: getSelectionAsNewSequence behaviour has changed - this method
641 // now returns a full copy of sequence data
642 // TODO consider using getSequenceSelection instead here
644 cap.setText(new jalview.io.AppletFormatAdapter().formatSequences(
645 e.getActionCommand(),
646 new Alignment(ap.av.getSelectionAsNewSequence()),
647 ap.av.showJVSuffix));
651 protected void showSequenceSelectionDetails()
653 createSequenceDetailsReport(ap.av.getSequenceSelection());
656 protected void showSequenceDetails()
658 createSequenceDetailsReport(new SequenceI[]
662 public void createSequenceDetailsReport(SequenceI[] sequences)
665 CutAndPasteTransfer cap = new CutAndPasteTransfer(false, ap.alignFrame);
667 StringBuffer contents = new StringBuffer();
668 for (SequenceI seq : sequences)
670 contents.append(MessageManager.formatMessage("label.annotation_for_displayid",new String[]{seq.getDisplayId(true)}));
671 new SequenceAnnotationReport(null)
672 .createSequenceAnnotationReport(
678 (ap.seqPanel.seqCanvas.fr != null) ? ap.seqPanel.seqCanvas.fr.minmax
680 contents.append("</p>");
682 Frame frame = new Frame();
684 jalview.bin.JalviewLite.addFrame(frame, "Sequence Details for "
685 + (sequences.length == 1 ? sequences[0].getDisplayId(true)
686 : "Selection"), 600, 500);
687 cap.setText(MessageManager.formatMessage("label.html_content", new String[]{contents.toString()}));
692 EditNameDialog dialog = new EditNameDialog(seq.getName(),
693 seq.getDescription(), " Sequence Name",
694 "Sequence Description", ap.alignFrame,
695 "Edit Sequence Name / Description", 500, 100, true);
699 seq.setName(dialog.getName());
700 seq.setDescription(dialog.getDescription());
701 ap.paintAlignment(false);
707 if (seq.getPDBId() != null)
709 PDBEntry entry = (PDBEntry) seq.getPDBId().firstElement();
711 if (ap.av.applet.jmolAvailable)
712 new jalview.appletgui.AppletJmol(entry, new Sequence[]
713 { seq }, null, ap, AppletFormatAdapter.URL);
715 new MCview.AppletPDBViewer(entry, new Sequence[]
716 { seq }, null, ap, AppletFormatAdapter.URL);
721 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, ap.alignFrame);
722 cap.setText(MessageManager.getString("label.paste_pdb_file"));
723 cap.setPDBImport(seq);
724 Frame frame = new Frame();
726 jalview.bin.JalviewLite.addFrame(frame,
727 MessageManager.formatMessage("label.paste_pdb_file_for_sequence", new String[]{seq.getName()}), 400, 300);
731 private void jbInit() throws Exception
733 groupMenu.setLabel(MessageManager.getString("label.group"));
734 groupMenu.setLabel(MessageManager.getString("label.selection"));
735 sequenceFeature.addActionListener(this);
737 editGroupName.addActionListener(this);
738 unGroupMenuItem.setLabel(MessageManager.getString("action.remove_group"));
739 unGroupMenuItem.addActionListener(this);
741 nucleotideMenuItem.setLabel(MessageManager.getString("label.nucleotide"));
742 nucleotideMenuItem.addActionListener(this);
743 conservationMenuItem.addItemListener(this);
744 abovePIDColour.addItemListener(this);
745 colourMenu.setLabel(MessageManager.getString("label.group_colour"));
746 showBoxes.setLabel(MessageManager.getString("label.boxes"));
747 showBoxes.setState(true);
748 showBoxes.addItemListener(this);
749 sequenceName.addActionListener(this);
750 sequenceDetails.addActionListener(this);
751 selSeqDetails.addActionListener(this);
752 displayNonconserved.setLabel(MessageManager.getString("label.show_non_conversed"));
753 displayNonconserved.setState(false);
754 displayNonconserved.addItemListener(this);
755 showText.setLabel(MessageManager.getString("label.text"));
756 showText.addItemListener(this);
757 showColourText.setLabel(MessageManager.getString("label.colour_text"));
758 showColourText.addItemListener(this);
759 outputmenu.setLabel(MessageManager.getString("label.out_to_textbox"));
760 seqMenu.setLabel(MessageManager.getString("label.sequence"));
761 pdb.setLabel(MessageManager.getString("label.view_pdb_structure"));
762 hideSeqs.setLabel(MessageManager.getString("action.hide_sequences"));
763 repGroup.setLabel(MessageManager.getString("label.represent_group_with"));
764 revealAll.setLabel(MessageManager.getString("action.reveal_all"));
765 revealSeq.setLabel(MessageManager.getString("action.reveal_sequences"));
766 menu1.setLabel(MessageManager.getString("label.group"));
772 // groupMenu.add(selSeqDetails);
773 groupMenu.add(editGroupName);
774 groupMenu.add(editMenu);
775 groupMenu.add(outputmenu);
776 groupMenu.add(sequenceFeature);
777 groupMenu.add(menu1);
779 colourMenu.add(noColourmenuItem);
780 colourMenu.add(clustalColour);
781 colourMenu.add(BLOSUM62Colour);
782 colourMenu.add(PIDColour);
783 colourMenu.add(zappoColour);
784 colourMenu.add(taylorColour);
785 colourMenu.add(hydrophobicityColour);
786 colourMenu.add(helixColour);
787 colourMenu.add(strandColour);
788 colourMenu.add(turnColour);
789 colourMenu.add(buriedColour);
790 colourMenu.add(nucleotideMenuItem);
791 colourMenu.add(userDefinedColour);
792 colourMenu.addSeparator();
793 colourMenu.add(abovePIDColour);
794 colourMenu.add(conservationMenuItem);
796 noColourmenuItem.setLabel("None");
797 noColourmenuItem.addActionListener(this);
799 clustalColour.setLabel("Clustalx colours");
800 clustalColour.addActionListener(this);
801 zappoColour.setLabel("Zappo");
802 zappoColour.addActionListener(this);
803 taylorColour.setLabel("Taylor");
804 taylorColour.addActionListener(this);
805 hydrophobicityColour.setLabel("Hydrophobicity");
806 hydrophobicityColour.addActionListener(this);
807 helixColour.setLabel("Helix propensity");
808 helixColour.addActionListener(this);
809 strandColour.setLabel("Strand propensity");
810 strandColour.addActionListener(this);
811 turnColour.setLabel("Turn propensity");
812 turnColour.addActionListener(this);
813 buriedColour.setLabel("Buried Index");
814 buriedColour.addActionListener(this);
815 abovePIDColour.setLabel("Above % Identity");
817 userDefinedColour.setLabel("User Defined");
818 userDefinedColour.addActionListener(this);
819 PIDColour.setLabel("Percentage Identity");
820 PIDColour.addActionListener(this);
821 BLOSUM62Colour.setLabel("BLOSUM62");
822 BLOSUM62Colour.addActionListener(this);
823 conservationMenuItem.setLabel("Conservation");
826 copy.addActionListener(this);
828 cut.addActionListener(this);
830 editMenu.add(editSequence);
831 editSequence.addActionListener(this);
833 editMenu.add(toUpper);
834 toUpper.addActionListener(this);
835 editMenu.add(toLower);
836 toLower.addActionListener(this);
837 editMenu.add(toggleCase);
838 seqMenu.add(sequenceName);
839 // seqMenu.add(sequenceDetails);
841 if (!ap.av.applet.useXtrnalSviewer)
845 seqMenu.add(repGroup);
846 menu1.add(unGroupMenuItem);
847 menu1.add(colourMenu);
848 menu1.add(showBoxes);
850 menu1.add(showColourText);
851 menu1.add(displayNonconserved);
852 toggleCase.addActionListener(this);
853 pdb.addActionListener(this);
854 hideSeqs.addActionListener(this);
855 repGroup.addActionListener(this);
856 revealAll.addActionListener(this);
857 revealSeq.addActionListener(this);
862 ap.paintAlignment(true);
865 protected void clustalColour_actionPerformed()
867 SequenceGroup sg = getGroup();
868 sg.cs = new ClustalxColourScheme(sg, ap.av.getHiddenRepSequences());
872 protected void zappoColour_actionPerformed()
874 getGroup().cs = new ZappoColourScheme();
878 protected void taylorColour_actionPerformed()
880 getGroup().cs = new TaylorColourScheme();
884 protected void hydrophobicityColour_actionPerformed()
886 getGroup().cs = new HydrophobicColourScheme();
890 protected void helixColour_actionPerformed()
892 getGroup().cs = new HelixColourScheme();
896 protected void strandColour_actionPerformed()
898 getGroup().cs = new StrandColourScheme();
902 protected void turnColour_actionPerformed()
904 getGroup().cs = new TurnColourScheme();
908 protected void buriedColour_actionPerformed()
910 getGroup().cs = new BuriedColourScheme();
914 public void nucleotideMenuItem_actionPerformed()
916 getGroup().cs = new NucleotideColourScheme();
920 protected void abovePIDColour_itemStateChanged()
922 SequenceGroup sg = getGroup();
928 if (abovePIDColour.getState())
930 sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(ap.av
931 .getHiddenRepSequences()), 0, ap.av.getAlignment().getWidth()));
932 int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
935 sg.cs.setThreshold(threshold, ap.av.getIgnoreGapsConsensus());
937 SliderPanel.showPIDSlider();
941 // remove PIDColouring
943 sg.cs.setThreshold(0, ap.av.getIgnoreGapsConsensus());
950 protected void userDefinedColour_actionPerformed()
952 new UserDefinedColours(ap, getGroup());
955 protected void PIDColour_actionPerformed()
957 SequenceGroup sg = getGroup();
958 sg.cs = new PIDColourScheme();
959 sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(ap.av
960 .getHiddenRepSequences()), 0, ap.av.getAlignment().getWidth()));
964 protected void BLOSUM62Colour_actionPerformed()
966 SequenceGroup sg = getGroup();
968 sg.cs = new Blosum62ColourScheme();
970 sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(ap.av
971 .getHiddenRepSequences()), 0, ap.av.getAlignment().getWidth()));
976 protected void noColourmenuItem_actionPerformed()
978 getGroup().cs = null;
982 protected void conservationMenuItem_itemStateChanged()
984 SequenceGroup sg = getGroup();
990 if (conservationMenuItem.getState())
993 sg.cs.setConservation(Conservation.calculateConservation("Group",
994 ResidueProperties.propHash, 3, sg.getSequences(ap.av
995 .getHiddenRepSequences()), 0, ap.av.getAlignment()
996 .getWidth(), false, ap.av.getConsPercGaps(), false));
997 SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
998 SliderPanel.showConservationSlider();
1001 // remove ConservationColouring
1003 sg.cs.setConservation(null);
1009 SequenceGroup getGroup()
1011 SequenceGroup sg = ap.av.getSelectionGroup();
1013 // this method won't add a new group if it already exists
1016 ap.av.getAlignment().addGroup(sg);
1022 void unGroupMenuItem_actionPerformed()
1024 SequenceGroup sg = ap.av.getSelectionGroup();
1025 ap.av.getAlignment().deleteGroup(sg);
1026 ap.av.setSelectionGroup(null);
1027 ap.paintAlignment(true);
1030 public void showColourText_itemStateChanged()
1032 getGroup().setColourText(showColourText.getState());
1036 public void showText_itemStateChanged()
1038 getGroup().setDisplayText(showText.getState());
1042 public void showNonconserved_itemStateChanged()
1044 getGroup().setShowNonconserved(this.displayNonconserved.getState());
1048 public void showBoxes_itemStateChanged()
1050 getGroup().setDisplayBoxes(showBoxes.getState());
1054 void hideSequences(boolean representGroup)
1056 SequenceGroup sg = ap.av.getSelectionGroup();
1057 if (sg == null || sg.getSize() < 1)
1059 ap.av.hideSequence(new SequenceI[]
1064 ap.av.setSelectionGroup(null);
1068 ap.av.hideRepSequences(seq, sg);
1073 int gsize = sg.getSize();
1076 hseqs = new SequenceI[gsize];
1079 for (int i = 0; i < gsize; i++)
1081 hseqs[index++] = sg.getSequenceAt(i);
1084 ap.av.hideSequence(hseqs);
1085 ap.av.sendSelection();