2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ 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
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.appletgui;
23 import jalview.analysis.AlignmentSorter;
24 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
25 import jalview.api.AlignViewControllerGuiI;
26 import jalview.api.AlignViewControllerI;
27 import jalview.api.AlignViewportI;
28 import jalview.api.FeatureRenderer;
29 import jalview.api.FeatureSettingsControllerI;
30 import jalview.api.SequenceStructureBinding;
31 import jalview.bin.JalviewLite;
32 import jalview.commands.CommandI;
33 import jalview.commands.EditCommand;
34 import jalview.commands.EditCommand.Action;
35 import jalview.commands.OrderCommand;
36 import jalview.commands.RemoveGapColCommand;
37 import jalview.commands.RemoveGapsCommand;
38 import jalview.commands.SlideSequencesCommand;
39 import jalview.commands.TrimRegionCommand;
40 import jalview.datamodel.Alignment;
41 import jalview.datamodel.AlignmentAnnotation;
42 import jalview.datamodel.AlignmentI;
43 import jalview.datamodel.AlignmentOrder;
44 import jalview.datamodel.ColumnSelection;
45 import jalview.datamodel.PDBEntry;
46 import jalview.datamodel.Sequence;
47 import jalview.datamodel.SequenceGroup;
48 import jalview.datamodel.SequenceI;
49 import jalview.io.AnnotationFile;
50 import jalview.io.AppletFormatAdapter;
51 import jalview.io.FeaturesFile;
52 import jalview.io.TCoffeeScoreFile;
53 import jalview.schemes.Blosum62ColourScheme;
54 import jalview.schemes.BuriedColourScheme;
55 import jalview.schemes.ClustalxColourScheme;
56 import jalview.schemes.ColourSchemeI;
57 import jalview.schemes.HelixColourScheme;
58 import jalview.schemes.HydrophobicColourScheme;
59 import jalview.schemes.NucleotideColourScheme;
60 import jalview.schemes.PIDColourScheme;
61 import jalview.schemes.PurinePyrimidineColourScheme;
62 import jalview.schemes.RNAHelicesColourChooser;
63 import jalview.schemes.RNAInteractionColourScheme;
64 import jalview.schemes.StrandColourScheme;
65 import jalview.schemes.TCoffeeColourScheme;
66 import jalview.schemes.TaylorColourScheme;
67 import jalview.schemes.TurnColourScheme;
68 import jalview.schemes.ZappoColourScheme;
69 import jalview.structure.StructureSelectionManager;
70 import jalview.structures.models.AAStructureBindingModel;
71 import jalview.util.MappingUtils;
72 import jalview.util.MessageManager;
73 import jalview.viewmodel.AlignmentViewport;
75 import java.awt.BorderLayout;
76 import java.awt.Canvas;
77 import java.awt.CheckboxMenuItem;
78 import java.awt.Color;
80 import java.awt.FontMetrics;
81 import java.awt.Frame;
82 import java.awt.Graphics;
83 import java.awt.Label;
85 import java.awt.MenuBar;
86 import java.awt.MenuItem;
87 import java.awt.event.ActionEvent;
88 import java.awt.event.ActionListener;
89 import java.awt.event.FocusEvent;
90 import java.awt.event.FocusListener;
91 import java.awt.event.ItemEvent;
92 import java.awt.event.ItemListener;
93 import java.awt.event.KeyEvent;
94 import java.awt.event.KeyListener;
95 import java.awt.event.WindowAdapter;
96 import java.awt.event.WindowEvent;
97 import java.io.IOException;
99 import java.net.URLEncoder;
100 import java.util.Arrays;
101 import java.util.Deque;
102 import java.util.HashMap;
103 import java.util.Hashtable;
104 import java.util.List;
105 import java.util.Map;
106 import java.util.StringTokenizer;
107 import java.util.Vector;
109 import org.jmol.viewer.Viewer;
111 public class AlignFrame extends EmbmenuFrame implements ActionListener,
112 ItemListener, KeyListener, AlignViewControllerGuiI
114 public AlignViewControllerI avc;
116 public AlignmentPanel alignPanel;
118 public AlignViewport viewport;
120 // width and height may be overridden by applet parameters
121 int frameWidth = 700;
123 int frameHeight = 500;
125 String jalviewServletURL;
128 * Flag for showing autocalculated consensus above or below other consensus
131 private boolean showAutoCalculatedAbove;
133 private SequenceAnnotationOrder annotationSortOrder;
136 * Constructor that creates the frame and adds it to the display.
143 public AlignFrame(AlignmentI al, JalviewLite applet,
144 String title, boolean embedded)
146 this(al, applet, title, embedded, true);
150 * Constructor that optionally allows the frame to be displayed or only
157 * @param addToDisplay
159 public AlignFrame(AlignmentI al, JalviewLite applet,
160 String title, boolean embedded, boolean addToDisplay)
162 this(al, null, null, applet, title, embedded, addToDisplay);
165 public AlignFrame(AlignmentI al, SequenceI[] hiddenSeqs,
166 ColumnSelection columnSelection, JalviewLite applet,
167 String title, boolean embedded)
169 this(al, hiddenSeqs, columnSelection, applet, title, embedded, true);
172 public AlignFrame(AlignmentI al, SequenceI[] hiddenSeqs,
173 ColumnSelection columnSelection, JalviewLite applet,
174 String title, boolean embedded, boolean addToDisplay)
178 jalviewServletURL = applet.getParameter("APPLICATION_URL");
184 } catch (Exception ex)
186 ex.printStackTrace();
188 // need to get window geometry before we calculate alignment layout
194 param = applet.getParameter("windowWidth");
197 int width = Integer.parseInt(param);
200 param = applet.getParameter("windowHeight");
203 int height = Integer.parseInt(param);
204 frameHeight = height;
206 } catch (Exception ex)
210 viewport = new AlignViewport(al, applet);
212 if (hiddenSeqs != null && hiddenSeqs.length > 0)
214 viewport.hideSequence(hiddenSeqs);
216 if (columnSelection != null)
218 viewport.setColumnSelection(columnSelection);
221 alignPanel = new AlignmentPanel(this, viewport);
222 avc = new jalview.controller.AlignViewController(this, viewport,
224 viewport.updateConservation(alignPanel);
225 viewport.updateConsensus(alignPanel);
227 displayNonconservedMenuItem.setState(viewport.getShowUnconserved());
228 followMouseOverFlag.setState(viewport.isFollowHighlight());
229 showGroupConsensus.setState(viewport.isShowGroupConsensus());
230 showGroupConservation.setState(viewport.isShowGroupConservation());
231 showConsensusHistogram.setState(viewport.isShowConsensusHistogram());
232 showSequenceLogo.setState(viewport.isShowSequenceLogo());
233 normSequenceLogo.setState(viewport.isNormaliseSequenceLogo());
234 applyToAllGroups.setState(viewport.getColourAppliesToAllGroups());
235 annotationPanelMenuItem.setState(viewport.isShowAnnotation());
236 showAlignmentAnnotations.setState(viewport.isShowAnnotation());
237 showSequenceAnnotations.setState(viewport.isShowAnnotation());
239 seqLimits.setState(viewport.getShowJVSuffix());
243 String param = applet.getParameter("sortBy");
246 if (param.equalsIgnoreCase("Id"))
248 sortIDMenuItem_actionPerformed();
250 else if (param.equalsIgnoreCase("Pairwise Identity"))
252 sortPairwiseMenuItem_actionPerformed();
254 else if (param.equalsIgnoreCase("Length"))
256 sortLengthMenuItem_actionPerformed();
260 param = applet.getParameter("wrap");
263 if (param.equalsIgnoreCase("true"))
265 wrapMenuItem.setState(true);
266 wrapMenuItem_actionPerformed();
269 param = applet.getParameter("centrecolumnlabels");
272 centreColumnLabelFlag.setState(true);
273 centreColumnLabelFlag_stateChanged();
277 if (viewport.getAlignment().isNucleotide())
279 viewport.updateStrucConsensus(alignPanel);
280 if (viewport.getAlignment().hasRNAStructure())
282 RNAHelixColour.setEnabled(true);
286 RNAHelixColour.setEnabled(false);
291 RNAHelixColour.setEnabled(false);
292 purinePyrimidineColour.setEnabled(false);
294 // Some JVMS send keyevents to Top frame or lowest panel,
295 // Havent worked out why yet. So add to both this frame and seqCanvas for
297 this.addKeyListener(this);
298 alignPanel.seqPanel.seqCanvas.addKeyListener(this);
299 alignPanel.idPanel.idCanvas.addKeyListener(this);
300 alignPanel.scalePanel.addKeyListener(this);
301 alignPanel.annotationPanel.addKeyListener(this);
302 alignPanel.annotationPanelHolder.addKeyListener(this);
303 alignPanel.annotationSpaceFillerHolder.addKeyListener(this);
304 alignPanel.alabels.addKeyListener(this);
308 addToDisplay(embedded);
315 public void addToDisplay(boolean embedded)
317 createAlignFrameWindow(embedded);
319 alignPanel.adjustAnnotationHeight();
320 alignPanel.paintAlignment(true);
323 public AlignViewport getAlignViewport()
328 public SeqCanvas getSeqcanvas()
330 return alignPanel.seqPanel.seqCanvas;
334 * Load a features file onto the alignment
337 * file URL, content, or other resolvable path
339 * is protocol for accessing data referred to by file
342 public boolean parseFeaturesFile(String file, String type)
344 return parseFeaturesFile(file, type, true);
348 * Load a features file onto the alignment
351 * file URL, content, or other resolvable path
353 * is protocol for accessing data referred to by file
354 * @param autoenabledisplay
355 * when true, display features flag will be automatically enabled if
356 * features are loaded
357 * @return true if data parsed as a features file
359 public boolean parseFeaturesFile(String file, String type,
360 boolean autoenabledisplay)
362 // TODO: test if importing a features file onto an alignment which already
363 // has features with links overwrites the original links.
365 Hashtable featureLinks = new Hashtable();
366 boolean featuresFile = false;
369 featuresFile = new jalview.io.FeaturesFile(file, type)
370 .parse(viewport.getAlignment(), alignPanel.seqPanel.seqCanvas
371 .getFeatureRenderer().getFeatureColours(), featureLinks,
372 true, viewport.applet.getDefaultParameter(
373 "relaxedidmatch", false));
374 } catch (Exception ex)
376 ex.printStackTrace();
381 if (featureLinks.size() > 0)
383 alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featureLinks = featureLinks;
385 if (autoenabledisplay)
387 viewport.setShowSequenceFeatures(true);
388 sequenceFeatures.setState(true);
390 if (alignPanel.seqPanel.seqCanvas.fr != null)
392 // update the min/max ranges where necessary
393 alignPanel.seqPanel.seqCanvas.fr.findAllFeatures(true);
395 if (viewport.featureSettings != null)
397 viewport.featureSettings.refreshTable();
399 alignPanel.paintAlignment(true);
400 statusBar.setText(MessageManager
401 .getString("label.successfully_added_features_alignment"));
407 public void keyPressed(KeyEvent evt)
409 if (viewport.cursorMode
410 && ((evt.getKeyCode() >= KeyEvent.VK_0 && evt.getKeyCode() <= KeyEvent.VK_9) || (evt
411 .getKeyCode() >= KeyEvent.VK_NUMPAD0 && evt
412 .getKeyCode() <= KeyEvent.VK_NUMPAD9))
413 && Character.isDigit(evt.getKeyChar()))
415 alignPanel.seqPanel.numberPressed(evt.getKeyChar());
418 switch (evt.getKeyCode())
420 case 27: // escape key
421 deselectAllSequenceMenuItem_actionPerformed();
423 alignPanel.alabels.cancelDrag();
426 if (evt.isControlDown() || evt.isMetaDown())
428 cut_actionPerformed();
432 if (viewport.cursorMode && !evt.isControlDown())
434 alignPanel.seqPanel.setCursorColumn();
436 if (evt.isControlDown() || evt.isMetaDown())
438 copy_actionPerformed();
442 if (evt.isControlDown())
444 paste(evt.isShiftDown());
448 if (evt.isControlDown() || evt.isMetaDown())
450 selectAllSequenceMenuItem_actionPerformed();
453 case KeyEvent.VK_DOWN:
454 if (viewport.cursorMode)
456 alignPanel.seqPanel.moveCursor(0, 1);
460 moveSelectedSequences(false);
465 if (viewport.cursorMode)
467 alignPanel.seqPanel.moveCursor(0, -1);
471 moveSelectedSequences(true);
475 case KeyEvent.VK_LEFT:
476 if (evt.isAltDown() || !viewport.cursorMode)
478 slideSequences(false, alignPanel.seqPanel.getKeyboardNo1());
482 alignPanel.seqPanel.moveCursor(-1, 0);
486 case KeyEvent.VK_RIGHT:
487 if (evt.isAltDown() || !viewport.cursorMode)
489 slideSequences(true, alignPanel.seqPanel.getKeyboardNo1());
493 alignPanel.seqPanel.moveCursor(1, 0);
497 case KeyEvent.VK_SPACE:
498 if (viewport.cursorMode)
500 alignPanel.seqPanel.insertGapAtCursor(evt.isControlDown()
501 || evt.isShiftDown() || evt.isAltDown());
505 case KeyEvent.VK_DELETE:
506 case KeyEvent.VK_BACK_SPACE:
507 if (viewport.cursorMode)
509 alignPanel.seqPanel.deleteGapAtCursor(evt.isControlDown()
510 || evt.isShiftDown() || evt.isAltDown());
514 cut_actionPerformed();
515 alignPanel.seqPanel.seqCanvas.repaint();
520 if (viewport.cursorMode)
522 alignPanel.seqPanel.setCursorRow();
526 if (viewport.cursorMode)
528 alignPanel.seqPanel.setCursorPosition();
532 case KeyEvent.VK_ENTER:
533 case KeyEvent.VK_COMMA:
534 if (viewport.cursorMode)
536 alignPanel.seqPanel.setCursorRowAndColumn();
541 if (viewport.cursorMode)
543 alignPanel.seqPanel.setSelectionAreaAtCursor(true);
547 if (viewport.cursorMode)
549 alignPanel.seqPanel.setSelectionAreaAtCursor(false);
554 viewport.cursorMode = !viewport.cursorMode;
555 statusBar.setText(MessageManager.formatMessage(
556 "label.keyboard_editing_mode", new String[]
557 { (viewport.cursorMode ? "on" : "off") }));
558 if (viewport.cursorMode)
560 alignPanel.seqPanel.seqCanvas.cursorX = viewport.startRes;
561 alignPanel.seqPanel.seqCanvas.cursorY = viewport.startSeq;
566 if (evt.isControlDown())
568 findMenuItem_actionPerformed();
574 boolean toggleSeqs = !evt.isControlDown();
575 boolean toggleCols = !evt.isShiftDown();
576 toggleHiddenRegions(toggleSeqs, toggleCols);
580 case KeyEvent.VK_PAGE_UP:
581 if (viewport.getWrapAlignment())
583 alignPanel.scrollUp(true);
587 alignPanel.setScrollValues(viewport.startRes, viewport.startSeq
588 - viewport.endSeq + viewport.startSeq);
592 case KeyEvent.VK_PAGE_DOWN:
593 if (viewport.getWrapAlignment())
595 alignPanel.scrollUp(false);
599 alignPanel.setScrollValues(viewport.startRes, viewport.startSeq
600 + viewport.endSeq - viewport.startSeq);
605 if (evt.isControlDown())
607 undoMenuItem_actionPerformed();
612 if (evt.isControlDown())
614 redoMenuItem_actionPerformed();
619 if (evt.isControlDown())
626 if (evt.isControlDown())
628 trimAlignment(false);
633 if (evt.isControlDown())
635 if (evt.isShiftDown())
637 this.removeAllGapsMenuItem_actionPerformed();
641 removeGappedColumnMenuItem_actionPerformed();
646 if (evt.isControlDown())
650 invertColSel_actionPerformed();
654 invertSequenceMenuItem_actionPerformed();
660 if (evt.isControlDown())
662 if (evt.isShiftDown())
664 this.unGroup_actionPerformed();
668 this.createGroup_actionPerformed();
674 if (evt.isControlDown())
676 this.deleteGroups_actionPerformed();
681 if (evt.isControlDown())
688 alignPanel.paintAlignment(true);
692 * called by key handler and the hide all/show all menu items
697 private void toggleHiddenRegions(boolean toggleSeqs, boolean toggleCols)
699 boolean hide = false;
700 SequenceGroup sg = viewport.getSelectionGroup();
701 if (!toggleSeqs && !toggleCols)
703 // Hide everything by the current selection - this is a hack - we do the
704 // invert and then hide
705 // first check that there will be visible columns after the invert.
706 if ((viewport.getColumnSelection() != null
707 && viewport.getColumnSelection().getSelected() != null && viewport
708 .getColumnSelection().getSelected().size() > 0)
709 || (sg != null && sg.getSize() > 0 && sg.getStartRes() <= sg
712 // now invert the sequence set, if required - empty selection implies
713 // that no hiding is required.
716 invertSequenceMenuItem_actionPerformed();
717 sg = viewport.getSelectionGroup();
721 viewport.expandColSelection(sg, true);
722 // finally invert the column selection and get the new sequence
723 // selection and indicate it should be hidden.
724 invertColSel_actionPerformed();
731 if (sg != null && sg.getSize() != viewport.getAlignment().getHeight())
734 viewport.hideAllSelectedSeqs();
736 else if (!(toggleCols && viewport.getColumnSelection().getSelected()
739 viewport.showAllHiddenSeqs();
745 if (viewport.getColumnSelection().getSelected().size() > 0)
747 viewport.hideSelectedColumns();
750 viewport.setSelectionGroup(sg);
755 viewport.showAllHiddenColumns();
761 public void keyReleased(KeyEvent evt)
766 public void keyTyped(KeyEvent evt)
771 public void itemStateChanged(ItemEvent evt)
773 final Object source = evt.getSource();
774 if (source == displayNonconservedMenuItem)
776 displayNonconservedMenuItem_actionPerformed();
778 else if (source == colourTextMenuItem)
780 colourTextMenuItem_actionPerformed();
782 else if (source == wrapMenuItem)
784 wrapMenuItem_actionPerformed();
786 else if (source == scaleAbove)
788 viewport.setScaleAboveWrapped(scaleAbove.getState());
790 else if (source == scaleLeft)
792 viewport.setScaleLeftWrapped(scaleLeft.getState());
794 else if (source == scaleRight)
796 viewport.setScaleRightWrapped(scaleRight.getState());
798 else if (source == seqLimits)
800 seqLimits_itemStateChanged();
802 else if (source == viewBoxesMenuItem)
804 viewport.setShowBoxes(viewBoxesMenuItem.getState());
806 else if (source == viewTextMenuItem)
808 viewport.setShowText(viewTextMenuItem.getState());
810 else if (source == renderGapsMenuItem)
812 viewport.setRenderGaps(renderGapsMenuItem.getState());
814 else if (source == annotationPanelMenuItem)
816 viewport.setShowAnnotation(annotationPanelMenuItem.getState());
817 alignPanel.setAnnotationVisible(annotationPanelMenuItem.getState());
819 else if (source == sequenceFeatures)
821 viewport.setShowSequenceFeatures(sequenceFeatures.getState());
822 alignPanel.seqPanel.seqCanvas.repaint();
824 else if (source == showAlignmentAnnotations)
826 setAnnotationsVisibility();
828 else if (source == showSequenceAnnotations)
830 setAnnotationsVisibility();
832 else if (source == sortAnnBySequence)
834 boolean newState = sortAnnBySequence.getState();
835 sortAnnByLabel.setState(false);
836 setAnnotationSortOrder(newState ? SequenceAnnotationOrder.SEQUENCE_AND_LABEL
837 : SequenceAnnotationOrder.NONE);
838 setViewportAnnotationOrder();
840 else if (source == sortAnnByLabel)
842 boolean newState = sortAnnByLabel.getState();
843 sortAnnBySequence.setState(false);
844 setAnnotationSortOrder(newState ? SequenceAnnotationOrder.LABEL_AND_SEQUENCE
845 : SequenceAnnotationOrder.NONE);
846 setViewportAnnotationOrder();
848 else if (source == showAutoFirst)
850 showAutoLast.setState(!showAutoFirst.getState());
851 setShowAutoCalculatedAbove(showAutoFirst.getState());
852 setViewportAnnotationOrder();
854 else if (source == showAutoLast)
856 showAutoFirst.setState(!showAutoLast.getState());
857 setShowAutoCalculatedAbove(showAutoFirst.getState());
858 setViewportAnnotationOrder();
860 else if (source == conservationMenuItem)
862 conservationMenuItem_actionPerformed();
864 else if (source == abovePIDThreshold)
866 abovePIDThreshold_actionPerformed();
868 else if (source == applyToAllGroups)
870 viewport.setColourAppliesToAllGroups(applyToAllGroups.getState());
872 else if (source == autoCalculate)
874 viewport.autoCalculateConsensus = autoCalculate.getState();
876 else if (source == sortByTree)
878 viewport.sortByTree = sortByTree.getState();
880 else if (source == this.centreColumnLabelFlag)
882 centreColumnLabelFlag_stateChanged();
884 else if (source == this.followMouseOverFlag)
886 mouseOverFlag_stateChanged();
888 else if (source == showGroupConsensus)
890 showGroupConsensus_actionPerformed();
892 else if (source == showGroupConservation)
894 showGroupConservation_actionPerformed();
896 else if (source == showSequenceLogo)
898 showSequenceLogo_actionPerformed();
900 else if (source == normSequenceLogo)
902 normSequenceLogo_actionPerformed();
904 else if (source == showConsensusHistogram)
906 showConsensusHistogram_actionPerformed();
908 else if (source == applyAutoAnnotationSettings)
910 applyAutoAnnotationSettings_actionPerformed();
912 alignPanel.paintAlignment(true);
916 * Set the visibility state of sequence-related and/or alignment-related
917 * annotations depending on checkbox selections. Repaint after calling.
921 private void setAnnotationsVisibility()
923 boolean showForAlignment = showAlignmentAnnotations.getState();
924 boolean showForSequences = showSequenceAnnotations.getState();
925 for (AlignmentAnnotation aa : alignPanel.getAlignment()
926 .getAlignmentAnnotation())
928 boolean visible = (aa.sequenceRef == null ? showForAlignment
930 aa.visible = visible;
932 alignPanel.validateAnnotationDimensions(true);
937 private void setAnnotationSortOrder(SequenceAnnotationOrder order)
939 this.annotationSortOrder = order;
943 * Set flags on the viewport that control annotation ordering
945 private void setViewportAnnotationOrder()
947 this.alignPanel.av.setSortAnnotationsBy(this.annotationSortOrder);
949 .setShowAutocalculatedAbove(this.showAutoCalculatedAbove);
952 private void setShowAutoCalculatedAbove(boolean showAbove)
954 this.showAutoCalculatedAbove = showAbove;
957 private void mouseOverFlag_stateChanged()
959 viewport.setFollowHighlight(followMouseOverFlag.getState());
960 // TODO: could kick the scrollTo mechanism to reset view for current
964 private void centreColumnLabelFlag_stateChanged()
966 viewport.centreColumnLabels = centreColumnLabelFlag.getState();
967 this.alignPanel.annotationPanel.repaint();
971 public void actionPerformed(ActionEvent evt)
973 Object source = evt.getSource();
975 if (source == inputText)
977 inputText_actionPerformed();
979 else if (source == loadTree)
981 loadTree_actionPerformed();
983 else if (source == loadApplication)
985 launchFullApplication();
987 else if (source == loadAnnotations)
991 else if (source == outputAnnotations)
993 outputAnnotations(true);
995 else if (source == outputFeatures)
997 outputFeatures(true, "Jalview");
999 else if (source == closeMenuItem)
1001 closeMenuItem_actionPerformed();
1003 else if (source == copy)
1005 copy_actionPerformed();
1007 else if (source == undoMenuItem)
1009 undoMenuItem_actionPerformed();
1011 else if (source == redoMenuItem)
1013 redoMenuItem_actionPerformed();
1015 else if (source == inputText)
1017 inputText_actionPerformed();
1019 else if (source == closeMenuItem)
1021 closeMenuItem_actionPerformed();
1023 else if (source == undoMenuItem)
1025 undoMenuItem_actionPerformed();
1027 else if (source == redoMenuItem)
1029 redoMenuItem_actionPerformed();
1031 else if (source == copy)
1033 copy_actionPerformed();
1035 else if (source == pasteNew)
1037 pasteNew_actionPerformed();
1039 else if (source == pasteThis)
1041 pasteThis_actionPerformed();
1043 else if (source == cut)
1045 cut_actionPerformed();
1047 else if (source == delete)
1049 delete_actionPerformed();
1051 else if (source == grpsFromSelection)
1053 makeGrpsFromSelection_actionPerformed();
1055 else if (source == deleteGroups)
1057 deleteGroups_actionPerformed();
1059 else if (source == selectAllSequenceMenuItem)
1061 selectAllSequenceMenuItem_actionPerformed();
1063 else if (source == deselectAllSequenceMenuItem)
1065 deselectAllSequenceMenuItem_actionPerformed();
1067 else if (source == invertSequenceMenuItem)
1069 invertSequenceMenuItem_actionPerformed();
1071 else if (source == invertColSel)
1073 viewport.invertColumnSelection();
1074 alignPanel.paintAlignment(true);
1076 else if (source == remove2LeftMenuItem)
1078 trimAlignment(true);
1080 else if (source == remove2RightMenuItem)
1082 trimAlignment(false);
1084 else if (source == removeGappedColumnMenuItem)
1086 removeGappedColumnMenuItem_actionPerformed();
1088 else if (source == removeAllGapsMenuItem)
1090 removeAllGapsMenuItem_actionPerformed();
1092 else if (source == findMenuItem)
1094 findMenuItem_actionPerformed();
1096 else if (source == font)
1098 new FontChooser(alignPanel);
1100 else if (source == newView)
1104 else if (source == showColumns)
1106 viewport.showAllHiddenColumns();
1107 alignPanel.paintAlignment(true);
1109 else if (source == showSeqs)
1111 viewport.showAllHiddenSeqs();
1112 alignPanel.paintAlignment(true);
1114 else if (source == hideColumns)
1116 viewport.hideSelectedColumns();
1117 alignPanel.paintAlignment(true);
1119 else if (source == hideSequences
1120 && viewport.getSelectionGroup() != null)
1122 viewport.hideAllSelectedSeqs();
1123 alignPanel.paintAlignment(true);
1125 else if (source == hideAllButSelection)
1127 toggleHiddenRegions(false, false);
1128 alignPanel.paintAlignment(true);
1130 else if (source == hideAllSelection)
1132 SequenceGroup sg = viewport.getSelectionGroup();
1133 viewport.expandColSelection(sg, false);
1134 viewport.hideAllSelectedSeqs();
1135 viewport.hideSelectedColumns();
1136 alignPanel.paintAlignment(true);
1138 else if (source == showAllHidden)
1140 viewport.showAllHiddenColumns();
1141 viewport.showAllHiddenSeqs();
1142 alignPanel.paintAlignment(true);
1144 else if (source == showGroupConsensus)
1146 showGroupConsensus_actionPerformed();
1148 else if (source == showGroupConservation)
1150 showGroupConservation_actionPerformed();
1152 else if (source == showSequenceLogo)
1154 showSequenceLogo_actionPerformed();
1156 else if (source == normSequenceLogo)
1158 normSequenceLogo_actionPerformed();
1160 else if (source == showConsensusHistogram)
1162 showConsensusHistogram_actionPerformed();
1164 else if (source == applyAutoAnnotationSettings)
1166 applyAutoAnnotationSettings_actionPerformed();
1168 else if (source == featureSettings)
1170 new FeatureSettings(alignPanel);
1172 else if (source == alProperties)
1174 StringBuffer contents = new jalview.io.AlignmentProperties(
1175 viewport.getAlignment()).formatAsString();
1176 CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this);
1177 cap.setText(contents.toString());
1178 Frame frame = new Frame();
1180 jalview.bin.JalviewLite.addFrame(frame, MessageManager.formatMessage(
1181 "label.alignment_properties", new String[]
1182 { getTitle() }), 400, 250);
1184 else if (source == overviewMenuItem)
1186 overviewMenuItem_actionPerformed();
1188 else if (source == noColourmenuItem)
1192 else if (source == clustalColour)
1194 abovePIDThreshold.setState(false);
1195 changeColour(new ClustalxColourScheme(viewport.getAlignment(), null));
1197 else if (source == zappoColour)
1199 changeColour(new ZappoColourScheme());
1201 else if (source == taylorColour)
1203 changeColour(new TaylorColourScheme());
1205 else if (source == hydrophobicityColour)
1207 changeColour(new HydrophobicColourScheme());
1209 else if (source == helixColour)
1211 changeColour(new HelixColourScheme());
1213 else if (source == strandColour)
1215 changeColour(new StrandColourScheme());
1217 else if (source == turnColour)
1219 changeColour(new TurnColourScheme());
1221 else if (source == buriedColour)
1223 changeColour(new BuriedColourScheme());
1225 else if (source == nucleotideColour)
1227 changeColour(new NucleotideColourScheme());
1229 else if (source == purinePyrimidineColour)
1231 changeColour(new PurinePyrimidineColourScheme());
1233 else if (source == RNAInteractionColour)
1235 changeColour(new RNAInteractionColourScheme());
1237 else if (source == RNAHelixColour)
1239 new RNAHelicesColourChooser(viewport, alignPanel);
1241 else if (source == modifyPID)
1243 modifyPID_actionPerformed();
1245 else if (source == modifyConservation)
1247 modifyConservation_actionPerformed();
1249 else if (source == userDefinedColour)
1251 new UserDefinedColours(alignPanel, null);
1253 else if (source == PIDColour)
1255 changeColour(new PIDColourScheme());
1257 else if (source == BLOSUM62Colour)
1259 changeColour(new Blosum62ColourScheme());
1261 else if (source == tcoffeeColour)
1263 changeColour(new TCoffeeColourScheme(alignPanel.getAlignment()));
1265 else if (source == annotationColour)
1267 new AnnotationColourChooser(viewport, alignPanel);
1269 else if (source == annotationColumnSelection)
1271 new AnnotationColumnChooser(viewport, alignPanel);
1273 else if (source == sortPairwiseMenuItem)
1275 sortPairwiseMenuItem_actionPerformed();
1277 else if (source == sortIDMenuItem)
1279 sortIDMenuItem_actionPerformed();
1281 else if (source == sortLengthMenuItem)
1283 sortLengthMenuItem_actionPerformed();
1285 else if (source == sortGroupMenuItem)
1287 sortGroupMenuItem_actionPerformed();
1289 else if (source == removeRedundancyMenuItem)
1291 removeRedundancyMenuItem_actionPerformed();
1293 else if (source == pairwiseAlignmentMenuItem)
1295 pairwiseAlignmentMenuItem_actionPerformed();
1297 else if (source == PCAMenuItem)
1299 PCAMenuItem_actionPerformed();
1301 else if (source == averageDistanceTreeMenuItem)
1303 averageDistanceTreeMenuItem_actionPerformed();
1305 else if (source == neighbourTreeMenuItem)
1307 neighbourTreeMenuItem_actionPerformed();
1309 else if (source == njTreeBlosumMenuItem)
1311 njTreeBlosumMenuItem_actionPerformed();
1313 else if (source == avDistanceTreeBlosumMenuItem)
1315 avTreeBlosumMenuItem_actionPerformed();
1317 else if (source == documentation)
1319 documentation_actionPerformed();
1321 else if (source == about)
1323 about_actionPerformed();
1328 public void inputText_actionPerformed()
1330 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
1331 Frame frame = new Frame();
1333 jalview.bin.JalviewLite.addFrame(frame,
1334 MessageManager.getString("label.input_cut_paste"), 500, 500);
1337 protected void outputText_actionPerformed(ActionEvent e)
1339 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
1340 Frame frame = new Frame();
1342 jalview.bin.JalviewLite.addFrame(frame, MessageManager.formatMessage(
1343 "label.alignment_output_command", new Object[]
1344 { e.getActionCommand() }), 600, 500);
1346 FeatureRenderer fr = this.alignPanel.cloneFeatureRenderer();
1347 cap.setText(new AppletFormatAdapter(alignPanel).formatSequences(
1348 e.getActionCommand(), viewport.getAlignment(),
1349 viewport.getShowJVSuffix()));
1352 public void loadAnnotations()
1354 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
1355 cap.setText(MessageManager
1356 .getString("label.paste_features_annotations_Tcoffee_here"));
1357 cap.setAnnotationImport();
1358 Frame frame = new Frame();
1360 jalview.bin.JalviewLite.addFrame(frame,
1361 MessageManager.getString("action.paste_annotations"), 400, 300);
1365 public String outputAnnotations(boolean displayTextbox)
1367 String annotation = new AnnotationFile()
1368 .printAnnotationsForView(viewport);
1372 CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this);
1373 Frame frame = new Frame();
1375 jalview.bin.JalviewLite.addFrame(frame,
1376 MessageManager.getString("label.annotations"), 600, 500);
1377 cap.setText(annotation);
1383 private Map<String,Object> getDisplayedFeatureCols()
1385 if (alignPanel.getFeatureRenderer() != null
1386 && viewport.getFeaturesDisplayed()!= null)
1388 return alignPanel.getFeatureRenderer().getDisplayedFeatureCols();
1394 public String outputFeatures(boolean displayTextbox, String format)
1397 if (format.equalsIgnoreCase("Jalview"))
1399 features = new FeaturesFile().printJalviewFormat(viewport
1400 .getAlignment().getSequencesArray(),
1401 getDisplayedFeatureCols());
1405 features = new FeaturesFile().printGFFFormat(viewport.getAlignment()
1406 .getSequencesArray(), getDisplayedFeatureCols());
1411 boolean frimport = false;
1412 if (features == null || features.equals("No Features Visible"))
1414 features = "# No features visible - paste some and import them here.";
1418 CutAndPasteTransfer cap = new CutAndPasteTransfer(frimport, this);
1421 cap.setAnnotationImport();
1423 Frame frame = new Frame();
1425 jalview.bin.JalviewLite.addFrame(frame,
1426 MessageManager.getString("label.features"), 600, 500);
1427 cap.setText(features);
1431 if (features == null)
1440 void launchFullApplication()
1442 StringBuffer url = new StringBuffer(jalviewServletURL);
1444 // allow servlet parameters to be passed in applet parameter
1445 String firstSep = url.lastIndexOf("?") > url.lastIndexOf("/") ? "&"
1447 url.append(firstSep);
1450 + appendProtocol(viewport.applet.getParameter("file")));
1452 if (viewport.applet.getParameter("features") != null)
1454 url.append("&features=");
1455 url.append(appendProtocol(viewport.applet.getParameter("features")));
1458 if (viewport.applet.getParameter("annotations") != null)
1460 url.append("&annotations=");
1461 url.append(appendProtocol(viewport.applet.getParameter("annotations")));
1464 if (viewport.applet.getParameter("jnetfile") != null)
1466 url.append("&annotations=");
1467 url.append(appendProtocol(viewport.applet.getParameter("jnetfile")));
1470 if (viewport.applet.getParameter("defaultColour") != null)
1472 url.append("&colour="
1473 + removeWhiteSpace(viewport.applet
1474 .getParameter("defaultColour")));
1477 if (viewport.applet.getParameter("userDefinedColour") != null)
1479 url.append("&colour="
1480 + removeWhiteSpace(viewport.applet
1481 .getParameter("userDefinedColour")));
1483 if (viewport.applet.getParameter("tree") != null)
1486 + appendProtocol(viewport.applet.getParameter("tree")));
1488 if (viewport.applet.getParameter("treeFile") != null)
1491 + appendProtocol(viewport.applet.getParameter("treeFile")));
1494 showURL(url.toString(), "FULL_APP");
1497 String removeWhiteSpace(String colour)
1499 StringBuffer sb = new StringBuffer();
1500 for (int i = 0; i < colour.length(); i++)
1502 if (Character.isWhitespace(colour.charAt(i)))
1508 sb.append(colour.charAt(i));
1512 return sb.toString();
1515 String appendProtocol(String url)
1520 url = URLEncoder.encode(url);
1523 * When we finally deprecate 1.1 compatibility, we can start to use
1524 * URLEncoder.encode(url,"UTF-8") and then we'll need this catch: catch
1525 * (UnsupportedEncodingException ex) { System.err.println("WARNING -
1526 * IMPLEMENTATION ERROR - UNSUPPORTED ENCODING EXCEPTION FOR "+url);
1527 * ex.printStackTrace(); }
1529 catch (java.net.MalformedURLException ex)
1531 url = viewport.applet.getCodeBase() + url;
1536 public void closeMenuItem_actionPerformed()
1538 PaintRefresher.RemoveComponent(alignPanel);
1539 if (alignPanel.seqPanel != null
1540 && alignPanel.seqPanel.seqCanvas != null)
1542 PaintRefresher.RemoveComponent(alignPanel.seqPanel.seqCanvas);
1544 if (alignPanel.idPanel != null && alignPanel.idPanel.idCanvas != null)
1546 PaintRefresher.RemoveComponent(alignPanel.idPanel.idCanvas);
1549 if (PaintRefresher.components.size() == 0 && viewport.applet == null)
1564 void updateEditMenuBar()
1567 if (viewport.getHistoryList().size() > 0)
1569 undoMenuItem.setEnabled(true);
1570 CommandI command = viewport.getHistoryList().peek();
1571 undoMenuItem.setLabel(MessageManager.formatMessage(
1572 "label.undo_command", new Object[]
1573 { command.getDescription() }));
1577 undoMenuItem.setEnabled(false);
1578 undoMenuItem.setLabel(MessageManager.getString("action.undo"));
1581 if (viewport.getRedoList().size() > 0)
1583 redoMenuItem.setEnabled(true);
1585 CommandI command = viewport.getRedoList().peek();
1586 redoMenuItem.setLabel(MessageManager.formatMessage(
1587 "label.redo_command", new Object[]
1588 { command.getDescription() }));
1592 redoMenuItem.setEnabled(false);
1593 redoMenuItem.setLabel(MessageManager.getString("action.redo"));
1601 public void addHistoryItem(CommandI command)
1603 if (command.getSize() > 0)
1605 viewport.addToHistoryList(command);
1606 viewport.clearRedoList();
1607 updateEditMenuBar();
1608 viewport.updateHiddenColumns();
1613 * TODO: JAL-1104 DOCUMENT ME!
1618 protected void undoMenuItem_actionPerformed()
1620 if (viewport.getHistoryList().isEmpty())
1625 CommandI command = viewport.getHistoryList().pop();
1626 viewport.addToRedoList(command);
1627 command.undoCommand(null);
1629 AlignmentViewport originalSource = getOriginatingSource(command);
1631 if (originalSource != viewport)
1634 .println("Warning: Viewport object mismatch whilst undoing");
1636 originalSource.updateHiddenColumns(); // originalSource.hasHiddenColumns =
1637 // viewport.getColumnSelection().getHiddenColumns()
1639 updateEditMenuBar();
1640 originalSource.firePropertyChange("alignment", null, originalSource
1641 .getAlignment().getSequences());
1645 * TODO: JAL-1104 DOCUMENT ME!
1650 protected void redoMenuItem_actionPerformed()
1652 if (viewport.getRedoList().isEmpty())
1657 CommandI command = viewport.getRedoList().pop();
1658 viewport.addToHistoryList(command);
1659 command.doCommand(null);
1661 AlignmentViewport originalSource = getOriginatingSource(command);
1663 if (originalSource != viewport)
1666 .println("Warning: Viewport object mismatch whilst re-doing");
1668 originalSource.updateHiddenColumns(); // sethasHiddenColumns(); =
1669 // viewport.getColumnSelection().getHiddenColumns()
1672 updateEditMenuBar();
1673 originalSource.firePropertyChange("alignment", null, originalSource
1674 .getAlignment().getSequences());
1677 AlignmentViewport getOriginatingSource(CommandI command)
1679 AlignmentViewport originalSource = null;
1680 // For sequence removal and addition, we need to fire
1681 // the property change event FROM the viewport where the
1682 // original alignment was altered
1683 AlignmentI al = null;
1684 if (command instanceof EditCommand)
1686 EditCommand editCommand = (EditCommand) command;
1687 al = editCommand.getAlignment();
1688 Vector comps = (Vector) PaintRefresher.components.get(viewport
1689 .getSequenceSetId());
1690 for (int i = 0; i < comps.size(); i++)
1692 if (comps.elementAt(i) instanceof AlignmentPanel)
1694 if (al == ((AlignmentPanel) comps.elementAt(i)).av.getAlignment())
1696 originalSource = ((AlignmentPanel) comps.elementAt(i)).av;
1703 if (originalSource == null)
1705 // The original view is closed, we must validate
1706 // the current view against the closed view first
1709 PaintRefresher.validateSequences(al, viewport.getAlignment());
1712 originalSource = viewport;
1715 return originalSource;
1719 * Move the currently selected sequences up or down one position in the
1724 public void moveSelectedSequences(boolean up)
1726 SequenceGroup sg = viewport.getSelectionGroup();
1731 viewport.getAlignment().moveSelectedSequencesByOne(sg,
1732 up ? null : viewport.getHiddenRepSequences(), up);
1733 alignPanel.paintAlignment(true);
1736 * Also move cDNA/protein complement sequences
1738 AlignViewportI complement = viewport.getCodingComplement();
1739 if (complement != null)
1741 SequenceGroup mappedSelection = MappingUtils.mapSequenceGroup(sg,
1742 viewport, complement);
1743 complement.getAlignment().moveSelectedSequencesByOne(mappedSelection,
1744 up ? null : complement.getHiddenRepSequences(), up);
1745 // TODO need to trigger a repaint of the complementary panel - how?
1746 // would prefer to handle in SplitFrame but it is not overriding key
1751 synchronized void slideSequences(boolean right, int size)
1753 List<SequenceI> sg = new Vector<SequenceI>();
1754 if (viewport.cursorMode)
1756 sg.add(viewport.getAlignment().getSequenceAt(
1757 alignPanel.seqPanel.seqCanvas.cursorY));
1759 else if (viewport.getSelectionGroup() != null
1760 && viewport.getSelectionGroup().getSize() != viewport
1761 .getAlignment().getHeight())
1763 sg = viewport.getSelectionGroup().getSequences(
1764 viewport.getHiddenRepSequences());
1772 Vector<SequenceI> invertGroup = new Vector();
1774 for (int i = 0; i < viewport.getAlignment().getHeight(); i++)
1776 if (!sg.contains(viewport.getAlignment().getSequenceAt(i)))
1778 invertGroup.addElement(viewport.getAlignment().getSequenceAt(i));
1782 SequenceI[] seqs1 = sg.toArray(new SequenceI[sg.size()]);
1784 SequenceI[] seqs2 = invertGroup.toArray(new SequenceI[invertGroup
1786 for (int i = 0; i < invertGroup.size(); i++)
1788 seqs2[i] = invertGroup.elementAt(i);
1791 SlideSequencesCommand ssc;
1794 ssc = new SlideSequencesCommand("Slide Sequences", seqs2, seqs1,
1795 size, viewport.getGapCharacter());
1799 ssc = new SlideSequencesCommand("Slide Sequences", seqs1, seqs2,
1800 size, viewport.getGapCharacter());
1803 int groupAdjustment = 0;
1804 if (ssc.getGapsInsertedBegin() && right)
1806 if (viewport.cursorMode)
1808 alignPanel.seqPanel.moveCursor(size, 0);
1812 groupAdjustment = size;
1815 else if (!ssc.getGapsInsertedBegin() && !right)
1817 if (viewport.cursorMode)
1819 alignPanel.seqPanel.moveCursor(-size, 0);
1823 groupAdjustment = -size;
1827 if (groupAdjustment != 0)
1829 viewport.getSelectionGroup().setStartRes(
1830 viewport.getSelectionGroup().getStartRes() + groupAdjustment);
1831 viewport.getSelectionGroup().setEndRes(
1832 viewport.getSelectionGroup().getEndRes() + groupAdjustment);
1835 boolean appendHistoryItem = false;
1836 Deque<CommandI> historyList = viewport.getHistoryList();
1837 if (historyList != null && historyList.size() > 0
1838 && historyList.peek() instanceof SlideSequencesCommand)
1840 appendHistoryItem = ssc
1841 .appendSlideCommand((SlideSequencesCommand) historyList
1845 if (!appendHistoryItem)
1847 addHistoryItem(ssc);
1853 static StringBuffer copiedSequences;
1855 static Vector copiedHiddenColumns;
1857 protected void copy_actionPerformed()
1859 if (viewport.getSelectionGroup() == null)
1864 SequenceGroup sg = viewport.getSelectionGroup();
1865 copiedSequences = new StringBuffer();
1866 Map<Integer, SequenceI> orderedSeqs = new HashMap<Integer, SequenceI>();
1867 for (int i = 0; i < sg.getSize(); i++)
1869 SequenceI seq = sg.getSequenceAt(i);
1870 int index = viewport.getAlignment().findIndex(seq);
1871 orderedSeqs.put(index, seq);
1874 int index = 0, startRes, endRes;
1877 if (viewport.hasHiddenColumns() && viewport.getSelectionGroup() != null)
1879 copiedHiddenColumns = new Vector();
1880 int hiddenOffset = viewport.getSelectionGroup().getStartRes();
1881 for (int[] region : viewport.getColumnSelection().getHiddenColumns())
1883 copiedHiddenColumns.addElement(new int[]
1884 { region[0] - hiddenOffset, region[1] - hiddenOffset });
1889 copiedHiddenColumns = null;
1892 for (int i = 0; i < sg.getSize(); i++)
1894 SequenceI seq = null;
1898 if (orderedSeqs.containsKey(index))
1900 seq = orderedSeqs.get(index);
1911 // Returns residue following index if gap
1912 startRes = seq.findPosition(sg.getStartRes());
1915 // Need to find the residue preceeding index if gap
1918 for (int j = 0; j < sg.getEndRes() + 1 && j < seq.getLength(); j++)
1920 ch = seq.getCharAt(j);
1921 if (!jalview.util.Comparison.isGap((ch)))
1929 endRes += seq.getStart() - 1;
1932 copiedSequences.append(seq.getName()
1938 + seq.getSequenceAsString(sg.getStartRes(),
1939 sg.getEndRes() + 1) + "\n");
1944 protected void pasteNew_actionPerformed()
1949 protected void pasteThis_actionPerformed()
1954 void paste(boolean newAlignment)
1959 if (copiedSequences == null)
1964 StringTokenizer st = new StringTokenizer(copiedSequences.toString());
1965 Vector seqs = new Vector();
1966 while (st.hasMoreElements())
1968 String name = st.nextToken();
1969 int start = Integer.parseInt(st.nextToken());
1970 int end = Integer.parseInt(st.nextToken());
1971 seqs.addElement(new Sequence(name, st.nextToken(), start, end));
1973 SequenceI[] newSeqs = new SequenceI[seqs.size()];
1974 for (int i = 0; i < seqs.size(); i++)
1976 newSeqs[i] = (SequenceI) seqs.elementAt(i);
1981 String newtitle = MessageManager.getString("label.copied_sequences");
1982 if (getTitle().startsWith(MessageManager.getString("label.copied_sequences")))
1984 newtitle = getTitle();
1988 newtitle = newtitle.concat(MessageManager.formatMessage("label.from_msname", new String[]{getTitle()}));
1990 AlignFrame af = new AlignFrame(new Alignment(newSeqs),
1991 viewport.applet, newtitle, false);
1992 if (copiedHiddenColumns != null)
1994 for (int i = 0; i < copiedHiddenColumns.size(); i++)
1996 int[] region = (int[]) copiedHiddenColumns.elementAt(i);
1997 af.viewport.hideColumns(region[0], region[1]);
2001 jalview.bin.JalviewLite.addFrame(af, newtitle, frameWidth,
2006 addSequences(newSeqs);
2009 } catch (Exception ex)
2011 } // could be anything being pasted in here
2015 void addSequences(SequenceI[] seqs)
2017 for (int i = 0; i < seqs.length; i++)
2019 viewport.getAlignment().addSequence(seqs[i]);
2023 addHistoryItem(new EditCommand(
2024 MessageManager.getString("label.add_sequences"), Action.PASTE,
2025 seqs, 0, viewport.getAlignment().getWidth(),
2026 viewport.getAlignment()));
2028 viewport.setEndSeq(viewport.getAlignment().getHeight());
2029 viewport.getAlignment().getWidth();
2030 viewport.firePropertyChange("alignment", null, viewport.getAlignment()
2035 protected void cut_actionPerformed()
2037 copy_actionPerformed();
2038 delete_actionPerformed();
2041 protected void delete_actionPerformed()
2044 SequenceGroup sg = viewport.getSelectionGroup();
2050 Vector seqs = new Vector();
2052 for (int i = 0; i < sg.getSize(); i++)
2054 seq = sg.getSequenceAt(i);
2055 seqs.addElement(seq);
2058 // If the cut affects all sequences, remove highlighted columns
2059 if (sg.getSize() == viewport.getAlignment().getHeight())
2061 viewport.getColumnSelection().removeElements(sg.getStartRes(),
2062 sg.getEndRes() + 1);
2065 SequenceI[] cut = new SequenceI[seqs.size()];
2066 for (int i = 0; i < seqs.size(); i++)
2068 cut[i] = (SequenceI) seqs.elementAt(i);
2072 * //ADD HISTORY ITEM
2074 addHistoryItem(new EditCommand(
2075 MessageManager.getString("label.cut_sequences"), Action.CUT,
2076 cut, sg.getStartRes(), sg.getEndRes() - sg.getStartRes() + 1,
2077 viewport.getAlignment()));
2079 viewport.setSelectionGroup(null);
2080 viewport.getAlignment().deleteGroup(sg);
2082 viewport.firePropertyChange("alignment", null, viewport.getAlignment()
2085 if (viewport.getAlignment().getHeight() < 1)
2087 this.setVisible(false);
2089 viewport.sendSelection();
2093 * group consensus toggled
2096 protected void showGroupConsensus_actionPerformed()
2098 viewport.setShowGroupConsensus(showGroupConsensus.getState());
2099 alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
2104 * group conservation toggled.
2106 protected void showGroupConservation_actionPerformed()
2108 viewport.setShowGroupConservation(showGroupConservation.getState());
2109 alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
2116 * jalview.jbgui.GAlignFrame#showConsensusHistogram_actionPerformed(java.awt
2117 * .event.ActionEvent)
2119 protected void showConsensusHistogram_actionPerformed()
2121 viewport.setShowConsensusHistogram(showConsensusHistogram.getState());
2122 alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
2129 * jalview.jbgui.GAlignFrame#showConsensusProfile_actionPerformed(java.awt
2130 * .event.ActionEvent)
2132 protected void showSequenceLogo_actionPerformed()
2134 viewport.setShowSequenceLogo(showSequenceLogo.getState());
2135 alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
2138 protected void normSequenceLogo_actionPerformed()
2140 showSequenceLogo.setState(true);
2141 viewport.setShowSequenceLogo(true);
2142 viewport.setNormaliseSequenceLogo(normSequenceLogo.getState());
2143 alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
2146 protected void applyAutoAnnotationSettings_actionPerformed()
2148 alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
2151 protected void makeGrpsFromSelection_actionPerformed()
2153 if (avc.makeGroupsFromSelection())
2155 PaintRefresher.Refresh(this, viewport.getSequenceSetId());
2156 alignPanel.updateAnnotation();
2157 alignPanel.paintAlignment(true);
2161 protected void createGroup_actionPerformed()
2166 protected void unGroup_actionPerformed()
2170 alignPanel.alignmentChanged();
2174 protected void deleteGroups_actionPerformed()
2176 if (avc.deleteGroups())
2178 alignPanel.alignmentChanged();
2182 public void selectAllSequenceMenuItem_actionPerformed()
2184 SequenceGroup sg = new SequenceGroup();
2185 for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++)
2187 sg.addSequence(viewport.getAlignment().getSequenceAt(i), false);
2189 sg.setEndRes(viewport.getAlignment().getWidth() - 1);
2190 viewport.setSelectionGroup(sg);
2191 alignPanel.paintAlignment(true);
2192 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
2193 viewport.sendSelection();
2196 public void deselectAllSequenceMenuItem_actionPerformed()
2198 if (viewport.cursorMode)
2200 alignPanel.seqPanel.keyboardNo1 = null;
2201 alignPanel.seqPanel.keyboardNo2 = null;
2203 viewport.setSelectionGroup(null);
2204 viewport.getColumnSelection().clear();
2205 viewport.setSelectionGroup(null);
2206 alignPanel.idPanel.idCanvas.searchResults = null;
2207 alignPanel.seqPanel.seqCanvas.highlightSearchResults(null);
2208 alignPanel.paintAlignment(true);
2209 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
2210 viewport.sendSelection();
2213 public void invertSequenceMenuItem_actionPerformed()
2215 SequenceGroup sg = viewport.getSelectionGroup();
2216 for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++)
2218 sg.addOrRemove(viewport.getAlignment().getSequenceAt(i), false);
2221 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
2222 viewport.sendSelection();
2225 public void invertColSel_actionPerformed()
2227 viewport.invertColumnSelection();
2228 alignPanel.paintAlignment(true);
2229 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
2230 viewport.sendSelection();
2233 void trimAlignment(boolean trimLeft)
2235 ColumnSelection colSel = viewport.getColumnSelection();
2238 if (colSel.size() > 0)
2242 column = colSel.getMin();
2246 column = colSel.getMax();
2250 if (viewport.getSelectionGroup() != null)
2252 seqs = viewport.getSelectionGroup().getSequencesAsArray(
2253 viewport.getHiddenRepSequences());
2257 seqs = viewport.getAlignment().getSequencesArray();
2260 TrimRegionCommand trimRegion;
2263 trimRegion = new TrimRegionCommand("Remove Left",
2264 TrimRegionCommand.TRIM_LEFT, seqs, column,
2265 viewport.getAlignment(), viewport.getColumnSelection(),
2266 viewport.getSelectionGroup());
2267 viewport.setStartRes(0);
2271 trimRegion = new TrimRegionCommand("Remove Right",
2272 TrimRegionCommand.TRIM_RIGHT, seqs, column,
2273 viewport.getAlignment(), viewport.getColumnSelection(),
2274 viewport.getSelectionGroup());
2277 statusBar.setText(MessageManager.formatMessage(
2278 "label.removed_columns", new String[]
2279 { Integer.valueOf(trimRegion.getSize()).toString() }));
2280 addHistoryItem(trimRegion);
2282 for (SequenceGroup sg : viewport.getAlignment().getGroups())
2284 if ((trimLeft && !sg.adjustForRemoveLeft(column))
2285 || (!trimLeft && !sg.adjustForRemoveRight(column)))
2287 viewport.getAlignment().deleteGroup(sg);
2291 viewport.firePropertyChange("alignment", null, viewport
2292 .getAlignment().getSequences());
2296 public void removeGappedColumnMenuItem_actionPerformed()
2298 int start = 0, end = viewport.getAlignment().getWidth() - 1;
2301 if (viewport.getSelectionGroup() != null)
2303 seqs = viewport.getSelectionGroup().getSequencesAsArray(
2304 viewport.getHiddenRepSequences());
2305 start = viewport.getSelectionGroup().getStartRes();
2306 end = viewport.getSelectionGroup().getEndRes();
2310 seqs = viewport.getAlignment().getSequencesArray();
2313 RemoveGapColCommand removeGapCols = new RemoveGapColCommand(
2314 "Remove Gapped Columns", seqs, start, end,
2315 viewport.getAlignment());
2317 addHistoryItem(removeGapCols);
2319 statusBar.setText(MessageManager.formatMessage(
2320 "label.removed_empty_columns", new String[]
2321 { Integer.valueOf(removeGapCols.getSize()).toString() }));
2323 // This is to maintain viewport position on first residue
2324 // of first sequence
2325 SequenceI seq = viewport.getAlignment().getSequenceAt(0);
2326 int startRes = seq.findPosition(viewport.startRes);
2327 // ShiftList shifts;
2328 // viewport.getAlignment().removeGaps(shifts=new ShiftList());
2329 // edit.alColumnChanges=shifts.getInverse();
2330 // if (viewport.hasHiddenColumns)
2331 // viewport.getColumnSelection().compensateForEdits(shifts);
2332 viewport.setStartRes(seq.findIndex(startRes) - 1);
2333 viewport.firePropertyChange("alignment", null, viewport.getAlignment()
2338 public void removeAllGapsMenuItem_actionPerformed()
2340 int start = 0, end = viewport.getAlignment().getWidth() - 1;
2343 if (viewport.getSelectionGroup() != null)
2345 seqs = viewport.getSelectionGroup().getSequencesAsArray(
2346 viewport.getHiddenRepSequences());
2347 start = viewport.getSelectionGroup().getStartRes();
2348 end = viewport.getSelectionGroup().getEndRes();
2352 seqs = viewport.getAlignment().getSequencesArray();
2355 // This is to maintain viewport position on first residue
2356 // of first sequence
2357 SequenceI seq = viewport.getAlignment().getSequenceAt(0);
2358 int startRes = seq.findPosition(viewport.startRes);
2360 addHistoryItem(new RemoveGapsCommand("Remove Gaps", seqs, start, end,
2361 viewport.getAlignment()));
2363 viewport.setStartRes(seq.findIndex(startRes) - 1);
2365 viewport.firePropertyChange("alignment", null, viewport.getAlignment()
2370 public void findMenuItem_actionPerformed()
2372 new Finder(alignPanel);
2376 * create a new view derived from the current view
2379 * @return frame for the new view
2381 public AlignFrame newView(String viewtitle)
2384 if (viewport.hasHiddenRows())
2386 newal = new Alignment(viewport.getAlignment().getHiddenSequences()
2387 .getFullAlignment().getSequencesArray());
2391 newal = new Alignment(viewport.getAlignment().getSequencesArray());
2394 if (viewport.getAlignment().getAlignmentAnnotation() != null)
2396 for (int i = 0; i < viewport.getAlignment().getAlignmentAnnotation().length; i++)
2398 if (!viewport.getAlignment().getAlignmentAnnotation()[i].autoCalculated)
2400 newal.addAnnotation(viewport.getAlignment()
2401 .getAlignmentAnnotation()[i]);
2406 AlignFrame newaf = new AlignFrame(newal, viewport.applet, "", false);
2408 newaf.viewport.setSequenceSetId(alignPanel.av.getSequenceSetId());
2409 PaintRefresher.Register(alignPanel, alignPanel.av.getSequenceSetId());
2410 PaintRefresher.Register(newaf.alignPanel,
2411 newaf.alignPanel.av.getSequenceSetId());
2413 PaintRefresher.Register(newaf.alignPanel.idPanel.idCanvas,
2414 newaf.alignPanel.av.getSequenceSetId());
2415 PaintRefresher.Register(newaf.alignPanel.seqPanel.seqCanvas,
2416 newaf.alignPanel.av.getSequenceSetId());
2418 Vector comps = (Vector) PaintRefresher.components.get(viewport
2419 .getSequenceSetId());
2421 for (int i = 0; i < comps.size(); i++)
2423 if (comps.elementAt(i) instanceof AlignmentPanel)
2429 String title = new String(this.getTitle());
2430 if (viewtitle != null)
2432 title = viewtitle + " ( " + title + ")";
2436 if (title.indexOf("(View") > -1)
2438 title = title.substring(0, title.indexOf("(View"));
2440 title += "(View " + viewSize + ")";
2443 newaf.setTitle(title.toString());
2445 newaf.viewport.setHistoryList(viewport.getHistoryList());
2446 newaf.viewport.setRedoList(viewport.getRedoList());
2452 * @return list of feature groups on the view
2454 public String[] getFeatureGroups()
2456 FeatureRenderer fr = null;
2457 if (alignPanel != null
2458 && (fr = alignPanel.getFeatureRenderer()) != null)
2460 List<String> gps = fr.getFeatureGroups();
2461 String[] _gps = gps.toArray(new String[gps.size()]);
2468 * get sequence feature groups that are hidden or shown
2474 public String[] getFeatureGroupsOfState(boolean visible)
2476 FeatureRenderer fr = null;
2477 if (alignPanel != null
2478 && (fr = alignPanel.getFeatureRenderer()) != null)
2480 List<String> gps = fr.getGroups(visible);
2481 String[] _gps = gps.toArray(new String[gps.size()]);
2488 * Change the display state for the given feature groups
2491 * list of group strings
2493 * visible or invisible
2495 public void setFeatureGroupState(String[] groups, boolean state)
2497 FeatureRenderer fr = null;
2498 this.sequenceFeatures.setState(true);
2499 viewport.setShowSequenceFeatures(true);
2500 if (alignPanel != null
2501 && (fr = alignPanel.getFeatureRenderer()) != null)
2504 fr.setGroupVisibility(Arrays.asList(groups), state);
2505 alignPanel.seqPanel.seqCanvas.repaint();
2506 if (alignPanel.overviewPanel != null)
2508 alignPanel.overviewPanel.updateOverviewImage();
2513 public void seqLimits_itemStateChanged()
2515 viewport.setShowJVSuffix(seqLimits.getState());
2516 alignPanel.fontChanged();
2517 alignPanel.paintAlignment(true);
2520 protected void colourTextMenuItem_actionPerformed()
2522 viewport.setColourText(colourTextMenuItem.getState());
2523 alignPanel.paintAlignment(true);
2526 protected void displayNonconservedMenuItem_actionPerformed()
2528 viewport.setShowUnconserved(displayNonconservedMenuItem.getState());
2529 alignPanel.paintAlignment(true);
2532 protected void wrapMenuItem_actionPerformed()
2534 viewport.setWrapAlignment(wrapMenuItem.getState());
2535 alignPanel.setWrapAlignment(wrapMenuItem.getState());
2536 scaleAbove.setEnabled(wrapMenuItem.getState());
2537 scaleLeft.setEnabled(wrapMenuItem.getState());
2538 scaleRight.setEnabled(wrapMenuItem.getState());
2539 alignPanel.paintAlignment(true);
2542 public void overviewMenuItem_actionPerformed()
2544 if (alignPanel.overviewPanel != null)
2549 Frame frame = new Frame();
2550 OverviewPanel overview = new OverviewPanel(alignPanel);
2551 frame.add(overview);
2552 // +50 must allow for applet frame window
2553 jalview.bin.JalviewLite.addFrame(frame, MessageManager.formatMessage(
2554 "label.overview_params", new String[]
2555 { this.getTitle() }), overview.getPreferredSize().width,
2556 overview.getPreferredSize().height + 50);
2559 final AlignmentPanel ap = alignPanel;
2560 frame.addWindowListener(new WindowAdapter()
2563 public void windowClosing(WindowEvent e)
2567 ap.setOverviewPanel(null);
2572 alignPanel.setOverviewPanel(overview);
2576 public void changeColour(ColourSchemeI cs)
2582 if (viewport.getAbovePIDThreshold())
2584 viewport.setThreshold(SliderPanel.setPIDSliderSource(alignPanel,
2588 if (viewport.getConservationSelected())
2590 cs.setConservationApplied(true);
2591 viewport.setIncrement(SliderPanel.setConservationSlider(alignPanel,
2596 cs.setConservationApplied(false);
2599 viewport.setGlobalColourScheme(cs);
2601 if (alignPanel.getOverviewPanel() != null)
2603 alignPanel.getOverviewPanel().updateOverviewImage();
2606 jalview.structure.StructureSelectionManager
2607 .getStructureSelectionManager(viewport.applet)
2608 .sequenceColoursChanged(alignPanel);
2610 alignPanel.paintAlignment(true);
2613 protected void modifyPID_actionPerformed()
2615 if (viewport.getAbovePIDThreshold()
2616 && viewport.getGlobalColourScheme() != null)
2618 SliderPanel.setPIDSliderSource(alignPanel,
2619 viewport.getGlobalColourScheme(), "Background");
2620 SliderPanel.showPIDSlider();
2624 protected void modifyConservation_actionPerformed()
2626 if (viewport.getConservationSelected()
2627 && viewport.getGlobalColourScheme() != null)
2629 SliderPanel.setConservationSlider(alignPanel,
2630 viewport.getGlobalColourScheme(), "Background");
2631 SliderPanel.showConservationSlider();
2635 protected void conservationMenuItem_actionPerformed()
2637 viewport.setConservationSelected(conservationMenuItem.getState());
2639 viewport.setAbovePIDThreshold(false);
2640 abovePIDThreshold.setState(false);
2642 changeColour(viewport.getGlobalColourScheme());
2644 modifyConservation_actionPerformed();
2647 public void abovePIDThreshold_actionPerformed()
2649 viewport.setAbovePIDThreshold(abovePIDThreshold.getState());
2651 conservationMenuItem.setState(false);
2652 viewport.setConservationSelected(false);
2654 changeColour(viewport.getGlobalColourScheme());
2656 modifyPID_actionPerformed();
2659 public void sortPairwiseMenuItem_actionPerformed()
2661 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
2662 AlignmentSorter.sortByPID(viewport.getAlignment(), viewport
2663 .getAlignment().getSequenceAt(0), null);
2665 addHistoryItem(new OrderCommand("Pairwise Sort", oldOrder,
2666 viewport.getAlignment()));
2667 alignPanel.paintAlignment(true);
2670 public void sortIDMenuItem_actionPerformed()
2672 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
2673 AlignmentSorter.sortByID(viewport.getAlignment());
2674 addHistoryItem(new OrderCommand("ID Sort", oldOrder,
2675 viewport.getAlignment()));
2676 alignPanel.paintAlignment(true);
2679 public void sortLengthMenuItem_actionPerformed()
2681 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
2682 AlignmentSorter.sortByLength(viewport.getAlignment());
2683 addHistoryItem(new OrderCommand("Length Sort", oldOrder,
2684 viewport.getAlignment()));
2685 alignPanel.paintAlignment(true);
2688 public void sortGroupMenuItem_actionPerformed()
2690 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
2691 AlignmentSorter.sortByGroup(viewport.getAlignment());
2692 addHistoryItem(new OrderCommand("Group Sort", oldOrder,
2693 viewport.getAlignment()));
2694 alignPanel.paintAlignment(true);
2698 public void removeRedundancyMenuItem_actionPerformed()
2700 new RedundancyPanel(alignPanel);
2703 public void pairwiseAlignmentMenuItem_actionPerformed()
2705 if (viewport.getSelectionGroup() != null
2706 && viewport.getSelectionGroup().getSize() > 1)
2708 Frame frame = new Frame();
2709 frame.add(new PairwiseAlignPanel(alignPanel));
2710 jalview.bin.JalviewLite.addFrame(frame,
2711 MessageManager.getString("action.pairwise_alignment"), 600,
2716 public void PCAMenuItem_actionPerformed()
2718 // are the sequences aligned?
2719 if (!viewport.getAlignment().isAligned(false))
2722 int Width = viewport.getAlignment().getWidth();
2724 for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++)
2726 current = viewport.getAlignment().getSequenceAt(i);
2728 if (current.getLength() < Width)
2730 current.insertCharAt(Width - 1, viewport.getGapCharacter());
2733 alignPanel.paintAlignment(true);
2736 if ((viewport.getSelectionGroup() != null
2737 && viewport.getSelectionGroup().getSize() < 4 && viewport
2738 .getSelectionGroup().getSize() > 0)
2739 || viewport.getAlignment().getHeight() < 4)
2746 new PCAPanel(viewport);
2747 } catch (java.lang.OutOfMemoryError ex)
2753 public void averageDistanceTreeMenuItem_actionPerformed()
2755 NewTreePanel("AV", "PID", "Average distance tree using PID");
2758 public void neighbourTreeMenuItem_actionPerformed()
2760 NewTreePanel("NJ", "PID", "Neighbour joining tree using PID");
2763 protected void njTreeBlosumMenuItem_actionPerformed()
2765 NewTreePanel("NJ", "BL", "Neighbour joining tree using BLOSUM62");
2768 protected void avTreeBlosumMenuItem_actionPerformed()
2770 NewTreePanel("AV", "BL", "Average distance tree using BLOSUM62");
2773 void NewTreePanel(String type, String pwType, String title)
2775 // are the sequences aligned?
2776 if (!viewport.getAlignment().isAligned(false))
2779 int Width = viewport.getAlignment().getWidth();
2781 for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++)
2783 current = viewport.getAlignment().getSequenceAt(i);
2785 if (current.getLength() < Width)
2787 current.insertCharAt(Width - 1, viewport.getGapCharacter());
2790 alignPanel.paintAlignment(true);
2794 if ((viewport.getSelectionGroup() != null && viewport
2795 .getSelectionGroup().getSize() > 1)
2796 || (viewport.getAlignment().getHeight() > 1))
2798 final TreePanel tp = new TreePanel(alignPanel, type, pwType);
2800 addTreeMenuItem(tp, title);
2802 jalview.bin.JalviewLite.addFrame(tp, title, 600, 500);
2806 void loadTree_actionPerformed()
2808 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
2809 cap.setText(MessageManager.getString("label.paste_newick_tree_file"));
2810 cap.setTreeImport();
2811 Frame frame = new Frame();
2813 jalview.bin.JalviewLite.addFrame(frame,
2814 MessageManager.getString("label.paste_newick_file"), 400, 300);
2817 public void loadTree(jalview.io.NewickFile tree, String treeFile)
2819 TreePanel tp = new TreePanel(alignPanel, treeFile,
2820 MessageManager.getString("label.load_tree_from_file"), tree);
2821 jalview.bin.JalviewLite.addFrame(tp, treeFile, 600, 500);
2822 addTreeMenuItem(tp, treeFile);
2826 * sort the alignment using the given treePanel
2829 * tree used to sort view
2831 * string used for undo event name
2833 public void sortByTree(TreePanel treePanel, String title)
2835 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
2837 .sortByTree(viewport.getAlignment(), treePanel.getTree());
2838 // addHistoryItem(new HistoryItem("Sort", viewport.alignment,
2839 // HistoryItem.SORT));
2840 addHistoryItem(new OrderCommand(MessageManager.formatMessage(
2841 "label.order_by_params", new String[]
2842 { title }), oldOrder, viewport.getAlignment()));
2843 alignPanel.paintAlignment(true);
2847 * Do any automatic reordering of the alignment and add the necessary bits to
2848 * the menu structure for the new tree
2853 protected void addTreeMenuItem(final TreePanel treePanel,
2856 final MenuItem item = new MenuItem(title);
2857 sortByTreeMenu.add(item);
2858 item.addActionListener(new java.awt.event.ActionListener()
2861 public void actionPerformed(ActionEvent evt)
2863 sortByTree(treePanel, title); // treePanel.getTitle());
2867 treePanel.addWindowListener(new WindowAdapter()
2870 public void windowOpened(WindowEvent e)
2872 if (viewport.sortByTree)
2874 sortByTree(treePanel, title);
2876 super.windowOpened(e);
2880 public void windowClosing(WindowEvent e)
2882 sortByTreeMenu.remove(item);
2887 public boolean sortBy(AlignmentOrder alorder, String undoname)
2889 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
2890 if (viewport.applet.debug)
2892 System.err.println("Sorting " + alorder.getOrder().size()
2893 + " in alignment '" + getTitle() + "'");
2895 AlignmentSorter.sortBy(viewport.getAlignment(), alorder);
2896 if (undoname != null)
2898 addHistoryItem(new OrderCommand(undoname, oldOrder,
2899 viewport.getAlignment()));
2901 alignPanel.paintAlignment(true);
2905 protected void documentation_actionPerformed()
2907 alignPanel.av.applet.openJalviewHelpUrl();
2910 protected void about_actionPerformed()
2913 class AboutPanel extends Canvas
2919 public AboutPanel(String version, String builddate)
2921 this.version = version;
2922 this.builddate = builddate;
2926 public void paint(Graphics g)
2928 g.setColor(Color.white);
2929 g.fillRect(0, 0, getSize().width, getSize().height);
2930 g.setFont(new Font("Helvetica", Font.PLAIN, 12));
2931 FontMetrics fm = g.getFontMetrics();
2932 int fh = fm.getHeight();
2934 g.setColor(Color.black);
2935 // TODO: update this text for each release or centrally store it for
2936 // lite and application
2937 g.setFont(new Font("Helvetica", Font.BOLD, 14));
2938 g.drawString(MessageManager.formatMessage(
2939 "label.jalviewLite_release", new String[]
2940 { version }), x, y += fh);
2941 g.setFont(new Font("Helvetica", Font.BOLD, 12));
2942 g.drawString(MessageManager.formatMessage(
2943 "label.jaview_build_date", new String[]
2944 { builddate }), x, y += fh);
2945 g.setFont(new Font("Helvetica", Font.PLAIN, 12));
2946 g.drawString(MessageManager.getString("label.jalview_authors_1"),
2948 g.drawString(MessageManager.getString("label.jalview_authors_2"),
2949 x + 50, y += fh + 8);
2951 MessageManager.getString("label.jalview_dev_managers"), x,
2953 g.drawString(MessageManager
2954 .getString("label.jalview_distribution_lists"), x, y += fh);
2955 g.drawString(MessageManager.getString("label.jalview_please_cite"),
2958 MessageManager.getString("label.jalview_cite_1_authors"),
2961 MessageManager.getString("label.jalview_cite_1_title"), x,
2963 g.drawString(MessageManager.getString("label.jalview_cite_1_ref"),
2968 Frame frame = new Frame();
2969 frame.add(new AboutPanel(JalviewLite.getVersion(), JalviewLite
2971 jalview.bin.JalviewLite.addFrame(frame,
2972 MessageManager.getString("label.jalview"), 580, 220);
2976 public void showURL(String url, String target)
2978 if (viewport.applet == null)
2980 System.out.println("Not running as applet - no browser available.");
2984 viewport.applet.showURL(url, target);
2988 // ////////////////////////////////////////////////////////////////////////////////
2989 // JBuilder Graphics here
2991 MenuBar alignFrameMenuBar = new MenuBar();
2993 Menu fileMenu = new Menu(MessageManager.getString("action.file"));
2995 MenuItem loadApplication = new MenuItem(
2996 MessageManager.getString("label.view_full_application"));
2998 MenuItem loadTree = new MenuItem(
2999 MessageManager.getString("label.load_associated_tree"));
3001 MenuItem loadAnnotations = new MenuItem(
3002 MessageManager.getString("label.load_features_annotations"));
3004 MenuItem outputFeatures = new MenuItem(
3005 MessageManager.getString("label.export_features").concat("..."));
3007 MenuItem outputAnnotations = new MenuItem(
3008 MessageManager.getString("label.export_annotations").concat("..."));
3010 MenuItem closeMenuItem = new MenuItem(
3011 MessageManager.getString("action.close"));
3013 MenuItem selectAllSequenceMenuItem = new MenuItem(
3014 MessageManager.getString("action.select_all"));
3016 MenuItem deselectAllSequenceMenuItem = new MenuItem(
3017 MessageManager.getString("action.deselect_all"));
3019 MenuItem invertSequenceMenuItem = new MenuItem(
3020 MessageManager.getString("action.invert_selection"));
3022 MenuItem remove2LeftMenuItem = new MenuItem();
3024 MenuItem remove2RightMenuItem = new MenuItem();
3026 MenuItem removeGappedColumnMenuItem = new MenuItem();
3028 MenuItem removeAllGapsMenuItem = new MenuItem();
3030 CheckboxMenuItem viewBoxesMenuItem = new CheckboxMenuItem();
3032 CheckboxMenuItem viewTextMenuItem = new CheckboxMenuItem();
3034 MenuItem sortPairwiseMenuItem = new MenuItem();
3036 MenuItem sortIDMenuItem = new MenuItem();
3038 MenuItem sortLengthMenuItem = new MenuItem();
3040 MenuItem sortGroupMenuItem = new MenuItem();
3042 MenuItem removeRedundancyMenuItem = new MenuItem();
3044 MenuItem pairwiseAlignmentMenuItem = new MenuItem();
3046 MenuItem PCAMenuItem = new MenuItem();
3048 MenuItem averageDistanceTreeMenuItem = new MenuItem();
3050 MenuItem neighbourTreeMenuItem = new MenuItem();
3052 BorderLayout borderLayout1 = new BorderLayout();
3054 public Label statusBar = new Label();
3056 MenuItem clustalColour = new MenuItem();
3058 MenuItem zappoColour = new MenuItem();
3060 MenuItem taylorColour = new MenuItem();
3062 MenuItem hydrophobicityColour = new MenuItem();
3064 MenuItem helixColour = new MenuItem();
3066 MenuItem strandColour = new MenuItem();
3068 MenuItem turnColour = new MenuItem();
3070 MenuItem buriedColour = new MenuItem();
3072 MenuItem purinePyrimidineColour = new MenuItem();
3074 MenuItem RNAInteractionColour = new MenuItem();
3076 MenuItem RNAHelixColour = new MenuItem();
3078 MenuItem userDefinedColour = new MenuItem();
3080 MenuItem PIDColour = new MenuItem();
3082 MenuItem BLOSUM62Colour = new MenuItem();
3084 MenuItem tcoffeeColour = new MenuItem();
3086 MenuItem njTreeBlosumMenuItem = new MenuItem();
3088 MenuItem avDistanceTreeBlosumMenuItem = new MenuItem();
3090 CheckboxMenuItem annotationPanelMenuItem = new CheckboxMenuItem();
3092 CheckboxMenuItem colourTextMenuItem = new CheckboxMenuItem();
3094 CheckboxMenuItem displayNonconservedMenuItem = new CheckboxMenuItem();
3096 MenuItem alProperties = new MenuItem(
3097 MessageManager.getString("label.alignment_props"));
3099 MenuItem overviewMenuItem = new MenuItem();
3101 MenuItem undoMenuItem = new MenuItem();
3103 MenuItem redoMenuItem = new MenuItem();
3105 CheckboxMenuItem conservationMenuItem = new CheckboxMenuItem();
3107 MenuItem noColourmenuItem = new MenuItem();
3109 CheckboxMenuItem wrapMenuItem = new CheckboxMenuItem();
3111 CheckboxMenuItem renderGapsMenuItem = new CheckboxMenuItem();
3113 MenuItem findMenuItem = new MenuItem();
3115 CheckboxMenuItem abovePIDThreshold = new CheckboxMenuItem();
3117 MenuItem nucleotideColour = new MenuItem();
3119 MenuItem deleteGroups = new MenuItem();
3121 MenuItem grpsFromSelection = new MenuItem();
3123 MenuItem createGroup = new MenuItem();
3125 MenuItem unGroup = new MenuItem();
3127 MenuItem delete = new MenuItem();
3129 MenuItem copy = new MenuItem();
3131 MenuItem cut = new MenuItem();
3133 Menu pasteMenu = new Menu();
3135 MenuItem pasteNew = new MenuItem();
3137 MenuItem pasteThis = new MenuItem();
3139 CheckboxMenuItem applyToAllGroups = new CheckboxMenuItem();
3141 MenuItem font = new MenuItem();
3143 CheckboxMenuItem scaleAbove = new CheckboxMenuItem();
3145 CheckboxMenuItem scaleLeft = new CheckboxMenuItem();
3147 CheckboxMenuItem scaleRight = new CheckboxMenuItem();
3149 MenuItem modifyPID = new MenuItem();
3151 MenuItem modifyConservation = new MenuItem();
3153 CheckboxMenuItem autoCalculate = null;
3155 CheckboxMenuItem sortByTree = new CheckboxMenuItem(
3156 "Sort Alignment With New Tree", true);
3158 Menu sortByTreeMenu = new Menu();
3160 MenuItem inputText = new MenuItem();
3162 MenuItem documentation = new MenuItem();
3164 MenuItem about = new MenuItem();
3166 CheckboxMenuItem seqLimits = new CheckboxMenuItem();
3168 CheckboxMenuItem centreColumnLabelFlag = new CheckboxMenuItem();
3170 CheckboxMenuItem followMouseOverFlag = new CheckboxMenuItem();
3172 CheckboxMenuItem showSequenceLogo = new CheckboxMenuItem();
3174 CheckboxMenuItem applyAutoAnnotationSettings = new CheckboxMenuItem();
3176 CheckboxMenuItem showConsensusHistogram = new CheckboxMenuItem();
3178 CheckboxMenuItem showGroupConsensus = new CheckboxMenuItem();
3180 CheckboxMenuItem showGroupConservation = new CheckboxMenuItem();
3182 CheckboxMenuItem normSequenceLogo = new CheckboxMenuItem();
3185 * Initialise menus and other items
3189 private void jbInit() throws Exception
3191 setMenuBar(alignFrameMenuBar);
3194 * Configure File menu items and actions
3197 .setLabel(MessageManager.getString("label.input_from_textbox"));
3198 inputText.addActionListener(this);
3199 Menu outputTextboxMenu = new Menu(
3200 MessageManager.getString("label.out_to_textbox"));
3201 for (int i = 0; i < jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS.length; i++)
3204 MenuItem item = new MenuItem(
3205 jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS[i]);
3207 item.addActionListener(new java.awt.event.ActionListener()
3210 public void actionPerformed(ActionEvent e)
3212 outputText_actionPerformed(e);
3216 outputTextboxMenu.add(item);
3218 closeMenuItem.addActionListener(this);
3219 loadApplication.addActionListener(this);
3220 loadTree.addActionListener(this);
3221 loadAnnotations.addActionListener(this);
3222 outputFeatures.addActionListener(this);
3223 outputAnnotations.addActionListener(this);
3226 * Configure Edit menu items and actions
3228 undoMenuItem.setEnabled(false);
3229 undoMenuItem.setLabel(MessageManager.getString("action.undo"));
3230 undoMenuItem.addActionListener(this);
3231 redoMenuItem.setEnabled(false);
3232 redoMenuItem.setLabel(MessageManager.getString("action.redo"));
3233 redoMenuItem.addActionListener(this);
3234 copy.setLabel(MessageManager.getString("action.copy"));
3235 copy.addActionListener(this);
3236 cut.setLabel(MessageManager.getString("action.cut"));
3237 cut.addActionListener(this);
3238 delete.setLabel(MessageManager.getString("action.delete"));
3239 delete.addActionListener(this);
3240 pasteMenu.setLabel(MessageManager.getString("action.paste"));
3241 pasteNew.setLabel(MessageManager.getString("label.to_new_alignment"));
3242 pasteNew.addActionListener(this);
3243 pasteThis.setLabel(MessageManager.getString("label.to_this_alignment"));
3244 pasteThis.addActionListener(this);
3245 remove2LeftMenuItem.setLabel(MessageManager
3246 .getString("action.remove_left"));
3247 remove2LeftMenuItem.addActionListener(this);
3248 remove2RightMenuItem.setLabel(MessageManager
3249 .getString("action.remove_right"));
3250 remove2RightMenuItem.addActionListener(this);
3251 removeGappedColumnMenuItem.setLabel(MessageManager
3252 .getString("action.remove_empty_columns"));
3253 removeGappedColumnMenuItem.addActionListener(this);
3254 removeAllGapsMenuItem.setLabel(MessageManager
3255 .getString("action.remove_all_gaps"));
3256 removeAllGapsMenuItem.addActionListener(this);
3257 removeRedundancyMenuItem.setLabel(MessageManager.getString(
3258 "action.remove_redundancy").concat("..."));
3259 removeRedundancyMenuItem.addActionListener(this);
3262 * Configure Select menu items and actions
3264 findMenuItem.setLabel(MessageManager.getString("action.find"));
3265 findMenuItem.addActionListener(this);
3266 selectAllSequenceMenuItem.addActionListener(this);
3267 deselectAllSequenceMenuItem.addActionListener(this);
3268 invertSequenceMenuItem.setLabel(MessageManager
3269 .getString("action.invert_sequence_selection"));
3270 invertSequenceMenuItem.addActionListener(this);
3271 invertColSel.setLabel(MessageManager
3272 .getString("action.invert_column_selection"));
3273 invertColSel.addActionListener(this);
3274 deleteGroups.setLabel(MessageManager
3275 .getString("action.undefine_groups"));
3276 deleteGroups.addActionListener(this);
3277 grpsFromSelection.setLabel(MessageManager
3278 .getString("action.make_groups_selection"));
3279 grpsFromSelection.addActionListener(this);
3280 createGroup.setLabel(MessageManager.getString("action.create_group"));
3281 unGroup.setLabel(MessageManager.getString("action.remove_group"));
3282 annotationColumnSelection.setLabel("Select by Annotation");
3283 annotationColumnSelection.addActionListener(this);
3286 * Configure View menu items and actions
3288 newView.setLabel(MessageManager.getString("action.new_view"));
3289 newView.addActionListener(this);
3290 Menu showMenu = new Menu(MessageManager.getString("action.show"));
3291 showColumns.setLabel(MessageManager.getString("label.all_columns"));
3292 showSeqs.setLabel(MessageManager.getString("label.all_sequences"));
3293 Menu hideMenu = new Menu(MessageManager.getString("action.hide"));
3295 .setLabel(MessageManager.getString("label.selected_columns"));
3296 hideSequences.setLabel(MessageManager
3297 .getString("label.selected_sequences"));
3298 hideAllButSelection.setLabel(MessageManager
3299 .getString("label.all_but_selected_region"));
3300 hideAllSelection.setLabel(MessageManager
3301 .getString("label.selected_region"));
3302 showAllHidden.setLabel(MessageManager
3303 .getString("label.all_sequences_columns"));
3304 showColumns.addActionListener(this);
3305 showSeqs.addActionListener(this);
3306 hideColumns.addActionListener(this);
3307 hideSequences.addActionListener(this);
3308 hideAllButSelection.addActionListener(this);
3309 hideAllSelection.addActionListener(this);
3310 showAllHidden.addActionListener(this);
3311 featureSettings.setLabel(MessageManager
3312 .getString("label.feature_settings"));
3313 featureSettings.addActionListener(this);
3314 sequenceFeatures.setLabel(MessageManager
3315 .getString("label.show_sequence_features"));
3316 sequenceFeatures.addItemListener(this);
3317 sequenceFeatures.setState(false);
3318 followMouseOverFlag.setLabel(MessageManager
3319 .getString("label.automatic_scrolling"));
3320 followMouseOverFlag.addItemListener(this);
3321 alProperties.addActionListener(this);
3322 overviewMenuItem.setLabel(MessageManager
3323 .getString("label.overview_window"));
3324 overviewMenuItem.addActionListener(this);
3327 * Configure Annotations menu items and actions
3329 annotationPanelMenuItem.setLabel(MessageManager
3330 .getString("label.show_annotations"));
3331 annotationPanelMenuItem.addItemListener(this);
3332 showGroupConsensus.setLabel(MessageManager
3333 .getString("label.group_consensus"));
3334 showGroupConservation.setLabel(MessageManager
3335 .getString("label.group_conservation"));
3336 showConsensusHistogram.setLabel(MessageManager
3337 .getString("label.show_consensus_histogram"));
3338 showSequenceLogo.setLabel(MessageManager
3339 .getString("label.show_consensus_logo"));
3340 normSequenceLogo.setLabel(MessageManager
3341 .getString("label.norm_consensus_logo"));
3342 applyAutoAnnotationSettings.setLabel(MessageManager
3343 .getString("label.apply_all_groups"));
3344 applyAutoAnnotationSettings.setState(true);
3345 Menu autoAnnMenu = new Menu(
3346 MessageManager.getString("label.autocalculated_annotation"));
3347 showGroupConsensus.addItemListener(this);
3348 showGroupConservation.addItemListener(this);
3349 showConsensusHistogram.addItemListener(this);
3350 showSequenceLogo.addItemListener(this);
3351 normSequenceLogo.addItemListener(this);
3352 applyAutoAnnotationSettings.addItemListener(this);
3353 showAlignmentAnnotations = new CheckboxMenuItem(
3354 MessageManager.getString("label.show_all_al_annotations"));
3355 showSequenceAnnotations = new CheckboxMenuItem(
3356 MessageManager.getString("label.show_all_seq_annotations"));
3357 sortAnnBySequence = new CheckboxMenuItem(
3358 MessageManager.getString("label.sort_annotations_by_sequence"));
3359 sortAnnByLabel = new CheckboxMenuItem(
3360 MessageManager.getString("label.sort_annotations_by_label"));
3361 showAutoFirst = new CheckboxMenuItem(
3362 MessageManager.getString("label.show_first"));
3363 showAutoLast = new CheckboxMenuItem(
3364 MessageManager.getString("label.show_last"));
3365 showAlignmentAnnotations.addItemListener(this);
3366 showSequenceAnnotations.addItemListener(this);
3367 sortAnnBySequence.addItemListener(this);
3368 sortAnnByLabel.addItemListener(this);
3369 showAutoFirst.addItemListener(this);
3370 showAutoLast.addItemListener(this);
3373 * Configure Format menu items and actions
3375 font.setLabel(MessageManager.getString("action.font"));
3376 font.addActionListener(this);
3377 scaleAbove.setLabel(MessageManager.getString("action.scale_above"));
3378 scaleAbove.setState(true);
3379 scaleAbove.setEnabled(false);
3380 scaleAbove.addItemListener(this);
3381 scaleLeft.setEnabled(false);
3382 scaleLeft.setState(true);
3383 scaleLeft.setLabel(MessageManager.getString("action.scale_left"));
3384 scaleLeft.addItemListener(this);
3385 scaleRight.setEnabled(false);
3386 scaleRight.setState(true);
3387 scaleRight.setLabel(MessageManager.getString("action.scale_right"));
3388 scaleRight.addItemListener(this);
3389 viewBoxesMenuItem.setLabel(MessageManager.getString("action.boxes"));
3390 viewBoxesMenuItem.setState(true);
3391 viewBoxesMenuItem.addItemListener(this);
3392 viewTextMenuItem.setLabel(MessageManager.getString("action.text"));
3393 viewTextMenuItem.setState(true);
3394 viewTextMenuItem.addItemListener(this);
3395 colourTextMenuItem.setLabel(MessageManager
3396 .getString("label.colour_text"));
3397 colourTextMenuItem.addItemListener(this);
3398 displayNonconservedMenuItem.setLabel(MessageManager
3399 .getString("label.show_non_conversed"));
3400 displayNonconservedMenuItem.addItemListener(this);
3401 wrapMenuItem.setLabel(MessageManager.getString("action.wrap"));
3402 wrapMenuItem.addItemListener(this);
3403 renderGapsMenuItem.setLabel(MessageManager
3404 .getString("action.show_gaps"));
3405 renderGapsMenuItem.setState(true);
3406 renderGapsMenuItem.addItemListener(this);
3407 centreColumnLabelFlag.setLabel(MessageManager
3408 .getString("label.centre_column_labels"));
3409 centreColumnLabelFlag.addItemListener(this);
3410 seqLimits.setState(true);
3411 seqLimits.setLabel(MessageManager
3412 .getString("label.show_sequence_limits"));
3413 seqLimits.addItemListener(this);
3416 * Configure Colour menu items and actions
3418 applyToAllGroups.setLabel(MessageManager
3419 .getString("label.apply_colour_to_all_groups"));
3420 applyToAllGroups.setState(true);
3421 applyToAllGroups.addItemListener(this);
3422 clustalColour.setLabel(MessageManager.getString("label.clustalx"));
3423 clustalColour.addActionListener(this);
3424 zappoColour.setLabel(MessageManager.getString("label.zappo"));
3425 zappoColour.addActionListener(this);
3426 taylorColour.setLabel(MessageManager.getString("label.taylor"));
3427 taylorColour.addActionListener(this);
3428 hydrophobicityColour.setLabel(MessageManager
3429 .getString("label.hydrophobicity"));
3430 hydrophobicityColour.addActionListener(this);
3432 .setLabel(MessageManager.getString("label.helix_propensity"));
3433 helixColour.addActionListener(this);
3434 strandColour.setLabel(MessageManager
3435 .getString("label.strand_propensity"));
3436 strandColour.addActionListener(this);
3437 turnColour.setLabel(MessageManager.getString("label.turn_propensity"));
3438 turnColour.addActionListener(this);
3439 buriedColour.setLabel(MessageManager.getString("label.buried_index"));
3440 buriedColour.addActionListener(this);
3441 purinePyrimidineColour.setLabel(MessageManager
3442 .getString("label.purine_pyrimidine"));
3443 purinePyrimidineColour.addActionListener(this);
3444 RNAInteractionColour.setLabel(MessageManager
3445 .getString("label.rna_interaction"));
3446 RNAInteractionColour.addActionListener(this);
3447 RNAHelixColour.setLabel(MessageManager
3448 .getString("action.by_rna_helixes"));
3449 RNAHelixColour.addActionListener(this);
3450 userDefinedColour.setLabel(MessageManager
3451 .getString("action.user_defined"));
3452 userDefinedColour.addActionListener(this);
3453 PIDColour.setLabel(MessageManager
3454 .getString("label.percentage_identity"));
3455 PIDColour.addActionListener(this);
3456 BLOSUM62Colour.setLabel(MessageManager
3457 .getString("label.blosum62_score"));
3458 BLOSUM62Colour.addActionListener(this);
3460 .setLabel(MessageManager.getString("label.tcoffee_scores"));
3461 // it will be enabled only if a score file is provided
3462 tcoffeeColour.setEnabled(false);
3463 tcoffeeColour.addActionListener(this);
3464 conservationMenuItem.setLabel(MessageManager
3465 .getString("action.by_conservation"));
3466 conservationMenuItem.addItemListener(this);
3467 noColourmenuItem.setLabel(MessageManager.getString("label.none"));
3468 noColourmenuItem.addActionListener(this);
3469 abovePIDThreshold.setLabel(MessageManager
3470 .getString("label.above_identity_threshold"));
3471 abovePIDThreshold.addItemListener(this);
3472 nucleotideColour.setLabel(MessageManager.getString("label.nucleotide"));
3473 nucleotideColour.addActionListener(this);
3474 modifyPID.setLabel(MessageManager
3475 .getString("label.modify_identity_thereshold"));
3476 modifyPID.addActionListener(this);
3477 modifyConservation.setLabel(MessageManager
3478 .getString("label.modify_conservation_thereshold"));
3479 modifyConservation.addActionListener(this);
3480 annotationColour.setLabel(MessageManager
3481 .getString("action.by_annotation"));
3482 annotationColour.addActionListener(this);
3485 * Configure Calculate menu items and actions
3487 sortPairwiseMenuItem.setLabel(MessageManager
3488 .getString("action.by_pairwise_id"));
3489 sortPairwiseMenuItem.addActionListener(this);
3490 sortIDMenuItem.setLabel(MessageManager.getString("action.by_id"));
3491 sortIDMenuItem.addActionListener(this);
3492 sortLengthMenuItem.setLabel(MessageManager
3493 .getString("action.by_length"));
3494 sortLengthMenuItem.addActionListener(this);
3495 sortGroupMenuItem.setLabel(MessageManager.getString("action.by_group"));
3496 sortGroupMenuItem.addActionListener(this);
3497 pairwiseAlignmentMenuItem.setLabel(MessageManager
3498 .getString("action.pairwise_alignment"));
3499 pairwiseAlignmentMenuItem.addActionListener(this);
3500 PCAMenuItem.setLabel(MessageManager
3501 .getString("label.principal_component_analysis"));
3502 PCAMenuItem.addActionListener(this);
3503 autoCalculate = new CheckboxMenuItem(
3504 MessageManager.getString("label.autocalculate_consensus"), true);
3505 averageDistanceTreeMenuItem.setLabel(MessageManager
3506 .getString("label.average_distance_identity"));
3507 averageDistanceTreeMenuItem.addActionListener(this);
3508 neighbourTreeMenuItem.setLabel(MessageManager
3509 .getString("label.neighbour_joining_identity"));
3510 neighbourTreeMenuItem.addActionListener(this);
3511 avDistanceTreeBlosumMenuItem.setLabel(MessageManager
3512 .getString("label.average_distance_bloslum62"));
3513 avDistanceTreeBlosumMenuItem.addActionListener(this);
3514 njTreeBlosumMenuItem.setLabel(MessageManager
3515 .getString("label.neighbour_blosum62"));
3516 njTreeBlosumMenuItem.addActionListener(this);
3517 sortByTreeMenu.setLabel(MessageManager
3518 .getString("action.by_tree_order"));
3519 Menu sortMenu = new Menu(MessageManager.getString("action.sort"));
3520 Menu calculateTreeMenu = new Menu(
3521 MessageManager.getString("action.calculate_tree"));
3522 autoCalculate.addItemListener(this);
3523 sortByTree.addItemListener(this);
3526 * Configure Help menu items and actions
3528 Menu helpMenu = new Menu(MessageManager.getString("action.help"));
3529 documentation.setLabel(MessageManager.getString("label.documentation"));
3530 documentation.addActionListener(this);
3531 about.setLabel(MessageManager.getString("label.about"));
3532 about.addActionListener(this);
3535 * Add top level menus to frame
3537 alignFrameMenuBar.add(fileMenu);
3538 Menu editMenu = new Menu(MessageManager.getString("action.edit"));
3539 alignFrameMenuBar.add(editMenu);
3540 Menu selectMenu = new Menu(MessageManager.getString("action.select"));
3541 alignFrameMenuBar.add(selectMenu);
3542 Menu viewMenu = new Menu(MessageManager.getString("action.view"));
3543 alignFrameMenuBar.add(viewMenu);
3544 Menu annotationsMenu = new Menu(
3545 MessageManager.getString("action.annotations"));
3546 alignFrameMenuBar.add(annotationsMenu);
3547 Menu formatMenu = new Menu(MessageManager.getString("action.format"));
3548 alignFrameMenuBar.add(formatMenu);
3549 Menu colourMenu = new Menu(MessageManager.getString("action.colour"));
3550 alignFrameMenuBar.add(colourMenu);
3551 Menu calculateMenu = new Menu(
3552 MessageManager.getString("action.calculate"));
3553 alignFrameMenuBar.add(calculateMenu);
3554 alignFrameMenuBar.add(helpMenu);
3559 fileMenu.add(inputText);
3560 fileMenu.add(loadTree);
3561 fileMenu.add(loadAnnotations);
3562 fileMenu.addSeparator();
3563 fileMenu.add(outputTextboxMenu);
3564 fileMenu.add(outputFeatures);
3565 fileMenu.add(outputAnnotations);
3566 if (jalviewServletURL != null)
3568 fileMenu.add(loadApplication);
3570 fileMenu.addSeparator();
3571 fileMenu.add(closeMenuItem);
3576 editMenu.add(undoMenuItem);
3577 editMenu.add(redoMenuItem);
3580 pasteMenu.add(pasteNew);
3581 pasteMenu.add(pasteThis);
3582 editMenu.add(pasteMenu);
3583 editMenu.add(delete);
3584 editMenu.addSeparator();
3585 editMenu.add(remove2LeftMenuItem);
3586 editMenu.add(remove2RightMenuItem);
3587 editMenu.add(removeGappedColumnMenuItem);
3588 editMenu.add(removeAllGapsMenuItem);
3589 editMenu.add(removeRedundancyMenuItem);
3594 selectMenu.add(findMenuItem);
3595 selectMenu.addSeparator();
3596 selectMenu.add(selectAllSequenceMenuItem);
3597 selectMenu.add(deselectAllSequenceMenuItem);
3598 selectMenu.add(invertSequenceMenuItem);
3599 selectMenu.add(invertColSel);
3600 selectMenu.add(createGroup);
3601 selectMenu.add(unGroup);
3602 selectMenu.add(grpsFromSelection);
3603 selectMenu.add(deleteGroups);
3604 selectMenu.add(annotationColumnSelection);
3609 viewMenu.add(newView);
3610 viewMenu.addSeparator();
3611 showMenu.add(showColumns);
3612 showMenu.add(showSeqs);
3613 showMenu.add(showAllHidden);
3614 viewMenu.add(showMenu);
3615 hideMenu.add(hideColumns);
3616 hideMenu.add(hideSequences);
3617 hideMenu.add(hideAllSelection);
3618 hideMenu.add(hideAllButSelection);
3619 viewMenu.add(hideMenu);
3620 viewMenu.addSeparator();
3621 viewMenu.add(followMouseOverFlag);
3622 viewMenu.addSeparator();
3623 viewMenu.add(sequenceFeatures);
3624 viewMenu.add(featureSettings);
3625 viewMenu.addSeparator();
3626 viewMenu.add(alProperties);
3627 viewMenu.addSeparator();
3628 viewMenu.add(overviewMenuItem);
3633 annotationsMenu.add(annotationPanelMenuItem);
3634 annotationsMenu.addSeparator();
3635 annotationsMenu.add(showAlignmentAnnotations);
3636 annotationsMenu.add(showSequenceAnnotations);
3637 annotationsMenu.add(sortAnnBySequence);
3638 annotationsMenu.add(sortAnnByLabel);
3639 annotationsMenu.addSeparator();
3640 autoAnnMenu.add(showAutoFirst);
3641 autoAnnMenu.add(showAutoLast);
3642 autoAnnMenu.addSeparator();
3643 autoAnnMenu.add(applyAutoAnnotationSettings);
3644 autoAnnMenu.add(showConsensusHistogram);
3645 autoAnnMenu.add(showSequenceLogo);
3646 autoAnnMenu.add(normSequenceLogo);
3647 autoAnnMenu.addSeparator();
3648 autoAnnMenu.add(showGroupConservation);
3649 autoAnnMenu.add(showGroupConsensus);
3650 annotationsMenu.add(autoAnnMenu);
3655 formatMenu.add(font);
3656 formatMenu.add(seqLimits);
3657 formatMenu.add(wrapMenuItem);
3658 formatMenu.add(scaleAbove);
3659 formatMenu.add(scaleLeft);
3660 formatMenu.add(scaleRight);
3661 formatMenu.add(viewBoxesMenuItem);
3662 formatMenu.add(viewTextMenuItem);
3663 formatMenu.add(colourTextMenuItem);
3664 formatMenu.add(displayNonconservedMenuItem);
3665 formatMenu.add(renderGapsMenuItem);
3666 formatMenu.add(centreColumnLabelFlag);
3671 colourMenu.add(applyToAllGroups);
3672 colourMenu.addSeparator();
3673 colourMenu.add(noColourmenuItem);
3674 colourMenu.add(clustalColour);
3675 colourMenu.add(BLOSUM62Colour);
3676 colourMenu.add(PIDColour);
3677 colourMenu.add(zappoColour);
3678 colourMenu.add(taylorColour);
3679 colourMenu.add(hydrophobicityColour);
3680 colourMenu.add(helixColour);
3681 colourMenu.add(strandColour);
3682 colourMenu.add(turnColour);
3683 colourMenu.add(buriedColour);
3684 colourMenu.add(nucleotideColour);
3685 colourMenu.add(purinePyrimidineColour);
3686 // colourMenu.add(RNAInteractionColour);
3687 colourMenu.add(tcoffeeColour);
3688 colourMenu.add(userDefinedColour);
3689 colourMenu.addSeparator();
3690 colourMenu.add(conservationMenuItem);
3691 colourMenu.add(modifyConservation);
3692 colourMenu.add(abovePIDThreshold);
3693 colourMenu.add(modifyPID);
3694 colourMenu.add(annotationColour);
3695 colourMenu.add(RNAHelixColour);
3700 sortMenu.add(sortIDMenuItem);
3701 sortMenu.add(sortLengthMenuItem);
3702 sortMenu.add(sortByTreeMenu);
3703 sortMenu.add(sortGroupMenuItem);
3704 sortMenu.add(sortPairwiseMenuItem);
3705 calculateMenu.add(sortMenu);
3706 calculateTreeMenu.add(averageDistanceTreeMenuItem);
3707 calculateTreeMenu.add(neighbourTreeMenuItem);
3708 calculateTreeMenu.add(avDistanceTreeBlosumMenuItem);
3709 calculateTreeMenu.add(njTreeBlosumMenuItem);
3710 calculateMenu.add(calculateTreeMenu);
3711 calculateMenu.addSeparator();
3712 calculateMenu.add(pairwiseAlignmentMenuItem);
3713 calculateMenu.add(PCAMenuItem);
3714 calculateMenu.add(autoCalculate);
3715 calculateMenu.add(sortByTree);
3720 helpMenu.add(documentation);
3721 helpMenu.add(about);
3726 statusBar.setBackground(Color.white);
3727 statusBar.setFont(new java.awt.Font("Verdana", 0, 11));
3728 statusBar.setText(MessageManager.getString("label.status_bar"));
3729 this.add(statusBar, BorderLayout.SOUTH);
3732 public void setStatus(String string)
3734 statusBar.setText(string);
3737 MenuItem featureSettings = new MenuItem();
3739 CheckboxMenuItem sequenceFeatures = new CheckboxMenuItem();
3741 MenuItem annotationColour = new MenuItem();
3743 MenuItem annotationColumnSelection = new MenuItem();
3745 MenuItem invertColSel = new MenuItem();
3747 MenuItem showColumns = new MenuItem();
3749 MenuItem showSeqs = new MenuItem();
3751 MenuItem hideColumns = new MenuItem();
3753 MenuItem hideSequences = new MenuItem();
3755 MenuItem hideAllButSelection = new MenuItem();
3757 MenuItem hideAllSelection = new MenuItem();
3759 MenuItem showAllHidden = new MenuItem();
3761 MenuItem newView = new MenuItem();
3763 private CheckboxMenuItem showAlignmentAnnotations;
3765 private CheckboxMenuItem showSequenceAnnotations;
3767 private CheckboxMenuItem sortAnnBySequence;
3769 private CheckboxMenuItem sortAnnByLabel;
3771 private CheckboxMenuItem showAutoFirst;
3773 private CheckboxMenuItem showAutoLast;
3775 private SplitFrame splitFrame;
3778 * Attach the alignFrame panels after embedding menus, if necessary. This used
3779 * to be called setEmbedded, but is now creates the dropdown menus in a
3780 * platform independent manner to avoid OSX/Mac menu appendage daftness.
3782 * @param reallyEmbedded
3783 * true to attach the view to the applet area on the page rather than
3786 public void createAlignFrameWindow(boolean reallyEmbedded)
3790 embedAlignFrameInApplet(viewport.applet);
3795 // test and embed menu bar if necessary.
3797 if (embedMenuIfNeeded(alignPanel))
3800 * adjust for status bar height too. ? pointless as overridden by layout
3803 alignPanel.setSize(getSize().width,
3804 getSize().height - statusBar.getHeight());
3806 add(statusBar, BorderLayout.SOUTH);
3807 add(alignPanel, BorderLayout.CENTER);
3808 // and register with the applet so it can pass external API calls to us
3809 jalview.bin.JalviewLite.addFrame(this, this.getTitle(),
3816 * Add the components of this AlignFrame to the applet container.
3820 public void embedAlignFrameInApplet(final JalviewLite theApplet)
3823 // Explicitly build the embedded menu panel for the on-page applet
3825 // view cannot be closed if its actually on the page
3826 fileMenu.remove(closeMenuItem);
3827 fileMenu.remove(3); // Remove Separator
3828 // construct embedded menu, using default font
3829 embeddedMenu = makeEmbeddedPopupMenu(alignFrameMenuBar, false, false);
3830 // and actually add the components to the applet area
3831 theApplet.setLayout(new BorderLayout());
3832 theApplet.add(embeddedMenu, BorderLayout.NORTH);
3833 theApplet.add(statusBar, BorderLayout.SOUTH);
3834 // TODO should size be left to the layout manager?
3835 alignPanel.setSize(theApplet.getSize().width,
3836 theApplet.getSize().height - embeddedMenu.getHeight()
3837 - statusBar.getHeight());
3838 theApplet.add(alignPanel, BorderLayout.CENTER);
3839 final AlignFrame me = this;
3840 theApplet.addFocusListener(new FocusListener()
3844 public void focusLost(FocusEvent e)
3846 if (theApplet.currentAlignFrame == me)
3848 theApplet.currentAlignFrame = null;
3853 public void focusGained(FocusEvent e)
3855 theApplet.currentAlignFrame = me;
3858 theApplet.validate();
3862 * create a new binding between structures in an existing jmol viewer instance
3863 * and an alignpanel with sequences that have existing PDBFile entries. Note,
3864 * this does not open a new Jmol window, or modify the display of the
3865 * structures in the original jmol window. Note This method doesn't work
3866 * without an additional javascript library to exchange messages between the
3867 * distinct applets. See http://issues.jalview.org/browse/JAL-621
3870 * JmolViewer instance
3871 * @param sequenceIds
3872 * - sequence Ids to search for associations
3874 public SequenceStructureBinding addStructureViewInstance(
3875 Object jmolviewer, String[] sequenceIds)
3877 Viewer viewer = null;
3880 viewer = (Viewer) jmolviewer;
3881 } catch (ClassCastException ex)
3883 System.err.println("Unsupported viewer object :"
3884 + jmolviewer.getClass());
3888 System.err.println("Can't use this object as a structure viewer:"
3889 + jmolviewer.getClass());
3892 SequenceI[] seqs = null;
3893 if (sequenceIds == null || sequenceIds.length == 0)
3895 seqs = viewport.getAlignment().getSequencesArray();
3899 Vector sqi = new Vector();
3900 AlignmentI al = viewport.getAlignment();
3901 for (int sid = 0; sid < sequenceIds.length; sid++)
3903 SequenceI sq = al.findName(sequenceIds[sid]);
3911 seqs = new SequenceI[sqi.size()];
3912 for (int sid = 0, sSize = sqi.size(); sid < sSize; sid++)
3914 seqs[sid] = (SequenceI) sqi.elementAt(sid);
3922 AAStructureBindingModel jmv = null;
3923 // TODO: search for a jmv that involves viewer
3925 { // create a new viewer/jalview binding.
3926 jmv = new ExtJmol(viewer, alignPanel, new SequenceI[][]
3934 * bind a pdb file to a sequence in the current view
3937 * - sequenceId within the dataset.
3938 * @param pdbEntryString
3939 * - the short name for the PDB file
3941 * - pdb file - either a URL or a valid PDB file.
3942 * @return true if binding was as success TODO: consider making an exception
3943 * structure for indicating when PDB parsing or sequenceId location
3946 public boolean addPdbFile(String sequenceId, String pdbEntryString,
3949 SequenceI toaddpdb = viewport.getAlignment().findName(sequenceId);
3950 boolean needtoadd = false;
3951 if (toaddpdb != null)
3953 Vector pdbe = toaddpdb.getAllPDBEntries();
3954 PDBEntry pdbentry = null;
3955 if (pdbe != null && pdbe.size() > 0)
3957 for (int pe = 0, peSize = pdbe.size(); pe < peSize; pe++)
3959 pdbentry = (PDBEntry) pdbe.elementAt(pe);
3960 if (!pdbentry.getId().equals(pdbEntryString)
3961 && !pdbentry.getFile().equals(pdbFile))
3971 if (pdbentry == null)
3973 pdbentry = new PDBEntry();
3974 pdbentry.setId(pdbEntryString);
3975 pdbentry.setFile(pdbFile);
3976 needtoadd = true; // add this new entry to sequence.
3978 // resolve data source
3979 // TODO: this code should be a refactored to an io package
3980 String protocol = AppletFormatAdapter.resolveProtocol(pdbFile, "PDB");
3981 if (protocol == null)
3987 // make a note of the access mode and add
3988 if (pdbentry.getProperty() == null)
3990 pdbentry.setProperty(new Hashtable());
3992 pdbentry.getProperty().put("protocol", protocol);
3993 toaddpdb.addPDBId(pdbentry);
3994 alignPanel.getStructureSelectionManager()
3995 .registerPDBEntry(pdbentry);
4001 private Object[] cleanSeqChainArrays(SequenceI[] seqs, String[] chains)
4005 Vector sequences = new Vector();
4006 for (int i = 0; i < seqs.length; i++)
4008 if (seqs[i] != null)
4010 sequences.addElement(new Object[]
4011 { seqs[i], (chains != null) ? chains[i] : null });
4014 seqs = new SequenceI[sequences.size()];
4015 chains = new String[sequences.size()];
4016 for (int i = 0, isize = sequences.size(); i < isize; i++)
4018 Object[] oj = (Object[]) sequences.elementAt(i);
4020 seqs[i] = (SequenceI) oj[0];
4021 chains[i] = (String) oj[1];
4029 public void newStructureView(JalviewLite applet, PDBEntry pdb,
4030 SequenceI[] seqs, String[] chains, String protocol)
4032 // Scrub any null sequences from the array
4033 Object[] sqch = cleanSeqChainArrays(seqs, chains);
4034 seqs = (SequenceI[]) sqch[0];
4035 chains = (String[]) sqch[1];
4036 if (seqs == null || seqs.length == 0)
4039 .println("JalviewLite.AlignFrame:newStructureView: No sequence to bind structure to.");
4041 if (protocol == null || protocol.trim().length() == 0
4042 || protocol.equals("null"))
4044 protocol = (String) pdb.getProperty().get("protocol");
4045 if (protocol == null)
4047 System.err.println("Couldn't work out protocol to open structure: "
4052 if (applet.useXtrnalSviewer)
4054 // register the association(s) and quit, don't create any windows.
4055 if (StructureSelectionManager.getStructureSelectionManager(applet)
4056 .setMapping(seqs, chains, pdb.getFile(), protocol) == null)
4058 System.err.println("Failed to map " + pdb.getFile() + " ("
4059 + protocol + ") to any sequences");
4063 if (applet.isAlignPdbStructures() && applet.jmolAvailable)
4065 // can only do alignments with Jmol
4066 // find the last jmol window assigned to this alignment
4067 jalview.appletgui.AppletJmol ajm = null, tajm;
4068 Vector jmols = applet
4069 .getAppletWindow(jalview.appletgui.AppletJmol.class);
4070 for (int i = 0, iSize = jmols.size(); i < iSize; i++)
4072 tajm = (jalview.appletgui.AppletJmol) jmols.elementAt(i);
4073 if (tajm.ap.alignFrame == this)
4082 .println("Incremental adding and aligning structure to existing Jmol view not yet implemented.");
4083 // try and add the pdb structure
4088 // otherwise, create a new window
4089 if (applet.jmolAvailable)
4091 new jalview.appletgui.AppletJmol(pdb, seqs, chains, alignPanel,
4093 applet.lastFrameX += 40;
4094 applet.lastFrameY += 40;
4098 new MCview.AppletPDBViewer(pdb, seqs, chains, alignPanel, protocol);
4103 public void alignedStructureView(JalviewLite applet, PDBEntry[] pdb,
4104 SequenceI[][] seqs, String[][] chains, String[] protocols)
4106 // TODO Auto-generated method stub
4107 System.err.println("Aligned Structure View: Not yet implemented.");
4111 * modify the current selection, providing the user has not made a selection
4115 * - sequences from this alignment
4117 * - columns to be selected on the alignment
4119 public void select(SequenceGroup sel, ColumnSelection csel)
4121 alignPanel.seqPanel.selection(sel, csel, null);
4124 public void scrollTo(int row, int column)
4126 alignPanel.seqPanel.scrollTo(row, column);
4129 public void scrollToRow(int row)
4131 alignPanel.seqPanel.scrollToRow(row);
4134 public void scrollToColumn(int column)
4136 alignPanel.seqPanel.scrollToColumn(column);
4140 * @return the alignments unique ID.
4142 public String getSequenceSetId()
4144 return viewport.getSequenceSetId();
4148 * Load the (T-Coffee) score file from the specified url
4151 * File/URL/T-COFFEE score file contents
4152 * @throws IOException
4153 * @return true if alignment was annotated with data from source
4155 public boolean loadScoreFile(String source) throws IOException
4158 TCoffeeScoreFile file = new TCoffeeScoreFile(source,
4159 AppletFormatAdapter.checkProtocol(source));
4160 if (!file.isValid())
4162 // TODO: raise dialog for gui
4163 System.err.println("Problems parsing T-Coffee scores: "
4164 + file.getWarningMessage());
4165 System.err.println("Origin was:\n" + source);
4170 * check that the score matrix matches the alignment dimensions
4173 if ((aln = viewport.getAlignment()) != null
4174 && (aln.getHeight() != file.getHeight() || aln.getWidth() != file
4177 // TODO: raise a dialog box here rather than bomb out.
4179 .println("The scores matrix does not match the alignment dimensions");
4183 // TODO add parameter to indicate if matching should be done
4184 if (file.annotateAlignment(alignPanel.getAlignment(), false))
4186 alignPanel.fontChanged();
4187 tcoffeeColour.setEnabled(true);
4188 // switch to this color
4189 changeColour(new TCoffeeColourScheme(alignPanel.getAlignment()));
4194 System.err.println("Problems resolving T-Coffee scores:");
4195 if (file.getWarningMessage() != null)
4197 System.err.println(file.getWarningMessage());
4203 public SplitFrame getSplitFrame()
4205 return this.splitFrame;
4208 public void setSplitFrame(SplitFrame sf)
4210 this.splitFrame = sf;
4213 // may not need this
4215 public void setShowSeqFeatures(boolean b)
4217 // showSeqFeatures.setSelected(b);
4218 viewport.setShowSequenceFeatures(b);
4223 public void setMenusForViewport()
4225 // setMenusFromViewport(viewport);
4229 public void refreshFeatureUI(boolean enableIfNecessary)
4231 if (enableIfNecessary)
4233 sequenceFeatures.setState(true);
4234 alignPanel.av.setShowSequenceFeatures(true);
4239 public FeatureSettingsControllerI getFeatureSettingsUI()
4241 return alignPanel.av.featureSettings;