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();
438 for (int r = 0; r < dbr.length; r++)
440 if (id != null && dbr[r].getAccessionId().equals(id))
442 // suppress duplicate link creation for the bare sequence ID
443 // string with this link
446 // create Bare ID link for this RUL
447 String[] urls = urlLink.makeUrls(dbr[r].getAccessionId(),
451 for (int u = 0; u < urls.length; u += 2)
453 addshowLink(linkMenu, label + "|" + urls[u], urls[u + 1]);
460 // create Bare ID link for this RUL
461 String[] urls = urlLink.makeUrls(id, true);
464 for (int u = 0; u < urls.length; u += 2)
466 addshowLink(linkMenu, label, urls[u + 1]);
473 // Add a non-dynamic link
474 addshowLink(linkMenu, label, urlLink.getUrl_prefix());
477 if (sequence != null)
479 sequenceMenu.add(linkMenu);
489 * add a show URL menu item to the given linkMenu
497 private void addshowLink(JMenu linkMenu, String label, final String url)
499 JMenuItem item = new JMenuItem(label);
500 item.setToolTipText("open URL: " + url);
501 item.addActionListener(new java.awt.event.ActionListener()
503 public void actionPerformed(ActionEvent e)
505 new Thread(new Runnable()
526 private void jbInit() throws Exception
528 groupMenu.setText("Group");
529 groupMenu.setText("Selection");
530 groupName.setText("Name");
531 groupName.addActionListener(new java.awt.event.ActionListener()
533 public void actionPerformed(ActionEvent e)
535 groupName_actionPerformed();
538 sequenceMenu.setText("Sequence");
539 sequenceName.setText("Edit Name/Description");
540 sequenceName.addActionListener(new java.awt.event.ActionListener()
542 public void actionPerformed(ActionEvent e)
544 sequenceName_actionPerformed();
547 PIDColour.setFocusPainted(false);
548 unGroupMenuItem.setText("Remove Group");
549 unGroupMenuItem.addActionListener(new java.awt.event.ActionListener()
551 public void actionPerformed(ActionEvent e)
553 unGroupMenuItem_actionPerformed();
557 outline.setText("Border colour");
558 outline.addActionListener(new java.awt.event.ActionListener()
560 public void actionPerformed(ActionEvent e)
562 outline_actionPerformed();
565 nucleotideMenuItem.setText("Nucleotide");
566 nucleotideMenuItem.addActionListener(new ActionListener()
568 public void actionPerformed(ActionEvent e)
570 nucleotideMenuItem_actionPerformed();
573 colourMenu.setText("Group Colour");
574 showBoxes.setText("Boxes");
575 showBoxes.setState(true);
576 showBoxes.addActionListener(new ActionListener()
578 public void actionPerformed(ActionEvent e)
580 showBoxes_actionPerformed();
583 showText.setText("Text");
584 showText.setState(true);
585 showText.addActionListener(new ActionListener()
587 public void actionPerformed(ActionEvent e)
589 showText_actionPerformed();
592 showColourText.setText("Colour Text");
593 showColourText.addActionListener(new ActionListener()
595 public void actionPerformed(ActionEvent e)
597 showColourText_actionPerformed();
600 editMenu.setText("Edit");
602 cut.addActionListener(new ActionListener()
604 public void actionPerformed(ActionEvent e)
606 cut_actionPerformed();
609 upperCase.setText("To Upper Case");
610 upperCase.addActionListener(new ActionListener()
612 public void actionPerformed(ActionEvent e)
617 copy.setText("Copy");
618 copy.addActionListener(new ActionListener()
620 public void actionPerformed(ActionEvent e)
622 copy_actionPerformed();
625 lowerCase.setText("To Lower Case");
626 lowerCase.addActionListener(new ActionListener()
628 public void actionPerformed(ActionEvent e)
633 toggle.setText("Toggle Case");
634 toggle.addActionListener(new ActionListener()
636 public void actionPerformed(ActionEvent e)
641 pdbMenu.setText("Associate Structure with Sequence");
642 pdbFromFile.setText("From File");
643 pdbFromFile.addActionListener(new ActionListener()
645 public void actionPerformed(ActionEvent e)
647 pdbFromFile_actionPerformed();
650 enterPDB.setText("Enter PDB Id");
651 enterPDB.addActionListener(new ActionListener()
653 public void actionPerformed(ActionEvent e)
655 enterPDB_actionPerformed();
658 discoverPDB.setText("Discover PDB ids");
659 discoverPDB.addActionListener(new ActionListener()
661 public void actionPerformed(ActionEvent e)
663 discoverPDB_actionPerformed();
666 outputMenu.setText("Output to Textbox...");
667 sequenceFeature.setText("Create Sequence Feature");
668 sequenceFeature.addActionListener(new ActionListener()
670 public void actionPerformed(ActionEvent e)
672 sequenceFeature_actionPerformed();
675 textColour.setText("Text Colour");
676 textColour.addActionListener(new ActionListener()
678 public void actionPerformed(ActionEvent e)
680 textColour_actionPerformed();
683 jMenu1.setText("Group");
684 structureMenu.setText("Structure");
685 viewStructureMenu.setText("View Structure");
686 // colStructureMenu.setText("Colour By Structure");
687 editSequence.setText("Edit Sequence...");
688 editSequence.addActionListener(new ActionListener()
690 public void actionPerformed(ActionEvent actionEvent)
692 editSequence_actionPerformed(actionEvent);
696 * annotationMenuItem.setText("By Annotation");
697 * annotationMenuItem.addActionListener(new ActionListener() { public void
698 * actionPerformed(ActionEvent actionEvent) {
699 * annotationMenuItem_actionPerformed(actionEvent); } });
705 this.add(structureMenu);
706 groupMenu.add(editMenu);
707 groupMenu.add(outputMenu);
708 groupMenu.add(sequenceFeature);
709 groupMenu.add(jMenu1);
710 sequenceMenu.add(sequenceName);
711 colourMenu.add(textColour);
712 colourMenu.add(noColourmenuItem);
713 colourMenu.add(clustalColour);
714 colourMenu.add(BLOSUM62Colour);
715 colourMenu.add(PIDColour);
716 colourMenu.add(zappoColour);
717 colourMenu.add(taylorColour);
718 colourMenu.add(hydrophobicityColour);
719 colourMenu.add(helixColour);
720 colourMenu.add(strandColour);
721 colourMenu.add(turnColour);
722 colourMenu.add(buriedColour);
723 colourMenu.add(nucleotideMenuItem);
724 colourMenu.add(userDefinedColour);
726 if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null)
728 java.util.Enumeration userColours = jalview.gui.UserDefinedColours
729 .getUserColourSchemes().keys();
731 while (userColours.hasMoreElements())
733 JMenuItem item = new JMenuItem(userColours.nextElement().toString());
734 item.addActionListener(new ActionListener()
736 public void actionPerformed(ActionEvent evt)
738 userDefinedColour_actionPerformed(evt);
741 colourMenu.add(item);
745 colourMenu.addSeparator();
746 colourMenu.add(abovePIDColour);
747 colourMenu.add(conservationMenuItem);
748 // colourMenu.add(annotationMenuItem);
751 editMenu.add(editSequence);
752 editMenu.add(upperCase);
753 editMenu.add(lowerCase);
754 editMenu.add(toggle);
755 pdbMenu.add(pdbFromFile);
756 pdbMenu.add(enterPDB);
757 pdbMenu.add(discoverPDB);
758 jMenu1.add(groupName);
759 jMenu1.add(unGroupMenuItem);
760 jMenu1.add(colourMenu);
761 jMenu1.add(showBoxes);
762 jMenu1.add(showText);
763 jMenu1.add(showColourText);
765 structureMenu.add(pdbMenu);
766 structureMenu.add(viewStructureMenu);
767 // structureMenu.add(colStructureMenu);
768 noColourmenuItem.setText("None");
769 noColourmenuItem.addActionListener(new java.awt.event.ActionListener()
771 public void actionPerformed(ActionEvent e)
773 noColourmenuItem_actionPerformed();
777 clustalColour.setText("Clustalx colours");
778 clustalColour.addActionListener(new java.awt.event.ActionListener()
780 public void actionPerformed(ActionEvent e)
782 clustalColour_actionPerformed();
785 zappoColour.setText("Zappo");
786 zappoColour.addActionListener(new java.awt.event.ActionListener()
788 public void actionPerformed(ActionEvent e)
790 zappoColour_actionPerformed();
793 taylorColour.setText("Taylor");
794 taylorColour.addActionListener(new java.awt.event.ActionListener()
796 public void actionPerformed(ActionEvent e)
798 taylorColour_actionPerformed();
801 hydrophobicityColour.setText("Hydrophobicity");
803 .addActionListener(new java.awt.event.ActionListener()
805 public void actionPerformed(ActionEvent e)
807 hydrophobicityColour_actionPerformed();
810 helixColour.setText("Helix propensity");
811 helixColour.addActionListener(new java.awt.event.ActionListener()
813 public void actionPerformed(ActionEvent e)
815 helixColour_actionPerformed();
818 strandColour.setText("Strand propensity");
819 strandColour.addActionListener(new java.awt.event.ActionListener()
821 public void actionPerformed(ActionEvent e)
823 strandColour_actionPerformed();
826 turnColour.setText("Turn propensity");
827 turnColour.addActionListener(new java.awt.event.ActionListener()
829 public void actionPerformed(ActionEvent e)
831 turnColour_actionPerformed();
834 buriedColour.setText("Buried Index");
835 buriedColour.addActionListener(new java.awt.event.ActionListener()
837 public void actionPerformed(ActionEvent e)
839 buriedColour_actionPerformed();
842 abovePIDColour.setText("Above % Identity");
843 abovePIDColour.addActionListener(new java.awt.event.ActionListener()
845 public void actionPerformed(ActionEvent e)
847 abovePIDColour_actionPerformed();
850 userDefinedColour.setText("User Defined...");
851 userDefinedColour.addActionListener(new java.awt.event.ActionListener()
853 public void actionPerformed(ActionEvent e)
855 userDefinedColour_actionPerformed(e);
858 PIDColour.setText("Percentage Identity");
859 PIDColour.addActionListener(new java.awt.event.ActionListener()
861 public void actionPerformed(ActionEvent e)
863 PIDColour_actionPerformed();
866 BLOSUM62Colour.setText("BLOSUM62");
867 BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener()
869 public void actionPerformed(ActionEvent e)
871 BLOSUM62Colour_actionPerformed();
874 conservationMenuItem.setText("Conservation");
876 .addActionListener(new java.awt.event.ActionListener()
878 public void actionPerformed(ActionEvent e)
880 conservationMenuItem_actionPerformed();
890 ap.paintAlignment(true);
892 PaintRefresher.Refresh(this, ap.av.getSequenceSetId());
901 protected void clustalColour_actionPerformed()
903 SequenceGroup sg = getGroup();
904 sg.cs = new ClustalxColourScheme(sg
905 .getSequences(ap.av.hiddenRepSequences), ap.av.alignment
916 protected void zappoColour_actionPerformed()
918 getGroup().cs = new ZappoColourScheme();
928 protected void taylorColour_actionPerformed()
930 getGroup().cs = new TaylorColourScheme();
940 protected void hydrophobicityColour_actionPerformed()
942 getGroup().cs = new HydrophobicColourScheme();
952 protected void helixColour_actionPerformed()
954 getGroup().cs = new HelixColourScheme();
964 protected void strandColour_actionPerformed()
966 getGroup().cs = new StrandColourScheme();
976 protected void turnColour_actionPerformed()
978 getGroup().cs = new TurnColourScheme();
988 protected void buriedColour_actionPerformed()
990 getGroup().cs = new BuriedColourScheme();
1000 public void nucleotideMenuItem_actionPerformed()
1002 getGroup().cs = new NucleotideColourScheme();
1012 protected void abovePIDColour_actionPerformed()
1014 SequenceGroup sg = getGroup();
1020 if (abovePIDColour.isSelected())
1022 sg.cs.setConsensus(AAFrequency.calculate(sg
1023 .getSequences(ap.av.hiddenRepSequences), sg.getStartRes(), sg
1026 int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
1029 sg.cs.setThreshold(threshold, ap.av.getIgnoreGapsConsensus());
1031 SliderPanel.showPIDSlider();
1034 // remove PIDColouring
1036 sg.cs.setThreshold(0, ap.av.getIgnoreGapsConsensus());
1048 protected void userDefinedColour_actionPerformed(ActionEvent e)
1050 SequenceGroup sg = getGroup();
1052 if (e.getActionCommand().equals("User Defined..."))
1054 new UserDefinedColours(ap, sg);
1058 UserColourScheme udc = (UserColourScheme) UserDefinedColours
1059 .getUserColourSchemes().get(e.getActionCommand());
1072 protected void PIDColour_actionPerformed()
1074 SequenceGroup sg = getGroup();
1075 sg.cs = new PIDColourScheme();
1076 sg.cs.setConsensus(AAFrequency.calculate(sg
1077 .getSequences(ap.av.hiddenRepSequences), sg.getStartRes(), sg
1088 protected void BLOSUM62Colour_actionPerformed()
1090 SequenceGroup sg = getGroup();
1092 sg.cs = new Blosum62ColourScheme();
1094 sg.cs.setConsensus(AAFrequency.calculate(sg
1095 .getSequences(ap.av.hiddenRepSequences), sg.getStartRes(), sg
1107 protected void noColourmenuItem_actionPerformed()
1109 getGroup().cs = null;
1119 protected void conservationMenuItem_actionPerformed()
1121 SequenceGroup sg = getGroup();
1127 if (conservationMenuItem.isSelected())
1129 Conservation c = new Conservation("Group",
1130 ResidueProperties.propHash, 3, sg
1131 .getSequences(ap.av.hiddenRepSequences), sg
1132 .getStartRes(), sg.getEndRes() + 1);
1135 c.verdict(false, ap.av.ConsPercGaps);
1137 sg.cs.setConservation(c);
1139 SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
1140 SliderPanel.showConservationSlider();
1143 // remove ConservationColouring
1145 sg.cs.setConservation(null);
1151 public void annotationMenuItem_actionPerformed(ActionEvent actionEvent)
1153 SequenceGroup sg = getGroup();
1159 AnnotationColourGradient acg = new AnnotationColourGradient(sequence
1160 .getAnnotation()[0], null,
1161 AnnotationColourGradient.NO_THRESHOLD);
1163 acg.predefinedColours = true;
1175 protected void groupName_actionPerformed()
1178 SequenceGroup sg = getGroup();
1179 EditNameDialog dialog = new EditNameDialog(sg.getName(), sg
1180 .getDescription(), " Group Name ", "Group Description ",
1181 "Edit Group Name/Description");
1188 sg.setName(dialog.getName());
1189 sg.setDescription(dialog.getDescription());
1195 * @return DOCUMENT ME!
1197 SequenceGroup getGroup()
1199 SequenceGroup sg = ap.av.getSelectionGroup();
1200 // this method won't add a new group if it already exists
1203 ap.av.alignment.addGroup(sg);
1215 void sequenceName_actionPerformed()
1217 EditNameDialog dialog = new EditNameDialog(sequence.getName(), sequence
1218 .getDescription(), " Sequence Name ",
1219 "Sequence Description ", "Edit Sequence Name/Description");
1226 if (dialog.getName() != null)
1228 if (dialog.getName().indexOf(" ") > -1)
1230 JOptionPane.showMessageDialog(ap,
1231 "Spaces have been converted to \"_\"",
1232 "No spaces allowed in Sequence Name",
1233 JOptionPane.WARNING_MESSAGE);
1236 sequence.setName(dialog.getName().replace(' ', '_'));
1237 ap.paintAlignment(false);
1240 sequence.setDescription(dialog.getDescription());
1242 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1253 void unGroupMenuItem_actionPerformed()
1255 SequenceGroup sg = ap.av.getSelectionGroup();
1256 ap.av.alignment.deleteGroup(sg);
1257 ap.av.setSelectionGroup(null);
1267 protected void outline_actionPerformed()
1269 SequenceGroup sg = getGroup();
1270 Color col = JColorChooser.showDialog(this, "Select Outline Colour",
1275 sg.setOutlineColour(col);
1287 public void showBoxes_actionPerformed()
1289 getGroup().setDisplayBoxes(showBoxes.isSelected());
1299 public void showText_actionPerformed()
1301 getGroup().setDisplayText(showText.isSelected());
1311 public void showColourText_actionPerformed()
1313 getGroup().setColourText(showColourText.isSelected());
1317 public void showLink(String url)
1321 jalview.util.BrowserLauncher.openURL(url);
1322 } catch (Exception ex)
1325 .showInternalMessageDialog(
1327 "Unixers: Couldn't find default web browser."
1328 + "\nAdd the full path to your browser in Preferences.",
1329 "Web browser not found", JOptionPane.WARNING_MESSAGE);
1331 ex.printStackTrace();
1335 void hideSequences(boolean representGroup)
1337 SequenceGroup sg = ap.av.getSelectionGroup();
1338 if (sg == null || sg.getSize() < 1)
1340 ap.av.hideSequence(new SequenceI[]
1345 ap.av.setSelectionGroup(null);
1349 ap.av.hideRepSequences(sequence, sg);
1354 int gsize = sg.getSize();
1357 hseqs = new SequenceI[gsize];
1360 for (int i = 0; i < gsize; i++)
1362 hseqs[index++] = sg.getSequenceAt(i);
1365 ap.av.hideSequence(hseqs);
1368 public void copy_actionPerformed()
1370 ap.alignFrame.copy_actionPerformed(null);
1373 public void cut_actionPerformed()
1375 ap.alignFrame.cut_actionPerformed(null);
1378 void changeCase(ActionEvent e)
1380 Object source = e.getSource();
1381 SequenceGroup sg = ap.av.getSelectionGroup();
1385 int[][] startEnd = ap.av.getVisibleRegionBoundaries(sg.getStartRes(),
1386 sg.getEndRes() + 1);
1391 if (source == toggle)
1393 description = "Toggle Case";
1394 caseChange = ChangeCaseCommand.TOGGLE_CASE;
1396 else if (source == upperCase)
1398 description = "To Upper Case";
1399 caseChange = ChangeCaseCommand.TO_UPPER;
1403 description = "To Lower Case";
1404 caseChange = ChangeCaseCommand.TO_LOWER;
1407 ChangeCaseCommand caseCommand = new ChangeCaseCommand(description, sg
1408 .getSequencesAsArray(ap.av.hiddenRepSequences), startEnd,
1411 ap.alignFrame.addHistoryItem(caseCommand);
1413 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1419 public void outputText_actionPerformed(ActionEvent e)
1421 CutAndPasteTransfer cap = new CutAndPasteTransfer();
1422 cap.setForInput(null);
1423 Desktop.addInternalFrame(cap, "Alignment output - "
1424 + e.getActionCommand(), 600, 500);
1426 String[] omitHidden = null;
1428 System.out.println("PROMPT USER HERE"); // TODO: decide if a prompt happens
1429 // or we simply trust the user wants
1430 // wysiwig behaviour
1431 SequenceGroup sg = ap.av.getSelectionGroup();
1432 ColumnSelection csel = new ColumnSelection(ap.av.getColumnSelection());
1433 omitHidden = ap.av.getViewAsString(true);
1434 Alignment oal = new Alignment(ap.av.getSequenceSelection());
1435 AlignmentAnnotation[] nala = ap.av.alignment.getAlignmentAnnotation();
1436 for (int i = 0; i < nala.length; i++)
1438 AlignmentAnnotation na = nala[i];
1439 oal.addAnnotation(na);
1441 cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(),
1442 oal, omitHidden, csel, sg));
1446 public void pdbFromFile_actionPerformed()
1448 jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(
1449 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
1450 chooser.setFileView(new jalview.io.JalviewFileView());
1451 chooser.setDialogTitle("Select a PDB file");
1452 chooser.setToolTipText("Load a PDB file");
1454 int value = chooser.showOpenDialog(null);
1456 if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
1458 PDBEntry entry = new PDBEntry();
1459 String choice = chooser.getSelectedFile().getPath();
1460 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
1463 MCview.PDBfile pdbfile = new MCview.PDBfile(choice,
1464 jalview.io.AppletFormatAdapter.FILE);
1466 if (pdbfile.id == null)
1468 String reply = JOptionPane
1469 .showInternalInputDialog(
1471 "Couldn't find a PDB id in the file supplied."
1472 + "Please enter an Id to identify this structure.",
1473 "No PDB Id in File", JOptionPane.QUESTION_MESSAGE);
1483 entry.setId(pdbfile.id);
1485 } catch (java.io.IOException ex)
1487 ex.printStackTrace();
1490 entry.setFile(choice);
1491 sequence.getDatasetSequence().addPDBId(entry);
1496 public void enterPDB_actionPerformed()
1498 String id = JOptionPane.showInternalInputDialog(Desktop.desktop,
1499 "Enter PDB Id", "Enter PDB Id", JOptionPane.QUESTION_MESSAGE);
1501 if (id != null && id.length() > 0)
1503 PDBEntry entry = new PDBEntry();
1504 entry.setId(id.toUpperCase());
1505 sequence.getDatasetSequence().addPDBId(entry);
1509 public void discoverPDB_actionPerformed()
1512 final SequenceI[] sequences = ((ap.av.selectionGroup == null) ? new Sequence[]
1514 : ap.av.selectionGroup.getSequencesInOrder(ap.av.alignment));
1515 Thread discpdb = new Thread(new Runnable()
1520 new jalview.ws.DBRefFetcher(sequences, ap.alignFrame)
1521 .fetchDBRefs(false);
1528 public void sequenceFeature_actionPerformed()
1530 SequenceGroup sg = ap.av.getSelectionGroup();
1536 int gSize = sg.getSize();
1537 SequenceI[] seqs = new SequenceI[gSize];
1538 SequenceFeature[] features = new SequenceFeature[gSize];
1540 for (int i = 0; i < gSize; i++)
1542 seqs[i] = sg.getSequenceAt(i).getDatasetSequence();
1543 int start = sg.getSequenceAt(i).findPosition(sg.getStartRes());
1544 int end = sg.findEndRes(sg.getSequenceAt(i));
1545 features[i] = new SequenceFeature(null, null, null, start, end,
1549 if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs,
1550 features, true, ap))
1552 ap.alignFrame.showSeqFeatures.setSelected(true);
1553 ap.av.setShowSequenceFeatures(true);
1554 ap.highlightSearchResults(null);
1558 public void textColour_actionPerformed()
1560 SequenceGroup sg = getGroup();
1563 new TextColourChooser().chooseColour(ap, sg);
1567 public void colourByStructure(String pdbid)
1569 Annotation[] anots = jalview.structure.StructureSelectionManager
1570 .getStructureSelectionManager().colourSequenceFromStructure(
1573 AlignmentAnnotation an = new AlignmentAnnotation("Structure",
1574 "Coloured by " + pdbid, anots);
1576 ap.av.alignment.addAnnotation(an);
1577 an.createSequenceMapping(sequence, 0, true);
1578 // an.adjustForAlignment();
1579 ap.av.alignment.setAnnotationIndex(an, 0);
1581 ap.adjustAnnotationHeight();
1583 sequence.addAlignmentAnnotation(an);
1587 public void editSequence_actionPerformed(ActionEvent actionEvent)
1589 SequenceGroup sg = ap.av.getSelectionGroup();
1593 if (sequence == null)
1594 sequence = (Sequence) sg.getSequenceAt(0);
1596 EditNameDialog dialog = new EditNameDialog(sequence
1597 .getSequenceAsString(sg.getStartRes(), sg.getEndRes() + 1),
1598 null, "Edit Sequence ", null, "Edit Sequence");
1602 EditCommand editCommand = new EditCommand("Edit Sequences",
1603 EditCommand.REPLACE, dialog.getName().replace(' ',
1604 ap.av.getGapCharacter()), sg
1605 .getSequencesAsArray(ap.av.hiddenRepSequences), sg
1606 .getStartRes(), sg.getEndRes() + 1, ap.av.alignment);
1608 ap.alignFrame.addHistoryItem(editCommand);
1610 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()