added help and documentation for annotation editing.
[jalview.git] / src / jalview / gui / PopupMenu.java
1 /*\r
2  * Jalview - A Sequence Alignment Editor and Viewer\r
3  * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
4  *\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
9  *\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
14  *\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
18  */\r
19 package jalview.gui;\r
20 \r
21 import MCview.*;\r
22 \r
23 import jalview.analysis.*;\r
24 \r
25 import jalview.datamodel.*;\r
26 \r
27 import jalview.io.*;\r
28 \r
29 import jalview.schemes.*;\r
30 \r
31 import java.awt.*;\r
32 import java.awt.event.*;\r
33 \r
34 import javax.swing.*;\r
35 \r
36 \r
37 /**\r
38  * DOCUMENT ME!\r
39  *\r
40  * @author $author$\r
41  * @version $Revision$\r
42  */\r
43 public class PopupMenu extends JPopupMenu\r
44 {\r
45     JMenu groupMenu = new JMenu();\r
46     JMenuItem groupName = new JMenuItem();\r
47     protected JRadioButtonMenuItem clustalColour = new JRadioButtonMenuItem();\r
48     protected JRadioButtonMenuItem zappoColour = new JRadioButtonMenuItem();\r
49     protected JRadioButtonMenuItem taylorColour = new JRadioButtonMenuItem();\r
50     protected JRadioButtonMenuItem hydrophobicityColour = new JRadioButtonMenuItem();\r
51     protected JRadioButtonMenuItem helixColour = new JRadioButtonMenuItem();\r
52     protected JRadioButtonMenuItem strandColour = new JRadioButtonMenuItem();\r
53     protected JRadioButtonMenuItem turnColour = new JRadioButtonMenuItem();\r
54     protected JRadioButtonMenuItem buriedColour = new JRadioButtonMenuItem();\r
55     protected JCheckBoxMenuItem abovePIDColour = new JCheckBoxMenuItem();\r
56     protected JRadioButtonMenuItem userDefinedColour = new JRadioButtonMenuItem();\r
57     protected JRadioButtonMenuItem PIDColour = new JRadioButtonMenuItem();\r
58     protected JRadioButtonMenuItem BLOSUM62Colour = new JRadioButtonMenuItem();\r
59     JRadioButtonMenuItem noColourmenuItem = new JRadioButtonMenuItem();\r
60     protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem();\r
61     AlignmentPanel ap;\r
62     JMenu sequenceMenu = new JMenu();\r
63     JMenuItem sequenceName = new JMenuItem();\r
64     Sequence sequence;\r
65     JMenuItem unGroupMenuItem = new JMenuItem();\r
66     JMenuItem pdbMenuItem = 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 \r
74     /**\r
75      * Creates a new PopupMenu object.\r
76      *\r
77      * @param ap DOCUMENT ME!\r
78      * @param seq DOCUMENT ME!\r
79      */\r
80     public PopupMenu(AlignmentPanel ap, Sequence seq)\r
81     {\r
82         ///////////////////////////////////////////////////////////\r
83         // If this is activated from the sequence panel, the user may want to\r
84         // edit or annotate a particular residue. Therefore display the residue menu\r
85         //\r
86         // If from the IDPanel, we must display the sequence menu\r
87         //////////////////////////////////////////////////////////\r
88         this.ap = ap;\r
89         sequence = seq;\r
90 \r
91         ButtonGroup colours = new ButtonGroup();\r
92         colours.add(noColourmenuItem);\r
93         colours.add(clustalColour);\r
94         colours.add(zappoColour);\r
95         colours.add(taylorColour);\r
96         colours.add(hydrophobicityColour);\r
97         colours.add(helixColour);\r
98         colours.add(strandColour);\r
99         colours.add(turnColour);\r
100         colours.add(buriedColour);\r
101         colours.add(abovePIDColour);\r
102         colours.add(userDefinedColour);\r
103         colours.add(PIDColour);\r
104         colours.add(BLOSUM62Colour);\r
105 \r
106         try\r
107         {\r
108             jbInit();\r
109         }\r
110         catch (Exception e)\r
111         {\r
112             e.printStackTrace();\r
113         }\r
114 \r
115         if ((seq == null) || (seq.getPDBId() == null))\r
116         {\r
117             pdbMenuItem.setVisible(false);\r
118         }\r
119 \r
120         SequenceGroup sg = ap.av.getSelectionGroup();\r
121 \r
122         if (sg != null)\r
123         {\r
124             groupName.setText(sg.getName());\r
125 \r
126             if (sg.cs instanceof ZappoColourScheme)\r
127             {\r
128                 zappoColour.setSelected(true);\r
129             }\r
130             else if (sg.cs instanceof TaylorColourScheme)\r
131             {\r
132                 taylorColour.setSelected(true);\r
133             }\r
134             else if (sg.cs instanceof PIDColourScheme)\r
135             {\r
136                 PIDColour.setSelected(true);\r
137             }\r
138             else if (sg.cs instanceof Blosum62ColourScheme)\r
139             {\r
140                 BLOSUM62Colour.setSelected(true);\r
141             }\r
142             else if (sg.cs instanceof UserColourScheme)\r
143             {\r
144                 userDefinedColour.setSelected(true);\r
145             }\r
146             else if (sg.cs instanceof HydrophobicColourScheme)\r
147             {\r
148                 hydrophobicityColour.setSelected(true);\r
149             }\r
150             else if (sg.cs instanceof HelixColourScheme)\r
151             {\r
152                 helixColour.setSelected(true);\r
153             }\r
154             else if (sg.cs instanceof StrandColourScheme)\r
155             {\r
156                 strandColour.setSelected(true);\r
157             }\r
158             else if (sg.cs instanceof TurnColourScheme)\r
159             {\r
160                 turnColour.setSelected(true);\r
161             }\r
162             else if (sg.cs instanceof BuriedColourScheme)\r
163             {\r
164                 buriedColour.setSelected(true);\r
165             }\r
166             else if (sg.cs instanceof ClustalxColourScheme)\r
167             {\r
168                 clustalColour.setSelected(true);\r
169             }\r
170             else\r
171             {\r
172                 noColourmenuItem.setSelected(true);\r
173             }\r
174 \r
175             if (sg.cs instanceof ConservationColourScheme)\r
176             {\r
177                 conservationMenuItem.setSelected(true);\r
178             }\r
179 \r
180             showText.setSelected(sg.getDisplayText());\r
181             showColourText.setSelected(sg.getColourText());\r
182             showBoxes.setSelected(sg.getDisplayBoxes());\r
183         }\r
184 \r
185         if (!ap.av.alignment.getGroups().contains(sg))\r
186         {\r
187             unGroupMenuItem.setVisible(false);\r
188         }\r
189         else\r
190         {\r
191             groupMenu.insertSeparator(3);\r
192         }\r
193 \r
194         if (seq == null)\r
195         {\r
196             sequenceMenu.setVisible(false);\r
197         }\r
198     }\r
199 \r
200     /**\r
201      * DOCUMENT ME!\r
202      *\r
203      * @throws Exception DOCUMENT ME!\r
204      */\r
205     private void jbInit() throws Exception\r
206     {\r
207         groupMenu.setText("Group");\r
208         groupMenu.setText("Define");\r
209         groupName.setText("Name");\r
210         groupName.addActionListener(new java.awt.event.ActionListener()\r
211             {\r
212                 public void actionPerformed(ActionEvent e)\r
213                 {\r
214                     groupName_actionPerformed(e);\r
215                 }\r
216             });\r
217         sequenceMenu.setText("Sequence");\r
218         sequenceName.setText("Edit name");\r
219         sequenceName.addActionListener(new java.awt.event.ActionListener()\r
220             {\r
221                 public void actionPerformed(ActionEvent e)\r
222                 {\r
223                     sequenceName_actionPerformed(e);\r
224                 }\r
225             });\r
226         PIDColour.setFocusPainted(false);\r
227         unGroupMenuItem.setText("Remove Group");\r
228         unGroupMenuItem.addActionListener(new java.awt.event.ActionListener()\r
229             {\r
230                 public void actionPerformed(ActionEvent e)\r
231                 {\r
232                     unGroupMenuItem_actionPerformed(e);\r
233                 }\r
234             });\r
235         pdbMenuItem.setText("View PDB structure");\r
236         pdbMenuItem.addActionListener(new java.awt.event.ActionListener()\r
237             {\r
238                 public void actionPerformed(ActionEvent e)\r
239                 {\r
240                     pdbMenuItem_actionPerformed(e);\r
241                 }\r
242             });\r
243         outline.setText("Border colour");\r
244         outline.addActionListener(new java.awt.event.ActionListener()\r
245             {\r
246                 public void actionPerformed(ActionEvent e)\r
247                 {\r
248                     outline_actionPerformed(e);\r
249                 }\r
250             });\r
251         nucleotideMenuItem.setText("Nucleotide");\r
252         nucleotideMenuItem.addActionListener(new ActionListener()\r
253             {\r
254                 public void actionPerformed(ActionEvent e)\r
255                 {\r
256                     nucleotideMenuItem_actionPerformed(e);\r
257                 }\r
258             });\r
259         colourMenu.setText("Group Colour");\r
260         showBoxes.setText("Boxes");\r
261         showBoxes.setState(true);\r
262         showBoxes.addActionListener(new ActionListener()\r
263             {\r
264                 public void actionPerformed(ActionEvent e)\r
265                 {\r
266                     showBoxes_actionPerformed(e);\r
267                 }\r
268             });\r
269         showText.setText("Text");\r
270         showText.setState(true);\r
271         showText.addActionListener(new ActionListener()\r
272             {\r
273                 public void actionPerformed(ActionEvent e)\r
274                 {\r
275                     showText_actionPerformed(e);\r
276                 }\r
277             });\r
278         showColourText.setText("Colour Text");\r
279         showColourText.addActionListener(new ActionListener()\r
280             {\r
281                 public void actionPerformed(ActionEvent e)\r
282                 {\r
283                     showColourText_actionPerformed(e);\r
284                 }\r
285             });\r
286         add(groupMenu);\r
287         add(sequenceMenu);\r
288         groupMenu.add(groupName);\r
289         groupMenu.addSeparator();\r
290         groupMenu.add(unGroupMenuItem);\r
291         groupMenu.add(colourMenu);\r
292         groupMenu.addSeparator();\r
293         groupMenu.add(showBoxes);\r
294         groupMenu.add(showText);\r
295         groupMenu.add(showColourText);\r
296         groupMenu.addSeparator();\r
297         groupMenu.add(outline);\r
298         sequenceMenu.add(sequenceName);\r
299         sequenceMenu.add(pdbMenuItem);\r
300         colourMenu.add(noColourmenuItem);\r
301         colourMenu.add(clustalColour);\r
302         colourMenu.add(BLOSUM62Colour);\r
303         colourMenu.add(PIDColour);\r
304         colourMenu.add(zappoColour);\r
305         colourMenu.add(taylorColour);\r
306         colourMenu.add(hydrophobicityColour);\r
307         colourMenu.add(helixColour);\r
308         colourMenu.add(strandColour);\r
309         colourMenu.add(turnColour);\r
310         colourMenu.add(buriedColour);\r
311         colourMenu.add(nucleotideMenuItem);\r
312         colourMenu.add(userDefinedColour);\r
313         colourMenu.addSeparator();\r
314         colourMenu.add(abovePIDColour);\r
315         colourMenu.add(conservationMenuItem);\r
316         noColourmenuItem.setText("None");\r
317         noColourmenuItem.addActionListener(new java.awt.event.ActionListener()\r
318             {\r
319                 public void actionPerformed(ActionEvent e)\r
320                 {\r
321                     noColourmenuItem_actionPerformed(e);\r
322                 }\r
323             });\r
324 \r
325         clustalColour.setText("Clustalx colours");\r
326         clustalColour.addActionListener(new java.awt.event.ActionListener()\r
327             {\r
328                 public void actionPerformed(ActionEvent e)\r
329                 {\r
330                     clustalColour_actionPerformed(e);\r
331                 }\r
332             });\r
333         zappoColour.setText("Zappo");\r
334         zappoColour.addActionListener(new java.awt.event.ActionListener()\r
335             {\r
336                 public void actionPerformed(ActionEvent e)\r
337                 {\r
338                     zappoColour_actionPerformed(e);\r
339                 }\r
340             });\r
341         taylorColour.setText("Taylor");\r
342         taylorColour.addActionListener(new java.awt.event.ActionListener()\r
343             {\r
344                 public void actionPerformed(ActionEvent e)\r
345                 {\r
346                     taylorColour_actionPerformed(e);\r
347                 }\r
348             });\r
349         hydrophobicityColour.setText("Hydrophobicity");\r
350         hydrophobicityColour.addActionListener(new java.awt.event.ActionListener()\r
351             {\r
352                 public void actionPerformed(ActionEvent e)\r
353                 {\r
354                     hydrophobicityColour_actionPerformed(e);\r
355                 }\r
356             });\r
357         helixColour.setText("Helix propensity");\r
358         helixColour.addActionListener(new java.awt.event.ActionListener()\r
359             {\r
360                 public void actionPerformed(ActionEvent e)\r
361                 {\r
362                     helixColour_actionPerformed(e);\r
363                 }\r
364             });\r
365         strandColour.setText("Strand propensity");\r
366         strandColour.addActionListener(new java.awt.event.ActionListener()\r
367             {\r
368                 public void actionPerformed(ActionEvent e)\r
369                 {\r
370                     strandColour_actionPerformed(e);\r
371                 }\r
372             });\r
373         turnColour.setText("Turn propensity");\r
374         turnColour.addActionListener(new java.awt.event.ActionListener()\r
375             {\r
376                 public void actionPerformed(ActionEvent e)\r
377                 {\r
378                     turnColour_actionPerformed(e);\r
379                 }\r
380             });\r
381         buriedColour.setText("Buried Index");\r
382         buriedColour.addActionListener(new java.awt.event.ActionListener()\r
383             {\r
384                 public void actionPerformed(ActionEvent e)\r
385                 {\r
386                     buriedColour_actionPerformed(e);\r
387                 }\r
388             });\r
389         abovePIDColour.setText("Above % Identity");\r
390         abovePIDColour.addActionListener(new java.awt.event.ActionListener()\r
391             {\r
392                 public void actionPerformed(ActionEvent e)\r
393                 {\r
394                     abovePIDColour_actionPerformed(e);\r
395                 }\r
396             });\r
397         userDefinedColour.setText("User Defined");\r
398         userDefinedColour.addActionListener(new java.awt.event.ActionListener()\r
399             {\r
400                 public void actionPerformed(ActionEvent e)\r
401                 {\r
402                     userDefinedColour_actionPerformed(e);\r
403                 }\r
404             });\r
405         PIDColour.setText("Percentage Identity");\r
406         PIDColour.addActionListener(new java.awt.event.ActionListener()\r
407             {\r
408                 public void actionPerformed(ActionEvent e)\r
409                 {\r
410                     PIDColour_actionPerformed(e);\r
411                 }\r
412             });\r
413         BLOSUM62Colour.setText("BLOSUM62");\r
414         BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener()\r
415             {\r
416                 public void actionPerformed(ActionEvent e)\r
417                 {\r
418                     BLOSUM62Colour_actionPerformed(e);\r
419                 }\r
420             });\r
421         conservationMenuItem.setText("Conservation");\r
422         conservationMenuItem.addActionListener(new java.awt.event.ActionListener()\r
423             {\r
424                 public void actionPerformed(ActionEvent e)\r
425                 {\r
426                     conservationMenuItem_actionPerformed(e);\r
427                 }\r
428             });\r
429     }\r
430 \r
431     /**\r
432      * DOCUMENT ME!\r
433      */\r
434     void refresh()\r
435     {\r
436         SequenceGroup sg = getGroup();\r
437         if(sg!=null)\r
438         {\r
439           SuperGroup superG = ap.av.alignment.getSuperGroup(sg);\r
440 \r
441           if (superG != null)\r
442           {\r
443             superG.setSuperGroupProperties(sg);\r
444           }\r
445         }\r
446         ap.seqPanel.repaint();\r
447     }\r
448 \r
449     /**\r
450      * DOCUMENT ME!\r
451      *\r
452      * @param e DOCUMENT ME!\r
453      */\r
454     protected void clustalColour_actionPerformed(ActionEvent e)\r
455     {\r
456         SequenceGroup sg = getGroup();\r
457         sg.cs = new ClustalxColourScheme(sg.sequences,\r
458                 ap.av.alignment.getWidth());\r
459         refresh();\r
460     }\r
461 \r
462     /**\r
463      * DOCUMENT ME!\r
464      *\r
465      * @param e DOCUMENT ME!\r
466      */\r
467     protected void zappoColour_actionPerformed(ActionEvent e)\r
468     {\r
469         getGroup().cs = new ZappoColourScheme();\r
470         refresh();\r
471     }\r
472 \r
473     /**\r
474      * DOCUMENT ME!\r
475      *\r
476      * @param e DOCUMENT ME!\r
477      */\r
478     protected void taylorColour_actionPerformed(ActionEvent e)\r
479     {\r
480         getGroup().cs = new TaylorColourScheme();\r
481         refresh();\r
482     }\r
483 \r
484     /**\r
485      * DOCUMENT ME!\r
486      *\r
487      * @param e DOCUMENT ME!\r
488      */\r
489     protected void hydrophobicityColour_actionPerformed(ActionEvent e)\r
490     {\r
491         getGroup().cs = new HydrophobicColourScheme();\r
492         refresh();\r
493     }\r
494 \r
495     /**\r
496      * DOCUMENT ME!\r
497      *\r
498      * @param e DOCUMENT ME!\r
499      */\r
500     protected void helixColour_actionPerformed(ActionEvent e)\r
501     {\r
502         getGroup().cs = new HelixColourScheme();\r
503         refresh();\r
504     }\r
505 \r
506     /**\r
507      * DOCUMENT ME!\r
508      *\r
509      * @param e DOCUMENT ME!\r
510      */\r
511     protected void strandColour_actionPerformed(ActionEvent e)\r
512     {\r
513         getGroup().cs = new StrandColourScheme();\r
514         refresh();\r
515     }\r
516 \r
517     /**\r
518      * DOCUMENT ME!\r
519      *\r
520      * @param e DOCUMENT ME!\r
521      */\r
522     protected void turnColour_actionPerformed(ActionEvent e)\r
523     {\r
524         getGroup().cs = new TurnColourScheme();\r
525         refresh();\r
526     }\r
527 \r
528     /**\r
529      * DOCUMENT ME!\r
530      *\r
531      * @param e DOCUMENT ME!\r
532      */\r
533     protected void buriedColour_actionPerformed(ActionEvent e)\r
534     {\r
535         getGroup().cs = new BuriedColourScheme();\r
536         refresh();\r
537     }\r
538 \r
539     /**\r
540      * DOCUMENT ME!\r
541      *\r
542      * @param e DOCUMENT ME!\r
543      */\r
544     public void nucleotideMenuItem_actionPerformed(ActionEvent e)\r
545     {\r
546         getGroup().cs = new NucleotideColourScheme();\r
547         refresh();\r
548     }\r
549 \r
550     /**\r
551      * DOCUMENT ME!\r
552      *\r
553      * @param e DOCUMENT ME!\r
554      */\r
555     protected void abovePIDColour_actionPerformed(ActionEvent e)\r
556     {\r
557         SequenceGroup sg = getGroup();\r
558 \r
559         if (abovePIDColour.isSelected())\r
560         {\r
561             sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0,\r
562                     ap.av.alignment.getWidth()));\r
563 \r
564             int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs,\r
565                     getGroup().getName());\r
566 \r
567             if (sg.cs instanceof ResidueColourScheme)\r
568             {\r
569                 ((ResidueColourScheme) sg.cs).setThreshold(threshold);\r
570             }\r
571             else if (sg.cs instanceof ScoreColourScheme)\r
572             {\r
573                 ((ScoreColourScheme) sg.cs).setThreshold(threshold);\r
574             }\r
575 \r
576             SliderPanel.showPIDSlider();\r
577         }\r
578         else // remove PIDColouring\r
579         {\r
580             ResidueColourScheme rcs = (ResidueColourScheme) sg.cs;\r
581             rcs.setThreshold(0);\r
582             sg.cs = rcs;\r
583         }\r
584 \r
585         refresh();\r
586     }\r
587 \r
588     /**\r
589      * DOCUMENT ME!\r
590      *\r
591      * @param e DOCUMENT ME!\r
592      */\r
593     protected void userDefinedColour_actionPerformed(ActionEvent e)\r
594     {\r
595         new UserDefinedColours(ap, getGroup());\r
596     }\r
597 \r
598     /**\r
599      * DOCUMENT ME!\r
600      *\r
601      * @param e DOCUMENT ME!\r
602      */\r
603     protected void PIDColour_actionPerformed(ActionEvent e)\r
604     {\r
605         SequenceGroup sg = getGroup();\r
606         sg.cs = new PIDColourScheme();\r
607         sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0,\r
608                 ap.av.alignment.getWidth()));\r
609         refresh();\r
610     }\r
611 \r
612     /**\r
613      * DOCUMENT ME!\r
614      *\r
615      * @param e DOCUMENT ME!\r
616      */\r
617     protected void BLOSUM62Colour_actionPerformed(ActionEvent e)\r
618     {\r
619         SequenceGroup sg = getGroup();\r
620 \r
621         sg.cs = new Blosum62ColourScheme();\r
622 \r
623         sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0,\r
624                 ap.av.alignment.getWidth()));\r
625 \r
626         refresh();\r
627     }\r
628 \r
629     /**\r
630      * DOCUMENT ME!\r
631      *\r
632      * @param e DOCUMENT ME!\r
633      */\r
634     protected void noColourmenuItem_actionPerformed(ActionEvent e)\r
635     {\r
636         getGroup().cs = null;\r
637         refresh();\r
638     }\r
639 \r
640     /**\r
641      * DOCUMENT ME!\r
642      *\r
643      * @param e DOCUMENT ME!\r
644      */\r
645     protected void conservationMenuItem_actionPerformed(ActionEvent e)\r
646     {\r
647         SequenceGroup sg = getGroup();\r
648 \r
649         if (conservationMenuItem.isSelected())\r
650         {\r
651             Conservation c = new Conservation("Group",\r
652                     ResidueProperties.propHash, 3, sg.sequences, 0,\r
653                     ap.av.alignment.getWidth());\r
654 \r
655             c.calculate();\r
656             c.verdict(false, ap.av.ConsPercGaps);\r
657 \r
658             ConservationColourScheme ccs = new ConservationColourScheme(c, sg.cs);\r
659 \r
660             sg.cs = ccs;\r
661 \r
662             SliderPanel.setConservationSlider(ap, ccs, sg.getName());\r
663             SliderPanel.showConservationSlider();\r
664         }\r
665         else // remove ConservationColouring\r
666         {\r
667             ConservationColourScheme ccs = (ConservationColourScheme) sg.cs;\r
668             sg.cs = ccs.cs;\r
669         }\r
670 \r
671         refresh();\r
672     }\r
673 \r
674     /**\r
675      * DOCUMENT ME!\r
676      *\r
677      * @param e DOCUMENT ME!\r
678      */\r
679     protected void groupName_actionPerformed(ActionEvent e)\r
680     {\r
681         SequenceGroup sg = getGroup();\r
682         String reply = JOptionPane.showInternalInputDialog(Desktop.desktop,\r
683                 "Enter new group name", "Edit group name",\r
684                 JOptionPane.QUESTION_MESSAGE);\r
685 \r
686         if (reply == null)\r
687         {\r
688             return;\r
689         }\r
690 \r
691         sg.setName(reply);\r
692         groupName.setText(reply);\r
693     }\r
694 \r
695     /**\r
696      * DOCUMENT ME!\r
697      *\r
698      * @param e DOCUMENT ME!\r
699      */\r
700     protected void analyze_actionPerformed(ActionEvent e)\r
701     {\r
702         CutAndPasteTransfer cap = new CutAndPasteTransfer();\r
703         JInternalFrame frame = new JInternalFrame();\r
704         frame.setContentPane(cap);\r
705         Desktop.addInternalFrame(frame, "Analyze this - ", 400, 300);\r
706 \r
707         SequenceGroup sg = getGroup();\r
708         StringBuffer sb = new StringBuffer();\r
709 \r
710         for (int i = 0; i < sg.sequences.size(); i++)\r
711         {\r
712             Sequence tmp = (Sequence) sg.sequences.get(i);\r
713             sb.append(tmp.getSequence(sg.getStartRes(), sg.getEndRes() + 1));\r
714             sb.append("\n");\r
715         }\r
716 \r
717         sb.append("Something amazing will happen soon");\r
718         cap.setText(sb.toString());\r
719     }\r
720 \r
721     /**\r
722      * DOCUMENT ME!\r
723      *\r
724      * @return DOCUMENT ME!\r
725      */\r
726     SequenceGroup getGroup()\r
727     {\r
728         SequenceGroup sg = ap.av.getSelectionGroup();\r
729       // this method won't add a new group if it already exists\r
730         if(sg!=null)\r
731           ap.av.alignment.addGroup(sg);\r
732 \r
733         return sg;\r
734     }\r
735 \r
736     /**\r
737      * DOCUMENT ME!\r
738      *\r
739      * @param e DOCUMENT ME!\r
740      */\r
741     void sequenceName_actionPerformed(ActionEvent e)\r
742     {\r
743         String id = sequence.getName();\r
744         String s = (String) JOptionPane.showInternalInputDialog(ap,\r
745                 "Edit sequence name",\r
746                 "Edit sequence name (" + sequence.getName() + ")",\r
747                 JOptionPane.PLAIN_MESSAGE, null, null, id);\r
748 \r
749         if (s != null)\r
750         {\r
751             if (s.indexOf(" ") > -1)\r
752             {\r
753                 JOptionPane.showMessageDialog(ap,\r
754                     "Spaces have been converted to \"_\"",\r
755                     "No spaces allowed in Sequence Name",\r
756                     JOptionPane.WARNING_MESSAGE);\r
757             }\r
758 \r
759             s = s.replace(' ', '_');\r
760             sequence.setName(s);\r
761             ap.repaint();\r
762         }\r
763     }\r
764 \r
765     /**\r
766      * DOCUMENT ME!\r
767      *\r
768      * @param e DOCUMENT ME!\r
769      */\r
770     void unGroupMenuItem_actionPerformed(ActionEvent e)\r
771     {\r
772         SequenceGroup sg = ap.av.getSelectionGroup();\r
773         ap.av.alignment.deleteGroup(sg);\r
774         ap.av.setSelectionGroup(null);\r
775         refresh();\r
776     }\r
777 \r
778     /**\r
779      * DOCUMENT ME!\r
780      *\r
781      * @param e DOCUMENT ME!\r
782      */\r
783     void pdbMenuItem_actionPerformed(ActionEvent e)\r
784     {\r
785         if (sequence.getPDBId() == null)\r
786         {\r
787             return;\r
788         }\r
789 \r
790         try\r
791         {\r
792             EBIFetchClient ebi = new EBIFetchClient();\r
793             String[] result = ebi.fetchData("pdb:" + sequence.getPDBId(), null,\r
794                     null);\r
795 \r
796             PDBfile pdb = new PDBfile(result);\r
797 \r
798             rotCanvas rc = new rotCanvas(pdb, sequence, ap.av);\r
799             JInternalFrame frame = new JInternalFrame();\r
800             frame.setContentPane(rc);\r
801             Desktop.addInternalFrame(frame,\r
802                 sequence.getName() + " " + sequence.getPDBId(), 400, 400);\r
803         }\r
804         catch (Exception ex)\r
805         {\r
806             ex.printStackTrace();\r
807         }\r
808     }\r
809 \r
810     /**\r
811      * DOCUMENT ME!\r
812      *\r
813      * @param e DOCUMENT ME!\r
814      */\r
815     protected void outline_actionPerformed(ActionEvent e)\r
816     {\r
817         SequenceGroup sg = getGroup();\r
818         Color col = JColorChooser.showDialog(this, "Select Outline Colour",\r
819                 Color.BLUE);\r
820 \r
821         if (col != null)\r
822         {\r
823             sg.setOutlineColour(col);\r
824         }\r
825 \r
826         refresh();\r
827     }\r
828 \r
829     /**\r
830      * DOCUMENT ME!\r
831      *\r
832      * @param e DOCUMENT ME!\r
833      */\r
834     public void showBoxes_actionPerformed(ActionEvent e)\r
835     {\r
836         getGroup().setDisplayBoxes(showBoxes.isSelected());\r
837         refresh();\r
838     }\r
839 \r
840     /**\r
841      * DOCUMENT ME!\r
842      *\r
843      * @param e DOCUMENT ME!\r
844      */\r
845     public void showText_actionPerformed(ActionEvent e)\r
846     {\r
847         getGroup().setDisplayText(showText.isSelected());\r
848         refresh();\r
849     }\r
850 \r
851     /**\r
852      * DOCUMENT ME!\r
853      *\r
854      * @param e DOCUMENT ME!\r
855      */\r
856     public void showColourText_actionPerformed(ActionEvent e)\r
857     {\r
858         getGroup().setColourText(showColourText.isSelected());\r
859         refresh();\r
860     }\r
861 }\r