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>(),reppdb=new Hashtable<String,PDBEntry>();
476 SequenceI sqass = null;
477 for (SequenceI sq : ap.av.getSequenceSelection())
479 Vector<PDBEntry> pes = (Vector<PDBEntry>) sq.getDatasetSequence()
483 reppdb.put(pes.get(0).getId(),pes.get(0));
484 for (PDBEntry pe : pes)
486 pdbe.put(pe.getId(), pe);
496 final PDBEntry[] pe = pdbe.values().toArray(
497 new PDBEntry[pdbe.size()]),pr = reppdb.values().toArray(
498 new PDBEntry[reppdb.size()]);
499 final JMenuItem gpdbview,rpdbview;
500 if (pdbe.size() == 1)
502 structureMenu.add(gpdbview = new JMenuItem(MessageManager.formatMessage("label.view_structure_for", new String[]{sqass.getDisplayId(false)})));
\r
506 structureMenu.add(gpdbview = new JMenuItem(MessageManager.formatMessage("label.view_all_structures", new String[]{new Integer(pdbe.size()).toString()})));
\r
508 gpdbview.setToolTipText(MessageManager.getString("label.open_new_jmol_view_with_all_structures_associated_current_selection_superimpose_using_alignment"));
\r
509 gpdbview.addActionListener(new ActionListener()
513 public void actionPerformed(ActionEvent e)
515 new AppJmol(ap, pe, ap.av.collateForPDB(pe));
518 if (reppdb.size()>1 && reppdb.size()<pdbe.size())
520 structureMenu.add(rpdbview = new JMenuItem(MessageManager.formatMessage("label.view_all_representative_structures", new String[]{new Integer(reppdb.size()).toString()})));
521 rpdbview.setToolTipText(MessageManager.getString("label.open_new_jmol_view_with_all_representative_structures_associated_current_selection_superimpose_using_alignment"));
522 rpdbview.addActionListener(new ActionListener()
526 public void actionPerformed(ActionEvent e)
528 new AppJmol(ap, pr, ap.av.collateForPDB(pr));
536 groupMenu.setVisible(false);
537 editMenu.setVisible(false);
542 createGroupMenuItem.setVisible(true);
543 unGroupMenuItem.setVisible(false);
544 jMenu1.setText(MessageManager.getString("action.edit_new_group"));
\r
546 createGroupMenuItem.setVisible(false);
547 unGroupMenuItem.setVisible(true);
548 jMenu1.setText(MessageManager.getString("action.edit_group"));
\r
553 sequenceMenu.setVisible(false);
554 structureMenu.setVisible(false);
557 if (links != null && links.size() > 0)
560 JMenu linkMenu = new JMenu(MessageManager.getString("action.link"));
\r
561 Vector linkset = new Vector();
562 for (int i = 0; i < links.size(); i++)
564 String link = links.elementAt(i).toString();
565 UrlLink urlLink = null;
568 urlLink = new UrlLink(link);
569 } catch (Exception foo)
571 jalview.bin.Cache.log.error("Exception for URLLink '" + link
576 if (!urlLink.isValid())
578 jalview.bin.Cache.log.error(urlLink.getInvalidMessage());
581 final String label = urlLink.getLabel();
582 if (seq != null && urlLink.isDynamic())
585 // collect matching db-refs
586 DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(
587 seq.getDBRef(), new String[]
588 { urlLink.getTarget() });
589 // collect id string too
590 String id = seq.getName();
591 String descr = seq.getDescription();
592 if (descr != null && descr.length() < 1)
599 for (int r = 0; r < dbr.length; r++)
601 if (id != null && dbr[r].getAccessionId().equals(id))
603 // suppress duplicate link creation for the bare sequence ID
604 // string with this link
607 // create Bare ID link for this RUL
608 String[] urls = urlLink.makeUrls(dbr[r].getAccessionId(),
612 for (int u = 0; u < urls.length; u += 2)
614 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
616 linkset.addElement(urls[u] + "|" + urls[u + 1]);
617 addshowLink(linkMenu, label + "|" + urls[u],
626 // create Bare ID link for this RUL
627 String[] urls = urlLink.makeUrls(id, true);
630 for (int u = 0; u < urls.length; u += 2)
632 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
634 linkset.addElement(urls[u] + "|" + urls[u + 1]);
635 addshowLink(linkMenu, label, urls[u + 1]);
640 // Create urls from description but only for URL links which are regex
642 if (descr != null && urlLink.getRegexReplace() != null)
644 // create link for this URL from description where regex matches
645 String[] urls = urlLink.makeUrls(descr, true);
648 for (int u = 0; u < urls.length; u += 2)
650 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
652 linkset.addElement(urls[u] + "|" + urls[u + 1]);
653 addshowLink(linkMenu, label, urls[u + 1]);
661 if (!linkset.contains(label + "|" + urlLink.getUrl_prefix()))
663 linkset.addElement(label + "|" + urlLink.getUrl_prefix());
664 // Add a non-dynamic link
665 addshowLink(linkMenu, label, urlLink.getUrl_prefix());
669 if (sequence != null)
671 sequenceMenu.add(linkMenu);
680 private void buildGroupURLMenu(SequenceGroup sg, Vector groupLinks)
683 // TODO: usability: thread off the generation of group url content so root
685 // sequence only URLs
686 // ID/regex match URLs
687 groupLinksMenu = new JMenu(MessageManager.getString("action.group_link"));
\r
688 JMenu[] linkMenus = new JMenu[]
689 { null, new JMenu(MessageManager.getString("action.ids")), new JMenu(MessageManager.getString("action.sequences")),
\r
690 new JMenu(MessageManager.getString("action.ids_sequences")) }; // three types of url that might be
\r
692 SequenceI[] seqs = ap.av.getSelectionAsNewSequence();
693 String[][] idandseqs = GroupUrlLink.formStrings(seqs);
694 Hashtable commonDbrefs = new Hashtable();
695 for (int sq = 0; sq < seqs.length; sq++)
698 int start = seqs[sq].findPosition(sg.getStartRes()), end = seqs[sq]
699 .findPosition(sg.getEndRes());
700 // just collect ids from dataset sequence
701 // TODO: check if IDs collected from selecton group intersects with the
702 // current selection, too
703 SequenceI sqi = seqs[sq];
704 while (sqi.getDatasetSequence() != null)
706 sqi = sqi.getDatasetSequence();
708 DBRefEntry[] dbr = sqi.getDBRef();
709 if (dbr != null && dbr.length > 0)
711 for (int d = 0; d < dbr.length; d++)
713 String src = dbr[d].getSource(); // jalview.util.DBRefUtils.getCanonicalName(dbr[d].getSource()).toUpperCase();
714 Object[] sarray = (Object[]) commonDbrefs.get(src);
717 sarray = new Object[2];
718 sarray[0] = new int[]
720 sarray[1] = new String[seqs.length];
722 commonDbrefs.put(src, sarray);
725 if (((String[]) sarray[1])[sq] == null)
728 || (dbr[d].getMap().locateMappedRange(start, end) != null))
730 ((String[]) sarray[1])[sq] = dbr[d].getAccessionId();
731 ((int[]) sarray[0])[0]++;
737 // now create group links for all distinct ID/sequence sets.
738 boolean addMenu = false; // indicates if there are any group links to give
740 for (int i = 0; i < groupLinks.size(); i++)
742 String link = groupLinks.elementAt(i).toString();
743 GroupUrlLink urlLink = null;
746 urlLink = new GroupUrlLink(link);
747 } catch (Exception foo)
749 jalview.bin.Cache.log.error("Exception for GroupURLLink '" + link
754 if (!urlLink.isValid())
756 jalview.bin.Cache.log.error(urlLink.getInvalidMessage());
759 final String label = urlLink.getLabel();
760 boolean usingNames = false;
761 // Now see which parts of the group apply for this URL
762 String ltarget = urlLink.getTarget(); // jalview.util.DBRefUtils.getCanonicalName(urlLink.getTarget());
763 Object[] idset = (Object[]) commonDbrefs.get(ltarget.toUpperCase());
764 String[] seqstr, ids; // input to makeUrl
767 int numinput = ((int[]) idset[0])[0];
768 String[] allids = ((String[]) idset[1]);
769 seqstr = new String[numinput];
770 ids = new String[numinput];
771 for (int sq = 0, idcount = 0; sq < seqs.length; sq++)
773 if (allids[sq] != null)
775 ids[idcount] = allids[sq];
776 seqstr[idcount++] = idandseqs[1][sq];
782 // just use the id/seq set
783 seqstr = idandseqs[1];
787 // and try and make the groupURL!
789 Object[] urlset = null;
792 urlset = urlLink.makeUrlStubs(ids, seqstr,
793 "FromJalview" + System.currentTimeMillis(), false);
794 } catch (UrlStringTooLongException e)
799 int type = urlLink.getGroupURLType() & 3;
800 // System.out.println(urlLink.getGroupURLType()
801 // +" "+((String[])urlset[3])[0]);
802 // first two bits ofurlLink type bitfield are sequenceids and sequences
803 // TODO: FUTURE: ensure the groupURL menu structure can be generalised
804 addshowLink(linkMenus[type], label
805 + (((type & 1) == 1) ? ("("
806 + (usingNames ? "Names" : ltarget) + ")") : ""),
813 groupLinksMenu = new JMenu(MessageManager.getString("action.group_link"));
\r
814 for (int m = 0; m < linkMenus.length; m++)
816 if (linkMenus[m] != null
817 && linkMenus[m].getMenuComponentCount() > 0)
819 groupLinksMenu.add(linkMenus[m]);
823 groupMenu.add(groupLinksMenu);
828 * add a show URL menu item to the given linkMenu
832 * - menu label string
836 private void addshowLink(JMenu linkMenu, String label, final String url)
838 JMenuItem item = new JMenuItem(label);
839 item.setToolTipText(MessageManager.formatMessage("label.open_url_param", new String[]{url}));
\r
840 item.addActionListener(new java.awt.event.ActionListener()
842 public void actionPerformed(ActionEvent e)
844 new Thread(new Runnable()
860 * add a late bound groupURL item to the given linkMenu
864 * - menu label string
865 * @param urlgenerator
866 * GroupURLLink used to generate URL
868 * Object array returned from the makeUrlStubs function.
870 private void addshowLink(JMenu linkMenu, String label,
871 final GroupUrlLink urlgenerator, final Object[] urlstub)
873 JMenuItem item = new JMenuItem(label);
874 item.setToolTipText(MessageManager.formatMessage("label.open_url_seqs_param", new Object[]{urlgenerator.getUrl_prefix(),urlgenerator.getNumberInvolved(urlstub)}));
\r
875 // TODO: put in info about what is being sent.
\r
876 item.addActionListener(new java.awt.event.ActionListener()
878 public void actionPerformed(ActionEvent e)
880 new Thread(new Runnable()
887 showLink(urlgenerator.constructFrom(urlstub));
888 } catch (UrlStringTooLongException e)
906 private void jbInit() throws Exception
908 groupMenu.setText(MessageManager.getString("label.group"));
\r
909 groupMenu.setText(MessageManager.getString("label.selection"));
\r
910 groupName.setText(MessageManager.getString("label.name"));
\r
911 groupName.addActionListener(new java.awt.event.ActionListener()
913 public void actionPerformed(ActionEvent e)
915 groupName_actionPerformed();
918 sequenceMenu.setText(MessageManager.getString("label.sequence"));
\r
919 sequenceName.setText(MessageManager.getString("label.edit_name_description"));
\r
920 sequenceName.addActionListener(new java.awt.event.ActionListener()
922 public void actionPerformed(ActionEvent e)
924 sequenceName_actionPerformed();
927 sequenceDetails.setText(MessageManager.getString("label.sequence_details") + "...");
\r
928 sequenceDetails.addActionListener(new java.awt.event.ActionListener()
930 public void actionPerformed(ActionEvent e)
932 sequenceDetails_actionPerformed();
935 sequenceSelDetails.setText(MessageManager.getString("label.sequence_details") + "...");
\r
937 .addActionListener(new java.awt.event.ActionListener()
939 public void actionPerformed(ActionEvent e)
941 sequenceSelectionDetails_actionPerformed();
944 PIDColour.setFocusPainted(false);
945 unGroupMenuItem.setText(MessageManager.getString("action.remove_group"));
\r
946 unGroupMenuItem.addActionListener(new java.awt.event.ActionListener()
948 public void actionPerformed(ActionEvent e)
950 unGroupMenuItem_actionPerformed();
953 createGroupMenuItem.setText(MessageManager.getString("action.create_group"));
\r
954 createGroupMenuItem.addActionListener(new java.awt.event.ActionListener()
956 public void actionPerformed(ActionEvent e)
958 createGroupMenuItem_actionPerformed();
962 outline.setText(MessageManager.getString("action.border_colour"));
\r
963 outline.addActionListener(new java.awt.event.ActionListener()
965 public void actionPerformed(ActionEvent e)
967 outline_actionPerformed();
970 nucleotideMenuItem.setText(MessageManager.getString("label.nucleotide"));
\r
971 nucleotideMenuItem.addActionListener(new ActionListener()
973 public void actionPerformed(ActionEvent e)
975 nucleotideMenuItem_actionPerformed();
978 colourMenu.setText(MessageManager.getString("label.group_colour"));
\r
979 showBoxes.setText(MessageManager.getString("action.boxes"));
\r
980 showBoxes.setState(true);
981 showBoxes.addActionListener(new ActionListener()
983 public void actionPerformed(ActionEvent e)
985 showBoxes_actionPerformed();
988 showText.setText(MessageManager.getString("action.text"));
\r
989 showText.setState(true);
990 showText.addActionListener(new ActionListener()
992 public void actionPerformed(ActionEvent e)
994 showText_actionPerformed();
997 showColourText.setText(MessageManager.getString("label.colour_text"));
\r
998 showColourText.addActionListener(new ActionListener()
1000 public void actionPerformed(ActionEvent e)
1002 showColourText_actionPerformed();
1005 displayNonconserved.setText(MessageManager.getString("label.show_non_conversed"));
\r
1006 displayNonconserved.setState(true);
1007 displayNonconserved.addActionListener(new ActionListener()
1009 public void actionPerformed(ActionEvent e)
1011 showNonconserved_actionPerformed();
1014 editMenu.setText(MessageManager.getString("action.edit"));
\r
1015 cut.setText(MessageManager.getString("action.cut"));
\r
1016 cut.addActionListener(new ActionListener()
1018 public void actionPerformed(ActionEvent e)
1020 cut_actionPerformed();
1023 upperCase.setText(MessageManager.getString("label.to_upper_case"));
\r
1024 upperCase.addActionListener(new ActionListener()
1026 public void actionPerformed(ActionEvent e)
1031 copy.setText(MessageManager.getString("action.copy"));
\r
1032 copy.addActionListener(new ActionListener()
1034 public void actionPerformed(ActionEvent e)
1036 copy_actionPerformed();
1039 lowerCase.setText(MessageManager.getString("label.to_lower_case"));
\r
1040 lowerCase.addActionListener(new ActionListener()
1042 public void actionPerformed(ActionEvent e)
1047 toggle.setText(MessageManager.getString("label.toggle_case"));
\r
1048 toggle.addActionListener(new ActionListener()
1050 public void actionPerformed(ActionEvent e)
1055 pdbMenu.setText(MessageManager.getString("label.associate_structure_with_sequence"));
\r
1056 pdbFromFile.setText(MessageManager.getString("label.from_file"));
\r
1057 pdbFromFile.addActionListener(new ActionListener()
1059 public void actionPerformed(ActionEvent e)
1061 pdbFromFile_actionPerformed();
1064 enterPDB.setText(MessageManager.getString("label.enter_pdb_id"));
\r
1065 enterPDB.addActionListener(new ActionListener()
1067 public void actionPerformed(ActionEvent e)
1069 enterPDB_actionPerformed();
1072 discoverPDB.setText(MessageManager.getString("label.discover_pdb_ids"));
\r
1073 discoverPDB.addActionListener(new ActionListener()
1075 public void actionPerformed(ActionEvent e)
1077 discoverPDB_actionPerformed();
1080 outputMenu.setText(MessageManager.getString("label.out_to_textbox") + "...");
\r
1081 sequenceFeature.setText(MessageManager.getString("label.create_sequence_feature"));
\r
1082 sequenceFeature.addActionListener(new ActionListener()
1084 public void actionPerformed(ActionEvent e)
1086 sequenceFeature_actionPerformed();
1089 textColour.setText(MessageManager.getString("label.text_colour"));
\r
1090 textColour.addActionListener(new ActionListener()
1092 public void actionPerformed(ActionEvent e)
1094 textColour_actionPerformed();
1097 jMenu1.setText(MessageManager.getString("label.group"));
\r
1098 structureMenu.setText(MessageManager.getString("label.structure"));
\r
1099 viewStructureMenu.setText(MessageManager.getString("label.view_structure"));
\r
1100 // colStructureMenu.setText("Colour By Structure");
1101 editSequence.setText(MessageManager.getString("label.edit_sequence") + "...");
\r
1102 editSequence.addActionListener(new ActionListener()
1104 public void actionPerformed(ActionEvent actionEvent)
1106 editSequence_actionPerformed(actionEvent);
1111 * annotationMenuItem.setText("By Annotation");
1112 * annotationMenuItem.addActionListener(new ActionListener() { public void
1113 * actionPerformed(ActionEvent actionEvent) {
1114 * annotationMenuItem_actionPerformed(actionEvent); } });
1116 groupMenu.add(sequenceSelDetails);
1119 this.add(structureMenu);
1120 groupMenu.add(editMenu);
1121 groupMenu.add(outputMenu);
1122 groupMenu.add(sequenceFeature);
1123 groupMenu.add(createGroupMenuItem);
1124 groupMenu.add(unGroupMenuItem);
1125 groupMenu.add(jMenu1);
1126 sequenceMenu.add(sequenceName);
1127 sequenceMenu.add(sequenceDetails);
1128 colourMenu.add(textColour);
1129 colourMenu.add(noColourmenuItem);
1130 colourMenu.add(clustalColour);
1131 colourMenu.add(BLOSUM62Colour);
1132 colourMenu.add(PIDColour);
1133 colourMenu.add(zappoColour);
1134 colourMenu.add(taylorColour);
1135 colourMenu.add(hydrophobicityColour);
1136 colourMenu.add(helixColour);
1137 colourMenu.add(strandColour);
1138 colourMenu.add(turnColour);
1139 colourMenu.add(buriedColour);
1140 colourMenu.add(nucleotideMenuItem);
1141 if (ap.getAlignment().isNucleotide())
1143 colourMenu.add(purinePyrimidineColour);
1145 // colourMenu.add(covariationColour);
1146 colourMenu.add(userDefinedColour);
1148 if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null)
1150 java.util.Enumeration userColours = jalview.gui.UserDefinedColours
1151 .getUserColourSchemes().keys();
1153 while (userColours.hasMoreElements())
1155 JMenuItem item = new JMenuItem(userColours.nextElement().toString());
1156 item.addActionListener(new ActionListener()
1158 public void actionPerformed(ActionEvent evt)
1160 userDefinedColour_actionPerformed(evt);
1163 colourMenu.add(item);
1167 colourMenu.addSeparator();
1168 colourMenu.add(abovePIDColour);
1169 colourMenu.add(conservationMenuItem);
1170 // colourMenu.add(annotationMenuItem);
1173 editMenu.add(editSequence);
1174 editMenu.add(upperCase);
1175 editMenu.add(lowerCase);
1176 editMenu.add(toggle);
1177 pdbMenu.add(pdbFromFile);
1178 pdbMenu.add(enterPDB);
1179 pdbMenu.add(discoverPDB);
1180 jMenu1.add(groupName);
1181 jMenu1.add(colourMenu);
1182 jMenu1.add(showBoxes);
1183 jMenu1.add(showText);
1184 jMenu1.add(showColourText);
1185 jMenu1.add(outline);
1186 jMenu1.add(displayNonconserved);
1187 structureMenu.add(pdbMenu);
1188 structureMenu.add(viewStructureMenu);
1189 // structureMenu.add(colStructureMenu);
1190 noColourmenuItem.setText(MessageManager.getString("label.none"));
\r
1191 noColourmenuItem.addActionListener(new java.awt.event.ActionListener()
1193 public void actionPerformed(ActionEvent e)
1195 noColourmenuItem_actionPerformed();
1199 clustalColour.setText(MessageManager.getString("label.clustalx_colours"));
\r
1200 clustalColour.addActionListener(new java.awt.event.ActionListener()
1202 public void actionPerformed(ActionEvent e)
1204 clustalColour_actionPerformed();
1207 zappoColour.setText(MessageManager.getString("label.zappo"));
\r
1208 zappoColour.addActionListener(new java.awt.event.ActionListener()
1210 public void actionPerformed(ActionEvent e)
1212 zappoColour_actionPerformed();
1215 taylorColour.setText(MessageManager.getString("label.taylor"));
\r
1216 taylorColour.addActionListener(new java.awt.event.ActionListener()
1218 public void actionPerformed(ActionEvent e)
1220 taylorColour_actionPerformed();
1223 hydrophobicityColour.setText(MessageManager.getString("label.hydrophobicity"));
\r
1224 hydrophobicityColour
1225 .addActionListener(new java.awt.event.ActionListener()
1227 public void actionPerformed(ActionEvent e)
1229 hydrophobicityColour_actionPerformed();
1232 helixColour.setText(MessageManager.getString("label.helix_propensity"));
\r
1233 helixColour.addActionListener(new java.awt.event.ActionListener()
1235 public void actionPerformed(ActionEvent e)
1237 helixColour_actionPerformed();
1240 strandColour.setText(MessageManager.getString("label.strand_propensity"));
\r
1241 strandColour.addActionListener(new java.awt.event.ActionListener()
1243 public void actionPerformed(ActionEvent e)
1245 strandColour_actionPerformed();
1248 turnColour.setText(MessageManager.getString("label.turn_propensity"));
\r
1249 turnColour.addActionListener(new java.awt.event.ActionListener()
1251 public void actionPerformed(ActionEvent e)
1253 turnColour_actionPerformed();
1256 buriedColour.setText(MessageManager.getString("label.buried_index"));
\r
1257 buriedColour.addActionListener(new java.awt.event.ActionListener()
1259 public void actionPerformed(ActionEvent e)
1261 buriedColour_actionPerformed();
1264 abovePIDColour.setText(MessageManager.getString("label.above_identity_percentage"));
\r
1265 abovePIDColour.addActionListener(new java.awt.event.ActionListener()
1267 public void actionPerformed(ActionEvent e)
1269 abovePIDColour_actionPerformed();
1272 userDefinedColour.setText(MessageManager.getString("action.user_defined"));
\r
1273 userDefinedColour.addActionListener(new java.awt.event.ActionListener()
1275 public void actionPerformed(ActionEvent e)
1277 userDefinedColour_actionPerformed(e);
1280 PIDColour.setText(MessageManager.getString("label.percentage_identity"));
\r
1281 PIDColour.addActionListener(new java.awt.event.ActionListener()
1283 public void actionPerformed(ActionEvent e)
1285 PIDColour_actionPerformed();
1288 BLOSUM62Colour.setText(MessageManager.getString("label.blosum62"));
\r
1289 BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener()
1291 public void actionPerformed(ActionEvent e)
1293 BLOSUM62Colour_actionPerformed();
1296 purinePyrimidineColour.setText(MessageManager.getString("label.purine_pyrimidine"));
\r
1297 purinePyrimidineColour
1298 .addActionListener(new java.awt.event.ActionListener()
1300 public void actionPerformed(ActionEvent e)
1302 purinePyrimidineColour_actionPerformed();
1306 * covariationColour.addActionListener(new java.awt.event.ActionListener() {
1307 * public void actionPerformed(ActionEvent e) {
1308 * covariationColour_actionPerformed(); } });
1311 conservationMenuItem.setText(MessageManager.getString("label.conservation"));
\r
1312 conservationMenuItem
1313 .addActionListener(new java.awt.event.ActionListener()
1315 public void actionPerformed(ActionEvent e)
1317 conservationMenuItem_actionPerformed();
1322 protected void sequenceSelectionDetails_actionPerformed()
1324 createSequenceDetailsReport(ap.av.getSequenceSelection());
1327 protected void sequenceDetails_actionPerformed()
1329 createSequenceDetailsReport(new SequenceI[]
1333 public void createSequenceDetailsReport(SequenceI[] sequences)
1335 CutAndPasteHtmlTransfer cap = new CutAndPasteHtmlTransfer();
1336 StringBuffer contents = new StringBuffer();
1337 for (SequenceI seq : sequences)
1339 contents.append("<p><h2>" + MessageManager.formatMessage("label.create_sequence_details_report_annotation_for", new String[]{seq.getDisplayId(true)})
\r
1341 new SequenceAnnotationReport(null)
1342 .createSequenceAnnotationReport(
1348 (ap.seqPanel.seqCanvas.fr != null) ? ap.seqPanel.seqCanvas.fr.minmax
1350 contents.append("</p>");
1352 cap.setText("<html>" + contents.toString() + "</html>");
1354 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
1359 protected void showNonconserved_actionPerformed()
1361 getGroup().setShowNonconserved(displayNonconserved.isSelected());
1366 * call to refresh view after settings change
1370 ap.updateAnnotation();
1371 ap.paintAlignment(true);
1373 PaintRefresher.Refresh(this, ap.av.getSequenceSetId());
1382 protected void clustalColour_actionPerformed()
1384 SequenceGroup sg = getGroup();
1385 sg.cs = new ClustalxColourScheme(sg, ap.av.getHiddenRepSequences());
1395 protected void zappoColour_actionPerformed()
1397 getGroup().cs = new ZappoColourScheme();
1407 protected void taylorColour_actionPerformed()
1409 getGroup().cs = new TaylorColourScheme();
1419 protected void hydrophobicityColour_actionPerformed()
1421 getGroup().cs = new HydrophobicColourScheme();
1431 protected void helixColour_actionPerformed()
1433 getGroup().cs = new HelixColourScheme();
1443 protected void strandColour_actionPerformed()
1445 getGroup().cs = new StrandColourScheme();
1455 protected void turnColour_actionPerformed()
1457 getGroup().cs = new TurnColourScheme();
1467 protected void buriedColour_actionPerformed()
1469 getGroup().cs = new BuriedColourScheme();
1479 public void nucleotideMenuItem_actionPerformed()
1481 getGroup().cs = new NucleotideColourScheme();
1485 protected void purinePyrimidineColour_actionPerformed()
1487 getGroup().cs = new PurinePyrimidineColourScheme();
1492 * protected void covariationColour_actionPerformed() { getGroup().cs = new
1493 * CovariationColourScheme(sequence.getAnnotation()[0]); refresh(); }
1501 protected void abovePIDColour_actionPerformed()
1503 SequenceGroup sg = getGroup();
1509 if (abovePIDColour.isSelected())
1511 sg.cs.setConsensus(AAFrequency.calculate(
1512 sg.getSequences(ap.av.getHiddenRepSequences()),
1513 sg.getStartRes(), sg.getEndRes() + 1));
1515 int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
1518 sg.cs.setThreshold(threshold, ap.av.getIgnoreGapsConsensus());
1520 SliderPanel.showPIDSlider();
1523 // remove PIDColouring
1525 sg.cs.setThreshold(0, ap.av.getIgnoreGapsConsensus());
1537 protected void userDefinedColour_actionPerformed(ActionEvent e)
1539 SequenceGroup sg = getGroup();
1541 if (e.getSource().equals(userDefinedColour))
\r
1543 new UserDefinedColours(ap, sg);
1547 UserColourScheme udc = (UserColourScheme) UserDefinedColours
1548 .getUserColourSchemes().get(e.getActionCommand());
1561 protected void PIDColour_actionPerformed()
1563 SequenceGroup sg = getGroup();
1564 sg.cs = new PIDColourScheme();
1565 sg.cs.setConsensus(AAFrequency.calculate(
1566 sg.getSequences(ap.av.getHiddenRepSequences()),
1567 sg.getStartRes(), sg.getEndRes() + 1));
1577 protected void BLOSUM62Colour_actionPerformed()
1579 SequenceGroup sg = getGroup();
1581 sg.cs = new Blosum62ColourScheme();
1583 sg.cs.setConsensus(AAFrequency.calculate(
1584 sg.getSequences(ap.av.getHiddenRepSequences()),
1585 sg.getStartRes(), sg.getEndRes() + 1));
1596 protected void noColourmenuItem_actionPerformed()
1598 getGroup().cs = null;
1608 protected void conservationMenuItem_actionPerformed()
1610 SequenceGroup sg = getGroup();
1616 if (conservationMenuItem.isSelected())
1618 // JBPNote: Conservation name shouldn't be i18n translated
1619 Conservation c = new Conservation("Group",
1620 ResidueProperties.propHash, 3, sg.getSequences(ap.av
1621 .getHiddenRepSequences()), sg.getStartRes(),
1622 sg.getEndRes() + 1);
1625 c.verdict(false, ap.av.getConsPercGaps());
1627 sg.cs.setConservation(c);
1629 SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
1630 SliderPanel.showConservationSlider();
1633 // remove ConservationColouring
1635 sg.cs.setConservation(null);
1641 public void annotationMenuItem_actionPerformed(ActionEvent actionEvent)
1643 SequenceGroup sg = getGroup();
1649 AnnotationColourGradient acg = new AnnotationColourGradient(
1650 sequence.getAnnotation()[0], null,
1651 AnnotationColourGradient.NO_THRESHOLD);
1653 acg.setPredefinedColours(true);
1665 protected void groupName_actionPerformed()
1668 SequenceGroup sg = getGroup();
1669 EditNameDialog dialog = new EditNameDialog(sg.getName(),
1670 sg.getDescription(), " " + MessageManager.getString("label.group_name") + " ",
\r
1671 MessageManager.getString("label.group_description") + " ", MessageManager.getString("label.edit_group_name_description"),
\r
1679 sg.setName(dialog.getName());
1680 sg.setDescription(dialog.getDescription());
1685 * Get selection group - adding it to the alignment if necessary.
1687 * @return sequence group to operate on
1689 SequenceGroup getGroup()
1691 SequenceGroup sg = ap.av.getSelectionGroup();
1692 // this method won't add a new group if it already exists
1695 ap.av.getAlignment().addGroup(sg);
1707 void sequenceName_actionPerformed()
1709 EditNameDialog dialog = new EditNameDialog(sequence.getName(),
1710 sequence.getDescription(), " " + MessageManager.getString("label.sequence_name") + " ",
\r
1711 MessageManager.getString("label.sequence_description") + " ", MessageManager.getString("label.edit_sequence_name_description"),
\r
1719 if (dialog.getName() != null)
1721 if (dialog.getName().indexOf(" ") > -1)
1723 JOptionPane.showMessageDialog(ap,
1724 MessageManager.getString("label.spaces_converted_to_backslashes"),
\r
1725 MessageManager.getString("label.no_spaces_allowed_sequence_name"),
\r
1726 JOptionPane.WARNING_MESSAGE);
1729 sequence.setName(dialog.getName().replace(' ', '_'));
1730 ap.paintAlignment(false);
1733 sequence.setDescription(dialog.getDescription());
1735 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1746 void unGroupMenuItem_actionPerformed()
1748 SequenceGroup sg = ap.av.getSelectionGroup();
1749 ap.av.getAlignment().deleteGroup(sg);
1750 ap.av.setSelectionGroup(null);
1753 void createGroupMenuItem_actionPerformed()
1755 getGroup(); // implicitly creates group - note - should apply defaults / use standard alignment window logic for this
1765 protected void outline_actionPerformed()
1767 SequenceGroup sg = getGroup();
1768 Color col = JColorChooser.showDialog(this, MessageManager.getString("label.select_outline_colour"),
\r
1773 sg.setOutlineColour(col);
1785 public void showBoxes_actionPerformed()
1787 getGroup().setDisplayBoxes(showBoxes.isSelected());
1797 public void showText_actionPerformed()
1799 getGroup().setDisplayText(showText.isSelected());
1809 public void showColourText_actionPerformed()
1811 getGroup().setColourText(showColourText.isSelected());
1815 public void showLink(String url)
1819 jalview.util.BrowserLauncher.openURL(url);
1820 } catch (Exception ex)
1823 .showInternalMessageDialog(
1825 MessageManager.getString("label.web_browser_not_found_unix"),
\r
1826 MessageManager.getString("label.web_browser_not_found"), JOptionPane.WARNING_MESSAGE);
\r
1828 ex.printStackTrace();
1832 void hideSequences(boolean representGroup)
1834 SequenceGroup sg = ap.av.getSelectionGroup();
1835 if (sg == null || sg.getSize() < 1)
1837 ap.av.hideSequence(new SequenceI[]
1842 ap.av.setSelectionGroup(null);
1846 ap.av.hideRepSequences(sequence, sg);
1851 int gsize = sg.getSize();
1854 hseqs = new SequenceI[gsize];
1857 for (int i = 0; i < gsize; i++)
1859 hseqs[index++] = sg.getSequenceAt(i);
1862 ap.av.hideSequence(hseqs);
1863 // refresh(); TODO: ? needed ?
1864 ap.av.sendSelection();
1867 public void copy_actionPerformed()
1869 ap.alignFrame.copy_actionPerformed(null);
1872 public void cut_actionPerformed()
1874 ap.alignFrame.cut_actionPerformed(null);
1877 void changeCase(ActionEvent e)
1879 Object source = e.getSource();
1880 SequenceGroup sg = ap.av.getSelectionGroup();
1884 int[][] startEnd = ap.av.getVisibleRegionBoundaries(sg.getStartRes(),
1885 sg.getEndRes() + 1);
1890 if (source == toggle)
1892 description = MessageManager.getString("label.toggle_case");
\r
1893 caseChange = ChangeCaseCommand.TOGGLE_CASE;
1895 else if (source == upperCase)
1897 description = MessageManager.getString("label.to_upper_case");
\r
1898 caseChange = ChangeCaseCommand.TO_UPPER;
1902 description = MessageManager.getString("label.to_lower_case");
\r
1903 caseChange = ChangeCaseCommand.TO_LOWER;
1906 ChangeCaseCommand caseCommand = new ChangeCaseCommand(description,
1907 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
1908 startEnd, caseChange);
1910 ap.alignFrame.addHistoryItem(caseCommand);
1912 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1918 public void outputText_actionPerformed(ActionEvent e)
1920 CutAndPasteTransfer cap = new CutAndPasteTransfer();
1921 cap.setForInput(null);
1922 Desktop.addInternalFrame(cap,
1923 MessageManager.formatMessage("label.alignment_output_command", new String[]{e.getActionCommand()}), 600, 500);
\r
1925 String[] omitHidden = null;
1927 System.out.println("PROMPT USER HERE"); // TODO: decide if a prompt happens
1928 // or we simply trust the user wants
1929 // wysiwig behaviour
1930 SequenceGroup sg = ap.av.getSelectionGroup();
1931 ColumnSelection csel = new ColumnSelection(ap.av.getColumnSelection());
1932 omitHidden = ap.av.getViewAsString(true);
1933 Alignment oal = new Alignment(ap.av.getSequenceSelection());
1934 AlignmentAnnotation[] nala = ap.av.getAlignment()
1935 .getAlignmentAnnotation();
1938 for (int i = 0; i < nala.length; i++)
1940 AlignmentAnnotation na = nala[i];
1941 oal.addAnnotation(na);
1944 cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(),
1945 oal, omitHidden, csel, sg));
1949 public void pdbFromFile_actionPerformed()
1951 jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(
1952 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
1953 chooser.setFileView(new jalview.io.JalviewFileView());
1954 chooser.setDialogTitle(MessageManager.formatMessage("label.select_pdb_file_for", new String[]{sequence.getDisplayId(false)}));
\r
1955 chooser.setToolTipText(MessageManager.formatMessage("label.load_pdb_file_associate_with_sequence", new String[]{new Integer(sequence.getDisplayId(false)).toString()}));
\r
1957 int value = chooser.showOpenDialog(null);
1959 if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
1961 String choice = chooser.getSelectedFile().getPath();
1962 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
1963 new AssociatePdbFileWithSeq().associatePdbWithSeq(choice,
1964 jalview.io.AppletFormatAdapter.FILE, sequence, true);
1969 public void enterPDB_actionPerformed()
1971 String id = JOptionPane.showInternalInputDialog(Desktop.desktop,
1972 MessageManager.getString("label.enter_pdb_id"), MessageManager.getString("label.enter_pdb_id"), JOptionPane.QUESTION_MESSAGE);
\r
1974 if (id != null && id.length() > 0)
1976 PDBEntry entry = new PDBEntry();
1977 entry.setId(id.toUpperCase());
1978 sequence.getDatasetSequence().addPDBId(entry);
1982 public void discoverPDB_actionPerformed()
1985 final SequenceI[] sequences = ((ap.av.getSelectionGroup() == null) ? new SequenceI[]
1987 : ap.av.getSequenceSelection());
1988 Thread discpdb = new Thread(new Runnable()
1993 new jalview.ws.DBRefFetcher(sequences, ap.alignFrame)
1994 .fetchDBRefs(false);
2001 public void sequenceFeature_actionPerformed()
2003 SequenceGroup sg = ap.av.getSelectionGroup();
2009 int rsize = 0, gSize = sg.getSize();
2010 SequenceI[] rseqs, seqs = new SequenceI[gSize];
2011 SequenceFeature[] tfeatures, features = new SequenceFeature[gSize];
2013 for (int i = 0; i < gSize; i++)
2015 int start = sg.getSequenceAt(i).findPosition(sg.getStartRes());
2016 int end = sg.findEndRes(sg.getSequenceAt(i));
2019 seqs[rsize] = sg.getSequenceAt(i).getDatasetSequence();
2020 features[rsize] = new SequenceFeature(null, null, null, start, end,
2025 rseqs = new SequenceI[rsize];
2026 tfeatures = new SequenceFeature[rsize];
2027 System.arraycopy(seqs, 0, rseqs, 0, rsize);
2028 System.arraycopy(features, 0, tfeatures, 0, rsize);
2029 features = tfeatures;
2031 if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs,
2032 features, true, ap))
2034 ap.alignFrame.setShowSeqFeatures(true);
2035 ap.highlightSearchResults(null);
2039 public void textColour_actionPerformed()
2041 SequenceGroup sg = getGroup();
2044 new TextColourChooser().chooseColour(ap, sg);
2048 public void colourByStructure(String pdbid)
2050 Annotation[] anots = ap.av.getStructureSelectionManager()
2051 .colourSequenceFromStructure(sequence, pdbid);
2053 AlignmentAnnotation an = new AlignmentAnnotation("Structure",
2054 "Coloured by " + pdbid, anots);
2056 ap.av.getAlignment().addAnnotation(an);
2057 an.createSequenceMapping(sequence, 0, true);
2058 // an.adjustForAlignment();
2059 ap.av.getAlignment().setAnnotationIndex(an, 0);
2061 ap.adjustAnnotationHeight();
2063 sequence.addAlignmentAnnotation(an);
2067 public void editSequence_actionPerformed(ActionEvent actionEvent)
2069 SequenceGroup sg = ap.av.getSelectionGroup();
2073 if (sequence == null)
2074 sequence = (Sequence) sg.getSequenceAt(0);
2076 EditNameDialog dialog = new EditNameDialog(
2077 sequence.getSequenceAsString(sg.getStartRes(),
2078 sg.getEndRes() + 1), null, MessageManager.getString("label.edit_sequence"), null,
\r
2079 MessageManager.getString("label.edit_sequence"), ap.alignFrame);
\r
2083 EditCommand editCommand = new EditCommand(MessageManager.getString("label.edit_sequences"),
\r
2084 EditCommand.REPLACE, dialog.getName().replace(' ',
2085 ap.av.getGapCharacter()),
2086 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
2087 sg.getStartRes(), sg.getEndRes() + 1, ap.av.getAlignment());
2089 ap.alignFrame.addHistoryItem(editCommand);
2091 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()