2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
3 * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 import java.awt.event.*;
28 import jalview.analysis.*;
29 import jalview.commands.*;
30 import jalview.datamodel.*;
32 import jalview.schemes.*;
33 import jalview.util.UrlLink;
41 public class PopupMenu extends JPopupMenu
43 JMenu groupMenu = new JMenu();
45 JMenuItem groupName = new JMenuItem();
47 protected JRadioButtonMenuItem clustalColour = new JRadioButtonMenuItem();
49 protected JRadioButtonMenuItem zappoColour = new JRadioButtonMenuItem();
51 protected JRadioButtonMenuItem taylorColour = new JRadioButtonMenuItem();
53 protected JRadioButtonMenuItem hydrophobicityColour = new JRadioButtonMenuItem();
55 protected JRadioButtonMenuItem helixColour = new JRadioButtonMenuItem();
57 protected JRadioButtonMenuItem strandColour = new JRadioButtonMenuItem();
59 protected JRadioButtonMenuItem turnColour = new JRadioButtonMenuItem();
61 protected JRadioButtonMenuItem buriedColour = new JRadioButtonMenuItem();
63 protected JCheckBoxMenuItem abovePIDColour = new JCheckBoxMenuItem();
65 protected JRadioButtonMenuItem userDefinedColour = new JRadioButtonMenuItem();
67 protected JRadioButtonMenuItem PIDColour = new JRadioButtonMenuItem();
69 protected JRadioButtonMenuItem BLOSUM62Colour = new JRadioButtonMenuItem();
71 JRadioButtonMenuItem noColourmenuItem = new JRadioButtonMenuItem();
73 protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem();
77 JMenu sequenceMenu = new JMenu();
79 JMenuItem sequenceName = new JMenuItem();
83 JMenuItem unGroupMenuItem = new JMenuItem();
85 JMenuItem outline = new JMenuItem();
87 JRadioButtonMenuItem nucleotideMenuItem = new JRadioButtonMenuItem();
89 JMenu colourMenu = new JMenu();
91 JCheckBoxMenuItem showBoxes = new JCheckBoxMenuItem();
93 JCheckBoxMenuItem showText = new JCheckBoxMenuItem();
95 JCheckBoxMenuItem showColourText = new JCheckBoxMenuItem();
97 JMenu editMenu = new JMenu();
99 JMenuItem cut = new JMenuItem();
101 JMenuItem copy = new JMenuItem();
103 JMenuItem upperCase = new JMenuItem();
105 JMenuItem lowerCase = new JMenuItem();
107 JMenuItem toggle = new JMenuItem();
109 JMenu pdbMenu = new JMenu();
111 JMenuItem pdbFromFile = new JMenuItem();
113 JMenuItem enterPDB = new JMenuItem();
115 JMenuItem discoverPDB = new JMenuItem();
117 JMenu outputMenu = new JMenu();
119 JMenuItem sequenceFeature = new JMenuItem();
121 JMenuItem textColour = new JMenuItem();
123 JMenu jMenu1 = new JMenu();
125 JMenu structureMenu = new JMenu();
127 JMenu viewStructureMenu = new JMenu();
129 // JMenu colStructureMenu = new JMenu();
130 JMenuItem editSequence = new JMenuItem();
132 // JMenuItem annotationMenuItem = new JMenuItem();
135 * Creates a new PopupMenu object.
142 public PopupMenu(final AlignmentPanel ap, Sequence seq, Vector links)
144 // /////////////////////////////////////////////////////////
145 // If this is activated from the sequence panel, the user may want to
146 // edit or annotate a particular residue. Therefore display the residue menu
148 // If from the IDPanel, we must display the sequence menu
149 // ////////////////////////////////////////////////////////
153 ButtonGroup colours = new ButtonGroup();
154 colours.add(noColourmenuItem);
155 colours.add(clustalColour);
156 colours.add(zappoColour);
157 colours.add(taylorColour);
158 colours.add(hydrophobicityColour);
159 colours.add(helixColour);
160 colours.add(strandColour);
161 colours.add(turnColour);
162 colours.add(buriedColour);
163 colours.add(abovePIDColour);
164 colours.add(userDefinedColour);
165 colours.add(PIDColour);
166 colours.add(BLOSUM62Colour);
168 for (int i = 0; i < jalview.io.FormatAdapter.WRITEABLE_FORMATS.length; i++)
170 JMenuItem item = new JMenuItem(
171 jalview.io.FormatAdapter.WRITEABLE_FORMATS[i]);
173 item.addActionListener(new java.awt.event.ActionListener()
175 public void actionPerformed(ActionEvent e)
177 outputText_actionPerformed(e);
181 outputMenu.add(item);
187 } catch (Exception e)
194 sequenceMenu.setText(sequence.getName());
197 if (seq.getDatasetSequence().getPDBId() != null
198 && seq.getDatasetSequence().getPDBId().size() > 0)
200 java.util.Enumeration e = seq.getDatasetSequence().getPDBId()
203 while (e.hasMoreElements())
205 final PDBEntry pdb = (PDBEntry) e.nextElement();
207 menuItem = new JMenuItem();
208 menuItem.setText(pdb.getId());
209 menuItem.addActionListener(new java.awt.event.ActionListener()
211 public void actionPerformed(ActionEvent e)
213 Vector seqs = new Vector();
214 for (int i = 0; i < ap.av.alignment.getHeight(); i++)
216 Vector pdbs = ap.av.alignment.getSequenceAt(i)
217 .getDatasetSequence().getPDBId();
221 for (int p = 0; p < pdbs.size(); p++)
223 PDBEntry p1 = (PDBEntry) pdbs.elementAt(p);
224 if (p1.getId().equals(pdb.getId()))
226 if (!seqs.contains(ap.av.alignment.getSequenceAt(i)))
227 seqs.addElement(ap.av.alignment.getSequenceAt(i));
234 SequenceI[] seqs2 = new SequenceI[seqs.size()];
237 new AppJmol(pdb, seqs2, null, ap);
238 // new PDBViewer(pdb, seqs2, null, ap, AppletFormatAdapter.FILE);
241 viewStructureMenu.add(menuItem);
244 * menuItem = new JMenuItem(); menuItem.setText(pdb.getId());
245 * menuItem.addActionListener(new java.awt.event.ActionListener() {
246 * public void actionPerformed(ActionEvent e) {
247 * colourByStructure(pdb.getId()); } });
248 * colStructureMenu.add(menuItem);
254 structureMenu.remove(viewStructureMenu);
255 // structureMenu.remove(colStructureMenu);
258 menuItem = new JMenuItem("Hide Sequences");
259 menuItem.addActionListener(new java.awt.event.ActionListener()
261 public void actionPerformed(ActionEvent e)
263 hideSequences(false);
268 if (ap.av.getSelectionGroup() != null
269 && ap.av.getSelectionGroup().getSize() > 1)
271 menuItem = new JMenuItem("Represent Group with " + seq.getName());
272 menuItem.addActionListener(new java.awt.event.ActionListener()
274 public void actionPerformed(ActionEvent e)
279 sequenceMenu.add(menuItem);
282 if (ap.av.hasHiddenRows)
284 final int index = ap.av.alignment.findIndex(seq);
286 if (ap.av.adjustForHiddenSeqs(index)
287 - ap.av.adjustForHiddenSeqs(index - 1) > 1)
289 menuItem = new JMenuItem("Reveal Sequences");
290 menuItem.addActionListener(new ActionListener()
292 public void actionPerformed(ActionEvent e)
294 ap.av.showSequence(index);
295 if (ap.overviewPanel != null)
297 ap.overviewPanel.updateOverviewImage();
304 menuItem = new JMenuItem("Reveal All");
305 menuItem.addActionListener(new ActionListener()
307 public void actionPerformed(ActionEvent e)
309 ap.av.showAllHiddenSeqs();
310 if (ap.overviewPanel != null)
312 ap.overviewPanel.updateOverviewImage();
322 SequenceGroup sg = ap.av.getSelectionGroup();
326 groupName.setText(sg.getName());
328 if (sg.cs instanceof ZappoColourScheme)
330 zappoColour.setSelected(true);
332 else if (sg.cs instanceof TaylorColourScheme)
334 taylorColour.setSelected(true);
336 else if (sg.cs instanceof PIDColourScheme)
338 PIDColour.setSelected(true);
340 else if (sg.cs instanceof Blosum62ColourScheme)
342 BLOSUM62Colour.setSelected(true);
344 else if (sg.cs instanceof UserColourScheme)
346 userDefinedColour.setSelected(true);
348 else if (sg.cs instanceof HydrophobicColourScheme)
350 hydrophobicityColour.setSelected(true);
352 else if (sg.cs instanceof HelixColourScheme)
354 helixColour.setSelected(true);
356 else if (sg.cs instanceof StrandColourScheme)
358 strandColour.setSelected(true);
360 else if (sg.cs instanceof TurnColourScheme)
362 turnColour.setSelected(true);
364 else if (sg.cs instanceof BuriedColourScheme)
366 buriedColour.setSelected(true);
368 else if (sg.cs instanceof ClustalxColourScheme)
370 clustalColour.setSelected(true);
374 noColourmenuItem.setSelected(true);
377 if (sg.cs != null && sg.cs.conservationApplied())
379 conservationMenuItem.setSelected(true);
382 showText.setSelected(sg.getDisplayText());
383 showColourText.setSelected(sg.getColourText());
384 showBoxes.setSelected(sg.getDisplayBoxes());
388 groupMenu.setVisible(false);
389 editMenu.setVisible(false);
392 if (!ap.av.alignment.getGroups().contains(sg))
394 unGroupMenuItem.setVisible(false);
399 sequenceMenu.setVisible(false);
400 structureMenu.setVisible(false);
403 if (links != null && links.size() > 0)
405 JMenu linkMenu = new JMenu("Link");
407 for (int i = 0; i < links.size(); i++)
409 String link = links.elementAt(i).toString();
410 UrlLink urlLink = null;
413 urlLink = new UrlLink(link);
414 } catch (Exception foo)
416 jalview.bin.Cache.log.error("Exception for URLLink '" + link
421 if (!urlLink.isValid())
423 jalview.bin.Cache.log.error(urlLink.getInvalidMessage());
426 final String label = urlLink.getLabel();
427 if (urlLink.isDynamic())
430 // collect matching db-refs
431 DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(seq
432 .getDBRef(), new String[]
433 { urlLink.getTarget() });
434 // collect id string too
435 String id = seq.getName();
436 String descr = seq.getDescription();
437 if (descr!=null && descr.length()<1)
444 for (int r = 0; r < dbr.length; r++)
446 if (id != null && dbr[r].getAccessionId().equals(id))
448 // suppress duplicate link creation for the bare sequence ID
449 // string with this link
452 // create Bare ID link for this RUL
453 String[] urls = urlLink.makeUrls(dbr[r].getAccessionId(),
457 for (int u = 0; u < urls.length; u += 2)
459 addshowLink(linkMenu, label + "|" + urls[u], urls[u + 1]);
466 // create Bare ID link for this RUL
467 String[] urls = urlLink.makeUrls(id, true);
470 for (int u = 0; u < urls.length; u += 2)
472 addshowLink(linkMenu, label, urls[u + 1]);
476 // Create urls from description but only for URL links which are regex links
477 if (descr != null && urlLink.getRegexReplace()!=null)
479 // create link for this URL from description where regex matches
480 String[] urls = urlLink.makeUrls(descr, true);
483 for (int u = 0; u < urls.length; u += 2)
485 addshowLink(linkMenu, label, urls[u + 1]);
492 // Add a non-dynamic link
493 addshowLink(linkMenu, label, urlLink.getUrl_prefix());
496 if (sequence != null)
498 sequenceMenu.add(linkMenu);
508 * add a show URL menu item to the given linkMenu
516 private void addshowLink(JMenu linkMenu, String label, final String url)
518 JMenuItem item = new JMenuItem(label);
519 item.setToolTipText("open URL: " + url);
520 item.addActionListener(new java.awt.event.ActionListener()
522 public void actionPerformed(ActionEvent e)
524 new Thread(new Runnable()
545 private void jbInit() throws Exception
547 groupMenu.setText("Group");
548 groupMenu.setText("Selection");
549 groupName.setText("Name");
550 groupName.addActionListener(new java.awt.event.ActionListener()
552 public void actionPerformed(ActionEvent e)
554 groupName_actionPerformed();
557 sequenceMenu.setText("Sequence");
558 sequenceName.setText("Edit Name/Description");
559 sequenceName.addActionListener(new java.awt.event.ActionListener()
561 public void actionPerformed(ActionEvent e)
563 sequenceName_actionPerformed();
566 PIDColour.setFocusPainted(false);
567 unGroupMenuItem.setText("Remove Group");
568 unGroupMenuItem.addActionListener(new java.awt.event.ActionListener()
570 public void actionPerformed(ActionEvent e)
572 unGroupMenuItem_actionPerformed();
576 outline.setText("Border colour");
577 outline.addActionListener(new java.awt.event.ActionListener()
579 public void actionPerformed(ActionEvent e)
581 outline_actionPerformed();
584 nucleotideMenuItem.setText("Nucleotide");
585 nucleotideMenuItem.addActionListener(new ActionListener()
587 public void actionPerformed(ActionEvent e)
589 nucleotideMenuItem_actionPerformed();
592 colourMenu.setText("Group Colour");
593 showBoxes.setText("Boxes");
594 showBoxes.setState(true);
595 showBoxes.addActionListener(new ActionListener()
597 public void actionPerformed(ActionEvent e)
599 showBoxes_actionPerformed();
602 showText.setText("Text");
603 showText.setState(true);
604 showText.addActionListener(new ActionListener()
606 public void actionPerformed(ActionEvent e)
608 showText_actionPerformed();
611 showColourText.setText("Colour Text");
612 showColourText.addActionListener(new ActionListener()
614 public void actionPerformed(ActionEvent e)
616 showColourText_actionPerformed();
619 editMenu.setText("Edit");
621 cut.addActionListener(new ActionListener()
623 public void actionPerformed(ActionEvent e)
625 cut_actionPerformed();
628 upperCase.setText("To Upper Case");
629 upperCase.addActionListener(new ActionListener()
631 public void actionPerformed(ActionEvent e)
636 copy.setText("Copy");
637 copy.addActionListener(new ActionListener()
639 public void actionPerformed(ActionEvent e)
641 copy_actionPerformed();
644 lowerCase.setText("To Lower Case");
645 lowerCase.addActionListener(new ActionListener()
647 public void actionPerformed(ActionEvent e)
652 toggle.setText("Toggle Case");
653 toggle.addActionListener(new ActionListener()
655 public void actionPerformed(ActionEvent e)
660 pdbMenu.setText("Associate Structure with Sequence");
661 pdbFromFile.setText("From File");
662 pdbFromFile.addActionListener(new ActionListener()
664 public void actionPerformed(ActionEvent e)
666 pdbFromFile_actionPerformed();
669 enterPDB.setText("Enter PDB Id");
670 enterPDB.addActionListener(new ActionListener()
672 public void actionPerformed(ActionEvent e)
674 enterPDB_actionPerformed();
677 discoverPDB.setText("Discover PDB ids");
678 discoverPDB.addActionListener(new ActionListener()
680 public void actionPerformed(ActionEvent e)
682 discoverPDB_actionPerformed();
685 outputMenu.setText("Output to Textbox...");
686 sequenceFeature.setText("Create Sequence Feature");
687 sequenceFeature.addActionListener(new ActionListener()
689 public void actionPerformed(ActionEvent e)
691 sequenceFeature_actionPerformed();
694 textColour.setText("Text Colour");
695 textColour.addActionListener(new ActionListener()
697 public void actionPerformed(ActionEvent e)
699 textColour_actionPerformed();
702 jMenu1.setText("Group");
703 structureMenu.setText("Structure");
704 viewStructureMenu.setText("View Structure");
705 // colStructureMenu.setText("Colour By Structure");
706 editSequence.setText("Edit Sequence...");
707 editSequence.addActionListener(new ActionListener()
709 public void actionPerformed(ActionEvent actionEvent)
711 editSequence_actionPerformed(actionEvent);
715 * annotationMenuItem.setText("By Annotation");
716 * annotationMenuItem.addActionListener(new ActionListener() { public void
717 * actionPerformed(ActionEvent actionEvent) {
718 * annotationMenuItem_actionPerformed(actionEvent); } });
724 this.add(structureMenu);
725 groupMenu.add(editMenu);
726 groupMenu.add(outputMenu);
727 groupMenu.add(sequenceFeature);
728 groupMenu.add(jMenu1);
729 sequenceMenu.add(sequenceName);
730 colourMenu.add(textColour);
731 colourMenu.add(noColourmenuItem);
732 colourMenu.add(clustalColour);
733 colourMenu.add(BLOSUM62Colour);
734 colourMenu.add(PIDColour);
735 colourMenu.add(zappoColour);
736 colourMenu.add(taylorColour);
737 colourMenu.add(hydrophobicityColour);
738 colourMenu.add(helixColour);
739 colourMenu.add(strandColour);
740 colourMenu.add(turnColour);
741 colourMenu.add(buriedColour);
742 colourMenu.add(nucleotideMenuItem);
743 colourMenu.add(userDefinedColour);
745 if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null)
747 java.util.Enumeration userColours = jalview.gui.UserDefinedColours
748 .getUserColourSchemes().keys();
750 while (userColours.hasMoreElements())
752 JMenuItem item = new JMenuItem(userColours.nextElement().toString());
753 item.addActionListener(new ActionListener()
755 public void actionPerformed(ActionEvent evt)
757 userDefinedColour_actionPerformed(evt);
760 colourMenu.add(item);
764 colourMenu.addSeparator();
765 colourMenu.add(abovePIDColour);
766 colourMenu.add(conservationMenuItem);
767 // colourMenu.add(annotationMenuItem);
770 editMenu.add(editSequence);
771 editMenu.add(upperCase);
772 editMenu.add(lowerCase);
773 editMenu.add(toggle);
774 pdbMenu.add(pdbFromFile);
775 pdbMenu.add(enterPDB);
776 pdbMenu.add(discoverPDB);
777 jMenu1.add(groupName);
778 jMenu1.add(unGroupMenuItem);
779 jMenu1.add(colourMenu);
780 jMenu1.add(showBoxes);
781 jMenu1.add(showText);
782 jMenu1.add(showColourText);
784 structureMenu.add(pdbMenu);
785 structureMenu.add(viewStructureMenu);
786 // structureMenu.add(colStructureMenu);
787 noColourmenuItem.setText("None");
788 noColourmenuItem.addActionListener(new java.awt.event.ActionListener()
790 public void actionPerformed(ActionEvent e)
792 noColourmenuItem_actionPerformed();
796 clustalColour.setText("Clustalx colours");
797 clustalColour.addActionListener(new java.awt.event.ActionListener()
799 public void actionPerformed(ActionEvent e)
801 clustalColour_actionPerformed();
804 zappoColour.setText("Zappo");
805 zappoColour.addActionListener(new java.awt.event.ActionListener()
807 public void actionPerformed(ActionEvent e)
809 zappoColour_actionPerformed();
812 taylorColour.setText("Taylor");
813 taylorColour.addActionListener(new java.awt.event.ActionListener()
815 public void actionPerformed(ActionEvent e)
817 taylorColour_actionPerformed();
820 hydrophobicityColour.setText("Hydrophobicity");
822 .addActionListener(new java.awt.event.ActionListener()
824 public void actionPerformed(ActionEvent e)
826 hydrophobicityColour_actionPerformed();
829 helixColour.setText("Helix propensity");
830 helixColour.addActionListener(new java.awt.event.ActionListener()
832 public void actionPerformed(ActionEvent e)
834 helixColour_actionPerformed();
837 strandColour.setText("Strand propensity");
838 strandColour.addActionListener(new java.awt.event.ActionListener()
840 public void actionPerformed(ActionEvent e)
842 strandColour_actionPerformed();
845 turnColour.setText("Turn propensity");
846 turnColour.addActionListener(new java.awt.event.ActionListener()
848 public void actionPerformed(ActionEvent e)
850 turnColour_actionPerformed();
853 buriedColour.setText("Buried Index");
854 buriedColour.addActionListener(new java.awt.event.ActionListener()
856 public void actionPerformed(ActionEvent e)
858 buriedColour_actionPerformed();
861 abovePIDColour.setText("Above % Identity");
862 abovePIDColour.addActionListener(new java.awt.event.ActionListener()
864 public void actionPerformed(ActionEvent e)
866 abovePIDColour_actionPerformed();
869 userDefinedColour.setText("User Defined...");
870 userDefinedColour.addActionListener(new java.awt.event.ActionListener()
872 public void actionPerformed(ActionEvent e)
874 userDefinedColour_actionPerformed(e);
877 PIDColour.setText("Percentage Identity");
878 PIDColour.addActionListener(new java.awt.event.ActionListener()
880 public void actionPerformed(ActionEvent e)
882 PIDColour_actionPerformed();
885 BLOSUM62Colour.setText("BLOSUM62");
886 BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener()
888 public void actionPerformed(ActionEvent e)
890 BLOSUM62Colour_actionPerformed();
893 conservationMenuItem.setText("Conservation");
895 .addActionListener(new java.awt.event.ActionListener()
897 public void actionPerformed(ActionEvent e)
899 conservationMenuItem_actionPerformed();
909 ap.paintAlignment(true);
911 PaintRefresher.Refresh(this, ap.av.getSequenceSetId());
920 protected void clustalColour_actionPerformed()
922 SequenceGroup sg = getGroup();
923 sg.cs = new ClustalxColourScheme(sg
924 .getSequences(ap.av.hiddenRepSequences), ap.av.alignment
935 protected void zappoColour_actionPerformed()
937 getGroup().cs = new ZappoColourScheme();
947 protected void taylorColour_actionPerformed()
949 getGroup().cs = new TaylorColourScheme();
959 protected void hydrophobicityColour_actionPerformed()
961 getGroup().cs = new HydrophobicColourScheme();
971 protected void helixColour_actionPerformed()
973 getGroup().cs = new HelixColourScheme();
983 protected void strandColour_actionPerformed()
985 getGroup().cs = new StrandColourScheme();
995 protected void turnColour_actionPerformed()
997 getGroup().cs = new TurnColourScheme();
1007 protected void buriedColour_actionPerformed()
1009 getGroup().cs = new BuriedColourScheme();
1019 public void nucleotideMenuItem_actionPerformed()
1021 getGroup().cs = new NucleotideColourScheme();
1031 protected void abovePIDColour_actionPerformed()
1033 SequenceGroup sg = getGroup();
1039 if (abovePIDColour.isSelected())
1041 sg.cs.setConsensus(AAFrequency.calculate(sg
1042 .getSequences(ap.av.hiddenRepSequences), sg.getStartRes(), sg
1045 int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
1048 sg.cs.setThreshold(threshold, ap.av.getIgnoreGapsConsensus());
1050 SliderPanel.showPIDSlider();
1053 // remove PIDColouring
1055 sg.cs.setThreshold(0, ap.av.getIgnoreGapsConsensus());
1067 protected void userDefinedColour_actionPerformed(ActionEvent e)
1069 SequenceGroup sg = getGroup();
1071 if (e.getActionCommand().equals("User Defined..."))
1073 new UserDefinedColours(ap, sg);
1077 UserColourScheme udc = (UserColourScheme) UserDefinedColours
1078 .getUserColourSchemes().get(e.getActionCommand());
1091 protected void PIDColour_actionPerformed()
1093 SequenceGroup sg = getGroup();
1094 sg.cs = new PIDColourScheme();
1095 sg.cs.setConsensus(AAFrequency.calculate(sg
1096 .getSequences(ap.av.hiddenRepSequences), sg.getStartRes(), sg
1107 protected void BLOSUM62Colour_actionPerformed()
1109 SequenceGroup sg = getGroup();
1111 sg.cs = new Blosum62ColourScheme();
1113 sg.cs.setConsensus(AAFrequency.calculate(sg
1114 .getSequences(ap.av.hiddenRepSequences), sg.getStartRes(), sg
1126 protected void noColourmenuItem_actionPerformed()
1128 getGroup().cs = null;
1138 protected void conservationMenuItem_actionPerformed()
1140 SequenceGroup sg = getGroup();
1146 if (conservationMenuItem.isSelected())
1148 Conservation c = new Conservation("Group",
1149 ResidueProperties.propHash, 3, sg
1150 .getSequences(ap.av.hiddenRepSequences), sg
1151 .getStartRes(), sg.getEndRes() + 1);
1154 c.verdict(false, ap.av.ConsPercGaps);
1156 sg.cs.setConservation(c);
1158 SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
1159 SliderPanel.showConservationSlider();
1162 // remove ConservationColouring
1164 sg.cs.setConservation(null);
1170 public void annotationMenuItem_actionPerformed(ActionEvent actionEvent)
1172 SequenceGroup sg = getGroup();
1178 AnnotationColourGradient acg = new AnnotationColourGradient(sequence
1179 .getAnnotation()[0], null,
1180 AnnotationColourGradient.NO_THRESHOLD);
1182 acg.predefinedColours = true;
1194 protected void groupName_actionPerformed()
1197 SequenceGroup sg = getGroup();
1198 EditNameDialog dialog = new EditNameDialog(sg.getName(), sg
1199 .getDescription(), " Group Name ", "Group Description ",
1200 "Edit Group Name/Description");
1207 sg.setName(dialog.getName());
1208 sg.setDescription(dialog.getDescription());
1214 * @return DOCUMENT ME!
1216 SequenceGroup getGroup()
1218 SequenceGroup sg = ap.av.getSelectionGroup();
1219 // this method won't add a new group if it already exists
1222 ap.av.alignment.addGroup(sg);
1234 void sequenceName_actionPerformed()
1236 EditNameDialog dialog = new EditNameDialog(sequence.getName(), sequence
1237 .getDescription(), " Sequence Name ",
1238 "Sequence Description ", "Edit Sequence Name/Description");
1245 if (dialog.getName() != null)
1247 if (dialog.getName().indexOf(" ") > -1)
1249 JOptionPane.showMessageDialog(ap,
1250 "Spaces have been converted to \"_\"",
1251 "No spaces allowed in Sequence Name",
1252 JOptionPane.WARNING_MESSAGE);
1255 sequence.setName(dialog.getName().replace(' ', '_'));
1256 ap.paintAlignment(false);
1259 sequence.setDescription(dialog.getDescription());
1261 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1272 void unGroupMenuItem_actionPerformed()
1274 SequenceGroup sg = ap.av.getSelectionGroup();
1275 ap.av.alignment.deleteGroup(sg);
1276 ap.av.setSelectionGroup(null);
1286 protected void outline_actionPerformed()
1288 SequenceGroup sg = getGroup();
1289 Color col = JColorChooser.showDialog(this, "Select Outline Colour",
1294 sg.setOutlineColour(col);
1306 public void showBoxes_actionPerformed()
1308 getGroup().setDisplayBoxes(showBoxes.isSelected());
1318 public void showText_actionPerformed()
1320 getGroup().setDisplayText(showText.isSelected());
1330 public void showColourText_actionPerformed()
1332 getGroup().setColourText(showColourText.isSelected());
1336 public void showLink(String url)
1340 jalview.util.BrowserLauncher.openURL(url);
1341 } catch (Exception ex)
1344 .showInternalMessageDialog(
1346 "Unixers: Couldn't find default web browser."
1347 + "\nAdd the full path to your browser in Preferences.",
1348 "Web browser not found", JOptionPane.WARNING_MESSAGE);
1350 ex.printStackTrace();
1354 void hideSequences(boolean representGroup)
1356 SequenceGroup sg = ap.av.getSelectionGroup();
1357 if (sg == null || sg.getSize() < 1)
1359 ap.av.hideSequence(new SequenceI[]
1364 ap.av.setSelectionGroup(null);
1368 ap.av.hideRepSequences(sequence, sg);
1373 int gsize = sg.getSize();
1376 hseqs = new SequenceI[gsize];
1379 for (int i = 0; i < gsize; i++)
1381 hseqs[index++] = sg.getSequenceAt(i);
1384 ap.av.hideSequence(hseqs);
1385 ap.av.sendSelection();
1388 public void copy_actionPerformed()
1390 ap.alignFrame.copy_actionPerformed(null);
1393 public void cut_actionPerformed()
1395 ap.alignFrame.cut_actionPerformed(null);
1398 void changeCase(ActionEvent e)
1400 Object source = e.getSource();
1401 SequenceGroup sg = ap.av.getSelectionGroup();
1405 int[][] startEnd = ap.av.getVisibleRegionBoundaries(sg.getStartRes(),
1406 sg.getEndRes() + 1);
1411 if (source == toggle)
1413 description = "Toggle Case";
1414 caseChange = ChangeCaseCommand.TOGGLE_CASE;
1416 else if (source == upperCase)
1418 description = "To Upper Case";
1419 caseChange = ChangeCaseCommand.TO_UPPER;
1423 description = "To Lower Case";
1424 caseChange = ChangeCaseCommand.TO_LOWER;
1427 ChangeCaseCommand caseCommand = new ChangeCaseCommand(description, sg
1428 .getSequencesAsArray(ap.av.hiddenRepSequences), startEnd,
1431 ap.alignFrame.addHistoryItem(caseCommand);
1433 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1439 public void outputText_actionPerformed(ActionEvent e)
1441 CutAndPasteTransfer cap = new CutAndPasteTransfer();
1442 cap.setForInput(null);
1443 Desktop.addInternalFrame(cap, "Alignment output - "
1444 + e.getActionCommand(), 600, 500);
1446 String[] omitHidden = null;
1448 System.out.println("PROMPT USER HERE"); // TODO: decide if a prompt happens
1449 // or we simply trust the user wants
1450 // wysiwig behaviour
1451 SequenceGroup sg = ap.av.getSelectionGroup();
1452 ColumnSelection csel = new ColumnSelection(ap.av.getColumnSelection());
1453 omitHidden = ap.av.getViewAsString(true);
1454 Alignment oal = new Alignment(ap.av.getSequenceSelection());
1455 AlignmentAnnotation[] nala = ap.av.alignment.getAlignmentAnnotation();
1456 for (int i = 0; i < nala.length; i++)
1458 AlignmentAnnotation na = nala[i];
1459 oal.addAnnotation(na);
1461 cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(),
1462 oal, omitHidden, csel, sg));
1466 public void pdbFromFile_actionPerformed()
1468 jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(
1469 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
1470 chooser.setFileView(new jalview.io.JalviewFileView());
1471 chooser.setDialogTitle("Select a PDB file");
1472 chooser.setToolTipText("Load a PDB file");
1474 int value = chooser.showOpenDialog(null);
1476 if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
1478 PDBEntry entry = new PDBEntry();
1479 String choice = chooser.getSelectedFile().getPath();
1480 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
1483 MCview.PDBfile pdbfile = new MCview.PDBfile(choice,
1484 jalview.io.AppletFormatAdapter.FILE);
1486 if (pdbfile.id == null)
1488 String reply = JOptionPane
1489 .showInternalInputDialog(
1491 "Couldn't find a PDB id in the file supplied."
1492 + "Please enter an Id to identify this structure.",
1493 "No PDB Id in File", JOptionPane.QUESTION_MESSAGE);
1503 entry.setId(pdbfile.id);
1505 } catch (java.io.IOException ex)
1507 ex.printStackTrace();
1510 entry.setFile(choice);
1511 sequence.getDatasetSequence().addPDBId(entry);
1516 public void enterPDB_actionPerformed()
1518 String id = JOptionPane.showInternalInputDialog(Desktop.desktop,
1519 "Enter PDB Id", "Enter PDB Id", JOptionPane.QUESTION_MESSAGE);
1521 if (id != null && id.length() > 0)
1523 PDBEntry entry = new PDBEntry();
1524 entry.setId(id.toUpperCase());
1525 sequence.getDatasetSequence().addPDBId(entry);
1529 public void discoverPDB_actionPerformed()
1532 final SequenceI[] sequences = ((ap.av.selectionGroup == null) ? new Sequence[]
1534 : ap.av.selectionGroup.getSequencesInOrder(ap.av.alignment));
1535 Thread discpdb = new Thread(new Runnable()
1540 new jalview.ws.DBRefFetcher(sequences, ap.alignFrame)
1541 .fetchDBRefs(false);
1548 public void sequenceFeature_actionPerformed()
1550 SequenceGroup sg = ap.av.getSelectionGroup();
1556 int gSize = sg.getSize();
1557 SequenceI[] seqs = new SequenceI[gSize];
1558 SequenceFeature[] features = new SequenceFeature[gSize];
1560 for (int i = 0; i < gSize; i++)
1562 seqs[i] = sg.getSequenceAt(i).getDatasetSequence();
1563 int start = sg.getSequenceAt(i).findPosition(sg.getStartRes());
1564 int end = sg.findEndRes(sg.getSequenceAt(i));
1565 features[i] = new SequenceFeature(null, null, null, start, end,
1569 if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs,
1570 features, true, ap))
1572 ap.alignFrame.setShowSeqFeatures(true);
1573 ap.highlightSearchResults(null);
1577 public void textColour_actionPerformed()
1579 SequenceGroup sg = getGroup();
1582 new TextColourChooser().chooseColour(ap, sg);
1586 public void colourByStructure(String pdbid)
1588 Annotation[] anots = jalview.structure.StructureSelectionManager
1589 .getStructureSelectionManager().colourSequenceFromStructure(
1592 AlignmentAnnotation an = new AlignmentAnnotation("Structure",
1593 "Coloured by " + pdbid, anots);
1595 ap.av.alignment.addAnnotation(an);
1596 an.createSequenceMapping(sequence, 0, true);
1597 // an.adjustForAlignment();
1598 ap.av.alignment.setAnnotationIndex(an, 0);
1600 ap.adjustAnnotationHeight();
1602 sequence.addAlignmentAnnotation(an);
1606 public void editSequence_actionPerformed(ActionEvent actionEvent)
1608 SequenceGroup sg = ap.av.getSelectionGroup();
1612 if (sequence == null)
1613 sequence = (Sequence) sg.getSequenceAt(0);
1615 EditNameDialog dialog = new EditNameDialog(sequence
1616 .getSequenceAsString(sg.getStartRes(), sg.getEndRes() + 1),
1617 null, "Edit Sequence ", null, "Edit Sequence");
1621 EditCommand editCommand = new EditCommand("Edit Sequences",
1622 EditCommand.REPLACE, dialog.getName().replace(' ',
1623 ap.av.getGapCharacter()), sg
1624 .getSequencesAsArray(ap.av.hiddenRepSequences), sg
1625 .getStartRes(), sg.getEndRes() + 1, ap.av.alignment);
1627 ap.alignFrame.addHistoryItem(editCommand);
1629 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()