2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
3 * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
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/>.
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.UrlLink;
40 * @version $Revision: 1.118 $
42 public class PopupMenu extends JPopupMenu
44 JMenu groupMenu = new JMenu();
46 JMenuItem groupName = new JMenuItem();
48 protected JRadioButtonMenuItem clustalColour = new JRadioButtonMenuItem();
50 protected JRadioButtonMenuItem zappoColour = new JRadioButtonMenuItem();
52 protected JRadioButtonMenuItem taylorColour = new JRadioButtonMenuItem();
54 protected JRadioButtonMenuItem hydrophobicityColour = new JRadioButtonMenuItem();
56 protected JRadioButtonMenuItem helixColour = new JRadioButtonMenuItem();
58 protected JRadioButtonMenuItem strandColour = new JRadioButtonMenuItem();
60 protected JRadioButtonMenuItem turnColour = new JRadioButtonMenuItem();
62 protected JRadioButtonMenuItem buriedColour = new JRadioButtonMenuItem();
64 protected JCheckBoxMenuItem abovePIDColour = new JCheckBoxMenuItem();
66 protected JRadioButtonMenuItem userDefinedColour = new JRadioButtonMenuItem();
68 protected JRadioButtonMenuItem PIDColour = new JRadioButtonMenuItem();
70 protected JRadioButtonMenuItem BLOSUM62Colour = new JRadioButtonMenuItem();
72 protected JRadioButtonMenuItem purinePyrimidineColour = new JRadioButtonMenuItem();
74 // protected JRadioButtonMenuItem covariationColour = new
75 // JRadioButtonMenuItem();
77 JRadioButtonMenuItem noColourmenuItem = new JRadioButtonMenuItem();
79 protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem();
83 JMenu sequenceMenu = new JMenu();
85 JMenuItem sequenceName = new JMenuItem();
87 JMenuItem sequenceDetails = new JMenuItem();
89 JMenuItem sequenceSelDetails = new JMenuItem();
92 JMenuItem createGroupMenuItem = new JMenuItem();
93 JMenuItem unGroupMenuItem = new JMenuItem();
95 JMenuItem outline = new JMenuItem();
97 JRadioButtonMenuItem nucleotideMenuItem = new JRadioButtonMenuItem();
99 JMenu colourMenu = new JMenu();
101 JCheckBoxMenuItem showBoxes = new JCheckBoxMenuItem();
103 JCheckBoxMenuItem showText = new JCheckBoxMenuItem();
105 JCheckBoxMenuItem showColourText = new JCheckBoxMenuItem();
107 JCheckBoxMenuItem displayNonconserved = new JCheckBoxMenuItem();
109 JMenu editMenu = new JMenu();
111 JMenuItem cut = new JMenuItem();
113 JMenuItem copy = new JMenuItem();
115 JMenuItem upperCase = new JMenuItem();
117 JMenuItem lowerCase = new JMenuItem();
119 JMenuItem toggle = new JMenuItem();
121 JMenu pdbMenu = new JMenu();
123 JMenuItem pdbFromFile = new JMenuItem();
125 JMenuItem enterPDB = new JMenuItem();
127 JMenuItem discoverPDB = new JMenuItem();
129 JMenu outputMenu = new JMenu();
131 JMenuItem sequenceFeature = new JMenuItem();
133 JMenuItem textColour = new JMenuItem();
135 JMenu jMenu1 = new JMenu();
137 JMenu structureMenu = new JMenu();
139 JMenu viewStructureMenu = new JMenu();
141 // JMenu colStructureMenu = new JMenu();
142 JMenuItem editSequence = new JMenuItem();
144 // JMenuItem annotationMenuItem = new JMenuItem();
146 JMenu groupLinksMenu;
149 * Creates a new PopupMenu object.
156 public PopupMenu(final AlignmentPanel ap, Sequence seq, Vector links)
158 this(ap, seq, links, null);
168 public PopupMenu(final AlignmentPanel ap, final SequenceI seq,
169 Vector links, Vector groupLinks)
171 // /////////////////////////////////////////////////////////
172 // If this is activated from the sequence panel, the user may want to
173 // edit or annotate a particular residue. Therefore display the residue menu
175 // If from the IDPanel, we must display the sequence menu
176 // ////////////////////////////////////////////////////////
180 ButtonGroup colours = new ButtonGroup();
181 colours.add(noColourmenuItem);
182 colours.add(clustalColour);
183 colours.add(zappoColour);
184 colours.add(taylorColour);
185 colours.add(hydrophobicityColour);
186 colours.add(helixColour);
187 colours.add(strandColour);
188 colours.add(turnColour);
189 colours.add(buriedColour);
190 colours.add(abovePIDColour);
191 colours.add(userDefinedColour);
192 colours.add(PIDColour);
193 colours.add(BLOSUM62Colour);
194 colours.add(purinePyrimidineColour);
195 // colours.add(covariationColour);
197 for (int i = 0; i < jalview.io.FormatAdapter.WRITEABLE_FORMATS.length; i++)
199 JMenuItem item = new JMenuItem(
200 jalview.io.FormatAdapter.WRITEABLE_FORMATS[i]);
202 item.addActionListener(new java.awt.event.ActionListener()
204 public void actionPerformed(ActionEvent e)
206 outputText_actionPerformed(e);
210 outputMenu.add(item);
216 } catch (Exception e)
224 sequenceMenu.setText(sequence.getName());
226 if (seq.getDatasetSequence().getPDBId() != null
227 && seq.getDatasetSequence().getPDBId().size() > 0)
229 java.util.Enumeration e = seq.getDatasetSequence().getPDBId()
232 while (e.hasMoreElements())
234 final PDBEntry pdb = (PDBEntry) e.nextElement();
236 menuItem = new JMenuItem();
237 menuItem.setText(pdb.getId());
238 menuItem.addActionListener(new java.awt.event.ActionListener()
240 public void actionPerformed(ActionEvent e)
242 // TODO re JAL-860: optionally open dialog or provide a menu entry
243 // allowing user to open just one structure per sequence
244 new AppJmol(pdb, ap.av.collateForPDB(new PDBEntry[]
245 { pdb })[0], null, ap);
246 // new PDBViewer(pdb, seqs2, null, ap, AppletFormatAdapter.FILE);
250 viewStructureMenu.add(menuItem);
253 * menuItem = new JMenuItem(); menuItem.setText(pdb.getId());
254 * menuItem.addActionListener(new java.awt.event.ActionListener() {
255 * public void actionPerformed(ActionEvent e) {
256 * colourByStructure(pdb.getId()); } });
257 * colStructureMenu.add(menuItem);
263 if (ap.av.getAlignment().isNucleotide() == false)
265 structureMenu.remove(viewStructureMenu);
267 // structureMenu.remove(colStructureMenu);
270 if (ap.av.getAlignment().isNucleotide() == true)
272 AlignmentAnnotation[] aa = ap.av.getAlignment()
273 .getAlignmentAnnotation();
274 for (int i = 0; i < aa.length; i++)
276 if (aa[i].getRNAStruc() != null)
278 final String rnastruc = aa[i].getRNAStruc();
279 final String structureLine = aa[i].label;
280 menuItem = new JMenuItem();
281 menuItem.setText("2D RNA " + structureLine);
282 menuItem.addActionListener(new java.awt.event.ActionListener()
284 public void actionPerformed(ActionEvent e)
286 new AppVarna(structureLine, seq, seq.getSequenceAsString(),
287 rnastruc, seq.getName(), ap);
290 viewStructureMenu.add(menuItem);
294 // SequenceFeatures[] test = seq.getSequenceFeatures();
296 if (seq.getAnnotation() != null)
298 AlignmentAnnotation seqAnno[] = seq.getAnnotation();
299 for (int i = 0; i < seqAnno.length; i++)
301 if (seqAnno[i].getRNAStruc() != null)
303 final String rnastruc = seqAnno[i].getRNAStruc();
305 // TODO: make rnastrucF a bit more nice
306 menuItem = new JMenuItem();
307 menuItem.setText("2D RNA - " + seq.getName());
308 menuItem.addActionListener(new java.awt.event.ActionListener()
310 public void actionPerformed(ActionEvent e)
312 // TODO: VARNA does'nt print gaps in the sequence
313 new AppVarna(seq.getName() + " structure", seq, seq
314 .getSequenceAsString(), rnastruc, seq.getName(),
318 viewStructureMenu.add(menuItem);
325 menuItem = new JMenuItem("Hide Sequences");
326 menuItem.addActionListener(new java.awt.event.ActionListener()
328 public void actionPerformed(ActionEvent e)
330 hideSequences(false);
335 if (ap.av.getSelectionGroup() != null
336 && ap.av.getSelectionGroup().getSize() > 1)
338 menuItem = new JMenuItem("Represent Group with " + seq.getName());
339 menuItem.addActionListener(new java.awt.event.ActionListener()
341 public void actionPerformed(ActionEvent e)
346 sequenceMenu.add(menuItem);
349 if (ap.av.hasHiddenRows())
351 final int index = ap.av.getAlignment().findIndex(seq);
353 if (ap.av.adjustForHiddenSeqs(index)
354 - ap.av.adjustForHiddenSeqs(index - 1) > 1)
356 menuItem = new JMenuItem("Reveal Sequences");
357 menuItem.addActionListener(new ActionListener()
359 public void actionPerformed(ActionEvent e)
361 ap.av.showSequence(index);
362 if (ap.overviewPanel != null)
364 ap.overviewPanel.updateOverviewImage();
372 // for the case when no sequences are even visible
373 if (ap.av.hasHiddenRows())
376 menuItem = new JMenuItem("Reveal All");
377 menuItem.addActionListener(new ActionListener()
379 public void actionPerformed(ActionEvent e)
381 ap.av.showAllHiddenSeqs();
382 if (ap.overviewPanel != null)
384 ap.overviewPanel.updateOverviewImage();
394 SequenceGroup sg = ap.av.getSelectionGroup();
395 boolean isDefinedGroup = (sg!=null) ? ap.av.getAlignment().getGroups().contains(sg) : false;
397 if (sg != null && sg.getSize() > 0)
399 groupName.setText("Name: " + sg.getName());
400 groupName.setText("Edit name and description of current group.");
402 if (sg.cs instanceof ZappoColourScheme)
404 zappoColour.setSelected(true);
406 else if (sg.cs instanceof TaylorColourScheme)
408 taylorColour.setSelected(true);
410 else if (sg.cs instanceof PIDColourScheme)
412 PIDColour.setSelected(true);
414 else if (sg.cs instanceof Blosum62ColourScheme)
416 BLOSUM62Colour.setSelected(true);
418 else if (sg.cs instanceof UserColourScheme)
420 userDefinedColour.setSelected(true);
422 else if (sg.cs instanceof HydrophobicColourScheme)
424 hydrophobicityColour.setSelected(true);
426 else if (sg.cs instanceof HelixColourScheme)
428 helixColour.setSelected(true);
430 else if (sg.cs instanceof StrandColourScheme)
432 strandColour.setSelected(true);
434 else if (sg.cs instanceof TurnColourScheme)
436 turnColour.setSelected(true);
438 else if (sg.cs instanceof BuriedColourScheme)
440 buriedColour.setSelected(true);
442 else if (sg.cs instanceof ClustalxColourScheme)
444 clustalColour.setSelected(true);
446 else if (sg.cs instanceof PurinePyrimidineColourScheme)
448 purinePyrimidineColour.setSelected(true);
451 * else if (sg.cs instanceof CovariationColourScheme) {
452 * covariationColour.setSelected(true); }
456 noColourmenuItem.setSelected(true);
459 if (sg.cs != null && sg.cs.conservationApplied())
461 conservationMenuItem.setSelected(true);
463 displayNonconserved.setSelected(sg.getShowNonconserved());
464 showText.setSelected(sg.getDisplayText());
465 showColourText.setSelected(sg.getColourText());
466 showBoxes.setSelected(sg.getDisplayBoxes());
467 // add any groupURLs to the groupURL submenu and make it visible
468 if (groupLinks != null && groupLinks.size() > 0)
470 buildGroupURLMenu(sg, groupLinks);
472 // Add a 'show all structures' for the current selection
473 Hashtable<String, PDBEntry> pdbe = new Hashtable<String, PDBEntry>();
474 SequenceI sqass = null;
475 for (SequenceI sq : ap.av.getSequenceSelection())
477 Vector<PDBEntry> pes = (Vector<PDBEntry>) sq.getDatasetSequence()
481 for (PDBEntry pe : pes)
483 pdbe.put(pe.getId(), pe);
493 final PDBEntry[] pe = pdbe.values().toArray(
494 new PDBEntry[pdbe.size()]);
495 final JMenuItem gpdbview;
496 if (pdbe.size() == 1)
498 structureMenu.add(gpdbview = new JMenuItem("View structure for "
499 + sqass.getDisplayId(false)));
503 structureMenu.add(gpdbview = new JMenuItem("View all "
504 + pdbe.size() + " structures."));
506 gpdbview.setToolTipText("Open a new Jmol view with all structures associated with the current selection and superimpose them using the alignment.");
507 gpdbview.addActionListener(new ActionListener()
511 public void actionPerformed(ActionEvent e)
513 new AppJmol(ap, pe, ap.av.collateForPDB(pe));
520 groupMenu.setVisible(false);
521 editMenu.setVisible(false);
526 createGroupMenuItem.setVisible(true);
527 unGroupMenuItem.setVisible(false);
528 jMenu1.setText("Edit New Group");
530 createGroupMenuItem.setVisible(false);
531 unGroupMenuItem.setVisible(true);
532 jMenu1.setText("Edit Group");
537 sequenceMenu.setVisible(false);
538 structureMenu.setVisible(false);
541 if (links != null && links.size() > 0)
544 JMenu linkMenu = new JMenu("Link");
545 Vector linkset = new Vector();
546 for (int i = 0; i < links.size(); i++)
548 String link = links.elementAt(i).toString();
549 UrlLink urlLink = null;
552 urlLink = new UrlLink(link);
553 } catch (Exception foo)
555 jalview.bin.Cache.log.error("Exception for URLLink '" + link
560 if (!urlLink.isValid())
562 jalview.bin.Cache.log.error(urlLink.getInvalidMessage());
565 final String label = urlLink.getLabel();
566 if (seq != null && urlLink.isDynamic())
569 // collect matching db-refs
570 DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(
571 seq.getDBRef(), new String[]
572 { urlLink.getTarget() });
573 // collect id string too
574 String id = seq.getName();
575 String descr = seq.getDescription();
576 if (descr != null && descr.length() < 1)
583 for (int r = 0; r < dbr.length; r++)
585 if (id != null && dbr[r].getAccessionId().equals(id))
587 // suppress duplicate link creation for the bare sequence ID
588 // string with this link
591 // create Bare ID link for this RUL
592 String[] urls = urlLink.makeUrls(dbr[r].getAccessionId(),
596 for (int u = 0; u < urls.length; u += 2)
598 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
600 linkset.addElement(urls[u] + "|" + urls[u + 1]);
601 addshowLink(linkMenu, label + "|" + urls[u],
610 // create Bare ID link for this RUL
611 String[] urls = urlLink.makeUrls(id, true);
614 for (int u = 0; u < urls.length; u += 2)
616 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
618 linkset.addElement(urls[u] + "|" + urls[u + 1]);
619 addshowLink(linkMenu, label, urls[u + 1]);
624 // Create urls from description but only for URL links which are regex
626 if (descr != null && urlLink.getRegexReplace() != null)
628 // create link for this URL from description where regex matches
629 String[] urls = urlLink.makeUrls(descr, true);
632 for (int u = 0; u < urls.length; u += 2)
634 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
636 linkset.addElement(urls[u] + "|" + urls[u + 1]);
637 addshowLink(linkMenu, label, urls[u + 1]);
645 if (!linkset.contains(label + "|" + urlLink.getUrl_prefix()))
647 linkset.addElement(label + "|" + urlLink.getUrl_prefix());
648 // Add a non-dynamic link
649 addshowLink(linkMenu, label, urlLink.getUrl_prefix());
653 if (sequence != null)
655 sequenceMenu.add(linkMenu);
664 private void buildGroupURLMenu(SequenceGroup sg, Vector groupLinks)
667 // TODO: usability: thread off the generation of group url content so root
669 // sequence only URLs
670 // ID/regex match URLs
671 groupLinksMenu = new JMenu("Group Link");
672 JMenu[] linkMenus = new JMenu[]
673 { null, new JMenu("IDS"), new JMenu("Sequences"),
674 new JMenu("IDS and Sequences") }; // three types of url that might be
676 SequenceI[] seqs = ap.av.getSelectionAsNewSequence();
677 String[][] idandseqs = GroupUrlLink.formStrings(seqs);
678 Hashtable commonDbrefs = new Hashtable();
679 for (int sq = 0; sq < seqs.length; sq++)
682 int start = seqs[sq].findPosition(sg.getStartRes()), end = seqs[sq]
683 .findPosition(sg.getEndRes());
684 // just collect ids from dataset sequence
685 // TODO: check if IDs collected from selecton group intersects with the
686 // current selection, too
687 SequenceI sqi = seqs[sq];
688 while (sqi.getDatasetSequence() != null)
690 sqi = sqi.getDatasetSequence();
692 DBRefEntry[] dbr = sqi.getDBRef();
693 if (dbr != null && dbr.length > 0)
695 for (int d = 0; d < dbr.length; d++)
697 String src = dbr[d].getSource(); // jalview.util.DBRefUtils.getCanonicalName(dbr[d].getSource()).toUpperCase();
698 Object[] sarray = (Object[]) commonDbrefs.get(src);
701 sarray = new Object[2];
702 sarray[0] = new int[]
704 sarray[1] = new String[seqs.length];
706 commonDbrefs.put(src, sarray);
709 if (((String[]) sarray[1])[sq] == null)
712 || (dbr[d].getMap().locateMappedRange(start, end) != null))
714 ((String[]) sarray[1])[sq] = dbr[d].getAccessionId();
715 ((int[]) sarray[0])[0]++;
721 // now create group links for all distinct ID/sequence sets.
722 boolean addMenu = false; // indicates if there are any group links to give
724 for (int i = 0; i < groupLinks.size(); i++)
726 String link = groupLinks.elementAt(i).toString();
727 GroupUrlLink urlLink = null;
730 urlLink = new GroupUrlLink(link);
731 } catch (Exception foo)
733 jalview.bin.Cache.log.error("Exception for GroupURLLink '" + link
738 if (!urlLink.isValid())
740 jalview.bin.Cache.log.error(urlLink.getInvalidMessage());
743 final String label = urlLink.getLabel();
744 boolean usingNames = false;
745 // Now see which parts of the group apply for this URL
746 String ltarget = urlLink.getTarget(); // jalview.util.DBRefUtils.getCanonicalName(urlLink.getTarget());
747 Object[] idset = (Object[]) commonDbrefs.get(ltarget.toUpperCase());
748 String[] seqstr, ids; // input to makeUrl
751 int numinput = ((int[]) idset[0])[0];
752 String[] allids = ((String[]) idset[1]);
753 seqstr = new String[numinput];
754 ids = new String[numinput];
755 for (int sq = 0, idcount = 0; sq < seqs.length; sq++)
757 if (allids[sq] != null)
759 ids[idcount] = allids[sq];
760 seqstr[idcount++] = idandseqs[1][sq];
766 // just use the id/seq set
767 seqstr = idandseqs[1];
771 // and try and make the groupURL!
773 Object[] urlset = null;
776 urlset = urlLink.makeUrlStubs(ids, seqstr,
777 "FromJalview" + System.currentTimeMillis(), false);
778 } catch (UrlStringTooLongException e)
783 int type = urlLink.getGroupURLType() & 3;
784 // System.out.println(urlLink.getGroupURLType()
785 // +" "+((String[])urlset[3])[0]);
786 // first two bits ofurlLink type bitfield are sequenceids and sequences
787 // TODO: FUTURE: ensure the groupURL menu structure can be generalised
788 addshowLink(linkMenus[type], label
789 + (((type & 1) == 1) ? ("("
790 + (usingNames ? "Names" : ltarget) + ")") : ""),
797 groupLinksMenu = new JMenu("Group Links");
798 for (int m = 0; m < linkMenus.length; m++)
800 if (linkMenus[m] != null
801 && linkMenus[m].getMenuComponentCount() > 0)
803 groupLinksMenu.add(linkMenus[m]);
807 groupMenu.add(groupLinksMenu);
812 * add a show URL menu item to the given linkMenu
816 * - menu label string
820 private void addshowLink(JMenu linkMenu, String label, final String url)
822 JMenuItem item = new JMenuItem(label);
823 item.setToolTipText("open URL: " + url);
824 item.addActionListener(new java.awt.event.ActionListener()
826 public void actionPerformed(ActionEvent e)
828 new Thread(new Runnable()
844 * add a late bound groupURL item to the given linkMenu
848 * - menu label string
849 * @param urlgenerator
850 * GroupURLLink used to generate URL
852 * Object array returned from the makeUrlStubs function.
854 private void addshowLink(JMenu linkMenu, String label,
855 final GroupUrlLink urlgenerator, final Object[] urlstub)
857 JMenuItem item = new JMenuItem(label);
858 item.setToolTipText("open URL (" + urlgenerator.getUrl_prefix()
859 + "..) (" + urlgenerator.getNumberInvolved(urlstub) + " seqs)"); // TODO:
868 item.addActionListener(new java.awt.event.ActionListener()
870 public void actionPerformed(ActionEvent e)
872 new Thread(new Runnable()
879 showLink(urlgenerator.constructFrom(urlstub));
880 } catch (UrlStringTooLongException e)
898 private void jbInit() throws Exception
900 groupMenu.setText("Group");
901 groupMenu.setText("Selection");
902 groupName.setText("Name");
903 groupName.addActionListener(new java.awt.event.ActionListener()
905 public void actionPerformed(ActionEvent e)
907 groupName_actionPerformed();
910 sequenceMenu.setText("Sequence");
911 sequenceName.setText("Edit Name/Description");
912 sequenceName.addActionListener(new java.awt.event.ActionListener()
914 public void actionPerformed(ActionEvent e)
916 sequenceName_actionPerformed();
919 sequenceDetails.setText("Sequence Details ...");
920 sequenceDetails.addActionListener(new java.awt.event.ActionListener()
922 public void actionPerformed(ActionEvent e)
924 sequenceDetails_actionPerformed();
927 sequenceSelDetails.setText("Sequence Details ...");
929 .addActionListener(new java.awt.event.ActionListener()
931 public void actionPerformed(ActionEvent e)
933 sequenceSelectionDetails_actionPerformed();
936 PIDColour.setFocusPainted(false);
937 unGroupMenuItem.setText("Remove Group");
938 unGroupMenuItem.addActionListener(new java.awt.event.ActionListener()
940 public void actionPerformed(ActionEvent e)
942 unGroupMenuItem_actionPerformed();
945 createGroupMenuItem.setText("Create Group");
946 createGroupMenuItem.addActionListener(new java.awt.event.ActionListener()
948 public void actionPerformed(ActionEvent e)
950 createGroupMenuItem_actionPerformed();
954 outline.setText("Border colour");
955 outline.addActionListener(new java.awt.event.ActionListener()
957 public void actionPerformed(ActionEvent e)
959 outline_actionPerformed();
962 nucleotideMenuItem.setText("Nucleotide");
963 nucleotideMenuItem.addActionListener(new ActionListener()
965 public void actionPerformed(ActionEvent e)
967 nucleotideMenuItem_actionPerformed();
970 colourMenu.setText("Group Colour");
971 showBoxes.setText("Boxes");
972 showBoxes.setState(true);
973 showBoxes.addActionListener(new ActionListener()
975 public void actionPerformed(ActionEvent e)
977 showBoxes_actionPerformed();
980 showText.setText("Text");
981 showText.setState(true);
982 showText.addActionListener(new ActionListener()
984 public void actionPerformed(ActionEvent e)
986 showText_actionPerformed();
989 showColourText.setText("Colour Text");
990 showColourText.addActionListener(new ActionListener()
992 public void actionPerformed(ActionEvent e)
994 showColourText_actionPerformed();
997 displayNonconserved.setText("Show Nonconserved");
998 displayNonconserved.setState(true);
999 displayNonconserved.addActionListener(new ActionListener()
1001 public void actionPerformed(ActionEvent e)
1003 showNonconserved_actionPerformed();
1006 editMenu.setText("Edit");
1008 cut.addActionListener(new ActionListener()
1010 public void actionPerformed(ActionEvent e)
1012 cut_actionPerformed();
1015 upperCase.setText("To Upper Case");
1016 upperCase.addActionListener(new ActionListener()
1018 public void actionPerformed(ActionEvent e)
1023 copy.setText("Copy");
1024 copy.addActionListener(new ActionListener()
1026 public void actionPerformed(ActionEvent e)
1028 copy_actionPerformed();
1031 lowerCase.setText("To Lower Case");
1032 lowerCase.addActionListener(new ActionListener()
1034 public void actionPerformed(ActionEvent e)
1039 toggle.setText("Toggle Case");
1040 toggle.addActionListener(new ActionListener()
1042 public void actionPerformed(ActionEvent e)
1047 pdbMenu.setText("Associate Structure with Sequence");
1048 pdbFromFile.setText("From File");
1049 pdbFromFile.addActionListener(new ActionListener()
1051 public void actionPerformed(ActionEvent e)
1053 pdbFromFile_actionPerformed();
1056 enterPDB.setText("Enter PDB Id");
1057 enterPDB.addActionListener(new ActionListener()
1059 public void actionPerformed(ActionEvent e)
1061 enterPDB_actionPerformed();
1064 discoverPDB.setText("Discover PDB ids");
1065 discoverPDB.addActionListener(new ActionListener()
1067 public void actionPerformed(ActionEvent e)
1069 discoverPDB_actionPerformed();
1072 outputMenu.setText("Output to Textbox...");
1073 sequenceFeature.setText("Create Sequence Feature");
1074 sequenceFeature.addActionListener(new ActionListener()
1076 public void actionPerformed(ActionEvent e)
1078 sequenceFeature_actionPerformed();
1081 textColour.setText("Text Colour");
1082 textColour.addActionListener(new ActionListener()
1084 public void actionPerformed(ActionEvent e)
1086 textColour_actionPerformed();
1089 jMenu1.setText("Group");
1090 structureMenu.setText("Structure");
1091 viewStructureMenu.setText("View Structure");
1092 // colStructureMenu.setText("Colour By Structure");
1093 editSequence.setText("Edit Sequence...");
1094 editSequence.addActionListener(new ActionListener()
1096 public void actionPerformed(ActionEvent actionEvent)
1098 editSequence_actionPerformed(actionEvent);
1103 * annotationMenuItem.setText("By Annotation");
1104 * annotationMenuItem.addActionListener(new ActionListener() { public void
1105 * actionPerformed(ActionEvent actionEvent) {
1106 * annotationMenuItem_actionPerformed(actionEvent); } });
1108 groupMenu.add(sequenceSelDetails);
1111 this.add(structureMenu);
1112 groupMenu.add(editMenu);
1113 groupMenu.add(outputMenu);
1114 groupMenu.add(sequenceFeature);
1115 groupMenu.add(createGroupMenuItem);
1116 groupMenu.add(unGroupMenuItem);
1117 groupMenu.add(jMenu1);
1118 sequenceMenu.add(sequenceName);
1119 sequenceMenu.add(sequenceDetails);
1120 colourMenu.add(textColour);
1121 colourMenu.add(noColourmenuItem);
1122 colourMenu.add(clustalColour);
1123 colourMenu.add(BLOSUM62Colour);
1124 colourMenu.add(PIDColour);
1125 colourMenu.add(zappoColour);
1126 colourMenu.add(taylorColour);
1127 colourMenu.add(hydrophobicityColour);
1128 colourMenu.add(helixColour);
1129 colourMenu.add(strandColour);
1130 colourMenu.add(turnColour);
1131 colourMenu.add(buriedColour);
1132 colourMenu.add(nucleotideMenuItem);
1133 if (ap.getAlignment().isNucleotide())
1135 colourMenu.add(purinePyrimidineColour);
1137 // colourMenu.add(covariationColour);
1138 colourMenu.add(userDefinedColour);
1140 if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null)
1142 java.util.Enumeration userColours = jalview.gui.UserDefinedColours
1143 .getUserColourSchemes().keys();
1145 while (userColours.hasMoreElements())
1147 JMenuItem item = new JMenuItem(userColours.nextElement().toString());
1148 item.addActionListener(new ActionListener()
1150 public void actionPerformed(ActionEvent evt)
1152 userDefinedColour_actionPerformed(evt);
1155 colourMenu.add(item);
1159 colourMenu.addSeparator();
1160 colourMenu.add(abovePIDColour);
1161 colourMenu.add(conservationMenuItem);
1162 // colourMenu.add(annotationMenuItem);
1165 editMenu.add(editSequence);
1166 editMenu.add(upperCase);
1167 editMenu.add(lowerCase);
1168 editMenu.add(toggle);
1169 pdbMenu.add(pdbFromFile);
1170 pdbMenu.add(enterPDB);
1171 pdbMenu.add(discoverPDB);
1172 jMenu1.add(groupName);
1173 jMenu1.add(colourMenu);
1174 jMenu1.add(showBoxes);
1175 jMenu1.add(showText);
1176 jMenu1.add(showColourText);
1177 jMenu1.add(outline);
1178 jMenu1.add(displayNonconserved);
1179 structureMenu.add(pdbMenu);
1180 structureMenu.add(viewStructureMenu);
1181 // structureMenu.add(colStructureMenu);
1182 noColourmenuItem.setText("None");
1183 noColourmenuItem.addActionListener(new java.awt.event.ActionListener()
1185 public void actionPerformed(ActionEvent e)
1187 noColourmenuItem_actionPerformed();
1191 clustalColour.setText("Clustalx colours");
1192 clustalColour.addActionListener(new java.awt.event.ActionListener()
1194 public void actionPerformed(ActionEvent e)
1196 clustalColour_actionPerformed();
1199 zappoColour.setText("Zappo");
1200 zappoColour.addActionListener(new java.awt.event.ActionListener()
1202 public void actionPerformed(ActionEvent e)
1204 zappoColour_actionPerformed();
1207 taylorColour.setText("Taylor");
1208 taylorColour.addActionListener(new java.awt.event.ActionListener()
1210 public void actionPerformed(ActionEvent e)
1212 taylorColour_actionPerformed();
1215 hydrophobicityColour.setText("Hydrophobicity");
1216 hydrophobicityColour
1217 .addActionListener(new java.awt.event.ActionListener()
1219 public void actionPerformed(ActionEvent e)
1221 hydrophobicityColour_actionPerformed();
1224 helixColour.setText("Helix propensity");
1225 helixColour.addActionListener(new java.awt.event.ActionListener()
1227 public void actionPerformed(ActionEvent e)
1229 helixColour_actionPerformed();
1232 strandColour.setText("Strand propensity");
1233 strandColour.addActionListener(new java.awt.event.ActionListener()
1235 public void actionPerformed(ActionEvent e)
1237 strandColour_actionPerformed();
1240 turnColour.setText("Turn propensity");
1241 turnColour.addActionListener(new java.awt.event.ActionListener()
1243 public void actionPerformed(ActionEvent e)
1245 turnColour_actionPerformed();
1248 buriedColour.setText("Buried Index");
1249 buriedColour.addActionListener(new java.awt.event.ActionListener()
1251 public void actionPerformed(ActionEvent e)
1253 buriedColour_actionPerformed();
1256 abovePIDColour.setText("Above % Identity");
1257 abovePIDColour.addActionListener(new java.awt.event.ActionListener()
1259 public void actionPerformed(ActionEvent e)
1261 abovePIDColour_actionPerformed();
1264 userDefinedColour.setText("User Defined...");
1265 userDefinedColour.addActionListener(new java.awt.event.ActionListener()
1267 public void actionPerformed(ActionEvent e)
1269 userDefinedColour_actionPerformed(e);
1272 PIDColour.setText("Percentage Identity");
1273 PIDColour.addActionListener(new java.awt.event.ActionListener()
1275 public void actionPerformed(ActionEvent e)
1277 PIDColour_actionPerformed();
1280 BLOSUM62Colour.setText("BLOSUM62");
1281 BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener()
1283 public void actionPerformed(ActionEvent e)
1285 BLOSUM62Colour_actionPerformed();
1288 purinePyrimidineColour.setText("Purine/Pyrimidine");
1289 purinePyrimidineColour
1290 .addActionListener(new java.awt.event.ActionListener()
1292 public void actionPerformed(ActionEvent e)
1294 purinePyrimidineColour_actionPerformed();
1298 * covariationColour.addActionListener(new java.awt.event.ActionListener() {
1299 * public void actionPerformed(ActionEvent e) {
1300 * covariationColour_actionPerformed(); } });
1303 conservationMenuItem.setText("Conservation");
1304 conservationMenuItem
1305 .addActionListener(new java.awt.event.ActionListener()
1307 public void actionPerformed(ActionEvent e)
1309 conservationMenuItem_actionPerformed();
1314 protected void sequenceSelectionDetails_actionPerformed()
1316 createSequenceDetailsReport(ap.av.getSequenceSelection());
1319 protected void sequenceDetails_actionPerformed()
1321 createSequenceDetailsReport(new SequenceI[]
1325 public void createSequenceDetailsReport(SequenceI[] sequences)
1327 CutAndPasteHtmlTransfer cap = new CutAndPasteHtmlTransfer();
1328 StringBuffer contents = new StringBuffer();
1329 for (SequenceI seq : sequences)
1331 contents.append("<p><h2>Annotation for " + seq.getDisplayId(true)
1333 new SequenceAnnotationReport(null)
1334 .createSequenceAnnotationReport(
1340 (ap.seqPanel.seqCanvas.fr != null) ? ap.seqPanel.seqCanvas.fr.minmax
1342 contents.append("</p>");
1344 cap.setText("<html>" + contents.toString() + "</html>");
1346 Desktop.instance.addInternalFrame(cap, "Sequence Details for "
1347 + (sequences.length == 1 ? sequences[0].getDisplayId(true)
1348 : "Selection"), 500, 400);
1352 protected void showNonconserved_actionPerformed()
1354 getGroup().setShowNonconserved(displayNonconserved.isSelected());
1359 * call to refresh view after settings change
1363 ap.updateAnnotation();
1364 ap.paintAlignment(true);
1366 PaintRefresher.Refresh(this, ap.av.getSequenceSetId());
1375 protected void clustalColour_actionPerformed()
1377 SequenceGroup sg = getGroup();
1378 sg.cs = new ClustalxColourScheme(sg, ap.av.getHiddenRepSequences());
1388 protected void zappoColour_actionPerformed()
1390 getGroup().cs = new ZappoColourScheme();
1400 protected void taylorColour_actionPerformed()
1402 getGroup().cs = new TaylorColourScheme();
1412 protected void hydrophobicityColour_actionPerformed()
1414 getGroup().cs = new HydrophobicColourScheme();
1424 protected void helixColour_actionPerformed()
1426 getGroup().cs = new HelixColourScheme();
1436 protected void strandColour_actionPerformed()
1438 getGroup().cs = new StrandColourScheme();
1448 protected void turnColour_actionPerformed()
1450 getGroup().cs = new TurnColourScheme();
1460 protected void buriedColour_actionPerformed()
1462 getGroup().cs = new BuriedColourScheme();
1472 public void nucleotideMenuItem_actionPerformed()
1474 getGroup().cs = new NucleotideColourScheme();
1478 protected void purinePyrimidineColour_actionPerformed()
1480 getGroup().cs = new PurinePyrimidineColourScheme();
1485 * protected void covariationColour_actionPerformed() { getGroup().cs = new
1486 * CovariationColourScheme(sequence.getAnnotation()[0]); refresh(); }
1494 protected void abovePIDColour_actionPerformed()
1496 SequenceGroup sg = getGroup();
1502 if (abovePIDColour.isSelected())
1504 sg.cs.setConsensus(AAFrequency.calculate(
1505 sg.getSequences(ap.av.getHiddenRepSequences()),
1506 sg.getStartRes(), sg.getEndRes() + 1));
1508 int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
1511 sg.cs.setThreshold(threshold, ap.av.getIgnoreGapsConsensus());
1513 SliderPanel.showPIDSlider();
1516 // remove PIDColouring
1518 sg.cs.setThreshold(0, ap.av.getIgnoreGapsConsensus());
1530 protected void userDefinedColour_actionPerformed(ActionEvent e)
1532 SequenceGroup sg = getGroup();
1534 if (e.getActionCommand().equals("User Defined..."))
1536 new UserDefinedColours(ap, sg);
1540 UserColourScheme udc = (UserColourScheme) UserDefinedColours
1541 .getUserColourSchemes().get(e.getActionCommand());
1554 protected void PIDColour_actionPerformed()
1556 SequenceGroup sg = getGroup();
1557 sg.cs = new PIDColourScheme();
1558 sg.cs.setConsensus(AAFrequency.calculate(
1559 sg.getSequences(ap.av.getHiddenRepSequences()),
1560 sg.getStartRes(), sg.getEndRes() + 1));
1570 protected void BLOSUM62Colour_actionPerformed()
1572 SequenceGroup sg = getGroup();
1574 sg.cs = new Blosum62ColourScheme();
1576 sg.cs.setConsensus(AAFrequency.calculate(
1577 sg.getSequences(ap.av.getHiddenRepSequences()),
1578 sg.getStartRes(), sg.getEndRes() + 1));
1589 protected void noColourmenuItem_actionPerformed()
1591 getGroup().cs = null;
1601 protected void conservationMenuItem_actionPerformed()
1603 SequenceGroup sg = getGroup();
1609 if (conservationMenuItem.isSelected())
1611 Conservation c = new Conservation("Group",
1612 ResidueProperties.propHash, 3, sg.getSequences(ap.av
1613 .getHiddenRepSequences()), sg.getStartRes(),
1614 sg.getEndRes() + 1);
1617 c.verdict(false, ap.av.getConsPercGaps());
1619 sg.cs.setConservation(c);
1621 SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
1622 SliderPanel.showConservationSlider();
1625 // remove ConservationColouring
1627 sg.cs.setConservation(null);
1633 public void annotationMenuItem_actionPerformed(ActionEvent actionEvent)
1635 SequenceGroup sg = getGroup();
1641 AnnotationColourGradient acg = new AnnotationColourGradient(
1642 sequence.getAnnotation()[0], null,
1643 AnnotationColourGradient.NO_THRESHOLD);
1645 acg.setPredefinedColours(true);
1657 protected void groupName_actionPerformed()
1660 SequenceGroup sg = getGroup();
1661 EditNameDialog dialog = new EditNameDialog(sg.getName(),
1662 sg.getDescription(), " Group Name ",
1663 "Group Description ", "Edit Group Name/Description",
1671 sg.setName(dialog.getName());
1672 sg.setDescription(dialog.getDescription());
1677 * Get selection group - adding it to the alignment if necessary.
1679 * @return sequence group to operate on
1681 SequenceGroup getGroup()
1683 SequenceGroup sg = ap.av.getSelectionGroup();
1684 // this method won't add a new group if it already exists
1687 ap.av.getAlignment().addGroup(sg);
1699 void sequenceName_actionPerformed()
1701 EditNameDialog dialog = new EditNameDialog(sequence.getName(),
1702 sequence.getDescription(), " Sequence Name ",
1703 "Sequence Description ", "Edit Sequence Name/Description",
1711 if (dialog.getName() != null)
1713 if (dialog.getName().indexOf(" ") > -1)
1715 JOptionPane.showMessageDialog(ap,
1716 "Spaces have been converted to \"_\"",
1717 "No spaces allowed in Sequence Name",
1718 JOptionPane.WARNING_MESSAGE);
1721 sequence.setName(dialog.getName().replace(' ', '_'));
1722 ap.paintAlignment(false);
1725 sequence.setDescription(dialog.getDescription());
1727 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1738 void unGroupMenuItem_actionPerformed()
1740 SequenceGroup sg = ap.av.getSelectionGroup();
1741 ap.av.getAlignment().deleteGroup(sg);
1742 ap.av.setSelectionGroup(null);
1745 void createGroupMenuItem_actionPerformed()
1747 getGroup(); // implicitly creates group - note - should apply defaults / use standard alignment window logic for this
1757 protected void outline_actionPerformed()
1759 SequenceGroup sg = getGroup();
1760 Color col = JColorChooser.showDialog(this, "Select Outline Colour",
1765 sg.setOutlineColour(col);
1777 public void showBoxes_actionPerformed()
1779 getGroup().setDisplayBoxes(showBoxes.isSelected());
1789 public void showText_actionPerformed()
1791 getGroup().setDisplayText(showText.isSelected());
1801 public void showColourText_actionPerformed()
1803 getGroup().setColourText(showColourText.isSelected());
1807 public void showLink(String url)
1811 jalview.util.BrowserLauncher.openURL(url);
1812 } catch (Exception ex)
1815 .showInternalMessageDialog(
1817 "Unixers: Couldn't find default web browser."
1818 + "\nAdd the full path to your browser in Preferences.",
1819 "Web browser not found", JOptionPane.WARNING_MESSAGE);
1821 ex.printStackTrace();
1825 void hideSequences(boolean representGroup)
1827 SequenceGroup sg = ap.av.getSelectionGroup();
1828 if (sg == null || sg.getSize() < 1)
1830 ap.av.hideSequence(new SequenceI[]
1835 ap.av.setSelectionGroup(null);
1839 ap.av.hideRepSequences(sequence, sg);
1844 int gsize = sg.getSize();
1847 hseqs = new SequenceI[gsize];
1850 for (int i = 0; i < gsize; i++)
1852 hseqs[index++] = sg.getSequenceAt(i);
1855 ap.av.hideSequence(hseqs);
1856 // refresh(); TODO: ? needed ?
1857 ap.av.sendSelection();
1860 public void copy_actionPerformed()
1862 ap.alignFrame.copy_actionPerformed(null);
1865 public void cut_actionPerformed()
1867 ap.alignFrame.cut_actionPerformed(null);
1870 void changeCase(ActionEvent e)
1872 Object source = e.getSource();
1873 SequenceGroup sg = ap.av.getSelectionGroup();
1877 int[][] startEnd = ap.av.getVisibleRegionBoundaries(sg.getStartRes(),
1878 sg.getEndRes() + 1);
1883 if (source == toggle)
1885 description = "Toggle Case";
1886 caseChange = ChangeCaseCommand.TOGGLE_CASE;
1888 else if (source == upperCase)
1890 description = "To Upper Case";
1891 caseChange = ChangeCaseCommand.TO_UPPER;
1895 description = "To Lower Case";
1896 caseChange = ChangeCaseCommand.TO_LOWER;
1899 ChangeCaseCommand caseCommand = new ChangeCaseCommand(description,
1900 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
1901 startEnd, caseChange);
1903 ap.alignFrame.addHistoryItem(caseCommand);
1905 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1911 public void outputText_actionPerformed(ActionEvent e)
1913 CutAndPasteTransfer cap = new CutAndPasteTransfer();
1914 cap.setForInput(null);
1915 Desktop.addInternalFrame(cap,
1916 "Alignment output - " + e.getActionCommand(), 600, 500);
1918 String[] omitHidden = null;
1920 System.out.println("PROMPT USER HERE"); // TODO: decide if a prompt happens
1921 // or we simply trust the user wants
1922 // wysiwig behaviour
1923 SequenceGroup sg = ap.av.getSelectionGroup();
1924 ColumnSelection csel = new ColumnSelection(ap.av.getColumnSelection());
1925 omitHidden = ap.av.getViewAsString(true);
1926 Alignment oal = new Alignment(ap.av.getSequenceSelection());
1927 AlignmentAnnotation[] nala = ap.av.getAlignment()
1928 .getAlignmentAnnotation();
1931 for (int i = 0; i < nala.length; i++)
1933 AlignmentAnnotation na = nala[i];
1934 oal.addAnnotation(na);
1937 cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(),
1938 oal, omitHidden, csel, sg));
1942 public void pdbFromFile_actionPerformed()
1944 jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(
1945 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
1946 chooser.setFileView(new jalview.io.JalviewFileView());
1947 chooser.setDialogTitle("Select a PDB file for "
1948 + sequence.getDisplayId(false));
1949 chooser.setToolTipText("Load a PDB file and associate it with sequence '"
1950 + sequence.getDisplayId(false) + "'");
1952 int value = chooser.showOpenDialog(null);
1954 if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
1956 String choice = chooser.getSelectedFile().getPath();
1957 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
1958 new AssociatePdbFileWithSeq().associatePdbWithSeq(choice,
1959 jalview.io.AppletFormatAdapter.FILE, sequence, true);
1964 public void enterPDB_actionPerformed()
1966 String id = JOptionPane.showInternalInputDialog(Desktop.desktop,
1967 "Enter PDB Id", "Enter PDB Id", JOptionPane.QUESTION_MESSAGE);
1969 if (id != null && id.length() > 0)
1971 PDBEntry entry = new PDBEntry();
1972 entry.setId(id.toUpperCase());
1973 sequence.getDatasetSequence().addPDBId(entry);
1977 public void discoverPDB_actionPerformed()
1980 final SequenceI[] sequences = ((ap.av.getSelectionGroup() == null) ? new SequenceI[]
1982 : ap.av.getSequenceSelection());
1983 Thread discpdb = new Thread(new Runnable()
1988 new jalview.ws.DBRefFetcher(sequences, ap.alignFrame)
1989 .fetchDBRefs(false);
1996 public void sequenceFeature_actionPerformed()
1998 SequenceGroup sg = ap.av.getSelectionGroup();
2004 int rsize = 0, gSize = sg.getSize();
2005 SequenceI[] rseqs, seqs = new SequenceI[gSize];
2006 SequenceFeature[] tfeatures, features = new SequenceFeature[gSize];
2008 for (int i = 0; i < gSize; i++)
2010 int start = sg.getSequenceAt(i).findPosition(sg.getStartRes());
2011 int end = sg.findEndRes(sg.getSequenceAt(i));
2014 seqs[rsize] = sg.getSequenceAt(i).getDatasetSequence();
2015 features[rsize] = new SequenceFeature(null, null, null, start, end,
2020 rseqs = new SequenceI[rsize];
2021 tfeatures = new SequenceFeature[rsize];
2022 System.arraycopy(seqs, 0, rseqs, 0, rsize);
2023 System.arraycopy(features, 0, tfeatures, 0, rsize);
2024 features = tfeatures;
2026 if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs,
2027 features, true, ap))
2029 ap.alignFrame.setShowSeqFeatures(true);
2030 ap.highlightSearchResults(null);
2034 public void textColour_actionPerformed()
2036 SequenceGroup sg = getGroup();
2039 new TextColourChooser().chooseColour(ap, sg);
2043 public void colourByStructure(String pdbid)
2045 Annotation[] anots = ap.av.getStructureSelectionManager()
2046 .colourSequenceFromStructure(sequence, pdbid);
2048 AlignmentAnnotation an = new AlignmentAnnotation("Structure",
2049 "Coloured by " + pdbid, anots);
2051 ap.av.getAlignment().addAnnotation(an);
2052 an.createSequenceMapping(sequence, 0, true);
2053 // an.adjustForAlignment();
2054 ap.av.getAlignment().setAnnotationIndex(an, 0);
2056 ap.adjustAnnotationHeight();
2058 sequence.addAlignmentAnnotation(an);
2062 public void editSequence_actionPerformed(ActionEvent actionEvent)
2064 SequenceGroup sg = ap.av.getSelectionGroup();
2068 if (sequence == null)
2069 sequence = (Sequence) sg.getSequenceAt(0);
2071 EditNameDialog dialog = new EditNameDialog(
2072 sequence.getSequenceAsString(sg.getStartRes(),
2073 sg.getEndRes() + 1), null, "Edit Sequence ", null,
2074 "Edit Sequence", ap.alignFrame);
2078 EditCommand editCommand = new EditCommand("Edit Sequences",
2079 EditCommand.REPLACE, dialog.getName().replace(' ',
2080 ap.av.getGapCharacter()),
2081 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
2082 sg.getStartRes(), sg.getEndRes() + 1, ap.av.getAlignment());
2084 ap.alignFrame.addHistoryItem(editCommand);
2086 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()