2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
3 * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 package jalview.appletgui;
26 import java.awt.event.*;
28 import jalview.analysis.*;
29 import jalview.commands.*;
30 import jalview.datamodel.*;
32 import jalview.schemes.*;
34 public class AlignFrame extends EmbmenuFrame implements ActionListener,
35 ItemListener, KeyListener
37 public AlignmentPanel alignPanel;
39 public AlignViewport viewport;
41 int DEFAULT_WIDTH = 700;
43 int DEFAULT_HEIGHT = 500;
45 String jalviewServletURL;
47 public AlignFrame(AlignmentI al, jalview.bin.JalviewLite applet,
48 String title, boolean embedded)
53 jalviewServletURL = applet.getParameter("APPLICATION_URL");
59 } catch (Exception ex)
64 viewport = new AlignViewport(al, applet);
65 alignPanel = new AlignmentPanel(this, viewport);
67 viewport.updateConservation(alignPanel);
68 viewport.updateConsensus(alignPanel);
70 annotationPanelMenuItem.setState(viewport.showAnnotation);
71 displayNonconservedMenuItem.setState(viewport.getShowunconserved());
73 seqLimits.setState(viewport.showJVSuffix);
77 String param = applet.getParameter("sortBy");
80 if (param.equalsIgnoreCase("Id"))
82 sortIDMenuItem_actionPerformed();
84 else if (param.equalsIgnoreCase("Pairwise Identity"))
86 sortPairwiseMenuItem_actionPerformed();
90 param = applet.getParameter("wrap");
93 if (param.equalsIgnoreCase("true"))
95 wrapMenuItem.setState(true);
96 wrapMenuItem_actionPerformed();
99 param = applet.getParameter("centrecolumnlabels");
102 centreColumnLabelFlag.setState(true);
103 centreColumnLabelFlag_stateChanged();
107 param = applet.getParameter("windowWidth");
110 int width = Integer.parseInt(param);
111 DEFAULT_WIDTH = width;
113 param = applet.getParameter("windowHeight");
116 int height = Integer.parseInt(param);
117 DEFAULT_HEIGHT = height;
119 } catch (Exception ex)
125 // Some JVMS send keyevents to Top frame or lowest panel,
126 // Havent worked out why yet. So add to both this frame and seqCanvas for
128 this.addKeyListener(this);
129 alignPanel.seqPanel.seqCanvas.addKeyListener(this);
130 alignPanel.idPanel.idCanvas.addKeyListener(this);
131 alignPanel.scalePanel.addKeyListener(this);
132 alignPanel.annotationPanel.addKeyListener(this);
133 createAlignFrameWindow(embedded, title);
134 alignPanel.validate();
135 alignPanel.paintAlignment(true);
138 public AlignViewport getAlignViewport()
143 public SeqCanvas getSeqcanvas()
145 return alignPanel.seqPanel.seqCanvas;
155 public void parseFeaturesFile(String file, String type)
157 Hashtable featureLinks = new Hashtable();
158 boolean featuresFile = false;
161 featuresFile = new jalview.io.FeaturesFile(file, type).parse(
162 viewport.alignment, alignPanel.seqPanel.seqCanvas
163 .getFeatureRenderer().featureColours, featureLinks,
165 } catch (Exception ex)
167 ex.printStackTrace();
172 if (featureLinks.size() > 0)
174 alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featureLinks = featureLinks;
176 viewport.showSequenceFeatures = true;
177 sequenceFeatures.setState(true);
178 alignPanel.paintAlignment(true);
183 public void keyPressed(KeyEvent evt)
185 if (viewport.cursorMode
186 && ((evt.getKeyCode() >= KeyEvent.VK_0 && evt.getKeyCode() <= KeyEvent.VK_9) || (evt
187 .getKeyCode() >= KeyEvent.VK_NUMPAD0 && evt
188 .getKeyCode() <= KeyEvent.VK_NUMPAD9))
189 && Character.isDigit(evt.getKeyChar()))
190 alignPanel.seqPanel.numberPressed(evt.getKeyChar());
192 switch (evt.getKeyCode())
194 case 27: // escape key
195 deselectAllSequenceMenuItem_actionPerformed();
198 if (evt.isControlDown() || evt.isMetaDown())
200 cut_actionPerformed();
204 if (viewport.cursorMode && !evt.isControlDown())
206 alignPanel.seqPanel.setCursorColumn();
208 if (evt.isControlDown() || evt.isMetaDown())
210 copy_actionPerformed();
214 if (evt.isControlDown())
216 paste(evt.isShiftDown());
220 if (evt.isControlDown() || evt.isMetaDown())
222 selectAllSequenceMenuItem_actionPerformed();
225 case KeyEvent.VK_DOWN:
226 if (viewport.cursorMode)
228 alignPanel.seqPanel.moveCursor(0, 1);
232 moveSelectedSequences(false);
237 if (viewport.cursorMode)
239 alignPanel.seqPanel.moveCursor(0, -1);
243 moveSelectedSequences(true);
247 case KeyEvent.VK_LEFT:
248 if (evt.isAltDown() || !viewport.cursorMode)
249 slideSequences(false, alignPanel.seqPanel.getKeyboardNo1());
251 alignPanel.seqPanel.moveCursor(-1, 0);
254 case KeyEvent.VK_RIGHT:
255 if (evt.isAltDown() || !viewport.cursorMode)
256 slideSequences(true, alignPanel.seqPanel.getKeyboardNo1());
258 alignPanel.seqPanel.moveCursor(1, 0);
261 case KeyEvent.VK_SPACE:
262 if (viewport.cursorMode)
264 alignPanel.seqPanel.insertGapAtCursor(evt.isControlDown()
265 || evt.isShiftDown() || evt.isAltDown());
269 case KeyEvent.VK_DELETE:
270 case KeyEvent.VK_BACK_SPACE:
271 if (viewport.cursorMode)
273 alignPanel.seqPanel.deleteGapAtCursor(evt.isControlDown()
274 || evt.isShiftDown() || evt.isAltDown());
278 cut_actionPerformed();
279 alignPanel.seqPanel.seqCanvas.repaint();
284 if (viewport.cursorMode)
286 alignPanel.seqPanel.setCursorRow();
290 if (viewport.cursorMode)
292 alignPanel.seqPanel.setCursorPosition();
296 case KeyEvent.VK_ENTER:
297 case KeyEvent.VK_COMMA:
298 if (viewport.cursorMode)
300 alignPanel.seqPanel.setCursorRowAndColumn();
305 if (viewport.cursorMode)
307 alignPanel.seqPanel.setSelectionAreaAtCursor(true);
311 if (viewport.cursorMode)
313 alignPanel.seqPanel.setSelectionAreaAtCursor(false);
318 viewport.cursorMode = !viewport.cursorMode;
319 statusBar.setText("Keyboard editing mode is "
320 + (viewport.cursorMode ? "on" : "off"));
321 if (viewport.cursorMode)
323 alignPanel.seqPanel.seqCanvas.cursorX = viewport.startRes;
324 alignPanel.seqPanel.seqCanvas.cursorY = viewport.startSeq;
329 if (evt.isControlDown())
331 findMenuItem_actionPerformed();
337 boolean toggleSeqs = !evt.isControlDown();
338 boolean toggleCols = !evt.isShiftDown();
339 boolean hide = false;
340 SequenceGroup sg = viewport.getSelectionGroup();
344 if (sg != null && sg.getSize() != viewport.alignment.getHeight())
347 viewport.hideAllSelectedSeqs();
349 else if (!(toggleCols && viewport.colSel.getSelected().size() > 0))
351 viewport.showAllHiddenSeqs();
357 if (viewport.colSel.getSelected().size() > 0)
359 viewport.hideSelectedColumns();
362 viewport.selectionGroup = sg;
367 viewport.showAllHiddenColumns();
373 case KeyEvent.VK_PAGE_UP:
374 if (viewport.wrapAlignment)
376 alignPanel.scrollUp(true);
380 alignPanel.setScrollValues(viewport.startRes, viewport.startSeq
381 - viewport.endSeq + viewport.startSeq);
385 case KeyEvent.VK_PAGE_DOWN:
386 if (viewport.wrapAlignment)
388 alignPanel.scrollUp(false);
392 alignPanel.setScrollValues(viewport.startRes, viewport.startSeq
393 + viewport.endSeq - viewport.startSeq);
398 if (evt.isControlDown())
400 undoMenuItem_actionPerformed();
405 if (evt.isControlDown())
407 redoMenuItem_actionPerformed();
412 if (evt.isControlDown())
419 if (evt.isControlDown())
421 trimAlignment(false);
426 if (evt.isControlDown())
428 if (evt.isShiftDown())
430 this.removeAllGapsMenuItem_actionPerformed();
434 removeGappedColumnMenuItem_actionPerformed();
439 if (evt.isControlDown())
443 viewport.invertColumnSelection();
447 this.invertSequenceMenuItem_actionPerformed();
453 if (evt.isControlDown())
455 this.deleteGroups_actionPerformed();
460 if (evt.isControlDown())
467 alignPanel.paintAlignment(true);
470 public void keyReleased(KeyEvent evt)
474 public void keyTyped(KeyEvent evt)
478 public void itemStateChanged(ItemEvent evt)
480 if (evt.getSource() == displayNonconservedMenuItem)
482 displayNonconservedMenuItem_actionPerformed();
484 else if (evt.getSource() == colourTextMenuItem)
486 colourTextMenuItem_actionPerformed();
488 else if (evt.getSource() == wrapMenuItem)
490 wrapMenuItem_actionPerformed();
492 else if (evt.getSource() == scaleAbove)
494 viewport.setScaleAboveWrapped(scaleAbove.getState());
496 else if (evt.getSource() == scaleLeft)
498 viewport.setScaleLeftWrapped(scaleLeft.getState());
500 else if (evt.getSource() == scaleRight)
502 viewport.setScaleRightWrapped(scaleRight.getState());
504 else if (evt.getSource() == seqLimits)
506 seqLimits_itemStateChanged();
508 else if (evt.getSource() == viewBoxesMenuItem)
510 viewport.setShowBoxes(viewBoxesMenuItem.getState());
512 else if (evt.getSource() == viewTextMenuItem)
514 viewport.setShowText(viewTextMenuItem.getState());
516 else if (evt.getSource() == renderGapsMenuItem)
518 viewport.setRenderGaps(renderGapsMenuItem.getState());
520 else if (evt.getSource() == annotationPanelMenuItem)
522 viewport.setShowAnnotation(annotationPanelMenuItem.getState());
523 alignPanel.setAnnotationVisible(annotationPanelMenuItem.getState());
525 else if (evt.getSource() == sequenceFeatures)
527 viewport.showSequenceFeatures(sequenceFeatures.getState());
528 alignPanel.seqPanel.seqCanvas.repaint();
530 else if (evt.getSource() == conservationMenuItem)
532 conservationMenuItem_actionPerformed();
534 else if (evt.getSource() == abovePIDThreshold)
536 abovePIDThreshold_actionPerformed();
538 else if (evt.getSource() == applyToAllGroups)
540 viewport.setColourAppliesToAllGroups(applyToAllGroups.getState());
542 else if (evt.getSource() == autoCalculate)
544 viewport.autocalculateConsensus = autoCalculate.getState();
546 else if (evt.getSource() == this.centreColumnLabelFlag)
548 centreColumnLabelFlag_stateChanged();
549 } else if (evt.getSource() == this.followMouseOverFlag)
551 mouseOverFlag_stateChanged();
554 alignPanel.paintAlignment(true);
557 private void mouseOverFlag_stateChanged()
559 viewport.followHighlight = followMouseOverFlag.getState();
560 // TODO: could kick the scrollTo mechanism to reset view for current searchresults.
563 private void centreColumnLabelFlag_stateChanged()
565 viewport.centreColumnLabels = centreColumnLabelFlag.getState();
566 this.alignPanel.annotationPanel.repaint();
569 public void actionPerformed(ActionEvent evt)
571 Object source = evt.getSource();
573 if (source == inputText)
575 inputText_actionPerformed();
577 else if (source == loadTree)
579 loadTree_actionPerformed();
581 else if (source == loadApplication)
583 launchFullApplication();
585 else if (source == loadAnnotations)
589 else if (source == outputAnnotations)
591 outputAnnotations(true);
593 else if (source == outputFeatures)
595 outputFeatures(true, "Jalview");
597 else if (source == closeMenuItem)
599 closeMenuItem_actionPerformed();
601 else if (source == copy)
603 copy_actionPerformed();
605 else if (source == undoMenuItem)
607 undoMenuItem_actionPerformed();
609 else if (source == redoMenuItem)
611 redoMenuItem_actionPerformed();
613 else if (source == inputText)
615 inputText_actionPerformed();
617 else if (source == closeMenuItem)
619 closeMenuItem_actionPerformed();
621 else if (source == undoMenuItem)
623 undoMenuItem_actionPerformed();
625 else if (source == redoMenuItem)
627 redoMenuItem_actionPerformed();
629 else if (source == copy)
631 copy_actionPerformed();
633 else if (source == pasteNew)
635 pasteNew_actionPerformed();
637 else if (source == pasteThis)
639 pasteThis_actionPerformed();
641 else if (source == cut)
643 cut_actionPerformed();
645 else if (source == delete)
647 delete_actionPerformed();
649 else if (source == deleteGroups)
651 deleteGroups_actionPerformed();
653 else if (source == selectAllSequenceMenuItem)
655 selectAllSequenceMenuItem_actionPerformed();
657 else if (source == deselectAllSequenceMenuItem)
659 deselectAllSequenceMenuItem_actionPerformed();
661 else if (source == invertSequenceMenuItem)
663 invertSequenceMenuItem_actionPerformed();
665 else if (source == invertColSel)
667 viewport.invertColumnSelection();
668 alignPanel.paintAlignment(true);
670 else if (source == remove2LeftMenuItem)
674 else if (source == remove2RightMenuItem)
676 trimAlignment(false);
678 else if (source == removeGappedColumnMenuItem)
680 removeGappedColumnMenuItem_actionPerformed();
682 else if (source == removeAllGapsMenuItem)
684 removeAllGapsMenuItem_actionPerformed();
686 else if (source == findMenuItem)
688 findMenuItem_actionPerformed();
690 else if (source == font)
692 new FontChooser(alignPanel);
694 else if (source == newView)
698 else if (source == showColumns)
700 viewport.showAllHiddenColumns();
701 alignPanel.paintAlignment(true);
703 else if (source == showSeqs)
705 viewport.showAllHiddenSeqs();
707 else if (source == hideColumns)
709 viewport.hideSelectedColumns();
710 alignPanel.paintAlignment(true);
712 else if (source == hideSequences
713 && viewport.getSelectionGroup() != null)
715 viewport.hideAllSelectedSeqs();
717 else if (source == featureSettings)
719 new FeatureSettings(alignPanel);
721 else if (source == alProperties)
723 StringBuffer contents = new StringBuffer();
726 int min = Integer.MAX_VALUE, max = 0;
727 for (int i = 0; i < viewport.alignment.getHeight(); i++)
729 int size = viewport.alignment.getSequenceAt(i).getEnd()
730 - viewport.alignment.getSequenceAt(i).getStart();
737 avg = avg / (float) viewport.alignment.getHeight();
739 contents.append("\nSequences: " + viewport.alignment.getHeight());
740 contents.append("\nMinimum Sequence Length: " + min);
741 contents.append("\nMaximum Sequence Length: " + max);
742 contents.append("\nAverage Length: " + (int) avg);
744 if (((Alignment) viewport.alignment).alignmentProperties != null)
746 Hashtable props = ((Alignment) viewport.alignment).alignmentProperties;
747 Enumeration en = props.keys();
748 while (en.hasMoreElements())
750 String key = en.nextElement().toString();
751 contents.append("\n" + key + "\t" + props.get(key));
755 CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this);
756 cap.setText(contents.toString());
757 Frame frame = new Frame();
759 jalview.bin.JalviewLite.addFrame(frame, "Alignment Properties: "
760 + getTitle(), 400, 250);
762 else if (source == overviewMenuItem)
764 overviewMenuItem_actionPerformed();
766 else if (source == noColourmenuItem)
770 else if (source == clustalColour)
772 abovePIDThreshold.setState(false);
773 changeColour(new ClustalxColourScheme(viewport.alignment
774 .getSequences(), viewport.alignment.getWidth()));
776 else if (source == zappoColour)
778 changeColour(new ZappoColourScheme());
780 else if (source == taylorColour)
782 changeColour(new TaylorColourScheme());
784 else if (source == hydrophobicityColour)
786 changeColour(new HydrophobicColourScheme());
788 else if (source == helixColour)
790 changeColour(new HelixColourScheme());
792 else if (source == strandColour)
794 changeColour(new StrandColourScheme());
796 else if (source == turnColour)
798 changeColour(new TurnColourScheme());
800 else if (source == buriedColour)
802 changeColour(new BuriedColourScheme());
804 else if (source == nucleotideColour)
806 changeColour(new NucleotideColourScheme());
808 else if (source == modifyPID)
810 modifyPID_actionPerformed();
812 else if (source == modifyConservation)
814 modifyConservation_actionPerformed();
816 else if (source == userDefinedColour)
818 new UserDefinedColours(alignPanel, null);
820 else if (source == PIDColour)
822 changeColour(new PIDColourScheme());
824 else if (source == BLOSUM62Colour)
826 changeColour(new Blosum62ColourScheme());
828 else if (source == annotationColour)
830 new AnnotationColourChooser(viewport, alignPanel);
832 else if (source == sortPairwiseMenuItem)
834 sortPairwiseMenuItem_actionPerformed();
836 else if (source == sortIDMenuItem)
838 sortIDMenuItem_actionPerformed();
840 else if (source == sortGroupMenuItem)
842 sortGroupMenuItem_actionPerformed();
844 else if (source == removeRedundancyMenuItem)
846 removeRedundancyMenuItem_actionPerformed();
848 else if (source == pairwiseAlignmentMenuItem)
850 pairwiseAlignmentMenuItem_actionPerformed();
852 else if (source == PCAMenuItem)
854 PCAMenuItem_actionPerformed();
856 else if (source == averageDistanceTreeMenuItem)
858 averageDistanceTreeMenuItem_actionPerformed();
860 else if (source == neighbourTreeMenuItem)
862 neighbourTreeMenuItem_actionPerformed();
864 else if (source == njTreeBlosumMenuItem)
866 njTreeBlosumMenuItem_actionPerformed();
868 else if (source == avDistanceTreeBlosumMenuItem)
870 avTreeBlosumMenuItem_actionPerformed();
872 else if (source == documentation)
874 documentation_actionPerformed();
876 else if (source == about)
878 about_actionPerformed();
883 public void inputText_actionPerformed()
885 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
886 Frame frame = new Frame();
888 jalview.bin.JalviewLite.addFrame(frame, "Cut & Paste Input", 500, 500);
891 protected void outputText_actionPerformed(ActionEvent e)
893 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
894 Frame frame = new Frame();
896 jalview.bin.JalviewLite.addFrame(frame, "Alignment output - "
897 + e.getActionCommand(), 600, 500);
898 cap.setText(new AppletFormatAdapter().formatSequences(e
899 .getActionCommand(), viewport.getAlignment(),
900 viewport.showJVSuffix));
903 public void loadAnnotations()
905 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
906 cap.setText("Paste your features / annotations file here.");
907 cap.setAnnotationImport();
908 Frame frame = new Frame();
910 jalview.bin.JalviewLite.addFrame(frame, "Paste Annotations ", 400, 300);
914 public String outputAnnotations(boolean displayTextbox)
916 String annotation = new AnnotationFile().printAnnotations(
917 viewport.showAnnotation ? viewport.alignment
918 .getAlignmentAnnotation() : null, viewport.alignment
920 ((Alignment) viewport.alignment).alignmentProperties);
924 CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this);
925 Frame frame = new Frame();
927 jalview.bin.JalviewLite.addFrame(frame, "Annotations", 600, 500);
928 cap.setText(annotation);
934 public String outputFeatures(boolean displayTextbox, String format)
937 if (format.equalsIgnoreCase("Jalview"))
939 features = new FeaturesFile().printJalviewFormat(viewport.alignment
940 .getSequencesArray(), viewport.featuresDisplayed);
944 features = new FeaturesFile().printGFFFormat(viewport.alignment
945 .getSequencesArray(), viewport.featuresDisplayed);
950 CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this);
951 Frame frame = new Frame();
953 jalview.bin.JalviewLite.addFrame(frame, "Features", 600, 500);
955 cap.setText(features);
961 void launchFullApplication()
963 StringBuffer url = new StringBuffer(jalviewServletURL);
966 + appendProtocol(viewport.applet.getParameter("file")));
968 if (viewport.applet.getParameter("features") != null)
970 url.append("&features=");
971 url.append(appendProtocol(viewport.applet.getParameter("features")));
974 if (viewport.applet.getParameter("annotations") != null)
976 url.append("&annotations=");
978 .append(appendProtocol(viewport.applet
979 .getParameter("annotations")));
982 if (viewport.applet.getParameter("jnetfile") != null)
984 url.append("&annotations=");
985 url.append(appendProtocol(viewport.applet.getParameter("jnetfile")));
988 if (viewport.applet.getParameter("defaultColour") != null)
990 url.append("&colour="
991 + removeWhiteSpace(viewport.applet
992 .getParameter("defaultColour")));
995 if (viewport.applet.getParameter("userDefinedColour") != null)
997 url.append("&colour="
998 + removeWhiteSpace(viewport.applet
999 .getParameter("userDefinedColour")));
1001 if (viewport.applet.getParameter("tree") != null)
1004 + appendProtocol(viewport.applet.getParameter("tree")));
1006 if (viewport.applet.getParameter("treeFile") != null)
1009 + appendProtocol(viewport.applet.getParameter("treeFile")));
1012 showURL(url.toString(), "FULL_APP");
1015 String removeWhiteSpace(String colour)
1017 StringBuffer sb = new StringBuffer();
1018 for (int i = 0; i < colour.length(); i++)
1020 if (Character.isWhitespace(colour.charAt(i)))
1026 sb.append(colour.charAt(i));
1030 return sb.toString();
1033 String appendProtocol(String url)
1038 url = URLEncoder.encode(url);
1041 * When we finally deprecate 1.1 compatibility, we can start to use
1042 * URLEncoder.encode(url,"UTF-8") and then we'll need this catch: catch
1043 * (UnsupportedEncodingException ex) { System.err.println("WARNING -
1044 * IMPLEMENTATION ERROR - UNSUPPORTED ENCODING EXCEPTION FOR "+url);
1045 * ex.printStackTrace(); }
1047 catch (java.net.MalformedURLException ex)
1049 url = viewport.applet.getCodeBase() + url;
1054 public void closeMenuItem_actionPerformed()
1056 PaintRefresher.RemoveComponent(alignPanel);
1057 PaintRefresher.RemoveComponent(alignPanel.seqPanel.seqCanvas);
1058 PaintRefresher.RemoveComponent(alignPanel.idPanel.idCanvas);
1060 if (PaintRefresher.components.size() == 0 && viewport.applet == null)
1071 void updateEditMenuBar()
1074 if (viewport.historyList.size() > 0)
1076 undoMenuItem.setEnabled(true);
1077 CommandI command = (CommandI) viewport.historyList.peek();
1078 undoMenuItem.setLabel("Undo " + command.getDescription());
1082 undoMenuItem.setEnabled(false);
1083 undoMenuItem.setLabel("Undo");
1086 if (viewport.redoList.size() > 0)
1088 redoMenuItem.setEnabled(true);
1090 CommandI command = (CommandI) viewport.redoList.peek();
1091 redoMenuItem.setLabel("Redo " + command.getDescription());
1095 redoMenuItem.setEnabled(false);
1096 redoMenuItem.setLabel("Redo");
1100 public void addHistoryItem(CommandI command)
1102 if (command.getSize() > 0)
1104 viewport.historyList.push(command);
1105 viewport.redoList.removeAllElements();
1106 updateEditMenuBar();
1107 viewport.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;
1117 protected void undoMenuItem_actionPerformed()
1119 if (viewport.historyList.size() < 1)
1124 CommandI command = (CommandI) viewport.historyList.pop();
1125 viewport.redoList.push(command);
1126 command.undoCommand(null);
1128 AlignViewport originalSource = getOriginatingSource(command);
1130 originalSource.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;
1131 updateEditMenuBar();
1132 originalSource.firePropertyChange("alignment", null,
1133 originalSource.alignment.getSequences());
1142 protected void redoMenuItem_actionPerformed()
1144 if (viewport.redoList.size() < 1)
1149 CommandI command = (CommandI) viewport.redoList.pop();
1150 viewport.historyList.push(command);
1151 command.doCommand(null);
1153 AlignViewport originalSource = getOriginatingSource(command);
1154 originalSource.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;
1156 updateEditMenuBar();
1157 originalSource.firePropertyChange("alignment", null,
1158 originalSource.alignment.getSequences());
1161 AlignViewport getOriginatingSource(CommandI command)
1163 AlignViewport originalSource = null;
1164 // For sequence removal and addition, we need to fire
1165 // the property change event FROM the viewport where the
1166 // original alignment was altered
1167 AlignmentI al = null;
1168 if (command instanceof EditCommand)
1170 EditCommand editCommand = (EditCommand) command;
1171 al = editCommand.getAlignment();
1172 Vector comps = (Vector) PaintRefresher.components.get(viewport
1173 .getSequenceSetId());
1174 for (int i = 0; i < comps.size(); i++)
1176 if (comps.elementAt(i) instanceof AlignmentPanel)
1178 if (al == ((AlignmentPanel) comps.elementAt(i)).av.alignment)
1180 originalSource = ((AlignmentPanel) comps.elementAt(i)).av;
1187 if (originalSource == null)
1189 // The original view is closed, we must validate
1190 // the current view against the closed view first
1193 PaintRefresher.validateSequences(al, viewport.alignment);
1196 originalSource = viewport;
1199 return originalSource;
1202 public void moveSelectedSequences(boolean up)
1204 SequenceGroup sg = viewport.getSelectionGroup();
1212 for (int i = 1; i < viewport.alignment.getHeight(); i++)
1214 SequenceI seq = viewport.alignment.getSequenceAt(i);
1215 if (!sg.getSequences(null).contains(seq))
1220 SequenceI temp = viewport.alignment.getSequenceAt(i - 1);
1221 if (sg.getSequences(null).contains(temp))
1226 viewport.alignment.getSequences().setElementAt(temp, i);
1227 viewport.alignment.getSequences().setElementAt(seq, i - 1);
1232 for (int i = viewport.alignment.getHeight() - 2; i > -1; i--)
1234 SequenceI seq = viewport.alignment.getSequenceAt(i);
1235 if (!sg.getSequences(viewport.hiddenRepSequences).contains(seq))
1240 SequenceI temp = viewport.alignment.getSequenceAt(i + 1);
1241 if (sg.getSequences(viewport.hiddenRepSequences).contains(temp))
1246 viewport.alignment.getSequences().setElementAt(temp, i);
1247 viewport.alignment.getSequences().setElementAt(seq, i + 1);
1251 alignPanel.paintAlignment(true);
1254 synchronized void slideSequences(boolean right, int size)
1256 Vector sg = new Vector();
1257 if (viewport.cursorMode)
1259 sg.addElement(viewport.alignment
1260 .getSequenceAt(alignPanel.seqPanel.seqCanvas.cursorY));
1262 else if (viewport.getSelectionGroup() != null
1263 && viewport.getSelectionGroup().getSize() != viewport.alignment
1266 sg = viewport.getSelectionGroup().getSequences(
1267 viewport.hiddenRepSequences);
1275 Vector invertGroup = new Vector();
1277 for (int i = 0; i < viewport.alignment.getHeight(); i++)
1279 if (!sg.contains(viewport.alignment.getSequenceAt(i)))
1280 invertGroup.addElement(viewport.alignment.getSequenceAt(i));
1283 SequenceI[] seqs1 = new SequenceI[sg.size()];
1284 for (int i = 0; i < sg.size(); i++)
1285 seqs1[i] = (SequenceI) sg.elementAt(i);
1287 SequenceI[] seqs2 = new SequenceI[invertGroup.size()];
1288 for (int i = 0; i < invertGroup.size(); i++)
1289 seqs2[i] = (SequenceI) invertGroup.elementAt(i);
1291 SlideSequencesCommand ssc;
1293 ssc = new SlideSequencesCommand("Slide Sequences", seqs2, seqs1,
1294 size, viewport.getGapCharacter());
1296 ssc = new SlideSequencesCommand("Slide Sequences", seqs1, seqs2,
1297 size, viewport.getGapCharacter());
1299 int groupAdjustment = 0;
1300 if (ssc.getGapsInsertedBegin() && right)
1302 if (viewport.cursorMode)
1303 alignPanel.seqPanel.moveCursor(size, 0);
1305 groupAdjustment = size;
1307 else if (!ssc.getGapsInsertedBegin() && !right)
1309 if (viewport.cursorMode)
1310 alignPanel.seqPanel.moveCursor(-size, 0);
1312 groupAdjustment = -size;
1315 if (groupAdjustment != 0)
1317 viewport.getSelectionGroup().setStartRes(
1318 viewport.getSelectionGroup().getStartRes() + groupAdjustment);
1319 viewport.getSelectionGroup().setEndRes(
1320 viewport.getSelectionGroup().getEndRes() + groupAdjustment);
1323 boolean appendHistoryItem = false;
1324 if (viewport.historyList != null && viewport.historyList.size() > 0
1325 && viewport.historyList.peek() instanceof SlideSequencesCommand)
1327 appendHistoryItem = ssc
1328 .appendSlideCommand((SlideSequencesCommand) viewport.historyList
1332 if (!appendHistoryItem)
1333 addHistoryItem(ssc);
1338 static StringBuffer copiedSequences;
1340 static Vector copiedHiddenColumns;
1342 protected void copy_actionPerformed()
1344 if (viewport.getSelectionGroup() == null)
1349 SequenceGroup sg = viewport.getSelectionGroup();
1350 copiedSequences = new StringBuffer();
1351 Hashtable orderedSeqs = new Hashtable();
1352 for (int i = 0; i < sg.getSize(); i++)
1354 SequenceI seq = sg.getSequenceAt(i);
1355 int index = viewport.alignment.findIndex(seq);
1356 orderedSeqs.put(index + "", seq);
1359 int index = 0, startRes, endRes;
1362 if (viewport.hasHiddenColumns && viewport.getSelectionGroup() != null)
1364 copiedHiddenColumns = new Vector();
1365 int hiddenOffset = viewport.getSelectionGroup().getStartRes();
1366 for (int i = 0; i < viewport.getColumnSelection().getHiddenColumns()
1369 int[] region = (int[]) viewport.getColumnSelection()
1370 .getHiddenColumns().elementAt(i);
1372 copiedHiddenColumns.addElement(new int[]
1373 { region[0] - hiddenOffset, region[1] - hiddenOffset });
1378 copiedHiddenColumns = null;
1381 for (int i = 0; i < sg.getSize(); i++)
1383 SequenceI seq = null;
1387 if (orderedSeqs.containsKey(index + ""))
1389 seq = (SequenceI) orderedSeqs.get(index + "");
1401 // Returns residue following index if gap
1402 startRes = seq.findPosition(sg.getStartRes());
1405 // Need to find the residue preceeding index if gap
1408 for (int j = 0; j < sg.getEndRes() + 1 && j < seq.getLength(); j++)
1410 ch = seq.getCharAt(j);
1411 if (!jalview.util.Comparison.isGap((ch)))
1419 endRes += seq.getStart() - 1;
1422 copiedSequences.append(seq.getName()
1428 + seq.getSequenceAsString(sg.getStartRes(),
1429 sg.getEndRes() + 1) + "\n");
1434 protected void pasteNew_actionPerformed()
1439 protected void pasteThis_actionPerformed()
1444 void paste(boolean newAlignment)
1449 if (copiedSequences == null)
1454 StringTokenizer st = new StringTokenizer(copiedSequences.toString());
1455 Vector seqs = new Vector();
1456 while (st.hasMoreElements())
1458 String name = st.nextToken();
1459 int start = Integer.parseInt(st.nextToken());
1460 int end = Integer.parseInt(st.nextToken());
1461 seqs.addElement(new Sequence(name, st.nextToken(), start, end));
1463 SequenceI[] newSeqs = new SequenceI[seqs.size()];
1464 for (int i = 0; i < seqs.size(); i++)
1466 newSeqs[i] = (SequenceI) seqs.elementAt(i);
1471 String newtitle = new String("Copied sequences");
1472 if (getTitle().startsWith("Copied sequences"))
1474 newtitle = getTitle();
1478 newtitle = newtitle.concat("- from " + getTitle());
1480 AlignFrame af = new AlignFrame(new Alignment(newSeqs),
1481 viewport.applet, newtitle, false);
1482 if (copiedHiddenColumns != null)
1484 for (int i = 0; i < copiedHiddenColumns.size(); i++)
1486 int[] region = (int[]) copiedHiddenColumns.elementAt(i);
1487 af.viewport.hideColumns(region[0], region[1]);
1491 jalview.bin.JalviewLite.addFrame(af, newtitle, DEFAULT_WIDTH,
1496 addSequences(newSeqs);
1499 } catch (Exception ex)
1501 } // could be anything being pasted in here
1505 void addSequences(SequenceI[] seqs)
1507 for (int i = 0; i < seqs.length; i++)
1509 viewport.alignment.addSequence(seqs[i]);
1513 addHistoryItem(new EditCommand("Add sequences", EditCommand.PASTE,
1514 seqs, 0, viewport.alignment.getWidth(), viewport.alignment));
1516 viewport.setEndSeq(viewport.alignment.getHeight());
1517 viewport.alignment.getWidth();
1518 viewport.firePropertyChange("alignment", null, viewport.alignment
1523 protected void cut_actionPerformed()
1525 copy_actionPerformed();
1526 delete_actionPerformed();
1529 protected void delete_actionPerformed()
1532 SequenceGroup sg = viewport.getSelectionGroup();
1538 Vector seqs = new Vector();
1540 for (int i = 0; i < sg.getSize(); i++)
1542 seq = sg.getSequenceAt(i);
1543 seqs.addElement(seq);
1546 // If the cut affects all sequences, remove highlighted columns
1547 if (sg.getSize() == viewport.alignment.getHeight())
1549 viewport.getColumnSelection().removeElements(sg.getStartRes(),
1550 sg.getEndRes() + 1);
1553 SequenceI[] cut = new SequenceI[seqs.size()];
1554 for (int i = 0; i < seqs.size(); i++)
1556 cut[i] = (SequenceI) seqs.elementAt(i);
1560 * //ADD HISTORY ITEM
1562 addHistoryItem(new EditCommand("Cut Sequences", EditCommand.CUT, cut,
1563 sg.getStartRes(), sg.getEndRes() - sg.getStartRes() + 1,
1564 viewport.alignment));
1566 viewport.setSelectionGroup(null);
1567 viewport.alignment.deleteGroup(sg);
1569 viewport.firePropertyChange("alignment", null, viewport.getAlignment()
1572 if (viewport.getAlignment().getHeight() < 1)
1574 this.setVisible(false);
1578 protected void deleteGroups_actionPerformed()
1580 viewport.alignment.deleteAllGroups();
1581 viewport.sequenceColours = null;
1582 viewport.setSelectionGroup(null);
1584 alignPanel.paintAlignment(true);
1587 public void selectAllSequenceMenuItem_actionPerformed()
1589 SequenceGroup sg = new SequenceGroup();
1590 for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++)
1592 sg.addSequence(viewport.getAlignment().getSequenceAt(i), false);
1594 sg.setEndRes(viewport.alignment.getWidth() - 1);
1595 viewport.setSelectionGroup(sg);
1596 alignPanel.paintAlignment(true);
1597 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
1600 public void deselectAllSequenceMenuItem_actionPerformed()
1602 if (viewport.cursorMode)
1604 alignPanel.seqPanel.keyboardNo1 = null;
1605 alignPanel.seqPanel.keyboardNo2 = null;
1607 viewport.setSelectionGroup(null);
1608 viewport.getColumnSelection().clear();
1609 viewport.setSelectionGroup(null);
1610 alignPanel.idPanel.idCanvas.searchResults = null;
1611 alignPanel.seqPanel.seqCanvas.highlightSearchResults(null);
1612 alignPanel.paintAlignment(true);
1613 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
1616 public void invertSequenceMenuItem_actionPerformed()
1618 SequenceGroup sg = viewport.getSelectionGroup();
1619 for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++)
1621 sg.addOrRemove(viewport.getAlignment().getSequenceAt(i), false);
1624 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
1627 void trimAlignment(boolean trimLeft)
1629 ColumnSelection colSel = viewport.getColumnSelection();
1632 if (colSel.size() > 0)
1636 column = colSel.getMin();
1640 column = colSel.getMax();
1644 if (viewport.getSelectionGroup() != null)
1646 seqs = viewport.getSelectionGroup().getSequencesAsArray(
1647 viewport.hiddenRepSequences);
1651 seqs = viewport.alignment.getSequencesArray();
1654 TrimRegionCommand trimRegion;
1657 trimRegion = new TrimRegionCommand("Remove Left",
1658 TrimRegionCommand.TRIM_LEFT, seqs, column,
1659 viewport.alignment, viewport.colSel,
1660 viewport.selectionGroup);
1661 viewport.setStartRes(0);
1665 trimRegion = new TrimRegionCommand("Remove Right",
1666 TrimRegionCommand.TRIM_RIGHT, seqs, column,
1667 viewport.alignment, viewport.colSel,
1668 viewport.selectionGroup);
1671 statusBar.setText("Removed " + trimRegion.getSize() + " columns.");
1673 addHistoryItem(trimRegion);
1675 Vector groups = viewport.alignment.getGroups();
1677 for (int i = 0; i < groups.size(); i++)
1679 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
1681 if ((trimLeft && !sg.adjustForRemoveLeft(column))
1682 || (!trimLeft && !sg.adjustForRemoveRight(column)))
1684 viewport.alignment.deleteGroup(sg);
1688 viewport.firePropertyChange("alignment", null, viewport
1689 .getAlignment().getSequences());
1693 public void removeGappedColumnMenuItem_actionPerformed()
1695 int start = 0, end = viewport.alignment.getWidth() - 1;
1698 if (viewport.getSelectionGroup() != null)
1700 seqs = viewport.getSelectionGroup().getSequencesAsArray(
1701 viewport.hiddenRepSequences);
1702 start = viewport.getSelectionGroup().getStartRes();
1703 end = viewport.getSelectionGroup().getEndRes();
1707 seqs = viewport.alignment.getSequencesArray();
1710 RemoveGapColCommand removeGapCols = new RemoveGapColCommand(
1711 "Remove Gapped Columns", seqs, start, end, viewport.alignment);
1713 addHistoryItem(removeGapCols);
1715 statusBar.setText("Removed " + removeGapCols.getSize()
1716 + " empty columns.");
1718 // This is to maintain viewport position on first residue
1719 // of first sequence
1720 SequenceI seq = viewport.alignment.getSequenceAt(0);
1721 int startRes = seq.findPosition(viewport.startRes);
1722 // ShiftList shifts;
1723 // viewport.getAlignment().removeGaps(shifts=new ShiftList());
1724 // edit.alColumnChanges=shifts.getInverse();
1725 // if (viewport.hasHiddenColumns)
1726 // viewport.getColumnSelection().compensateForEdits(shifts);
1727 viewport.setStartRes(seq.findIndex(startRes) - 1);
1728 viewport.firePropertyChange("alignment", null, viewport.getAlignment()
1733 public void removeAllGapsMenuItem_actionPerformed()
1735 int start = 0, end = viewport.alignment.getWidth() - 1;
1738 if (viewport.getSelectionGroup() != null)
1740 seqs = viewport.getSelectionGroup().getSequencesAsArray(
1741 viewport.hiddenRepSequences);
1742 start = viewport.getSelectionGroup().getStartRes();
1743 end = viewport.getSelectionGroup().getEndRes();
1747 seqs = viewport.alignment.getSequencesArray();
1750 // This is to maintain viewport position on first residue
1751 // of first sequence
1752 SequenceI seq = viewport.alignment.getSequenceAt(0);
1753 int startRes = seq.findPosition(viewport.startRes);
1755 addHistoryItem(new RemoveGapsCommand("Remove Gaps", seqs, start, end,
1756 viewport.alignment));
1758 viewport.setStartRes(seq.findIndex(startRes) - 1);
1760 viewport.firePropertyChange("alignment", null, viewport.getAlignment()
1765 public void findMenuItem_actionPerformed()
1767 new Finder(alignPanel);
1771 * create a new view derived from the current view
1774 * @return frame for the new view
1776 public AlignFrame newView(String viewtitle)
1779 if (viewport.hasHiddenRows)
1781 newal = new Alignment(viewport.getAlignment().getHiddenSequences()
1782 .getFullAlignment().getSequencesArray());
1786 newal = new Alignment(viewport.alignment.getSequencesArray());
1789 if (viewport.alignment.getAlignmentAnnotation() != null)
1791 for (int i = 0; i < viewport.alignment.getAlignmentAnnotation().length; i++)
1793 if (!viewport.alignment.getAlignmentAnnotation()[i].autoCalculated)
1796 .addAnnotation(viewport.alignment
1797 .getAlignmentAnnotation()[i]);
1802 AlignFrame newaf = new AlignFrame(newal, viewport.applet, "", false);
1804 newaf.viewport.sequenceSetID = alignPanel.av.getSequenceSetId();
1805 PaintRefresher.Register(alignPanel, alignPanel.av.getSequenceSetId());
1806 PaintRefresher.Register(newaf.alignPanel, newaf.alignPanel.av
1807 .getSequenceSetId());
1809 PaintRefresher.Register(newaf.alignPanel.idPanel.idCanvas,
1810 newaf.alignPanel.av.getSequenceSetId());
1811 PaintRefresher.Register(newaf.alignPanel.seqPanel.seqCanvas,
1812 newaf.alignPanel.av.getSequenceSetId());
1814 Vector comps = (Vector) PaintRefresher.components.get(viewport
1815 .getSequenceSetId());
1817 for (int i = 0; i < comps.size(); i++)
1819 if (comps.elementAt(i) instanceof AlignmentPanel)
1825 String title = new String(this.getTitle());
1826 if (viewtitle != null)
1828 title = viewtitle + " ( " + title + ")";
1832 if (title.indexOf("(View") > -1)
1834 title = title.substring(0, title.indexOf("(View"));
1836 title += "(View " + viewSize + ")";
1839 newaf.setTitle(title.toString());
1841 newaf.viewport.historyList = viewport.historyList;
1842 newaf.viewport.redoList = viewport.redoList;
1848 * @return list of feature groups on the view
1850 public String[] getFeatureGroups()
1852 FeatureRenderer fr = null;
1853 if (alignPanel != null
1854 && (fr = alignPanel.getFeatureRenderer()) != null)
1856 return fr.getGroups();
1862 * get sequence feature groups that are hidden or shown
1868 public String[] getFeatureGroupsOfState(boolean visible)
1870 FeatureRenderer fr = null;
1871 if (alignPanel != null
1872 && (fr = alignPanel.getFeatureRenderer()) != null)
1874 return fr.getGroups(visible);
1880 * Change the display state for the given feature groups
1883 * list of group strings
1885 * visible or invisible
1887 public void setFeatureGroupState(String[] groups, boolean state)
1889 FeatureRenderer fr = null;
1890 this.sequenceFeatures.setState(true);
1891 viewport.showSequenceFeatures(true);
1892 if (alignPanel != null
1893 && (fr = alignPanel.getFeatureRenderer()) != null)
1895 fr.setGroupState(groups, state);
1896 alignPanel.seqPanel.seqCanvas.repaint();
1897 if (alignPanel.overviewPanel != null)
1899 alignPanel.overviewPanel.updateOverviewImage();
1904 public void seqLimits_itemStateChanged()
1906 viewport.setShowJVSuffix(seqLimits.getState());
1907 alignPanel.fontChanged();
1908 alignPanel.paintAlignment(true);
1911 protected void colourTextMenuItem_actionPerformed()
1913 viewport.setColourText(colourTextMenuItem.getState());
1914 alignPanel.paintAlignment(true);
1917 protected void displayNonconservedMenuItem_actionPerformed()
1919 viewport.setShowunconserved(displayNonconservedMenuItem.getState());
1920 alignPanel.paintAlignment(true);
1923 protected void wrapMenuItem_actionPerformed()
1925 viewport.setWrapAlignment(wrapMenuItem.getState());
1926 alignPanel.setWrapAlignment(wrapMenuItem.getState());
1927 scaleAbove.setEnabled(wrapMenuItem.getState());
1928 scaleLeft.setEnabled(wrapMenuItem.getState());
1929 scaleRight.setEnabled(wrapMenuItem.getState());
1930 alignPanel.paintAlignment(true);
1933 public void overviewMenuItem_actionPerformed()
1935 if (alignPanel.overviewPanel != null)
1940 Frame frame = new Frame();
1941 OverviewPanel overview = new OverviewPanel(alignPanel);
1942 frame.add(overview);
1943 // +50 must allow for applet frame window
1944 jalview.bin.JalviewLite.addFrame(frame, "Overview " + this.getTitle(),
1945 overview.getPreferredSize().width,
1946 overview.getPreferredSize().height + 50);
1949 frame.addWindowListener(new WindowAdapter()
1951 public void windowClosing(WindowEvent e)
1953 alignPanel.setOverviewPanel(null);
1957 alignPanel.setOverviewPanel(overview);
1961 void changeColour(ColourSchemeI cs)
1967 if (viewport.getAbovePIDThreshold())
1969 threshold = SliderPanel.setPIDSliderSource(alignPanel, cs,
1972 cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus());
1974 viewport.setGlobalColourScheme(cs);
1978 cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
1981 if (viewport.getConservationSelected())
1984 Alignment al = (Alignment) viewport.alignment;
1985 Conservation c = new Conservation("All",
1986 ResidueProperties.propHash, 3, al.getSequences(), 0, al
1990 c.verdict(false, viewport.ConsPercGaps);
1992 cs.setConservation(c);
1994 cs.setConservationInc(SliderPanel.setConservationSlider(alignPanel,
2000 cs.setConservation(null);
2003 cs.setConsensus(viewport.hconsensus);
2006 viewport.setGlobalColourScheme(cs);
2008 if (viewport.getColourAppliesToAllGroups())
2010 Vector groups = viewport.alignment.getGroups();
2011 for (int i = 0; i < groups.size(); i++)
2013 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
2020 if (cs instanceof ClustalxColourScheme)
2022 sg.cs = new ClustalxColourScheme(sg
2023 .getSequences(viewport.hiddenRepSequences), sg.getWidth());
2029 sg.cs = (ColourSchemeI) cs.getClass().newInstance();
2030 } catch (Exception ex)
2032 ex.printStackTrace();
2037 if (viewport.getAbovePIDThreshold()
2038 || cs instanceof PIDColourScheme
2039 || cs instanceof Blosum62ColourScheme)
2041 sg.cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus());
2042 sg.cs.setConsensus(AAFrequency.calculate(sg
2043 .getSequences(viewport.hiddenRepSequences), 0, sg
2048 sg.cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
2051 if (viewport.getConservationSelected())
2053 Conservation c = new Conservation("Group",
2054 ResidueProperties.propHash, 3, sg
2055 .getSequences(viewport.hiddenRepSequences), 0,
2056 viewport.alignment.getWidth() - 1);
2058 c.verdict(false, viewport.ConsPercGaps);
2059 sg.cs.setConservation(c);
2063 sg.cs.setConservation(null);
2064 sg.cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
2070 if (alignPanel.getOverviewPanel() != null)
2072 alignPanel.getOverviewPanel().updateOverviewImage();
2075 jalview.structure.StructureSelectionManager
2076 .getStructureSelectionManager().sequenceColoursChanged(
2079 alignPanel.paintAlignment(true);
2082 protected void modifyPID_actionPerformed()
2084 if (viewport.getAbovePIDThreshold()
2085 && viewport.globalColourScheme != null)
2087 SliderPanel.setPIDSliderSource(alignPanel, viewport
2088 .getGlobalColourScheme(), "Background");
2089 SliderPanel.showPIDSlider();
2093 protected void modifyConservation_actionPerformed()
2095 if (viewport.getConservationSelected()
2096 && viewport.globalColourScheme != null)
2098 SliderPanel.setConservationSlider(alignPanel,
2099 viewport.globalColourScheme, "Background");
2100 SliderPanel.showConservationSlider();
2104 protected void conservationMenuItem_actionPerformed()
2106 viewport.setConservationSelected(conservationMenuItem.getState());
2108 viewport.setAbovePIDThreshold(false);
2109 abovePIDThreshold.setState(false);
2111 changeColour(viewport.getGlobalColourScheme());
2113 modifyConservation_actionPerformed();
2116 public void abovePIDThreshold_actionPerformed()
2118 viewport.setAbovePIDThreshold(abovePIDThreshold.getState());
2120 conservationMenuItem.setState(false);
2121 viewport.setConservationSelected(false);
2123 changeColour(viewport.getGlobalColourScheme());
2125 modifyPID_actionPerformed();
2127 public void sortPairwiseMenuItem_actionPerformed()
2129 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
2130 AlignmentSorter.sortByPID(viewport.getAlignment(), viewport
2131 .getAlignment().getSequenceAt(0), null);
2133 addHistoryItem(new OrderCommand("Pairwise Sort", oldOrder,
2134 viewport.alignment));
2135 alignPanel.paintAlignment(true);
2138 public void sortIDMenuItem_actionPerformed()
2140 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
2141 AlignmentSorter.sortByID(viewport.getAlignment());
2142 addHistoryItem(new OrderCommand("ID Sort", oldOrder,
2143 viewport.alignment));
2144 alignPanel.paintAlignment(true);
2147 public void sortGroupMenuItem_actionPerformed()
2149 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
2150 AlignmentSorter.sortByGroup(viewport.getAlignment());
2151 addHistoryItem(new OrderCommand("Group Sort", oldOrder,
2152 viewport.alignment));
2153 alignPanel.paintAlignment(true);
2157 public void removeRedundancyMenuItem_actionPerformed()
2159 new RedundancyPanel(alignPanel);
2162 public void pairwiseAlignmentMenuItem_actionPerformed()
2164 if (viewport.getSelectionGroup() != null
2165 && viewport.getSelectionGroup().getSize() > 1)
2167 Frame frame = new Frame();
2168 frame.add(new PairwiseAlignPanel(alignPanel));
2169 jalview.bin.JalviewLite.addFrame(frame, "Pairwise Alignment", 600,
2174 public void PCAMenuItem_actionPerformed()
2176 // are the sequences aligned?
2177 if (!viewport.alignment.isAligned())
2180 int Width = viewport.getAlignment().getWidth();
2182 for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++)
2184 current = viewport.getAlignment().getSequenceAt(i);
2186 if (current.getLength() < Width)
2188 current.insertCharAt(Width - 1, viewport.getGapCharacter());
2191 alignPanel.paintAlignment(true);
2194 if ((viewport.getSelectionGroup() != null
2195 && viewport.getSelectionGroup().getSize() < 4 && viewport
2196 .getSelectionGroup().getSize() > 0)
2197 || viewport.getAlignment().getHeight() < 4)
2204 new PCAPanel(viewport);
2205 } catch (java.lang.OutOfMemoryError ex)
2211 public void averageDistanceTreeMenuItem_actionPerformed()
2213 NewTreePanel("AV", "PID", "Average distance tree using PID");
2216 public void neighbourTreeMenuItem_actionPerformed()
2218 NewTreePanel("NJ", "PID", "Neighbour joining tree using PID");
2221 protected void njTreeBlosumMenuItem_actionPerformed()
2223 NewTreePanel("NJ", "BL", "Neighbour joining tree using BLOSUM62");
2226 protected void avTreeBlosumMenuItem_actionPerformed()
2228 NewTreePanel("AV", "BL", "Average distance tree using BLOSUM62");
2231 void NewTreePanel(String type, String pwType, String title)
2233 // are the sequences aligned?
2234 if (!viewport.alignment.isAligned())
2237 int Width = viewport.getAlignment().getWidth();
2239 for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++)
2241 current = viewport.getAlignment().getSequenceAt(i);
2243 if (current.getLength() < Width)
2245 current.insertCharAt(Width - 1, viewport.getGapCharacter());
2248 alignPanel.paintAlignment(true);
2252 if ((viewport.getSelectionGroup() != null && viewport
2253 .getSelectionGroup().getSize() > 1)
2254 || (viewport.getSelectionGroup() == null && viewport.alignment
2257 final TreePanel tp = new TreePanel(viewport, type, pwType);
2259 addTreeMenuItem(tp, title);
2261 jalview.bin.JalviewLite.addFrame(tp, title, 600, 500);
2265 void loadTree_actionPerformed()
2267 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
2268 cap.setText("Paste your Newick tree file here.");
2269 cap.setTreeImport();
2270 Frame frame = new Frame();
2272 jalview.bin.JalviewLite.addFrame(frame, "Paste Newick file ", 400, 300);
2275 public void loadTree(jalview.io.NewickFile tree, String treeFile)
2277 TreePanel tp = new TreePanel(viewport, treeFile, "From File - ", tree);
2278 jalview.bin.JalviewLite.addFrame(tp, treeFile, 600, 500);
2279 addTreeMenuItem(tp, treeFile);
2282 * sort the alignment using the given treePanel
2283 * @param treePanel tree used to sort view
2284 * @param title string used for undo event name
2286 public void sortByTree(TreePanel treePanel, String title)
2288 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
2289 AlignmentSorter.sortByTree(viewport.getAlignment(), treePanel
2291 // addHistoryItem(new HistoryItem("Sort", viewport.alignment,
2292 // HistoryItem.SORT));
2293 addHistoryItem(new OrderCommand("Order by "+title, oldOrder,
2294 viewport.alignment));
2295 alignPanel.paintAlignment(true);
2298 * Do any automatic reordering of the alignment and add the necessary bits to the menu structure for the new tree
2302 protected void addTreeMenuItem(final TreePanel treePanel, final String title)
2304 final MenuItem item = new MenuItem(title);
2305 sortByTreeMenu.add(item);
2306 item.addActionListener(new java.awt.event.ActionListener()
2308 public void actionPerformed(ActionEvent evt)
2310 sortByTree(treePanel, title); // treePanel.getTitle());
2314 treePanel.addWindowListener(new WindowAdapter()
2316 public void windowOpened(WindowEvent e)
2318 if (viewport.sortByTree)
2320 sortByTree(treePanel, title);
2322 super.windowOpened(e);
2325 public void windowClosing(WindowEvent e)
2327 sortByTreeMenu.remove(item);
2332 protected void documentation_actionPerformed()
2334 showURL("http://www.jalview.org/help.html", "HELP");
2337 protected void about_actionPerformed()
2340 class AboutPanel extends Canvas
2344 public AboutPanel(String version)
2346 this.version = version;
2349 public void paint(Graphics g)
2351 g.setColor(Color.white);
2352 g.fillRect(0, 0, getSize().width, getSize().height);
2353 g.setFont(new Font("Helvetica", Font.PLAIN, 12));
2354 FontMetrics fm = g.getFontMetrics();
2355 int fh = fm.getHeight();
2357 g.setColor(Color.black);
2358 // TODO: update this text for each release or centrally store it for
2359 // lite and application
2360 g.setFont(new Font("Helvetica", Font.BOLD, 14));
2361 g.drawString("JalviewLite - Release " + version, x, y += fh);
2362 g.setFont(new Font("Helvetica", Font.PLAIN, 12));
2365 "Authors: Andrew Waterhouse, Jim Procter, Michele Clamp, James Cuff, Steve Searle,",
2367 g.drawString("David Martin & Geoff Barton.", x + 50, y += fh);
2370 "Development managed by The Barton Group, University of Dundee, Scotland, UK.",
2374 "For help, see the FAQ at www.jalview.org and/or join the jalview-discuss@jalview.org mailing list",
2376 g.drawString("If you use Jalview, please cite:", x, y += fh + 8);
2378 "Waterhouse, A.M., Procter, J.B., Martin, D.M.A, Clamp, M. and Barton, G. J. (2009)",x,y+=fh);
2379 g.drawString("Jalview Version 2 - a multiple sequence alignment editor and analysis workbench",x,y+=fh);
2380 g.drawString("Bioinformatics doi: 10.1093/bioinformatics/btp033",x,y+=fh);
2384 String version = "test";
2385 java.net.URL url = getClass().getResource("/.build_properties");
2390 BufferedReader reader = new BufferedReader(new InputStreamReader(
2393 while ((line = reader.readLine()) != null)
2395 if (line.indexOf("VERSION") > -1)
2397 version = line.substring(line.indexOf("=") + 1);
2400 } catch (Exception ex)
2402 ex.printStackTrace();
2406 Frame frame = new Frame();
2407 frame.add(new AboutPanel(version));
2408 jalview.bin.JalviewLite.addFrame(frame, "Jalview", 580, 220);
2412 public void showURL(String url, String target)
2414 if (viewport.applet == null)
2416 System.out.println("Not running as applet - no browser available.");
2422 if (url.indexOf(":")==-1)
2424 // TODO: verify (Bas Vroling bug) prepend codebase or server URL to form valid URL
2425 if (url.indexOf("/")==0)
2427 String codebase = viewport.applet.getCodeBase().toString();
2428 url = codebase.substring(0,codebase.length()-viewport.applet.getCodeBase().getFile().length())+url;
2430 url = viewport.applet.getCodeBase()+url;
2432 System.out.println("Show url (prepended codebase): " + url);
2434 System.out.println("Show url: " + url);
2436 viewport.applet.getAppletContext().showDocument(
2437 new java.net.URL(url), target);
2438 } catch (Exception ex)
2440 ex.printStackTrace();
2445 // ////////////////////////////////////////////////////////////////////////////////
2446 // JBuilder Graphics here
2448 MenuBar alignFrameMenuBar = new MenuBar();
2450 Menu fileMenu = new Menu("File");
2452 MenuItem loadApplication = new MenuItem("View in Full Application");
2454 MenuItem loadTree = new MenuItem("Load Associated Tree ...");
2456 MenuItem loadAnnotations = new MenuItem("Load Features/Annotations ...");
2458 MenuItem outputFeatures = new MenuItem("Export Features ...");
2460 MenuItem outputAnnotations = new MenuItem("Export Annotations ...");
2462 MenuItem closeMenuItem = new MenuItem("Close");
2464 Menu editMenu = new Menu("Edit");
2466 Menu viewMenu = new Menu("View");
2468 Menu colourMenu = new Menu("Colour");
2470 Menu calculateMenu = new Menu("Calculate");
2472 MenuItem selectAllSequenceMenuItem = new MenuItem("Select all");
2474 MenuItem deselectAllSequenceMenuItem = new MenuItem("Deselect All");
2476 MenuItem invertSequenceMenuItem = new MenuItem("Invert Selection");
2478 MenuItem remove2LeftMenuItem = new MenuItem();
2480 MenuItem remove2RightMenuItem = new MenuItem();
2482 MenuItem removeGappedColumnMenuItem = new MenuItem();
2484 MenuItem removeAllGapsMenuItem = new MenuItem();
2486 CheckboxMenuItem viewBoxesMenuItem = new CheckboxMenuItem();
2488 CheckboxMenuItem viewTextMenuItem = new CheckboxMenuItem();
2490 MenuItem sortPairwiseMenuItem = new MenuItem();
2492 MenuItem sortIDMenuItem = new MenuItem();
2494 MenuItem sortGroupMenuItem = new MenuItem();
2496 MenuItem removeRedundancyMenuItem = new MenuItem();
2498 MenuItem pairwiseAlignmentMenuItem = new MenuItem();
2500 MenuItem PCAMenuItem = new MenuItem();
2502 MenuItem averageDistanceTreeMenuItem = new MenuItem();
2504 MenuItem neighbourTreeMenuItem = new MenuItem();
2506 BorderLayout borderLayout1 = new BorderLayout();
2508 public Label statusBar = new Label();
2510 Menu outputTextboxMenu = new Menu();
2512 MenuItem clustalColour = new MenuItem();
2514 MenuItem zappoColour = new MenuItem();
2516 MenuItem taylorColour = new MenuItem();
2518 MenuItem hydrophobicityColour = new MenuItem();
2520 MenuItem helixColour = new MenuItem();
2522 MenuItem strandColour = new MenuItem();
2524 MenuItem turnColour = new MenuItem();
2526 MenuItem buriedColour = new MenuItem();
2528 MenuItem userDefinedColour = new MenuItem();
2530 MenuItem PIDColour = new MenuItem();
2532 MenuItem BLOSUM62Colour = new MenuItem();
2534 MenuItem njTreeBlosumMenuItem = new MenuItem();
2536 MenuItem avDistanceTreeBlosumMenuItem = new MenuItem();
2538 CheckboxMenuItem annotationPanelMenuItem = new CheckboxMenuItem();
2540 CheckboxMenuItem colourTextMenuItem = new CheckboxMenuItem();
2542 CheckboxMenuItem displayNonconservedMenuItem = new CheckboxMenuItem();
2544 MenuItem alProperties = new MenuItem("Alignment Properties...");
2546 MenuItem overviewMenuItem = new MenuItem();
2548 MenuItem undoMenuItem = new MenuItem();
2550 MenuItem redoMenuItem = new MenuItem();
2552 CheckboxMenuItem conservationMenuItem = new CheckboxMenuItem();
2554 MenuItem noColourmenuItem = new MenuItem();
2556 CheckboxMenuItem wrapMenuItem = new CheckboxMenuItem();
2558 CheckboxMenuItem renderGapsMenuItem = new CheckboxMenuItem();
2560 MenuItem findMenuItem = new MenuItem();
2562 CheckboxMenuItem abovePIDThreshold = new CheckboxMenuItem();
2564 MenuItem nucleotideColour = new MenuItem();
2566 MenuItem deleteGroups = new MenuItem();
2568 MenuItem delete = new MenuItem();
2570 MenuItem copy = new MenuItem();
2572 MenuItem cut = new MenuItem();
2574 Menu pasteMenu = new Menu();
2576 MenuItem pasteNew = new MenuItem();
2578 MenuItem pasteThis = new MenuItem();
2580 CheckboxMenuItem applyToAllGroups = new CheckboxMenuItem();
2582 MenuItem font = new MenuItem();
2584 CheckboxMenuItem scaleAbove = new CheckboxMenuItem();
2586 CheckboxMenuItem scaleLeft = new CheckboxMenuItem();
2588 CheckboxMenuItem scaleRight = new CheckboxMenuItem();
2590 MenuItem modifyPID = new MenuItem();
2592 MenuItem modifyConservation = new MenuItem();
2594 CheckboxMenuItem autoCalculate = new CheckboxMenuItem(
2595 "Autocalculate Consensus", true);
2597 Menu sortByTreeMenu = new Menu();
2599 Menu sort = new Menu();
2601 Menu calculate = new Menu();
2603 MenuItem inputText = new MenuItem();
2605 Menu helpMenu = new Menu();
2607 MenuItem documentation = new MenuItem();
2609 MenuItem about = new MenuItem();
2611 CheckboxMenuItem seqLimits = new CheckboxMenuItem();
2613 CheckboxMenuItem centreColumnLabelFlag = new CheckboxMenuItem();
2615 CheckboxMenuItem followMouseOverFlag = new CheckboxMenuItem();
2617 private void jbInit() throws Exception
2620 setMenuBar(alignFrameMenuBar);
2624 // dynamically fill save as menu with available formats
2625 for (int i = 0; i < jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS.length; i++)
2628 item = new MenuItem(
2629 jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS[i]);
2631 item.addActionListener(new java.awt.event.ActionListener()
2633 public void actionPerformed(ActionEvent e)
2635 outputText_actionPerformed(e);
2639 outputTextboxMenu.add(item);
2641 closeMenuItem.addActionListener(this);
2642 loadApplication.addActionListener(this);
2644 loadTree.addActionListener(this);
2645 loadAnnotations.addActionListener(this);
2646 outputFeatures.addActionListener(this);
2647 outputAnnotations.addActionListener(this);
2648 selectAllSequenceMenuItem.addActionListener(this);
2649 deselectAllSequenceMenuItem.addActionListener(this);
2650 invertSequenceMenuItem.addActionListener(this);
2651 remove2LeftMenuItem.setLabel("Remove Left");
2652 remove2LeftMenuItem.addActionListener(this);
2653 remove2RightMenuItem.setLabel("Remove Right");
2654 remove2RightMenuItem.addActionListener(this);
2655 removeGappedColumnMenuItem.setLabel("Remove Empty Columns");
2656 removeGappedColumnMenuItem.addActionListener(this);
2657 removeAllGapsMenuItem.setLabel("Remove All Gaps");
2658 removeAllGapsMenuItem.addActionListener(this);
2659 viewBoxesMenuItem.setLabel("Boxes");
2660 viewBoxesMenuItem.setState(true);
2661 viewBoxesMenuItem.addItemListener(this);
2662 viewTextMenuItem.setLabel("Text");
2663 viewTextMenuItem.setState(true);
2664 viewTextMenuItem.addItemListener(this);
2665 sortPairwiseMenuItem.setLabel("by Pairwise Identity");
2666 sortPairwiseMenuItem.addActionListener(this);
2667 sortIDMenuItem.setLabel("by ID");
2668 sortIDMenuItem.addActionListener(this);
2669 sortGroupMenuItem.setLabel("by Group");
2670 sortGroupMenuItem.addActionListener(this);
2671 removeRedundancyMenuItem.setLabel("Remove Redundancy...");
2672 removeRedundancyMenuItem.addActionListener(this);
2673 pairwiseAlignmentMenuItem.setLabel("Pairwise Alignments...");
2674 pairwiseAlignmentMenuItem.addActionListener(this);
2675 PCAMenuItem.setLabel("Principal Component Analysis");
2676 PCAMenuItem.addActionListener(this);
2677 averageDistanceTreeMenuItem
2678 .setLabel("Average Distance Using % Identity");
2679 averageDistanceTreeMenuItem.addActionListener(this);
2680 neighbourTreeMenuItem.setLabel("Neighbour Joining Using % Identity");
2681 neighbourTreeMenuItem.addActionListener(this);
2682 statusBar.setBackground(Color.white);
2683 statusBar.setFont(new java.awt.Font("Verdana", 0, 11));
2684 statusBar.setText("Status bar");
2685 outputTextboxMenu.setLabel("Output to Textbox");
2686 clustalColour.setLabel("Clustalx");
2688 clustalColour.addActionListener(this);
2689 zappoColour.setLabel("Zappo");
2690 zappoColour.addActionListener(this);
2691 taylorColour.setLabel("Taylor");
2692 taylorColour.addActionListener(this);
2693 hydrophobicityColour.setLabel("Hydrophobicity");
2694 hydrophobicityColour.addActionListener(this);
2695 helixColour.setLabel("Helix Propensity");
2696 helixColour.addActionListener(this);
2697 strandColour.setLabel("Strand Propensity");
2698 strandColour.addActionListener(this);
2699 turnColour.setLabel("Turn Propensity");
2700 turnColour.addActionListener(this);
2701 buriedColour.setLabel("Buried Index");
2702 buriedColour.addActionListener(this);
2703 userDefinedColour.setLabel("User Defined...");
2704 userDefinedColour.addActionListener(this);
2705 PIDColour.setLabel("Percentage Identity");
2706 PIDColour.addActionListener(this);
2707 BLOSUM62Colour.setLabel("BLOSUM62 Score");
2708 BLOSUM62Colour.addActionListener(this);
2709 avDistanceTreeBlosumMenuItem
2710 .setLabel("Average Distance Using BLOSUM62");
2711 avDistanceTreeBlosumMenuItem.addActionListener(this);
2712 njTreeBlosumMenuItem.setLabel("Neighbour Joining Using BLOSUM62");
2713 njTreeBlosumMenuItem.addActionListener(this);
2714 annotationPanelMenuItem.setLabel("Show Annotations");
2715 annotationPanelMenuItem.addItemListener(this);
2716 colourTextMenuItem.setLabel("Colour Text");
2717 colourTextMenuItem.addItemListener(this);
2718 displayNonconservedMenuItem.setLabel("Show non-conserved");
2719 displayNonconservedMenuItem.addItemListener(this);
2720 alProperties.addActionListener(this);
2721 overviewMenuItem.setLabel("Overview Window");
2722 overviewMenuItem.addActionListener(this);
2723 undoMenuItem.setEnabled(false);
2724 undoMenuItem.setLabel("Undo");
2725 undoMenuItem.addActionListener(this);
2726 redoMenuItem.setEnabled(false);
2727 redoMenuItem.setLabel("Redo");
2728 redoMenuItem.addActionListener(this);
2729 conservationMenuItem.setLabel("by Conservation");
2730 conservationMenuItem.addItemListener(this);
2731 noColourmenuItem.setLabel("None");
2732 noColourmenuItem.addActionListener(this);
2733 wrapMenuItem.setLabel("Wrap");
2734 wrapMenuItem.addItemListener(this);
2735 renderGapsMenuItem.setLabel("Show Gaps");
2736 renderGapsMenuItem.setState(true);
2737 renderGapsMenuItem.addItemListener(this);
2738 findMenuItem.setLabel("Find...");
2739 findMenuItem.addActionListener(this);
2740 abovePIDThreshold.setLabel("Above Identity Threshold");
2741 abovePIDThreshold.addItemListener(this);
2742 nucleotideColour.setLabel("Nucleotide");
2743 nucleotideColour.addActionListener(this);
2744 deleteGroups.setLabel("Undefine Groups");
2745 deleteGroups.addActionListener(this);
2746 copy.setLabel("Copy");
2747 copy.addActionListener(this);
2748 cut.setLabel("Cut");
2749 cut.addActionListener(this);
2750 delete.setLabel("Delete");
2751 delete.addActionListener(this);
2752 pasteMenu.setLabel("Paste");
2753 pasteNew.setLabel("To New Alignment");
2754 pasteNew.addActionListener(this);
2755 pasteThis.setLabel("Add To This Alignment");
2756 pasteThis.addActionListener(this);
2757 applyToAllGroups.setLabel("Apply Colour To All Groups");
2758 applyToAllGroups.setState(true);
2759 applyToAllGroups.addItemListener(this);
2760 font.setLabel("Font...");
2761 font.addActionListener(this);
2762 scaleAbove.setLabel("Scale Above");
2763 scaleAbove.setState(true);
2764 scaleAbove.setEnabled(false);
2765 scaleAbove.addItemListener(this);
2766 scaleLeft.setEnabled(false);
2767 scaleLeft.setState(true);
2768 scaleLeft.setLabel("Scale Left");
2769 scaleLeft.addItemListener(this);
2770 scaleRight.setEnabled(false);
2771 scaleRight.setState(true);
2772 scaleRight.setLabel("Scale Right");
2773 scaleRight.addItemListener(this);
2774 modifyPID.setLabel("Modify Identity Threshold...");
2775 modifyPID.addActionListener(this);
2776 modifyConservation.setLabel("Modify Conservation Threshold...");
2777 modifyConservation.addActionListener(this);
2778 sortByTreeMenu.setLabel("By Tree Order");
2779 sort.setLabel("Sort");
2780 calculate.setLabel("Calculate Tree");
2781 autoCalculate.addItemListener(this);
2782 inputText.setLabel("Input from textbox");
2783 inputText.addActionListener(this);
2784 centreColumnLabelFlag.setLabel("Centre column labels");
2785 centreColumnLabelFlag.addItemListener(this);
2786 followMouseOverFlag.setLabel("Automatic Scrolling");
2787 followMouseOverFlag.addItemListener(this);
2788 helpMenu.setLabel("Help");
2789 documentation.setLabel("Documentation");
2790 documentation.addActionListener(this);
2792 about.setLabel("About...");
2793 about.addActionListener(this);
2794 seqLimits.setState(true);
2795 seqLimits.setLabel("Show Sequence Limits");
2796 seqLimits.addItemListener(this);
2797 featureSettings.setLabel("Feature Settings...");
2798 featureSettings.addActionListener(this);
2799 sequenceFeatures.setLabel("Sequence Features");
2800 sequenceFeatures.addItemListener(this);
2801 sequenceFeatures.setState(false);
2802 annotationColour.setLabel("by Annotation...");
2803 annotationColour.addActionListener(this);
2804 invertSequenceMenuItem.setLabel("Invert Sequence Selection");
2805 invertColSel.setLabel("Invert Column Selection");
2806 menu1.setLabel("Show");
2807 showColumns.setLabel("All Columns ");
2808 showSeqs.setLabel("All Sequences");
2809 menu2.setLabel("Hide");
2810 hideColumns.setLabel("Selected Columns");
2811 hideSequences.setLabel("Selected Sequences");
2812 invertColSel.addActionListener(this);
2813 showColumns.addActionListener(this);
2814 showSeqs.addActionListener(this);
2815 hideColumns.addActionListener(this);
2816 hideSequences.addActionListener(this);
2817 formatMenu.setLabel("Format");
2818 selectMenu.setLabel("Select");
2819 newView.setLabel("New View");
2820 newView.addActionListener(this);
2821 alignFrameMenuBar.add(fileMenu);
2822 alignFrameMenuBar.add(editMenu);
2823 alignFrameMenuBar.add(selectMenu);
2824 alignFrameMenuBar.add(viewMenu);
2825 alignFrameMenuBar.add(formatMenu);
2826 alignFrameMenuBar.add(colourMenu);
2827 alignFrameMenuBar.add(calculateMenu);
2828 alignFrameMenuBar.add(helpMenu);
2830 fileMenu.add(inputText);
2831 fileMenu.add(loadTree);
2832 fileMenu.add(loadAnnotations);
2834 fileMenu.addSeparator();
2835 fileMenu.add(outputTextboxMenu);
2836 fileMenu.add(outputFeatures);
2837 fileMenu.add(outputAnnotations);
2839 if (jalviewServletURL != null)
2841 fileMenu.add(loadApplication);
2844 fileMenu.addSeparator();
2845 fileMenu.add(closeMenuItem);
2847 editMenu.add(undoMenuItem);
2848 editMenu.add(redoMenuItem);
2851 editMenu.add(pasteMenu);
2852 editMenu.add(delete);
2853 editMenu.addSeparator();
2854 editMenu.add(remove2LeftMenuItem);
2855 editMenu.add(remove2RightMenuItem);
2856 editMenu.add(removeGappedColumnMenuItem);
2857 editMenu.add(removeAllGapsMenuItem);
2858 editMenu.add(removeRedundancyMenuItem);
2859 viewMenu.add(newView);
2860 viewMenu.addSeparator();
2861 viewMenu.add(menu1);
2862 viewMenu.add(menu2);
2863 viewMenu.addSeparator();
2864 viewMenu.add(followMouseOverFlag);
2865 viewMenu.add(annotationPanelMenuItem);
2866 viewMenu.addSeparator();
2867 viewMenu.add(sequenceFeatures);
2868 viewMenu.add(featureSettings);
2869 viewMenu.addSeparator();
2870 viewMenu.add(alProperties);
2871 viewMenu.addSeparator();
2872 viewMenu.add(overviewMenuItem);
2873 colourMenu.add(applyToAllGroups);
2874 colourMenu.addSeparator();
2875 colourMenu.add(noColourmenuItem);
2876 colourMenu.add(clustalColour);
2877 colourMenu.add(BLOSUM62Colour);
2878 colourMenu.add(PIDColour);
2879 colourMenu.add(zappoColour);
2880 colourMenu.add(taylorColour);
2881 colourMenu.add(hydrophobicityColour);
2882 colourMenu.add(helixColour);
2883 colourMenu.add(strandColour);
2884 colourMenu.add(turnColour);
2885 colourMenu.add(buriedColour);
2886 colourMenu.add(nucleotideColour);
2887 colourMenu.add(userDefinedColour);
2888 colourMenu.addSeparator();
2889 colourMenu.add(conservationMenuItem);
2890 colourMenu.add(modifyConservation);
2891 colourMenu.add(abovePIDThreshold);
2892 colourMenu.add(modifyPID);
2893 colourMenu.add(annotationColour);
2894 calculateMenu.add(sort);
2895 calculateMenu.add(calculate);
2896 calculateMenu.addSeparator();
2897 calculateMenu.add(pairwiseAlignmentMenuItem);
2898 calculateMenu.add(PCAMenuItem);
2899 calculateMenu.add(autoCalculate);
2900 this.add(statusBar, BorderLayout.SOUTH);
2901 pasteMenu.add(pasteNew);
2902 pasteMenu.add(pasteThis);
2903 sort.add(sortIDMenuItem);
2904 sort.add(sortByTreeMenu);
2905 sort.add(sortGroupMenuItem);
2906 sort.add(sortPairwiseMenuItem);
2907 calculate.add(averageDistanceTreeMenuItem);
2908 calculate.add(neighbourTreeMenuItem);
2909 calculate.add(avDistanceTreeBlosumMenuItem);
2910 calculate.add(njTreeBlosumMenuItem);
2911 helpMenu.add(documentation);
2912 helpMenu.add(about);
2913 menu1.add(showColumns);
2914 menu1.add(showSeqs);
2915 menu2.add(hideColumns);
2916 menu2.add(hideSequences);
2917 formatMenu.add(font);
2918 formatMenu.add(seqLimits);
2919 formatMenu.add(wrapMenuItem);
2920 formatMenu.add(scaleAbove);
2921 formatMenu.add(scaleLeft);
2922 formatMenu.add(scaleRight);
2923 formatMenu.add(viewBoxesMenuItem);
2924 formatMenu.add(viewTextMenuItem);
2925 formatMenu.add(colourTextMenuItem);
2926 formatMenu.add(displayNonconservedMenuItem);
2927 formatMenu.add(renderGapsMenuItem);
2928 formatMenu.add(centreColumnLabelFlag);
2929 selectMenu.add(findMenuItem);
2930 selectMenu.addSeparator();
2931 selectMenu.add(selectAllSequenceMenuItem);
2932 selectMenu.add(deselectAllSequenceMenuItem);
2933 selectMenu.add(invertSequenceMenuItem);
2934 selectMenu.add(invertColSel);
2935 selectMenu.add(deleteGroups);
2938 MenuItem featureSettings = new MenuItem();
2940 CheckboxMenuItem sequenceFeatures = new CheckboxMenuItem();
2942 MenuItem annotationColour = new MenuItem();
2944 MenuItem invertColSel = new MenuItem();
2946 Menu menu1 = new Menu();
2948 MenuItem showColumns = new MenuItem();
2950 MenuItem showSeqs = new MenuItem();
2952 Menu menu2 = new Menu();
2954 MenuItem hideColumns = new MenuItem();
2956 MenuItem hideSequences = new MenuItem();
2958 Menu formatMenu = new Menu();
2960 Menu selectMenu = new Menu();
2962 MenuItem newView = new MenuItem();
2965 * Attach the alignFrame panels after embedding menus, if necessary. This used
2966 * to be called setEmbedded, but is now creates the dropdown menus in a
2967 * platform independent manner to avoid OSX/Mac menu appendage daftness.
2969 * @param reallyEmbedded
2970 * true to attach the view to the applet area on the page
2971 * rather than in a new window
2973 public void createAlignFrameWindow(boolean reallyEmbedded, String title)
2978 // Explicly build the embedded menu panel for the on-page applet
2980 // view cannot be closed if its actually on the page
2981 fileMenu.remove(closeMenuItem);
2982 fileMenu.remove(3); // Remove Seperator
2983 embeddedMenu = makeEmbeddedPopupMenu(alignFrameMenuBar, "Arial",
2984 Font.PLAIN, 10, false); // use our own fonts.
2985 // and actually add the components to the applet area
2986 viewport.applet.setLayout(new BorderLayout());
2987 viewport.applet.add(embeddedMenu, BorderLayout.NORTH);
2988 viewport.applet.add(statusBar, BorderLayout.SOUTH);
2989 alignPanel.setSize(viewport.applet.getSize().width, viewport.applet
2991 - embeddedMenu.HEIGHT - statusBar.HEIGHT);
2992 viewport.applet.add(alignPanel, BorderLayout.CENTER);
2993 viewport.applet.validate();
2998 // test and embed menu bar if necessary.
3000 if (embedMenuIfNeeded(alignPanel))
3002 // adjust for status bar height too
3003 alignPanel.setSize(getSize().width, getSize().height
3004 - statusBar.HEIGHT);
3006 add(statusBar, BorderLayout.SOUTH);
3007 add(alignPanel, BorderLayout.CENTER);
3008 // and register with the applet so it can pass external API calls to us
3009 jalview.bin.JalviewLite.addFrame(this, title, DEFAULT_WIDTH,