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.UrlLink;
30 import jalview.io.AppletFormatAdapter;
31 import jalview.io.SequenceAnnotationReport;
33 public class APopupMenu extends java.awt.PopupMenu implements
34 ActionListener, ItemListener
36 Menu groupMenu = new Menu();
38 MenuItem editGroupName = new MenuItem();
40 protected MenuItem clustalColour = new MenuItem();
42 protected MenuItem zappoColour = new MenuItem();
44 protected MenuItem taylorColour = new MenuItem();
46 protected MenuItem hydrophobicityColour = new MenuItem();
48 protected MenuItem helixColour = new MenuItem();
50 protected MenuItem strandColour = new MenuItem();
52 protected MenuItem turnColour = new MenuItem();
54 protected MenuItem buriedColour = new MenuItem();
56 protected CheckboxMenuItem abovePIDColour = new CheckboxMenuItem();
58 protected MenuItem userDefinedColour = new MenuItem();
60 protected MenuItem PIDColour = new MenuItem();
62 protected MenuItem BLOSUM62Colour = new MenuItem();
64 MenuItem noColourmenuItem = new MenuItem();
66 protected CheckboxMenuItem conservationMenuItem = new CheckboxMenuItem();
68 final AlignmentPanel ap;
70 MenuItem unGroupMenuItem = new MenuItem();
72 MenuItem nucleotideMenuItem = new MenuItem();
74 Menu colourMenu = new Menu();
76 CheckboxMenuItem showBoxes = new CheckboxMenuItem();
78 CheckboxMenuItem showText = new CheckboxMenuItem();
80 CheckboxMenuItem showColourText = new CheckboxMenuItem();
82 CheckboxMenuItem displayNonconserved = new CheckboxMenuItem();
84 Menu editMenu = new Menu("Edit");
86 MenuItem copy = new MenuItem("Copy (Jalview Only)");
88 MenuItem cut = new MenuItem("Cut (Jalview Only)");
90 MenuItem toUpper = new MenuItem("To Upper Case");
92 MenuItem toLower = new MenuItem("To Lower Case");
94 MenuItem toggleCase = new MenuItem("Toggle Case");
96 Menu outputmenu = new Menu();
98 Menu seqMenu = new Menu();
100 MenuItem pdb = new MenuItem();
102 MenuItem hideSeqs = new MenuItem();
104 MenuItem repGroup = new MenuItem();
106 MenuItem sequenceName = new MenuItem("Edit Name/Description");
108 MenuItem sequenceFeature = new MenuItem("Create Sequence Feature");
110 MenuItem editSequence = new MenuItem("Edit Sequence");
112 MenuItem sequenceDetails = new MenuItem("Sequence Details ...");
114 MenuItem selSeqDetails = new MenuItem("Sequence Details ...");
118 MenuItem revealAll = new MenuItem();
120 MenuItem revealSeq = new MenuItem();
123 * index of sequence to be revealed
125 int revealSeq_index = -1;
127 Menu menu1 = new Menu();
129 public APopupMenu(AlignmentPanel apanel, final Sequence seq, Vector links)
131 // /////////////////////////////////////////////////////////
132 // If this is activated from the sequence panel, the user may want to
133 // edit or annotate a particular residue. Therefore display the residue menu
135 // If from the IDPanel, we must display the sequence menu
136 // ////////////////////////////////////////////////////////
144 } catch (Exception e)
149 for (int i = 0; i < jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS.length; i++)
151 MenuItem item = new MenuItem(
152 jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS[i]);
154 item.addActionListener(this);
155 outputmenu.add(item);
158 SequenceGroup sg = ap.av.getSelectionGroup();
160 if (sg != null && sg.getSize() > 0)
162 editGroupName.setLabel("Name: " + sg.getName());
163 showText.setState(sg.getDisplayText());
164 showColourText.setState(sg.getColourText());
165 showBoxes.setState(sg.getDisplayBoxes());
166 displayNonconserved.setState(sg.getShowNonconserved());
167 if (!ap.av.getAlignment().getGroups().contains(sg))
169 groupMenu.remove(unGroupMenuItem);
179 if (links != null && links.size() > 0)
181 Menu linkMenu = new Menu("Link");
183 for (int i = 0; i < links.size(); i++)
185 link = links.elementAt(i).toString();
186 UrlLink urlLink = new UrlLink(link);
187 if (!urlLink.isValid())
189 System.err.println(urlLink.getInvalidMessage());
192 final String target = urlLink.getTarget(); // link.substring(0,
193 // link.indexOf("|"));
194 final String label = urlLink.getLabel();
195 if (seq != null && urlLink.isDynamic())
198 // collect matching db-refs
199 DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(
200 seq.getDBRef(), new String[]
202 // collect id string too
203 String id = seq.getName();
204 String descr = seq.getDescription();
205 if (descr != null && descr.length() < 1)
211 for (int r = 0; r < dbr.length; r++)
213 if (id != null && dbr[r].getAccessionId().equals(id))
215 // suppress duplicate link creation for the bare sequence ID
216 // string with this link
219 // create Bare ID link for this RUL
220 String[] urls = urlLink.makeUrls(dbr[r].getAccessionId(),
224 for (int u = 0; u < urls.length; u += 2)
226 addshowLink(linkMenu, label + "|" + urls[u], urls[u + 1]);
233 // create Bare ID link for this RUL
234 String[] urls = urlLink.makeUrls(id, true);
237 for (int u = 0; u < urls.length; u += 2)
239 addshowLink(linkMenu, label, urls[u + 1]);
242 // addshowLink(linkMenu, target, url_pref + id + url_suff);
244 // Now construct URLs from description but only try to do it for regex
246 if (descr != null && urlLink.getRegexReplace() != null)
248 // create link for this URL from description only if regex matches
249 String[] urls = urlLink.makeUrls(descr, true);
252 for (int u = 0; u < urls.length; u += 2)
254 addshowLink(linkMenu, label, urls[u + 1]);
261 addshowLink(linkMenu, target, urlLink.getUrl_prefix()); // link.substring(link.lastIndexOf("|")+1));
266 * if (link.indexOf("$SEQUENCE_ID$") > -1) { // Substitute SEQUENCE_ID
267 * string and any matching database reference accessions String url_pref
268 * = link.substring(link.indexOf("|") + 1,
269 * link.indexOf("$SEQUENCE_ID$"));
271 * String url_suff = link.substring(link.indexOf("$SEQUENCE_ID$") + 13);
272 * // collect matching db-refs DBRefEntry[] dbr =
273 * jalview.util.DBRefUtils.selectRefs(seq.getDBRef(), new
274 * String[]{target}); // collect id string too String id =
275 * seq.getName(); if (id.indexOf("|") > -1) { id =
276 * id.substring(id.lastIndexOf("|") + 1); } if (dbr!=null) { for (int
277 * r=0;r<dbr.length; r++) { if (dbr[r].getAccessionId().equals(id)) { //
278 * suppress duplicate link creation for the bare sequence ID string with
279 * this link id = null; } addshowLink(linkMenu,
280 * dbr[r].getSource()+"|"+dbr[r].getAccessionId(), target,
281 * url_pref+dbr[r].getAccessionId()+url_suff); } } if (id!=null) { //
282 * create Bare ID link for this RUL addshowLink(linkMenu, target,
283 * url_pref + id + url_suff); } } else { addshowLink(linkMenu, target,
284 * link.substring(link.lastIndexOf("|")+1)); }
287 if (linkMenu.getItemCount() > 0)
291 seqMenu.add(linkMenu);
299 // TODO: add group link menu entry here
302 seqMenu.setLabel(seq.getName());
303 repGroup.setLabel("Represent Group with " + seq.getName());
310 if (!ap.av.hasHiddenRows())
317 final int index = ap.av.getAlignment().findIndex(seq);
319 if (ap.av.adjustForHiddenSeqs(index)
320 - ap.av.adjustForHiddenSeqs(index - 1) > 1)
322 revealSeq_index = index;
332 * add a show URL menu item to the given linkMenu
336 * - menu label string
340 private void addshowLink(Menu linkMenu, final String target,
343 addshowLink(linkMenu, target, target, url);
347 * add a show URL menu item to the given linkMenu
351 * - URL target window
353 * - menu label string
357 private void addshowLink(Menu linkMenu, final String target,
358 final String label, final String url)
360 MenuItem item = new MenuItem(label);
361 item.addActionListener(new java.awt.event.ActionListener()
363 public void actionPerformed(ActionEvent e)
365 ap.alignFrame.showURL(url, target);
371 public void itemStateChanged(ItemEvent evt)
373 if (evt.getSource() == abovePIDColour)
375 abovePIDColour_itemStateChanged();
377 else if (evt.getSource() == showColourText)
379 showColourText_itemStateChanged();
381 else if (evt.getSource() == showText)
383 showText_itemStateChanged();
385 else if (evt.getSource() == showBoxes)
387 showBoxes_itemStateChanged();
389 else if (evt.getSource() == displayNonconserved)
391 this.showNonconserved_itemStateChanged();
395 public void actionPerformed(ActionEvent evt)
397 Object source = evt.getSource();
398 if (source == clustalColour)
400 clustalColour_actionPerformed();
402 else if (source == zappoColour)
404 zappoColour_actionPerformed();
406 else if (source == taylorColour)
408 taylorColour_actionPerformed();
410 else if (source == hydrophobicityColour)
412 hydrophobicityColour_actionPerformed();
414 else if (source == helixColour)
416 helixColour_actionPerformed();
418 else if (source == strandColour)
420 strandColour_actionPerformed();
422 else if (source == turnColour)
424 turnColour_actionPerformed();
426 else if (source == buriedColour)
428 buriedColour_actionPerformed();
430 else if (source == nucleotideMenuItem)
432 nucleotideMenuItem_actionPerformed();
435 else if (source == userDefinedColour)
437 userDefinedColour_actionPerformed();
439 else if (source == PIDColour)
441 PIDColour_actionPerformed();
443 else if (source == BLOSUM62Colour)
445 BLOSUM62Colour_actionPerformed();
447 else if (source == noColourmenuItem)
449 noColourmenuItem_actionPerformed();
451 else if (source == conservationMenuItem)
453 conservationMenuItem_itemStateChanged();
455 else if (source == unGroupMenuItem)
457 unGroupMenuItem_actionPerformed();
460 else if (source == sequenceName)
464 else if (source == sequenceDetails)
466 showSequenceDetails();
468 else if (source == selSeqDetails)
470 showSequenceSelectionDetails();
472 else if (source == pdb)
476 else if (source == hideSeqs)
478 hideSequences(false);
480 else if (source == repGroup)
484 else if (source == revealSeq)
486 ap.av.showSequence(revealSeq_index);
488 else if (source == revealAll)
490 ap.av.showAllHiddenSeqs();
493 else if (source == editGroupName)
495 EditNameDialog dialog = new EditNameDialog(getGroup().getName(),
496 getGroup().getDescription(), " Group Name",
497 "Group Description", ap.alignFrame,
498 "Edit Group Name / Description", 500, 100, true);
502 getGroup().setName(dialog.getName().replace(' ', '_'));
503 getGroup().setDescription(dialog.getDescription());
507 else if (source == copy)
509 ap.alignFrame.copy_actionPerformed();
511 else if (source == cut)
513 ap.alignFrame.cut_actionPerformed();
515 else if (source == editSequence)
517 SequenceGroup sg = ap.av.getSelectionGroup();
522 seq = (Sequence) sg.getSequenceAt(0);
524 EditNameDialog dialog = new EditNameDialog(seq.getSequenceAsString(
525 sg.getStartRes(), sg.getEndRes() + 1), null,
526 "Edit Sequence ", null,
528 ap.alignFrame, "Edit Sequence", 500, 100, true);
532 EditCommand editCommand = new EditCommand("Edit Sequences",
533 EditCommand.REPLACE, dialog.getName().replace(' ',
534 ap.av.getGapCharacter()),
535 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
536 sg.getStartRes(), sg.getEndRes() + 1,
537 ap.av.getAlignment());
539 ap.alignFrame.addHistoryItem(editCommand);
541 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
546 else if (source == toUpper || source == toLower || source == toggleCase)
548 SequenceGroup sg = ap.av.getSelectionGroup();
549 Vector regions = new Vector();
552 int[][] startEnd = ap.av.getVisibleRegionBoundaries(
553 sg.getStartRes(), sg.getEndRes() + 1);
558 if (source == toggleCase)
560 description = "Toggle Case";
561 caseChange = ChangeCaseCommand.TOGGLE_CASE;
563 else if (source == toUpper)
565 description = "To Upper Case";
566 caseChange = ChangeCaseCommand.TO_UPPER;
570 description = "To Lower Case";
571 caseChange = ChangeCaseCommand.TO_LOWER;
574 ChangeCaseCommand caseCommand = new ChangeCaseCommand(description,
575 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
576 startEnd, caseChange);
578 ap.alignFrame.addHistoryItem(caseCommand);
580 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
585 else if (source == sequenceFeature)
587 SequenceGroup sg = ap.av.getSelectionGroup();
593 int rsize = 0, gSize = sg.getSize();
594 SequenceI[] rseqs, seqs = new SequenceI[gSize];
595 SequenceFeature[] tfeatures, features = new SequenceFeature[gSize];
597 for (int i = 0; i < gSize; i++)
599 int start = sg.getSequenceAt(i).findPosition(sg.getStartRes());
600 int end = sg.findEndRes(sg.getSequenceAt(i));
603 seqs[rsize] = sg.getSequenceAt(i);
604 features[rsize] = new SequenceFeature(null, null, null, start,
609 rseqs = new SequenceI[rsize];
610 tfeatures = new SequenceFeature[rsize];
611 System.arraycopy(seqs, 0, rseqs, 0, rsize);
612 System.arraycopy(features, 0, tfeatures, 0, rsize);
613 features = tfeatures;
616 if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs,
619 ap.alignFrame.sequenceFeatures.setState(true);
620 ap.av.showSequenceFeatures(true);
621 ap.highlightSearchResults(null);
631 void outputText(ActionEvent e)
633 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, ap.alignFrame);
635 Frame frame = new Frame();
637 jalview.bin.JalviewLite.addFrame(frame,
638 "Selection output - " + e.getActionCommand(), 600, 500);
639 // JBPNote: getSelectionAsNewSequence behaviour has changed - this method
640 // now returns a full copy of sequence data
641 // TODO consider using getSequenceSelection instead here
643 cap.setText(new jalview.io.AppletFormatAdapter().formatSequences(
644 e.getActionCommand(),
645 new Alignment(ap.av.getSelectionAsNewSequence()),
646 ap.av.showJVSuffix));
650 protected void showSequenceSelectionDetails()
652 createSequenceDetailsReport(ap.av.getSequenceSelection());
655 protected void showSequenceDetails()
657 createSequenceDetailsReport(new SequenceI[]
661 public void createSequenceDetailsReport(SequenceI[] sequences)
664 CutAndPasteTransfer cap = new CutAndPasteTransfer(false, ap.alignFrame);
666 StringBuffer contents = new StringBuffer();
667 for (SequenceI seq : sequences)
669 contents.append("<p><h2>Annotation for " + 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("<html>" + contents.toString() + "</html>");
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("Paste your PDB file here.");
723 cap.setPDBImport(seq);
724 Frame frame = new Frame();
726 jalview.bin.JalviewLite.addFrame(frame,
727 "Paste PDB file for sequence " + seq.getName(), 400, 300);
731 private void jbInit() throws Exception
733 groupMenu.setLabel("Group");
734 groupMenu.setLabel("Selection");
735 sequenceFeature.addActionListener(this);
737 editGroupName.addActionListener(this);
738 unGroupMenuItem.setLabel("Remove Group");
739 unGroupMenuItem.addActionListener(this);
741 nucleotideMenuItem.setLabel("Nucleotide");
742 nucleotideMenuItem.addActionListener(this);
743 conservationMenuItem.addItemListener(this);
744 abovePIDColour.addItemListener(this);
745 colourMenu.setLabel("Group Colour");
746 showBoxes.setLabel("Boxes");
747 showBoxes.setState(true);
748 showBoxes.addItemListener(this);
749 sequenceName.addActionListener(this);
750 sequenceDetails.addActionListener(this);
751 selSeqDetails.addActionListener(this);
752 displayNonconserved.setLabel("Show Nonconserved");
753 displayNonconserved.setState(false);
754 displayNonconserved.addItemListener(this);
755 showText.setLabel("Text");
756 showText.addItemListener(this);
757 showColourText.setLabel("Colour Text");
758 showColourText.addItemListener(this);
759 outputmenu.setLabel("Output to Textbox...");
760 seqMenu.setLabel("Sequence");
761 pdb.setLabel("View PDB Structure");
762 hideSeqs.setLabel("Hide Sequences");
763 repGroup.setLabel("Represent Group with");
764 revealAll.setLabel("Reveal All");
765 revealSeq.setLabel("Reveal Sequences");
766 menu1.setLabel("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();