2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
3 * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, 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.*;
28 import jalview.analysis.*;
29 import jalview.commands.*;
30 import jalview.datamodel.*;
32 import jalview.schemes.*;
33 import jalview.util.GroupUrlLink;
34 import jalview.util.GroupUrlLink.UrlStringTooLongException;
35 import jalview.util.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();
89 JMenuItem sequenceSelDetails = 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, Vector links,
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 allowing user to open just one structure per sequence
243 new AppJmol(pdb, ap.av.collateForPDB(new PDBEntry[] { pdb })[0], null, ap);
244 // new PDBViewer(pdb, seqs2, null, ap, AppletFormatAdapter.FILE);
248 viewStructureMenu.add(menuItem);
251 * menuItem = new JMenuItem(); menuItem.setText(pdb.getId());
252 * menuItem.addActionListener(new java.awt.event.ActionListener() {
253 * public void actionPerformed(ActionEvent e) {
254 * colourByStructure(pdb.getId()); } });
255 * colStructureMenu.add(menuItem);
261 if (ap.av.getAlignment().isNucleotide() == false)
263 structureMenu.remove(viewStructureMenu);
265 // structureMenu.remove(colStructureMenu);
268 if (ap.av.getAlignment().isNucleotide() == true)
270 AlignmentAnnotation[] aa = ap.av.getAlignment().getAlignmentAnnotation();
271 for (int i = 0; i < aa.length; i++)
273 if (aa[i].getRNAStruc() != null)
275 final String rnastruc = aa[i].getRNAStruc();
276 final String structureLine=aa[i].label;
277 menuItem = new JMenuItem();
278 menuItem.setText("2D RNA "+structureLine);
279 menuItem.addActionListener(new java.awt.event.ActionListener()
281 public void actionPerformed(ActionEvent e)
283 new AppVarna(structureLine, seq, seq.getSequenceAsString(), rnastruc, seq
287 viewStructureMenu.add(menuItem);
291 // SequenceFeatures[] test = seq.getSequenceFeatures();
293 if (seq.getAnnotation() != null)
295 AlignmentAnnotation seqAnno[] = seq.getAnnotation();
296 for (int i = 0; i < seqAnno.length; i++)
298 if (seqAnno[i].getRNAStruc() != null)
300 final String rnastruc = seqAnno[i].getRNAStruc();
302 // TODO: make rnastrucF a bit more nice
303 menuItem = new JMenuItem();
304 menuItem.setText("2D RNA - "+seq.getName());
305 menuItem.addActionListener(new java.awt.event.ActionListener()
307 public void actionPerformed(ActionEvent e)
309 // TODO: VARNA does'nt print gaps in the sequence
310 new AppVarna(seq.getName()+" structure",seq,seq.getSequenceAsString(), rnastruc, seq
314 viewStructureMenu.add(menuItem);
322 menuItem = new JMenuItem("Hide Sequences");
323 menuItem.addActionListener(new java.awt.event.ActionListener()
325 public void actionPerformed(ActionEvent e)
327 hideSequences(false);
332 if (ap.av.getSelectionGroup() != null
333 && ap.av.getSelectionGroup().getSize() > 1)
335 menuItem = new JMenuItem("Represent Group with " + seq.getName());
336 menuItem.addActionListener(new java.awt.event.ActionListener()
338 public void actionPerformed(ActionEvent e)
343 sequenceMenu.add(menuItem);
346 if (ap.av.hasHiddenRows())
348 final int index = ap.av.getAlignment().findIndex(seq);
350 if (ap.av.adjustForHiddenSeqs(index)
351 - ap.av.adjustForHiddenSeqs(index - 1) > 1)
353 menuItem = new JMenuItem("Reveal Sequences");
354 menuItem.addActionListener(new ActionListener()
356 public void actionPerformed(ActionEvent e)
358 ap.av.showSequence(index);
359 if (ap.overviewPanel != null)
361 ap.overviewPanel.updateOverviewImage();
369 // for the case when no sequences are even visible
370 if (ap.av.hasHiddenRows()) {
372 menuItem = new JMenuItem("Reveal All");
373 menuItem.addActionListener(new ActionListener()
375 public void actionPerformed(ActionEvent e)
377 ap.av.showAllHiddenSeqs();
378 if (ap.overviewPanel != null)
380 ap.overviewPanel.updateOverviewImage();
390 SequenceGroup sg = ap.av.getSelectionGroup();
392 if (sg != null&& sg.getSize()>0)
394 groupName.setText("Name: "+sg.getName());
395 groupName.setText("Edit name and description of current group.");
397 if (sg.cs instanceof ZappoColourScheme)
399 zappoColour.setSelected(true);
401 else if (sg.cs instanceof TaylorColourScheme)
403 taylorColour.setSelected(true);
405 else if (sg.cs instanceof PIDColourScheme)
407 PIDColour.setSelected(true);
409 else if (sg.cs instanceof Blosum62ColourScheme)
411 BLOSUM62Colour.setSelected(true);
413 else if (sg.cs instanceof UserColourScheme)
415 userDefinedColour.setSelected(true);
417 else if (sg.cs instanceof HydrophobicColourScheme)
419 hydrophobicityColour.setSelected(true);
421 else if (sg.cs instanceof HelixColourScheme)
423 helixColour.setSelected(true);
425 else if (sg.cs instanceof StrandColourScheme)
427 strandColour.setSelected(true);
429 else if (sg.cs instanceof TurnColourScheme)
431 turnColour.setSelected(true);
433 else if (sg.cs instanceof BuriedColourScheme)
435 buriedColour.setSelected(true);
437 else if (sg.cs instanceof ClustalxColourScheme)
439 clustalColour.setSelected(true);
441 else if (sg.cs instanceof PurinePyrimidineColourScheme)
443 purinePyrimidineColour.setSelected(true);
446 * else if (sg.cs instanceof CovariationColourScheme) {
447 * covariationColour.setSelected(true); }
451 noColourmenuItem.setSelected(true);
454 if (sg.cs != null && sg.cs.conservationApplied())
456 conservationMenuItem.setSelected(true);
458 displayNonconserved.setSelected(sg.getShowNonconserved());
459 showText.setSelected(sg.getDisplayText());
460 showColourText.setSelected(sg.getColourText());
461 showBoxes.setSelected(sg.getDisplayBoxes());
462 // add any groupURLs to the groupURL submenu and make it visible
463 if (groupLinks != null && groupLinks.size() > 0)
465 buildGroupURLMenu(sg, groupLinks);
467 // Add a 'show all structures' for the current selection
468 Hashtable<String, PDBEntry> pdbe=new Hashtable<String,PDBEntry>();
469 SequenceI sqass=null;
470 for (SequenceI sq: ap.av.getSequenceSelection())
472 Vector<PDBEntry> pes = (Vector<PDBEntry>) sq.getDatasetSequence().getPDBId();
474 for (PDBEntry pe: pes)
476 pdbe.put(pe.getId(), pe);
486 final PDBEntry[] pe = pdbe.values().toArray(new PDBEntry[pdbe.size()]);
487 final JMenuItem gpdbview;
490 structureMenu.add(gpdbview=new JMenuItem("View structure for "+sqass.getDisplayId(false)));
492 structureMenu.add(gpdbview=new JMenuItem("View all "+pdbe.size()+" structures."));
494 gpdbview.setToolTipText("Open a new Jmol view with all structures associated with the current selection and superimpose them using the alignment.");
495 gpdbview.addActionListener(new ActionListener()
499 public void actionPerformed(ActionEvent e)
501 new AppJmol(ap, pe, ap.av.collateForPDB(pe));
508 groupMenu.setVisible(false);
509 editMenu.setVisible(false);
512 if (!ap.av.getAlignment().getGroups().contains(sg))
514 unGroupMenuItem.setVisible(false);
519 sequenceMenu.setVisible(false);
520 structureMenu.setVisible(false);
523 if (links != null && links.size() > 0)
526 JMenu linkMenu = new JMenu("Link");
527 Vector linkset = new Vector();
528 for (int i = 0; i < links.size(); i++)
530 String link = links.elementAt(i).toString();
531 UrlLink urlLink = null;
534 urlLink = new UrlLink(link);
535 } catch (Exception foo)
537 jalview.bin.Cache.log.error("Exception for URLLink '" + link
542 if (!urlLink.isValid())
544 jalview.bin.Cache.log.error(urlLink.getInvalidMessage());
547 final String label = urlLink.getLabel();
548 if (seq!=null && urlLink.isDynamic())
551 // collect matching db-refs
552 DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(
553 seq.getDBRef(), new String[]
554 { urlLink.getTarget() });
555 // collect id string too
556 String id = seq.getName();
557 String descr = seq.getDescription();
558 if (descr != null && descr.length() < 1)
565 for (int r = 0; r < dbr.length; r++)
567 if (id != null && dbr[r].getAccessionId().equals(id))
569 // suppress duplicate link creation for the bare sequence ID
570 // string with this link
573 // create Bare ID link for this RUL
574 String[] urls = urlLink.makeUrls(dbr[r].getAccessionId(),
578 for (int u = 0; u < urls.length; u += 2)
580 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
582 linkset.addElement(urls[u] + "|" + urls[u + 1]);
583 addshowLink(linkMenu, label + "|" + urls[u],
592 // create Bare ID link for this RUL
593 String[] urls = urlLink.makeUrls(id, true);
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 + 1]);
606 // Create urls from description but only for URL links which are regex
608 if (descr != null && urlLink.getRegexReplace() != null)
610 // create link for this URL from description where regex matches
611 String[] urls = urlLink.makeUrls(descr, 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]);
627 if (!linkset.contains(label + "|" + urlLink.getUrl_prefix()))
629 linkset.addElement(label + "|" + urlLink.getUrl_prefix());
630 // Add a non-dynamic link
631 addshowLink(linkMenu, label, urlLink.getUrl_prefix());
635 if (sequence != null)
637 sequenceMenu.add(linkMenu);
646 private void buildGroupURLMenu(SequenceGroup sg, Vector groupLinks)
649 // TODO: usability: thread off the generation of group url content so root
651 // sequence only URLs
652 // ID/regex match URLs
653 groupLinksMenu = new JMenu("Group Link");
654 JMenu[] linkMenus = new JMenu[]
655 { null, new JMenu("IDS"), new JMenu("Sequences"),
656 new JMenu("IDS and Sequences") }; // three types of url that might be
658 SequenceI[] seqs = ap.av.getSelectionAsNewSequence();
659 String[][] idandseqs = GroupUrlLink.formStrings(seqs);
660 Hashtable commonDbrefs = new Hashtable();
661 for (int sq = 0; sq < seqs.length; sq++)
664 int start = seqs[sq].findPosition(sg.getStartRes()), end = seqs[sq]
665 .findPosition(sg.getEndRes());
666 // just collect ids from dataset sequence
667 // TODO: check if IDs collected from selecton group intersects with the
668 // current selection, too
669 SequenceI sqi = seqs[sq];
670 while (sqi.getDatasetSequence() != null)
672 sqi = sqi.getDatasetSequence();
674 DBRefEntry[] dbr = sqi.getDBRef();
675 if (dbr != null && dbr.length > 0)
677 for (int d = 0; d < dbr.length; d++)
679 String src = dbr[d].getSource(); // jalview.util.DBRefUtils.getCanonicalName(dbr[d].getSource()).toUpperCase();
680 Object[] sarray = (Object[]) commonDbrefs.get(src);
683 sarray = new Object[2];
684 sarray[0] = new int[]
686 sarray[1] = new String[seqs.length];
688 commonDbrefs.put(src, sarray);
691 if (((String[]) sarray[1])[sq] == null)
694 || (dbr[d].getMap().locateMappedRange(start, end) != null))
696 ((String[]) sarray[1])[sq] = dbr[d].getAccessionId();
697 ((int[]) sarray[0])[0]++;
703 // now create group links for all distinct ID/sequence sets.
704 boolean addMenu = false; // indicates if there are any group links to give
706 for (int i = 0; i < groupLinks.size(); i++)
708 String link = groupLinks.elementAt(i).toString();
709 GroupUrlLink urlLink = null;
712 urlLink = new GroupUrlLink(link);
713 } catch (Exception foo)
715 jalview.bin.Cache.log.error("Exception for GroupURLLink '" + link
720 if (!urlLink.isValid())
722 jalview.bin.Cache.log.error(urlLink.getInvalidMessage());
725 final String label = urlLink.getLabel();
726 boolean usingNames = false;
727 // Now see which parts of the group apply for this URL
728 String ltarget = urlLink.getTarget(); // jalview.util.DBRefUtils.getCanonicalName(urlLink.getTarget());
729 Object[] idset = (Object[]) commonDbrefs.get(ltarget.toUpperCase());
730 String[] seqstr, ids; // input to makeUrl
733 int numinput = ((int[]) idset[0])[0];
734 String[] allids = ((String[]) idset[1]);
735 seqstr = new String[numinput];
736 ids = new String[numinput];
737 for (int sq = 0, idcount = 0; sq < seqs.length; sq++)
739 if (allids[sq] != null)
741 ids[idcount] = allids[sq];
742 seqstr[idcount++] = idandseqs[1][sq];
748 // just use the id/seq set
749 seqstr = idandseqs[1];
753 // and try and make the groupURL!
755 Object[] urlset = null;
758 urlset = urlLink.makeUrlStubs(ids, seqstr,
759 "FromJalview" + System.currentTimeMillis(), false);
760 } catch (UrlStringTooLongException e)
765 int type = urlLink.getGroupURLType() & 3;
766 // System.out.println(urlLink.getGroupURLType()
767 // +" "+((String[])urlset[3])[0]);
768 // first two bits ofurlLink type bitfield are sequenceids and sequences
769 // TODO: FUTURE: ensure the groupURL menu structure can be generalised
770 addshowLink(linkMenus[type], label
771 + (((type & 1) == 1) ? ("("
772 + (usingNames ? "Names" : ltarget) + ")") : ""),
779 groupLinksMenu = new JMenu("Group Links");
780 for (int m = 0; m < linkMenus.length; m++)
782 if (linkMenus[m] != null
783 && linkMenus[m].getMenuComponentCount() > 0)
785 groupLinksMenu.add(linkMenus[m]);
789 groupMenu.add(groupLinksMenu);
794 * add a show URL menu item to the given linkMenu
798 * - menu label string
802 private void addshowLink(JMenu linkMenu, String label, final String url)
804 JMenuItem item = new JMenuItem(label);
805 item.setToolTipText("open URL: " + url);
806 item.addActionListener(new java.awt.event.ActionListener()
808 public void actionPerformed(ActionEvent e)
810 new Thread(new Runnable()
826 * add a late bound groupURL item to the given linkMenu
830 * - menu label string
831 * @param urlgenerator
832 * GroupURLLink used to generate URL
834 * Object array returned from the makeUrlStubs function.
836 private void addshowLink(JMenu linkMenu, String label,
837 final GroupUrlLink urlgenerator, final Object[] urlstub)
839 JMenuItem item = new JMenuItem(label);
840 item.setToolTipText("open URL (" + urlgenerator.getUrl_prefix()
841 + "..) (" + urlgenerator.getNumberInvolved(urlstub) + " seqs)"); // TODO:
850 item.addActionListener(new java.awt.event.ActionListener()
852 public void actionPerformed(ActionEvent e)
854 new Thread(new Runnable()
861 showLink(urlgenerator.constructFrom(urlstub));
862 } catch (UrlStringTooLongException e)
880 private void jbInit() throws Exception
882 groupMenu.setText("Group");
883 groupMenu.setText("Selection");
884 groupName.setText("Name");
885 groupName.addActionListener(new java.awt.event.ActionListener()
887 public void actionPerformed(ActionEvent e)
889 groupName_actionPerformed();
892 sequenceMenu.setText("Sequence");
893 sequenceName.setText("Edit Name/Description");
894 sequenceName.addActionListener(new java.awt.event.ActionListener()
896 public void actionPerformed(ActionEvent e)
898 sequenceName_actionPerformed();
901 sequenceDetails.setText("Sequence Details ...");
902 sequenceDetails.addActionListener(new java.awt.event.ActionListener()
904 public void actionPerformed(ActionEvent e)
906 sequenceDetails_actionPerformed();
908 sequenceSelDetails.setText("Sequence Details ...");
909 sequenceSelDetails.addActionListener(new java.awt.event.ActionListener()
911 public void actionPerformed(ActionEvent e)
913 sequenceSelectionDetails_actionPerformed();
915 PIDColour.setFocusPainted(false);
916 unGroupMenuItem.setText("Remove Group");
917 unGroupMenuItem.addActionListener(new java.awt.event.ActionListener()
919 public void actionPerformed(ActionEvent e)
921 unGroupMenuItem_actionPerformed();
925 outline.setText("Border colour");
926 outline.addActionListener(new java.awt.event.ActionListener()
928 public void actionPerformed(ActionEvent e)
930 outline_actionPerformed();
933 nucleotideMenuItem.setText("Nucleotide");
934 nucleotideMenuItem.addActionListener(new ActionListener()
936 public void actionPerformed(ActionEvent e)
938 nucleotideMenuItem_actionPerformed();
941 colourMenu.setText("Group Colour");
942 showBoxes.setText("Boxes");
943 showBoxes.setState(true);
944 showBoxes.addActionListener(new ActionListener()
946 public void actionPerformed(ActionEvent e)
948 showBoxes_actionPerformed();
951 showText.setText("Text");
952 showText.setState(true);
953 showText.addActionListener(new ActionListener()
955 public void actionPerformed(ActionEvent e)
957 showText_actionPerformed();
960 showColourText.setText("Colour Text");
961 showColourText.addActionListener(new ActionListener()
963 public void actionPerformed(ActionEvent e)
965 showColourText_actionPerformed();
968 displayNonconserved.setText("Show Nonconserved");
969 displayNonconserved.setState(true);
970 displayNonconserved.addActionListener(new ActionListener()
972 public void actionPerformed(ActionEvent e)
974 showNonconserved_actionPerformed();
977 editMenu.setText("Edit");
979 cut.addActionListener(new ActionListener()
981 public void actionPerformed(ActionEvent e)
983 cut_actionPerformed();
986 upperCase.setText("To Upper Case");
987 upperCase.addActionListener(new ActionListener()
989 public void actionPerformed(ActionEvent e)
994 copy.setText("Copy");
995 copy.addActionListener(new ActionListener()
997 public void actionPerformed(ActionEvent e)
999 copy_actionPerformed();
1002 lowerCase.setText("To Lower Case");
1003 lowerCase.addActionListener(new ActionListener()
1005 public void actionPerformed(ActionEvent e)
1010 toggle.setText("Toggle Case");
1011 toggle.addActionListener(new ActionListener()
1013 public void actionPerformed(ActionEvent e)
1018 pdbMenu.setText("Associate Structure with Sequence");
1019 pdbFromFile.setText("From File");
1020 pdbFromFile.addActionListener(new ActionListener()
1022 public void actionPerformed(ActionEvent e)
1024 pdbFromFile_actionPerformed();
1027 enterPDB.setText("Enter PDB Id");
1028 enterPDB.addActionListener(new ActionListener()
1030 public void actionPerformed(ActionEvent e)
1032 enterPDB_actionPerformed();
1035 discoverPDB.setText("Discover PDB ids");
1036 discoverPDB.addActionListener(new ActionListener()
1038 public void actionPerformed(ActionEvent e)
1040 discoverPDB_actionPerformed();
1043 outputMenu.setText("Output to Textbox...");
1044 sequenceFeature.setText("Create Sequence Feature");
1045 sequenceFeature.addActionListener(new ActionListener()
1047 public void actionPerformed(ActionEvent e)
1049 sequenceFeature_actionPerformed();
1052 textColour.setText("Text Colour");
1053 textColour.addActionListener(new ActionListener()
1055 public void actionPerformed(ActionEvent e)
1057 textColour_actionPerformed();
1060 jMenu1.setText("Group");
1061 structureMenu.setText("Structure");
1062 viewStructureMenu.setText("View Structure");
1063 // colStructureMenu.setText("Colour By Structure");
1064 editSequence.setText("Edit Sequence...");
1065 editSequence.addActionListener(new ActionListener()
1067 public void actionPerformed(ActionEvent actionEvent)
1069 editSequence_actionPerformed(actionEvent);
1074 * annotationMenuItem.setText("By Annotation");
1075 * annotationMenuItem.addActionListener(new ActionListener() { public void
1076 * actionPerformed(ActionEvent actionEvent) {
1077 * annotationMenuItem_actionPerformed(actionEvent); } });
1079 groupMenu.add(sequenceSelDetails);
1082 this.add(structureMenu);
1083 groupMenu.add(editMenu);
1084 groupMenu.add(outputMenu);
1085 groupMenu.add(sequenceFeature);
1086 groupMenu.add(jMenu1);
1087 sequenceMenu.add(sequenceName);
1088 sequenceMenu.add(sequenceDetails);
1089 colourMenu.add(textColour);
1090 colourMenu.add(noColourmenuItem);
1091 colourMenu.add(clustalColour);
1092 colourMenu.add(BLOSUM62Colour);
1093 colourMenu.add(PIDColour);
1094 colourMenu.add(zappoColour);
1095 colourMenu.add(taylorColour);
1096 colourMenu.add(hydrophobicityColour);
1097 colourMenu.add(helixColour);
1098 colourMenu.add(strandColour);
1099 colourMenu.add(turnColour);
1100 colourMenu.add(buriedColour);
1101 colourMenu.add(nucleotideMenuItem);
1102 if (ap.getAlignment().isNucleotide()) {
1103 colourMenu.add(purinePyrimidineColour);
1105 // colourMenu.add(covariationColour);
1106 colourMenu.add(userDefinedColour);
1108 if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null)
1110 java.util.Enumeration userColours = jalview.gui.UserDefinedColours
1111 .getUserColourSchemes().keys();
1113 while (userColours.hasMoreElements())
1115 JMenuItem item = new JMenuItem(userColours.nextElement().toString());
1116 item.addActionListener(new ActionListener()
1118 public void actionPerformed(ActionEvent evt)
1120 userDefinedColour_actionPerformed(evt);
1123 colourMenu.add(item);
1127 colourMenu.addSeparator();
1128 colourMenu.add(abovePIDColour);
1129 colourMenu.add(conservationMenuItem);
1130 // colourMenu.add(annotationMenuItem);
1133 editMenu.add(editSequence);
1134 editMenu.add(upperCase);
1135 editMenu.add(lowerCase);
1136 editMenu.add(toggle);
1137 pdbMenu.add(pdbFromFile);
1138 pdbMenu.add(enterPDB);
1139 pdbMenu.add(discoverPDB);
1140 jMenu1.add(groupName);
1141 jMenu1.add(unGroupMenuItem);
1142 jMenu1.add(colourMenu);
1143 jMenu1.add(showBoxes);
1144 jMenu1.add(showText);
1145 jMenu1.add(showColourText);
1146 jMenu1.add(outline);
1147 jMenu1.add(displayNonconserved);
1148 structureMenu.add(pdbMenu);
1149 structureMenu.add(viewStructureMenu);
1150 // structureMenu.add(colStructureMenu);
1151 noColourmenuItem.setText("None");
1152 noColourmenuItem.addActionListener(new java.awt.event.ActionListener()
1154 public void actionPerformed(ActionEvent e)
1156 noColourmenuItem_actionPerformed();
1160 clustalColour.setText("Clustalx colours");
1161 clustalColour.addActionListener(new java.awt.event.ActionListener()
1163 public void actionPerformed(ActionEvent e)
1165 clustalColour_actionPerformed();
1168 zappoColour.setText("Zappo");
1169 zappoColour.addActionListener(new java.awt.event.ActionListener()
1171 public void actionPerformed(ActionEvent e)
1173 zappoColour_actionPerformed();
1176 taylorColour.setText("Taylor");
1177 taylorColour.addActionListener(new java.awt.event.ActionListener()
1179 public void actionPerformed(ActionEvent e)
1181 taylorColour_actionPerformed();
1184 hydrophobicityColour.setText("Hydrophobicity");
1185 hydrophobicityColour
1186 .addActionListener(new java.awt.event.ActionListener()
1188 public void actionPerformed(ActionEvent e)
1190 hydrophobicityColour_actionPerformed();
1193 helixColour.setText("Helix propensity");
1194 helixColour.addActionListener(new java.awt.event.ActionListener()
1196 public void actionPerformed(ActionEvent e)
1198 helixColour_actionPerformed();
1201 strandColour.setText("Strand propensity");
1202 strandColour.addActionListener(new java.awt.event.ActionListener()
1204 public void actionPerformed(ActionEvent e)
1206 strandColour_actionPerformed();
1209 turnColour.setText("Turn propensity");
1210 turnColour.addActionListener(new java.awt.event.ActionListener()
1212 public void actionPerformed(ActionEvent e)
1214 turnColour_actionPerformed();
1217 buriedColour.setText("Buried Index");
1218 buriedColour.addActionListener(new java.awt.event.ActionListener()
1220 public void actionPerformed(ActionEvent e)
1222 buriedColour_actionPerformed();
1225 abovePIDColour.setText("Above % Identity");
1226 abovePIDColour.addActionListener(new java.awt.event.ActionListener()
1228 public void actionPerformed(ActionEvent e)
1230 abovePIDColour_actionPerformed();
1233 userDefinedColour.setText("User Defined...");
1234 userDefinedColour.addActionListener(new java.awt.event.ActionListener()
1236 public void actionPerformed(ActionEvent e)
1238 userDefinedColour_actionPerformed(e);
1241 PIDColour.setText("Percentage Identity");
1242 PIDColour.addActionListener(new java.awt.event.ActionListener()
1244 public void actionPerformed(ActionEvent e)
1246 PIDColour_actionPerformed();
1249 BLOSUM62Colour.setText("BLOSUM62");
1250 BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener()
1252 public void actionPerformed(ActionEvent e)
1254 BLOSUM62Colour_actionPerformed();
1257 purinePyrimidineColour.setText("Purine/Pyrimidine");
1258 purinePyrimidineColour
1259 .addActionListener(new java.awt.event.ActionListener()
1261 public void actionPerformed(ActionEvent e)
1263 purinePyrimidineColour_actionPerformed();
1267 * covariationColour.addActionListener(new java.awt.event.ActionListener() {
1268 * public void actionPerformed(ActionEvent e) {
1269 * covariationColour_actionPerformed(); } });
1272 conservationMenuItem.setText("Conservation");
1273 conservationMenuItem
1274 .addActionListener(new java.awt.event.ActionListener()
1276 public void actionPerformed(ActionEvent e)
1278 conservationMenuItem_actionPerformed();
1283 protected void sequenceSelectionDetails_actionPerformed()
1285 createSequenceDetailsReport(ap.av.getSequenceSelection());
1288 protected void sequenceDetails_actionPerformed()
1290 createSequenceDetailsReport(new SequenceI[]{sequence});
1292 public void createSequenceDetailsReport(SequenceI[] sequences)
1294 CutAndPasteHtmlTransfer cap = new CutAndPasteHtmlTransfer();
1295 StringBuffer contents = new StringBuffer();
1296 for (SequenceI seq:sequences)
1298 contents.append("<p><h2>Annotation for "+seq.getDisplayId(true)+"</h2></p><p>");
1299 new SequenceAnnotationReport(null)
1300 .createSequenceAnnotationReport(
1305 (ap.seqPanel.seqCanvas.fr != null) ? ap.seqPanel.seqCanvas.fr.minmax
1307 contents.append("</p>");
1309 cap.setText("<html>" + contents.toString() + "</html>");
1311 Desktop.instance.addInternalFrame(cap,
1312 "Sequence Details for " + (sequences.length==1 ? sequences[0].getDisplayId(true) : "Selection")
1317 protected void showNonconserved_actionPerformed()
1319 getGroup().setShowNonconserved(displayNonconserved.isSelected());
1324 * call to refresh view after settings change
1328 ap.updateAnnotation();
1329 ap.paintAlignment(true);
1331 PaintRefresher.Refresh(this, ap.av.getSequenceSetId());
1340 protected void clustalColour_actionPerformed()
1342 SequenceGroup sg = getGroup();
1343 sg.cs = new ClustalxColourScheme(
1344 sg,ap.av.getHiddenRepSequences());
1354 protected void zappoColour_actionPerformed()
1356 getGroup().cs = new ZappoColourScheme();
1366 protected void taylorColour_actionPerformed()
1368 getGroup().cs = new TaylorColourScheme();
1378 protected void hydrophobicityColour_actionPerformed()
1380 getGroup().cs = new HydrophobicColourScheme();
1390 protected void helixColour_actionPerformed()
1392 getGroup().cs = new HelixColourScheme();
1402 protected void strandColour_actionPerformed()
1404 getGroup().cs = new StrandColourScheme();
1414 protected void turnColour_actionPerformed()
1416 getGroup().cs = new TurnColourScheme();
1426 protected void buriedColour_actionPerformed()
1428 getGroup().cs = new BuriedColourScheme();
1438 public void nucleotideMenuItem_actionPerformed()
1440 getGroup().cs = new NucleotideColourScheme();
1444 protected void purinePyrimidineColour_actionPerformed()
1446 getGroup().cs = new PurinePyrimidineColourScheme();
1451 * protected void covariationColour_actionPerformed() { getGroup().cs = new
1452 * CovariationColourScheme(sequence.getAnnotation()[0]); refresh(); }
1460 protected void abovePIDColour_actionPerformed()
1462 SequenceGroup sg = getGroup();
1468 if (abovePIDColour.isSelected())
1470 sg.cs.setConsensus(AAFrequency.calculate(
1471 sg.getSequences(ap.av.getHiddenRepSequences()), sg.getStartRes(),
1472 sg.getEndRes() + 1));
1474 int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
1477 sg.cs.setThreshold(threshold, ap.av.getIgnoreGapsConsensus());
1479 SliderPanel.showPIDSlider();
1482 // remove PIDColouring
1484 sg.cs.setThreshold(0, ap.av.getIgnoreGapsConsensus());
1496 protected void userDefinedColour_actionPerformed(ActionEvent e)
1498 SequenceGroup sg = getGroup();
1500 if (e.getActionCommand().equals("User Defined..."))
1502 new UserDefinedColours(ap, sg);
1506 UserColourScheme udc = (UserColourScheme) UserDefinedColours
1507 .getUserColourSchemes().get(e.getActionCommand());
1520 protected void PIDColour_actionPerformed()
1522 SequenceGroup sg = getGroup();
1523 sg.cs = new PIDColourScheme();
1524 sg.cs.setConsensus(AAFrequency.calculate(
1525 sg.getSequences(ap.av.getHiddenRepSequences()), sg.getStartRes(),
1526 sg.getEndRes() + 1));
1536 protected void BLOSUM62Colour_actionPerformed()
1538 SequenceGroup sg = getGroup();
1540 sg.cs = new Blosum62ColourScheme();
1542 sg.cs.setConsensus(AAFrequency.calculate(
1543 sg.getSequences(ap.av.getHiddenRepSequences()), sg.getStartRes(),
1544 sg.getEndRes() + 1));
1555 protected void noColourmenuItem_actionPerformed()
1557 getGroup().cs = null;
1567 protected void conservationMenuItem_actionPerformed()
1569 SequenceGroup sg = getGroup();
1575 if (conservationMenuItem.isSelected())
1577 Conservation c = new Conservation("Group",
1578 ResidueProperties.propHash, 3,
1579 sg.getSequences(ap.av.getHiddenRepSequences()), sg.getStartRes(),
1580 sg.getEndRes() + 1);
1583 c.verdict(false, ap.av.getConsPercGaps());
1585 sg.cs.setConservation(c);
1587 SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
1588 SliderPanel.showConservationSlider();
1591 // remove ConservationColouring
1593 sg.cs.setConservation(null);
1599 public void annotationMenuItem_actionPerformed(ActionEvent actionEvent)
1601 SequenceGroup sg = getGroup();
1607 AnnotationColourGradient acg = new AnnotationColourGradient(
1608 sequence.getAnnotation()[0], null,
1609 AnnotationColourGradient.NO_THRESHOLD);
1611 acg.predefinedColours = true;
1623 protected void groupName_actionPerformed()
1626 SequenceGroup sg = getGroup();
1627 EditNameDialog dialog = new EditNameDialog(sg.getName(),
1628 sg.getDescription(), " Group Name ",
1629 "Group Description ", "Edit Group Name/Description",
1637 sg.setName(dialog.getName());
1638 sg.setDescription(dialog.getDescription());
1643 * Get selection group - adding it to the alignment if necessary.
1645 * @return sequence group to operate on
1647 SequenceGroup getGroup()
1649 SequenceGroup sg = ap.av.getSelectionGroup();
1650 // this method won't add a new group if it already exists
1653 ap.av.getAlignment().addGroup(sg);
1665 void sequenceName_actionPerformed()
1667 EditNameDialog dialog = new EditNameDialog(sequence.getName(),
1668 sequence.getDescription(), " Sequence Name ",
1669 "Sequence Description ", "Edit Sequence Name/Description",
1677 if (dialog.getName() != null)
1679 if (dialog.getName().indexOf(" ") > -1)
1681 JOptionPane.showMessageDialog(ap,
1682 "Spaces have been converted to \"_\"",
1683 "No spaces allowed in Sequence Name",
1684 JOptionPane.WARNING_MESSAGE);
1687 sequence.setName(dialog.getName().replace(' ', '_'));
1688 ap.paintAlignment(false);
1691 sequence.setDescription(dialog.getDescription());
1693 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1704 void unGroupMenuItem_actionPerformed()
1706 SequenceGroup sg = ap.av.getSelectionGroup();
1707 ap.av.getAlignment().deleteGroup(sg);
1708 ap.av.setSelectionGroup(null);
1718 protected void outline_actionPerformed()
1720 SequenceGroup sg = getGroup();
1721 Color col = JColorChooser.showDialog(this, "Select Outline Colour",
1726 sg.setOutlineColour(col);
1738 public void showBoxes_actionPerformed()
1740 getGroup().setDisplayBoxes(showBoxes.isSelected());
1750 public void showText_actionPerformed()
1752 getGroup().setDisplayText(showText.isSelected());
1762 public void showColourText_actionPerformed()
1764 getGroup().setColourText(showColourText.isSelected());
1768 public void showLink(String url)
1772 jalview.util.BrowserLauncher.openURL(url);
1773 } catch (Exception ex)
1776 .showInternalMessageDialog(
1778 "Unixers: Couldn't find default web browser."
1779 + "\nAdd the full path to your browser in Preferences.",
1780 "Web browser not found", JOptionPane.WARNING_MESSAGE);
1782 ex.printStackTrace();
1786 void hideSequences(boolean representGroup)
1788 SequenceGroup sg = ap.av.getSelectionGroup();
1789 if (sg == null || sg.getSize() < 1)
1791 ap.av.hideSequence(new SequenceI[]
1796 ap.av.setSelectionGroup(null);
1800 ap.av.hideRepSequences(sequence, sg);
1805 int gsize = sg.getSize();
1808 hseqs = new SequenceI[gsize];
1811 for (int i = 0; i < gsize; i++)
1813 hseqs[index++] = sg.getSequenceAt(i);
1816 ap.av.hideSequence(hseqs);
1817 // refresh(); TODO: ? needed ?
1818 ap.av.sendSelection();
1821 public void copy_actionPerformed()
1823 ap.alignFrame.copy_actionPerformed(null);
1826 public void cut_actionPerformed()
1828 ap.alignFrame.cut_actionPerformed(null);
1831 void changeCase(ActionEvent e)
1833 Object source = e.getSource();
1834 SequenceGroup sg = ap.av.getSelectionGroup();
1838 int[][] startEnd = ap.av.getVisibleRegionBoundaries(sg.getStartRes(),
1839 sg.getEndRes() + 1);
1844 if (source == toggle)
1846 description = "Toggle Case";
1847 caseChange = ChangeCaseCommand.TOGGLE_CASE;
1849 else if (source == upperCase)
1851 description = "To Upper Case";
1852 caseChange = ChangeCaseCommand.TO_UPPER;
1856 description = "To Lower Case";
1857 caseChange = ChangeCaseCommand.TO_LOWER;
1860 ChangeCaseCommand caseCommand = new ChangeCaseCommand(description,
1861 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()), startEnd,
1864 ap.alignFrame.addHistoryItem(caseCommand);
1866 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1872 public void outputText_actionPerformed(ActionEvent e)
1874 CutAndPasteTransfer cap = new CutAndPasteTransfer();
1875 cap.setForInput(null);
1876 Desktop.addInternalFrame(cap,
1877 "Alignment output - " + e.getActionCommand(), 600, 500);
1879 String[] omitHidden = null;
1881 System.out.println("PROMPT USER HERE"); // TODO: decide if a prompt happens
1882 // or we simply trust the user wants
1883 // wysiwig behaviour
1884 SequenceGroup sg = ap.av.getSelectionGroup();
1885 ColumnSelection csel = new ColumnSelection(ap.av.getColumnSelection());
1886 omitHidden = ap.av.getViewAsString(true);
1887 Alignment oal = new Alignment(ap.av.getSequenceSelection());
1888 AlignmentAnnotation[] nala = ap.av.getAlignment().getAlignmentAnnotation();
1891 for (int i = 0; i < nala.length; i++)
1893 AlignmentAnnotation na = nala[i];
1894 oal.addAnnotation(na);
1897 cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(),
1898 oal, omitHidden, csel, sg));
1902 public void pdbFromFile_actionPerformed()
1904 jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(
1905 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
1906 chooser.setFileView(new jalview.io.JalviewFileView());
1907 chooser.setDialogTitle("Select a PDB file for "+sequence.getDisplayId(false));
1908 chooser.setToolTipText("Load a PDB file and associate it with sequence '"+sequence.getDisplayId(false)+"'");
1910 int value = chooser.showOpenDialog(null);
1912 if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
1914 String choice = chooser.getSelectedFile().getPath();
1915 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
1916 new AssociatePdbFileWithSeq().associatePdbWithSeq(choice, jalview.io.AppletFormatAdapter.FILE, sequence, true);
1921 public void enterPDB_actionPerformed()
1923 String id = JOptionPane.showInternalInputDialog(Desktop.desktop,
1924 "Enter PDB Id", "Enter PDB Id", JOptionPane.QUESTION_MESSAGE);
1926 if (id != null && id.length() > 0)
1928 PDBEntry entry = new PDBEntry();
1929 entry.setId(id.toUpperCase());
1930 sequence.getDatasetSequence().addPDBId(entry);
1934 public void discoverPDB_actionPerformed()
1937 final SequenceI[] sequences = ((ap.av.getSelectionGroup() == null) ? new SequenceI[]
1939 : ap.av.getSequenceSelection());
1940 Thread discpdb = new Thread(new Runnable()
1945 new jalview.ws.DBRefFetcher(sequences, ap.alignFrame)
1946 .fetchDBRefs(false);
1953 public void sequenceFeature_actionPerformed()
1955 SequenceGroup sg = ap.av.getSelectionGroup();
1961 int rsize = 0, gSize = sg.getSize();
1962 SequenceI[] rseqs, seqs = new SequenceI[gSize];
1963 SequenceFeature[] tfeatures, features = new SequenceFeature[gSize];
1965 for (int i = 0; i < gSize; i++)
1967 int start = sg.getSequenceAt(i).findPosition(sg.getStartRes());
1968 int end = sg.findEndRes(sg.getSequenceAt(i));
1971 seqs[rsize] = sg.getSequenceAt(i).getDatasetSequence();
1972 features[rsize] = new SequenceFeature(null, null, null, start, end,
1977 rseqs = new SequenceI[rsize];
1978 tfeatures = new SequenceFeature[rsize];
1979 System.arraycopy(seqs, 0, rseqs, 0, rsize);
1980 System.arraycopy(features, 0, tfeatures, 0, rsize);
1981 features = tfeatures;
1983 if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs,
1984 features, true, ap))
1986 ap.alignFrame.setShowSeqFeatures(true);
1987 ap.highlightSearchResults(null);
1991 public void textColour_actionPerformed()
1993 SequenceGroup sg = getGroup();
1996 new TextColourChooser().chooseColour(ap, sg);
2000 public void colourByStructure(String pdbid)
2002 Annotation[] anots = ap.av.getStructureSelectionManager().colourSequenceFromStructure(
2005 AlignmentAnnotation an = new AlignmentAnnotation("Structure",
2006 "Coloured by " + pdbid, anots);
2008 ap.av.getAlignment().addAnnotation(an);
2009 an.createSequenceMapping(sequence, 0, true);
2010 // an.adjustForAlignment();
2011 ap.av.getAlignment().setAnnotationIndex(an, 0);
2013 ap.adjustAnnotationHeight();
2015 sequence.addAlignmentAnnotation(an);
2019 public void editSequence_actionPerformed(ActionEvent actionEvent)
2021 SequenceGroup sg = ap.av.getSelectionGroup();
2025 if (sequence == null)
2026 sequence = (Sequence) sg.getSequenceAt(0);
2028 EditNameDialog dialog = new EditNameDialog(
2029 sequence.getSequenceAsString(sg.getStartRes(),
2030 sg.getEndRes() + 1), null, "Edit Sequence ", null,
2031 "Edit Sequence", ap.alignFrame);
2035 EditCommand editCommand = new EditCommand("Edit Sequences",
2036 EditCommand.REPLACE, dialog.getName().replace(' ',
2037 ap.av.getGapCharacter()),
2038 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
2039 sg.getStartRes(), sg.getEndRes() + 1, ap.av.getAlignment());
2041 ap.alignFrame.addHistoryItem(editCommand);
2043 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()