2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
19 package jalview.gui;
\r
23 import jalview.analysis.*;
\r
25 import jalview.datamodel.*;
\r
28 import jalview.schemes.*;
\r
31 import java.awt.event.*;
\r
33 import javax.swing.*;
\r
35 import java.util.Vector;
\r
36 import jalview.io.FormatAdapter;
\r
43 * @version $Revision$
\r
45 public class PopupMenu extends JPopupMenu
\r
47 JMenu groupMenu = new JMenu();
\r
48 JMenuItem groupName = new JMenuItem();
\r
49 protected JRadioButtonMenuItem clustalColour = new JRadioButtonMenuItem();
\r
50 protected JRadioButtonMenuItem zappoColour = new JRadioButtonMenuItem();
\r
51 protected JRadioButtonMenuItem taylorColour = new JRadioButtonMenuItem();
\r
52 protected JRadioButtonMenuItem hydrophobicityColour = new JRadioButtonMenuItem();
\r
53 protected JRadioButtonMenuItem helixColour = new JRadioButtonMenuItem();
\r
54 protected JRadioButtonMenuItem strandColour = new JRadioButtonMenuItem();
\r
55 protected JRadioButtonMenuItem turnColour = new JRadioButtonMenuItem();
\r
56 protected JRadioButtonMenuItem buriedColour = new JRadioButtonMenuItem();
\r
57 protected JCheckBoxMenuItem abovePIDColour = new JCheckBoxMenuItem();
\r
58 protected JRadioButtonMenuItem userDefinedColour = new JRadioButtonMenuItem();
\r
59 protected JRadioButtonMenuItem PIDColour = new JRadioButtonMenuItem();
\r
60 protected JRadioButtonMenuItem BLOSUM62Colour = new JRadioButtonMenuItem();
\r
61 JRadioButtonMenuItem noColourmenuItem = new JRadioButtonMenuItem();
\r
62 protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem();
\r
64 JMenu sequenceMenu = new JMenu();
\r
65 JMenuItem sequenceName = new JMenuItem();
\r
67 JMenuItem unGroupMenuItem = new JMenuItem();
\r
68 JMenuItem outline = new JMenuItem();
\r
69 JRadioButtonMenuItem nucleotideMenuItem = new JRadioButtonMenuItem();
\r
70 JMenu colourMenu = new JMenu();
\r
71 JCheckBoxMenuItem showBoxes = new JCheckBoxMenuItem();
\r
72 JCheckBoxMenuItem showText = new JCheckBoxMenuItem();
\r
73 JCheckBoxMenuItem showColourText = new JCheckBoxMenuItem();
\r
74 JMenu editMenu = new JMenu();
\r
75 JMenuItem cut = new JMenuItem();
\r
76 JMenuItem copy = new JMenuItem();
\r
77 JMenuItem upperCase = new JMenuItem();
\r
78 JMenuItem lowerCase = new JMenuItem();
\r
79 JMenuItem toggle = new JMenuItem();
\r
80 JMenu outputMenu = new JMenu();
\r
83 * Creates a new PopupMenu object.
\r
85 * @param ap DOCUMENT ME!
\r
86 * @param seq DOCUMENT ME!
\r
88 public PopupMenu(final AlignmentPanel ap, Sequence seq, Vector links)
\r
90 ///////////////////////////////////////////////////////////
\r
91 // If this is activated from the sequence panel, the user may want to
\r
92 // edit or annotate a particular residue. Therefore display the residue menu
\r
94 // If from the IDPanel, we must display the sequence menu
\r
95 //////////////////////////////////////////////////////////
\r
99 ButtonGroup colours = new ButtonGroup();
\r
100 colours.add(noColourmenuItem);
\r
101 colours.add(clustalColour);
\r
102 colours.add(zappoColour);
\r
103 colours.add(taylorColour);
\r
104 colours.add(hydrophobicityColour);
\r
105 colours.add(helixColour);
\r
106 colours.add(strandColour);
\r
107 colours.add(turnColour);
\r
108 colours.add(buriedColour);
\r
109 colours.add(abovePIDColour);
\r
110 colours.add(userDefinedColour);
\r
111 colours.add(PIDColour);
\r
112 colours.add(BLOSUM62Colour);
\r
114 for (int i = 0; i < jalview.io.FormatAdapter.formats.size(); i++)
\r
116 JMenuItem item = new JMenuItem( (String) jalview.io.FormatAdapter.formats.
\r
119 item.addActionListener(new java.awt.event.ActionListener()
\r
121 public void actionPerformed(ActionEvent e)
\r
123 outputText_actionPerformed(e);
\r
127 outputMenu.add(item);
\r
135 catch (Exception e)
\r
137 e.printStackTrace();
\r
143 JMenuItem menuItem;
\r
144 if( seq.getDatasetSequence().getPDBId() != null)
\r
146 java.util.Enumeration e = seq.getDatasetSequence().getPDBId().
\r
148 while (e.hasMoreElements())
\r
150 final PDBEntry pdb = (PDBEntry) e.nextElement();
\r
152 menuItem = new JMenuItem();
\r
153 menuItem.setText("View PDB entry: " + pdb.getId());
\r
154 menuItem.addActionListener(new java.awt.event.ActionListener()
\r
156 public void actionPerformed(ActionEvent e)
\r
158 new PDBViewer(pdb, sequence, ap.seqPanel.seqCanvas);
\r
161 sequenceMenu.add(menuItem);
\r
165 menuItem = new JMenuItem("Hide Sequences");
\r
166 menuItem.addActionListener(new java.awt.event.ActionListener()
\r
168 public void actionPerformed(ActionEvent e)
\r
170 hideSequences(false);
\r
173 sequenceMenu.add(menuItem);
\r
175 if(ap.av.getSelectionGroup() !=null
\r
176 && ap.av.getSelectionGroup().getSize(false)>1)
\r
178 menuItem = new JMenuItem("Represent Group with " + seq.getName());
\r
179 menuItem.addActionListener(new java.awt.event.ActionListener()
\r
181 public void actionPerformed(ActionEvent e)
\r
183 hideSequences(true);
\r
186 sequenceMenu.add(menuItem);
\r
189 if (ap.av.hasHiddenRows)
\r
191 final int index = ap.av.alignment.findIndex(seq);
\r
193 if (ap.av.adjustForHiddenSeqs(index) -
\r
194 ap.av.adjustForHiddenSeqs(index - 1) > 1)
\r
196 menuItem = new JMenuItem("Reveal");
\r
197 menuItem.addActionListener(new ActionListener()
\r
199 public void actionPerformed(ActionEvent e)
\r
201 ap.av.showSequence(index);
\r
203 if (ap.overviewPanel != null)
\r
204 ap.overviewPanel.updateOverviewImage();
\r
207 sequenceMenu.add(menuItem);
\r
210 menuItem = new JMenuItem("Reveal All");
\r
211 menuItem.addActionListener(new ActionListener()
\r
213 public void actionPerformed(ActionEvent e)
\r
215 ap.av.showAllHiddenSeqs();
\r
217 if (ap.overviewPanel != null)
\r
218 ap.overviewPanel.updateOverviewImage();
\r
222 sequenceMenu.add(menuItem);
\r
233 SequenceGroup sg = ap.av.getSelectionGroup();
\r
237 groupName.setText(sg.getName());
\r
239 if (sg.cs instanceof ZappoColourScheme)
\r
241 zappoColour.setSelected(true);
\r
243 else if (sg.cs instanceof TaylorColourScheme)
\r
245 taylorColour.setSelected(true);
\r
247 else if (sg.cs instanceof PIDColourScheme)
\r
249 PIDColour.setSelected(true);
\r
251 else if (sg.cs instanceof Blosum62ColourScheme)
\r
253 BLOSUM62Colour.setSelected(true);
\r
255 else if (sg.cs instanceof UserColourScheme)
\r
257 userDefinedColour.setSelected(true);
\r
259 else if (sg.cs instanceof HydrophobicColourScheme)
\r
261 hydrophobicityColour.setSelected(true);
\r
263 else if (sg.cs instanceof HelixColourScheme)
\r
265 helixColour.setSelected(true);
\r
267 else if (sg.cs instanceof StrandColourScheme)
\r
269 strandColour.setSelected(true);
\r
271 else if (sg.cs instanceof TurnColourScheme)
\r
273 turnColour.setSelected(true);
\r
275 else if (sg.cs instanceof BuriedColourScheme)
\r
277 buriedColour.setSelected(true);
\r
279 else if (sg.cs instanceof ClustalxColourScheme)
\r
281 clustalColour.setSelected(true);
\r
285 noColourmenuItem.setSelected(true);
\r
288 if (sg.cs!=null && sg.cs.conservationApplied())
\r
290 conservationMenuItem.setSelected(true);
\r
293 showText.setSelected(sg.getDisplayText());
\r
294 showColourText.setSelected(sg.getColourText());
\r
295 showBoxes.setSelected(sg.getDisplayBoxes());
\r
299 groupMenu.setVisible(false);
\r
300 editMenu.setVisible(false);
\r
303 if (!ap.av.alignment.getGroups().contains(sg))
\r
305 unGroupMenuItem.setVisible(false);
\r
309 groupMenu.insertSeparator(3);
\r
314 sequenceMenu.setVisible(false);
\r
317 if(links != null && links.size()>0)
\r
319 JMenu linkMenu = new JMenu("Link");
\r
321 for(int i=0; i<links.size(); i++)
\r
323 String link = links.elementAt(i).toString();
\r
324 final String label = link.substring(0, link.indexOf("|"));
\r
325 item = new JMenuItem(label);
\r
328 if (link.indexOf("$SEQUENCE_ID$") > -1)
\r
330 String id = seq.getName();
\r
331 if (id.indexOf("|") > -1)
\r
332 id = id.substring(id.lastIndexOf("|") + 1);
\r
334 url = link.substring(link.indexOf("|") + 1,
\r
335 link.indexOf("$SEQUENCE_ID$"))
\r
337 link.substring(link.indexOf("$SEQUENCE_ID$") + 13);
\r
340 url = link.substring(link.lastIndexOf("|")+1);
\r
343 item.addActionListener(new java.awt.event.ActionListener()
\r
345 public void actionPerformed(ActionEvent e)
\r
351 linkMenu.add(item);
\r
361 * @throws Exception DOCUMENT ME!
\r
363 private void jbInit() throws Exception
\r
365 groupMenu.setText("Group");
\r
366 groupMenu.setText("Group");
\r
367 groupName.setText("Name");
\r
368 groupName.addActionListener(new java.awt.event.ActionListener()
\r
370 public void actionPerformed(ActionEvent e)
\r
372 groupName_actionPerformed(e);
\r
375 sequenceMenu.setText("Sequence");
\r
376 sequenceName.setText("Edit Name/Description");
\r
377 sequenceName.addActionListener(new java.awt.event.ActionListener()
\r
379 public void actionPerformed(ActionEvent e)
\r
381 sequenceName_actionPerformed(e);
\r
384 PIDColour.setFocusPainted(false);
\r
385 unGroupMenuItem.setText("Remove Group");
\r
386 unGroupMenuItem.addActionListener(new java.awt.event.ActionListener()
\r
388 public void actionPerformed(ActionEvent e)
\r
390 unGroupMenuItem_actionPerformed(e);
\r
394 outline.setText("Border colour");
\r
395 outline.addActionListener(new java.awt.event.ActionListener()
\r
397 public void actionPerformed(ActionEvent e)
\r
399 outline_actionPerformed(e);
\r
402 nucleotideMenuItem.setText("Nucleotide");
\r
403 nucleotideMenuItem.addActionListener(new ActionListener()
\r
405 public void actionPerformed(ActionEvent e)
\r
407 nucleotideMenuItem_actionPerformed(e);
\r
410 colourMenu.setText("Group Colour");
\r
411 showBoxes.setText("Boxes");
\r
412 showBoxes.setState(true);
\r
413 showBoxes.addActionListener(new ActionListener()
\r
415 public void actionPerformed(ActionEvent e)
\r
417 showBoxes_actionPerformed(e);
\r
420 showText.setText("Text");
\r
421 showText.setState(true);
\r
422 showText.addActionListener(new ActionListener()
\r
424 public void actionPerformed(ActionEvent e)
\r
426 showText_actionPerformed(e);
\r
429 showColourText.setText("Colour Text");
\r
430 showColourText.addActionListener(new ActionListener()
\r
432 public void actionPerformed(ActionEvent e)
\r
434 showColourText_actionPerformed(e);
\r
437 editMenu.setText("Edit");
\r
438 cut.setText("Cut");
\r
439 cut.addActionListener(new ActionListener()
\r
441 public void actionPerformed(ActionEvent e)
\r
443 cut_actionPerformed(e);
\r
446 upperCase.setText("To Upper Case");
\r
447 upperCase.addActionListener(new ActionListener()
\r
449 public void actionPerformed(ActionEvent e)
\r
451 upperCase_actionPerformed(e);
\r
454 copy.setText("Copy");
\r
455 copy.addActionListener(new ActionListener()
\r
457 public void actionPerformed(ActionEvent e)
\r
459 copy_actionPerformed(e);
\r
462 lowerCase.setText("To Lower Case");
\r
463 lowerCase.addActionListener(new ActionListener()
\r
465 public void actionPerformed(ActionEvent e)
\r
467 lowerCase_actionPerformed(e);
\r
470 toggle.setText("Toggle Case");
\r
471 toggle.addActionListener(new ActionListener()
\r
473 public void actionPerformed(ActionEvent e)
\r
475 toggle_actionPerformed(e);
\r
478 outputMenu.setText("Output to Textbox...");
\r
481 this.add(editMenu);
\r
482 this.add(outputMenu);
\r
483 groupMenu.add(groupName);
\r
484 groupMenu.addSeparator();
\r
485 groupMenu.add(unGroupMenuItem);
\r
486 groupMenu.add(colourMenu);
\r
487 groupMenu.addSeparator();
\r
488 groupMenu.add(showBoxes);
\r
489 groupMenu.add(showText);
\r
490 groupMenu.add(showColourText);
\r
491 groupMenu.addSeparator();
\r
492 groupMenu.add(outline);
\r
493 sequenceMenu.add(sequenceName);
\r
494 colourMenu.add(noColourmenuItem);
\r
495 colourMenu.add(clustalColour);
\r
496 colourMenu.add(BLOSUM62Colour);
\r
497 colourMenu.add(PIDColour);
\r
498 colourMenu.add(zappoColour);
\r
499 colourMenu.add(taylorColour);
\r
500 colourMenu.add(hydrophobicityColour);
\r
501 colourMenu.add(helixColour);
\r
502 colourMenu.add(strandColour);
\r
503 colourMenu.add(turnColour);
\r
504 colourMenu.add(buriedColour);
\r
505 colourMenu.add(nucleotideMenuItem);
\r
506 colourMenu.add(userDefinedColour);
\r
508 if(jalview.gui.UserDefinedColours.getUserColourSchemes()!=null)
\r
510 java.util.Enumeration userColours = jalview.gui.UserDefinedColours.
\r
511 getUserColourSchemes().keys();
\r
513 while (userColours.hasMoreElements())
\r
515 JMenuItem item = new JMenuItem(userColours.
\r
516 nextElement().toString());
\r
517 item.addActionListener(new ActionListener()
\r
519 public void actionPerformed(ActionEvent evt)
\r
521 userDefinedColour_actionPerformed(evt);
\r
524 colourMenu.add(item);
\r
529 colourMenu.addSeparator();
\r
530 colourMenu.add(abovePIDColour);
\r
531 colourMenu.add(conservationMenuItem);
\r
532 editMenu.add(copy);
\r
534 editMenu.add(upperCase);
\r
535 editMenu.add(lowerCase);
\r
536 editMenu.add(toggle);
\r
537 noColourmenuItem.setText("None");
\r
538 noColourmenuItem.addActionListener(new java.awt.event.ActionListener()
\r
540 public void actionPerformed(ActionEvent e)
\r
542 noColourmenuItem_actionPerformed(e);
\r
546 clustalColour.setText("Clustalx colours");
\r
547 clustalColour.addActionListener(new java.awt.event.ActionListener()
\r
549 public void actionPerformed(ActionEvent e)
\r
551 clustalColour_actionPerformed(e);
\r
554 zappoColour.setText("Zappo");
\r
555 zappoColour.addActionListener(new java.awt.event.ActionListener()
\r
557 public void actionPerformed(ActionEvent e)
\r
559 zappoColour_actionPerformed(e);
\r
562 taylorColour.setText("Taylor");
\r
563 taylorColour.addActionListener(new java.awt.event.ActionListener()
\r
565 public void actionPerformed(ActionEvent e)
\r
567 taylorColour_actionPerformed(e);
\r
570 hydrophobicityColour.setText("Hydrophobicity");
\r
571 hydrophobicityColour.addActionListener(new java.awt.event.ActionListener()
\r
573 public void actionPerformed(ActionEvent e)
\r
575 hydrophobicityColour_actionPerformed(e);
\r
578 helixColour.setText("Helix propensity");
\r
579 helixColour.addActionListener(new java.awt.event.ActionListener()
\r
581 public void actionPerformed(ActionEvent e)
\r
583 helixColour_actionPerformed(e);
\r
586 strandColour.setText("Strand propensity");
\r
587 strandColour.addActionListener(new java.awt.event.ActionListener()
\r
589 public void actionPerformed(ActionEvent e)
\r
591 strandColour_actionPerformed(e);
\r
594 turnColour.setText("Turn propensity");
\r
595 turnColour.addActionListener(new java.awt.event.ActionListener()
\r
597 public void actionPerformed(ActionEvent e)
\r
599 turnColour_actionPerformed(e);
\r
602 buriedColour.setText("Buried Index");
\r
603 buriedColour.addActionListener(new java.awt.event.ActionListener()
\r
605 public void actionPerformed(ActionEvent e)
\r
607 buriedColour_actionPerformed(e);
\r
610 abovePIDColour.setText("Above % Identity");
\r
611 abovePIDColour.addActionListener(new java.awt.event.ActionListener()
\r
613 public void actionPerformed(ActionEvent e)
\r
615 abovePIDColour_actionPerformed(e);
\r
618 userDefinedColour.setText("User Defined...");
\r
619 userDefinedColour.addActionListener(new java.awt.event.ActionListener()
\r
621 public void actionPerformed(ActionEvent e)
\r
623 userDefinedColour_actionPerformed(e);
\r
626 PIDColour.setText("Percentage Identity");
\r
627 PIDColour.addActionListener(new java.awt.event.ActionListener()
\r
629 public void actionPerformed(ActionEvent e)
\r
631 PIDColour_actionPerformed(e);
\r
634 BLOSUM62Colour.setText("BLOSUM62");
\r
635 BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener()
\r
637 public void actionPerformed(ActionEvent e)
\r
639 BLOSUM62Colour_actionPerformed(e);
\r
642 conservationMenuItem.setText("Conservation");
\r
643 conservationMenuItem.addActionListener(new java.awt.event.ActionListener()
\r
645 public void actionPerformed(ActionEvent e)
\r
647 conservationMenuItem_actionPerformed(e);
\r
657 if (ap.overviewPanel != null)
\r
658 ap.overviewPanel.updateOverviewImage();
\r
660 ap.seqPanel.repaint();
\r
666 * @param e DOCUMENT ME!
\r
668 protected void clustalColour_actionPerformed(ActionEvent e)
\r
670 SequenceGroup sg = getGroup();
\r
671 sg.cs = new ClustalxColourScheme(sg.getSequences(true),
\r
672 ap.av.alignment.getWidth());
\r
679 * @param e DOCUMENT ME!
\r
681 protected void zappoColour_actionPerformed(ActionEvent e)
\r
683 getGroup().cs = new ZappoColourScheme();
\r
690 * @param e DOCUMENT ME!
\r
692 protected void taylorColour_actionPerformed(ActionEvent e)
\r
694 getGroup().cs = new TaylorColourScheme();
\r
701 * @param e DOCUMENT ME!
\r
703 protected void hydrophobicityColour_actionPerformed(ActionEvent e)
\r
705 getGroup().cs = new HydrophobicColourScheme();
\r
712 * @param e DOCUMENT ME!
\r
714 protected void helixColour_actionPerformed(ActionEvent e)
\r
716 getGroup().cs = new HelixColourScheme();
\r
723 * @param e DOCUMENT ME!
\r
725 protected void strandColour_actionPerformed(ActionEvent e)
\r
727 getGroup().cs = new StrandColourScheme();
\r
734 * @param e DOCUMENT ME!
\r
736 protected void turnColour_actionPerformed(ActionEvent e)
\r
738 getGroup().cs = new TurnColourScheme();
\r
745 * @param e DOCUMENT ME!
\r
747 protected void buriedColour_actionPerformed(ActionEvent e)
\r
749 getGroup().cs = new BuriedColourScheme();
\r
756 * @param e DOCUMENT ME!
\r
758 public void nucleotideMenuItem_actionPerformed(ActionEvent e)
\r
760 getGroup().cs = new NucleotideColourScheme();
\r
767 * @param e DOCUMENT ME!
\r
769 protected void abovePIDColour_actionPerformed(ActionEvent e)
\r
771 SequenceGroup sg = getGroup();
\r
775 if (abovePIDColour.isSelected())
\r
777 sg.cs.setConsensus(AAFrequency.calculate(
\r
778 sg.getSequences(true), 0,
\r
779 ap.av.alignment.getWidth()));
\r
781 int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs,
\r
782 getGroup().getName());
\r
784 sg.cs.setThreshold(threshold, ap.av.getIgnoreGapsConsensus());
\r
786 SliderPanel.showPIDSlider();
\r
788 else // remove PIDColouring
\r
790 sg.cs.setThreshold(0, ap.av.getIgnoreGapsConsensus());
\r
799 * @param e DOCUMENT ME!
\r
801 protected void userDefinedColour_actionPerformed(ActionEvent e)
\r
803 SequenceGroup sg = getGroup();
\r
805 if (e.getActionCommand().equals("User Defined..."))
\r
806 new UserDefinedColours(ap, sg);
\r
809 UserColourScheme udc = (UserColourScheme) UserDefinedColours.
\r
810 getUserColourSchemes().get(e.getActionCommand());
\r
818 * @param e DOCUMENT ME!
\r
820 protected void PIDColour_actionPerformed(ActionEvent e)
\r
822 SequenceGroup sg = getGroup();
\r
823 sg.cs = new PIDColourScheme();
\r
824 sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(true), 0,
\r
825 ap.av.alignment.getWidth()));
\r
832 * @param e DOCUMENT ME!
\r
834 protected void BLOSUM62Colour_actionPerformed(ActionEvent e)
\r
836 SequenceGroup sg = getGroup();
\r
838 sg.cs = new Blosum62ColourScheme();
\r
840 sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(true), 0,
\r
841 ap.av.alignment.getWidth()));
\r
849 * @param e DOCUMENT ME!
\r
851 protected void noColourmenuItem_actionPerformed(ActionEvent e)
\r
853 getGroup().cs = null;
\r
860 * @param e DOCUMENT ME!
\r
862 protected void conservationMenuItem_actionPerformed(ActionEvent e)
\r
864 SequenceGroup sg = getGroup();
\r
868 if (conservationMenuItem.isSelected())
\r
870 Conservation c = new Conservation("Group",
\r
871 ResidueProperties.propHash, 3,
\r
872 sg.getSequences(true), 0,
\r
873 ap.av.alignment.getWidth());
\r
876 c.verdict(false, ap.av.ConsPercGaps);
\r
878 sg.cs.setConservation(c);
\r
880 SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
\r
881 SliderPanel.showConservationSlider();
\r
883 else // remove ConservationColouring
\r
885 sg.cs.setConservation(null);
\r
894 * @param e DOCUMENT ME!
\r
896 protected void groupName_actionPerformed(ActionEvent e)
\r
898 SequenceGroup sg = getGroup();
\r
899 String reply = JOptionPane.showInternalInputDialog(Desktop.desktop,
\r
900 "Enter new group name", "Edit group name",
\r
901 JOptionPane.QUESTION_MESSAGE);
\r
909 groupName.setText(reply);
\r
915 * @param e DOCUMENT ME!
\r
917 protected void analyze_actionPerformed(ActionEvent e)
\r
919 CutAndPasteTransfer cap = new CutAndPasteTransfer();
\r
920 JInternalFrame frame = new JInternalFrame();
\r
921 frame.setContentPane(cap);
\r
922 Desktop.addInternalFrame(frame, "Analyze this - ", 400, 300);
\r
924 SequenceGroup sg = getGroup();
\r
925 StringBuffer sb = new StringBuffer();
\r
927 for (int i = 0; i < sg.getSize(false); i++)
\r
929 Sequence tmp = (Sequence) sg.getSequences(false).elementAt(i);
\r
930 sb.append(tmp.getSequence(sg.getStartRes(), sg.getEndRes() + 1));
\r
934 sb.append("Something amazing will happen soon");
\r
935 cap.setText(sb.toString());
\r
941 * @return DOCUMENT ME!
\r
943 SequenceGroup getGroup()
\r
945 SequenceGroup sg = ap.av.getSelectionGroup();
\r
946 // this method won't add a new group if it already exists
\r
948 ap.av.alignment.addGroup(sg);
\r
956 * @param e DOCUMENT ME!
\r
958 void sequenceName_actionPerformed(ActionEvent e)
\r
960 JLabel idlabel = new JLabel( " Sequence Name ");
\r
961 JLabel desclabel = new JLabel("Sequence Description ");
\r
962 idlabel.setFont(new Font("Courier", Font.PLAIN, 12));
\r
963 desclabel.setFont(new Font("Courier", Font.PLAIN, 12));
\r
964 JTextField id = new JTextField(sequence.getName(), 40);
\r
965 JTextField description = new JTextField(sequence.getDescription(), 40);
\r
966 JPanel panel = new JPanel(new BorderLayout());
\r
967 JPanel panel2 = new JPanel(new BorderLayout());
\r
968 panel2.add(idlabel, BorderLayout.WEST);
\r
969 panel2.add(id, BorderLayout.CENTER);
\r
970 panel.add(panel2, BorderLayout.NORTH);
\r
971 panel2 = new JPanel(new BorderLayout());
\r
972 panel2.add(desclabel, BorderLayout.WEST);
\r
973 panel2.add(description, BorderLayout.CENTER);
\r
974 panel.add(panel2, BorderLayout.SOUTH);
\r
977 int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
\r
978 panel, "Edit Sequence Name/Description",
\r
979 JOptionPane.OK_CANCEL_OPTION );
\r
982 if (reply != JOptionPane.OK_OPTION )
\r
987 String s = id.getText();
\r
991 if (s.indexOf(" ") > -1)
\r
993 JOptionPane.showMessageDialog(ap,
\r
994 "Spaces have been converted to \"_\"",
\r
995 "No spaces allowed in Sequence Name",
\r
996 JOptionPane.WARNING_MESSAGE);
\r
999 s = s.replace(' ', '_');
\r
1000 sequence.getDatasetSequence().setName(s);
\r
1001 sequence.setName(s);
\r
1005 sequence.getDatasetSequence().setDescription(description.getText());
\r
1006 sequence.setDescription(description.getText());
\r
1012 * @param e DOCUMENT ME!
\r
1014 void unGroupMenuItem_actionPerformed(ActionEvent e)
\r
1016 SequenceGroup sg = ap.av.getSelectionGroup();
\r
1017 ap.av.alignment.deleteGroup(sg);
\r
1018 ap.av.setSelectionGroup(null);
\r
1026 * @param e DOCUMENT ME!
\r
1028 protected void outline_actionPerformed(ActionEvent e)
\r
1030 SequenceGroup sg = getGroup();
\r
1031 Color col = JColorChooser.showDialog(this, "Select Outline Colour",
\r
1036 sg.setOutlineColour(col);
\r
1045 * @param e DOCUMENT ME!
\r
1047 public void showBoxes_actionPerformed(ActionEvent e)
\r
1049 getGroup().setDisplayBoxes(showBoxes.isSelected());
\r
1056 * @param e DOCUMENT ME!
\r
1058 public void showText_actionPerformed(ActionEvent e)
\r
1060 getGroup().setDisplayText(showText.isSelected());
\r
1067 * @param e DOCUMENT ME!
\r
1069 public void showColourText_actionPerformed(ActionEvent e)
\r
1071 getGroup().setColourText(showColourText.isSelected());
\r
1075 public void showLink(String url)
\r
1079 jalview.util.BrowserLauncher.openURL(url);
\r
1081 catch (Exception ex)
\r
1083 JOptionPane.showInternalMessageDialog(Desktop.desktop,
\r
1084 "Unixers: Couldn't find default web browser."
\r
1085 +"\nAdd the full path to your browser in Preferences.",
\r
1086 "Web browser not found", JOptionPane.WARNING_MESSAGE );
\r
1089 ex.printStackTrace();
\r
1093 void hideSequences(boolean representGroup)
\r
1095 SequenceGroup sg = ap.av.getSelectionGroup();
\r
1096 if(sg==null || sg.getSize(false)<1)
\r
1098 ap.av.hideSequence(sequence);
\r
1103 while(index < sg.getSize(false))
\r
1105 if(representGroup && sg.getSequenceAt(index)!=sequence)
\r
1107 sequence.addHiddenSequence(sg.getSequenceAt(index));
\r
1108 ap.av.hideSequence(sg.getSequenceAt(index));
\r
1110 else if(!representGroup)
\r
1112 ap.av.hideSequence(sg.getSequenceAt(index));
\r
1117 ap.av.setSelectionGroup(null);
\r
1121 public void copy_actionPerformed(ActionEvent e)
\r
1123 ap.alignFrame.copy_actionPerformed(null);
\r
1126 public void cut_actionPerformed(ActionEvent e)
\r
1128 ap.alignFrame.cut_actionPerformed(null);
\r
1131 public void upperCase_actionPerformed(ActionEvent e)
\r
1133 SequenceGroup sg = ap.av.getSelectionGroup();
\r
1137 for(int g=0; g<sg.getSize(true); g++)
\r
1139 ( (SequenceI)sg.getSequences(true).elementAt(g))
\r
1140 .changeCase(true, sg.getStartRes(), sg.getEndRes()+1);
\r
1145 public void lowerCase_actionPerformed(ActionEvent e)
\r
1147 SequenceGroup sg = ap.av.getSelectionGroup();
\r
1151 for(int g=0; g<sg.getSize(true); g++)
\r
1153 ( (SequenceI)sg.getSequences(true).elementAt(g))
\r
1154 .changeCase(false, sg.getStartRes(), sg.getEndRes()+1);
\r
1159 public void toggle_actionPerformed(ActionEvent e)
\r
1161 SequenceGroup sg = ap.av.getSelectionGroup();
\r
1165 for (int g = 0; g < sg.getSize(true); g++)
\r
1167 ( (SequenceI)sg.getSequences(true).elementAt(g))
\r
1168 .toggleCase(sg.getStartRes(), sg.getEndRes() + 1);
\r
1174 public void outputText_actionPerformed(ActionEvent e)
\r
1176 CutAndPasteTransfer cap = new CutAndPasteTransfer();
\r
1177 Desktop.addInternalFrame(cap,
\r
1178 "Alignment output - " + e.getActionCommand(), 600,
\r
1181 String [] omitHidden = null;
\r
1183 if(ap.av.hasHiddenColumns)
\r
1185 System.out.println("PROMPT USER HERE");
\r
1186 omitHidden = ap.av.getViewAsString(true);
\r
1189 cap.setText(new FormatAdapter().formatSequences(
\r
1190 e.getActionCommand(),
\r
1191 ap.av.getSelectionAsNewSequence(),
\r