2 * Jalview - A Sequence Alignment Editor and Viewer
3 * Copyright (C) 2007 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.*;
40 public class PopupMenu
43 JMenu groupMenu = new JMenu();
44 JMenuItem groupName = new JMenuItem();
45 protected JRadioButtonMenuItem clustalColour = new JRadioButtonMenuItem();
46 protected JRadioButtonMenuItem zappoColour = new JRadioButtonMenuItem();
47 protected JRadioButtonMenuItem taylorColour = new JRadioButtonMenuItem();
48 protected JRadioButtonMenuItem hydrophobicityColour = new
49 JRadioButtonMenuItem();
50 protected JRadioButtonMenuItem helixColour = new JRadioButtonMenuItem();
51 protected JRadioButtonMenuItem strandColour = new JRadioButtonMenuItem();
52 protected JRadioButtonMenuItem turnColour = new JRadioButtonMenuItem();
53 protected JRadioButtonMenuItem buriedColour = new JRadioButtonMenuItem();
54 protected JCheckBoxMenuItem abovePIDColour = new JCheckBoxMenuItem();
55 protected JRadioButtonMenuItem userDefinedColour = new JRadioButtonMenuItem();
56 protected JRadioButtonMenuItem PIDColour = new JRadioButtonMenuItem();
57 protected JRadioButtonMenuItem BLOSUM62Colour = new JRadioButtonMenuItem();
58 JRadioButtonMenuItem noColourmenuItem = new JRadioButtonMenuItem();
59 protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem();
61 JMenu sequenceMenu = new JMenu();
62 JMenuItem sequenceName = new JMenuItem();
64 JMenuItem unGroupMenuItem = new JMenuItem();
65 JMenuItem outline = new JMenuItem();
66 JRadioButtonMenuItem nucleotideMenuItem = new JRadioButtonMenuItem();
67 JMenu colourMenu = new JMenu();
68 JCheckBoxMenuItem showBoxes = new JCheckBoxMenuItem();
69 JCheckBoxMenuItem showText = new JCheckBoxMenuItem();
70 JCheckBoxMenuItem showColourText = new JCheckBoxMenuItem();
71 JMenu editMenu = new JMenu();
72 JMenuItem cut = new JMenuItem();
73 JMenuItem copy = new JMenuItem();
74 JMenuItem upperCase = new JMenuItem();
75 JMenuItem lowerCase = new JMenuItem();
76 JMenuItem toggle = new JMenuItem();
77 JMenu pdbMenu = new JMenu();
78 JMenuItem pdbFromFile = new JMenuItem();
79 JMenuItem enterPDB = new JMenuItem();
80 JMenuItem discoverPDB = new JMenuItem();
81 JMenu outputMenu = new JMenu();
82 JMenuItem sequenceFeature = new JMenuItem();
83 JMenuItem textColour = new JMenuItem();
84 JMenu jMenu1 = new JMenu();
85 JMenu structureMenu = new JMenu();
86 JMenu viewStructureMenu = new JMenu();
87 // JMenu colStructureMenu = new JMenu();
88 JMenuItem editSequence = new JMenuItem();
89 // JMenuItem annotationMenuItem = new JMenuItem();
92 * Creates a new PopupMenu object.
94 * @param ap DOCUMENT ME!
95 * @param seq DOCUMENT ME!
97 public PopupMenu(final AlignmentPanel ap, Sequence seq, Vector links)
99 ///////////////////////////////////////////////////////////
100 // If this is activated from the sequence panel, the user may want to
101 // edit or annotate a particular residue. Therefore display the residue menu
103 // If from the IDPanel, we must display the sequence menu
104 //////////////////////////////////////////////////////////
108 ButtonGroup colours = new ButtonGroup();
109 colours.add(noColourmenuItem);
110 colours.add(clustalColour);
111 colours.add(zappoColour);
112 colours.add(taylorColour);
113 colours.add(hydrophobicityColour);
114 colours.add(helixColour);
115 colours.add(strandColour);
116 colours.add(turnColour);
117 colours.add(buriedColour);
118 colours.add(abovePIDColour);
119 colours.add(userDefinedColour);
120 colours.add(PIDColour);
121 colours.add(BLOSUM62Colour);
123 for (int i = 0; i < jalview.io.FormatAdapter.WRITEABLE_FORMATS.length; i++)
125 JMenuItem item = new JMenuItem(jalview.io.FormatAdapter.WRITEABLE_FORMATS[
128 item.addActionListener(new java.awt.event.ActionListener()
130 public void actionPerformed(ActionEvent e)
132 outputText_actionPerformed(e);
136 outputMenu.add(item);
150 sequenceMenu.setText(sequence.getName());
153 if (seq.getDatasetSequence().getPDBId() != null
154 && seq.getDatasetSequence().getPDBId().size()>0)
156 java.util.Enumeration e = seq.getDatasetSequence().getPDBId().
159 while (e.hasMoreElements())
161 final PDBEntry pdb = (PDBEntry) e.nextElement();
163 menuItem = new JMenuItem();
164 menuItem.setText(pdb.getId());
165 menuItem.addActionListener(new java.awt.event.ActionListener()
167 public void actionPerformed(ActionEvent e)
169 Vector seqs = new Vector();
170 for (int i = 0; i < ap.av.alignment.getHeight(); i++)
172 Vector pdbs = ap.av.alignment.getSequenceAt(i).getDatasetSequence().getPDBId();
176 for(int p=0; p<pdbs.size(); p++)
178 PDBEntry p1 = (PDBEntry)pdbs.elementAt(p);
179 if(p1.getId().equals(pdb.getId()))
181 if (!seqs.contains(ap.av.alignment.getSequenceAt(i)))
182 seqs.addElement(ap.av.alignment.getSequenceAt(i));
189 SequenceI [] seqs2 = new SequenceI[seqs.size()];
192 new AppJmol(pdb, seqs2, null, ap);
193 // new PDBViewer(pdb, seqs2, null, ap, AppletFormatAdapter.FILE);
196 viewStructureMenu.add(menuItem);
198 /* menuItem = new JMenuItem();
199 menuItem.setText(pdb.getId());
200 menuItem.addActionListener(new java.awt.event.ActionListener()
202 public void actionPerformed(ActionEvent e)
204 colourByStructure(pdb.getId());
207 colStructureMenu.add(menuItem);*/
212 structureMenu.remove(viewStructureMenu);
213 // structureMenu.remove(colStructureMenu);
216 menuItem = new JMenuItem("Hide Sequences");
217 menuItem.addActionListener(new java.awt.event.ActionListener()
219 public void actionPerformed(ActionEvent e)
221 hideSequences(false);
226 if (ap.av.getSelectionGroup() != null
227 && ap.av.getSelectionGroup().getSize() > 1)
229 menuItem = new JMenuItem("Represent Group with " + seq.getName());
230 menuItem.addActionListener(new java.awt.event.ActionListener()
232 public void actionPerformed(ActionEvent e)
237 sequenceMenu.add(menuItem);
240 if (ap.av.hasHiddenRows)
242 final int index = ap.av.alignment.findIndex(seq);
244 if (ap.av.adjustForHiddenSeqs(index) -
245 ap.av.adjustForHiddenSeqs(index - 1) > 1)
247 menuItem = new JMenuItem("Reveal Sequences");
248 menuItem.addActionListener(new ActionListener()
250 public void actionPerformed(ActionEvent e)
252 ap.av.showSequence(index);
253 if (ap.overviewPanel != null)
255 ap.overviewPanel.updateOverviewImage();
262 menuItem = new JMenuItem("Reveal All");
263 menuItem.addActionListener(new ActionListener()
265 public void actionPerformed(ActionEvent e)
267 ap.av.showAllHiddenSeqs();
268 if (ap.overviewPanel != null)
270 ap.overviewPanel.updateOverviewImage();
280 SequenceGroup sg = ap.av.getSelectionGroup();
284 groupName.setText(sg.getName());
286 if (sg.cs instanceof ZappoColourScheme)
288 zappoColour.setSelected(true);
290 else if (sg.cs instanceof TaylorColourScheme)
292 taylorColour.setSelected(true);
294 else if (sg.cs instanceof PIDColourScheme)
296 PIDColour.setSelected(true);
298 else if (sg.cs instanceof Blosum62ColourScheme)
300 BLOSUM62Colour.setSelected(true);
302 else if (sg.cs instanceof UserColourScheme)
304 userDefinedColour.setSelected(true);
306 else if (sg.cs instanceof HydrophobicColourScheme)
308 hydrophobicityColour.setSelected(true);
310 else if (sg.cs instanceof HelixColourScheme)
312 helixColour.setSelected(true);
314 else if (sg.cs instanceof StrandColourScheme)
316 strandColour.setSelected(true);
318 else if (sg.cs instanceof TurnColourScheme)
320 turnColour.setSelected(true);
322 else if (sg.cs instanceof BuriedColourScheme)
324 buriedColour.setSelected(true);
326 else if (sg.cs instanceof ClustalxColourScheme)
328 clustalColour.setSelected(true);
332 noColourmenuItem.setSelected(true);
335 if (sg.cs != null && sg.cs.conservationApplied())
337 conservationMenuItem.setSelected(true);
340 showText.setSelected(sg.getDisplayText());
341 showColourText.setSelected(sg.getColourText());
342 showBoxes.setSelected(sg.getDisplayBoxes());
346 groupMenu.setVisible(false);
347 editMenu.setVisible(false);
350 if (!ap.av.alignment.getGroups().contains(sg))
352 unGroupMenuItem.setVisible(false);
357 sequenceMenu.setVisible(false);
358 structureMenu.setVisible(false);
361 if (links != null && links.size() > 0)
363 JMenu linkMenu = new JMenu("Link");
365 for (int i = 0; i < links.size(); i++)
367 String link = links.elementAt(i).toString();
368 final String label = link.substring(0, link.indexOf("|"));
369 item = new JMenuItem(label);
372 if (link.indexOf("$SEQUENCE_ID$") > -1)
374 String id = seq.getName();
375 if (id.indexOf("|") > -1)
377 id = id.substring(id.lastIndexOf("|") + 1);
380 url = link.substring(link.indexOf("|") + 1,
381 link.indexOf("$SEQUENCE_ID$"))
383 link.substring(link.indexOf("$SEQUENCE_ID$") + 13);
387 url = link.substring(link.lastIndexOf("|") + 1);
390 item.addActionListener(new java.awt.event.ActionListener()
392 public void actionPerformed(ActionEvent e)
400 if (sequence != null)
402 sequenceMenu.add(linkMenu);
414 * @throws Exception DOCUMENT ME!
416 private void jbInit()
419 groupMenu.setText("Group");
420 groupMenu.setText("Selection");
421 groupName.setText("Name");
422 groupName.addActionListener(new java.awt.event.ActionListener()
424 public void actionPerformed(ActionEvent e)
426 groupName_actionPerformed();
429 sequenceMenu.setText("Sequence");
430 sequenceName.setText("Edit Name/Description");
431 sequenceName.addActionListener(new java.awt.event.ActionListener()
433 public void actionPerformed(ActionEvent e)
435 sequenceName_actionPerformed();
438 PIDColour.setFocusPainted(false);
439 unGroupMenuItem.setText("Remove Group");
440 unGroupMenuItem.addActionListener(new java.awt.event.ActionListener()
442 public void actionPerformed(ActionEvent e)
444 unGroupMenuItem_actionPerformed();
448 outline.setText("Border colour");
449 outline.addActionListener(new java.awt.event.ActionListener()
451 public void actionPerformed(ActionEvent e)
453 outline_actionPerformed();
456 nucleotideMenuItem.setText("Nucleotide");
457 nucleotideMenuItem.addActionListener(new ActionListener()
459 public void actionPerformed(ActionEvent e)
461 nucleotideMenuItem_actionPerformed();
464 colourMenu.setText("Group Colour");
465 showBoxes.setText("Boxes");
466 showBoxes.setState(true);
467 showBoxes.addActionListener(new ActionListener()
469 public void actionPerformed(ActionEvent e)
471 showBoxes_actionPerformed();
474 showText.setText("Text");
475 showText.setState(true);
476 showText.addActionListener(new ActionListener()
478 public void actionPerformed(ActionEvent e)
480 showText_actionPerformed();
483 showColourText.setText("Colour Text");
484 showColourText.addActionListener(new ActionListener()
486 public void actionPerformed(ActionEvent e)
488 showColourText_actionPerformed();
491 editMenu.setText("Edit");
493 cut.addActionListener(new ActionListener()
495 public void actionPerformed(ActionEvent e)
497 cut_actionPerformed();
500 upperCase.setText("To Upper Case");
501 upperCase.addActionListener(new ActionListener()
503 public void actionPerformed(ActionEvent e)
508 copy.setText("Copy");
509 copy.addActionListener(new ActionListener()
511 public void actionPerformed(ActionEvent e)
513 copy_actionPerformed();
516 lowerCase.setText("To Lower Case");
517 lowerCase.addActionListener(new ActionListener()
519 public void actionPerformed(ActionEvent e)
524 toggle.setText("Toggle Case");
525 toggle.addActionListener(new ActionListener()
527 public void actionPerformed(ActionEvent e)
532 pdbMenu.setText("Associate Structure with Sequence");
533 pdbFromFile.setText("From File");
534 pdbFromFile.addActionListener(new ActionListener()
536 public void actionPerformed(ActionEvent e)
538 pdbFromFile_actionPerformed();
541 enterPDB.setText("Enter PDB Id");
542 enterPDB.addActionListener(new ActionListener()
544 public void actionPerformed(ActionEvent e)
546 enterPDB_actionPerformed();
549 discoverPDB.setText("Discover PDB ids");
550 discoverPDB.addActionListener(new ActionListener()
552 public void actionPerformed(ActionEvent e)
554 discoverPDB_actionPerformed();
557 outputMenu.setText("Output to Textbox...");
558 sequenceFeature.setText("Create Sequence Feature");
559 sequenceFeature.addActionListener(new ActionListener()
561 public void actionPerformed(ActionEvent e)
563 sequenceFeature_actionPerformed();
566 textColour.setText("Text Colour");
567 textColour.addActionListener(new ActionListener()
569 public void actionPerformed(ActionEvent e)
571 textColour_actionPerformed();
574 jMenu1.setText("Group");
575 structureMenu.setText("Structure");
576 viewStructureMenu.setText("View Structure");
577 // colStructureMenu.setText("Colour By Structure");
578 editSequence.setText("Edit Sequence...");
579 editSequence.addActionListener(new ActionListener()
581 public void actionPerformed(ActionEvent actionEvent)
583 editSequence_actionPerformed(actionEvent);
586 /* annotationMenuItem.setText("By Annotation");
587 annotationMenuItem.addActionListener(new ActionListener()
589 public void actionPerformed(ActionEvent actionEvent)
591 annotationMenuItem_actionPerformed(actionEvent);
598 this.add(structureMenu);
599 groupMenu.add(editMenu);
600 groupMenu.add(outputMenu);
601 groupMenu.add(sequenceFeature);
602 groupMenu.add(jMenu1);
603 sequenceMenu.add(sequenceName);
604 colourMenu.add(textColour);
605 colourMenu.add(noColourmenuItem);
606 colourMenu.add(clustalColour);
607 colourMenu.add(BLOSUM62Colour);
608 colourMenu.add(PIDColour);
609 colourMenu.add(zappoColour);
610 colourMenu.add(taylorColour);
611 colourMenu.add(hydrophobicityColour);
612 colourMenu.add(helixColour);
613 colourMenu.add(strandColour);
614 colourMenu.add(turnColour);
615 colourMenu.add(buriedColour);
616 colourMenu.add(nucleotideMenuItem);
617 colourMenu.add(userDefinedColour);
619 if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null)
621 java.util.Enumeration userColours = jalview.gui.UserDefinedColours.
622 getUserColourSchemes().keys();
624 while (userColours.hasMoreElements())
626 JMenuItem item = new JMenuItem(userColours.
627 nextElement().toString());
628 item.addActionListener(new ActionListener()
630 public void actionPerformed(ActionEvent evt)
632 userDefinedColour_actionPerformed(evt);
635 colourMenu.add(item);
639 colourMenu.addSeparator();
640 colourMenu.add(abovePIDColour);
641 colourMenu.add(conservationMenuItem);
642 //colourMenu.add(annotationMenuItem);
645 editMenu.add(editSequence);
646 editMenu.add(upperCase);
647 editMenu.add(lowerCase);
648 editMenu.add(toggle);
649 pdbMenu.add(pdbFromFile);
650 pdbMenu.add(enterPDB);
651 pdbMenu.add(discoverPDB);
652 jMenu1.add(groupName);
653 jMenu1.add(unGroupMenuItem);
654 jMenu1.add(colourMenu);
655 jMenu1.add(showBoxes);
656 jMenu1.add(showText);
657 jMenu1.add(showColourText);
659 structureMenu.add(pdbMenu);
660 structureMenu.add(viewStructureMenu);
661 // structureMenu.add(colStructureMenu);
662 noColourmenuItem.setText("None");
663 noColourmenuItem.addActionListener(new java.awt.event.ActionListener()
665 public void actionPerformed(ActionEvent e)
667 noColourmenuItem_actionPerformed();
671 clustalColour.setText("Clustalx colours");
672 clustalColour.addActionListener(new java.awt.event.ActionListener()
674 public void actionPerformed(ActionEvent e)
676 clustalColour_actionPerformed();
679 zappoColour.setText("Zappo");
680 zappoColour.addActionListener(new java.awt.event.ActionListener()
682 public void actionPerformed(ActionEvent e)
684 zappoColour_actionPerformed();
687 taylorColour.setText("Taylor");
688 taylorColour.addActionListener(new java.awt.event.ActionListener()
690 public void actionPerformed(ActionEvent e)
692 taylorColour_actionPerformed();
695 hydrophobicityColour.setText("Hydrophobicity");
696 hydrophobicityColour.addActionListener(new java.awt.event.ActionListener()
698 public void actionPerformed(ActionEvent e)
700 hydrophobicityColour_actionPerformed();
703 helixColour.setText("Helix propensity");
704 helixColour.addActionListener(new java.awt.event.ActionListener()
706 public void actionPerformed(ActionEvent e)
708 helixColour_actionPerformed();
711 strandColour.setText("Strand propensity");
712 strandColour.addActionListener(new java.awt.event.ActionListener()
714 public void actionPerformed(ActionEvent e)
716 strandColour_actionPerformed();
719 turnColour.setText("Turn propensity");
720 turnColour.addActionListener(new java.awt.event.ActionListener()
722 public void actionPerformed(ActionEvent e)
724 turnColour_actionPerformed();
727 buriedColour.setText("Buried Index");
728 buriedColour.addActionListener(new java.awt.event.ActionListener()
730 public void actionPerformed(ActionEvent e)
732 buriedColour_actionPerformed();
735 abovePIDColour.setText("Above % Identity");
736 abovePIDColour.addActionListener(new java.awt.event.ActionListener()
738 public void actionPerformed(ActionEvent e)
740 abovePIDColour_actionPerformed();
743 userDefinedColour.setText("User Defined...");
744 userDefinedColour.addActionListener(new java.awt.event.ActionListener()
746 public void actionPerformed(ActionEvent e)
748 userDefinedColour_actionPerformed(e);
751 PIDColour.setText("Percentage Identity");
752 PIDColour.addActionListener(new java.awt.event.ActionListener()
754 public void actionPerformed(ActionEvent e)
756 PIDColour_actionPerformed();
759 BLOSUM62Colour.setText("BLOSUM62");
760 BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener()
762 public void actionPerformed(ActionEvent e)
764 BLOSUM62Colour_actionPerformed();
767 conservationMenuItem.setText("Conservation");
768 conservationMenuItem.addActionListener(new java.awt.event.ActionListener()
770 public void actionPerformed(ActionEvent e)
772 conservationMenuItem_actionPerformed();
782 ap.paintAlignment(true);
784 PaintRefresher.Refresh(this, ap.av.getSequenceSetId());
790 * @param e DOCUMENT ME!
792 protected void clustalColour_actionPerformed()
794 SequenceGroup sg = getGroup();
795 sg.cs = new ClustalxColourScheme(sg.getSequences(ap.av.hiddenRepSequences),
796 ap.av.alignment.getWidth());
803 * @param e DOCUMENT ME!
805 protected void zappoColour_actionPerformed()
807 getGroup().cs = new ZappoColourScheme();
814 * @param e DOCUMENT ME!
816 protected void taylorColour_actionPerformed()
818 getGroup().cs = new TaylorColourScheme();
825 * @param e DOCUMENT ME!
827 protected void hydrophobicityColour_actionPerformed()
829 getGroup().cs = new HydrophobicColourScheme();
836 * @param e DOCUMENT ME!
838 protected void helixColour_actionPerformed()
840 getGroup().cs = new HelixColourScheme();
847 * @param e DOCUMENT ME!
849 protected void strandColour_actionPerformed()
851 getGroup().cs = new StrandColourScheme();
858 * @param e DOCUMENT ME!
860 protected void turnColour_actionPerformed()
862 getGroup().cs = new TurnColourScheme();
869 * @param e DOCUMENT ME!
871 protected void buriedColour_actionPerformed()
873 getGroup().cs = new BuriedColourScheme();
880 * @param e DOCUMENT ME!
882 public void nucleotideMenuItem_actionPerformed()
884 getGroup().cs = new NucleotideColourScheme();
891 * @param e DOCUMENT ME!
893 protected void abovePIDColour_actionPerformed()
895 SequenceGroup sg = getGroup();
901 if (abovePIDColour.isSelected())
903 sg.cs.setConsensus(AAFrequency.calculate(
904 sg.getSequences(ap.av.hiddenRepSequences), sg.getStartRes(),
905 sg.getEndRes() + 1));
907 int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs,
908 getGroup().getName());
910 sg.cs.setThreshold(threshold, ap.av.getIgnoreGapsConsensus());
912 SliderPanel.showPIDSlider();
914 else // remove PIDColouring
916 sg.cs.setThreshold(0, ap.av.getIgnoreGapsConsensus());
925 * @param e DOCUMENT ME!
927 protected void userDefinedColour_actionPerformed(ActionEvent e)
929 SequenceGroup sg = getGroup();
931 if (e.getActionCommand().equals("User Defined..."))
933 new UserDefinedColours(ap, sg);
937 UserColourScheme udc = (UserColourScheme) UserDefinedColours.
938 getUserColourSchemes().get(e.getActionCommand());
948 * @param e DOCUMENT ME!
950 protected void PIDColour_actionPerformed()
952 SequenceGroup sg = getGroup();
953 sg.cs = new PIDColourScheme();
954 sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(ap.av.
957 sg.getEndRes() + 1));
964 * @param e DOCUMENT ME!
966 protected void BLOSUM62Colour_actionPerformed()
968 SequenceGroup sg = getGroup();
970 sg.cs = new Blosum62ColourScheme();
972 sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(ap.av.
975 sg.getEndRes() + 1));
983 * @param e DOCUMENT ME!
985 protected void noColourmenuItem_actionPerformed()
987 getGroup().cs = null;
994 * @param e DOCUMENT ME!
996 protected void conservationMenuItem_actionPerformed()
998 SequenceGroup sg = getGroup();
1004 if (conservationMenuItem.isSelected())
1006 Conservation c = new Conservation("Group",
1007 ResidueProperties.propHash, 3,
1008 sg.getSequences(ap.av.
1009 hiddenRepSequences),
1011 sg.getEndRes() + 1);
1014 c.verdict(false, ap.av.ConsPercGaps);
1016 sg.cs.setConservation(c);
1018 SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
1019 SliderPanel.showConservationSlider();
1021 else // remove ConservationColouring
1023 sg.cs.setConservation(null);
1029 public void annotationMenuItem_actionPerformed(ActionEvent actionEvent)
1031 SequenceGroup sg = getGroup();
1037 AnnotationColourGradient acg = new AnnotationColourGradient(
1038 sequence.getAnnotation()[0], null, AnnotationColourGradient.NO_THRESHOLD);
1040 acg.predefinedColours = true;
1049 * @param e DOCUMENT ME!
1051 protected void groupName_actionPerformed()
1054 SequenceGroup sg = getGroup();
1055 EditNameDialog dialog = new EditNameDialog(sg.getName(),
1056 sg.getDescription(),
1058 "Group Description ",
1059 "Edit Group Name/Description");
1066 sg.setName(dialog.getName());
1067 sg.setDescription(dialog.getDescription());
1073 * @return DOCUMENT ME!
1075 SequenceGroup getGroup()
1077 SequenceGroup sg = ap.av.getSelectionGroup();
1078 // this method won't add a new group if it already exists
1081 ap.av.alignment.addGroup(sg);
1090 * @param e DOCUMENT ME!
1092 void sequenceName_actionPerformed()
1094 EditNameDialog dialog = new EditNameDialog(sequence.getName(),
1095 sequence.getDescription(),
1097 "Sequence Description ",
1098 "Edit Sequence Name/Description");
1105 if (dialog.getName() != null)
1107 if (dialog.getName().indexOf(" ") > -1)
1109 JOptionPane.showMessageDialog(ap,
1110 "Spaces have been converted to \"_\"",
1111 "No spaces allowed in Sequence Name",
1112 JOptionPane.WARNING_MESSAGE);
1115 sequence.setName(dialog.getName().replace(' ', '_'));
1116 ap.paintAlignment(false);
1119 sequence.setDescription(dialog.getDescription());
1121 ap.av.firePropertyChange("alignment", null,
1122 ap.av.getAlignment().getSequences());
1129 * @param e DOCUMENT ME!
1131 void unGroupMenuItem_actionPerformed()
1133 SequenceGroup sg = ap.av.getSelectionGroup();
1134 ap.av.alignment.deleteGroup(sg);
1135 ap.av.setSelectionGroup(null);
1142 * @param e DOCUMENT ME!
1144 protected void outline_actionPerformed()
1146 SequenceGroup sg = getGroup();
1147 Color col = JColorChooser.showDialog(this, "Select Outline Colour",
1152 sg.setOutlineColour(col);
1161 * @param e DOCUMENT ME!
1163 public void showBoxes_actionPerformed()
1165 getGroup().setDisplayBoxes(showBoxes.isSelected());
1172 * @param e DOCUMENT ME!
1174 public void showText_actionPerformed()
1176 getGroup().setDisplayText(showText.isSelected());
1183 * @param e DOCUMENT ME!
1185 public void showColourText_actionPerformed()
1187 getGroup().setColourText(showColourText.isSelected());
1191 public void showLink(String url)
1195 jalview.util.BrowserLauncher.openURL(url);
1197 catch (Exception ex)
1199 JOptionPane.showInternalMessageDialog(Desktop.desktop,
1200 "Unixers: Couldn't find default web browser."
1202 "\nAdd the full path to your browser in Preferences.",
1203 "Web browser not found",
1204 JOptionPane.WARNING_MESSAGE);
1206 ex.printStackTrace();
1210 void hideSequences(boolean representGroup)
1212 SequenceGroup sg = ap.av.getSelectionGroup();
1213 if (sg == null || sg.getSize() < 1)
1215 ap.av.hideSequence(new SequenceI[]
1220 ap.av.setSelectionGroup(null);
1224 ap.av.hideRepSequences(sequence, sg);
1229 int gsize = sg.getSize();
1232 hseqs = new SequenceI[gsize];
1235 for (int i = 0; i < gsize; i++)
1237 hseqs[index++] = sg.getSequenceAt(i);
1240 ap.av.hideSequence(hseqs);
1243 public void copy_actionPerformed()
1245 ap.alignFrame.copy_actionPerformed(null);
1248 public void cut_actionPerformed()
1250 ap.alignFrame.cut_actionPerformed(null);
1253 void changeCase(ActionEvent e)
1255 Object source = e.getSource();
1256 SequenceGroup sg = ap.av.getSelectionGroup();
1260 int[][] startEnd = ap.av.getVisibleRegionBoundaries(
1261 sg.getStartRes(), sg.getEndRes() + 1);
1266 if (source == toggle)
1268 description = "Toggle Case";
1269 caseChange = ChangeCaseCommand.TOGGLE_CASE;
1271 else if (source == upperCase)
1273 description = "To Upper Case";
1274 caseChange = ChangeCaseCommand.TO_UPPER;
1278 description = "To Lower Case";
1279 caseChange = ChangeCaseCommand.TO_LOWER;
1282 ChangeCaseCommand caseCommand = new ChangeCaseCommand(
1283 description, sg.getSequencesAsArray(ap.av.hiddenRepSequences),
1284 startEnd, caseChange
1287 ap.alignFrame.addHistoryItem(caseCommand);
1289 ap.av.firePropertyChange("alignment", null,
1290 ap.av.getAlignment().getSequences());
1295 public void outputText_actionPerformed(ActionEvent e)
1297 CutAndPasteTransfer cap = new CutAndPasteTransfer();
1298 cap.setForInput(null);
1299 Desktop.addInternalFrame(cap,
1300 "Alignment output - " + e.getActionCommand(), 600,
1303 String[] omitHidden = null;
1305 System.out.println("PROMPT USER HERE"); // TODO: decide if a prompt happens or we simply trust the user wants wysiwig behaviour
1306 SequenceGroup sg = ap.av.getSelectionGroup();
1307 ColumnSelection csel = new ColumnSelection(ap.av.getColumnSelection());
1308 omitHidden = ap.av.getViewAsString(true);
1309 Alignment oal = new Alignment(ap.av.getSequenceSelection());
1310 AlignmentAnnotation[] nala = ap.av.alignment.getAlignmentAnnotation();
1311 for (int i=0; i<nala.length; i++)
1313 AlignmentAnnotation na =nala[i];
1314 oal.addAnnotation(na);
1316 cap.setText(new FormatAdapter().formatSequences(
1317 e.getActionCommand(),
1319 omitHidden, csel, sg));
1323 public void pdbFromFile_actionPerformed()
1325 jalview.io.JalviewFileChooser chooser
1326 = new jalview.io.JalviewFileChooser(jalview.bin.Cache.
1329 chooser.setFileView(new jalview.io.JalviewFileView());
1330 chooser.setDialogTitle("Select a PDB file");
1331 chooser.setToolTipText("Load a PDB file");
1333 int value = chooser.showOpenDialog(null);
1335 if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
1337 PDBEntry entry = new PDBEntry();
1338 String choice = chooser.getSelectedFile().getPath();
1339 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
1342 MCview.PDBfile pdbfile = new MCview.PDBfile(choice,
1343 jalview.io.AppletFormatAdapter.FILE);
1345 if (pdbfile.id == null)
1347 String reply = JOptionPane.showInternalInputDialog(
1349 "Couldn't find a PDB id in the file supplied."
1350 + "Please enter an Id to identify this structure.",
1351 "No PDB Id in File", JOptionPane.QUESTION_MESSAGE);
1361 entry.setId(pdbfile.id);
1364 catch (java.io.IOException ex)
1366 ex.printStackTrace();
1369 entry.setFile(choice);
1370 sequence.getDatasetSequence().addPDBId(entry);
1375 public void enterPDB_actionPerformed()
1377 String id = JOptionPane.showInternalInputDialog(Desktop.desktop,
1378 "Enter PDB Id", "Enter PDB Id", JOptionPane.QUESTION_MESSAGE);
1380 if (id != null && id.length() > 0)
1382 PDBEntry entry = new PDBEntry();
1383 entry.setId(id.toUpperCase());
1384 sequence.getDatasetSequence()
1389 public void discoverPDB_actionPerformed()
1391 SequenceI[] sequences =
1392 ap.av.selectionGroup == null ?
1393 new Sequence[]{sequence}
1394 : ap.av.selectionGroup.getSequencesInOrder(ap.av.alignment);
1396 new jalview.ws.DBRefFetcher(sequences,
1397 ap.alignFrame).fetchDBRefs(false);
1400 public void sequenceFeature_actionPerformed()
1402 SequenceGroup sg = ap.av.getSelectionGroup();
1408 int gSize = sg.getSize();
1409 SequenceI[] seqs = new SequenceI[gSize];
1410 SequenceFeature[] features = new SequenceFeature[gSize];
1412 for (int i = 0; i < gSize; i++)
1414 seqs[i] = sg.getSequenceAt(i).getDatasetSequence();
1415 int start = sg.getSequenceAt(i).findPosition(sg.getStartRes());
1416 int end = sg.findEndRes(sg.getSequenceAt(i));
1417 features[i] = new SequenceFeature(null, null, null, start, end, "Jalview");
1420 if (ap.seqPanel.seqCanvas.getFeatureRenderer()
1421 .amendFeatures(seqs, features, true, ap))
1423 ap.alignFrame.showSeqFeatures.setSelected(true);
1424 ap.av.setShowSequenceFeatures(true);
1425 ap.highlightSearchResults(null);
1429 public void textColour_actionPerformed()
1431 SequenceGroup sg = getGroup();
1434 new TextColourChooser().chooseColour(ap, sg);
1438 public void colourByStructure(String pdbid)
1440 Annotation [] anots = jalview.structure.StructureSelectionManager.getStructureSelectionManager()
1441 .colourSequenceFromStructure(sequence, pdbid);
1443 AlignmentAnnotation an = new AlignmentAnnotation(
1444 "Structure", "Coloured by "+pdbid, anots);
1446 ap.av.alignment.addAnnotation(an);
1447 an.createSequenceMapping(sequence, 0, true);
1448 //an.adjustForAlignment();
1449 ap.av.alignment.setAnnotationIndex(an,0);
1451 ap.adjustAnnotationHeight();
1453 sequence.addAlignmentAnnotation(an);
1457 public void editSequence_actionPerformed(ActionEvent actionEvent)
1459 SequenceGroup sg = ap.av.getSelectionGroup();
1463 if (sequence == null)
1464 sequence = (Sequence) sg.getSequenceAt(0);
1466 EditNameDialog dialog = new EditNameDialog(
1467 sequence.getSequenceAsString(
1469 sg.getEndRes() + 1),
1477 EditCommand editCommand = new EditCommand(
1478 "Edit Sequences", EditCommand.REPLACE,
1479 dialog.getName().replace(' ', ap.av.getGapCharacter()),
1480 sg.getSequencesAsArray(ap.av.hiddenRepSequences),
1481 sg.getStartRes(), sg.getEndRes() + 1, ap.av.alignment
1484 ap.alignFrame.addHistoryItem(editCommand);
1486 ap.av.firePropertyChange("alignment", null,
1487 ap.av.getAlignment().getSequences());