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.
23 import java.awt.event.*;
27 import jalview.analysis.*;
28 import jalview.commands.*;
29 import jalview.datamodel.*;
31 import jalview.schemes.*;
32 import jalview.util.GroupUrlLink;
33 import jalview.util.GroupUrlLink.UrlStringTooLongException;
34 import jalview.util.MessageManager;
\r
35 import jalview.util.UrlLink;
41 * @version $Revision: 1.118 $
43 public class PopupMenu extends JPopupMenu
45 JMenu groupMenu = new JMenu();
47 JMenuItem groupName = new JMenuItem();
49 protected JRadioButtonMenuItem clustalColour = new JRadioButtonMenuItem();
51 protected JRadioButtonMenuItem zappoColour = new JRadioButtonMenuItem();
53 protected JRadioButtonMenuItem taylorColour = new JRadioButtonMenuItem();
55 protected JRadioButtonMenuItem hydrophobicityColour = new JRadioButtonMenuItem();
57 protected JRadioButtonMenuItem helixColour = new JRadioButtonMenuItem();
59 protected JRadioButtonMenuItem strandColour = new JRadioButtonMenuItem();
61 protected JRadioButtonMenuItem turnColour = new JRadioButtonMenuItem();
63 protected JRadioButtonMenuItem buriedColour = new JRadioButtonMenuItem();
65 protected JCheckBoxMenuItem abovePIDColour = new JCheckBoxMenuItem();
67 protected JRadioButtonMenuItem userDefinedColour = new JRadioButtonMenuItem();
69 protected JRadioButtonMenuItem PIDColour = new JRadioButtonMenuItem();
71 protected JRadioButtonMenuItem BLOSUM62Colour = new JRadioButtonMenuItem();
73 protected JRadioButtonMenuItem purinePyrimidineColour = new JRadioButtonMenuItem();
75 // protected JRadioButtonMenuItem covariationColour = new
76 // JRadioButtonMenuItem();
78 JRadioButtonMenuItem noColourmenuItem = new JRadioButtonMenuItem();
80 protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem();
84 JMenu sequenceMenu = new JMenu();
86 JMenuItem sequenceName = new JMenuItem();
88 JMenuItem sequenceDetails = new JMenuItem();
90 JMenuItem sequenceSelDetails = new JMenuItem();
92 JMenuItem makeReferenceSeq = new JMenuItem();
95 JMenuItem createGroupMenuItem = new JMenuItem();
96 JMenuItem unGroupMenuItem = new JMenuItem();
98 JMenuItem outline = new JMenuItem();
100 JRadioButtonMenuItem nucleotideMenuItem = new JRadioButtonMenuItem();
102 JMenu colourMenu = new JMenu();
104 JCheckBoxMenuItem showBoxes = new JCheckBoxMenuItem();
106 JCheckBoxMenuItem showText = new JCheckBoxMenuItem();
108 JCheckBoxMenuItem showColourText = new JCheckBoxMenuItem();
110 JCheckBoxMenuItem displayNonconserved = new JCheckBoxMenuItem();
112 JMenu editMenu = new JMenu();
114 JMenuItem cut = new JMenuItem();
116 JMenuItem copy = new JMenuItem();
118 JMenuItem upperCase = new JMenuItem();
120 JMenuItem lowerCase = new JMenuItem();
122 JMenuItem toggle = new JMenuItem();
124 JMenu pdbMenu = new JMenu();
126 JMenuItem pdbFromFile = new JMenuItem();
128 JMenuItem enterPDB = new JMenuItem();
130 JMenuItem discoverPDB = new JMenuItem();
132 JMenu outputMenu = new JMenu();
134 JMenuItem sequenceFeature = new JMenuItem();
136 JMenuItem textColour = new JMenuItem();
138 JMenu jMenu1 = new JMenu();
140 JMenu structureMenu = new JMenu();
142 JMenu viewStructureMenu = new JMenu();
144 // JMenu colStructureMenu = new JMenu();
145 JMenuItem editSequence = new JMenuItem();
147 // JMenuItem annotationMenuItem = new JMenuItem();
149 JMenu groupLinksMenu;
152 * Creates a new PopupMenu object.
159 public PopupMenu(final AlignmentPanel ap, Sequence seq, Vector links)
161 this(ap, seq, links, null);
171 public PopupMenu(final AlignmentPanel ap, final SequenceI seq,
172 Vector links, Vector groupLinks)
174 // /////////////////////////////////////////////////////////
175 // If this is activated from the sequence panel, the user may want to
176 // edit or annotate a particular residue. Therefore display the residue menu
178 // If from the IDPanel, we must display the sequence menu
179 // ////////////////////////////////////////////////////////
183 ButtonGroup colours = new ButtonGroup();
184 colours.add(noColourmenuItem);
185 colours.add(clustalColour);
186 colours.add(zappoColour);
187 colours.add(taylorColour);
188 colours.add(hydrophobicityColour);
189 colours.add(helixColour);
190 colours.add(strandColour);
191 colours.add(turnColour);
192 colours.add(buriedColour);
193 colours.add(abovePIDColour);
194 colours.add(userDefinedColour);
195 colours.add(PIDColour);
196 colours.add(BLOSUM62Colour);
197 colours.add(purinePyrimidineColour);
198 // colours.add(covariationColour);
200 for (int i = 0; i < jalview.io.FormatAdapter.WRITEABLE_FORMATS.length; i++)
202 JMenuItem item = new JMenuItem(
203 jalview.io.FormatAdapter.WRITEABLE_FORMATS[i]);
205 item.addActionListener(new java.awt.event.ActionListener()
207 public void actionPerformed(ActionEvent e)
209 outputText_actionPerformed(e);
213 outputMenu.add(item);
219 } catch (Exception e)
227 sequenceMenu.setText(sequence.getName());
228 if (seq == ap.av.getAlignment().getSeqrep())
230 makeReferenceSeq.setText("Unmark representative");
232 makeReferenceSeq.setText("Mark as representative");
235 if (seq.getDatasetSequence().getPDBId() != null
236 && seq.getDatasetSequence().getPDBId().size() > 0)
238 java.util.Enumeration e = seq.getDatasetSequence().getPDBId()
241 while (e.hasMoreElements())
243 final PDBEntry pdb = (PDBEntry) e.nextElement();
245 menuItem = new JMenuItem();
246 menuItem.setText(pdb.getId());
247 menuItem.addActionListener(new java.awt.event.ActionListener()
249 public void actionPerformed(ActionEvent e)
251 // TODO re JAL-860: optionally open dialog or provide a menu entry
252 // allowing user to open just one structure per sequence
253 new AppJmol(pdb, ap.av.collateForPDB(new PDBEntry[]
254 { pdb })[0], null, ap);
255 // new PDBViewer(pdb, seqs2, null, ap, AppletFormatAdapter.FILE);
259 viewStructureMenu.add(menuItem);
262 * menuItem = new JMenuItem(); menuItem.setText(pdb.getId());
263 * menuItem.addActionListener(new java.awt.event.ActionListener() {
264 * public void actionPerformed(ActionEvent e) {
265 * colourByStructure(pdb.getId()); } });
266 * colStructureMenu.add(menuItem);
272 if (ap.av.getAlignment().isNucleotide() == false)
274 structureMenu.remove(viewStructureMenu);
276 // structureMenu.remove(colStructureMenu);
278 if (ap.av.getAlignment().isNucleotide() == true)
280 AlignmentAnnotation[] aa = ap.av.getAlignment()
281 .getAlignmentAnnotation();
282 for (int i = 0; i < aa.length; i++)
284 if (aa[i].getRNAStruc() != null)
286 final String rnastruc = aa[i].getRNAStruc();
287 final String structureLine = aa[i].label;
288 menuItem = new JMenuItem();
289 menuItem.setText(MessageManager.formatMessage("label.2d_rna_structure_line", new String[]{structureLine}));
\r
290 menuItem.addActionListener(new java.awt.event.ActionListener()
292 public void actionPerformed(ActionEvent e)
294 new AppVarna(structureLine, seq, seq.getSequenceAsString(),
295 rnastruc, seq.getName(), ap);
298 viewStructureMenu.add(menuItem);
302 // SequenceFeatures[] test = seq.getSequenceFeatures();
304 if (seq.getAnnotation() != null)
306 AlignmentAnnotation seqAnno[] = seq.getAnnotation();
307 for (int i = 0; i < seqAnno.length; i++)
309 if (seqAnno[i].getRNAStruc() != null)
311 final String rnastruc = seqAnno[i].getRNAStruc();
313 // TODO: make rnastrucF a bit more nice
314 menuItem = new JMenuItem();
315 menuItem.setText(MessageManager.formatMessage("label.2d_rna_sequence_name", new String[]{seq.getName()}));
\r
316 menuItem.addActionListener(new java.awt.event.ActionListener()
318 public void actionPerformed(ActionEvent e)
320 // TODO: VARNA does'nt print gaps in the sequence
321 new AppVarna(seq.getName() + " structure", seq, seq
322 .getSequenceAsString(), rnastruc, seq.getName(),
326 viewStructureMenu.add(menuItem);
332 menuItem = new JMenuItem(MessageManager.getString("action.hide_sequences"));
\r
333 menuItem.addActionListener(new java.awt.event.ActionListener()
335 public void actionPerformed(ActionEvent e)
337 hideSequences(false);
342 if (ap.av.getSelectionGroup() != null
343 && ap.av.getSelectionGroup().getSize() > 1)
345 menuItem = new JMenuItem(MessageManager.formatMessage("label.represent_group_with", new String[]{seq.getName()}));
\r
346 menuItem.addActionListener(new java.awt.event.ActionListener()
348 public void actionPerformed(ActionEvent e)
353 sequenceMenu.add(menuItem);
356 if (ap.av.hasHiddenRows())
358 final int index = ap.av.getAlignment().findIndex(seq);
360 if (ap.av.adjustForHiddenSeqs(index)
361 - ap.av.adjustForHiddenSeqs(index - 1) > 1)
363 menuItem = new JMenuItem(MessageManager.getString("action.reveal_sequences"));
\r
364 menuItem.addActionListener(new ActionListener()
366 public void actionPerformed(ActionEvent e)
368 ap.av.showSequence(index);
369 if (ap.overviewPanel != null)
371 ap.overviewPanel.updateOverviewImage();
379 // for the case when no sequences are even visible
380 if (ap.av.hasHiddenRows())
383 menuItem = new JMenuItem(MessageManager.getString("action.reveal_all"));
\r
384 menuItem.addActionListener(new ActionListener()
386 public void actionPerformed(ActionEvent e)
388 ap.av.showAllHiddenSeqs();
389 if (ap.overviewPanel != null)
391 ap.overviewPanel.updateOverviewImage();
401 SequenceGroup sg = ap.av.getSelectionGroup();
402 boolean isDefinedGroup = (sg!=null) ? ap.av.getAlignment().getGroups().contains(sg) : false;
404 if (sg != null && sg.getSize() > 0)
406 groupName.setText(MessageManager.formatMessage("label.name_param", new String[]{sg.getName()}));
\r
407 groupName.setText(MessageManager.getString("label.edit_name_and_description_current_group"));
\r
409 if (sg.cs instanceof ZappoColourScheme)
411 zappoColour.setSelected(true);
413 else if (sg.cs instanceof TaylorColourScheme)
415 taylorColour.setSelected(true);
417 else if (sg.cs instanceof PIDColourScheme)
419 PIDColour.setSelected(true);
421 else if (sg.cs instanceof Blosum62ColourScheme)
423 BLOSUM62Colour.setSelected(true);
425 else if (sg.cs instanceof UserColourScheme)
427 userDefinedColour.setSelected(true);
429 else if (sg.cs instanceof HydrophobicColourScheme)
431 hydrophobicityColour.setSelected(true);
433 else if (sg.cs instanceof HelixColourScheme)
435 helixColour.setSelected(true);
437 else if (sg.cs instanceof StrandColourScheme)
439 strandColour.setSelected(true);
441 else if (sg.cs instanceof TurnColourScheme)
443 turnColour.setSelected(true);
445 else if (sg.cs instanceof BuriedColourScheme)
447 buriedColour.setSelected(true);
449 else if (sg.cs instanceof ClustalxColourScheme)
451 clustalColour.setSelected(true);
453 else if (sg.cs instanceof PurinePyrimidineColourScheme)
455 purinePyrimidineColour.setSelected(true);
458 * else if (sg.cs instanceof CovariationColourScheme) {
459 * covariationColour.setSelected(true); }
463 noColourmenuItem.setSelected(true);
466 if (sg.cs != null && sg.cs.conservationApplied())
468 conservationMenuItem.setSelected(true);
470 displayNonconserved.setSelected(sg.getShowNonconserved());
471 showText.setSelected(sg.getDisplayText());
472 showColourText.setSelected(sg.getColourText());
473 showBoxes.setSelected(sg.getDisplayBoxes());
474 // add any groupURLs to the groupURL submenu and make it visible
475 if (groupLinks != null && groupLinks.size() > 0)
477 buildGroupURLMenu(sg, groupLinks);
479 // Add a 'show all structures' for the current selection
480 Hashtable<String, PDBEntry> pdbe = new Hashtable<String, PDBEntry>(),reppdb=new Hashtable<String,PDBEntry>();
481 SequenceI sqass = null;
482 for (SequenceI sq : ap.av.getSequenceSelection())
484 Vector<PDBEntry> pes = (Vector<PDBEntry>) sq.getDatasetSequence()
488 reppdb.put(pes.get(0).getId(),pes.get(0));
489 for (PDBEntry pe : pes)
491 pdbe.put(pe.getId(), pe);
501 final PDBEntry[] pe = pdbe.values().toArray(
502 new PDBEntry[pdbe.size()]),pr = reppdb.values().toArray(
503 new PDBEntry[reppdb.size()]);
504 final JMenuItem gpdbview,rpdbview;
505 if (pdbe.size() == 1)
507 structureMenu.add(gpdbview = new JMenuItem(MessageManager.formatMessage("label.view_structure_for", new String[]{sqass.getDisplayId(false)})));
\r
511 structureMenu.add(gpdbview = new JMenuItem(MessageManager.formatMessage("label.view_all_structures", new String[]{new Integer(pdbe.size()).toString()})));
\r
513 gpdbview.setToolTipText(MessageManager.getString("label.open_new_jmol_view_with_all_structures_associated_current_selection_superimpose_using_alignment"));
\r
514 gpdbview.addActionListener(new ActionListener()
518 public void actionPerformed(ActionEvent e)
520 new AppJmol(ap, pe, ap.av.collateForPDB(pe));
523 if (reppdb.size()>1 && reppdb.size()<pdbe.size())
525 structureMenu.add(rpdbview = new JMenuItem(MessageManager.formatMessage("label.view_all_representative_structures", new String[]{new Integer(reppdb.size()).toString()})));
526 rpdbview.setToolTipText(MessageManager.getString("label.open_new_jmol_view_with_all_representative_structures_associated_current_selection_superimpose_using_alignment"));
527 rpdbview.addActionListener(new ActionListener()
531 public void actionPerformed(ActionEvent e)
533 new AppJmol(ap, pr, ap.av.collateForPDB(pr));
541 groupMenu.setVisible(false);
542 editMenu.setVisible(false);
547 createGroupMenuItem.setVisible(true);
548 unGroupMenuItem.setVisible(false);
549 jMenu1.setText(MessageManager.getString("action.edit_new_group"));
\r
551 createGroupMenuItem.setVisible(false);
552 unGroupMenuItem.setVisible(true);
553 jMenu1.setText(MessageManager.getString("action.edit_group"));
\r
558 sequenceMenu.setVisible(false);
559 structureMenu.setVisible(false);
562 if (links != null && links.size() > 0)
565 JMenu linkMenu = new JMenu(MessageManager.getString("action.link"));
\r
566 Vector linkset = new Vector();
567 for (int i = 0; i < links.size(); i++)
569 String link = links.elementAt(i).toString();
570 UrlLink urlLink = null;
573 urlLink = new UrlLink(link);
574 } catch (Exception foo)
576 jalview.bin.Cache.log.error("Exception for URLLink '" + link
581 if (!urlLink.isValid())
583 jalview.bin.Cache.log.error(urlLink.getInvalidMessage());
586 final String label = urlLink.getLabel();
587 if (seq != null && urlLink.isDynamic())
590 // collect matching db-refs
591 DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(
592 seq.getDBRef(), new String[]
593 { urlLink.getTarget() });
594 // collect id string too
595 String id = seq.getName();
596 String descr = seq.getDescription();
597 if (descr != null && descr.length() < 1)
604 for (int r = 0; r < dbr.length; r++)
606 if (id != null && dbr[r].getAccessionId().equals(id))
608 // suppress duplicate link creation for the bare sequence ID
609 // string with this link
612 // create Bare ID link for this RUL
613 String[] urls = urlLink.makeUrls(dbr[r].getAccessionId(),
617 for (int u = 0; u < urls.length; u += 2)
619 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
621 linkset.addElement(urls[u] + "|" + urls[u + 1]);
622 addshowLink(linkMenu, label + "|" + urls[u],
631 // create Bare ID link for this RUL
632 String[] urls = urlLink.makeUrls(id, true);
635 for (int u = 0; u < urls.length; u += 2)
637 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
639 linkset.addElement(urls[u] + "|" + urls[u + 1]);
640 addshowLink(linkMenu, label, urls[u + 1]);
645 // Create urls from description but only for URL links which are regex
647 if (descr != null && urlLink.getRegexReplace() != null)
649 // create link for this URL from description where regex matches
650 String[] urls = urlLink.makeUrls(descr, true);
653 for (int u = 0; u < urls.length; u += 2)
655 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
657 linkset.addElement(urls[u] + "|" + urls[u + 1]);
658 addshowLink(linkMenu, label, urls[u + 1]);
666 if (!linkset.contains(label + "|" + urlLink.getUrl_prefix()))
668 linkset.addElement(label + "|" + urlLink.getUrl_prefix());
669 // Add a non-dynamic link
670 addshowLink(linkMenu, label, urlLink.getUrl_prefix());
674 if (sequence != null)
676 sequenceMenu.add(linkMenu);
685 private void buildGroupURLMenu(SequenceGroup sg, Vector groupLinks)
688 // TODO: usability: thread off the generation of group url content so root
690 // sequence only URLs
691 // ID/regex match URLs
692 groupLinksMenu = new JMenu(MessageManager.getString("action.group_link"));
\r
693 JMenu[] linkMenus = new JMenu[]
694 { null, new JMenu(MessageManager.getString("action.ids")), new JMenu(MessageManager.getString("action.sequences")),
\r
695 new JMenu(MessageManager.getString("action.ids_sequences")) }; // three types of url that might be
\r
697 SequenceI[] seqs = ap.av.getSelectionAsNewSequence();
698 String[][] idandseqs = GroupUrlLink.formStrings(seqs);
699 Hashtable commonDbrefs = new Hashtable();
700 for (int sq = 0; sq < seqs.length; sq++)
703 int start = seqs[sq].findPosition(sg.getStartRes()), end = seqs[sq]
704 .findPosition(sg.getEndRes());
705 // just collect ids from dataset sequence
706 // TODO: check if IDs collected from selecton group intersects with the
707 // current selection, too
708 SequenceI sqi = seqs[sq];
709 while (sqi.getDatasetSequence() != null)
711 sqi = sqi.getDatasetSequence();
713 DBRefEntry[] dbr = sqi.getDBRef();
714 if (dbr != null && dbr.length > 0)
716 for (int d = 0; d < dbr.length; d++)
718 String src = dbr[d].getSource(); // jalview.util.DBRefUtils.getCanonicalName(dbr[d].getSource()).toUpperCase();
719 Object[] sarray = (Object[]) commonDbrefs.get(src);
722 sarray = new Object[2];
723 sarray[0] = new int[]
725 sarray[1] = new String[seqs.length];
727 commonDbrefs.put(src, sarray);
730 if (((String[]) sarray[1])[sq] == null)
733 || (dbr[d].getMap().locateMappedRange(start, end) != null))
735 ((String[]) sarray[1])[sq] = dbr[d].getAccessionId();
736 ((int[]) sarray[0])[0]++;
742 // now create group links for all distinct ID/sequence sets.
743 boolean addMenu = false; // indicates if there are any group links to give
745 for (int i = 0; i < groupLinks.size(); i++)
747 String link = groupLinks.elementAt(i).toString();
748 GroupUrlLink urlLink = null;
751 urlLink = new GroupUrlLink(link);
752 } catch (Exception foo)
754 jalview.bin.Cache.log.error("Exception for GroupURLLink '" + link
759 if (!urlLink.isValid())
761 jalview.bin.Cache.log.error(urlLink.getInvalidMessage());
764 final String label = urlLink.getLabel();
765 boolean usingNames = false;
766 // Now see which parts of the group apply for this URL
767 String ltarget = urlLink.getTarget(); // jalview.util.DBRefUtils.getCanonicalName(urlLink.getTarget());
768 Object[] idset = (Object[]) commonDbrefs.get(ltarget.toUpperCase());
769 String[] seqstr, ids; // input to makeUrl
772 int numinput = ((int[]) idset[0])[0];
773 String[] allids = ((String[]) idset[1]);
774 seqstr = new String[numinput];
775 ids = new String[numinput];
776 for (int sq = 0, idcount = 0; sq < seqs.length; sq++)
778 if (allids[sq] != null)
780 ids[idcount] = allids[sq];
781 seqstr[idcount++] = idandseqs[1][sq];
787 // just use the id/seq set
788 seqstr = idandseqs[1];
792 // and try and make the groupURL!
794 Object[] urlset = null;
797 urlset = urlLink.makeUrlStubs(ids, seqstr,
798 "FromJalview" + System.currentTimeMillis(), false);
799 } catch (UrlStringTooLongException e)
804 int type = urlLink.getGroupURLType() & 3;
805 // System.out.println(urlLink.getGroupURLType()
806 // +" "+((String[])urlset[3])[0]);
807 // first two bits ofurlLink type bitfield are sequenceids and sequences
808 // TODO: FUTURE: ensure the groupURL menu structure can be generalised
809 addshowLink(linkMenus[type], label
810 + (((type & 1) == 1) ? ("("
811 + (usingNames ? "Names" : ltarget) + ")") : ""),
818 groupLinksMenu = new JMenu(MessageManager.getString("action.group_link"));
\r
819 for (int m = 0; m < linkMenus.length; m++)
821 if (linkMenus[m] != null
822 && linkMenus[m].getMenuComponentCount() > 0)
824 groupLinksMenu.add(linkMenus[m]);
828 groupMenu.add(groupLinksMenu);
833 * add a show URL menu item to the given linkMenu
837 * - menu label string
841 private void addshowLink(JMenu linkMenu, String label, final String url)
843 JMenuItem item = new JMenuItem(label);
844 item.setToolTipText(MessageManager.formatMessage("label.open_url_param", new String[]{url}));
\r
845 item.addActionListener(new java.awt.event.ActionListener()
847 public void actionPerformed(ActionEvent e)
849 new Thread(new Runnable()
865 * add a late bound groupURL item to the given linkMenu
869 * - menu label string
870 * @param urlgenerator
871 * GroupURLLink used to generate URL
873 * Object array returned from the makeUrlStubs function.
875 private void addshowLink(JMenu linkMenu, String label,
876 final GroupUrlLink urlgenerator, final Object[] urlstub)
878 JMenuItem item = new JMenuItem(label);
879 item.setToolTipText(MessageManager.formatMessage("label.open_url_seqs_param", new Object[]{urlgenerator.getUrl_prefix(),urlgenerator.getNumberInvolved(urlstub)}));
\r
880 // TODO: put in info about what is being sent.
\r
881 item.addActionListener(new java.awt.event.ActionListener()
883 public void actionPerformed(ActionEvent e)
885 new Thread(new Runnable()
892 showLink(urlgenerator.constructFrom(urlstub));
893 } catch (UrlStringTooLongException e)
911 private void jbInit() throws Exception
913 groupMenu.setText(MessageManager.getString("label.group"));
\r
914 groupMenu.setText(MessageManager.getString("label.selection"));
\r
915 groupName.setText(MessageManager.getString("label.name"));
\r
916 groupName.addActionListener(new java.awt.event.ActionListener()
918 public void actionPerformed(ActionEvent e)
920 groupName_actionPerformed();
923 sequenceMenu.setText(MessageManager.getString("label.sequence"));
\r
924 sequenceName.setText(MessageManager.getString("label.edit_name_description"));
\r
925 sequenceName.addActionListener(new java.awt.event.ActionListener()
927 public void actionPerformed(ActionEvent e)
929 sequenceName_actionPerformed();
932 sequenceDetails.setText(MessageManager.getString("label.sequence_details") + "...");
\r
933 sequenceDetails.addActionListener(new java.awt.event.ActionListener()
935 public void actionPerformed(ActionEvent e)
937 sequenceDetails_actionPerformed();
940 sequenceSelDetails.setText(MessageManager.getString("label.sequence_details") + "...");
\r
942 .addActionListener(new java.awt.event.ActionListener()
944 public void actionPerformed(ActionEvent e)
946 sequenceSelectionDetails_actionPerformed();
949 PIDColour.setFocusPainted(false);
950 unGroupMenuItem.setText(MessageManager.getString("action.remove_group"));
\r
951 unGroupMenuItem.addActionListener(new java.awt.event.ActionListener()
953 public void actionPerformed(ActionEvent e)
955 unGroupMenuItem_actionPerformed();
958 createGroupMenuItem.setText(MessageManager.getString("action.create_group"));
\r
959 createGroupMenuItem.addActionListener(new java.awt.event.ActionListener()
961 public void actionPerformed(ActionEvent e)
963 createGroupMenuItem_actionPerformed();
967 outline.setText(MessageManager.getString("action.border_colour"));
\r
968 outline.addActionListener(new java.awt.event.ActionListener()
970 public void actionPerformed(ActionEvent e)
972 outline_actionPerformed();
975 nucleotideMenuItem.setText(MessageManager.getString("label.nucleotide"));
\r
976 nucleotideMenuItem.addActionListener(new ActionListener()
978 public void actionPerformed(ActionEvent e)
980 nucleotideMenuItem_actionPerformed();
983 colourMenu.setText(MessageManager.getString("label.group_colour"));
\r
984 showBoxes.setText(MessageManager.getString("action.boxes"));
\r
985 showBoxes.setState(true);
986 showBoxes.addActionListener(new ActionListener()
988 public void actionPerformed(ActionEvent e)
990 showBoxes_actionPerformed();
993 showText.setText(MessageManager.getString("action.text"));
\r
994 showText.setState(true);
995 showText.addActionListener(new ActionListener()
997 public void actionPerformed(ActionEvent e)
999 showText_actionPerformed();
1002 showColourText.setText(MessageManager.getString("label.colour_text"));
\r
1003 showColourText.addActionListener(new ActionListener()
1005 public void actionPerformed(ActionEvent e)
1007 showColourText_actionPerformed();
1010 displayNonconserved.setText(MessageManager.getString("label.show_non_conversed"));
\r
1011 displayNonconserved.setState(true);
1012 displayNonconserved.addActionListener(new ActionListener()
1014 public void actionPerformed(ActionEvent e)
1016 showNonconserved_actionPerformed();
1019 editMenu.setText(MessageManager.getString("action.edit"));
\r
1020 cut.setText(MessageManager.getString("action.cut"));
\r
1021 cut.addActionListener(new ActionListener()
1023 public void actionPerformed(ActionEvent e)
1025 cut_actionPerformed();
1028 upperCase.setText(MessageManager.getString("label.to_upper_case"));
\r
1029 upperCase.addActionListener(new ActionListener()
1031 public void actionPerformed(ActionEvent e)
1036 copy.setText(MessageManager.getString("action.copy"));
\r
1037 copy.addActionListener(new ActionListener()
1039 public void actionPerformed(ActionEvent e)
1041 copy_actionPerformed();
1044 lowerCase.setText(MessageManager.getString("label.to_lower_case"));
\r
1045 lowerCase.addActionListener(new ActionListener()
1047 public void actionPerformed(ActionEvent e)
1052 toggle.setText(MessageManager.getString("label.toggle_case"));
\r
1053 toggle.addActionListener(new ActionListener()
1055 public void actionPerformed(ActionEvent e)
1060 pdbMenu.setText(MessageManager.getString("label.associate_structure_with_sequence"));
\r
1061 pdbFromFile.setText(MessageManager.getString("label.from_file"));
\r
1062 pdbFromFile.addActionListener(new ActionListener()
1064 public void actionPerformed(ActionEvent e)
1066 pdbFromFile_actionPerformed();
1069 enterPDB.setText(MessageManager.getString("label.enter_pdb_id"));
\r
1070 enterPDB.addActionListener(new ActionListener()
1072 public void actionPerformed(ActionEvent e)
1074 enterPDB_actionPerformed();
1077 discoverPDB.setText(MessageManager.getString("label.discover_pdb_ids"));
\r
1078 discoverPDB.addActionListener(new ActionListener()
1080 public void actionPerformed(ActionEvent e)
1082 discoverPDB_actionPerformed();
1085 outputMenu.setText(MessageManager.getString("label.out_to_textbox") + "...");
\r
1086 sequenceFeature.setText(MessageManager.getString("label.create_sequence_feature"));
\r
1087 sequenceFeature.addActionListener(new ActionListener()
1089 public void actionPerformed(ActionEvent e)
1091 sequenceFeature_actionPerformed();
1094 textColour.setText(MessageManager.getString("label.text_colour"));
\r
1095 textColour.addActionListener(new ActionListener()
1097 public void actionPerformed(ActionEvent e)
1099 textColour_actionPerformed();
1102 jMenu1.setText(MessageManager.getString("label.group"));
\r
1103 structureMenu.setText(MessageManager.getString("label.structure"));
\r
1104 viewStructureMenu.setText(MessageManager.getString("label.view_structure"));
\r
1105 // colStructureMenu.setText("Colour By Structure");
1106 editSequence.setText(MessageManager.getString("label.edit_sequence") + "...");
\r
1107 editSequence.addActionListener(new ActionListener()
1109 public void actionPerformed(ActionEvent actionEvent)
1111 editSequence_actionPerformed(actionEvent);
1114 makeReferenceSeq.setText("Mark as representative");
1115 makeReferenceSeq.addActionListener(new ActionListener()
1119 public void actionPerformed(ActionEvent actionEvent)
1121 makeReferenceSeq_actionPerformed(actionEvent);
1126 * annotationMenuItem.setText("By Annotation");
1127 * annotationMenuItem.addActionListener(new ActionListener() { public void
1128 * actionPerformed(ActionEvent actionEvent) {
1129 * annotationMenuItem_actionPerformed(actionEvent); } });
1131 groupMenu.add(sequenceSelDetails);
1134 this.add(structureMenu);
1135 groupMenu.add(editMenu);
1136 groupMenu.add(outputMenu);
1137 groupMenu.add(sequenceFeature);
1138 groupMenu.add(createGroupMenuItem);
1139 groupMenu.add(unGroupMenuItem);
1140 groupMenu.add(jMenu1);
1141 sequenceMenu.add(sequenceName);
1142 sequenceMenu.add(sequenceDetails);
1143 sequenceMenu.add(makeReferenceSeq);
1144 colourMenu.add(textColour);
1145 colourMenu.add(noColourmenuItem);
1146 colourMenu.add(clustalColour);
1147 colourMenu.add(BLOSUM62Colour);
1148 colourMenu.add(PIDColour);
1149 colourMenu.add(zappoColour);
1150 colourMenu.add(taylorColour);
1151 colourMenu.add(hydrophobicityColour);
1152 colourMenu.add(helixColour);
1153 colourMenu.add(strandColour);
1154 colourMenu.add(turnColour);
1155 colourMenu.add(buriedColour);
1156 colourMenu.add(nucleotideMenuItem);
1157 if (ap.getAlignment().isNucleotide())
1159 colourMenu.add(purinePyrimidineColour);
1161 // colourMenu.add(covariationColour);
1162 colourMenu.add(userDefinedColour);
1164 if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null)
1166 java.util.Enumeration userColours = jalview.gui.UserDefinedColours
1167 .getUserColourSchemes().keys();
1169 while (userColours.hasMoreElements())
1171 JMenuItem item = new JMenuItem(userColours.nextElement().toString());
1172 item.addActionListener(new ActionListener()
1174 public void actionPerformed(ActionEvent evt)
1176 userDefinedColour_actionPerformed(evt);
1179 colourMenu.add(item);
1183 colourMenu.addSeparator();
1184 colourMenu.add(abovePIDColour);
1185 colourMenu.add(conservationMenuItem);
1186 // colourMenu.add(annotationMenuItem);
1189 editMenu.add(editSequence);
1190 editMenu.add(upperCase);
1191 editMenu.add(lowerCase);
1192 editMenu.add(toggle);
1193 pdbMenu.add(pdbFromFile);
1194 pdbMenu.add(enterPDB);
1195 pdbMenu.add(discoverPDB);
1196 jMenu1.add(groupName);
1197 jMenu1.add(colourMenu);
1198 jMenu1.add(showBoxes);
1199 jMenu1.add(showText);
1200 jMenu1.add(showColourText);
1201 jMenu1.add(outline);
1202 jMenu1.add(displayNonconserved);
1203 structureMenu.add(pdbMenu);
1204 structureMenu.add(viewStructureMenu);
1205 // structureMenu.add(colStructureMenu);
1206 noColourmenuItem.setText(MessageManager.getString("label.none"));
\r
1207 noColourmenuItem.addActionListener(new java.awt.event.ActionListener()
1209 public void actionPerformed(ActionEvent e)
1211 noColourmenuItem_actionPerformed();
1215 clustalColour.setText(MessageManager.getString("label.clustalx_colours"));
\r
1216 clustalColour.addActionListener(new java.awt.event.ActionListener()
1218 public void actionPerformed(ActionEvent e)
1220 clustalColour_actionPerformed();
1223 zappoColour.setText(MessageManager.getString("label.zappo"));
\r
1224 zappoColour.addActionListener(new java.awt.event.ActionListener()
1226 public void actionPerformed(ActionEvent e)
1228 zappoColour_actionPerformed();
1231 taylorColour.setText(MessageManager.getString("label.taylor"));
\r
1232 taylorColour.addActionListener(new java.awt.event.ActionListener()
1234 public void actionPerformed(ActionEvent e)
1236 taylorColour_actionPerformed();
1239 hydrophobicityColour.setText(MessageManager.getString("label.hydrophobicity"));
\r
1240 hydrophobicityColour
1241 .addActionListener(new java.awt.event.ActionListener()
1243 public void actionPerformed(ActionEvent e)
1245 hydrophobicityColour_actionPerformed();
1248 helixColour.setText(MessageManager.getString("label.helix_propensity"));
\r
1249 helixColour.addActionListener(new java.awt.event.ActionListener()
1251 public void actionPerformed(ActionEvent e)
1253 helixColour_actionPerformed();
1256 strandColour.setText(MessageManager.getString("label.strand_propensity"));
\r
1257 strandColour.addActionListener(new java.awt.event.ActionListener()
1259 public void actionPerformed(ActionEvent e)
1261 strandColour_actionPerformed();
1264 turnColour.setText(MessageManager.getString("label.turn_propensity"));
\r
1265 turnColour.addActionListener(new java.awt.event.ActionListener()
1267 public void actionPerformed(ActionEvent e)
1269 turnColour_actionPerformed();
1272 buriedColour.setText(MessageManager.getString("label.buried_index"));
\r
1273 buriedColour.addActionListener(new java.awt.event.ActionListener()
1275 public void actionPerformed(ActionEvent e)
1277 buriedColour_actionPerformed();
1280 abovePIDColour.setText(MessageManager.getString("label.above_identity_percentage"));
\r
1281 abovePIDColour.addActionListener(new java.awt.event.ActionListener()
1283 public void actionPerformed(ActionEvent e)
1285 abovePIDColour_actionPerformed();
1288 userDefinedColour.setText(MessageManager.getString("action.user_defined"));
\r
1289 userDefinedColour.addActionListener(new java.awt.event.ActionListener()
1291 public void actionPerformed(ActionEvent e)
1293 userDefinedColour_actionPerformed(e);
1296 PIDColour.setText(MessageManager.getString("label.percentage_identity"));
\r
1297 PIDColour.addActionListener(new java.awt.event.ActionListener()
1299 public void actionPerformed(ActionEvent e)
1301 PIDColour_actionPerformed();
1304 BLOSUM62Colour.setText(MessageManager.getString("label.blosum62"));
\r
1305 BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener()
1307 public void actionPerformed(ActionEvent e)
1309 BLOSUM62Colour_actionPerformed();
1312 purinePyrimidineColour.setText(MessageManager.getString("label.purine_pyrimidine"));
\r
1313 purinePyrimidineColour
1314 .addActionListener(new java.awt.event.ActionListener()
1316 public void actionPerformed(ActionEvent e)
1318 purinePyrimidineColour_actionPerformed();
1322 * covariationColour.addActionListener(new java.awt.event.ActionListener() {
1323 * public void actionPerformed(ActionEvent e) {
1324 * covariationColour_actionPerformed(); } });
1327 conservationMenuItem.setText(MessageManager.getString("label.conservation"));
\r
1328 conservationMenuItem
1329 .addActionListener(new java.awt.event.ActionListener()
1331 public void actionPerformed(ActionEvent e)
1333 conservationMenuItem_actionPerformed();
1338 protected void makeReferenceSeq_actionPerformed(ActionEvent actionEvent)
1340 if (!ap.av.getAlignment().hasSeqrep())
1342 // initialise the display flags so the user sees something happen
1343 ap.av.setDisplayReferenceSeq(true);
1344 ap.av.setColourByReferenceSeq(true);
1345 ap.av.getAlignment().setSeqrep(sequence);
1349 if (ap.av.getAlignment().getSeqrep() == sequence)
1351 ap.av.getAlignment().setSeqrep(null);
1355 ap.av.getAlignment().setSeqrep(sequence);
1361 protected void sequenceSelectionDetails_actionPerformed()
1363 createSequenceDetailsReport(ap.av.getSequenceSelection());
1366 protected void sequenceDetails_actionPerformed()
1368 createSequenceDetailsReport(new SequenceI[]
1372 public void createSequenceDetailsReport(SequenceI[] sequences)
1374 CutAndPasteHtmlTransfer cap = new CutAndPasteHtmlTransfer();
1375 StringBuffer contents = new StringBuffer();
1376 for (SequenceI seq : sequences)
1378 contents.append("<p><h2>" + MessageManager.formatMessage("label.create_sequence_details_report_annotation_for", new String[]{seq.getDisplayId(true)})
\r
1380 new SequenceAnnotationReport(null)
1381 .createSequenceAnnotationReport(
1387 (ap.seqPanel.seqCanvas.fr != null) ? ap.seqPanel.seqCanvas.fr.minmax
1389 contents.append("</p>");
1391 cap.setText("<html>" + contents.toString() + "</html>");
1393 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
1398 protected void showNonconserved_actionPerformed()
1400 getGroup().setShowNonconserved(displayNonconserved.isSelected());
1405 * call to refresh view after settings change
1409 ap.updateAnnotation();
1410 ap.paintAlignment(true);
1412 PaintRefresher.Refresh(this, ap.av.getSequenceSetId());
1421 protected void clustalColour_actionPerformed()
1423 SequenceGroup sg = getGroup();
1424 sg.cs = new ClustalxColourScheme(sg, ap.av.getHiddenRepSequences());
1434 protected void zappoColour_actionPerformed()
1436 getGroup().cs = new ZappoColourScheme();
1446 protected void taylorColour_actionPerformed()
1448 getGroup().cs = new TaylorColourScheme();
1458 protected void hydrophobicityColour_actionPerformed()
1460 getGroup().cs = new HydrophobicColourScheme();
1470 protected void helixColour_actionPerformed()
1472 getGroup().cs = new HelixColourScheme();
1482 protected void strandColour_actionPerformed()
1484 getGroup().cs = new StrandColourScheme();
1494 protected void turnColour_actionPerformed()
1496 getGroup().cs = new TurnColourScheme();
1506 protected void buriedColour_actionPerformed()
1508 getGroup().cs = new BuriedColourScheme();
1518 public void nucleotideMenuItem_actionPerformed()
1520 getGroup().cs = new NucleotideColourScheme();
1524 protected void purinePyrimidineColour_actionPerformed()
1526 getGroup().cs = new PurinePyrimidineColourScheme();
1531 * protected void covariationColour_actionPerformed() { getGroup().cs = new
1532 * CovariationColourScheme(sequence.getAnnotation()[0]); refresh(); }
1540 protected void abovePIDColour_actionPerformed()
1542 SequenceGroup sg = getGroup();
1548 if (abovePIDColour.isSelected())
1550 sg.cs.setConsensus(AAFrequency.calculate(
1551 sg.getSequences(ap.av.getHiddenRepSequences()),
1552 sg.getStartRes(), sg.getEndRes() + 1));
1554 int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
1557 sg.cs.setThreshold(threshold, ap.av.getIgnoreGapsConsensus());
1559 SliderPanel.showPIDSlider();
1562 // remove PIDColouring
1564 sg.cs.setThreshold(0, ap.av.getIgnoreGapsConsensus());
1576 protected void userDefinedColour_actionPerformed(ActionEvent e)
1578 SequenceGroup sg = getGroup();
1580 if (e.getSource().equals(userDefinedColour))
\r
1582 new UserDefinedColours(ap, sg);
1586 UserColourScheme udc = (UserColourScheme) UserDefinedColours
1587 .getUserColourSchemes().get(e.getActionCommand());
1600 protected void PIDColour_actionPerformed()
1602 SequenceGroup sg = getGroup();
1603 sg.cs = new PIDColourScheme();
1604 sg.cs.setConsensus(AAFrequency.calculate(
1605 sg.getSequences(ap.av.getHiddenRepSequences()),
1606 sg.getStartRes(), sg.getEndRes() + 1));
1616 protected void BLOSUM62Colour_actionPerformed()
1618 SequenceGroup sg = getGroup();
1620 sg.cs = new Blosum62ColourScheme();
1622 sg.cs.setConsensus(AAFrequency.calculate(
1623 sg.getSequences(ap.av.getHiddenRepSequences()),
1624 sg.getStartRes(), sg.getEndRes() + 1));
1635 protected void noColourmenuItem_actionPerformed()
1637 getGroup().cs = null;
1647 protected void conservationMenuItem_actionPerformed()
1649 SequenceGroup sg = getGroup();
1655 if (conservationMenuItem.isSelected())
1657 // JBPNote: Conservation name shouldn't be i18n translated
1658 Conservation c = new Conservation("Group",
1659 ResidueProperties.propHash, 3, sg.getSequences(ap.av
1660 .getHiddenRepSequences()), sg.getStartRes(),
1661 sg.getEndRes() + 1);
1664 c.verdict(false, ap.av.getConsPercGaps());
1666 sg.cs.setConservation(c);
1668 SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
1669 SliderPanel.showConservationSlider();
1672 // remove ConservationColouring
1674 sg.cs.setConservation(null);
1680 public void annotationMenuItem_actionPerformed(ActionEvent actionEvent)
1682 SequenceGroup sg = getGroup();
1688 AnnotationColourGradient acg = new AnnotationColourGradient(
1689 sequence.getAnnotation()[0], null,
1690 AnnotationColourGradient.NO_THRESHOLD);
1692 acg.setPredefinedColours(true);
1704 protected void groupName_actionPerformed()
1707 SequenceGroup sg = getGroup();
1708 EditNameDialog dialog = new EditNameDialog(sg.getName(),
1709 sg.getDescription(), " " + MessageManager.getString("label.group_name") + " ",
\r
1710 MessageManager.getString("label.group_description") + " ", MessageManager.getString("label.edit_group_name_description"),
\r
1718 sg.setName(dialog.getName());
1719 sg.setDescription(dialog.getDescription());
1724 * Get selection group - adding it to the alignment if necessary.
1726 * @return sequence group to operate on
1728 SequenceGroup getGroup()
1730 SequenceGroup sg = ap.av.getSelectionGroup();
1731 // this method won't add a new group if it already exists
1734 ap.av.getAlignment().addGroup(sg);
1746 void sequenceName_actionPerformed()
1748 EditNameDialog dialog = new EditNameDialog(sequence.getName(),
1749 sequence.getDescription(), " " + MessageManager.getString("label.sequence_name") + " ",
\r
1750 MessageManager.getString("label.sequence_description") + " ", MessageManager.getString("label.edit_sequence_name_description"),
\r
1758 if (dialog.getName() != null)
1760 if (dialog.getName().indexOf(" ") > -1)
1762 JOptionPane.showMessageDialog(ap,
1763 MessageManager.getString("label.spaces_converted_to_backslashes"),
\r
1764 MessageManager.getString("label.no_spaces_allowed_sequence_name"),
\r
1765 JOptionPane.WARNING_MESSAGE);
1768 sequence.setName(dialog.getName().replace(' ', '_'));
1769 ap.paintAlignment(false);
1772 sequence.setDescription(dialog.getDescription());
1774 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1785 void unGroupMenuItem_actionPerformed()
1787 SequenceGroup sg = ap.av.getSelectionGroup();
1788 ap.av.getAlignment().deleteGroup(sg);
1789 ap.av.setSelectionGroup(null);
1792 void createGroupMenuItem_actionPerformed()
1794 getGroup(); // implicitly creates group - note - should apply defaults / use standard alignment window logic for this
1804 protected void outline_actionPerformed()
1806 SequenceGroup sg = getGroup();
1807 Color col = JColorChooser.showDialog(this, MessageManager.getString("label.select_outline_colour"),
\r
1812 sg.setOutlineColour(col);
1824 public void showBoxes_actionPerformed()
1826 getGroup().setDisplayBoxes(showBoxes.isSelected());
1836 public void showText_actionPerformed()
1838 getGroup().setDisplayText(showText.isSelected());
1848 public void showColourText_actionPerformed()
1850 getGroup().setColourText(showColourText.isSelected());
1854 public void showLink(String url)
1858 jalview.util.BrowserLauncher.openURL(url);
1859 } catch (Exception ex)
1862 .showInternalMessageDialog(
1864 MessageManager.getString("label.web_browser_not_found_unix"),
\r
1865 MessageManager.getString("label.web_browser_not_found"), JOptionPane.WARNING_MESSAGE);
\r
1867 ex.printStackTrace();
1871 void hideSequences(boolean representGroup)
1873 SequenceGroup sg = ap.av.getSelectionGroup();
1874 if (sg == null || sg.getSize() < 1)
1876 ap.av.hideSequence(new SequenceI[]
1881 ap.av.setSelectionGroup(null);
1885 ap.av.hideRepSequences(sequence, sg);
1890 int gsize = sg.getSize();
1893 hseqs = new SequenceI[gsize];
1896 for (int i = 0; i < gsize; i++)
1898 hseqs[index++] = sg.getSequenceAt(i);
1901 ap.av.hideSequence(hseqs);
1902 // refresh(); TODO: ? needed ?
1903 ap.av.sendSelection();
1906 public void copy_actionPerformed()
1908 ap.alignFrame.copy_actionPerformed(null);
1911 public void cut_actionPerformed()
1913 ap.alignFrame.cut_actionPerformed(null);
1916 void changeCase(ActionEvent e)
1918 Object source = e.getSource();
1919 SequenceGroup sg = ap.av.getSelectionGroup();
1923 int[][] startEnd = ap.av.getVisibleRegionBoundaries(sg.getStartRes(),
1924 sg.getEndRes() + 1);
1929 if (source == toggle)
1931 description = MessageManager.getString("label.toggle_case");
\r
1932 caseChange = ChangeCaseCommand.TOGGLE_CASE;
1934 else if (source == upperCase)
1936 description = MessageManager.getString("label.to_upper_case");
\r
1937 caseChange = ChangeCaseCommand.TO_UPPER;
1941 description = MessageManager.getString("label.to_lower_case");
\r
1942 caseChange = ChangeCaseCommand.TO_LOWER;
1945 ChangeCaseCommand caseCommand = new ChangeCaseCommand(description,
1946 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
1947 startEnd, caseChange);
1949 ap.alignFrame.addHistoryItem(caseCommand);
1951 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1957 public void outputText_actionPerformed(ActionEvent e)
1959 CutAndPasteTransfer cap = new CutAndPasteTransfer();
1960 cap.setForInput(null);
1961 Desktop.addInternalFrame(cap,
1962 MessageManager.formatMessage("label.alignment_output_command", new String[]{e.getActionCommand()}), 600, 500);
\r
1964 String[] omitHidden = null;
1966 System.out.println("PROMPT USER HERE"); // TODO: decide if a prompt happens
1967 // or we simply trust the user wants
1968 // wysiwig behaviour
1969 SequenceGroup sg = ap.av.getSelectionGroup();
1970 ColumnSelection csel = new ColumnSelection(ap.av.getColumnSelection());
1971 omitHidden = ap.av.getViewAsString(true);
1972 Alignment oal = new Alignment(ap.av.getSequenceSelection());
1973 AlignmentAnnotation[] nala = ap.av.getAlignment()
1974 .getAlignmentAnnotation();
1977 for (int i = 0; i < nala.length; i++)
1979 AlignmentAnnotation na = nala[i];
1980 oal.addAnnotation(na);
1983 cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(),
1984 oal, omitHidden, csel, sg));
1988 public void pdbFromFile_actionPerformed()
1990 jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(
1991 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
1992 chooser.setFileView(new jalview.io.JalviewFileView());
1993 chooser.setDialogTitle(MessageManager.formatMessage("label.select_pdb_file_for", new String[]{sequence.getDisplayId(false)}));
\r
1994 chooser.setToolTipText(MessageManager.formatMessage("label.load_pdb_file_associate_with_sequence", new String[]{new Integer(sequence.getDisplayId(false)).toString()}));
\r
1996 int value = chooser.showOpenDialog(null);
1998 if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
2000 String choice = chooser.getSelectedFile().getPath();
2001 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
2002 new AssociatePdbFileWithSeq().associatePdbWithSeq(choice,
2003 jalview.io.AppletFormatAdapter.FILE, sequence, true);
2008 public void enterPDB_actionPerformed()
2010 String id = JOptionPane.showInternalInputDialog(Desktop.desktop,
2011 MessageManager.getString("label.enter_pdb_id"), MessageManager.getString("label.enter_pdb_id"), JOptionPane.QUESTION_MESSAGE);
\r
2013 if (id != null && id.length() > 0)
2015 PDBEntry entry = new PDBEntry();
2016 entry.setId(id.toUpperCase());
2017 sequence.getDatasetSequence().addPDBId(entry);
2021 public void discoverPDB_actionPerformed()
2024 final SequenceI[] sequences = ((ap.av.getSelectionGroup() == null) ? new SequenceI[]
2026 : ap.av.getSequenceSelection());
2027 Thread discpdb = new Thread(new Runnable()
2032 new jalview.ws.DBRefFetcher(sequences, ap.alignFrame)
2033 .fetchDBRefs(false);
2040 public void sequenceFeature_actionPerformed()
2042 SequenceGroup sg = ap.av.getSelectionGroup();
2048 int rsize = 0, gSize = sg.getSize();
2049 SequenceI[] rseqs, seqs = new SequenceI[gSize];
2050 SequenceFeature[] tfeatures, features = new SequenceFeature[gSize];
2052 for (int i = 0; i < gSize; i++)
2054 int start = sg.getSequenceAt(i).findPosition(sg.getStartRes());
2055 int end = sg.findEndRes(sg.getSequenceAt(i));
2058 seqs[rsize] = sg.getSequenceAt(i).getDatasetSequence();
2059 features[rsize] = new SequenceFeature(null, null, null, start, end,
2064 rseqs = new SequenceI[rsize];
2065 tfeatures = new SequenceFeature[rsize];
2066 System.arraycopy(seqs, 0, rseqs, 0, rsize);
2067 System.arraycopy(features, 0, tfeatures, 0, rsize);
2068 features = tfeatures;
2070 if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs,
2071 features, true, ap))
2073 ap.alignFrame.setShowSeqFeatures(true);
2074 ap.highlightSearchResults(null);
2078 public void textColour_actionPerformed()
2080 SequenceGroup sg = getGroup();
2083 new TextColourChooser().chooseColour(ap, sg);
2087 public void colourByStructure(String pdbid)
2089 Annotation[] anots = ap.av.getStructureSelectionManager()
2090 .colourSequenceFromStructure(sequence, pdbid);
2092 AlignmentAnnotation an = new AlignmentAnnotation("Structure",
2093 "Coloured by " + pdbid, anots);
2095 ap.av.getAlignment().addAnnotation(an);
2096 an.createSequenceMapping(sequence, 0, true);
2097 // an.adjustForAlignment();
2098 ap.av.getAlignment().setAnnotationIndex(an, 0);
2100 ap.adjustAnnotationHeight();
2102 sequence.addAlignmentAnnotation(an);
2106 public void editSequence_actionPerformed(ActionEvent actionEvent)
2108 SequenceGroup sg = ap.av.getSelectionGroup();
2112 if (sequence == null)
2113 sequence = (Sequence) sg.getSequenceAt(0);
2115 EditNameDialog dialog = new EditNameDialog(
2116 sequence.getSequenceAsString(sg.getStartRes(),
2117 sg.getEndRes() + 1), null, MessageManager.getString("label.edit_sequence"), null,
\r
2118 MessageManager.getString("label.edit_sequence"), ap.alignFrame);
\r
2122 EditCommand editCommand = new EditCommand(MessageManager.getString("label.edit_sequences"),
\r
2123 EditCommand.REPLACE, dialog.getName().replace(' ',
2124 ap.av.getGapCharacter()),
2125 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
2126 sg.getStartRes(), sg.getEndRes() + 1, ap.av.getAlignment());
2128 ap.alignFrame.addHistoryItem(editCommand);
2130 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()