2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
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 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
17 * The Jalview Authors are detailed in the 'AUTHORS' file.
24 import java.awt.event.*;
28 import jalview.analysis.*;
29 import jalview.commands.*;
30 import jalview.datamodel.*;
32 import jalview.schemes.*;
33 import jalview.util.GroupUrlLink;
34 import jalview.util.GroupUrlLink.UrlStringTooLongException;
35 import jalview.util.MessageManager;
\r
36 import jalview.util.UrlLink;
42 * @version $Revision: 1.118 $
44 public class PopupMenu extends JPopupMenu
46 JMenu groupMenu = new JMenu();
48 JMenuItem groupName = new JMenuItem();
50 protected JRadioButtonMenuItem clustalColour = new JRadioButtonMenuItem();
52 protected JRadioButtonMenuItem zappoColour = new JRadioButtonMenuItem();
54 protected JRadioButtonMenuItem taylorColour = new JRadioButtonMenuItem();
56 protected JRadioButtonMenuItem hydrophobicityColour = new JRadioButtonMenuItem();
58 protected JRadioButtonMenuItem helixColour = new JRadioButtonMenuItem();
60 protected JRadioButtonMenuItem strandColour = new JRadioButtonMenuItem();
62 protected JRadioButtonMenuItem turnColour = new JRadioButtonMenuItem();
64 protected JRadioButtonMenuItem buriedColour = new JRadioButtonMenuItem();
66 protected JCheckBoxMenuItem abovePIDColour = new JCheckBoxMenuItem();
68 protected JRadioButtonMenuItem userDefinedColour = new JRadioButtonMenuItem();
70 protected JRadioButtonMenuItem PIDColour = new JRadioButtonMenuItem();
72 protected JRadioButtonMenuItem BLOSUM62Colour = new JRadioButtonMenuItem();
74 protected JRadioButtonMenuItem purinePyrimidineColour = new JRadioButtonMenuItem();
75 protected JRadioButtonMenuItem RNAInteractionColour = new JRadioButtonMenuItem();
77 // protected JRadioButtonMenuItem covariationColour = new
78 // JRadioButtonMenuItem();
80 JRadioButtonMenuItem noColourmenuItem = new JRadioButtonMenuItem();
82 protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem();
86 JMenu sequenceMenu = new JMenu();
88 JMenuItem sequenceName = new JMenuItem();
90 JMenuItem sequenceDetails = new JMenuItem();
92 JMenuItem sequenceSelDetails = new JMenuItem();
95 JMenuItem createGroupMenuItem = new JMenuItem();
96 JMenuItem unGroupMenuItem = new JMenuItem();
98 JMenuItem outline = new JMenuItem();
100 JRadioButtonMenuItem nucleotideMenuItem = new JRadioButtonMenuItem();
102 JMenu colourMenu = new JMenu();
104 JCheckBoxMenuItem showBoxes = new JCheckBoxMenuItem();
106 JCheckBoxMenuItem showText = new JCheckBoxMenuItem();
108 JCheckBoxMenuItem showColourText = new JCheckBoxMenuItem();
110 JCheckBoxMenuItem displayNonconserved = new JCheckBoxMenuItem();
112 JMenu editMenu = new JMenu();
114 JMenuItem cut = new JMenuItem();
116 JMenuItem copy = new JMenuItem();
118 JMenuItem upperCase = new JMenuItem();
120 JMenuItem lowerCase = new JMenuItem();
122 JMenuItem toggle = new JMenuItem();
124 JMenu pdbMenu = new JMenu();
126 JMenuItem pdbFromFile = new JMenuItem();
127 // JBPNote: Commented these out - Should add these services via the web services menu system.
128 // JMenuItem ContraFold = new JMenuItem();
130 // JMenuItem RNAFold = new JMenuItem();
132 JMenuItem enterPDB = new JMenuItem();
134 JMenuItem discoverPDB = new JMenuItem();
136 JMenu outputMenu = new JMenu();
138 JMenuItem sequenceFeature = new JMenuItem();
140 JMenuItem textColour = new JMenuItem();
142 JMenu jMenu1 = new JMenu();
144 JMenu structureMenu = new JMenu();
146 JMenu viewStructureMenu = new JMenu();
148 // JMenu colStructureMenu = new JMenu();
149 JMenuItem editSequence = new JMenuItem();
151 // JMenuItem annotationMenuItem = new JMenuItem();
153 JMenu groupLinksMenu;
156 * Creates a new PopupMenu object.
163 public PopupMenu(final AlignmentPanel ap, Sequence seq, Vector links)
165 this(ap, seq, links, null);
175 public PopupMenu(final AlignmentPanel ap, final SequenceI seq,
176 Vector links, Vector groupLinks)
178 // /////////////////////////////////////////////////////////
179 // If this is activated from the sequence panel, the user may want to
180 // edit or annotate a particular residue. Therefore display the residue menu
182 // If from the IDPanel, we must display the sequence menu
183 // ////////////////////////////////////////////////////////
187 ButtonGroup colours = new ButtonGroup();
188 colours.add(noColourmenuItem);
189 colours.add(clustalColour);
190 colours.add(zappoColour);
191 colours.add(taylorColour);
192 colours.add(hydrophobicityColour);
193 colours.add(helixColour);
194 colours.add(strandColour);
195 colours.add(turnColour);
196 colours.add(buriedColour);
197 colours.add(abovePIDColour);
198 colours.add(userDefinedColour);
199 colours.add(PIDColour);
200 colours.add(BLOSUM62Colour);
201 colours.add(purinePyrimidineColour);
202 colours.add(RNAInteractionColour);
203 // colours.add(covariationColour);
205 for (int i = 0; i < jalview.io.FormatAdapter.WRITEABLE_FORMATS.length; i++)
207 JMenuItem item = new JMenuItem(
208 jalview.io.FormatAdapter.WRITEABLE_FORMATS[i]);
210 item.addActionListener(new java.awt.event.ActionListener()
212 public void actionPerformed(ActionEvent e)
214 outputText_actionPerformed(e);
218 outputMenu.add(item);
224 } catch (Exception e)
232 sequenceMenu.setText(sequence.getName());
234 if (seq.getDatasetSequence().getPDBId() != null
235 && seq.getDatasetSequence().getPDBId().size() > 0)
237 java.util.Enumeration e = seq.getDatasetSequence().getPDBId()
240 while (e.hasMoreElements())
242 final PDBEntry pdb = (PDBEntry) e.nextElement();
244 menuItem = new JMenuItem();
245 menuItem.setText(pdb.getId());
246 menuItem.addActionListener(new java.awt.event.ActionListener()
248 public void actionPerformed(ActionEvent e)
250 // TODO re JAL-860: optionally open dialog or provide a menu entry
251 // allowing user to open just one structure per sequence
252 new AppJmol(pdb, ap.av.collateForPDB(new PDBEntry[]
253 { pdb })[0], null, ap);
254 // new PDBViewer(pdb, seqs2, null, ap, AppletFormatAdapter.FILE);
258 viewStructureMenu.add(menuItem);
261 * menuItem = new JMenuItem(); menuItem.setText(pdb.getId());
262 * menuItem.addActionListener(new java.awt.event.ActionListener() {
263 * public void actionPerformed(ActionEvent e) {
264 * colourByStructure(pdb.getId()); } });
265 * colStructureMenu.add(menuItem);
271 if (ap.av.getAlignment().isNucleotide() == false)
273 structureMenu.remove(viewStructureMenu);
275 // structureMenu.remove(colStructureMenu);
278 if (ap.av.getAlignment().isNucleotide() == true)
280 AlignmentAnnotation[] aa = ap.av.getAlignment()
281 .getAlignmentAnnotation();
282 for (int i = 0; i < aa.length; i++)
284 if (aa[i].getRNAStruc() != null)
286 final String rnastruc = aa[i].getRNAStruc();
287 final String structureLine = aa[i].label;
288 menuItem = new JMenuItem();
289 menuItem.setText(MessageManager.formatMessage("label.2d_rna_structure_line", new String[]{structureLine}));
\r
290 menuItem.addActionListener(new java.awt.event.ActionListener()
293 public void actionPerformed(ActionEvent e)
295 //System.out.println("1:"+structureLine);
296 System.out.println("1:sname"+seq.getName());
297 System.out.println("2:seq"+seq);
299 //System.out.println("3:"+seq.getSequenceAsString());
300 System.out.println("3:strucseq"+rnastruc);
301 //System.out.println("4:struc"+seq.getRNA());
302 System.out.println("5:name"+seq.getName());
303 System.out.println("6:ap"+ap);
304 new AppVarna(structureLine, seq, seq.getSequenceAsString(), rnastruc, seq
306 //new AppVarna(seq.getName(),seq,rnastruc,seq.getRNA(), seq.getName(), ap);
307 System.out.println("end");
310 viewStructureMenu.add(menuItem);
314 // SequenceFeatures[] test = seq.getSequenceFeatures();
316 if (seq.getAnnotation() != null)
318 AlignmentAnnotation seqAnno[] = seq.getAnnotation();
319 for (int i = 0; i < seqAnno.length; i++)
321 if (seqAnno[i].getRNAStruc() != null)
323 final String rnastruc = seqAnno[i].getRNAStruc();
325 // TODO: make rnastrucF a bit more nice
326 menuItem = new JMenuItem();
327 menuItem.setText(MessageManager.formatMessage("label.2d_rna_sequence_name", new String[]{seq.getName()}));
\r
328 menuItem.addActionListener(new java.awt.event.ActionListener()
330 public void actionPerformed(ActionEvent e)
332 // TODO: VARNA does'nt print gaps in the sequence
334 new AppVarna(seq.getName() + " structure", seq, seq
335 .getSequenceAsString(), rnastruc, seq.getName(),
339 viewStructureMenu.add(menuItem);
346 menuItem = new JMenuItem(MessageManager.getString("action.hide_sequences"));
\r
347 menuItem.addActionListener(new java.awt.event.ActionListener()
349 public void actionPerformed(ActionEvent e)
351 hideSequences(false);
356 if (ap.av.getSelectionGroup() != null
357 && ap.av.getSelectionGroup().getSize() > 1)
359 menuItem = new JMenuItem(MessageManager.formatMessage("label.represent_group_with", new String[]{seq.getName()}));
\r
360 menuItem.addActionListener(new java.awt.event.ActionListener()
362 public void actionPerformed(ActionEvent e)
367 sequenceMenu.add(menuItem);
370 if (ap.av.hasHiddenRows())
372 final int index = ap.av.getAlignment().findIndex(seq);
374 if (ap.av.adjustForHiddenSeqs(index)
375 - ap.av.adjustForHiddenSeqs(index - 1) > 1)
377 menuItem = new JMenuItem(MessageManager.getString("action.reveal_sequences"));
\r
378 menuItem.addActionListener(new ActionListener()
380 public void actionPerformed(ActionEvent e)
382 ap.av.showSequence(index);
383 if (ap.overviewPanel != null)
385 ap.overviewPanel.updateOverviewImage();
393 // for the case when no sequences are even visible
394 if (ap.av.hasHiddenRows())
397 menuItem = new JMenuItem(MessageManager.getString("action.reveal_all"));
\r
398 menuItem.addActionListener(new ActionListener()
400 public void actionPerformed(ActionEvent e)
402 ap.av.showAllHiddenSeqs();
403 if (ap.overviewPanel != null)
405 ap.overviewPanel.updateOverviewImage();
415 SequenceGroup sg = ap.av.getSelectionGroup();
416 boolean isDefinedGroup = (sg!=null) ? ap.av.getAlignment().getGroups().contains(sg) : false;
418 if (sg != null && sg.getSize() > 0)
420 groupName.setText(MessageManager.formatMessage("label.name_param", new String[]{sg.getName()}));
\r
421 groupName.setText(MessageManager.getString("label.edit_name_and_description_current_group"));
\r
423 if (sg.cs instanceof ZappoColourScheme)
425 zappoColour.setSelected(true);
427 else if (sg.cs instanceof TaylorColourScheme)
429 taylorColour.setSelected(true);
431 else if (sg.cs instanceof PIDColourScheme)
433 PIDColour.setSelected(true);
435 else if (sg.cs instanceof Blosum62ColourScheme)
437 BLOSUM62Colour.setSelected(true);
439 else if (sg.cs instanceof UserColourScheme)
441 userDefinedColour.setSelected(true);
443 else if (sg.cs instanceof HydrophobicColourScheme)
445 hydrophobicityColour.setSelected(true);
447 else if (sg.cs instanceof HelixColourScheme)
449 helixColour.setSelected(true);
451 else if (sg.cs instanceof StrandColourScheme)
453 strandColour.setSelected(true);
455 else if (sg.cs instanceof TurnColourScheme)
457 turnColour.setSelected(true);
459 else if (sg.cs instanceof BuriedColourScheme)
461 buriedColour.setSelected(true);
463 else if (sg.cs instanceof ClustalxColourScheme)
465 clustalColour.setSelected(true);
467 else if (sg.cs instanceof PurinePyrimidineColourScheme)
469 purinePyrimidineColour.setSelected(true);
474 * else if (sg.cs instanceof CovariationColourScheme) {
475 * covariationColour.setSelected(true); }
479 noColourmenuItem.setSelected(true);
482 if (sg.cs != null && sg.cs.conservationApplied())
484 conservationMenuItem.setSelected(true);
486 displayNonconserved.setSelected(sg.getShowNonconserved());
487 showText.setSelected(sg.getDisplayText());
488 showColourText.setSelected(sg.getColourText());
489 showBoxes.setSelected(sg.getDisplayBoxes());
490 // add any groupURLs to the groupURL submenu and make it visible
491 if (groupLinks != null && groupLinks.size() > 0)
493 buildGroupURLMenu(sg, groupLinks);
495 // Add a 'show all structures' for the current selection
496 Hashtable<String, PDBEntry> pdbe = new Hashtable<String, PDBEntry>(),reppdb=new Hashtable<String,PDBEntry>();
497 SequenceI sqass = null;
498 for (SequenceI sq : ap.av.getSequenceSelection())
500 Vector<PDBEntry> pes = (Vector<PDBEntry>) sq.getDatasetSequence()
504 reppdb.put(pes.get(0).getId(),pes.get(0));
505 for (PDBEntry pe : pes)
507 pdbe.put(pe.getId(), pe);
517 final PDBEntry[] pe = pdbe.values().toArray(
518 new PDBEntry[pdbe.size()]),pr = reppdb.values().toArray(
519 new PDBEntry[reppdb.size()]);
520 final JMenuItem gpdbview,rpdbview;
521 if (pdbe.size() == 1)
523 structureMenu.add(gpdbview = new JMenuItem(MessageManager.formatMessage("label.view_structure_for", new String[]{sqass.getDisplayId(false)})));
\r
527 structureMenu.add(gpdbview = new JMenuItem(MessageManager.formatMessage("label.view_all_structures", new String[]{new Integer(pdbe.size()).toString()})));
\r
529 gpdbview.setToolTipText(MessageManager.getString("label.open_new_jmol_view_with_all_structures_associated_current_selection_superimpose_using_alignment"));
\r
530 gpdbview.addActionListener(new ActionListener()
534 public void actionPerformed(ActionEvent e)
536 new AppJmol(ap, pe, ap.av.collateForPDB(pe));
539 if (reppdb.size()>1 && reppdb.size()<pdbe.size())
541 structureMenu.add(rpdbview = new JMenuItem(MessageManager.formatMessage("label.view_all_representative_structures", new String[]{new Integer(reppdb.size()).toString()})));
542 rpdbview.setToolTipText(MessageManager.getString("label.open_new_jmol_view_with_all_representative_structures_associated_current_selection_superimpose_using_alignment"));
543 rpdbview.addActionListener(new ActionListener()
547 public void actionPerformed(ActionEvent e)
549 new AppJmol(ap, pr, ap.av.collateForPDB(pr));
557 groupMenu.setVisible(false);
558 editMenu.setVisible(false);
563 createGroupMenuItem.setVisible(true);
564 unGroupMenuItem.setVisible(false);
565 jMenu1.setText(MessageManager.getString("action.edit_new_group"));
\r
567 createGroupMenuItem.setVisible(false);
568 unGroupMenuItem.setVisible(true);
569 jMenu1.setText(MessageManager.getString("action.edit_group"));
\r
574 sequenceMenu.setVisible(false);
575 structureMenu.setVisible(false);
578 if (links != null && links.size() > 0)
581 JMenu linkMenu = new JMenu(MessageManager.getString("action.link"));
\r
582 Vector linkset = new Vector();
583 for (int i = 0; i < links.size(); i++)
585 String link = links.elementAt(i).toString();
586 UrlLink urlLink = null;
589 urlLink = new UrlLink(link);
590 } catch (Exception foo)
592 jalview.bin.Cache.log.error("Exception for URLLink '" + link
597 if (!urlLink.isValid())
599 jalview.bin.Cache.log.error(urlLink.getInvalidMessage());
602 final String label = urlLink.getLabel();
603 if (seq != null && urlLink.isDynamic())
606 // collect matching db-refs
607 DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(
608 seq.getDBRef(), new String[]
609 { urlLink.getTarget() });
610 // collect id string too
611 String id = seq.getName();
612 String descr = seq.getDescription();
613 if (descr != null && descr.length() < 1)
620 for (int r = 0; r < dbr.length; r++)
622 if (id != null && dbr[r].getAccessionId().equals(id))
624 // suppress duplicate link creation for the bare sequence ID
625 // string with this link
628 // create Bare ID link for this RUL
629 String[] urls = urlLink.makeUrls(dbr[r].getAccessionId(),
633 for (int u = 0; u < urls.length; u += 2)
635 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
637 linkset.addElement(urls[u] + "|" + urls[u + 1]);
638 addshowLink(linkMenu, label + "|" + urls[u],
647 // create Bare ID link for this RUL
648 String[] urls = urlLink.makeUrls(id, true);
651 for (int u = 0; u < urls.length; u += 2)
653 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
655 linkset.addElement(urls[u] + "|" + urls[u + 1]);
656 addshowLink(linkMenu, label, urls[u + 1]);
661 // Create urls from description but only for URL links which are regex
663 if (descr != null && urlLink.getRegexReplace() != null)
665 // create link for this URL from description where regex matches
666 String[] urls = urlLink.makeUrls(descr, true);
669 for (int u = 0; u < urls.length; u += 2)
671 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
673 linkset.addElement(urls[u] + "|" + urls[u + 1]);
674 addshowLink(linkMenu, label, urls[u + 1]);
682 if (!linkset.contains(label + "|" + urlLink.getUrl_prefix()))
684 linkset.addElement(label + "|" + urlLink.getUrl_prefix());
685 // Add a non-dynamic link
686 addshowLink(linkMenu, label, urlLink.getUrl_prefix());
690 if (sequence != null)
692 sequenceMenu.add(linkMenu);
701 private void buildGroupURLMenu(SequenceGroup sg, Vector groupLinks)
704 // TODO: usability: thread off the generation of group url content so root
706 // sequence only URLs
707 // ID/regex match URLs
708 groupLinksMenu = new JMenu(MessageManager.getString("action.group_link"));
\r
709 JMenu[] linkMenus = new JMenu[]
710 { null, new JMenu(MessageManager.getString("action.ids")), new JMenu(MessageManager.getString("action.sequences")),
\r
711 new JMenu(MessageManager.getString("action.ids_sequences")) }; // three types of url that might be
\r
713 SequenceI[] seqs = ap.av.getSelectionAsNewSequence();
714 String[][] idandseqs = GroupUrlLink.formStrings(seqs);
715 Hashtable commonDbrefs = new Hashtable();
716 for (int sq = 0; sq < seqs.length; sq++)
719 int start = seqs[sq].findPosition(sg.getStartRes()), end = seqs[sq]
720 .findPosition(sg.getEndRes());
721 // just collect ids from dataset sequence
722 // TODO: check if IDs collected from selecton group intersects with the
723 // current selection, too
724 SequenceI sqi = seqs[sq];
725 while (sqi.getDatasetSequence() != null)
727 sqi = sqi.getDatasetSequence();
729 DBRefEntry[] dbr = sqi.getDBRef();
730 if (dbr != null && dbr.length > 0)
732 for (int d = 0; d < dbr.length; d++)
734 String src = dbr[d].getSource(); // jalview.util.DBRefUtils.getCanonicalName(dbr[d].getSource()).toUpperCase();
735 Object[] sarray = (Object[]) commonDbrefs.get(src);
738 sarray = new Object[2];
739 sarray[0] = new int[]
741 sarray[1] = new String[seqs.length];
743 commonDbrefs.put(src, sarray);
746 if (((String[]) sarray[1])[sq] == null)
749 || (dbr[d].getMap().locateMappedRange(start, end) != null))
751 ((String[]) sarray[1])[sq] = dbr[d].getAccessionId();
752 ((int[]) sarray[0])[0]++;
758 // now create group links for all distinct ID/sequence sets.
759 boolean addMenu = false; // indicates if there are any group links to give
761 for (int i = 0; i < groupLinks.size(); i++)
763 String link = groupLinks.elementAt(i).toString();
764 GroupUrlLink urlLink = null;
767 urlLink = new GroupUrlLink(link);
768 } catch (Exception foo)
770 jalview.bin.Cache.log.error("Exception for GroupURLLink '" + link
775 if (!urlLink.isValid())
777 jalview.bin.Cache.log.error(urlLink.getInvalidMessage());
780 final String label = urlLink.getLabel();
781 boolean usingNames = false;
782 // Now see which parts of the group apply for this URL
783 String ltarget = urlLink.getTarget(); // jalview.util.DBRefUtils.getCanonicalName(urlLink.getTarget());
784 Object[] idset = (Object[]) commonDbrefs.get(ltarget.toUpperCase());
785 String[] seqstr, ids; // input to makeUrl
788 int numinput = ((int[]) idset[0])[0];
789 String[] allids = ((String[]) idset[1]);
790 seqstr = new String[numinput];
791 ids = new String[numinput];
792 for (int sq = 0, idcount = 0; sq < seqs.length; sq++)
794 if (allids[sq] != null)
796 ids[idcount] = allids[sq];
797 seqstr[idcount++] = idandseqs[1][sq];
803 // just use the id/seq set
804 seqstr = idandseqs[1];
808 // and try and make the groupURL!
810 Object[] urlset = null;
813 urlset = urlLink.makeUrlStubs(ids, seqstr,
814 "FromJalview" + System.currentTimeMillis(), false);
815 } catch (UrlStringTooLongException e)
820 int type = urlLink.getGroupURLType() & 3;
821 // System.out.println(urlLink.getGroupURLType()
822 // +" "+((String[])urlset[3])[0]);
823 // first two bits ofurlLink type bitfield are sequenceids and sequences
824 // TODO: FUTURE: ensure the groupURL menu structure can be generalised
825 addshowLink(linkMenus[type], label
826 + (((type & 1) == 1) ? ("("
827 + (usingNames ? "Names" : ltarget) + ")") : ""),
834 groupLinksMenu = new JMenu(MessageManager.getString("action.group_link"));
\r
835 for (int m = 0; m < linkMenus.length; m++)
837 if (linkMenus[m] != null
838 && linkMenus[m].getMenuComponentCount() > 0)
840 groupLinksMenu.add(linkMenus[m]);
844 groupMenu.add(groupLinksMenu);
849 * add a show URL menu item to the given linkMenu
853 * - menu label string
857 private void addshowLink(JMenu linkMenu, String label, final String url)
859 JMenuItem item = new JMenuItem(label);
860 item.setToolTipText(MessageManager.formatMessage("label.open_url_param", new String[]{url}));
\r
861 item.addActionListener(new java.awt.event.ActionListener()
863 public void actionPerformed(ActionEvent e)
865 new Thread(new Runnable()
881 * add a late bound groupURL item to the given linkMenu
885 * - menu label string
886 * @param urlgenerator
887 * GroupURLLink used to generate URL
889 * Object array returned from the makeUrlStubs function.
891 private void addshowLink(JMenu linkMenu, String label,
892 final GroupUrlLink urlgenerator, final Object[] urlstub)
894 JMenuItem item = new JMenuItem(label);
895 item.setToolTipText(MessageManager.formatMessage("label.open_url_seqs_param", new Object[]{urlgenerator.getUrl_prefix(),urlgenerator.getNumberInvolved(urlstub)}));
\r
896 // TODO: put in info about what is being sent.
\r
897 item.addActionListener(new java.awt.event.ActionListener()
899 public void actionPerformed(ActionEvent e)
901 new Thread(new Runnable()
908 showLink(urlgenerator.constructFrom(urlstub));
909 } catch (UrlStringTooLongException e)
927 private void jbInit() throws Exception
929 groupMenu.setText(MessageManager.getString("label.group"));
\r
930 groupMenu.setText(MessageManager.getString("label.selection"));
\r
931 groupName.setText(MessageManager.getString("label.name"));
\r
932 groupName.addActionListener(new java.awt.event.ActionListener()
934 public void actionPerformed(ActionEvent e)
936 groupName_actionPerformed();
939 sequenceMenu.setText(MessageManager.getString("label.sequence"));
\r
940 sequenceName.setText(MessageManager.getString("label.edit_name_description"));
\r
941 sequenceName.addActionListener(new java.awt.event.ActionListener()
943 public void actionPerformed(ActionEvent e)
945 sequenceName_actionPerformed();
948 sequenceDetails.setText(MessageManager.getString("label.sequence_details") + "...");
\r
949 sequenceDetails.addActionListener(new java.awt.event.ActionListener()
951 public void actionPerformed(ActionEvent e)
953 sequenceDetails_actionPerformed();
956 sequenceSelDetails.setText(MessageManager.getString("label.sequence_details") + "...");
\r
958 .addActionListener(new java.awt.event.ActionListener()
960 public void actionPerformed(ActionEvent e)
962 sequenceSelectionDetails_actionPerformed();
965 PIDColour.setFocusPainted(false);
966 unGroupMenuItem.setText(MessageManager.getString("action.remove_group"));
\r
967 unGroupMenuItem.addActionListener(new java.awt.event.ActionListener()
969 public void actionPerformed(ActionEvent e)
971 unGroupMenuItem_actionPerformed();
974 createGroupMenuItem.setText(MessageManager.getString("action.create_group"));
\r
975 createGroupMenuItem.addActionListener(new java.awt.event.ActionListener()
977 public void actionPerformed(ActionEvent e)
979 createGroupMenuItem_actionPerformed();
983 outline.setText(MessageManager.getString("action.border_colour"));
\r
984 outline.addActionListener(new java.awt.event.ActionListener()
986 public void actionPerformed(ActionEvent e)
988 outline_actionPerformed();
991 nucleotideMenuItem.setText(MessageManager.getString("label.nucleotide"));
\r
992 nucleotideMenuItem.addActionListener(new ActionListener()
994 public void actionPerformed(ActionEvent e)
996 nucleotideMenuItem_actionPerformed();
999 colourMenu.setText(MessageManager.getString("label.group_colour"));
\r
1000 showBoxes.setText(MessageManager.getString("action.boxes"));
\r
1001 showBoxes.setState(true);
1002 showBoxes.addActionListener(new ActionListener()
1004 public void actionPerformed(ActionEvent e)
1006 showBoxes_actionPerformed();
1009 showText.setText(MessageManager.getString("action.text"));
\r
1010 showText.setState(true);
1011 showText.addActionListener(new ActionListener()
1013 public void actionPerformed(ActionEvent e)
1015 showText_actionPerformed();
1018 showColourText.setText(MessageManager.getString("label.colour_text"));
\r
1019 showColourText.addActionListener(new ActionListener()
1021 public void actionPerformed(ActionEvent e)
1023 showColourText_actionPerformed();
1026 displayNonconserved.setText(MessageManager.getString("label.show_non_conversed"));
\r
1027 displayNonconserved.setState(true);
1028 displayNonconserved.addActionListener(new ActionListener()
1030 public void actionPerformed(ActionEvent e)
1032 showNonconserved_actionPerformed();
1035 editMenu.setText(MessageManager.getString("action.edit"));
\r
1036 cut.setText(MessageManager.getString("action.cut"));
\r
1037 cut.addActionListener(new ActionListener()
1039 public void actionPerformed(ActionEvent e)
1041 cut_actionPerformed();
1044 upperCase.setText(MessageManager.getString("label.to_upper_case"));
\r
1045 upperCase.addActionListener(new ActionListener()
1047 public void actionPerformed(ActionEvent e)
1052 copy.setText(MessageManager.getString("action.copy"));
\r
1053 copy.addActionListener(new ActionListener()
1055 public void actionPerformed(ActionEvent e)
1057 copy_actionPerformed();
1060 lowerCase.setText(MessageManager.getString("label.to_lower_case"));
\r
1061 lowerCase.addActionListener(new ActionListener()
1063 public void actionPerformed(ActionEvent e)
1068 toggle.setText(MessageManager.getString("label.toggle_case"));
\r
1069 toggle.addActionListener(new ActionListener()
1071 public void actionPerformed(ActionEvent e)
1076 pdbMenu.setText(MessageManager.getString("label.associate_structure_with_sequence"));
\r
1077 pdbFromFile.setText(MessageManager.getString("label.from_file"));
\r
1078 pdbFromFile.addActionListener(new ActionListener()
1080 public void actionPerformed(ActionEvent e)
1082 pdbFromFile_actionPerformed();
1085 // RNAFold.setText("From RNA Fold with predict2D");
1086 // RNAFold.addActionListener(new ActionListener()
1088 // public void actionPerformed(ActionEvent e)
1091 // RNAFold_actionPerformed();
1092 // } catch (Exception e1) {
1093 // // TODO Auto-generated catch block
1094 // e1.printStackTrace();
1098 // ContraFold.setText("From Contra Fold with predict2D");
1099 // ContraFold.addActionListener(new ActionListener()
1101 // public void actionPerformed(ActionEvent e)
1104 // ContraFold_actionPerformed();
1105 // } catch (Exception e1) {
1106 // // TODO Auto-generated catch block
1107 // e1.printStackTrace();
1111 enterPDB.setText(MessageManager.getString("label.enter_pdb_id"));
\r
1112 enterPDB.addActionListener(new ActionListener()
1114 public void actionPerformed(ActionEvent e)
1116 enterPDB_actionPerformed();
1119 discoverPDB.setText(MessageManager.getString("label.discover_pdb_ids"));
\r
1120 discoverPDB.addActionListener(new ActionListener()
1122 public void actionPerformed(ActionEvent e)
1124 discoverPDB_actionPerformed();
1127 outputMenu.setText(MessageManager.getString("label.out_to_textbox") + "...");
\r
1128 sequenceFeature.setText(MessageManager.getString("label.create_sequence_feature"));
\r
1129 sequenceFeature.addActionListener(new ActionListener()
1131 public void actionPerformed(ActionEvent e)
1133 sequenceFeature_actionPerformed();
1136 textColour.setText(MessageManager.getString("label.text_colour"));
\r
1137 textColour.addActionListener(new ActionListener()
1139 public void actionPerformed(ActionEvent e)
1141 textColour_actionPerformed();
1144 jMenu1.setText(MessageManager.getString("label.group"));
\r
1145 structureMenu.setText(MessageManager.getString("label.structure"));
\r
1146 viewStructureMenu.setText(MessageManager.getString("label.view_structure"));
\r
1147 // colStructureMenu.setText("Colour By Structure");
1148 editSequence.setText(MessageManager.getString("label.edit_sequence") + "...");
\r
1149 editSequence.addActionListener(new ActionListener()
1151 public void actionPerformed(ActionEvent actionEvent)
1153 editSequence_actionPerformed(actionEvent);
1158 * annotationMenuItem.setText("By Annotation");
1159 * annotationMenuItem.addActionListener(new ActionListener() { public void
1160 * actionPerformed(ActionEvent actionEvent) {
1161 * annotationMenuItem_actionPerformed(actionEvent); } });
1163 groupMenu.add(sequenceSelDetails);
1166 this.add(structureMenu);
1167 groupMenu.add(editMenu);
1168 groupMenu.add(outputMenu);
1169 groupMenu.add(sequenceFeature);
1170 groupMenu.add(createGroupMenuItem);
1171 groupMenu.add(unGroupMenuItem);
1172 groupMenu.add(jMenu1);
1173 sequenceMenu.add(sequenceName);
1174 sequenceMenu.add(sequenceDetails);
1175 colourMenu.add(textColour);
1176 colourMenu.add(noColourmenuItem);
1177 colourMenu.add(clustalColour);
1178 colourMenu.add(BLOSUM62Colour);
1179 colourMenu.add(PIDColour);
1180 colourMenu.add(zappoColour);
1181 colourMenu.add(taylorColour);
1182 colourMenu.add(hydrophobicityColour);
1183 colourMenu.add(helixColour);
1184 colourMenu.add(strandColour);
1185 colourMenu.add(turnColour);
1186 colourMenu.add(buriedColour);
1187 colourMenu.add(nucleotideMenuItem);
1188 if (ap.getAlignment().isNucleotide()) {
1189 // JBPNote - commented since the colourscheme isn't functional
1190 // colourMenu.add(RNAInteractionColour);
1191 colourMenu.add(purinePyrimidineColour);
1193 // colourMenu.add(covariationColour);
1194 colourMenu.add(userDefinedColour);
1196 if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null)
1198 java.util.Enumeration userColours = jalview.gui.UserDefinedColours
1199 .getUserColourSchemes().keys();
1201 while (userColours.hasMoreElements())
1203 JMenuItem item = new JMenuItem(userColours.nextElement().toString());
1204 item.addActionListener(new ActionListener()
1206 public void actionPerformed(ActionEvent evt)
1208 userDefinedColour_actionPerformed(evt);
1211 colourMenu.add(item);
1215 colourMenu.addSeparator();
1216 colourMenu.add(abovePIDColour);
1217 colourMenu.add(conservationMenuItem);
1218 // colourMenu.add(annotationMenuItem);
1221 editMenu.add(editSequence);
1222 editMenu.add(upperCase);
1223 editMenu.add(lowerCase);
1224 editMenu.add(toggle);
1225 pdbMenu.add(pdbFromFile);
1226 // JBPNote: These shouldn't be added here - should appear in a generic 'apply web service to this sequence menu'
1227 // pdbMenu.add(RNAFold);
1228 // pdbMenu.add(ContraFold);
1229 pdbMenu.add(enterPDB);
1230 pdbMenu.add(discoverPDB);
1231 jMenu1.add(groupName);
1232 jMenu1.add(colourMenu);
1233 jMenu1.add(showBoxes);
1234 jMenu1.add(showText);
1235 jMenu1.add(showColourText);
1236 jMenu1.add(outline);
1237 jMenu1.add(displayNonconserved);
1238 structureMenu.add(pdbMenu);
1239 structureMenu.add(viewStructureMenu);
1240 // structureMenu.add(colStructureMenu);
1241 noColourmenuItem.setText(MessageManager.getString("label.none"));
\r
1242 noColourmenuItem.addActionListener(new java.awt.event.ActionListener()
1244 public void actionPerformed(ActionEvent e)
1246 noColourmenuItem_actionPerformed();
1250 clustalColour.setText(MessageManager.getString("label.clustalx_colours"));
\r
1251 clustalColour.addActionListener(new java.awt.event.ActionListener()
1253 public void actionPerformed(ActionEvent e)
1255 clustalColour_actionPerformed();
1258 zappoColour.setText(MessageManager.getString("label.zappo"));
\r
1259 zappoColour.addActionListener(new java.awt.event.ActionListener()
1261 public void actionPerformed(ActionEvent e)
1263 zappoColour_actionPerformed();
1266 taylorColour.setText(MessageManager.getString("label.taylor"));
\r
1267 taylorColour.addActionListener(new java.awt.event.ActionListener()
1269 public void actionPerformed(ActionEvent e)
1271 taylorColour_actionPerformed();
1274 hydrophobicityColour.setText(MessageManager.getString("label.hydrophobicity"));
\r
1275 hydrophobicityColour
1276 .addActionListener(new java.awt.event.ActionListener()
1278 public void actionPerformed(ActionEvent e)
1280 hydrophobicityColour_actionPerformed();
1283 helixColour.setText(MessageManager.getString("label.helix_propensity"));
\r
1284 helixColour.addActionListener(new java.awt.event.ActionListener()
1286 public void actionPerformed(ActionEvent e)
1288 helixColour_actionPerformed();
1291 strandColour.setText(MessageManager.getString("label.strand_propensity"));
\r
1292 strandColour.addActionListener(new java.awt.event.ActionListener()
1294 public void actionPerformed(ActionEvent e)
1296 strandColour_actionPerformed();
1299 turnColour.setText(MessageManager.getString("label.turn_propensity"));
\r
1300 turnColour.addActionListener(new java.awt.event.ActionListener()
1302 public void actionPerformed(ActionEvent e)
1304 turnColour_actionPerformed();
1307 buriedColour.setText(MessageManager.getString("label.buried_index"));
\r
1308 buriedColour.addActionListener(new java.awt.event.ActionListener()
1310 public void actionPerformed(ActionEvent e)
1312 buriedColour_actionPerformed();
1315 abovePIDColour.setText(MessageManager.getString("label.above_identity_percentage"));
\r
1316 abovePIDColour.addActionListener(new java.awt.event.ActionListener()
1318 public void actionPerformed(ActionEvent e)
1320 abovePIDColour_actionPerformed();
1323 userDefinedColour.setText(MessageManager.getString("action.user_defined"));
\r
1324 userDefinedColour.addActionListener(new java.awt.event.ActionListener()
1326 public void actionPerformed(ActionEvent e)
1328 userDefinedColour_actionPerformed(e);
1331 PIDColour.setText(MessageManager.getString("label.percentage_identity"));
\r
1332 PIDColour.addActionListener(new java.awt.event.ActionListener()
1334 public void actionPerformed(ActionEvent e)
1336 PIDColour_actionPerformed();
1339 BLOSUM62Colour.setText(MessageManager.getString("label.blosum62"));
\r
1340 BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener()
1342 public void actionPerformed(ActionEvent e)
1344 BLOSUM62Colour_actionPerformed();
1347 purinePyrimidineColour.setText(MessageManager.getString("label.purine_pyrimidine"));
\r
1348 purinePyrimidineColour
1349 .addActionListener(new java.awt.event.ActionListener()
1351 public void actionPerformed(ActionEvent e)
1353 purinePyrimidineColour_actionPerformed();
1359 * covariationColour.addActionListener(new java.awt.event.ActionListener() {
1360 * public void actionPerformed(ActionEvent e) {
1361 * covariationColour_actionPerformed(); } });
1364 conservationMenuItem.setText(MessageManager.getString("label.conservation"));
\r
1365 conservationMenuItem
1366 .addActionListener(new java.awt.event.ActionListener()
1368 public void actionPerformed(ActionEvent e)
1370 conservationMenuItem_actionPerformed();
1375 protected void sequenceSelectionDetails_actionPerformed()
1377 createSequenceDetailsReport(ap.av.getSequenceSelection());
1380 protected void sequenceDetails_actionPerformed()
1382 createSequenceDetailsReport(new SequenceI[]
1386 public void createSequenceDetailsReport(SequenceI[] sequences)
1388 CutAndPasteHtmlTransfer cap = new CutAndPasteHtmlTransfer();
1389 StringBuffer contents = new StringBuffer();
1390 for (SequenceI seq : sequences)
1392 contents.append("<p><h2>" + MessageManager.formatMessage("label.create_sequence_details_report_annotation_for", new String[]{seq.getDisplayId(true)})
\r
1394 new SequenceAnnotationReport(null)
1395 .createSequenceAnnotationReport(
1401 (ap.seqPanel.seqCanvas.fr != null) ? ap.seqPanel.seqCanvas.fr.minmax
1403 contents.append("</p>");
1405 cap.setText("<html>" + contents.toString() + "</html>");
1407 Desktop.instance.addInternalFrame(cap, MessageManager.formatMessage("label.sequece_details_for", (sequences.length == 1 ? new String[]{sequences[0].getDisplayId(true)}: new String[]{MessageManager.getString("label.selection")}))
\r
1412 protected void showNonconserved_actionPerformed()
1414 getGroup().setShowNonconserved(displayNonconserved.isSelected());
1419 * call to refresh view after settings change
1423 ap.updateAnnotation();
1424 ap.paintAlignment(true);
1426 PaintRefresher.Refresh(this, ap.av.getSequenceSetId());
1435 protected void clustalColour_actionPerformed()
1437 SequenceGroup sg = getGroup();
1438 sg.cs = new ClustalxColourScheme(sg, ap.av.getHiddenRepSequences());
1448 protected void zappoColour_actionPerformed()
1450 getGroup().cs = new ZappoColourScheme();
1460 protected void taylorColour_actionPerformed()
1462 getGroup().cs = new TaylorColourScheme();
1472 protected void hydrophobicityColour_actionPerformed()
1474 getGroup().cs = new HydrophobicColourScheme();
1484 protected void helixColour_actionPerformed()
1486 getGroup().cs = new HelixColourScheme();
1496 protected void strandColour_actionPerformed()
1498 getGroup().cs = new StrandColourScheme();
1508 protected void turnColour_actionPerformed()
1510 getGroup().cs = new TurnColourScheme();
1520 protected void buriedColour_actionPerformed()
1522 getGroup().cs = new BuriedColourScheme();
1532 public void nucleotideMenuItem_actionPerformed()
1534 getGroup().cs = new NucleotideColourScheme();
1538 protected void purinePyrimidineColour_actionPerformed()
1540 getGroup().cs = new PurinePyrimidineColourScheme();
1546 * protected void covariationColour_actionPerformed() { getGroup().cs = new
1547 * CovariationColourScheme(sequence.getAnnotation()[0]); refresh(); }
1555 protected void abovePIDColour_actionPerformed()
1557 SequenceGroup sg = getGroup();
1563 if (abovePIDColour.isSelected())
1565 sg.cs.setConsensus(AAFrequency.calculate(
1566 sg.getSequences(ap.av.getHiddenRepSequences()),
1567 sg.getStartRes(), sg.getEndRes() + 1));
1569 int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
1572 sg.cs.setThreshold(threshold, ap.av.getIgnoreGapsConsensus());
1574 SliderPanel.showPIDSlider();
1577 // remove PIDColouring
1579 sg.cs.setThreshold(0, ap.av.getIgnoreGapsConsensus());
1591 protected void userDefinedColour_actionPerformed(ActionEvent e)
1593 SequenceGroup sg = getGroup();
1595 if (e.getSource().equals(userDefinedColour))
\r
1597 new UserDefinedColours(ap, sg);
1601 UserColourScheme udc = (UserColourScheme) UserDefinedColours
1602 .getUserColourSchemes().get(e.getActionCommand());
1615 protected void PIDColour_actionPerformed()
1617 SequenceGroup sg = getGroup();
1618 sg.cs = new PIDColourScheme();
1619 sg.cs.setConsensus(AAFrequency.calculate(
1620 sg.getSequences(ap.av.getHiddenRepSequences()),
1621 sg.getStartRes(), sg.getEndRes() + 1));
1631 protected void BLOSUM62Colour_actionPerformed()
1633 SequenceGroup sg = getGroup();
1635 sg.cs = new Blosum62ColourScheme();
1637 sg.cs.setConsensus(AAFrequency.calculate(
1638 sg.getSequences(ap.av.getHiddenRepSequences()),
1639 sg.getStartRes(), sg.getEndRes() + 1));
1650 protected void noColourmenuItem_actionPerformed()
1652 getGroup().cs = null;
1662 protected void conservationMenuItem_actionPerformed()
1664 SequenceGroup sg = getGroup();
1670 if (conservationMenuItem.isSelected())
1672 // JBPNote: Conservation name shouldn't be i18n translated
1673 Conservation c = new Conservation("Group",
1674 ResidueProperties.propHash, 3, sg.getSequences(ap.av
1675 .getHiddenRepSequences()), sg.getStartRes(),
1676 sg.getEndRes() + 1);
1679 c.verdict(false, ap.av.getConsPercGaps());
1681 sg.cs.setConservation(c);
1683 SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
1684 SliderPanel.showConservationSlider();
1687 // remove ConservationColouring
1689 sg.cs.setConservation(null);
1695 public void annotationMenuItem_actionPerformed(ActionEvent actionEvent)
1697 SequenceGroup sg = getGroup();
1703 AnnotationColourGradient acg = new AnnotationColourGradient(
1704 sequence.getAnnotation()[0], null,
1705 AnnotationColourGradient.NO_THRESHOLD);
1707 acg.setPredefinedColours(true);
1719 protected void groupName_actionPerformed()
1722 SequenceGroup sg = getGroup();
1723 EditNameDialog dialog = new EditNameDialog(sg.getName(),
1724 sg.getDescription(), " " + MessageManager.getString("label.group_name") + " ",
\r
1725 MessageManager.getString("label.group_description") + " ", MessageManager.getString("label.edit_group_name_description"),
\r
1733 sg.setName(dialog.getName());
1734 sg.setDescription(dialog.getDescription());
1739 * Get selection group - adding it to the alignment if necessary.
1741 * @return sequence group to operate on
1743 SequenceGroup getGroup()
1745 SequenceGroup sg = ap.av.getSelectionGroup();
1746 // this method won't add a new group if it already exists
1749 ap.av.getAlignment().addGroup(sg);
1761 void sequenceName_actionPerformed()
1763 EditNameDialog dialog = new EditNameDialog(sequence.getName(),
1764 sequence.getDescription(), " " + MessageManager.getString("label.sequence_name") + " ",
\r
1765 MessageManager.getString("label.sequence_description") + " ", MessageManager.getString("label.edit_sequence_name_description"),
\r
1773 if (dialog.getName() != null)
1775 if (dialog.getName().indexOf(" ") > -1)
1777 JOptionPane.showMessageDialog(ap,
1778 MessageManager.getString("label.spaces_converted_to_backslashes"),
\r
1779 MessageManager.getString("label.no_spaces_allowed_sequence_name"),
\r
1780 JOptionPane.WARNING_MESSAGE);
1783 sequence.setName(dialog.getName().replace(' ', '_'));
1784 ap.paintAlignment(false);
1787 sequence.setDescription(dialog.getDescription());
1789 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1800 void unGroupMenuItem_actionPerformed()
1802 SequenceGroup sg = ap.av.getSelectionGroup();
1803 ap.av.getAlignment().deleteGroup(sg);
1804 ap.av.setSelectionGroup(null);
1807 void createGroupMenuItem_actionPerformed()
1809 getGroup(); // implicitly creates group - note - should apply defaults / use standard alignment window logic for this
1819 protected void outline_actionPerformed()
1821 SequenceGroup sg = getGroup();
1822 Color col = JColorChooser.showDialog(this, MessageManager.getString("label.select_outline_colour"),
\r
1827 sg.setOutlineColour(col);
1839 public void showBoxes_actionPerformed()
1841 getGroup().setDisplayBoxes(showBoxes.isSelected());
1851 public void showText_actionPerformed()
1853 getGroup().setDisplayText(showText.isSelected());
1863 public void showColourText_actionPerformed()
1865 getGroup().setColourText(showColourText.isSelected());
1869 public void showLink(String url)
1873 jalview.util.BrowserLauncher.openURL(url);
1874 } catch (Exception ex)
1877 .showInternalMessageDialog(
1879 MessageManager.getString("label.web_browser_not_found_unix"),
\r
1880 MessageManager.getString("label.web_browser_not_found"), JOptionPane.WARNING_MESSAGE);
\r
1882 ex.printStackTrace();
1886 void hideSequences(boolean representGroup)
1888 SequenceGroup sg = ap.av.getSelectionGroup();
1889 if (sg == null || sg.getSize() < 1)
1891 ap.av.hideSequence(new SequenceI[]
1896 ap.av.setSelectionGroup(null);
1900 ap.av.hideRepSequences(sequence, sg);
1905 int gsize = sg.getSize();
1908 hseqs = new SequenceI[gsize];
1911 for (int i = 0; i < gsize; i++)
1913 hseqs[index++] = sg.getSequenceAt(i);
1916 ap.av.hideSequence(hseqs);
1917 // refresh(); TODO: ? needed ?
1918 ap.av.sendSelection();
1921 public void copy_actionPerformed()
1923 ap.alignFrame.copy_actionPerformed(null);
1926 public void cut_actionPerformed()
1928 ap.alignFrame.cut_actionPerformed(null);
1931 void changeCase(ActionEvent e)
1933 Object source = e.getSource();
1934 SequenceGroup sg = ap.av.getSelectionGroup();
1938 int[][] startEnd = ap.av.getVisibleRegionBoundaries(sg.getStartRes(),
1939 sg.getEndRes() + 1);
1944 if (source == toggle)
1946 description = MessageManager.getString("label.toggle_case");
\r
1947 caseChange = ChangeCaseCommand.TOGGLE_CASE;
1949 else if (source == upperCase)
1951 description = MessageManager.getString("label.to_upper_case");
\r
1952 caseChange = ChangeCaseCommand.TO_UPPER;
1956 description = MessageManager.getString("label.to_lower_case");
\r
1957 caseChange = ChangeCaseCommand.TO_LOWER;
1960 ChangeCaseCommand caseCommand = new ChangeCaseCommand(description,
1961 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
1962 startEnd, caseChange);
1964 ap.alignFrame.addHistoryItem(caseCommand);
1966 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1972 public void outputText_actionPerformed(ActionEvent e)
1974 CutAndPasteTransfer cap = new CutAndPasteTransfer();
1975 cap.setForInput(null);
1976 Desktop.addInternalFrame(cap,
1977 MessageManager.formatMessage("label.alignment_output_command", new String[]{e.getActionCommand()}), 600, 500);
\r
1979 String[] omitHidden = null;
1981 System.out.println("PROMPT USER HERE"); // TODO: decide if a prompt happens
1982 // or we simply trust the user wants
1983 // wysiwig behaviour
1984 SequenceGroup sg = ap.av.getSelectionGroup();
1985 ColumnSelection csel = new ColumnSelection(ap.av.getColumnSelection());
1986 omitHidden = ap.av.getViewAsString(true);
1987 Alignment oal = new Alignment(ap.av.getSequenceSelection());
1988 AlignmentAnnotation[] nala = ap.av.getAlignment()
1989 .getAlignmentAnnotation();
1992 for (int i = 0; i < nala.length; i++)
1994 AlignmentAnnotation na = nala[i];
1995 oal.addAnnotation(na);
1998 cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(),
1999 oal, omitHidden, csel, sg));
2003 public void pdbFromFile_actionPerformed()
2005 jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(
2006 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
2007 chooser.setFileView(new jalview.io.JalviewFileView());
2008 chooser.setDialogTitle(MessageManager.formatMessage("label.select_pdb_file_for", new String[]{sequence.getDisplayId(false)}));
\r
2009 chooser.setToolTipText(MessageManager.formatMessage("label.load_pdb_file_associate_with_sequence", new String[]{new Integer(sequence.getDisplayId(false)).toString()}));
\r
2011 int value = chooser.showOpenDialog(null);
2013 if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
2015 String choice = chooser.getSelectedFile().getPath();
2016 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
2017 new AssociatePdbFileWithSeq().associatePdbWithSeq(choice,
2018 jalview.io.AppletFormatAdapter.FILE, sequence, true);
2022 // JBNote: commented out - these won't be instantiated here...!
2023 // public void RNAFold_actionPerformed() throws Exception
2025 // Predict2D P2D = new Predict2D();
2026 // P2D.getStructure2DFromRNAFold("toto");
2029 // public void ContraFold_actionPerformed() throws Exception
2031 // Predict2D P2D = new Predict2D();
2032 // P2D.getStructure2DFromContraFold("toto");
2034 public void enterPDB_actionPerformed()
2036 String id = JOptionPane.showInternalInputDialog(Desktop.desktop,
2037 MessageManager.getString("label.enter_pdb_id"), MessageManager.getString("label.enter_pdb_id"), JOptionPane.QUESTION_MESSAGE);
\r
2039 if (id != null && id.length() > 0)
2041 PDBEntry entry = new PDBEntry();
2042 entry.setId(id.toUpperCase());
2043 sequence.getDatasetSequence().addPDBId(entry);
2047 public void discoverPDB_actionPerformed()
2050 final SequenceI[] sequences = ((ap.av.getSelectionGroup() == null) ? new SequenceI[]
2052 : ap.av.getSequenceSelection());
2053 Thread discpdb = new Thread(new Runnable()
2058 new jalview.ws.DBRefFetcher(sequences, ap.alignFrame)
2059 .fetchDBRefs(false);
2066 public void sequenceFeature_actionPerformed()
2068 SequenceGroup sg = ap.av.getSelectionGroup();
2074 int rsize = 0, gSize = sg.getSize();
2075 SequenceI[] rseqs, seqs = new SequenceI[gSize];
2076 SequenceFeature[] tfeatures, features = new SequenceFeature[gSize];
2078 for (int i = 0; i < gSize; i++)
2080 int start = sg.getSequenceAt(i).findPosition(sg.getStartRes());
2081 int end = sg.findEndRes(sg.getSequenceAt(i));
2084 seqs[rsize] = sg.getSequenceAt(i).getDatasetSequence();
2085 features[rsize] = new SequenceFeature(null, null, null, start, end,
2090 rseqs = new SequenceI[rsize];
2091 tfeatures = new SequenceFeature[rsize];
2092 System.arraycopy(seqs, 0, rseqs, 0, rsize);
2093 System.arraycopy(features, 0, tfeatures, 0, rsize);
2094 features = tfeatures;
2096 if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs,
2097 features, true, ap))
2099 ap.alignFrame.setShowSeqFeatures(true);
2100 ap.highlightSearchResults(null);
2104 public void textColour_actionPerformed()
2106 SequenceGroup sg = getGroup();
2109 new TextColourChooser().chooseColour(ap, sg);
2113 public void colourByStructure(String pdbid)
2115 Annotation[] anots = ap.av.getStructureSelectionManager()
2116 .colourSequenceFromStructure(sequence, pdbid);
2118 AlignmentAnnotation an = new AlignmentAnnotation("Structure",
2119 "Coloured by " + pdbid, anots);
2121 ap.av.getAlignment().addAnnotation(an);
2122 an.createSequenceMapping(sequence, 0, true);
2123 // an.adjustForAlignment();
2124 ap.av.getAlignment().setAnnotationIndex(an, 0);
2126 ap.adjustAnnotationHeight();
2128 sequence.addAlignmentAnnotation(an);
2132 public void editSequence_actionPerformed(ActionEvent actionEvent)
2134 SequenceGroup sg = ap.av.getSelectionGroup();
2138 if (sequence == null)
2139 sequence = (Sequence) sg.getSequenceAt(0);
2141 EditNameDialog dialog = new EditNameDialog(
2142 sequence.getSequenceAsString(sg.getStartRes(),
2143 sg.getEndRes() + 1), null, MessageManager.getString("label.edit_sequence"), null,
\r
2144 MessageManager.getString("label.edit_sequence"), ap.alignFrame);
\r
2148 EditCommand editCommand = new EditCommand(MessageManager.getString("label.edit_sequences"),
\r
2149 EditCommand.REPLACE, dialog.getName().replace(' ',
2150 ap.av.getGapCharacter()),
2151 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
2152 sg.getStartRes(), sg.getEndRes() + 1, ap.av.getAlignment());
2154 ap.alignFrame.addHistoryItem(editCommand);
2156 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()