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
42 * @version $Revision$
\r
44 public class PopupMenu extends JPopupMenu
\r
46 JMenu groupMenu = new JMenu();
\r
47 JMenuItem groupName = new JMenuItem();
\r
48 protected JRadioButtonMenuItem clustalColour = new JRadioButtonMenuItem();
\r
49 protected JRadioButtonMenuItem zappoColour = new JRadioButtonMenuItem();
\r
50 protected JRadioButtonMenuItem taylorColour = new JRadioButtonMenuItem();
\r
51 protected JRadioButtonMenuItem hydrophobicityColour = new JRadioButtonMenuItem();
\r
52 protected JRadioButtonMenuItem helixColour = new JRadioButtonMenuItem();
\r
53 protected JRadioButtonMenuItem strandColour = new JRadioButtonMenuItem();
\r
54 protected JRadioButtonMenuItem turnColour = new JRadioButtonMenuItem();
\r
55 protected JRadioButtonMenuItem buriedColour = new JRadioButtonMenuItem();
\r
56 protected JCheckBoxMenuItem abovePIDColour = new JCheckBoxMenuItem();
\r
57 protected JRadioButtonMenuItem userDefinedColour = new JRadioButtonMenuItem();
\r
58 protected JRadioButtonMenuItem PIDColour = new JRadioButtonMenuItem();
\r
59 protected JRadioButtonMenuItem BLOSUM62Colour = new JRadioButtonMenuItem();
\r
60 JRadioButtonMenuItem noColourmenuItem = new JRadioButtonMenuItem();
\r
61 protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem();
\r
63 JMenu sequenceMenu = new JMenu();
\r
64 JMenuItem sequenceName = new JMenuItem();
\r
66 JMenuItem unGroupMenuItem = new JMenuItem();
\r
67 JMenuItem outline = new JMenuItem();
\r
68 JRadioButtonMenuItem nucleotideMenuItem = new JRadioButtonMenuItem();
\r
69 JMenu colourMenu = new JMenu();
\r
70 JCheckBoxMenuItem showBoxes = new JCheckBoxMenuItem();
\r
71 JCheckBoxMenuItem showText = new JCheckBoxMenuItem();
\r
72 JCheckBoxMenuItem showColourText = new JCheckBoxMenuItem();
\r
73 JMenu editMenu = new JMenu();
\r
74 JMenuItem cut = new JMenuItem();
\r
75 JMenuItem copy = new JMenuItem();
\r
76 JMenuItem upperCase = new JMenuItem();
\r
77 JMenuItem lowerCase = new JMenuItem();
\r
78 JMenuItem toggle = new JMenuItem();
\r
81 * Creates a new PopupMenu object.
\r
83 * @param ap DOCUMENT ME!
\r
84 * @param seq DOCUMENT ME!
\r
86 public PopupMenu(final AlignmentPanel ap, Sequence seq, Vector links)
\r
88 ///////////////////////////////////////////////////////////
\r
89 // If this is activated from the sequence panel, the user may want to
\r
90 // edit or annotate a particular residue. Therefore display the residue menu
\r
92 // If from the IDPanel, we must display the sequence menu
\r
93 //////////////////////////////////////////////////////////
\r
97 ButtonGroup colours = new ButtonGroup();
\r
98 colours.add(noColourmenuItem);
\r
99 colours.add(clustalColour);
\r
100 colours.add(zappoColour);
\r
101 colours.add(taylorColour);
\r
102 colours.add(hydrophobicityColour);
\r
103 colours.add(helixColour);
\r
104 colours.add(strandColour);
\r
105 colours.add(turnColour);
\r
106 colours.add(buriedColour);
\r
107 colours.add(abovePIDColour);
\r
108 colours.add(userDefinedColour);
\r
109 colours.add(PIDColour);
\r
110 colours.add(BLOSUM62Colour);
\r
116 catch (Exception e)
\r
118 e.printStackTrace();
\r
124 JMenuItem menuItem;
\r
125 if( seq.getDatasetSequence().getPDBId() != null)
\r
127 java.util.Enumeration e = seq.getDatasetSequence().getPDBId().
\r
129 while (e.hasMoreElements())
\r
131 final PDBEntry pdb = (PDBEntry) e.nextElement();
\r
133 menuItem = new JMenuItem();
\r
134 menuItem.setText("View PDB entry: " + pdb.getId());
\r
135 menuItem.addActionListener(new java.awt.event.ActionListener()
\r
137 public void actionPerformed(ActionEvent e)
\r
139 new PDBViewer(pdb, sequence, ap.seqPanel.seqCanvas);
\r
142 sequenceMenu.add(menuItem);
\r
146 menuItem = new JMenuItem("Hide Sequences");
\r
147 menuItem.addActionListener(new java.awt.event.ActionListener()
\r
149 public void actionPerformed(ActionEvent e)
\r
151 hideSequences(false);
\r
154 sequenceMenu.add(menuItem);
\r
156 if(ap.av.getSelectionGroup() !=null
\r
157 && ap.av.getSelectionGroup().getSize(false)>1)
\r
159 menuItem = new JMenuItem("Represent Group with " + seq.getName());
\r
160 menuItem.addActionListener(new java.awt.event.ActionListener()
\r
162 public void actionPerformed(ActionEvent e)
\r
164 hideSequences(true);
\r
167 sequenceMenu.add(menuItem);
\r
170 if (ap.av.hasHiddenRows)
\r
172 final int index = ap.av.alignment.findIndex(seq);
\r
174 if (ap.av.adjustForHiddenSeqs(index) -
\r
175 ap.av.adjustForHiddenSeqs(index - 1) > 1)
\r
177 menuItem = new JMenuItem("Reveal");
\r
178 menuItem.addActionListener(new ActionListener()
\r
180 public void actionPerformed(ActionEvent e)
\r
182 ap.av.showSequence(index);
\r
184 if (ap.overviewPanel != null)
\r
185 ap.overviewPanel.updateOverviewImage();
\r
188 sequenceMenu.add(menuItem);
\r
191 menuItem = new JMenuItem("Reveal All");
\r
192 menuItem.addActionListener(new ActionListener()
\r
194 public void actionPerformed(ActionEvent e)
\r
196 ap.av.showAllHiddenSeqs();
\r
198 if (ap.overviewPanel != null)
\r
199 ap.overviewPanel.updateOverviewImage();
\r
203 sequenceMenu.add(menuItem);
\r
214 SequenceGroup sg = ap.av.getSelectionGroup();
\r
218 groupName.setText(sg.getName());
\r
220 if (sg.cs instanceof ZappoColourScheme)
\r
222 zappoColour.setSelected(true);
\r
224 else if (sg.cs instanceof TaylorColourScheme)
\r
226 taylorColour.setSelected(true);
\r
228 else if (sg.cs instanceof PIDColourScheme)
\r
230 PIDColour.setSelected(true);
\r
232 else if (sg.cs instanceof Blosum62ColourScheme)
\r
234 BLOSUM62Colour.setSelected(true);
\r
236 else if (sg.cs instanceof UserColourScheme)
\r
238 userDefinedColour.setSelected(true);
\r
240 else if (sg.cs instanceof HydrophobicColourScheme)
\r
242 hydrophobicityColour.setSelected(true);
\r
244 else if (sg.cs instanceof HelixColourScheme)
\r
246 helixColour.setSelected(true);
\r
248 else if (sg.cs instanceof StrandColourScheme)
\r
250 strandColour.setSelected(true);
\r
252 else if (sg.cs instanceof TurnColourScheme)
\r
254 turnColour.setSelected(true);
\r
256 else if (sg.cs instanceof BuriedColourScheme)
\r
258 buriedColour.setSelected(true);
\r
260 else if (sg.cs instanceof ClustalxColourScheme)
\r
262 clustalColour.setSelected(true);
\r
266 noColourmenuItem.setSelected(true);
\r
269 if (sg.cs!=null && sg.cs.conservationApplied())
\r
271 conservationMenuItem.setSelected(true);
\r
274 showText.setSelected(sg.getDisplayText());
\r
275 showColourText.setSelected(sg.getColourText());
\r
276 showBoxes.setSelected(sg.getDisplayBoxes());
\r
280 groupMenu.setVisible(false);
\r
281 editMenu.setVisible(false);
\r
284 if (!ap.av.alignment.getGroups().contains(sg))
\r
286 unGroupMenuItem.setVisible(false);
\r
290 groupMenu.insertSeparator(3);
\r
295 sequenceMenu.setVisible(false);
\r
298 if(links != null && links.size()>0)
\r
300 JMenu linkMenu = new JMenu("Link");
\r
302 for(int i=0; i<links.size(); i++)
\r
304 String link = links.elementAt(i).toString();
\r
305 final String label = link.substring(0, link.indexOf("|"));
\r
306 item = new JMenuItem(label);
\r
309 if (link.indexOf("$SEQUENCE_ID$") > -1)
\r
311 String id = seq.getName();
\r
312 if (id.indexOf("|") > -1)
\r
313 id = id.substring(id.lastIndexOf("|") + 1);
\r
315 url = link.substring(link.indexOf("|") + 1,
\r
316 link.indexOf("$SEQUENCE_ID$"))
\r
318 link.substring(link.indexOf("$SEQUENCE_ID$") + 13);
\r
321 url = link.substring(link.lastIndexOf("|")+1);
\r
324 item.addActionListener(new java.awt.event.ActionListener()
\r
326 public void actionPerformed(ActionEvent e)
\r
332 linkMenu.add(item);
\r
342 * @throws Exception DOCUMENT ME!
\r
344 private void jbInit() throws Exception
\r
346 groupMenu.setText("Group");
\r
347 groupMenu.setText("Group");
\r
348 groupName.setText("Name");
\r
349 groupName.addActionListener(new java.awt.event.ActionListener()
\r
351 public void actionPerformed(ActionEvent e)
\r
353 groupName_actionPerformed(e);
\r
356 sequenceMenu.setText("Sequence");
\r
357 sequenceName.setText("Edit Name/Description");
\r
358 sequenceName.addActionListener(new java.awt.event.ActionListener()
\r
360 public void actionPerformed(ActionEvent e)
\r
362 sequenceName_actionPerformed(e);
\r
365 PIDColour.setFocusPainted(false);
\r
366 unGroupMenuItem.setText("Remove Group");
\r
367 unGroupMenuItem.addActionListener(new java.awt.event.ActionListener()
\r
369 public void actionPerformed(ActionEvent e)
\r
371 unGroupMenuItem_actionPerformed(e);
\r
375 outline.setText("Border colour");
\r
376 outline.addActionListener(new java.awt.event.ActionListener()
\r
378 public void actionPerformed(ActionEvent e)
\r
380 outline_actionPerformed(e);
\r
383 nucleotideMenuItem.setText("Nucleotide");
\r
384 nucleotideMenuItem.addActionListener(new ActionListener()
\r
386 public void actionPerformed(ActionEvent e)
\r
388 nucleotideMenuItem_actionPerformed(e);
\r
391 colourMenu.setText("Group Colour");
\r
392 showBoxes.setText("Boxes");
\r
393 showBoxes.setState(true);
\r
394 showBoxes.addActionListener(new ActionListener()
\r
396 public void actionPerformed(ActionEvent e)
\r
398 showBoxes_actionPerformed(e);
\r
401 showText.setText("Text");
\r
402 showText.setState(true);
\r
403 showText.addActionListener(new ActionListener()
\r
405 public void actionPerformed(ActionEvent e)
\r
407 showText_actionPerformed(e);
\r
410 showColourText.setText("Colour Text");
\r
411 showColourText.addActionListener(new ActionListener()
\r
413 public void actionPerformed(ActionEvent e)
\r
415 showColourText_actionPerformed(e);
\r
418 editMenu.setText("Edit");
\r
419 cut.setText("Cut");
\r
420 cut.addActionListener(new ActionListener()
\r
422 public void actionPerformed(ActionEvent e)
\r
424 cut_actionPerformed(e);
\r
427 upperCase.setText("To Upper Case");
\r
428 upperCase.addActionListener(new ActionListener()
\r
430 public void actionPerformed(ActionEvent e)
\r
432 upperCase_actionPerformed(e);
\r
435 copy.setText("Copy");
\r
436 copy.addActionListener(new ActionListener()
\r
438 public void actionPerformed(ActionEvent e)
\r
440 copy_actionPerformed(e);
\r
443 lowerCase.setText("To Lower Case");
\r
444 lowerCase.addActionListener(new ActionListener()
\r
446 public void actionPerformed(ActionEvent e)
\r
448 lowerCase_actionPerformed(e);
\r
451 toggle.setText("Toggle Case");
\r
452 toggle.addActionListener(new ActionListener()
\r
454 public void actionPerformed(ActionEvent e)
\r
456 toggle_actionPerformed(e);
\r
461 this.add(editMenu);
\r
462 groupMenu.add(groupName);
\r
463 groupMenu.addSeparator();
\r
464 groupMenu.add(unGroupMenuItem);
\r
465 groupMenu.add(colourMenu);
\r
466 groupMenu.addSeparator();
\r
467 groupMenu.add(showBoxes);
\r
468 groupMenu.add(showText);
\r
469 groupMenu.add(showColourText);
\r
470 groupMenu.addSeparator();
\r
471 groupMenu.add(outline);
\r
472 sequenceMenu.add(sequenceName);
\r
473 colourMenu.add(noColourmenuItem);
\r
474 colourMenu.add(clustalColour);
\r
475 colourMenu.add(BLOSUM62Colour);
\r
476 colourMenu.add(PIDColour);
\r
477 colourMenu.add(zappoColour);
\r
478 colourMenu.add(taylorColour);
\r
479 colourMenu.add(hydrophobicityColour);
\r
480 colourMenu.add(helixColour);
\r
481 colourMenu.add(strandColour);
\r
482 colourMenu.add(turnColour);
\r
483 colourMenu.add(buriedColour);
\r
484 colourMenu.add(nucleotideMenuItem);
\r
485 colourMenu.add(userDefinedColour);
\r
487 if(jalview.gui.UserDefinedColours.getUserColourSchemes()!=null)
\r
489 java.util.Enumeration userColours = jalview.gui.UserDefinedColours.
\r
490 getUserColourSchemes().keys();
\r
492 while (userColours.hasMoreElements())
\r
494 JMenuItem item = new JMenuItem(userColours.
\r
495 nextElement().toString());
\r
496 item.addActionListener(new ActionListener()
\r
498 public void actionPerformed(ActionEvent evt)
\r
500 userDefinedColour_actionPerformed(evt);
\r
503 colourMenu.add(item);
\r
508 colourMenu.addSeparator();
\r
509 colourMenu.add(abovePIDColour);
\r
510 colourMenu.add(conservationMenuItem);
\r
511 editMenu.add(copy);
\r
513 editMenu.add(upperCase);
\r
514 editMenu.add(lowerCase);
\r
515 editMenu.add(toggle);
\r
516 noColourmenuItem.setText("None");
\r
517 noColourmenuItem.addActionListener(new java.awt.event.ActionListener()
\r
519 public void actionPerformed(ActionEvent e)
\r
521 noColourmenuItem_actionPerformed(e);
\r
525 clustalColour.setText("Clustalx colours");
\r
526 clustalColour.addActionListener(new java.awt.event.ActionListener()
\r
528 public void actionPerformed(ActionEvent e)
\r
530 clustalColour_actionPerformed(e);
\r
533 zappoColour.setText("Zappo");
\r
534 zappoColour.addActionListener(new java.awt.event.ActionListener()
\r
536 public void actionPerformed(ActionEvent e)
\r
538 zappoColour_actionPerformed(e);
\r
541 taylorColour.setText("Taylor");
\r
542 taylorColour.addActionListener(new java.awt.event.ActionListener()
\r
544 public void actionPerformed(ActionEvent e)
\r
546 taylorColour_actionPerformed(e);
\r
549 hydrophobicityColour.setText("Hydrophobicity");
\r
550 hydrophobicityColour.addActionListener(new java.awt.event.ActionListener()
\r
552 public void actionPerformed(ActionEvent e)
\r
554 hydrophobicityColour_actionPerformed(e);
\r
557 helixColour.setText("Helix propensity");
\r
558 helixColour.addActionListener(new java.awt.event.ActionListener()
\r
560 public void actionPerformed(ActionEvent e)
\r
562 helixColour_actionPerformed(e);
\r
565 strandColour.setText("Strand propensity");
\r
566 strandColour.addActionListener(new java.awt.event.ActionListener()
\r
568 public void actionPerformed(ActionEvent e)
\r
570 strandColour_actionPerformed(e);
\r
573 turnColour.setText("Turn propensity");
\r
574 turnColour.addActionListener(new java.awt.event.ActionListener()
\r
576 public void actionPerformed(ActionEvent e)
\r
578 turnColour_actionPerformed(e);
\r
581 buriedColour.setText("Buried Index");
\r
582 buriedColour.addActionListener(new java.awt.event.ActionListener()
\r
584 public void actionPerformed(ActionEvent e)
\r
586 buriedColour_actionPerformed(e);
\r
589 abovePIDColour.setText("Above % Identity");
\r
590 abovePIDColour.addActionListener(new java.awt.event.ActionListener()
\r
592 public void actionPerformed(ActionEvent e)
\r
594 abovePIDColour_actionPerformed(e);
\r
597 userDefinedColour.setText("User Defined...");
\r
598 userDefinedColour.addActionListener(new java.awt.event.ActionListener()
\r
600 public void actionPerformed(ActionEvent e)
\r
602 userDefinedColour_actionPerformed(e);
\r
605 PIDColour.setText("Percentage Identity");
\r
606 PIDColour.addActionListener(new java.awt.event.ActionListener()
\r
608 public void actionPerformed(ActionEvent e)
\r
610 PIDColour_actionPerformed(e);
\r
613 BLOSUM62Colour.setText("BLOSUM62");
\r
614 BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener()
\r
616 public void actionPerformed(ActionEvent e)
\r
618 BLOSUM62Colour_actionPerformed(e);
\r
621 conservationMenuItem.setText("Conservation");
\r
622 conservationMenuItem.addActionListener(new java.awt.event.ActionListener()
\r
624 public void actionPerformed(ActionEvent e)
\r
626 conservationMenuItem_actionPerformed(e);
\r
636 if (ap.overviewPanel != null)
\r
637 ap.overviewPanel.updateOverviewImage();
\r
639 ap.seqPanel.repaint();
\r
645 * @param e DOCUMENT ME!
\r
647 protected void clustalColour_actionPerformed(ActionEvent e)
\r
649 SequenceGroup sg = getGroup();
\r
650 sg.cs = new ClustalxColourScheme(sg.getSequences(true),
\r
651 ap.av.alignment.getWidth());
\r
658 * @param e DOCUMENT ME!
\r
660 protected void zappoColour_actionPerformed(ActionEvent e)
\r
662 getGroup().cs = new ZappoColourScheme();
\r
669 * @param e DOCUMENT ME!
\r
671 protected void taylorColour_actionPerformed(ActionEvent e)
\r
673 getGroup().cs = new TaylorColourScheme();
\r
680 * @param e DOCUMENT ME!
\r
682 protected void hydrophobicityColour_actionPerformed(ActionEvent e)
\r
684 getGroup().cs = new HydrophobicColourScheme();
\r
691 * @param e DOCUMENT ME!
\r
693 protected void helixColour_actionPerformed(ActionEvent e)
\r
695 getGroup().cs = new HelixColourScheme();
\r
702 * @param e DOCUMENT ME!
\r
704 protected void strandColour_actionPerformed(ActionEvent e)
\r
706 getGroup().cs = new StrandColourScheme();
\r
713 * @param e DOCUMENT ME!
\r
715 protected void turnColour_actionPerformed(ActionEvent e)
\r
717 getGroup().cs = new TurnColourScheme();
\r
724 * @param e DOCUMENT ME!
\r
726 protected void buriedColour_actionPerformed(ActionEvent e)
\r
728 getGroup().cs = new BuriedColourScheme();
\r
735 * @param e DOCUMENT ME!
\r
737 public void nucleotideMenuItem_actionPerformed(ActionEvent e)
\r
739 getGroup().cs = new NucleotideColourScheme();
\r
746 * @param e DOCUMENT ME!
\r
748 protected void abovePIDColour_actionPerformed(ActionEvent e)
\r
750 SequenceGroup sg = getGroup();
\r
754 if (abovePIDColour.isSelected())
\r
756 sg.cs.setConsensus(AAFrequency.calculate(
\r
757 sg.getSequences(true), 0,
\r
758 ap.av.alignment.getWidth()));
\r
760 int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs,
\r
761 getGroup().getName());
\r
763 sg.cs.setThreshold(threshold, ap.av.getIgnoreGapsConsensus());
\r
765 SliderPanel.showPIDSlider();
\r
767 else // remove PIDColouring
\r
769 sg.cs.setThreshold(0, ap.av.getIgnoreGapsConsensus());
\r
778 * @param e DOCUMENT ME!
\r
780 protected void userDefinedColour_actionPerformed(ActionEvent e)
\r
782 SequenceGroup sg = getGroup();
\r
784 if (e.getActionCommand().equals("User Defined..."))
\r
785 new UserDefinedColours(ap, sg);
\r
788 UserColourScheme udc = (UserColourScheme) UserDefinedColours.
\r
789 getUserColourSchemes().get(e.getActionCommand());
\r
797 * @param e DOCUMENT ME!
\r
799 protected void PIDColour_actionPerformed(ActionEvent e)
\r
801 SequenceGroup sg = getGroup();
\r
802 sg.cs = new PIDColourScheme();
\r
803 sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(true), 0,
\r
804 ap.av.alignment.getWidth()));
\r
811 * @param e DOCUMENT ME!
\r
813 protected void BLOSUM62Colour_actionPerformed(ActionEvent e)
\r
815 SequenceGroup sg = getGroup();
\r
817 sg.cs = new Blosum62ColourScheme();
\r
819 sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(true), 0,
\r
820 ap.av.alignment.getWidth()));
\r
828 * @param e DOCUMENT ME!
\r
830 protected void noColourmenuItem_actionPerformed(ActionEvent e)
\r
832 getGroup().cs = null;
\r
839 * @param e DOCUMENT ME!
\r
841 protected void conservationMenuItem_actionPerformed(ActionEvent e)
\r
843 SequenceGroup sg = getGroup();
\r
847 if (conservationMenuItem.isSelected())
\r
849 Conservation c = new Conservation("Group",
\r
850 ResidueProperties.propHash, 3,
\r
851 sg.getSequences(true), 0,
\r
852 ap.av.alignment.getWidth());
\r
855 c.verdict(false, ap.av.ConsPercGaps);
\r
857 sg.cs.setConservation(c);
\r
859 SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
\r
860 SliderPanel.showConservationSlider();
\r
862 else // remove ConservationColouring
\r
864 sg.cs.setConservation(null);
\r
873 * @param e DOCUMENT ME!
\r
875 protected void groupName_actionPerformed(ActionEvent e)
\r
877 SequenceGroup sg = getGroup();
\r
878 String reply = JOptionPane.showInternalInputDialog(Desktop.desktop,
\r
879 "Enter new group name", "Edit group name",
\r
880 JOptionPane.QUESTION_MESSAGE);
\r
888 groupName.setText(reply);
\r
894 * @param e DOCUMENT ME!
\r
896 protected void analyze_actionPerformed(ActionEvent e)
\r
898 CutAndPasteTransfer cap = new CutAndPasteTransfer();
\r
899 JInternalFrame frame = new JInternalFrame();
\r
900 frame.setContentPane(cap);
\r
901 Desktop.addInternalFrame(frame, "Analyze this - ", 400, 300);
\r
903 SequenceGroup sg = getGroup();
\r
904 StringBuffer sb = new StringBuffer();
\r
906 for (int i = 0; i < sg.getSize(false); i++)
\r
908 Sequence tmp = (Sequence) sg.getSequences(false).elementAt(i);
\r
909 sb.append(tmp.getSequence(sg.getStartRes(), sg.getEndRes() + 1));
\r
913 sb.append("Something amazing will happen soon");
\r
914 cap.setText(sb.toString());
\r
920 * @return DOCUMENT ME!
\r
922 SequenceGroup getGroup()
\r
924 SequenceGroup sg = ap.av.getSelectionGroup();
\r
925 // this method won't add a new group if it already exists
\r
927 ap.av.alignment.addGroup(sg);
\r
935 * @param e DOCUMENT ME!
\r
937 void sequenceName_actionPerformed(ActionEvent e)
\r
939 JLabel idlabel = new JLabel( " Sequence Name ");
\r
940 JLabel desclabel = new JLabel("Sequence Description ");
\r
941 idlabel.setFont(new Font("Courier", Font.PLAIN, 12));
\r
942 desclabel.setFont(new Font("Courier", Font.PLAIN, 12));
\r
943 JTextField id = new JTextField(sequence.getName(), 40);
\r
944 JTextField description = new JTextField(sequence.getDescription(), 40);
\r
945 JPanel panel = new JPanel(new BorderLayout());
\r
946 JPanel panel2 = new JPanel(new BorderLayout());
\r
947 panel2.add(idlabel, BorderLayout.WEST);
\r
948 panel2.add(id, BorderLayout.CENTER);
\r
949 panel.add(panel2, BorderLayout.NORTH);
\r
950 panel2 = new JPanel(new BorderLayout());
\r
951 panel2.add(desclabel, BorderLayout.WEST);
\r
952 panel2.add(description, BorderLayout.CENTER);
\r
953 panel.add(panel2, BorderLayout.SOUTH);
\r
956 int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
\r
957 panel, "Edit Sequence Name/Description",
\r
958 JOptionPane.OK_CANCEL_OPTION );
\r
961 if (reply != JOptionPane.OK_OPTION )
\r
966 String s = id.getText();
\r
970 if (s.indexOf(" ") > -1)
\r
972 JOptionPane.showMessageDialog(ap,
\r
973 "Spaces have been converted to \"_\"",
\r
974 "No spaces allowed in Sequence Name",
\r
975 JOptionPane.WARNING_MESSAGE);
\r
978 s = s.replace(' ', '_');
\r
979 sequence.getDatasetSequence().setName(s);
\r
980 sequence.setName(s);
\r
984 sequence.getDatasetSequence().setDescription(description.getText());
\r
985 sequence.setDescription(description.getText());
\r
991 * @param e DOCUMENT ME!
\r
993 void unGroupMenuItem_actionPerformed(ActionEvent e)
\r
995 SequenceGroup sg = ap.av.getSelectionGroup();
\r
996 ap.av.alignment.deleteGroup(sg);
\r
997 ap.av.setSelectionGroup(null);
\r
1005 * @param e DOCUMENT ME!
\r
1007 protected void outline_actionPerformed(ActionEvent e)
\r
1009 SequenceGroup sg = getGroup();
\r
1010 Color col = JColorChooser.showDialog(this, "Select Outline Colour",
\r
1015 sg.setOutlineColour(col);
\r
1024 * @param e DOCUMENT ME!
\r
1026 public void showBoxes_actionPerformed(ActionEvent e)
\r
1028 getGroup().setDisplayBoxes(showBoxes.isSelected());
\r
1035 * @param e DOCUMENT ME!
\r
1037 public void showText_actionPerformed(ActionEvent e)
\r
1039 getGroup().setDisplayText(showText.isSelected());
\r
1046 * @param e DOCUMENT ME!
\r
1048 public void showColourText_actionPerformed(ActionEvent e)
\r
1050 getGroup().setColourText(showColourText.isSelected());
\r
1054 public void showLink(String url)
\r
1058 jalview.util.BrowserLauncher.openURL(url);
\r
1060 catch (Exception ex)
\r
1062 JOptionPane.showInternalMessageDialog(Desktop.desktop,
\r
1063 "Unixers: Couldn't find default web browser."
\r
1064 +"\nAdd the full path to your browser in Preferences.",
\r
1065 "Web browser not found", JOptionPane.WARNING_MESSAGE );
\r
1068 ex.printStackTrace();
\r
1072 void hideSequences(boolean representGroup)
\r
1074 SequenceGroup sg = ap.av.getSelectionGroup();
\r
1075 if(sg==null || sg.getSize(false)<1)
\r
1077 ap.av.hideSequence(sequence);
\r
1082 while(index < sg.getSize(false))
\r
1084 if(representGroup && sg.getSequenceAt(index)!=sequence)
\r
1086 sequence.addHiddenSequence(sg.getSequenceAt(index));
\r
1087 ap.av.hideSequence(sg.getSequenceAt(index));
\r
1089 else if(!representGroup)
\r
1091 ap.av.hideSequence(sg.getSequenceAt(index));
\r
1096 ap.av.setSelectionGroup(null);
\r
1100 public void copy_actionPerformed(ActionEvent e)
\r
1102 ap.alignFrame.copy_actionPerformed(null);
\r
1105 public void cut_actionPerformed(ActionEvent e)
\r
1107 ap.alignFrame.cut_actionPerformed(null);
\r
1110 public void upperCase_actionPerformed(ActionEvent e)
\r
1112 SequenceGroup sg = ap.av.getSelectionGroup();
\r
1116 for(int g=0; g<sg.getSize(true); g++)
\r
1118 ( (SequenceI)sg.getSequences(true).elementAt(g))
\r
1119 .changeCase(true, sg.getStartRes(), sg.getEndRes()+1);
\r
1124 public void lowerCase_actionPerformed(ActionEvent e)
\r
1126 SequenceGroup sg = ap.av.getSelectionGroup();
\r
1130 for(int g=0; g<sg.getSize(true); g++)
\r
1132 ( (SequenceI)sg.getSequences(true).elementAt(g))
\r
1133 .changeCase(false, sg.getStartRes(), sg.getEndRes()+1);
\r
1138 public void toggle_actionPerformed(ActionEvent e)
\r
1140 SequenceGroup sg = ap.av.getSelectionGroup();
\r
1144 for (int g = 0; g < sg.getSize(true); g++)
\r
1146 ( (SequenceI)sg.getSequences(true).elementAt(g))
\r
1147 .toggleCase(sg.getStartRes(), sg.getEndRes() + 1);
\r