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();
76 // protected JRadioButtonMenuItem covariationColour = new
77 // JRadioButtonMenuItem();
79 JRadioButtonMenuItem noColourmenuItem = new JRadioButtonMenuItem();
81 protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem();
85 JMenu sequenceMenu = new JMenu();
87 JMenuItem sequenceName = new JMenuItem();
89 JMenuItem sequenceDetails = new JMenuItem();
91 JMenuItem sequenceSelDetails = new JMenuItem();
94 JMenuItem createGroupMenuItem = new JMenuItem();
95 JMenuItem unGroupMenuItem = new JMenuItem();
97 JMenuItem outline = new JMenuItem();
99 JRadioButtonMenuItem nucleotideMenuItem = new JRadioButtonMenuItem();
101 JMenu colourMenu = new JMenu();
103 JCheckBoxMenuItem showBoxes = new JCheckBoxMenuItem();
105 JCheckBoxMenuItem showText = new JCheckBoxMenuItem();
107 JCheckBoxMenuItem showColourText = new JCheckBoxMenuItem();
109 JCheckBoxMenuItem displayNonconserved = new JCheckBoxMenuItem();
111 JMenu editMenu = new JMenu();
113 JMenuItem cut = new JMenuItem();
115 JMenuItem copy = new JMenuItem();
117 JMenuItem upperCase = new JMenuItem();
119 JMenuItem lowerCase = new JMenuItem();
121 JMenuItem toggle = new JMenuItem();
123 JMenu pdbMenu = new JMenu();
125 JMenuItem pdbFromFile = new JMenuItem();
127 JMenuItem enterPDB = new JMenuItem();
129 JMenuItem discoverPDB = new JMenuItem();
131 JMenu outputMenu = new JMenu();
133 JMenuItem sequenceFeature = new JMenuItem();
135 JMenuItem textColour = new JMenuItem();
137 JMenu jMenu1 = new JMenu();
139 JMenu structureMenu = new JMenu();
141 JMenu viewStructureMenu = new JMenu();
143 // JMenu colStructureMenu = new JMenu();
144 JMenuItem editSequence = new JMenuItem();
146 // JMenuItem annotationMenuItem = new JMenuItem();
148 JMenu groupLinksMenu;
151 * Creates a new PopupMenu object.
158 public PopupMenu(final AlignmentPanel ap, Sequence seq, Vector links)
160 this(ap, seq, links, null);
170 public PopupMenu(final AlignmentPanel ap, final SequenceI seq,
171 Vector links, Vector groupLinks)
173 // /////////////////////////////////////////////////////////
174 // If this is activated from the sequence panel, the user may want to
175 // edit or annotate a particular residue. Therefore display the residue menu
177 // If from the IDPanel, we must display the sequence menu
178 // ////////////////////////////////////////////////////////
182 ButtonGroup colours = new ButtonGroup();
183 colours.add(noColourmenuItem);
184 colours.add(clustalColour);
185 colours.add(zappoColour);
186 colours.add(taylorColour);
187 colours.add(hydrophobicityColour);
188 colours.add(helixColour);
189 colours.add(strandColour);
190 colours.add(turnColour);
191 colours.add(buriedColour);
192 colours.add(abovePIDColour);
193 colours.add(userDefinedColour);
194 colours.add(PIDColour);
195 colours.add(BLOSUM62Colour);
196 colours.add(purinePyrimidineColour);
197 // colours.add(covariationColour);
199 for (int i = 0; i < jalview.io.FormatAdapter.WRITEABLE_FORMATS.length; i++)
201 JMenuItem item = new JMenuItem(
202 jalview.io.FormatAdapter.WRITEABLE_FORMATS[i]);
204 item.addActionListener(new java.awt.event.ActionListener()
206 public void actionPerformed(ActionEvent e)
208 outputText_actionPerformed(e);
212 outputMenu.add(item);
218 } catch (Exception e)
226 sequenceMenu.setText(sequence.getName());
228 if (seq.getDatasetSequence().getPDBId() != null
229 && seq.getDatasetSequence().getPDBId().size() > 0)
231 java.util.Enumeration e = seq.getDatasetSequence().getPDBId()
234 while (e.hasMoreElements())
236 final PDBEntry pdb = (PDBEntry) e.nextElement();
238 menuItem = new JMenuItem();
239 menuItem.setText(pdb.getId());
240 menuItem.addActionListener(new java.awt.event.ActionListener()
242 public void actionPerformed(ActionEvent e)
244 // TODO re JAL-860: optionally open dialog or provide a menu entry
245 // allowing user to open just one structure per sequence
246 new AppJmol(pdb, ap.av.collateForPDB(new PDBEntry[]
247 { pdb })[0], null, ap);
248 // new PDBViewer(pdb, seqs2, null, ap, AppletFormatAdapter.FILE);
252 viewStructureMenu.add(menuItem);
255 * menuItem = new JMenuItem(); menuItem.setText(pdb.getId());
256 * menuItem.addActionListener(new java.awt.event.ActionListener() {
257 * public void actionPerformed(ActionEvent e) {
258 * colourByStructure(pdb.getId()); } });
259 * colStructureMenu.add(menuItem);
265 if (ap.av.getAlignment().isNucleotide() == false)
267 structureMenu.remove(viewStructureMenu);
269 // structureMenu.remove(colStructureMenu);
272 if (ap.av.getAlignment().isNucleotide() == true)
274 AlignmentAnnotation[] aa = ap.av.getAlignment()
275 .getAlignmentAnnotation();
276 for (int i = 0; i < aa.length; i++)
278 if (aa[i].getRNAStruc() != null)
280 final String rnastruc = aa[i].getRNAStruc();
281 final String structureLine = aa[i].label;
282 menuItem = new JMenuItem();
283 menuItem.setText(MessageManager.formatMessage("label.2d_rna_structure_line", new String[]{structureLine}));
\r
284 menuItem.addActionListener(new java.awt.event.ActionListener()
286 public void actionPerformed(ActionEvent e)
288 new AppVarna(structureLine, seq, seq.getSequenceAsString(),
289 rnastruc, seq.getName(), ap);
292 viewStructureMenu.add(menuItem);
296 // SequenceFeatures[] test = seq.getSequenceFeatures();
298 if (seq.getAnnotation() != null)
300 AlignmentAnnotation seqAnno[] = seq.getAnnotation();
301 for (int i = 0; i < seqAnno.length; i++)
303 if (seqAnno[i].getRNAStruc() != null)
305 final String rnastruc = seqAnno[i].getRNAStruc();
307 // TODO: make rnastrucF a bit more nice
308 menuItem = new JMenuItem();
309 menuItem.setText(MessageManager.formatMessage("label.2d_rna_sequence_name", new String[]{seq.getName()}));
\r
310 menuItem.addActionListener(new java.awt.event.ActionListener()
312 public void actionPerformed(ActionEvent e)
314 // TODO: VARNA does'nt print gaps in the sequence
315 new AppVarna(seq.getName() + " structure", seq, seq
316 .getSequenceAsString(), rnastruc, seq.getName(),
320 viewStructureMenu.add(menuItem);
327 menuItem = new JMenuItem(MessageManager.getString("action.hide_sequences"));
\r
328 menuItem.addActionListener(new java.awt.event.ActionListener()
330 public void actionPerformed(ActionEvent e)
332 hideSequences(false);
337 if (ap.av.getSelectionGroup() != null
338 && ap.av.getSelectionGroup().getSize() > 1)
340 menuItem = new JMenuItem(MessageManager.formatMessage("label.represent_group_with", new String[]{seq.getName()}));
\r
341 menuItem.addActionListener(new java.awt.event.ActionListener()
343 public void actionPerformed(ActionEvent e)
348 sequenceMenu.add(menuItem);
351 if (ap.av.hasHiddenRows())
353 final int index = ap.av.getAlignment().findIndex(seq);
355 if (ap.av.adjustForHiddenSeqs(index)
356 - ap.av.adjustForHiddenSeqs(index - 1) > 1)
358 menuItem = new JMenuItem(MessageManager.getString("action.reveal_sequences"));
\r
359 menuItem.addActionListener(new ActionListener()
361 public void actionPerformed(ActionEvent e)
363 ap.av.showSequence(index);
364 if (ap.overviewPanel != null)
366 ap.overviewPanel.updateOverviewImage();
374 // for the case when no sequences are even visible
375 if (ap.av.hasHiddenRows())
378 menuItem = new JMenuItem(MessageManager.getString("action.reveal_all"));
\r
379 menuItem.addActionListener(new ActionListener()
381 public void actionPerformed(ActionEvent e)
383 ap.av.showAllHiddenSeqs();
384 if (ap.overviewPanel != null)
386 ap.overviewPanel.updateOverviewImage();
396 SequenceGroup sg = ap.av.getSelectionGroup();
397 boolean isDefinedGroup = (sg!=null) ? ap.av.getAlignment().getGroups().contains(sg) : false;
399 if (sg != null && sg.getSize() > 0)
401 groupName.setText(MessageManager.formatMessage("label.name_param", new String[]{sg.getName()}));
\r
402 groupName.setText(MessageManager.getString("label.edit_name_and_description_current_group"));
\r
404 if (sg.cs instanceof ZappoColourScheme)
406 zappoColour.setSelected(true);
408 else if (sg.cs instanceof TaylorColourScheme)
410 taylorColour.setSelected(true);
412 else if (sg.cs instanceof PIDColourScheme)
414 PIDColour.setSelected(true);
416 else if (sg.cs instanceof Blosum62ColourScheme)
418 BLOSUM62Colour.setSelected(true);
420 else if (sg.cs instanceof UserColourScheme)
422 userDefinedColour.setSelected(true);
424 else if (sg.cs instanceof HydrophobicColourScheme)
426 hydrophobicityColour.setSelected(true);
428 else if (sg.cs instanceof HelixColourScheme)
430 helixColour.setSelected(true);
432 else if (sg.cs instanceof StrandColourScheme)
434 strandColour.setSelected(true);
436 else if (sg.cs instanceof TurnColourScheme)
438 turnColour.setSelected(true);
440 else if (sg.cs instanceof BuriedColourScheme)
442 buriedColour.setSelected(true);
444 else if (sg.cs instanceof ClustalxColourScheme)
446 clustalColour.setSelected(true);
448 else if (sg.cs instanceof PurinePyrimidineColourScheme)
450 purinePyrimidineColour.setSelected(true);
453 * else if (sg.cs instanceof CovariationColourScheme) {
454 * covariationColour.setSelected(true); }
458 noColourmenuItem.setSelected(true);
461 if (sg.cs != null && sg.cs.conservationApplied())
463 conservationMenuItem.setSelected(true);
465 displayNonconserved.setSelected(sg.getShowNonconserved());
466 showText.setSelected(sg.getDisplayText());
467 showColourText.setSelected(sg.getColourText());
468 showBoxes.setSelected(sg.getDisplayBoxes());
469 // add any groupURLs to the groupURL submenu and make it visible
470 if (groupLinks != null && groupLinks.size() > 0)
472 buildGroupURLMenu(sg, groupLinks);
474 // Add a 'show all structures' for the current selection
475 Hashtable<String, PDBEntry> pdbe = new Hashtable<String, PDBEntry>();
476 SequenceI sqass = null;
477 for (SequenceI sq : ap.av.getSequenceSelection())
479 Vector<PDBEntry> pes = (Vector<PDBEntry>) sq.getDatasetSequence()
483 for (PDBEntry pe : pes)
485 pdbe.put(pe.getId(), pe);
495 final PDBEntry[] pe = pdbe.values().toArray(
496 new PDBEntry[pdbe.size()]);
497 final JMenuItem gpdbview;
498 if (pdbe.size() == 1)
500 structureMenu.add(gpdbview = new JMenuItem(MessageManager.formatMessage("label.view_structure_for", new String[]{sqass.getDisplayId(false)})));
\r
504 structureMenu.add(gpdbview = new JMenuItem(MessageManager.formatMessage("label.view_all_structures", new String[]{new Integer(pdbe.size()).toString()})));
\r
506 gpdbview.setToolTipText(MessageManager.getString("label.open_new_jmol_view_with_all_structures_associated_current_selection_superimpose_using_alignment"));
\r
507 gpdbview.addActionListener(new ActionListener()
511 public void actionPerformed(ActionEvent e)
513 new AppJmol(ap, pe, ap.av.collateForPDB(pe));
520 groupMenu.setVisible(false);
521 editMenu.setVisible(false);
526 createGroupMenuItem.setVisible(true);
527 unGroupMenuItem.setVisible(false);
528 jMenu1.setText(MessageManager.getString("action.edit_new_group"));
\r
530 createGroupMenuItem.setVisible(false);
531 unGroupMenuItem.setVisible(true);
532 jMenu1.setText(MessageManager.getString("action.edit_group"));
\r
537 sequenceMenu.setVisible(false);
538 structureMenu.setVisible(false);
541 if (links != null && links.size() > 0)
544 JMenu linkMenu = new JMenu(MessageManager.getString("action.link"));
\r
545 Vector linkset = new Vector();
546 for (int i = 0; i < links.size(); i++)
548 String link = links.elementAt(i).toString();
549 UrlLink urlLink = null;
552 urlLink = new UrlLink(link);
553 } catch (Exception foo)
555 jalview.bin.Cache.log.error("Exception for URLLink '" + link
560 if (!urlLink.isValid())
562 jalview.bin.Cache.log.error(urlLink.getInvalidMessage());
565 final String label = urlLink.getLabel();
566 if (seq != null && urlLink.isDynamic())
569 // collect matching db-refs
570 DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(
571 seq.getDBRef(), new String[]
572 { urlLink.getTarget() });
573 // collect id string too
574 String id = seq.getName();
575 String descr = seq.getDescription();
576 if (descr != null && descr.length() < 1)
583 for (int r = 0; r < dbr.length; r++)
585 if (id != null && dbr[r].getAccessionId().equals(id))
587 // suppress duplicate link creation for the bare sequence ID
588 // string with this link
591 // create Bare ID link for this RUL
592 String[] urls = urlLink.makeUrls(dbr[r].getAccessionId(),
596 for (int u = 0; u < urls.length; u += 2)
598 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
600 linkset.addElement(urls[u] + "|" + urls[u + 1]);
601 addshowLink(linkMenu, label + "|" + urls[u],
610 // create Bare ID link for this RUL
611 String[] urls = urlLink.makeUrls(id, true);
614 for (int u = 0; u < urls.length; u += 2)
616 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
618 linkset.addElement(urls[u] + "|" + urls[u + 1]);
619 addshowLink(linkMenu, label, urls[u + 1]);
624 // Create urls from description but only for URL links which are regex
626 if (descr != null && urlLink.getRegexReplace() != null)
628 // create link for this URL from description where regex matches
629 String[] urls = urlLink.makeUrls(descr, true);
632 for (int u = 0; u < urls.length; u += 2)
634 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
636 linkset.addElement(urls[u] + "|" + urls[u + 1]);
637 addshowLink(linkMenu, label, urls[u + 1]);
645 if (!linkset.contains(label + "|" + urlLink.getUrl_prefix()))
647 linkset.addElement(label + "|" + urlLink.getUrl_prefix());
648 // Add a non-dynamic link
649 addshowLink(linkMenu, label, urlLink.getUrl_prefix());
653 if (sequence != null)
655 sequenceMenu.add(linkMenu);
664 private void buildGroupURLMenu(SequenceGroup sg, Vector groupLinks)
667 // TODO: usability: thread off the generation of group url content so root
669 // sequence only URLs
670 // ID/regex match URLs
671 groupLinksMenu = new JMenu(MessageManager.getString("action.group_link"));
\r
672 JMenu[] linkMenus = new JMenu[]
673 { null, new JMenu(MessageManager.getString("action.ids")), new JMenu(MessageManager.getString("action.sequences")),
\r
674 new JMenu(MessageManager.getString("action.ids_sequences")) }; // three types of url that might be
\r
676 SequenceI[] seqs = ap.av.getSelectionAsNewSequence();
677 String[][] idandseqs = GroupUrlLink.formStrings(seqs);
678 Hashtable commonDbrefs = new Hashtable();
679 for (int sq = 0; sq < seqs.length; sq++)
682 int start = seqs[sq].findPosition(sg.getStartRes()), end = seqs[sq]
683 .findPosition(sg.getEndRes());
684 // just collect ids from dataset sequence
685 // TODO: check if IDs collected from selecton group intersects with the
686 // current selection, too
687 SequenceI sqi = seqs[sq];
688 while (sqi.getDatasetSequence() != null)
690 sqi = sqi.getDatasetSequence();
692 DBRefEntry[] dbr = sqi.getDBRef();
693 if (dbr != null && dbr.length > 0)
695 for (int d = 0; d < dbr.length; d++)
697 String src = dbr[d].getSource(); // jalview.util.DBRefUtils.getCanonicalName(dbr[d].getSource()).toUpperCase();
698 Object[] sarray = (Object[]) commonDbrefs.get(src);
701 sarray = new Object[2];
702 sarray[0] = new int[]
704 sarray[1] = new String[seqs.length];
706 commonDbrefs.put(src, sarray);
709 if (((String[]) sarray[1])[sq] == null)
712 || (dbr[d].getMap().locateMappedRange(start, end) != null))
714 ((String[]) sarray[1])[sq] = dbr[d].getAccessionId();
715 ((int[]) sarray[0])[0]++;
721 // now create group links for all distinct ID/sequence sets.
722 boolean addMenu = false; // indicates if there are any group links to give
724 for (int i = 0; i < groupLinks.size(); i++)
726 String link = groupLinks.elementAt(i).toString();
727 GroupUrlLink urlLink = null;
730 urlLink = new GroupUrlLink(link);
731 } catch (Exception foo)
733 jalview.bin.Cache.log.error("Exception for GroupURLLink '" + link
738 if (!urlLink.isValid())
740 jalview.bin.Cache.log.error(urlLink.getInvalidMessage());
743 final String label = urlLink.getLabel();
744 boolean usingNames = false;
745 // Now see which parts of the group apply for this URL
746 String ltarget = urlLink.getTarget(); // jalview.util.DBRefUtils.getCanonicalName(urlLink.getTarget());
747 Object[] idset = (Object[]) commonDbrefs.get(ltarget.toUpperCase());
748 String[] seqstr, ids; // input to makeUrl
751 int numinput = ((int[]) idset[0])[0];
752 String[] allids = ((String[]) idset[1]);
753 seqstr = new String[numinput];
754 ids = new String[numinput];
755 for (int sq = 0, idcount = 0; sq < seqs.length; sq++)
757 if (allids[sq] != null)
759 ids[idcount] = allids[sq];
760 seqstr[idcount++] = idandseqs[1][sq];
766 // just use the id/seq set
767 seqstr = idandseqs[1];
771 // and try and make the groupURL!
773 Object[] urlset = null;
776 urlset = urlLink.makeUrlStubs(ids, seqstr,
777 "FromJalview" + System.currentTimeMillis(), false);
778 } catch (UrlStringTooLongException e)
783 int type = urlLink.getGroupURLType() & 3;
784 // System.out.println(urlLink.getGroupURLType()
785 // +" "+((String[])urlset[3])[0]);
786 // first two bits ofurlLink type bitfield are sequenceids and sequences
787 // TODO: FUTURE: ensure the groupURL menu structure can be generalised
788 addshowLink(linkMenus[type], label
789 + (((type & 1) == 1) ? ("("
790 + (usingNames ? "Names" : ltarget) + ")") : ""),
797 groupLinksMenu = new JMenu(MessageManager.getString("action.group_link"));
\r
798 for (int m = 0; m < linkMenus.length; m++)
800 if (linkMenus[m] != null
801 && linkMenus[m].getMenuComponentCount() > 0)
803 groupLinksMenu.add(linkMenus[m]);
807 groupMenu.add(groupLinksMenu);
812 * add a show URL menu item to the given linkMenu
816 * - menu label string
820 private void addshowLink(JMenu linkMenu, String label, final String url)
822 JMenuItem item = new JMenuItem(label);
823 item.setToolTipText(MessageManager.formatMessage("label.open_url_param", new String[]{url}));
\r
824 item.addActionListener(new java.awt.event.ActionListener()
826 public void actionPerformed(ActionEvent e)
828 new Thread(new Runnable()
844 * add a late bound groupURL item to the given linkMenu
848 * - menu label string
849 * @param urlgenerator
850 * GroupURLLink used to generate URL
852 * Object array returned from the makeUrlStubs function.
854 private void addshowLink(JMenu linkMenu, String label,
855 final GroupUrlLink urlgenerator, final Object[] urlstub)
857 JMenuItem item = new JMenuItem(label);
858 item.setToolTipText(MessageManager.formatMessage("label.open_url_seqs_param", new Object[]{urlgenerator.getUrl_prefix(),urlgenerator.getNumberInvolved(urlstub)}));
\r
859 // TODO: put in info about what is being sent.
\r
860 item.addActionListener(new java.awt.event.ActionListener()
862 public void actionPerformed(ActionEvent e)
864 new Thread(new Runnable()
871 showLink(urlgenerator.constructFrom(urlstub));
872 } catch (UrlStringTooLongException e)
890 private void jbInit() throws Exception
892 groupMenu.setText(MessageManager.getString("label.group"));
\r
893 groupMenu.setText(MessageManager.getString("label.selection"));
\r
894 groupName.setText(MessageManager.getString("label.name"));
\r
895 groupName.addActionListener(new java.awt.event.ActionListener()
897 public void actionPerformed(ActionEvent e)
899 groupName_actionPerformed();
902 sequenceMenu.setText(MessageManager.getString("label.sequence"));
\r
903 sequenceName.setText(MessageManager.getString("label.edit_name_description"));
\r
904 sequenceName.addActionListener(new java.awt.event.ActionListener()
906 public void actionPerformed(ActionEvent e)
908 sequenceName_actionPerformed();
911 sequenceDetails.setText(MessageManager.getString("label.sequence_details") + "...");
\r
912 sequenceDetails.addActionListener(new java.awt.event.ActionListener()
914 public void actionPerformed(ActionEvent e)
916 sequenceDetails_actionPerformed();
919 sequenceSelDetails.setText(MessageManager.getString("label.sequence_details") + "...");
\r
921 .addActionListener(new java.awt.event.ActionListener()
923 public void actionPerformed(ActionEvent e)
925 sequenceSelectionDetails_actionPerformed();
928 PIDColour.setFocusPainted(false);
929 unGroupMenuItem.setText(MessageManager.getString("action.remove_group"));
\r
930 unGroupMenuItem.addActionListener(new java.awt.event.ActionListener()
932 public void actionPerformed(ActionEvent e)
934 unGroupMenuItem_actionPerformed();
937 createGroupMenuItem.setText(MessageManager.getString("action.create_group"));
\r
938 createGroupMenuItem.addActionListener(new java.awt.event.ActionListener()
940 public void actionPerformed(ActionEvent e)
942 createGroupMenuItem_actionPerformed();
946 outline.setText(MessageManager.getString("action.border_colour"));
\r
947 outline.addActionListener(new java.awt.event.ActionListener()
949 public void actionPerformed(ActionEvent e)
951 outline_actionPerformed();
954 nucleotideMenuItem.setText(MessageManager.getString("label.nucleotide"));
\r
955 nucleotideMenuItem.addActionListener(new ActionListener()
957 public void actionPerformed(ActionEvent e)
959 nucleotideMenuItem_actionPerformed();
962 colourMenu.setText(MessageManager.getString("label.group_colour"));
\r
963 showBoxes.setText(MessageManager.getString("action.boxes"));
\r
964 showBoxes.setState(true);
965 showBoxes.addActionListener(new ActionListener()
967 public void actionPerformed(ActionEvent e)
969 showBoxes_actionPerformed();
972 showText.setText(MessageManager.getString("action.text"));
\r
973 showText.setState(true);
974 showText.addActionListener(new ActionListener()
976 public void actionPerformed(ActionEvent e)
978 showText_actionPerformed();
981 showColourText.setText(MessageManager.getString("label.colour_text"));
\r
982 showColourText.addActionListener(new ActionListener()
984 public void actionPerformed(ActionEvent e)
986 showColourText_actionPerformed();
989 displayNonconserved.setText(MessageManager.getString("label.show_non_conversed"));
\r
990 displayNonconserved.setState(true);
991 displayNonconserved.addActionListener(new ActionListener()
993 public void actionPerformed(ActionEvent e)
995 showNonconserved_actionPerformed();
998 editMenu.setText(MessageManager.getString("action.edit"));
\r
999 cut.setText(MessageManager.getString("action.cut"));
\r
1000 cut.addActionListener(new ActionListener()
1002 public void actionPerformed(ActionEvent e)
1004 cut_actionPerformed();
1007 upperCase.setText(MessageManager.getString("label.to_upper_case"));
\r
1008 upperCase.addActionListener(new ActionListener()
1010 public void actionPerformed(ActionEvent e)
1015 copy.setText(MessageManager.getString("action.copy"));
\r
1016 copy.addActionListener(new ActionListener()
1018 public void actionPerformed(ActionEvent e)
1020 copy_actionPerformed();
1023 lowerCase.setText(MessageManager.getString("label.to_lower_case"));
\r
1024 lowerCase.addActionListener(new ActionListener()
1026 public void actionPerformed(ActionEvent e)
1031 toggle.setText(MessageManager.getString("label.toggle_case"));
\r
1032 toggle.addActionListener(new ActionListener()
1034 public void actionPerformed(ActionEvent e)
1039 pdbMenu.setText(MessageManager.getString("label.associate_structure_with_sequence"));
\r
1040 pdbFromFile.setText(MessageManager.getString("label.from_file"));
\r
1041 pdbFromFile.addActionListener(new ActionListener()
1043 public void actionPerformed(ActionEvent e)
1045 pdbFromFile_actionPerformed();
1048 enterPDB.setText(MessageManager.getString("label.enter_pdb_id"));
\r
1049 enterPDB.addActionListener(new ActionListener()
1051 public void actionPerformed(ActionEvent e)
1053 enterPDB_actionPerformed();
1056 discoverPDB.setText(MessageManager.getString("label.discover_pdb_ids"));
\r
1057 discoverPDB.addActionListener(new ActionListener()
1059 public void actionPerformed(ActionEvent e)
1061 discoverPDB_actionPerformed();
1064 outputMenu.setText(MessageManager.getString("label.out_to_textbox") + "...");
\r
1065 sequenceFeature.setText(MessageManager.getString("label.create_sequence_feature"));
\r
1066 sequenceFeature.addActionListener(new ActionListener()
1068 public void actionPerformed(ActionEvent e)
1070 sequenceFeature_actionPerformed();
1073 textColour.setText(MessageManager.getString("label.text_colour"));
\r
1074 textColour.addActionListener(new ActionListener()
1076 public void actionPerformed(ActionEvent e)
1078 textColour_actionPerformed();
1081 jMenu1.setText(MessageManager.getString("label.group"));
\r
1082 structureMenu.setText(MessageManager.getString("label.structure"));
\r
1083 viewStructureMenu.setText(MessageManager.getString("label.view_structure"));
\r
1084 // colStructureMenu.setText("Colour By Structure");
1085 editSequence.setText(MessageManager.getString("label.edit_sequence") + "...");
\r
1086 editSequence.addActionListener(new ActionListener()
1088 public void actionPerformed(ActionEvent actionEvent)
1090 editSequence_actionPerformed(actionEvent);
1095 * annotationMenuItem.setText("By Annotation");
1096 * annotationMenuItem.addActionListener(new ActionListener() { public void
1097 * actionPerformed(ActionEvent actionEvent) {
1098 * annotationMenuItem_actionPerformed(actionEvent); } });
1100 groupMenu.add(sequenceSelDetails);
1103 this.add(structureMenu);
1104 groupMenu.add(editMenu);
1105 groupMenu.add(outputMenu);
1106 groupMenu.add(sequenceFeature);
1107 groupMenu.add(createGroupMenuItem);
1108 groupMenu.add(unGroupMenuItem);
1109 groupMenu.add(jMenu1);
1110 sequenceMenu.add(sequenceName);
1111 sequenceMenu.add(sequenceDetails);
1112 colourMenu.add(textColour);
1113 colourMenu.add(noColourmenuItem);
1114 colourMenu.add(clustalColour);
1115 colourMenu.add(BLOSUM62Colour);
1116 colourMenu.add(PIDColour);
1117 colourMenu.add(zappoColour);
1118 colourMenu.add(taylorColour);
1119 colourMenu.add(hydrophobicityColour);
1120 colourMenu.add(helixColour);
1121 colourMenu.add(strandColour);
1122 colourMenu.add(turnColour);
1123 colourMenu.add(buriedColour);
1124 colourMenu.add(nucleotideMenuItem);
1125 if (ap.getAlignment().isNucleotide())
1127 colourMenu.add(purinePyrimidineColour);
1129 // colourMenu.add(covariationColour);
1130 colourMenu.add(userDefinedColour);
1132 if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null)
1134 java.util.Enumeration userColours = jalview.gui.UserDefinedColours
1135 .getUserColourSchemes().keys();
1137 while (userColours.hasMoreElements())
1139 JMenuItem item = new JMenuItem(userColours.nextElement().toString());
1140 item.addActionListener(new ActionListener()
1142 public void actionPerformed(ActionEvent evt)
1144 userDefinedColour_actionPerformed(evt);
1147 colourMenu.add(item);
1151 colourMenu.addSeparator();
1152 colourMenu.add(abovePIDColour);
1153 colourMenu.add(conservationMenuItem);
1154 // colourMenu.add(annotationMenuItem);
1157 editMenu.add(editSequence);
1158 editMenu.add(upperCase);
1159 editMenu.add(lowerCase);
1160 editMenu.add(toggle);
1161 pdbMenu.add(pdbFromFile);
1162 pdbMenu.add(enterPDB);
1163 pdbMenu.add(discoverPDB);
1164 jMenu1.add(groupName);
1165 jMenu1.add(colourMenu);
1166 jMenu1.add(showBoxes);
1167 jMenu1.add(showText);
1168 jMenu1.add(showColourText);
1169 jMenu1.add(outline);
1170 jMenu1.add(displayNonconserved);
1171 structureMenu.add(pdbMenu);
1172 structureMenu.add(viewStructureMenu);
1173 // structureMenu.add(colStructureMenu);
1174 noColourmenuItem.setText(MessageManager.getString("label.none"));
\r
1175 noColourmenuItem.addActionListener(new java.awt.event.ActionListener()
1177 public void actionPerformed(ActionEvent e)
1179 noColourmenuItem_actionPerformed();
1183 clustalColour.setText(MessageManager.getString("label.clustalx_colours"));
\r
1184 clustalColour.addActionListener(new java.awt.event.ActionListener()
1186 public void actionPerformed(ActionEvent e)
1188 clustalColour_actionPerformed();
1191 zappoColour.setText(MessageManager.getString("label.zappo"));
\r
1192 zappoColour.addActionListener(new java.awt.event.ActionListener()
1194 public void actionPerformed(ActionEvent e)
1196 zappoColour_actionPerformed();
1199 taylorColour.setText(MessageManager.getString("label.taylor"));
\r
1200 taylorColour.addActionListener(new java.awt.event.ActionListener()
1202 public void actionPerformed(ActionEvent e)
1204 taylorColour_actionPerformed();
1207 hydrophobicityColour.setText(MessageManager.getString("label.hydrophobicity"));
\r
1208 hydrophobicityColour
1209 .addActionListener(new java.awt.event.ActionListener()
1211 public void actionPerformed(ActionEvent e)
1213 hydrophobicityColour_actionPerformed();
1216 helixColour.setText(MessageManager.getString("label.helix_propensity"));
\r
1217 helixColour.addActionListener(new java.awt.event.ActionListener()
1219 public void actionPerformed(ActionEvent e)
1221 helixColour_actionPerformed();
1224 strandColour.setText(MessageManager.getString("label.strand_propensity"));
\r
1225 strandColour.addActionListener(new java.awt.event.ActionListener()
1227 public void actionPerformed(ActionEvent e)
1229 strandColour_actionPerformed();
1232 turnColour.setText(MessageManager.getString("label.turn_propensity"));
\r
1233 turnColour.addActionListener(new java.awt.event.ActionListener()
1235 public void actionPerformed(ActionEvent e)
1237 turnColour_actionPerformed();
1240 buriedColour.setText(MessageManager.getString("label.buried_index"));
\r
1241 buriedColour.addActionListener(new java.awt.event.ActionListener()
1243 public void actionPerformed(ActionEvent e)
1245 buriedColour_actionPerformed();
1248 abovePIDColour.setText(MessageManager.getString("label.above_identity_percentage"));
\r
1249 abovePIDColour.addActionListener(new java.awt.event.ActionListener()
1251 public void actionPerformed(ActionEvent e)
1253 abovePIDColour_actionPerformed();
1256 userDefinedColour.setText(MessageManager.getString("action.user_defined"));
\r
1257 userDefinedColour.addActionListener(new java.awt.event.ActionListener()
1259 public void actionPerformed(ActionEvent e)
1261 userDefinedColour_actionPerformed(e);
1264 PIDColour.setText(MessageManager.getString("label.percentage_identity"));
\r
1265 PIDColour.addActionListener(new java.awt.event.ActionListener()
1267 public void actionPerformed(ActionEvent e)
1269 PIDColour_actionPerformed();
1272 BLOSUM62Colour.setText(MessageManager.getString("label.blosum62"));
\r
1273 BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener()
1275 public void actionPerformed(ActionEvent e)
1277 BLOSUM62Colour_actionPerformed();
1280 purinePyrimidineColour.setText(MessageManager.getString("label.purine_pyrimidine"));
\r
1281 purinePyrimidineColour
1282 .addActionListener(new java.awt.event.ActionListener()
1284 public void actionPerformed(ActionEvent e)
1286 purinePyrimidineColour_actionPerformed();
1290 * covariationColour.addActionListener(new java.awt.event.ActionListener() {
1291 * public void actionPerformed(ActionEvent e) {
1292 * covariationColour_actionPerformed(); } });
1295 conservationMenuItem.setText(MessageManager.getString("label.conservation"));
\r
1296 conservationMenuItem
1297 .addActionListener(new java.awt.event.ActionListener()
1299 public void actionPerformed(ActionEvent e)
1301 conservationMenuItem_actionPerformed();
1306 protected void sequenceSelectionDetails_actionPerformed()
1308 createSequenceDetailsReport(ap.av.getSequenceSelection());
1311 protected void sequenceDetails_actionPerformed()
1313 createSequenceDetailsReport(new SequenceI[]
1317 public void createSequenceDetailsReport(SequenceI[] sequences)
1319 CutAndPasteHtmlTransfer cap = new CutAndPasteHtmlTransfer();
1320 StringBuffer contents = new StringBuffer();
1321 for (SequenceI seq : sequences)
1323 contents.append("<p><h2>" + MessageManager.formatMessage("label.create_sequence_details_report_annotation_for", new String[]{seq.getDisplayId(true)})
\r
1325 new SequenceAnnotationReport(null)
1326 .createSequenceAnnotationReport(
1332 (ap.seqPanel.seqCanvas.fr != null) ? ap.seqPanel.seqCanvas.fr.minmax
1334 contents.append("</p>");
1336 cap.setText("<html>" + contents.toString() + "</html>");
1338 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
1343 protected void showNonconserved_actionPerformed()
1345 getGroup().setShowNonconserved(displayNonconserved.isSelected());
1350 * call to refresh view after settings change
1354 ap.updateAnnotation();
1355 ap.paintAlignment(true);
1357 PaintRefresher.Refresh(this, ap.av.getSequenceSetId());
1366 protected void clustalColour_actionPerformed()
1368 SequenceGroup sg = getGroup();
1369 sg.cs = new ClustalxColourScheme(sg, ap.av.getHiddenRepSequences());
1379 protected void zappoColour_actionPerformed()
1381 getGroup().cs = new ZappoColourScheme();
1391 protected void taylorColour_actionPerformed()
1393 getGroup().cs = new TaylorColourScheme();
1403 protected void hydrophobicityColour_actionPerformed()
1405 getGroup().cs = new HydrophobicColourScheme();
1415 protected void helixColour_actionPerformed()
1417 getGroup().cs = new HelixColourScheme();
1427 protected void strandColour_actionPerformed()
1429 getGroup().cs = new StrandColourScheme();
1439 protected void turnColour_actionPerformed()
1441 getGroup().cs = new TurnColourScheme();
1451 protected void buriedColour_actionPerformed()
1453 getGroup().cs = new BuriedColourScheme();
1463 public void nucleotideMenuItem_actionPerformed()
1465 getGroup().cs = new NucleotideColourScheme();
1469 protected void purinePyrimidineColour_actionPerformed()
1471 getGroup().cs = new PurinePyrimidineColourScheme();
1476 * protected void covariationColour_actionPerformed() { getGroup().cs = new
1477 * CovariationColourScheme(sequence.getAnnotation()[0]); refresh(); }
1485 protected void abovePIDColour_actionPerformed()
1487 SequenceGroup sg = getGroup();
1493 if (abovePIDColour.isSelected())
1495 sg.cs.setConsensus(AAFrequency.calculate(
1496 sg.getSequences(ap.av.getHiddenRepSequences()),
1497 sg.getStartRes(), sg.getEndRes() + 1));
1499 int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
1502 sg.cs.setThreshold(threshold, ap.av.getIgnoreGapsConsensus());
1504 SliderPanel.showPIDSlider();
1507 // remove PIDColouring
1509 sg.cs.setThreshold(0, ap.av.getIgnoreGapsConsensus());
1521 protected void userDefinedColour_actionPerformed(ActionEvent e)
1523 SequenceGroup sg = getGroup();
1525 if (e.getSource().equals(userDefinedColour))
\r
1527 new UserDefinedColours(ap, sg);
1531 UserColourScheme udc = (UserColourScheme) UserDefinedColours
1532 .getUserColourSchemes().get(e.getActionCommand());
1545 protected void PIDColour_actionPerformed()
1547 SequenceGroup sg = getGroup();
1548 sg.cs = new PIDColourScheme();
1549 sg.cs.setConsensus(AAFrequency.calculate(
1550 sg.getSequences(ap.av.getHiddenRepSequences()),
1551 sg.getStartRes(), sg.getEndRes() + 1));
1561 protected void BLOSUM62Colour_actionPerformed()
1563 SequenceGroup sg = getGroup();
1565 sg.cs = new Blosum62ColourScheme();
1567 sg.cs.setConsensus(AAFrequency.calculate(
1568 sg.getSequences(ap.av.getHiddenRepSequences()),
1569 sg.getStartRes(), sg.getEndRes() + 1));
1580 protected void noColourmenuItem_actionPerformed()
1582 getGroup().cs = null;
1592 protected void conservationMenuItem_actionPerformed()
1594 SequenceGroup sg = getGroup();
1600 if (conservationMenuItem.isSelected())
1602 // JBPNote: Conservation name shouldn't be i18n translated
1603 Conservation c = new Conservation("Group",
1604 ResidueProperties.propHash, 3, sg.getSequences(ap.av
1605 .getHiddenRepSequences()), sg.getStartRes(),
1606 sg.getEndRes() + 1);
1609 c.verdict(false, ap.av.getConsPercGaps());
1611 sg.cs.setConservation(c);
1613 SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
1614 SliderPanel.showConservationSlider();
1617 // remove ConservationColouring
1619 sg.cs.setConservation(null);
1625 public void annotationMenuItem_actionPerformed(ActionEvent actionEvent)
1627 SequenceGroup sg = getGroup();
1633 AnnotationColourGradient acg = new AnnotationColourGradient(
1634 sequence.getAnnotation()[0], null,
1635 AnnotationColourGradient.NO_THRESHOLD);
1637 acg.setPredefinedColours(true);
1649 protected void groupName_actionPerformed()
1652 SequenceGroup sg = getGroup();
1653 EditNameDialog dialog = new EditNameDialog(sg.getName(),
1654 sg.getDescription(), " " + MessageManager.getString("label.group_name") + " ",
\r
1655 MessageManager.getString("label.group_description") + " ", MessageManager.getString("label.edit_group_name_description"),
\r
1663 sg.setName(dialog.getName());
1664 sg.setDescription(dialog.getDescription());
1669 * Get selection group - adding it to the alignment if necessary.
1671 * @return sequence group to operate on
1673 SequenceGroup getGroup()
1675 SequenceGroup sg = ap.av.getSelectionGroup();
1676 // this method won't add a new group if it already exists
1679 ap.av.getAlignment().addGroup(sg);
1691 void sequenceName_actionPerformed()
1693 EditNameDialog dialog = new EditNameDialog(sequence.getName(),
1694 sequence.getDescription(), " " + MessageManager.getString("label.sequence_name") + " ",
\r
1695 MessageManager.getString("label.sequence_description") + " ", MessageManager.getString("label.edit_sequence_name_description"),
\r
1703 if (dialog.getName() != null)
1705 if (dialog.getName().indexOf(" ") > -1)
1707 JOptionPane.showMessageDialog(ap,
1708 MessageManager.getString("label.spaces_converted_to_backslashes"),
\r
1709 MessageManager.getString("label.no_spaces_allowed_sequence_name"),
\r
1710 JOptionPane.WARNING_MESSAGE);
1713 sequence.setName(dialog.getName().replace(' ', '_'));
1714 ap.paintAlignment(false);
1717 sequence.setDescription(dialog.getDescription());
1719 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1730 void unGroupMenuItem_actionPerformed()
1732 SequenceGroup sg = ap.av.getSelectionGroup();
1733 ap.av.getAlignment().deleteGroup(sg);
1734 ap.av.setSelectionGroup(null);
1737 void createGroupMenuItem_actionPerformed()
1739 getGroup(); // implicitly creates group - note - should apply defaults / use standard alignment window logic for this
1749 protected void outline_actionPerformed()
1751 SequenceGroup sg = getGroup();
1752 Color col = JColorChooser.showDialog(this, MessageManager.getString("label.select_outline_colour"),
\r
1757 sg.setOutlineColour(col);
1769 public void showBoxes_actionPerformed()
1771 getGroup().setDisplayBoxes(showBoxes.isSelected());
1781 public void showText_actionPerformed()
1783 getGroup().setDisplayText(showText.isSelected());
1793 public void showColourText_actionPerformed()
1795 getGroup().setColourText(showColourText.isSelected());
1799 public void showLink(String url)
1803 jalview.util.BrowserLauncher.openURL(url);
1804 } catch (Exception ex)
1807 .showInternalMessageDialog(
1809 MessageManager.getString("label.web_browser_not_found_unix"),
\r
1810 MessageManager.getString("label.web_browser_not_found"), JOptionPane.WARNING_MESSAGE);
\r
1812 ex.printStackTrace();
1816 void hideSequences(boolean representGroup)
1818 SequenceGroup sg = ap.av.getSelectionGroup();
1819 if (sg == null || sg.getSize() < 1)
1821 ap.av.hideSequence(new SequenceI[]
1826 ap.av.setSelectionGroup(null);
1830 ap.av.hideRepSequences(sequence, sg);
1835 int gsize = sg.getSize();
1838 hseqs = new SequenceI[gsize];
1841 for (int i = 0; i < gsize; i++)
1843 hseqs[index++] = sg.getSequenceAt(i);
1846 ap.av.hideSequence(hseqs);
1847 // refresh(); TODO: ? needed ?
1848 ap.av.sendSelection();
1851 public void copy_actionPerformed()
1853 ap.alignFrame.copy_actionPerformed(null);
1856 public void cut_actionPerformed()
1858 ap.alignFrame.cut_actionPerformed(null);
1861 void changeCase(ActionEvent e)
1863 Object source = e.getSource();
1864 SequenceGroup sg = ap.av.getSelectionGroup();
1868 int[][] startEnd = ap.av.getVisibleRegionBoundaries(sg.getStartRes(),
1869 sg.getEndRes() + 1);
1874 if (source == toggle)
1876 description = MessageManager.getString("label.toggle_case");
\r
1877 caseChange = ChangeCaseCommand.TOGGLE_CASE;
1879 else if (source == upperCase)
1881 description = MessageManager.getString("label.to_upper_case");
\r
1882 caseChange = ChangeCaseCommand.TO_UPPER;
1886 description = MessageManager.getString("label.to_lower_case");
\r
1887 caseChange = ChangeCaseCommand.TO_LOWER;
1890 ChangeCaseCommand caseCommand = new ChangeCaseCommand(description,
1891 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
1892 startEnd, caseChange);
1894 ap.alignFrame.addHistoryItem(caseCommand);
1896 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1902 public void outputText_actionPerformed(ActionEvent e)
1904 CutAndPasteTransfer cap = new CutAndPasteTransfer();
1905 cap.setForInput(null);
1906 Desktop.addInternalFrame(cap,
1907 MessageManager.formatMessage("label.alignment_output_command", new String[]{e.getActionCommand()}), 600, 500);
\r
1909 String[] omitHidden = null;
1911 System.out.println("PROMPT USER HERE"); // TODO: decide if a prompt happens
1912 // or we simply trust the user wants
1913 // wysiwig behaviour
1914 SequenceGroup sg = ap.av.getSelectionGroup();
1915 ColumnSelection csel = new ColumnSelection(ap.av.getColumnSelection());
1916 omitHidden = ap.av.getViewAsString(true);
1917 Alignment oal = new Alignment(ap.av.getSequenceSelection());
1918 AlignmentAnnotation[] nala = ap.av.getAlignment()
1919 .getAlignmentAnnotation();
1922 for (int i = 0; i < nala.length; i++)
1924 AlignmentAnnotation na = nala[i];
1925 oal.addAnnotation(na);
1928 cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(),
1929 oal, omitHidden, csel, sg));
1933 public void pdbFromFile_actionPerformed()
1935 jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(
1936 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
1937 chooser.setFileView(new jalview.io.JalviewFileView());
1938 chooser.setDialogTitle(MessageManager.formatMessage("label.select_pdb_file_for", new String[]{sequence.getDisplayId(false)}));
\r
1939 chooser.setToolTipText(MessageManager.formatMessage("label.load_pdb_file_associate_with_sequence", new String[]{new Integer(sequence.getDisplayId(false)).toString()}));
\r
1941 int value = chooser.showOpenDialog(null);
1943 if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
1945 String choice = chooser.getSelectedFile().getPath();
1946 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
1947 new AssociatePdbFileWithSeq().associatePdbWithSeq(choice,
1948 jalview.io.AppletFormatAdapter.FILE, sequence, true);
1953 public void enterPDB_actionPerformed()
1955 String id = JOptionPane.showInternalInputDialog(Desktop.desktop,
1956 MessageManager.getString("label.enter_pdb_id"), MessageManager.getString("label.enter_pdb_id"), JOptionPane.QUESTION_MESSAGE);
\r
1958 if (id != null && id.length() > 0)
1960 PDBEntry entry = new PDBEntry();
1961 entry.setId(id.toUpperCase());
1962 sequence.getDatasetSequence().addPDBId(entry);
1966 public void discoverPDB_actionPerformed()
1969 final SequenceI[] sequences = ((ap.av.getSelectionGroup() == null) ? new SequenceI[]
1971 : ap.av.getSequenceSelection());
1972 Thread discpdb = new Thread(new Runnable()
1977 new jalview.ws.DBRefFetcher(sequences, ap.alignFrame)
1978 .fetchDBRefs(false);
1985 public void sequenceFeature_actionPerformed()
1987 SequenceGroup sg = ap.av.getSelectionGroup();
1993 int rsize = 0, gSize = sg.getSize();
1994 SequenceI[] rseqs, seqs = new SequenceI[gSize];
1995 SequenceFeature[] tfeatures, features = new SequenceFeature[gSize];
1997 for (int i = 0; i < gSize; i++)
1999 int start = sg.getSequenceAt(i).findPosition(sg.getStartRes());
2000 int end = sg.findEndRes(sg.getSequenceAt(i));
2003 seqs[rsize] = sg.getSequenceAt(i).getDatasetSequence();
2004 features[rsize] = new SequenceFeature(null, null, null, start, end,
2009 rseqs = new SequenceI[rsize];
2010 tfeatures = new SequenceFeature[rsize];
2011 System.arraycopy(seqs, 0, rseqs, 0, rsize);
2012 System.arraycopy(features, 0, tfeatures, 0, rsize);
2013 features = tfeatures;
2015 if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs,
2016 features, true, ap))
2018 ap.alignFrame.setShowSeqFeatures(true);
2019 ap.highlightSearchResults(null);
2023 public void textColour_actionPerformed()
2025 SequenceGroup sg = getGroup();
2028 new TextColourChooser().chooseColour(ap, sg);
2032 public void colourByStructure(String pdbid)
2034 Annotation[] anots = ap.av.getStructureSelectionManager()
2035 .colourSequenceFromStructure(sequence, pdbid);
2037 AlignmentAnnotation an = new AlignmentAnnotation("Structure",
2038 "Coloured by " + pdbid, anots);
2040 ap.av.getAlignment().addAnnotation(an);
2041 an.createSequenceMapping(sequence, 0, true);
2042 // an.adjustForAlignment();
2043 ap.av.getAlignment().setAnnotationIndex(an, 0);
2045 ap.adjustAnnotationHeight();
2047 sequence.addAlignmentAnnotation(an);
2051 public void editSequence_actionPerformed(ActionEvent actionEvent)
2053 SequenceGroup sg = ap.av.getSelectionGroup();
2057 if (sequence == null)
2058 sequence = (Sequence) sg.getSequenceAt(0);
2060 EditNameDialog dialog = new EditNameDialog(
2061 sequence.getSequenceAsString(sg.getStartRes(),
2062 sg.getEndRes() + 1), null, MessageManager.getString("label.edit_sequence"), null,
\r
2063 MessageManager.getString("label.edit_sequence"), ap.alignFrame);
\r
2067 EditCommand editCommand = new EditCommand(MessageManager.getString("label.edit_sequences"),
\r
2068 EditCommand.REPLACE, dialog.getName().replace(' ',
2069 ap.av.getGapCharacter()),
2070 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
2071 sg.getStartRes(), sg.getEndRes() + 1, ap.av.getAlignment());
2073 ap.alignFrame.addHistoryItem(editCommand);
2075 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()