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 StructureViewer(ap.getStructureSelectionManager())
263 ap.av.collateForPDB(new PDBEntry[]
264 { pdb })[0], null, ap);
268 viewStructureMenu.add(menuItem);
271 * menuItem = new JMenuItem(); menuItem.setText(pdb.getId());
272 * menuItem.addActionListener(new java.awt.event.ActionListener() {
273 * public void actionPerformed(ActionEvent e) {
274 * colourByStructure(pdb.getId()); } });
275 * colStructureMenu.add(menuItem);
281 if (ap.av.getAlignment().isNucleotide() == false)
283 structureMenu.remove(viewStructureMenu);
285 // structureMenu.remove(colStructureMenu);
288 if (ap.av.getAlignment().isNucleotide() == true)
290 AlignmentAnnotation[] aa = ap.av.getAlignment()
291 .getAlignmentAnnotation();
292 for (int i = 0; i < aa.length; i++)
294 if (aa[i].getRNAStruc() != null)
296 final String rnastruc = aa[i].getRNAStruc();
297 final String structureLine = aa[i].label;
298 menuItem = new JMenuItem();
299 menuItem.setText(MessageManager.formatMessage(
300 "label.2d_rna_structure_line", new String[]
302 menuItem.addActionListener(new java.awt.event.ActionListener()
305 public void actionPerformed(ActionEvent e)
307 // System.out.println("1:"+structureLine);
308 System.out.println("1:sname" + seq.getName());
309 System.out.println("2:seq" + seq);
311 // System.out.println("3:"+seq.getSequenceAsString());
312 System.out.println("3:strucseq" + rnastruc);
313 // System.out.println("4:struc"+seq.getRNA());
314 System.out.println("5:name" + seq.getName());
315 System.out.println("6:ap" + ap);
316 new AppVarna(structureLine, seq, seq.getSequenceAsString(),
317 rnastruc, seq.getName(), ap);
318 // new AppVarna(seq.getName(),seq,rnastruc,seq.getRNA(),
319 // seq.getName(), ap);
320 System.out.println("end");
323 viewStructureMenu.add(menuItem);
327 // SequenceFeatures[] test = seq.getSequenceFeatures();
329 if (seq.getAnnotation() != null)
331 AlignmentAnnotation seqAnno[] = seq.getAnnotation();
332 for (int i = 0; i < seqAnno.length; i++)
334 if (seqAnno[i].getRNAStruc() != null)
336 final String rnastruc = seqAnno[i].getRNAStruc();
338 // TODO: make rnastrucF a bit more nice
339 menuItem = new JMenuItem();
340 menuItem.setText(MessageManager.formatMessage(
341 "label.2d_rna_sequence_name", new String[]
343 menuItem.addActionListener(new java.awt.event.ActionListener()
345 public void actionPerformed(ActionEvent e)
347 // TODO: VARNA does'nt print gaps in the sequence
349 new AppVarna(seq.getName() + " structure", seq, seq
350 .getSequenceAsString(), rnastruc, seq.getName(),
354 viewStructureMenu.add(menuItem);
361 menuItem = new JMenuItem(
362 MessageManager.getString("action.hide_sequences"));
363 menuItem.addActionListener(new java.awt.event.ActionListener()
365 public void actionPerformed(ActionEvent e)
367 hideSequences(false);
372 if (ap.av.getSelectionGroup() != null
373 && ap.av.getSelectionGroup().getSize() > 1)
375 menuItem = new JMenuItem(MessageManager.formatMessage(
376 "label.represent_group_with", new String[]
378 menuItem.addActionListener(new java.awt.event.ActionListener()
380 public void actionPerformed(ActionEvent e)
385 sequenceMenu.add(menuItem);
388 if (ap.av.hasHiddenRows())
390 final int index = ap.av.getAlignment().findIndex(seq);
392 if (ap.av.adjustForHiddenSeqs(index)
393 - ap.av.adjustForHiddenSeqs(index - 1) > 1)
395 menuItem = new JMenuItem(
396 MessageManager.getString("action.reveal_sequences"));
397 menuItem.addActionListener(new ActionListener()
399 public void actionPerformed(ActionEvent e)
401 ap.av.showSequence(index);
402 if (ap.overviewPanel != null)
404 ap.overviewPanel.updateOverviewImage();
412 // for the case when no sequences are even visible
413 if (ap.av.hasHiddenRows())
416 menuItem = new JMenuItem(
417 MessageManager.getString("action.reveal_all"));
418 menuItem.addActionListener(new ActionListener()
420 public void actionPerformed(ActionEvent e)
422 ap.av.showAllHiddenSeqs();
423 if (ap.overviewPanel != null)
425 ap.overviewPanel.updateOverviewImage();
435 SequenceGroup sg = ap.av.getSelectionGroup();
436 boolean isDefinedGroup = (sg != null) ? ap.av.getAlignment()
437 .getGroups().contains(sg) : false;
439 if (sg != null && sg.getSize() > 0)
441 groupName.setText(MessageManager.formatMessage("label.name_param",
444 groupName.setText(MessageManager
445 .getString("label.edit_name_and_description_current_group"));
447 if (sg.cs instanceof ZappoColourScheme)
449 zappoColour.setSelected(true);
451 else if (sg.cs instanceof TaylorColourScheme)
453 taylorColour.setSelected(true);
455 else if (sg.cs instanceof PIDColourScheme)
457 PIDColour.setSelected(true);
459 else if (sg.cs instanceof Blosum62ColourScheme)
461 BLOSUM62Colour.setSelected(true);
463 else if (sg.cs instanceof UserColourScheme)
465 userDefinedColour.setSelected(true);
467 else if (sg.cs instanceof HydrophobicColourScheme)
469 hydrophobicityColour.setSelected(true);
471 else if (sg.cs instanceof HelixColourScheme)
473 helixColour.setSelected(true);
475 else if (sg.cs instanceof StrandColourScheme)
477 strandColour.setSelected(true);
479 else if (sg.cs instanceof TurnColourScheme)
481 turnColour.setSelected(true);
483 else if (sg.cs instanceof BuriedColourScheme)
485 buriedColour.setSelected(true);
487 else if (sg.cs instanceof ClustalxColourScheme)
489 clustalColour.setSelected(true);
491 else if (sg.cs instanceof PurinePyrimidineColourScheme)
493 purinePyrimidineColour.setSelected(true);
497 * else if (sg.cs instanceof CovariationColourScheme) {
498 * covariationColour.setSelected(true); }
502 noColourmenuItem.setSelected(true);
505 if (sg.cs != null && sg.cs.conservationApplied())
507 conservationMenuItem.setSelected(true);
509 displayNonconserved.setSelected(sg.getShowNonconserved());
510 showText.setSelected(sg.getDisplayText());
511 showColourText.setSelected(sg.getColourText());
512 showBoxes.setSelected(sg.getDisplayBoxes());
513 // add any groupURLs to the groupURL submenu and make it visible
514 if (groupLinks != null && groupLinks.size() > 0)
516 buildGroupURLMenu(sg, groupLinks);
518 // Add a 'show all structures' for the current selection
519 Hashtable<String, PDBEntry> pdbe = new Hashtable<String, PDBEntry>(), reppdb = new Hashtable<String, PDBEntry>();
520 SequenceI sqass = null;
521 for (SequenceI sq : ap.av.getSequenceSelection())
523 Vector<PDBEntry> pes = (Vector<PDBEntry>) sq.getDatasetSequence()
525 if (pes != null && pes.size()>0)
527 reppdb.put(pes.get(0).getId(), pes.get(0));
528 for (PDBEntry pe : pes)
530 pdbe.put(pe.getId(), pe);
540 final PDBEntry[] pe = pdbe.values().toArray(
541 new PDBEntry[pdbe.size()]), pr = reppdb.values().toArray(
542 new PDBEntry[reppdb.size()]);
543 final JMenuItem gpdbview, rpdbview;
544 if (pdbe.size() == 1)
546 structureMenu.add(gpdbview = new JMenuItem(MessageManager
547 .formatMessage("label.view_structure_for", new String[]
548 { sqass.getDisplayId(false) })));
552 structureMenu.add(gpdbview = new JMenuItem(MessageManager
553 .formatMessage("label.view_all_structures", new String[]
554 { new Integer(pdbe.size()).toString() })));
556 gpdbview.setToolTipText(MessageManager
557 .getString("label.open_new_jmol_view_with_all_structures_associated_current_selection_superimpose_using_alignment"));
558 gpdbview.addActionListener(new ActionListener()
562 public void actionPerformed(ActionEvent e)
564 new StructureViewer(ap.getStructureSelectionManager()).viewStructures(ap, pe, ap.av.collateForPDB(pe));
567 if (reppdb.size() > 1 && reppdb.size() < pdbe.size())
569 structureMenu.add(rpdbview = new JMenuItem(MessageManager
571 "label.view_all_representative_structures",
573 { new Integer(reppdb.size()).toString() })));
574 rpdbview.setToolTipText(MessageManager
575 .getString("label.open_new_jmol_view_with_all_representative_structures_associated_current_selection_superimpose_using_alignment"));
576 rpdbview.addActionListener(new ActionListener()
580 public void actionPerformed(ActionEvent e)
582 new StructureViewer(ap.getStructureSelectionManager()).viewStructures(ap, pr, ap.av.collateForPDB(pr));
590 groupMenu.setVisible(false);
591 editMenu.setVisible(false);
596 createGroupMenuItem.setVisible(true);
597 unGroupMenuItem.setVisible(false);
598 jMenu1.setText(MessageManager.getString("action.edit_new_group"));
602 createGroupMenuItem.setVisible(false);
603 unGroupMenuItem.setVisible(true);
604 jMenu1.setText(MessageManager.getString("action.edit_group"));
609 sequenceMenu.setVisible(false);
610 structureMenu.setVisible(false);
613 if (links != null && links.size() > 0)
616 JMenu linkMenu = new JMenu(MessageManager.getString("action.link"));
617 Vector linkset = new Vector();
618 for (int i = 0; i < links.size(); i++)
620 String link = links.elementAt(i).toString();
621 UrlLink urlLink = null;
624 urlLink = new UrlLink(link);
625 } catch (Exception foo)
627 jalview.bin.Cache.log.error("Exception for URLLink '" + link
632 if (!urlLink.isValid())
634 jalview.bin.Cache.log.error(urlLink.getInvalidMessage());
637 final String label = urlLink.getLabel();
638 if (seq != null && urlLink.isDynamic())
641 // collect matching db-refs
642 DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(
643 seq.getDBRef(), new String[]
644 { urlLink.getTarget() });
645 // collect id string too
646 String id = seq.getName();
647 String descr = seq.getDescription();
648 if (descr != null && descr.length() < 1)
655 for (int r = 0; r < dbr.length; r++)
657 if (id != null && dbr[r].getAccessionId().equals(id))
659 // suppress duplicate link creation for the bare sequence ID
660 // string with this link
663 // create Bare ID link for this RUL
664 String[] urls = urlLink.makeUrls(dbr[r].getAccessionId(),
668 for (int u = 0; u < urls.length; u += 2)
670 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
672 linkset.addElement(urls[u] + "|" + urls[u + 1]);
673 addshowLink(linkMenu, label + "|" + urls[u],
682 // create Bare ID link for this RUL
683 String[] urls = urlLink.makeUrls(id, true);
686 for (int u = 0; u < urls.length; u += 2)
688 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
690 linkset.addElement(urls[u] + "|" + urls[u + 1]);
691 addshowLink(linkMenu, label, urls[u + 1]);
696 // Create urls from description but only for URL links which are regex
698 if (descr != null && urlLink.getRegexReplace() != null)
700 // create link for this URL from description where regex matches
701 String[] urls = urlLink.makeUrls(descr, true);
704 for (int u = 0; u < urls.length; u += 2)
706 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
708 linkset.addElement(urls[u] + "|" + urls[u + 1]);
709 addshowLink(linkMenu, label, urls[u + 1]);
717 if (!linkset.contains(label + "|" + urlLink.getUrl_prefix()))
719 linkset.addElement(label + "|" + urlLink.getUrl_prefix());
720 // Add a non-dynamic link
721 addshowLink(linkMenu, label, urlLink.getUrl_prefix());
725 if (sequence != null)
727 sequenceMenu.add(linkMenu);
736 private void buildGroupURLMenu(SequenceGroup sg, Vector groupLinks)
739 // TODO: usability: thread off the generation of group url content so root
741 // sequence only URLs
742 // ID/regex match URLs
743 groupLinksMenu = new JMenu(
744 MessageManager.getString("action.group_link"));
745 JMenu[] linkMenus = new JMenu[]
746 { null, new JMenu(MessageManager.getString("action.ids")),
747 new JMenu(MessageManager.getString("action.sequences")),
748 new JMenu(MessageManager.getString("action.ids_sequences")) }; // three
755 SequenceI[] seqs = ap.av.getSelectionAsNewSequence();
756 String[][] idandseqs = GroupUrlLink.formStrings(seqs);
757 Hashtable commonDbrefs = new Hashtable();
758 for (int sq = 0; sq < seqs.length; sq++)
761 int start = seqs[sq].findPosition(sg.getStartRes()), end = seqs[sq]
762 .findPosition(sg.getEndRes());
763 // just collect ids from dataset sequence
764 // TODO: check if IDs collected from selecton group intersects with the
765 // current selection, too
766 SequenceI sqi = seqs[sq];
767 while (sqi.getDatasetSequence() != null)
769 sqi = sqi.getDatasetSequence();
771 DBRefEntry[] dbr = sqi.getDBRef();
772 if (dbr != null && dbr.length > 0)
774 for (int d = 0; d < dbr.length; d++)
776 String src = dbr[d].getSource(); // jalview.util.DBRefUtils.getCanonicalName(dbr[d].getSource()).toUpperCase();
777 Object[] sarray = (Object[]) commonDbrefs.get(src);
780 sarray = new Object[2];
781 sarray[0] = new int[]
783 sarray[1] = new String[seqs.length];
785 commonDbrefs.put(src, sarray);
788 if (((String[]) sarray[1])[sq] == null)
791 || (dbr[d].getMap().locateMappedRange(start, end) != null))
793 ((String[]) sarray[1])[sq] = dbr[d].getAccessionId();
794 ((int[]) sarray[0])[0]++;
800 // now create group links for all distinct ID/sequence sets.
801 boolean addMenu = false; // indicates if there are any group links to give
803 for (int i = 0; i < groupLinks.size(); i++)
805 String link = groupLinks.elementAt(i).toString();
806 GroupUrlLink urlLink = null;
809 urlLink = new GroupUrlLink(link);
810 } catch (Exception foo)
812 jalview.bin.Cache.log.error("Exception for GroupURLLink '" + link
817 if (!urlLink.isValid())
819 jalview.bin.Cache.log.error(urlLink.getInvalidMessage());
822 final String label = urlLink.getLabel();
823 boolean usingNames = false;
824 // Now see which parts of the group apply for this URL
825 String ltarget = urlLink.getTarget(); // jalview.util.DBRefUtils.getCanonicalName(urlLink.getTarget());
826 Object[] idset = (Object[]) commonDbrefs.get(ltarget.toUpperCase());
827 String[] seqstr, ids; // input to makeUrl
830 int numinput = ((int[]) idset[0])[0];
831 String[] allids = ((String[]) idset[1]);
832 seqstr = new String[numinput];
833 ids = new String[numinput];
834 for (int sq = 0, idcount = 0; sq < seqs.length; sq++)
836 if (allids[sq] != null)
838 ids[idcount] = allids[sq];
839 seqstr[idcount++] = idandseqs[1][sq];
845 // just use the id/seq set
846 seqstr = idandseqs[1];
850 // and try and make the groupURL!
852 Object[] urlset = null;
855 urlset = urlLink.makeUrlStubs(ids, seqstr,
856 "FromJalview" + System.currentTimeMillis(), false);
857 } catch (UrlStringTooLongException e)
862 int type = urlLink.getGroupURLType() & 3;
863 // System.out.println(urlLink.getGroupURLType()
864 // +" "+((String[])urlset[3])[0]);
865 // first two bits ofurlLink type bitfield are sequenceids and sequences
866 // TODO: FUTURE: ensure the groupURL menu structure can be generalised
867 addshowLink(linkMenus[type], label
868 + (((type & 1) == 1) ? ("("
869 + (usingNames ? "Names" : ltarget) + ")") : ""),
876 groupLinksMenu = new JMenu(
877 MessageManager.getString("action.group_link"));
878 for (int m = 0; m < linkMenus.length; m++)
880 if (linkMenus[m] != null
881 && linkMenus[m].getMenuComponentCount() > 0)
883 groupLinksMenu.add(linkMenus[m]);
887 groupMenu.add(groupLinksMenu);
892 * add a show URL menu item to the given linkMenu
896 * - menu label string
900 private void addshowLink(JMenu linkMenu, String label, final String url)
902 JMenuItem item = new JMenuItem(label);
903 item.setToolTipText(MessageManager.formatMessage(
904 "label.open_url_param", new String[]
906 item.addActionListener(new java.awt.event.ActionListener()
908 public void actionPerformed(ActionEvent e)
910 new Thread(new Runnable()
926 * add a late bound groupURL item to the given linkMenu
930 * - menu label string
931 * @param urlgenerator
932 * GroupURLLink used to generate URL
934 * Object array returned from the makeUrlStubs function.
936 private void addshowLink(JMenu linkMenu, String label,
937 final GroupUrlLink urlgenerator, final Object[] urlstub)
939 JMenuItem item = new JMenuItem(label);
940 item.setToolTipText(MessageManager.formatMessage(
941 "label.open_url_seqs_param",
943 { urlgenerator.getUrl_prefix(),
944 urlgenerator.getNumberInvolved(urlstub) }));
945 // TODO: put in info about what is being sent.
946 item.addActionListener(new java.awt.event.ActionListener()
948 public void actionPerformed(ActionEvent e)
950 new Thread(new Runnable()
957 showLink(urlgenerator.constructFrom(urlstub));
958 } catch (UrlStringTooLongException e)
976 private void jbInit() throws Exception
978 groupMenu.setText(MessageManager.getString("label.group"));
979 groupMenu.setText(MessageManager.getString("label.selection"));
980 groupName.setText(MessageManager.getString("label.name"));
981 groupName.addActionListener(new java.awt.event.ActionListener()
983 public void actionPerformed(ActionEvent e)
985 groupName_actionPerformed();
988 sequenceMenu.setText(MessageManager.getString("label.sequence"));
989 sequenceName.setText(MessageManager
990 .getString("label.edit_name_description"));
991 sequenceName.addActionListener(new java.awt.event.ActionListener()
993 public void actionPerformed(ActionEvent e)
995 sequenceName_actionPerformed();
998 sequenceDetails.setText(MessageManager
999 .getString("label.sequence_details") + "...");
1000 sequenceDetails.addActionListener(new java.awt.event.ActionListener()
1002 public void actionPerformed(ActionEvent e)
1004 sequenceDetails_actionPerformed();
1007 sequenceSelDetails.setText(MessageManager
1008 .getString("label.sequence_details") + "...");
1010 .addActionListener(new java.awt.event.ActionListener()
1012 public void actionPerformed(ActionEvent e)
1014 sequenceSelectionDetails_actionPerformed();
1017 PIDColour.setFocusPainted(false);
1019 .setText(MessageManager.getString("action.remove_group"));
1020 unGroupMenuItem.addActionListener(new java.awt.event.ActionListener()
1022 public void actionPerformed(ActionEvent e)
1024 unGroupMenuItem_actionPerformed();
1027 createGroupMenuItem.setText(MessageManager
1028 .getString("action.create_group"));
1030 .addActionListener(new java.awt.event.ActionListener()
1032 public void actionPerformed(ActionEvent e)
1034 createGroupMenuItem_actionPerformed();
1038 outline.setText(MessageManager.getString("action.border_colour"));
1039 outline.addActionListener(new java.awt.event.ActionListener()
1041 public void actionPerformed(ActionEvent e)
1043 outline_actionPerformed();
1047 .setText(MessageManager.getString("label.nucleotide"));
1048 nucleotideMenuItem.addActionListener(new ActionListener()
1050 public void actionPerformed(ActionEvent e)
1052 nucleotideMenuItem_actionPerformed();
1055 colourMenu.setText(MessageManager.getString("label.group_colour"));
1056 showBoxes.setText(MessageManager.getString("action.boxes"));
1057 showBoxes.setState(true);
1058 showBoxes.addActionListener(new ActionListener()
1060 public void actionPerformed(ActionEvent e)
1062 showBoxes_actionPerformed();
1065 showText.setText(MessageManager.getString("action.text"));
1066 showText.setState(true);
1067 showText.addActionListener(new ActionListener()
1069 public void actionPerformed(ActionEvent e)
1071 showText_actionPerformed();
1074 showColourText.setText(MessageManager.getString("label.colour_text"));
1075 showColourText.addActionListener(new ActionListener()
1077 public void actionPerformed(ActionEvent e)
1079 showColourText_actionPerformed();
1082 displayNonconserved.setText(MessageManager
1083 .getString("label.show_non_conversed"));
1084 displayNonconserved.setState(true);
1085 displayNonconserved.addActionListener(new ActionListener()
1087 public void actionPerformed(ActionEvent e)
1089 showNonconserved_actionPerformed();
1092 editMenu.setText(MessageManager.getString("action.edit"));
1093 cut.setText(MessageManager.getString("action.cut"));
1094 cut.addActionListener(new ActionListener()
1096 public void actionPerformed(ActionEvent e)
1098 cut_actionPerformed();
1101 upperCase.setText(MessageManager.getString("label.to_upper_case"));
1102 upperCase.addActionListener(new ActionListener()
1104 public void actionPerformed(ActionEvent e)
1109 copy.setText(MessageManager.getString("action.copy"));
1110 copy.addActionListener(new ActionListener()
1112 public void actionPerformed(ActionEvent e)
1114 copy_actionPerformed();
1117 lowerCase.setText(MessageManager.getString("label.to_lower_case"));
1118 lowerCase.addActionListener(new ActionListener()
1120 public void actionPerformed(ActionEvent e)
1125 toggle.setText(MessageManager.getString("label.toggle_case"));
1126 toggle.addActionListener(new ActionListener()
1128 public void actionPerformed(ActionEvent e)
1133 pdbMenu.setText(MessageManager
1134 .getString("label.associate_structure_with_sequence"));
1135 pdbFromFile.setText(MessageManager.getString("label.from_file"));
1136 pdbFromFile.addActionListener(new ActionListener()
1138 public void actionPerformed(ActionEvent e)
1140 pdbFromFile_actionPerformed();
1143 // RNAFold.setText("From RNA Fold with predict2D");
1144 // RNAFold.addActionListener(new ActionListener()
1146 // public void actionPerformed(ActionEvent e)
1149 // RNAFold_actionPerformed();
1150 // } catch (Exception e1) {
1151 // // TODO Auto-generated catch block
1152 // e1.printStackTrace();
1156 // ContraFold.setText("From Contra Fold with predict2D");
1157 // ContraFold.addActionListener(new ActionListener()
1159 // public void actionPerformed(ActionEvent e)
1162 // ContraFold_actionPerformed();
1163 // } catch (Exception e1) {
1164 // // TODO Auto-generated catch block
1165 // e1.printStackTrace();
1169 enterPDB.setText(MessageManager.getString("label.enter_pdb_id"));
1170 enterPDB.addActionListener(new ActionListener()
1172 public void actionPerformed(ActionEvent e)
1174 enterPDB_actionPerformed();
1177 discoverPDB.setText(MessageManager.getString("label.discover_pdb_ids"));
1178 discoverPDB.addActionListener(new ActionListener()
1180 public void actionPerformed(ActionEvent e)
1182 discoverPDB_actionPerformed();
1185 outputMenu.setText(MessageManager.getString("label.out_to_textbox")
1187 sequenceFeature.setText(MessageManager
1188 .getString("label.create_sequence_feature"));
1189 sequenceFeature.addActionListener(new ActionListener()
1191 public void actionPerformed(ActionEvent e)
1193 sequenceFeature_actionPerformed();
1196 textColour.setText(MessageManager.getString("label.text_colour"));
1197 textColour.addActionListener(new ActionListener()
1199 public void actionPerformed(ActionEvent e)
1201 textColour_actionPerformed();
1204 jMenu1.setText(MessageManager.getString("label.group"));
1205 structureMenu.setText(MessageManager.getString("label.structure"));
1206 viewStructureMenu.setText(MessageManager
1207 .getString("label.view_structure"));
1208 // colStructureMenu.setText("Colour By Structure");
1209 editSequence.setText(MessageManager.getString("label.edit_sequence")
1211 editSequence.addActionListener(new ActionListener()
1213 public void actionPerformed(ActionEvent actionEvent)
1215 editSequence_actionPerformed(actionEvent);
1220 * annotationMenuItem.setText("By Annotation");
1221 * annotationMenuItem.addActionListener(new ActionListener() { public void
1222 * actionPerformed(ActionEvent actionEvent) {
1223 * annotationMenuItem_actionPerformed(actionEvent); } });
1225 groupMenu.add(sequenceSelDetails);
1228 this.add(structureMenu);
1229 groupMenu.add(editMenu);
1230 groupMenu.add(outputMenu);
1231 groupMenu.add(sequenceFeature);
1232 groupMenu.add(createGroupMenuItem);
1233 groupMenu.add(unGroupMenuItem);
1234 groupMenu.add(jMenu1);
1235 sequenceMenu.add(sequenceName);
1236 sequenceMenu.add(sequenceDetails);
1237 colourMenu.add(textColour);
1238 colourMenu.add(noColourmenuItem);
1239 colourMenu.add(clustalColour);
1240 colourMenu.add(BLOSUM62Colour);
1241 colourMenu.add(PIDColour);
1242 colourMenu.add(zappoColour);
1243 colourMenu.add(taylorColour);
1244 colourMenu.add(hydrophobicityColour);
1245 colourMenu.add(helixColour);
1246 colourMenu.add(strandColour);
1247 colourMenu.add(turnColour);
1248 colourMenu.add(buriedColour);
1249 colourMenu.add(nucleotideMenuItem);
1250 if (ap.getAlignment().isNucleotide())
1252 // JBPNote - commented since the colourscheme isn't functional
1253 // colourMenu.add(RNAInteractionColour);
1254 colourMenu.add(purinePyrimidineColour);
1256 // colourMenu.add(covariationColour);
1257 colourMenu.add(userDefinedColour);
1259 if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null)
1261 java.util.Enumeration userColours = jalview.gui.UserDefinedColours
1262 .getUserColourSchemes().keys();
1264 while (userColours.hasMoreElements())
1266 JMenuItem item = new JMenuItem(userColours.nextElement().toString());
1267 item.addActionListener(new ActionListener()
1269 public void actionPerformed(ActionEvent evt)
1271 userDefinedColour_actionPerformed(evt);
1274 colourMenu.add(item);
1278 colourMenu.addSeparator();
1279 colourMenu.add(abovePIDColour);
1280 colourMenu.add(conservationMenuItem);
1281 // colourMenu.add(annotationMenuItem);
1284 editMenu.add(editSequence);
1285 editMenu.add(upperCase);
1286 editMenu.add(lowerCase);
1287 editMenu.add(toggle);
1288 pdbMenu.add(pdbFromFile);
1289 // JBPNote: These shouldn't be added here - should appear in a generic
1290 // 'apply web service to this sequence menu'
1291 // pdbMenu.add(RNAFold);
1292 // pdbMenu.add(ContraFold);
1293 pdbMenu.add(enterPDB);
1294 pdbMenu.add(discoverPDB);
1295 jMenu1.add(groupName);
1296 jMenu1.add(colourMenu);
1297 jMenu1.add(showBoxes);
1298 jMenu1.add(showText);
1299 jMenu1.add(showColourText);
1300 jMenu1.add(outline);
1301 jMenu1.add(displayNonconserved);
1302 structureMenu.add(pdbMenu);
1303 structureMenu.add(viewStructureMenu);
1304 // structureMenu.add(colStructureMenu);
1305 noColourmenuItem.setText(MessageManager.getString("label.none"));
1306 noColourmenuItem.addActionListener(new java.awt.event.ActionListener()
1308 public void actionPerformed(ActionEvent e)
1310 noColourmenuItem_actionPerformed();
1314 clustalColour.setText(MessageManager
1315 .getString("label.clustalx_colours"));
1316 clustalColour.addActionListener(new java.awt.event.ActionListener()
1318 public void actionPerformed(ActionEvent e)
1320 clustalColour_actionPerformed();
1323 zappoColour.setText(MessageManager.getString("label.zappo"));
1324 zappoColour.addActionListener(new java.awt.event.ActionListener()
1326 public void actionPerformed(ActionEvent e)
1328 zappoColour_actionPerformed();
1331 taylorColour.setText(MessageManager.getString("label.taylor"));
1332 taylorColour.addActionListener(new java.awt.event.ActionListener()
1334 public void actionPerformed(ActionEvent e)
1336 taylorColour_actionPerformed();
1339 hydrophobicityColour.setText(MessageManager
1340 .getString("label.hydrophobicity"));
1341 hydrophobicityColour
1342 .addActionListener(new java.awt.event.ActionListener()
1344 public void actionPerformed(ActionEvent e)
1346 hydrophobicityColour_actionPerformed();
1349 helixColour.setText(MessageManager.getString("label.helix_propensity"));
1350 helixColour.addActionListener(new java.awt.event.ActionListener()
1352 public void actionPerformed(ActionEvent e)
1354 helixColour_actionPerformed();
1357 strandColour.setText(MessageManager
1358 .getString("label.strand_propensity"));
1359 strandColour.addActionListener(new java.awt.event.ActionListener()
1361 public void actionPerformed(ActionEvent e)
1363 strandColour_actionPerformed();
1366 turnColour.setText(MessageManager.getString("label.turn_propensity"));
1367 turnColour.addActionListener(new java.awt.event.ActionListener()
1369 public void actionPerformed(ActionEvent e)
1371 turnColour_actionPerformed();
1374 buriedColour.setText(MessageManager.getString("label.buried_index"));
1375 buriedColour.addActionListener(new java.awt.event.ActionListener()
1377 public void actionPerformed(ActionEvent e)
1379 buriedColour_actionPerformed();
1382 abovePIDColour.setText(MessageManager
1383 .getString("label.above_identity_percentage"));
1384 abovePIDColour.addActionListener(new java.awt.event.ActionListener()
1386 public void actionPerformed(ActionEvent e)
1388 abovePIDColour_actionPerformed();
1391 userDefinedColour.setText(MessageManager
1392 .getString("action.user_defined"));
1393 userDefinedColour.addActionListener(new java.awt.event.ActionListener()
1395 public void actionPerformed(ActionEvent e)
1397 userDefinedColour_actionPerformed(e);
1401 .setText(MessageManager.getString("label.percentage_identity"));
1402 PIDColour.addActionListener(new java.awt.event.ActionListener()
1404 public void actionPerformed(ActionEvent e)
1406 PIDColour_actionPerformed();
1409 BLOSUM62Colour.setText(MessageManager.getString("label.blosum62"));
1410 BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener()
1412 public void actionPerformed(ActionEvent e)
1414 BLOSUM62Colour_actionPerformed();
1417 purinePyrimidineColour.setText(MessageManager
1418 .getString("label.purine_pyrimidine"));
1419 purinePyrimidineColour
1420 .addActionListener(new java.awt.event.ActionListener()
1422 public void actionPerformed(ActionEvent e)
1424 purinePyrimidineColour_actionPerformed();
1429 * covariationColour.addActionListener(new java.awt.event.ActionListener() {
1430 * public void actionPerformed(ActionEvent e) {
1431 * covariationColour_actionPerformed(); } });
1434 conservationMenuItem.setText(MessageManager
1435 .getString("label.conservation"));
1436 conservationMenuItem
1437 .addActionListener(new java.awt.event.ActionListener()
1439 public void actionPerformed(ActionEvent e)
1441 conservationMenuItem_actionPerformed();
1446 protected void sequenceSelectionDetails_actionPerformed()
1448 createSequenceDetailsReport(ap.av.getSequenceSelection());
1451 protected void sequenceDetails_actionPerformed()
1453 createSequenceDetailsReport(new SequenceI[]
1457 public void createSequenceDetailsReport(SequenceI[] sequences)
1459 CutAndPasteHtmlTransfer cap = new CutAndPasteHtmlTransfer();
1460 StringBuffer contents = new StringBuffer();
1461 for (SequenceI seq : sequences)
1463 contents.append("<p><h2>"
1466 "label.create_sequence_details_report_annotation_for",
1468 { seq.getDisplayId(true) }) + "</h2></p><p>");
1469 new SequenceAnnotationReport(null)
1470 .createSequenceAnnotationReport(
1476 (ap.seqPanel.seqCanvas.fr != null) ? ap.seqPanel.seqCanvas.fr.minmax
1478 contents.append("</p>");
1480 cap.setText("<html>" + contents.toString() + "</html>");
1482 Desktop.instance.addInternalFrame(cap, MessageManager.formatMessage(
1483 "label.sequece_details_for",
1484 (sequences.length == 1 ? new String[]
1485 { sequences[0].getDisplayId(true) } : new String[]
1486 { MessageManager.getString("label.selection") })), 500, 400);
1490 protected void showNonconserved_actionPerformed()
1492 getGroup().setShowNonconserved(displayNonconserved.isSelected());
1497 * call to refresh view after settings change
1501 ap.updateAnnotation();
1502 ap.paintAlignment(true);
1504 PaintRefresher.Refresh(this, ap.av.getSequenceSetId());
1513 protected void clustalColour_actionPerformed()
1515 SequenceGroup sg = getGroup();
1516 sg.cs = new ClustalxColourScheme(sg, ap.av.getHiddenRepSequences());
1526 protected void zappoColour_actionPerformed()
1528 getGroup().cs = new ZappoColourScheme();
1538 protected void taylorColour_actionPerformed()
1540 getGroup().cs = new TaylorColourScheme();
1550 protected void hydrophobicityColour_actionPerformed()
1552 getGroup().cs = new HydrophobicColourScheme();
1562 protected void helixColour_actionPerformed()
1564 getGroup().cs = new HelixColourScheme();
1574 protected void strandColour_actionPerformed()
1576 getGroup().cs = new StrandColourScheme();
1586 protected void turnColour_actionPerformed()
1588 getGroup().cs = new TurnColourScheme();
1598 protected void buriedColour_actionPerformed()
1600 getGroup().cs = new BuriedColourScheme();
1610 public void nucleotideMenuItem_actionPerformed()
1612 getGroup().cs = new NucleotideColourScheme();
1616 protected void purinePyrimidineColour_actionPerformed()
1618 getGroup().cs = new PurinePyrimidineColourScheme();
1623 * protected void covariationColour_actionPerformed() { getGroup().cs = new
1624 * CovariationColourScheme(sequence.getAnnotation()[0]); refresh(); }
1632 protected void abovePIDColour_actionPerformed()
1634 SequenceGroup sg = getGroup();
1640 if (abovePIDColour.isSelected())
1642 sg.cs.setConsensus(AAFrequency.calculate(
1643 sg.getSequences(ap.av.getHiddenRepSequences()),
1644 sg.getStartRes(), sg.getEndRes() + 1));
1646 int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
1649 sg.cs.setThreshold(threshold, ap.av.getIgnoreGapsConsensus());
1651 SliderPanel.showPIDSlider();
1654 // remove PIDColouring
1656 sg.cs.setThreshold(0, ap.av.getIgnoreGapsConsensus());
1668 protected void userDefinedColour_actionPerformed(ActionEvent e)
1670 SequenceGroup sg = getGroup();
1672 if (e.getSource().equals(userDefinedColour))
1674 new UserDefinedColours(ap, sg);
1678 UserColourScheme udc = (UserColourScheme) UserDefinedColours
1679 .getUserColourSchemes().get(e.getActionCommand());
1692 protected void PIDColour_actionPerformed()
1694 SequenceGroup sg = getGroup();
1695 sg.cs = new PIDColourScheme();
1696 sg.cs.setConsensus(AAFrequency.calculate(
1697 sg.getSequences(ap.av.getHiddenRepSequences()),
1698 sg.getStartRes(), sg.getEndRes() + 1));
1708 protected void BLOSUM62Colour_actionPerformed()
1710 SequenceGroup sg = getGroup();
1712 sg.cs = new Blosum62ColourScheme();
1714 sg.cs.setConsensus(AAFrequency.calculate(
1715 sg.getSequences(ap.av.getHiddenRepSequences()),
1716 sg.getStartRes(), sg.getEndRes() + 1));
1727 protected void noColourmenuItem_actionPerformed()
1729 getGroup().cs = null;
1739 protected void conservationMenuItem_actionPerformed()
1741 SequenceGroup sg = getGroup();
1747 if (conservationMenuItem.isSelected())
1749 // JBPNote: Conservation name shouldn't be i18n translated
1750 Conservation c = new Conservation("Group",
1751 ResidueProperties.propHash, 3, sg.getSequences(ap.av
1752 .getHiddenRepSequences()), sg.getStartRes(),
1753 sg.getEndRes() + 1);
1756 c.verdict(false, ap.av.getConsPercGaps());
1758 sg.cs.setConservation(c);
1760 SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
1761 SliderPanel.showConservationSlider();
1764 // remove ConservationColouring
1766 sg.cs.setConservation(null);
1772 public void annotationMenuItem_actionPerformed(ActionEvent actionEvent)
1774 SequenceGroup sg = getGroup();
1780 AnnotationColourGradient acg = new AnnotationColourGradient(
1781 sequence.getAnnotation()[0], null,
1782 AnnotationColourGradient.NO_THRESHOLD);
1784 acg.setPredefinedColours(true);
1796 protected void groupName_actionPerformed()
1799 SequenceGroup sg = getGroup();
1800 EditNameDialog dialog = new EditNameDialog(sg.getName(),
1801 sg.getDescription(), " "
1802 + MessageManager.getString("label.group_name") + " ",
1803 MessageManager.getString("label.group_description") + " ",
1804 MessageManager.getString("label.edit_group_name_description"),
1812 sg.setName(dialog.getName());
1813 sg.setDescription(dialog.getDescription());
1818 * Get selection group - adding it to the alignment if necessary.
1820 * @return sequence group to operate on
1822 SequenceGroup getGroup()
1824 SequenceGroup sg = ap.av.getSelectionGroup();
1825 // this method won't add a new group if it already exists
1828 ap.av.getAlignment().addGroup(sg);
1840 void sequenceName_actionPerformed()
1842 EditNameDialog dialog = new EditNameDialog(sequence.getName(),
1843 sequence.getDescription(),
1844 " " + MessageManager.getString("label.sequence_name")
1846 MessageManager.getString("label.sequence_description") + " ",
1848 .getString("label.edit_sequence_name_description"),
1856 if (dialog.getName() != null)
1858 if (dialog.getName().indexOf(" ") > -1)
1864 .getString("label.spaces_converted_to_backslashes"),
1866 .getString("label.no_spaces_allowed_sequence_name"),
1867 JOptionPane.WARNING_MESSAGE);
1870 sequence.setName(dialog.getName().replace(' ', '_'));
1871 ap.paintAlignment(false);
1874 sequence.setDescription(dialog.getDescription());
1876 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1887 void unGroupMenuItem_actionPerformed()
1889 SequenceGroup sg = ap.av.getSelectionGroup();
1890 ap.av.getAlignment().deleteGroup(sg);
1891 ap.av.setSelectionGroup(null);
1895 void createGroupMenuItem_actionPerformed()
1897 getGroup(); // implicitly creates group - note - should apply defaults / use
1898 // standard alignment window logic for this
1908 protected void outline_actionPerformed()
1910 SequenceGroup sg = getGroup();
1911 Color col = JColorChooser.showDialog(this,
1912 MessageManager.getString("label.select_outline_colour"),
1917 sg.setOutlineColour(col);
1929 public void showBoxes_actionPerformed()
1931 getGroup().setDisplayBoxes(showBoxes.isSelected());
1941 public void showText_actionPerformed()
1943 getGroup().setDisplayText(showText.isSelected());
1953 public void showColourText_actionPerformed()
1955 getGroup().setColourText(showColourText.isSelected());
1959 public void showLink(String url)
1963 jalview.util.BrowserLauncher.openURL(url);
1964 } catch (Exception ex)
1966 JOptionPane.showInternalMessageDialog(Desktop.desktop,
1967 MessageManager.getString("label.web_browser_not_found_unix"),
1968 MessageManager.getString("label.web_browser_not_found"),
1969 JOptionPane.WARNING_MESSAGE);
1971 ex.printStackTrace();
1975 void hideSequences(boolean representGroup)
1977 SequenceGroup sg = ap.av.getSelectionGroup();
1978 if (sg == null || sg.getSize() < 1)
1980 ap.av.hideSequence(new SequenceI[]
1985 ap.av.setSelectionGroup(null);
1989 ap.av.hideRepSequences(sequence, sg);
1994 int gsize = sg.getSize();
1997 hseqs = new SequenceI[gsize];
2000 for (int i = 0; i < gsize; i++)
2002 hseqs[index++] = sg.getSequenceAt(i);
2005 ap.av.hideSequence(hseqs);
2006 // refresh(); TODO: ? needed ?
2007 ap.av.sendSelection();
2010 public void copy_actionPerformed()
2012 ap.alignFrame.copy_actionPerformed(null);
2015 public void cut_actionPerformed()
2017 ap.alignFrame.cut_actionPerformed(null);
2020 void changeCase(ActionEvent e)
2022 Object source = e.getSource();
2023 SequenceGroup sg = ap.av.getSelectionGroup();
2027 int[][] startEnd = ap.av.getVisibleRegionBoundaries(sg.getStartRes(),
2028 sg.getEndRes() + 1);
2033 if (source == toggle)
2035 description = MessageManager.getString("label.toggle_case");
2036 caseChange = ChangeCaseCommand.TOGGLE_CASE;
2038 else if (source == upperCase)
2040 description = MessageManager.getString("label.to_upper_case");
2041 caseChange = ChangeCaseCommand.TO_UPPER;
2045 description = MessageManager.getString("label.to_lower_case");
2046 caseChange = ChangeCaseCommand.TO_LOWER;
2049 ChangeCaseCommand caseCommand = new ChangeCaseCommand(description,
2050 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
2051 startEnd, caseChange);
2053 ap.alignFrame.addHistoryItem(caseCommand);
2055 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
2061 public void outputText_actionPerformed(ActionEvent e)
2063 CutAndPasteTransfer cap = new CutAndPasteTransfer();
2064 cap.setForInput(null);
2065 Desktop.addInternalFrame(cap, MessageManager.formatMessage(
2066 "label.alignment_output_command", new String[]
2067 { e.getActionCommand() }), 600, 500);
2069 String[] omitHidden = null;
2071 System.out.println("PROMPT USER HERE"); // TODO: decide if a prompt happens
2072 // or we simply trust the user wants
2073 // wysiwig behaviour
2075 AlignmentView selvew = ap.av.getAlignmentView(true, false);
2076 AlignmentI aselview = selvew.getVisibleAlignment(ap.av
2077 .getGapCharacter());
2078 List<AlignmentAnnotation> ala = (ap.av
2079 .getVisibleAlignmentAnnotation(true));
2082 for (AlignmentAnnotation aa : ala)
2084 aselview.addAnnotation(aa);
2087 cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(),
2088 aselview, null, null, null));
2091 public void pdbFromFile_actionPerformed()
2093 jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(
2094 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
2095 chooser.setFileView(new jalview.io.JalviewFileView());
2096 chooser.setDialogTitle(MessageManager.formatMessage(
2097 "label.select_pdb_file_for", new String[]
2098 { sequence.getDisplayId(false) }));
2099 chooser.setToolTipText(MessageManager.formatMessage(
2100 "label.load_pdb_file_associate_with_sequence", new String[]
2101 { sequence.getDisplayId(false) }));
2103 int value = chooser.showOpenDialog(null);
2105 if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
2107 String choice = chooser.getSelectedFile().getPath();
2108 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
2109 new AssociatePdbFileWithSeq().associatePdbWithSeq(choice,
2110 jalview.io.AppletFormatAdapter.FILE, sequence, true);
2115 // JBNote: commented out - these won't be instantiated here...!
2116 // public void RNAFold_actionPerformed() throws Exception
2118 // Predict2D P2D = new Predict2D();
2119 // P2D.getStructure2DFromRNAFold("toto");
2122 // public void ContraFold_actionPerformed() throws Exception
2124 // Predict2D P2D = new Predict2D();
2125 // P2D.getStructure2DFromContraFold("toto");
2127 public void enterPDB_actionPerformed()
2129 String id = JOptionPane.showInternalInputDialog(Desktop.desktop,
2130 MessageManager.getString("label.enter_pdb_id"),
2131 MessageManager.getString("label.enter_pdb_id"),
2132 JOptionPane.QUESTION_MESSAGE);
2134 if (id != null && id.length() > 0)
2136 PDBEntry entry = new PDBEntry();
2137 entry.setId(id.toUpperCase());
2138 sequence.getDatasetSequence().addPDBId(entry);
2142 public void discoverPDB_actionPerformed()
2145 final SequenceI[] sequences = ((ap.av.getSelectionGroup() == null) ? new SequenceI[]
2147 : ap.av.getSequenceSelection());
2148 Thread discpdb = new Thread(new Runnable()
2153 new jalview.ws.DBRefFetcher(sequences, ap.alignFrame)
2154 .fetchDBRefs(false);
2161 public void sequenceFeature_actionPerformed()
2163 SequenceGroup sg = ap.av.getSelectionGroup();
2169 int rsize = 0, gSize = sg.getSize();
2170 SequenceI[] rseqs, seqs = new SequenceI[gSize];
2171 SequenceFeature[] tfeatures, features = new SequenceFeature[gSize];
2173 for (int i = 0; i < gSize; i++)
2175 int start = sg.getSequenceAt(i).findPosition(sg.getStartRes());
2176 int end = sg.findEndRes(sg.getSequenceAt(i));
2179 seqs[rsize] = sg.getSequenceAt(i).getDatasetSequence();
2180 features[rsize] = new SequenceFeature(null, null, null, start, end,
2185 rseqs = new SequenceI[rsize];
2186 tfeatures = new SequenceFeature[rsize];
2187 System.arraycopy(seqs, 0, rseqs, 0, rsize);
2188 System.arraycopy(features, 0, tfeatures, 0, rsize);
2189 features = tfeatures;
2191 if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs,
2192 features, true, ap))
2194 ap.alignFrame.setShowSeqFeatures(true);
2195 ap.highlightSearchResults(null);
2199 public void textColour_actionPerformed()
2201 SequenceGroup sg = getGroup();
2204 new TextColourChooser().chooseColour(ap, sg);
2208 public void colourByStructure(String pdbid)
2210 Annotation[] anots = ap.av.getStructureSelectionManager()
2211 .colourSequenceFromStructure(sequence, pdbid);
2213 AlignmentAnnotation an = new AlignmentAnnotation("Structure",
2214 "Coloured by " + pdbid, anots);
2216 ap.av.getAlignment().addAnnotation(an);
2217 an.createSequenceMapping(sequence, 0, true);
2218 // an.adjustForAlignment();
2219 ap.av.getAlignment().setAnnotationIndex(an, 0);
2221 ap.adjustAnnotationHeight();
2223 sequence.addAlignmentAnnotation(an);
2227 public void editSequence_actionPerformed(ActionEvent actionEvent)
2229 SequenceGroup sg = ap.av.getSelectionGroup();
2233 if (sequence == null)
2234 sequence = (Sequence) sg.getSequenceAt(0);
2236 EditNameDialog dialog = new EditNameDialog(
2237 sequence.getSequenceAsString(sg.getStartRes(),
2238 sg.getEndRes() + 1), null,
2239 MessageManager.getString("label.edit_sequence"), null,
2240 MessageManager.getString("label.edit_sequence"),
2245 EditCommand editCommand = new EditCommand(
2246 MessageManager.getString("label.edit_sequences"),
2247 EditCommand.REPLACE, dialog.getName().replace(' ',
2248 ap.av.getGapCharacter()),
2249 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
2250 sg.getStartRes(), sg.getEndRes() + 1, ap.av.getAlignment());
2252 ap.alignFrame.addHistoryItem(editCommand);
2254 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()