2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
26 import java.awt.event.*;
30 import jalview.analysis.*;
31 import jalview.commands.*;
32 import jalview.datamodel.*;
34 import jalview.schemes.*;
35 import jalview.util.GroupUrlLink;
36 import jalview.util.GroupUrlLink.UrlStringTooLongException;
37 import jalview.util.MessageManager;
38 import jalview.util.UrlLink;
44 * @version $Revision: 1.118 $
46 public class PopupMenu extends JPopupMenu
48 JMenu groupMenu = new JMenu();
50 JMenuItem groupName = new JMenuItem();
52 protected JRadioButtonMenuItem clustalColour = new JRadioButtonMenuItem();
54 protected JRadioButtonMenuItem zappoColour = new JRadioButtonMenuItem();
56 protected JRadioButtonMenuItem taylorColour = new JRadioButtonMenuItem();
58 protected JRadioButtonMenuItem hydrophobicityColour = new JRadioButtonMenuItem();
60 protected JRadioButtonMenuItem helixColour = new JRadioButtonMenuItem();
62 protected JRadioButtonMenuItem strandColour = new JRadioButtonMenuItem();
64 protected JRadioButtonMenuItem turnColour = new JRadioButtonMenuItem();
66 protected JRadioButtonMenuItem buriedColour = new JRadioButtonMenuItem();
68 protected JCheckBoxMenuItem abovePIDColour = new JCheckBoxMenuItem();
70 protected JRadioButtonMenuItem userDefinedColour = new JRadioButtonMenuItem();
72 protected JRadioButtonMenuItem PIDColour = new JRadioButtonMenuItem();
74 protected JRadioButtonMenuItem BLOSUM62Colour = new JRadioButtonMenuItem();
76 protected JRadioButtonMenuItem purinePyrimidineColour = new JRadioButtonMenuItem();
78 protected JRadioButtonMenuItem RNAInteractionColour = new JRadioButtonMenuItem();
80 // protected JRadioButtonMenuItem covariationColour = new
81 // JRadioButtonMenuItem();
83 JRadioButtonMenuItem noColourmenuItem = new JRadioButtonMenuItem();
85 protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem();
89 JMenu sequenceMenu = new JMenu();
91 JMenuItem sequenceName = new JMenuItem();
93 JMenuItem sequenceDetails = new JMenuItem();
95 JMenuItem sequenceSelDetails = new JMenuItem();
99 JMenuItem createGroupMenuItem = new JMenuItem();
101 JMenuItem unGroupMenuItem = new JMenuItem();
103 JMenuItem outline = new JMenuItem();
105 JRadioButtonMenuItem nucleotideMenuItem = new JRadioButtonMenuItem();
107 JMenu colourMenu = new JMenu();
109 JCheckBoxMenuItem showBoxes = new JCheckBoxMenuItem();
111 JCheckBoxMenuItem showText = new JCheckBoxMenuItem();
113 JCheckBoxMenuItem showColourText = new JCheckBoxMenuItem();
115 JCheckBoxMenuItem displayNonconserved = new JCheckBoxMenuItem();
117 JMenu editMenu = new JMenu();
119 JMenuItem cut = new JMenuItem();
121 JMenuItem copy = new JMenuItem();
123 JMenuItem upperCase = new JMenuItem();
125 JMenuItem lowerCase = new JMenuItem();
127 JMenuItem toggle = new JMenuItem();
129 JMenu pdbMenu = new JMenu();
131 JMenuItem pdbFromFile = new JMenuItem();
133 // JBPNote: Commented these out - Should add these services via the web
134 // services menu system.
135 // JMenuItem ContraFold = new JMenuItem();
137 // JMenuItem RNAFold = new JMenuItem();
139 JMenuItem enterPDB = new JMenuItem();
141 JMenuItem discoverPDB = new JMenuItem();
143 JMenu outputMenu = new JMenu();
145 JMenuItem sequenceFeature = new JMenuItem();
147 JMenuItem textColour = new JMenuItem();
149 JMenu jMenu1 = new JMenu();
151 JMenu structureMenu = new JMenu();
153 JMenu viewStructureMenu = new JMenu();
155 // JMenu colStructureMenu = new JMenu();
156 JMenuItem editSequence = new JMenuItem();
158 // JMenuItem annotationMenuItem = new JMenuItem();
160 JMenu groupLinksMenu;
163 * Creates a new PopupMenu object.
170 public PopupMenu(final AlignmentPanel ap, Sequence seq, Vector links)
172 this(ap, seq, links, null);
182 public PopupMenu(final AlignmentPanel ap, final SequenceI seq,
183 Vector links, Vector groupLinks)
185 // /////////////////////////////////////////////////////////
186 // If this is activated from the sequence panel, the user may want to
187 // edit or annotate a particular residue. Therefore display the residue menu
189 // If from the IDPanel, we must display the sequence menu
190 // ////////////////////////////////////////////////////////
194 ButtonGroup colours = new ButtonGroup();
195 colours.add(noColourmenuItem);
196 colours.add(clustalColour);
197 colours.add(zappoColour);
198 colours.add(taylorColour);
199 colours.add(hydrophobicityColour);
200 colours.add(helixColour);
201 colours.add(strandColour);
202 colours.add(turnColour);
203 colours.add(buriedColour);
204 colours.add(abovePIDColour);
205 colours.add(userDefinedColour);
206 colours.add(PIDColour);
207 colours.add(BLOSUM62Colour);
208 colours.add(purinePyrimidineColour);
209 colours.add(RNAInteractionColour);
210 // colours.add(covariationColour);
212 for (int i = 0; i < jalview.io.FormatAdapter.WRITEABLE_FORMATS.length; i++)
214 JMenuItem item = new JMenuItem(
215 jalview.io.FormatAdapter.WRITEABLE_FORMATS[i]);
217 item.addActionListener(new java.awt.event.ActionListener()
219 public void actionPerformed(ActionEvent e)
221 outputText_actionPerformed(e);
225 outputMenu.add(item);
231 } catch (Exception e)
239 sequenceMenu.setText(sequence.getName());
241 if (seq.getDatasetSequence().getPDBId() != null
242 && seq.getDatasetSequence().getPDBId().size() > 0)
244 java.util.Enumeration e = seq.getDatasetSequence().getPDBId()
247 while (e.hasMoreElements())
249 final PDBEntry pdb = (PDBEntry) e.nextElement();
251 menuItem = new JMenuItem();
252 menuItem.setText(pdb.getId());
253 menuItem.addActionListener(new java.awt.event.ActionListener()
255 public void actionPerformed(ActionEvent e)
257 // TODO re JAL-860: optionally open dialog or provide a menu entry
258 // allowing user to open just one structure per sequence
259 new AppJmol(pdb, ap.av.collateForPDB(new PDBEntry[]
260 { pdb })[0], null, ap);
261 // new PDBViewer(pdb, seqs2, null, ap, AppletFormatAdapter.FILE);
265 viewStructureMenu.add(menuItem);
268 * menuItem = new JMenuItem(); menuItem.setText(pdb.getId());
269 * menuItem.addActionListener(new java.awt.event.ActionListener() {
270 * public void actionPerformed(ActionEvent e) {
271 * colourByStructure(pdb.getId()); } });
272 * colStructureMenu.add(menuItem);
278 if (ap.av.getAlignment().isNucleotide() == false)
280 structureMenu.remove(viewStructureMenu);
282 // structureMenu.remove(colStructureMenu);
285 if (ap.av.getAlignment().isNucleotide() == true)
287 AlignmentAnnotation[] aa = ap.av.getAlignment()
288 .getAlignmentAnnotation();
289 for (int i = 0; i < aa.length; i++)
291 if (aa[i].getRNAStruc() != null)
293 final String rnastruc = aa[i].getRNAStruc();
294 final String structureLine = aa[i].label;
295 menuItem = new JMenuItem();
296 menuItem.setText(MessageManager.formatMessage(
297 "label.2d_rna_structure_line", new String[]
299 menuItem.addActionListener(new java.awt.event.ActionListener()
302 public void actionPerformed(ActionEvent e)
304 // System.out.println("1:"+structureLine);
305 System.out.println("1:sname" + seq.getName());
306 System.out.println("2:seq" + seq);
308 // System.out.println("3:"+seq.getSequenceAsString());
309 System.out.println("3:strucseq" + rnastruc);
310 // System.out.println("4:struc"+seq.getRNA());
311 System.out.println("5:name" + seq.getName());
312 System.out.println("6:ap" + ap);
313 new AppVarna(structureLine, seq, seq.getSequenceAsString(),
314 rnastruc, seq.getName(), ap);
315 // new AppVarna(seq.getName(),seq,rnastruc,seq.getRNA(),
316 // seq.getName(), ap);
317 System.out.println("end");
320 viewStructureMenu.add(menuItem);
324 // SequenceFeatures[] test = seq.getSequenceFeatures();
326 if (seq.getAnnotation() != null)
328 AlignmentAnnotation seqAnno[] = seq.getAnnotation();
329 for (int i = 0; i < seqAnno.length; i++)
331 if (seqAnno[i].getRNAStruc() != null)
333 final String rnastruc = seqAnno[i].getRNAStruc();
335 // TODO: make rnastrucF a bit more nice
336 menuItem = new JMenuItem();
337 menuItem.setText(MessageManager.formatMessage(
338 "label.2d_rna_sequence_name", new String[]
340 menuItem.addActionListener(new java.awt.event.ActionListener()
342 public void actionPerformed(ActionEvent e)
344 // TODO: VARNA does'nt print gaps in the sequence
346 new AppVarna(seq.getName() + " structure", seq, seq
347 .getSequenceAsString(), rnastruc, seq.getName(),
351 viewStructureMenu.add(menuItem);
358 menuItem = new JMenuItem(
359 MessageManager.getString("action.hide_sequences"));
360 menuItem.addActionListener(new java.awt.event.ActionListener()
362 public void actionPerformed(ActionEvent e)
364 hideSequences(false);
369 if (ap.av.getSelectionGroup() != null
370 && ap.av.getSelectionGroup().getSize() > 1)
372 menuItem = new JMenuItem(MessageManager.formatMessage(
373 "label.represent_group_with", new String[]
375 menuItem.addActionListener(new java.awt.event.ActionListener()
377 public void actionPerformed(ActionEvent e)
382 sequenceMenu.add(menuItem);
385 if (ap.av.hasHiddenRows())
387 final int index = ap.av.getAlignment().findIndex(seq);
389 if (ap.av.adjustForHiddenSeqs(index)
390 - ap.av.adjustForHiddenSeqs(index - 1) > 1)
392 menuItem = new JMenuItem(
393 MessageManager.getString("action.reveal_sequences"));
394 menuItem.addActionListener(new ActionListener()
396 public void actionPerformed(ActionEvent e)
398 ap.av.showSequence(index);
399 if (ap.overviewPanel != null)
401 ap.overviewPanel.updateOverviewImage();
409 // for the case when no sequences are even visible
410 if (ap.av.hasHiddenRows())
413 menuItem = new JMenuItem(
414 MessageManager.getString("action.reveal_all"));
415 menuItem.addActionListener(new ActionListener()
417 public void actionPerformed(ActionEvent e)
419 ap.av.showAllHiddenSeqs();
420 if (ap.overviewPanel != null)
422 ap.overviewPanel.updateOverviewImage();
432 SequenceGroup sg = ap.av.getSelectionGroup();
433 boolean isDefinedGroup = (sg != null) ? ap.av.getAlignment()
434 .getGroups().contains(sg) : false;
436 if (sg != null && sg.getSize() > 0)
438 groupName.setText(MessageManager.formatMessage("label.name_param",
441 groupName.setText(MessageManager
442 .getString("label.edit_name_and_description_current_group"));
444 if (sg.cs instanceof ZappoColourScheme)
446 zappoColour.setSelected(true);
448 else if (sg.cs instanceof TaylorColourScheme)
450 taylorColour.setSelected(true);
452 else if (sg.cs instanceof PIDColourScheme)
454 PIDColour.setSelected(true);
456 else if (sg.cs instanceof Blosum62ColourScheme)
458 BLOSUM62Colour.setSelected(true);
460 else if (sg.cs instanceof UserColourScheme)
462 userDefinedColour.setSelected(true);
464 else if (sg.cs instanceof HydrophobicColourScheme)
466 hydrophobicityColour.setSelected(true);
468 else if (sg.cs instanceof HelixColourScheme)
470 helixColour.setSelected(true);
472 else if (sg.cs instanceof StrandColourScheme)
474 strandColour.setSelected(true);
476 else if (sg.cs instanceof TurnColourScheme)
478 turnColour.setSelected(true);
480 else if (sg.cs instanceof BuriedColourScheme)
482 buriedColour.setSelected(true);
484 else if (sg.cs instanceof ClustalxColourScheme)
486 clustalColour.setSelected(true);
488 else if (sg.cs instanceof PurinePyrimidineColourScheme)
490 purinePyrimidineColour.setSelected(true);
494 * else if (sg.cs instanceof CovariationColourScheme) {
495 * covariationColour.setSelected(true); }
499 noColourmenuItem.setSelected(true);
502 if (sg.cs != null && sg.cs.conservationApplied())
504 conservationMenuItem.setSelected(true);
506 displayNonconserved.setSelected(sg.getShowNonconserved());
507 showText.setSelected(sg.getDisplayText());
508 showColourText.setSelected(sg.getColourText());
509 showBoxes.setSelected(sg.getDisplayBoxes());
510 // add any groupURLs to the groupURL submenu and make it visible
511 if (groupLinks != null && groupLinks.size() > 0)
513 buildGroupURLMenu(sg, groupLinks);
515 // Add a 'show all structures' for the current selection
516 Hashtable<String, PDBEntry> pdbe = new Hashtable<String, PDBEntry>(), reppdb = new Hashtable<String, PDBEntry>();
517 SequenceI sqass = null;
518 for (SequenceI sq : ap.av.getSequenceSelection())
520 Vector<PDBEntry> pes = (Vector<PDBEntry>) sq.getDatasetSequence()
522 if (pes != null && pes.size()>0)
524 reppdb.put(pes.get(0).getId(), pes.get(0));
525 for (PDBEntry pe : pes)
527 pdbe.put(pe.getId(), pe);
537 final PDBEntry[] pe = pdbe.values().toArray(
538 new PDBEntry[pdbe.size()]), pr = reppdb.values().toArray(
539 new PDBEntry[reppdb.size()]);
540 final JMenuItem gpdbview, rpdbview;
541 if (pdbe.size() == 1)
543 structureMenu.add(gpdbview = new JMenuItem(MessageManager
544 .formatMessage("label.view_structure_for", new String[]
545 { sqass.getDisplayId(false) })));
549 structureMenu.add(gpdbview = new JMenuItem(MessageManager
550 .formatMessage("label.view_all_structures", new String[]
551 { new Integer(pdbe.size()).toString() })));
553 gpdbview.setToolTipText(MessageManager
554 .getString("label.open_new_jmol_view_with_all_structures_associated_current_selection_superimpose_using_alignment"));
555 gpdbview.addActionListener(new ActionListener()
559 public void actionPerformed(ActionEvent e)
561 new AppJmol(ap, pe, ap.av.collateForPDB(pe));
564 if (reppdb.size() > 1 && reppdb.size() < pdbe.size())
566 structureMenu.add(rpdbview = new JMenuItem(MessageManager
568 "label.view_all_representative_structures",
570 { new Integer(reppdb.size()).toString() })));
571 rpdbview.setToolTipText(MessageManager
572 .getString("label.open_new_jmol_view_with_all_representative_structures_associated_current_selection_superimpose_using_alignment"));
573 rpdbview.addActionListener(new ActionListener()
577 public void actionPerformed(ActionEvent e)
579 new AppJmol(ap, pr, ap.av.collateForPDB(pr));
587 groupMenu.setVisible(false);
588 editMenu.setVisible(false);
593 createGroupMenuItem.setVisible(true);
594 unGroupMenuItem.setVisible(false);
595 jMenu1.setText(MessageManager.getString("action.edit_new_group"));
599 createGroupMenuItem.setVisible(false);
600 unGroupMenuItem.setVisible(true);
601 jMenu1.setText(MessageManager.getString("action.edit_group"));
606 sequenceMenu.setVisible(false);
607 structureMenu.setVisible(false);
610 if (links != null && links.size() > 0)
613 JMenu linkMenu = new JMenu(MessageManager.getString("action.link"));
614 Vector linkset = new Vector();
615 for (int i = 0; i < links.size(); i++)
617 String link = links.elementAt(i).toString();
618 UrlLink urlLink = null;
621 urlLink = new UrlLink(link);
622 } catch (Exception foo)
624 jalview.bin.Cache.log.error("Exception for URLLink '" + link
629 if (!urlLink.isValid())
631 jalview.bin.Cache.log.error(urlLink.getInvalidMessage());
634 final String label = urlLink.getLabel();
635 if (seq != null && urlLink.isDynamic())
638 // collect matching db-refs
639 DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(
640 seq.getDBRef(), new String[]
641 { urlLink.getTarget() });
642 // collect id string too
643 String id = seq.getName();
644 String descr = seq.getDescription();
645 if (descr != null && descr.length() < 1)
652 for (int r = 0; r < dbr.length; r++)
654 if (id != null && dbr[r].getAccessionId().equals(id))
656 // suppress duplicate link creation for the bare sequence ID
657 // string with this link
660 // create Bare ID link for this RUL
661 String[] urls = urlLink.makeUrls(dbr[r].getAccessionId(),
665 for (int u = 0; u < urls.length; u += 2)
667 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
669 linkset.addElement(urls[u] + "|" + urls[u + 1]);
670 addshowLink(linkMenu, label + "|" + urls[u],
679 // create Bare ID link for this RUL
680 String[] urls = urlLink.makeUrls(id, true);
683 for (int u = 0; u < urls.length; u += 2)
685 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
687 linkset.addElement(urls[u] + "|" + urls[u + 1]);
688 addshowLink(linkMenu, label, urls[u + 1]);
693 // Create urls from description but only for URL links which are regex
695 if (descr != null && urlLink.getRegexReplace() != null)
697 // create link for this URL from description where regex matches
698 String[] urls = urlLink.makeUrls(descr, true);
701 for (int u = 0; u < urls.length; u += 2)
703 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
705 linkset.addElement(urls[u] + "|" + urls[u + 1]);
706 addshowLink(linkMenu, label, urls[u + 1]);
714 if (!linkset.contains(label + "|" + urlLink.getUrl_prefix()))
716 linkset.addElement(label + "|" + urlLink.getUrl_prefix());
717 // Add a non-dynamic link
718 addshowLink(linkMenu, label, urlLink.getUrl_prefix());
722 if (sequence != null)
724 sequenceMenu.add(linkMenu);
733 private void buildGroupURLMenu(SequenceGroup sg, Vector groupLinks)
736 // TODO: usability: thread off the generation of group url content so root
738 // sequence only URLs
739 // ID/regex match URLs
740 groupLinksMenu = new JMenu(
741 MessageManager.getString("action.group_link"));
742 JMenu[] linkMenus = new JMenu[]
743 { null, new JMenu(MessageManager.getString("action.ids")),
744 new JMenu(MessageManager.getString("action.sequences")),
745 new JMenu(MessageManager.getString("action.ids_sequences")) }; // three
752 SequenceI[] seqs = ap.av.getSelectionAsNewSequence();
753 String[][] idandseqs = GroupUrlLink.formStrings(seqs);
754 Hashtable commonDbrefs = new Hashtable();
755 for (int sq = 0; sq < seqs.length; sq++)
758 int start = seqs[sq].findPosition(sg.getStartRes()), end = seqs[sq]
759 .findPosition(sg.getEndRes());
760 // just collect ids from dataset sequence
761 // TODO: check if IDs collected from selecton group intersects with the
762 // current selection, too
763 SequenceI sqi = seqs[sq];
764 while (sqi.getDatasetSequence() != null)
766 sqi = sqi.getDatasetSequence();
768 DBRefEntry[] dbr = sqi.getDBRef();
769 if (dbr != null && dbr.length > 0)
771 for (int d = 0; d < dbr.length; d++)
773 String src = dbr[d].getSource(); // jalview.util.DBRefUtils.getCanonicalName(dbr[d].getSource()).toUpperCase();
774 Object[] sarray = (Object[]) commonDbrefs.get(src);
777 sarray = new Object[2];
778 sarray[0] = new int[]
780 sarray[1] = new String[seqs.length];
782 commonDbrefs.put(src, sarray);
785 if (((String[]) sarray[1])[sq] == null)
788 || (dbr[d].getMap().locateMappedRange(start, end) != null))
790 ((String[]) sarray[1])[sq] = dbr[d].getAccessionId();
791 ((int[]) sarray[0])[0]++;
797 // now create group links for all distinct ID/sequence sets.
798 boolean addMenu = false; // indicates if there are any group links to give
800 for (int i = 0; i < groupLinks.size(); i++)
802 String link = groupLinks.elementAt(i).toString();
803 GroupUrlLink urlLink = null;
806 urlLink = new GroupUrlLink(link);
807 } catch (Exception foo)
809 jalview.bin.Cache.log.error("Exception for GroupURLLink '" + link
814 if (!urlLink.isValid())
816 jalview.bin.Cache.log.error(urlLink.getInvalidMessage());
819 final String label = urlLink.getLabel();
820 boolean usingNames = false;
821 // Now see which parts of the group apply for this URL
822 String ltarget = urlLink.getTarget(); // jalview.util.DBRefUtils.getCanonicalName(urlLink.getTarget());
823 Object[] idset = (Object[]) commonDbrefs.get(ltarget.toUpperCase());
824 String[] seqstr, ids; // input to makeUrl
827 int numinput = ((int[]) idset[0])[0];
828 String[] allids = ((String[]) idset[1]);
829 seqstr = new String[numinput];
830 ids = new String[numinput];
831 for (int sq = 0, idcount = 0; sq < seqs.length; sq++)
833 if (allids[sq] != null)
835 ids[idcount] = allids[sq];
836 seqstr[idcount++] = idandseqs[1][sq];
842 // just use the id/seq set
843 seqstr = idandseqs[1];
847 // and try and make the groupURL!
849 Object[] urlset = null;
852 urlset = urlLink.makeUrlStubs(ids, seqstr,
853 "FromJalview" + System.currentTimeMillis(), false);
854 } catch (UrlStringTooLongException e)
859 int type = urlLink.getGroupURLType() & 3;
860 // System.out.println(urlLink.getGroupURLType()
861 // +" "+((String[])urlset[3])[0]);
862 // first two bits ofurlLink type bitfield are sequenceids and sequences
863 // TODO: FUTURE: ensure the groupURL menu structure can be generalised
864 addshowLink(linkMenus[type], label
865 + (((type & 1) == 1) ? ("("
866 + (usingNames ? "Names" : ltarget) + ")") : ""),
873 groupLinksMenu = new JMenu(
874 MessageManager.getString("action.group_link"));
875 for (int m = 0; m < linkMenus.length; m++)
877 if (linkMenus[m] != null
878 && linkMenus[m].getMenuComponentCount() > 0)
880 groupLinksMenu.add(linkMenus[m]);
884 groupMenu.add(groupLinksMenu);
889 * add a show URL menu item to the given linkMenu
893 * - menu label string
897 private void addshowLink(JMenu linkMenu, String label, final String url)
899 JMenuItem item = new JMenuItem(label);
900 item.setToolTipText(MessageManager.formatMessage(
901 "label.open_url_param", new String[]
903 item.addActionListener(new java.awt.event.ActionListener()
905 public void actionPerformed(ActionEvent e)
907 new Thread(new Runnable()
923 * add a late bound groupURL item to the given linkMenu
927 * - menu label string
928 * @param urlgenerator
929 * GroupURLLink used to generate URL
931 * Object array returned from the makeUrlStubs function.
933 private void addshowLink(JMenu linkMenu, String label,
934 final GroupUrlLink urlgenerator, final Object[] urlstub)
936 JMenuItem item = new JMenuItem(label);
937 item.setToolTipText(MessageManager.formatMessage(
938 "label.open_url_seqs_param",
940 { urlgenerator.getUrl_prefix(),
941 urlgenerator.getNumberInvolved(urlstub) }));
942 // TODO: put in info about what is being sent.
943 item.addActionListener(new java.awt.event.ActionListener()
945 public void actionPerformed(ActionEvent e)
947 new Thread(new Runnable()
954 showLink(urlgenerator.constructFrom(urlstub));
955 } catch (UrlStringTooLongException e)
973 private void jbInit() throws Exception
975 groupMenu.setText(MessageManager.getString("label.group"));
976 groupMenu.setText(MessageManager.getString("label.selection"));
977 groupName.setText(MessageManager.getString("label.name"));
978 groupName.addActionListener(new java.awt.event.ActionListener()
980 public void actionPerformed(ActionEvent e)
982 groupName_actionPerformed();
985 sequenceMenu.setText(MessageManager.getString("label.sequence"));
986 sequenceName.setText(MessageManager
987 .getString("label.edit_name_description"));
988 sequenceName.addActionListener(new java.awt.event.ActionListener()
990 public void actionPerformed(ActionEvent e)
992 sequenceName_actionPerformed();
995 sequenceDetails.setText(MessageManager
996 .getString("label.sequence_details") + "...");
997 sequenceDetails.addActionListener(new java.awt.event.ActionListener()
999 public void actionPerformed(ActionEvent e)
1001 sequenceDetails_actionPerformed();
1004 sequenceSelDetails.setText(MessageManager
1005 .getString("label.sequence_details") + "...");
1007 .addActionListener(new java.awt.event.ActionListener()
1009 public void actionPerformed(ActionEvent e)
1011 sequenceSelectionDetails_actionPerformed();
1014 PIDColour.setFocusPainted(false);
1016 .setText(MessageManager.getString("action.remove_group"));
1017 unGroupMenuItem.addActionListener(new java.awt.event.ActionListener()
1019 public void actionPerformed(ActionEvent e)
1021 unGroupMenuItem_actionPerformed();
1024 createGroupMenuItem.setText(MessageManager
1025 .getString("action.create_group"));
1027 .addActionListener(new java.awt.event.ActionListener()
1029 public void actionPerformed(ActionEvent e)
1031 createGroupMenuItem_actionPerformed();
1035 outline.setText(MessageManager.getString("action.border_colour"));
1036 outline.addActionListener(new java.awt.event.ActionListener()
1038 public void actionPerformed(ActionEvent e)
1040 outline_actionPerformed();
1044 .setText(MessageManager.getString("label.nucleotide"));
1045 nucleotideMenuItem.addActionListener(new ActionListener()
1047 public void actionPerformed(ActionEvent e)
1049 nucleotideMenuItem_actionPerformed();
1052 colourMenu.setText(MessageManager.getString("label.group_colour"));
1053 showBoxes.setText(MessageManager.getString("action.boxes"));
1054 showBoxes.setState(true);
1055 showBoxes.addActionListener(new ActionListener()
1057 public void actionPerformed(ActionEvent e)
1059 showBoxes_actionPerformed();
1062 showText.setText(MessageManager.getString("action.text"));
1063 showText.setState(true);
1064 showText.addActionListener(new ActionListener()
1066 public void actionPerformed(ActionEvent e)
1068 showText_actionPerformed();
1071 showColourText.setText(MessageManager.getString("label.colour_text"));
1072 showColourText.addActionListener(new ActionListener()
1074 public void actionPerformed(ActionEvent e)
1076 showColourText_actionPerformed();
1079 displayNonconserved.setText(MessageManager
1080 .getString("label.show_non_conversed"));
1081 displayNonconserved.setState(true);
1082 displayNonconserved.addActionListener(new ActionListener()
1084 public void actionPerformed(ActionEvent e)
1086 showNonconserved_actionPerformed();
1089 editMenu.setText(MessageManager.getString("action.edit"));
1090 cut.setText(MessageManager.getString("action.cut"));
1091 cut.addActionListener(new ActionListener()
1093 public void actionPerformed(ActionEvent e)
1095 cut_actionPerformed();
1098 upperCase.setText(MessageManager.getString("label.to_upper_case"));
1099 upperCase.addActionListener(new ActionListener()
1101 public void actionPerformed(ActionEvent e)
1106 copy.setText(MessageManager.getString("action.copy"));
1107 copy.addActionListener(new ActionListener()
1109 public void actionPerformed(ActionEvent e)
1111 copy_actionPerformed();
1114 lowerCase.setText(MessageManager.getString("label.to_lower_case"));
1115 lowerCase.addActionListener(new ActionListener()
1117 public void actionPerformed(ActionEvent e)
1122 toggle.setText(MessageManager.getString("label.toggle_case"));
1123 toggle.addActionListener(new ActionListener()
1125 public void actionPerformed(ActionEvent e)
1130 pdbMenu.setText(MessageManager
1131 .getString("label.associate_structure_with_sequence"));
1132 pdbFromFile.setText(MessageManager.getString("label.from_file"));
1133 pdbFromFile.addActionListener(new ActionListener()
1135 public void actionPerformed(ActionEvent e)
1137 pdbFromFile_actionPerformed();
1140 // RNAFold.setText("From RNA Fold with predict2D");
1141 // RNAFold.addActionListener(new ActionListener()
1143 // public void actionPerformed(ActionEvent e)
1146 // RNAFold_actionPerformed();
1147 // } catch (Exception e1) {
1148 // // TODO Auto-generated catch block
1149 // e1.printStackTrace();
1153 // ContraFold.setText("From Contra Fold with predict2D");
1154 // ContraFold.addActionListener(new ActionListener()
1156 // public void actionPerformed(ActionEvent e)
1159 // ContraFold_actionPerformed();
1160 // } catch (Exception e1) {
1161 // // TODO Auto-generated catch block
1162 // e1.printStackTrace();
1166 enterPDB.setText(MessageManager.getString("label.enter_pdb_id"));
1167 enterPDB.addActionListener(new ActionListener()
1169 public void actionPerformed(ActionEvent e)
1171 enterPDB_actionPerformed();
1174 discoverPDB.setText(MessageManager.getString("label.discover_pdb_ids"));
1175 discoverPDB.addActionListener(new ActionListener()
1177 public void actionPerformed(ActionEvent e)
1179 discoverPDB_actionPerformed();
1182 outputMenu.setText(MessageManager.getString("label.out_to_textbox")
1184 sequenceFeature.setText(MessageManager
1185 .getString("label.create_sequence_feature"));
1186 sequenceFeature.addActionListener(new ActionListener()
1188 public void actionPerformed(ActionEvent e)
1190 sequenceFeature_actionPerformed();
1193 textColour.setText(MessageManager.getString("label.text_colour"));
1194 textColour.addActionListener(new ActionListener()
1196 public void actionPerformed(ActionEvent e)
1198 textColour_actionPerformed();
1201 jMenu1.setText(MessageManager.getString("label.group"));
1202 structureMenu.setText(MessageManager.getString("label.structure"));
1203 viewStructureMenu.setText(MessageManager
1204 .getString("label.view_structure"));
1205 // colStructureMenu.setText("Colour By Structure");
1206 editSequence.setText(MessageManager.getString("label.edit_sequence")
1208 editSequence.addActionListener(new ActionListener()
1210 public void actionPerformed(ActionEvent actionEvent)
1212 editSequence_actionPerformed(actionEvent);
1217 * annotationMenuItem.setText("By Annotation");
1218 * annotationMenuItem.addActionListener(new ActionListener() { public void
1219 * actionPerformed(ActionEvent actionEvent) {
1220 * annotationMenuItem_actionPerformed(actionEvent); } });
1222 groupMenu.add(sequenceSelDetails);
1225 this.add(structureMenu);
1226 groupMenu.add(editMenu);
1227 groupMenu.add(outputMenu);
1228 groupMenu.add(sequenceFeature);
1229 groupMenu.add(createGroupMenuItem);
1230 groupMenu.add(unGroupMenuItem);
1231 groupMenu.add(jMenu1);
1232 sequenceMenu.add(sequenceName);
1233 sequenceMenu.add(sequenceDetails);
1234 colourMenu.add(textColour);
1235 colourMenu.add(noColourmenuItem);
1236 colourMenu.add(clustalColour);
1237 colourMenu.add(BLOSUM62Colour);
1238 colourMenu.add(PIDColour);
1239 colourMenu.add(zappoColour);
1240 colourMenu.add(taylorColour);
1241 colourMenu.add(hydrophobicityColour);
1242 colourMenu.add(helixColour);
1243 colourMenu.add(strandColour);
1244 colourMenu.add(turnColour);
1245 colourMenu.add(buriedColour);
1246 colourMenu.add(nucleotideMenuItem);
1247 if (ap.getAlignment().isNucleotide())
1249 // JBPNote - commented since the colourscheme isn't functional
1250 // colourMenu.add(RNAInteractionColour);
1251 colourMenu.add(purinePyrimidineColour);
1253 // colourMenu.add(covariationColour);
1254 colourMenu.add(userDefinedColour);
1256 if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null)
1258 java.util.Enumeration userColours = jalview.gui.UserDefinedColours
1259 .getUserColourSchemes().keys();
1261 while (userColours.hasMoreElements())
1263 JMenuItem item = new JMenuItem(userColours.nextElement().toString());
1264 item.addActionListener(new ActionListener()
1266 public void actionPerformed(ActionEvent evt)
1268 userDefinedColour_actionPerformed(evt);
1271 colourMenu.add(item);
1275 colourMenu.addSeparator();
1276 colourMenu.add(abovePIDColour);
1277 colourMenu.add(conservationMenuItem);
1278 // colourMenu.add(annotationMenuItem);
1281 editMenu.add(editSequence);
1282 editMenu.add(upperCase);
1283 editMenu.add(lowerCase);
1284 editMenu.add(toggle);
1285 pdbMenu.add(pdbFromFile);
1286 // JBPNote: These shouldn't be added here - should appear in a generic
1287 // 'apply web service to this sequence menu'
1288 // pdbMenu.add(RNAFold);
1289 // pdbMenu.add(ContraFold);
1290 pdbMenu.add(enterPDB);
1291 pdbMenu.add(discoverPDB);
1292 jMenu1.add(groupName);
1293 jMenu1.add(colourMenu);
1294 jMenu1.add(showBoxes);
1295 jMenu1.add(showText);
1296 jMenu1.add(showColourText);
1297 jMenu1.add(outline);
1298 jMenu1.add(displayNonconserved);
1299 structureMenu.add(pdbMenu);
1300 structureMenu.add(viewStructureMenu);
1301 // structureMenu.add(colStructureMenu);
1302 noColourmenuItem.setText(MessageManager.getString("label.none"));
1303 noColourmenuItem.addActionListener(new java.awt.event.ActionListener()
1305 public void actionPerformed(ActionEvent e)
1307 noColourmenuItem_actionPerformed();
1311 clustalColour.setText(MessageManager
1312 .getString("label.clustalx_colours"));
1313 clustalColour.addActionListener(new java.awt.event.ActionListener()
1315 public void actionPerformed(ActionEvent e)
1317 clustalColour_actionPerformed();
1320 zappoColour.setText(MessageManager.getString("label.zappo"));
1321 zappoColour.addActionListener(new java.awt.event.ActionListener()
1323 public void actionPerformed(ActionEvent e)
1325 zappoColour_actionPerformed();
1328 taylorColour.setText(MessageManager.getString("label.taylor"));
1329 taylorColour.addActionListener(new java.awt.event.ActionListener()
1331 public void actionPerformed(ActionEvent e)
1333 taylorColour_actionPerformed();
1336 hydrophobicityColour.setText(MessageManager
1337 .getString("label.hydrophobicity"));
1338 hydrophobicityColour
1339 .addActionListener(new java.awt.event.ActionListener()
1341 public void actionPerformed(ActionEvent e)
1343 hydrophobicityColour_actionPerformed();
1346 helixColour.setText(MessageManager.getString("label.helix_propensity"));
1347 helixColour.addActionListener(new java.awt.event.ActionListener()
1349 public void actionPerformed(ActionEvent e)
1351 helixColour_actionPerformed();
1354 strandColour.setText(MessageManager
1355 .getString("label.strand_propensity"));
1356 strandColour.addActionListener(new java.awt.event.ActionListener()
1358 public void actionPerformed(ActionEvent e)
1360 strandColour_actionPerformed();
1363 turnColour.setText(MessageManager.getString("label.turn_propensity"));
1364 turnColour.addActionListener(new java.awt.event.ActionListener()
1366 public void actionPerformed(ActionEvent e)
1368 turnColour_actionPerformed();
1371 buriedColour.setText(MessageManager.getString("label.buried_index"));
1372 buriedColour.addActionListener(new java.awt.event.ActionListener()
1374 public void actionPerformed(ActionEvent e)
1376 buriedColour_actionPerformed();
1379 abovePIDColour.setText(MessageManager
1380 .getString("label.above_identity_percentage"));
1381 abovePIDColour.addActionListener(new java.awt.event.ActionListener()
1383 public void actionPerformed(ActionEvent e)
1385 abovePIDColour_actionPerformed();
1388 userDefinedColour.setText(MessageManager
1389 .getString("action.user_defined"));
1390 userDefinedColour.addActionListener(new java.awt.event.ActionListener()
1392 public void actionPerformed(ActionEvent e)
1394 userDefinedColour_actionPerformed(e);
1398 .setText(MessageManager.getString("label.percentage_identity"));
1399 PIDColour.addActionListener(new java.awt.event.ActionListener()
1401 public void actionPerformed(ActionEvent e)
1403 PIDColour_actionPerformed();
1406 BLOSUM62Colour.setText(MessageManager.getString("label.blosum62"));
1407 BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener()
1409 public void actionPerformed(ActionEvent e)
1411 BLOSUM62Colour_actionPerformed();
1414 purinePyrimidineColour.setText(MessageManager
1415 .getString("label.purine_pyrimidine"));
1416 purinePyrimidineColour
1417 .addActionListener(new java.awt.event.ActionListener()
1419 public void actionPerformed(ActionEvent e)
1421 purinePyrimidineColour_actionPerformed();
1426 * covariationColour.addActionListener(new java.awt.event.ActionListener() {
1427 * public void actionPerformed(ActionEvent e) {
1428 * covariationColour_actionPerformed(); } });
1431 conservationMenuItem.setText(MessageManager
1432 .getString("label.conservation"));
1433 conservationMenuItem
1434 .addActionListener(new java.awt.event.ActionListener()
1436 public void actionPerformed(ActionEvent e)
1438 conservationMenuItem_actionPerformed();
1443 protected void sequenceSelectionDetails_actionPerformed()
1445 createSequenceDetailsReport(ap.av.getSequenceSelection());
1448 protected void sequenceDetails_actionPerformed()
1450 createSequenceDetailsReport(new SequenceI[]
1454 public void createSequenceDetailsReport(SequenceI[] sequences)
1456 CutAndPasteHtmlTransfer cap = new CutAndPasteHtmlTransfer();
1457 StringBuffer contents = new StringBuffer();
1458 for (SequenceI seq : sequences)
1460 contents.append("<p><h2>"
1463 "label.create_sequence_details_report_annotation_for",
1465 { seq.getDisplayId(true) }) + "</h2></p><p>");
1466 new SequenceAnnotationReport(null)
1467 .createSequenceAnnotationReport(
1473 (ap.seqPanel.seqCanvas.fr != null) ? ap.seqPanel.seqCanvas.fr.minmax
1475 contents.append("</p>");
1477 cap.setText("<html>" + contents.toString() + "</html>");
1479 Desktop.instance.addInternalFrame(cap, MessageManager.formatMessage(
1480 "label.sequece_details_for",
1481 (sequences.length == 1 ? new String[]
1482 { sequences[0].getDisplayId(true) } : new String[]
1483 { MessageManager.getString("label.selection") })), 500, 400);
1487 protected void showNonconserved_actionPerformed()
1489 getGroup().setShowNonconserved(displayNonconserved.isSelected());
1494 * call to refresh view after settings change
1498 ap.updateAnnotation();
1499 ap.paintAlignment(true);
1501 PaintRefresher.Refresh(this, ap.av.getSequenceSetId());
1510 protected void clustalColour_actionPerformed()
1512 SequenceGroup sg = getGroup();
1513 sg.cs = new ClustalxColourScheme(sg, ap.av.getHiddenRepSequences());
1523 protected void zappoColour_actionPerformed()
1525 getGroup().cs = new ZappoColourScheme();
1535 protected void taylorColour_actionPerformed()
1537 getGroup().cs = new TaylorColourScheme();
1547 protected void hydrophobicityColour_actionPerformed()
1549 getGroup().cs = new HydrophobicColourScheme();
1559 protected void helixColour_actionPerformed()
1561 getGroup().cs = new HelixColourScheme();
1571 protected void strandColour_actionPerformed()
1573 getGroup().cs = new StrandColourScheme();
1583 protected void turnColour_actionPerformed()
1585 getGroup().cs = new TurnColourScheme();
1595 protected void buriedColour_actionPerformed()
1597 getGroup().cs = new BuriedColourScheme();
1607 public void nucleotideMenuItem_actionPerformed()
1609 getGroup().cs = new NucleotideColourScheme();
1613 protected void purinePyrimidineColour_actionPerformed()
1615 getGroup().cs = new PurinePyrimidineColourScheme();
1620 * protected void covariationColour_actionPerformed() { getGroup().cs = new
1621 * CovariationColourScheme(sequence.getAnnotation()[0]); refresh(); }
1629 protected void abovePIDColour_actionPerformed()
1631 SequenceGroup sg = getGroup();
1637 if (abovePIDColour.isSelected())
1639 sg.cs.setConsensus(AAFrequency.calculate(
1640 sg.getSequences(ap.av.getHiddenRepSequences()),
1641 sg.getStartRes(), sg.getEndRes() + 1));
1643 int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
1646 sg.cs.setThreshold(threshold, ap.av.getIgnoreGapsConsensus());
1648 SliderPanel.showPIDSlider();
1651 // remove PIDColouring
1653 sg.cs.setThreshold(0, ap.av.getIgnoreGapsConsensus());
1665 protected void userDefinedColour_actionPerformed(ActionEvent e)
1667 SequenceGroup sg = getGroup();
1669 if (e.getSource().equals(userDefinedColour))
1671 new UserDefinedColours(ap, sg);
1675 UserColourScheme udc = (UserColourScheme) UserDefinedColours
1676 .getUserColourSchemes().get(e.getActionCommand());
1689 protected void PIDColour_actionPerformed()
1691 SequenceGroup sg = getGroup();
1692 sg.cs = new PIDColourScheme();
1693 sg.cs.setConsensus(AAFrequency.calculate(
1694 sg.getSequences(ap.av.getHiddenRepSequences()),
1695 sg.getStartRes(), sg.getEndRes() + 1));
1705 protected void BLOSUM62Colour_actionPerformed()
1707 SequenceGroup sg = getGroup();
1709 sg.cs = new Blosum62ColourScheme();
1711 sg.cs.setConsensus(AAFrequency.calculate(
1712 sg.getSequences(ap.av.getHiddenRepSequences()),
1713 sg.getStartRes(), sg.getEndRes() + 1));
1724 protected void noColourmenuItem_actionPerformed()
1726 getGroup().cs = null;
1736 protected void conservationMenuItem_actionPerformed()
1738 SequenceGroup sg = getGroup();
1744 if (conservationMenuItem.isSelected())
1746 // JBPNote: Conservation name shouldn't be i18n translated
1747 Conservation c = new Conservation("Group",
1748 ResidueProperties.propHash, 3, sg.getSequences(ap.av
1749 .getHiddenRepSequences()), sg.getStartRes(),
1750 sg.getEndRes() + 1);
1753 c.verdict(false, ap.av.getConsPercGaps());
1755 sg.cs.setConservation(c);
1757 SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
1758 SliderPanel.showConservationSlider();
1761 // remove ConservationColouring
1763 sg.cs.setConservation(null);
1769 public void annotationMenuItem_actionPerformed(ActionEvent actionEvent)
1771 SequenceGroup sg = getGroup();
1777 AnnotationColourGradient acg = new AnnotationColourGradient(
1778 sequence.getAnnotation()[0], null,
1779 AnnotationColourGradient.NO_THRESHOLD);
1781 acg.setPredefinedColours(true);
1793 protected void groupName_actionPerformed()
1796 SequenceGroup sg = getGroup();
1797 EditNameDialog dialog = new EditNameDialog(sg.getName(),
1798 sg.getDescription(), " "
1799 + MessageManager.getString("label.group_name") + " ",
1800 MessageManager.getString("label.group_description") + " ",
1801 MessageManager.getString("label.edit_group_name_description"),
1809 sg.setName(dialog.getName());
1810 sg.setDescription(dialog.getDescription());
1815 * Get selection group - adding it to the alignment if necessary.
1817 * @return sequence group to operate on
1819 SequenceGroup getGroup()
1821 SequenceGroup sg = ap.av.getSelectionGroup();
1822 // this method won't add a new group if it already exists
1825 ap.av.getAlignment().addGroup(sg);
1837 void sequenceName_actionPerformed()
1839 EditNameDialog dialog = new EditNameDialog(sequence.getName(),
1840 sequence.getDescription(),
1841 " " + MessageManager.getString("label.sequence_name")
1843 MessageManager.getString("label.sequence_description") + " ",
1845 .getString("label.edit_sequence_name_description"),
1853 if (dialog.getName() != null)
1855 if (dialog.getName().indexOf(" ") > -1)
1861 .getString("label.spaces_converted_to_backslashes"),
1863 .getString("label.no_spaces_allowed_sequence_name"),
1864 JOptionPane.WARNING_MESSAGE);
1867 sequence.setName(dialog.getName().replace(' ', '_'));
1868 ap.paintAlignment(false);
1871 sequence.setDescription(dialog.getDescription());
1873 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1884 void unGroupMenuItem_actionPerformed()
1886 SequenceGroup sg = ap.av.getSelectionGroup();
1887 ap.av.getAlignment().deleteGroup(sg);
1888 ap.av.setSelectionGroup(null);
1892 void createGroupMenuItem_actionPerformed()
1894 getGroup(); // implicitly creates group - note - should apply defaults / use
1895 // standard alignment window logic for this
1905 protected void outline_actionPerformed()
1907 SequenceGroup sg = getGroup();
1908 Color col = JColorChooser.showDialog(this,
1909 MessageManager.getString("label.select_outline_colour"),
1914 sg.setOutlineColour(col);
1926 public void showBoxes_actionPerformed()
1928 getGroup().setDisplayBoxes(showBoxes.isSelected());
1938 public void showText_actionPerformed()
1940 getGroup().setDisplayText(showText.isSelected());
1950 public void showColourText_actionPerformed()
1952 getGroup().setColourText(showColourText.isSelected());
1956 public void showLink(String url)
1960 jalview.util.BrowserLauncher.openURL(url);
1961 } catch (Exception ex)
1963 JOptionPane.showInternalMessageDialog(Desktop.desktop,
1964 MessageManager.getString("label.web_browser_not_found_unix"),
1965 MessageManager.getString("label.web_browser_not_found"),
1966 JOptionPane.WARNING_MESSAGE);
1968 ex.printStackTrace();
1972 void hideSequences(boolean representGroup)
1974 SequenceGroup sg = ap.av.getSelectionGroup();
1975 if (sg == null || sg.getSize() < 1)
1977 ap.av.hideSequence(new SequenceI[]
1982 ap.av.setSelectionGroup(null);
1986 ap.av.hideRepSequences(sequence, sg);
1991 int gsize = sg.getSize();
1994 hseqs = new SequenceI[gsize];
1997 for (int i = 0; i < gsize; i++)
1999 hseqs[index++] = sg.getSequenceAt(i);
2002 ap.av.hideSequence(hseqs);
2003 // refresh(); TODO: ? needed ?
2004 ap.av.sendSelection();
2007 public void copy_actionPerformed()
2009 ap.alignFrame.copy_actionPerformed(null);
2012 public void cut_actionPerformed()
2014 ap.alignFrame.cut_actionPerformed(null);
2017 void changeCase(ActionEvent e)
2019 Object source = e.getSource();
2020 SequenceGroup sg = ap.av.getSelectionGroup();
2024 int[][] startEnd = ap.av.getVisibleRegionBoundaries(sg.getStartRes(),
2025 sg.getEndRes() + 1);
2030 if (source == toggle)
2032 description = MessageManager.getString("label.toggle_case");
2033 caseChange = ChangeCaseCommand.TOGGLE_CASE;
2035 else if (source == upperCase)
2037 description = MessageManager.getString("label.to_upper_case");
2038 caseChange = ChangeCaseCommand.TO_UPPER;
2042 description = MessageManager.getString("label.to_lower_case");
2043 caseChange = ChangeCaseCommand.TO_LOWER;
2046 ChangeCaseCommand caseCommand = new ChangeCaseCommand(description,
2047 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
2048 startEnd, caseChange);
2050 ap.alignFrame.addHistoryItem(caseCommand);
2052 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
2058 public void outputText_actionPerformed(ActionEvent e)
2060 CutAndPasteTransfer cap = new CutAndPasteTransfer();
2061 cap.setForInput(null);
2062 Desktop.addInternalFrame(cap, MessageManager.formatMessage(
2063 "label.alignment_output_command", new String[]
2064 { e.getActionCommand() }), 600, 500);
2066 String[] omitHidden = null;
2068 System.out.println("PROMPT USER HERE"); // TODO: decide if a prompt happens
2069 // or we simply trust the user wants
2070 // wysiwig behaviour
2071 SequenceGroup sg = ap.av.getSelectionGroup();
2072 ColumnSelection csel = new ColumnSelection(ap.av.getColumnSelection());
2073 omitHidden = ap.av.getViewAsString(true);
2074 Alignment oal = new Alignment(ap.av.getSequenceSelection());
2075 AlignmentAnnotation[] nala = ap.av.getAlignment()
2076 .getAlignmentAnnotation();
2079 for (int i = 0; i < nala.length; i++)
2081 AlignmentAnnotation na = nala[i];
2082 oal.addAnnotation(na);
2085 cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(),
2086 oal, omitHidden, csel, sg));
2090 public void pdbFromFile_actionPerformed()
2092 jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(
2093 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
2094 chooser.setFileView(new jalview.io.JalviewFileView());
2095 chooser.setDialogTitle(MessageManager.formatMessage(
2096 "label.select_pdb_file_for", new String[]
2097 { sequence.getDisplayId(false) }));
2098 chooser.setToolTipText(MessageManager.formatMessage(
2099 "label.load_pdb_file_associate_with_sequence", new String[]
2100 { new Integer(sequence.getDisplayId(false)).toString() }));
2102 int value = chooser.showOpenDialog(null);
2104 if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
2106 String choice = chooser.getSelectedFile().getPath();
2107 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
2108 new AssociatePdbFileWithSeq().associatePdbWithSeq(choice,
2109 jalview.io.AppletFormatAdapter.FILE, sequence, true);
2114 // JBNote: commented out - these won't be instantiated here...!
2115 // public void RNAFold_actionPerformed() throws Exception
2117 // Predict2D P2D = new Predict2D();
2118 // P2D.getStructure2DFromRNAFold("toto");
2121 // public void ContraFold_actionPerformed() throws Exception
2123 // Predict2D P2D = new Predict2D();
2124 // P2D.getStructure2DFromContraFold("toto");
2126 public void enterPDB_actionPerformed()
2128 String id = JOptionPane.showInternalInputDialog(Desktop.desktop,
2129 MessageManager.getString("label.enter_pdb_id"),
2130 MessageManager.getString("label.enter_pdb_id"),
2131 JOptionPane.QUESTION_MESSAGE);
2133 if (id != null && id.length() > 0)
2135 PDBEntry entry = new PDBEntry();
2136 entry.setId(id.toUpperCase());
2137 sequence.getDatasetSequence().addPDBId(entry);
2141 public void discoverPDB_actionPerformed()
2144 final SequenceI[] sequences = ((ap.av.getSelectionGroup() == null) ? new SequenceI[]
2146 : ap.av.getSequenceSelection());
2147 Thread discpdb = new Thread(new Runnable()
2152 new jalview.ws.DBRefFetcher(sequences, ap.alignFrame)
2153 .fetchDBRefs(false);
2160 public void sequenceFeature_actionPerformed()
2162 SequenceGroup sg = ap.av.getSelectionGroup();
2168 int rsize = 0, gSize = sg.getSize();
2169 SequenceI[] rseqs, seqs = new SequenceI[gSize];
2170 SequenceFeature[] tfeatures, features = new SequenceFeature[gSize];
2172 for (int i = 0; i < gSize; i++)
2174 int start = sg.getSequenceAt(i).findPosition(sg.getStartRes());
2175 int end = sg.findEndRes(sg.getSequenceAt(i));
2178 seqs[rsize] = sg.getSequenceAt(i).getDatasetSequence();
2179 features[rsize] = new SequenceFeature(null, null, null, start, end,
2184 rseqs = new SequenceI[rsize];
2185 tfeatures = new SequenceFeature[rsize];
2186 System.arraycopy(seqs, 0, rseqs, 0, rsize);
2187 System.arraycopy(features, 0, tfeatures, 0, rsize);
2188 features = tfeatures;
2190 if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs,
2191 features, true, ap))
2193 ap.alignFrame.setShowSeqFeatures(true);
2194 ap.highlightSearchResults(null);
2198 public void textColour_actionPerformed()
2200 SequenceGroup sg = getGroup();
2203 new TextColourChooser().chooseColour(ap, sg);
2207 public void colourByStructure(String pdbid)
2209 Annotation[] anots = ap.av.getStructureSelectionManager()
2210 .colourSequenceFromStructure(sequence, pdbid);
2212 AlignmentAnnotation an = new AlignmentAnnotation("Structure",
2213 "Coloured by " + pdbid, anots);
2215 ap.av.getAlignment().addAnnotation(an);
2216 an.createSequenceMapping(sequence, 0, true);
2217 // an.adjustForAlignment();
2218 ap.av.getAlignment().setAnnotationIndex(an, 0);
2220 ap.adjustAnnotationHeight();
2222 sequence.addAlignmentAnnotation(an);
2226 public void editSequence_actionPerformed(ActionEvent actionEvent)
2228 SequenceGroup sg = ap.av.getSelectionGroup();
2232 if (sequence == null)
2233 sequence = (Sequence) sg.getSequenceAt(0);
2235 EditNameDialog dialog = new EditNameDialog(
2236 sequence.getSequenceAsString(sg.getStartRes(),
2237 sg.getEndRes() + 1), null,
2238 MessageManager.getString("label.edit_sequence"), null,
2239 MessageManager.getString("label.edit_sequence"),
2244 EditCommand editCommand = new EditCommand(
2245 MessageManager.getString("label.edit_sequences"),
2246 EditCommand.REPLACE, dialog.getName().replace(' ',
2247 ap.av.getGapCharacter()),
2248 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
2249 sg.getStartRes(), sg.getEndRes() + 1, ap.av.getAlignment());
2251 ap.alignFrame.addHistoryItem(editCommand);
2253 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()