2 * Jalview - A Sequence Alignment Editor and Viewer
3 * Copyright (C) 2007 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
20 package jalview.appletgui;
27 import java.awt.event.*;
29 import jalview.analysis.*;
30 import jalview.commands.*;
31 import jalview.datamodel.*;
33 import jalview.schemes.*;
35 public class AlignFrame
36 extends Frame implements ActionListener,
37 ItemListener, KeyListener, MouseListener
39 public AlignmentPanel alignPanel;
40 public AlignViewport viewport;
41 int DEFAULT_WIDTH = 700;
42 int DEFAULT_HEIGHT = 500;
44 String jalviewServletURL;
46 public AlignFrame(AlignmentI al,
47 jalview.bin.JalviewLite applet,
54 jalviewServletURL = applet.getParameter("APPLICATION_URL");
66 viewport = new AlignViewport(al, applet);
67 alignPanel = new AlignmentPanel(this, viewport);
69 viewport.updateConservation(alignPanel);
70 viewport.updateConsensus(alignPanel);
72 annotationPanelMenuItem.setState(viewport.showAnnotation);
74 seqLimits.setState(viewport.showJVSuffix);
78 String param = applet.getParameter("sortBy");
81 if (param.equalsIgnoreCase("Id"))
83 sortIDMenuItem_actionPerformed();
85 else if (param.equalsIgnoreCase("Pairwise Identity"))
87 sortPairwiseMenuItem_actionPerformed();
91 param = applet.getParameter("wrap");
94 if (param.equalsIgnoreCase("true"))
96 wrapMenuItem.setState(true);
97 wrapMenuItem_actionPerformed();
103 param = applet.getParameter("windowWidth");
106 int width = Integer.parseInt(param);
107 DEFAULT_WIDTH = width;
109 param = applet.getParameter("windowHeight");
112 int height = Integer.parseInt(param);
113 DEFAULT_HEIGHT = height;
121 //Some JVMS send keyevents to Top frame or lowest panel,
122 //Havent worked out why yet. So add to both this frame and seqCanvas for now
123 this.addKeyListener(this);
124 alignPanel.seqPanel.seqCanvas.addKeyListener(this);
125 alignPanel.idPanel.idCanvas.addKeyListener(this);
126 alignPanel.scalePanel.addKeyListener(this);
127 alignPanel.annotationPanel.addKeyListener(this);
135 add(alignPanel, BorderLayout.CENTER);
136 jalview.bin.JalviewLite.addFrame(this, title, DEFAULT_WIDTH,
139 alignPanel.validate();
140 alignPanel.paintAlignment(true);
143 public AlignViewport getAlignViewport()
148 public SeqCanvas getSeqcanvas()
150 return alignPanel.seqPanel.seqCanvas;
156 * @param String DOCUMENT ME!
159 public void parseFeaturesFile(String file, String type)
161 Hashtable featureLinks = new Hashtable();
162 boolean featuresFile = false;
165 featuresFile = new jalview.io.FeaturesFile(file,
166 type).parse(viewport.alignment,
167 alignPanel.seqPanel.seqCanvas.
168 getFeatureRenderer().featureColours,
174 ex.printStackTrace();
179 if (featureLinks.size() > 0)
181 alignPanel.seqPanel.seqCanvas
182 .getFeatureRenderer().featureLinks = featureLinks;
184 viewport.showSequenceFeatures = true;
185 sequenceFeatures.setState(true);
186 alignPanel.paintAlignment(true);
191 public void keyPressed(KeyEvent evt)
193 if (viewport.cursorMode &&
194 ( (evt.getKeyCode() >= KeyEvent.VK_0 &&
195 evt.getKeyCode() <= KeyEvent.VK_9)
197 (evt.getKeyCode() >= KeyEvent.VK_NUMPAD0 &&
198 evt.getKeyCode() <= KeyEvent.VK_NUMPAD9)
200 && Character.isDigit(evt.getKeyChar()))
201 alignPanel.seqPanel.numberPressed(evt.getKeyChar());
204 switch (evt.getKeyCode())
206 case 27: // escape key
207 deselectAllSequenceMenuItem_actionPerformed();
210 if (evt.isControlDown() || evt.isMetaDown())
212 cut_actionPerformed();
216 if (viewport.cursorMode && !evt.isControlDown())
218 alignPanel.seqPanel.setCursorColumn();
220 if (evt.isControlDown() || evt.isMetaDown())
222 copy_actionPerformed();
226 if (evt.isControlDown())
228 paste(evt.isShiftDown());
232 if (evt.isControlDown() || evt.isMetaDown())
234 selectAllSequenceMenuItem_actionPerformed();
237 case KeyEvent.VK_DOWN:
238 if (viewport.cursorMode)
240 alignPanel.seqPanel.moveCursor(0, 1);
244 moveSelectedSequences(false);
249 if (viewport.cursorMode)
251 alignPanel.seqPanel.moveCursor(0, -1);
255 moveSelectedSequences(true);
259 case KeyEvent.VK_LEFT:
260 if (evt.isAltDown() || !viewport.cursorMode)
261 slideSequences(false,
262 alignPanel.seqPanel.getKeyboardNo1());
264 alignPanel.seqPanel.moveCursor( -1, 0);
267 case KeyEvent.VK_RIGHT:
268 if (evt.isAltDown() || !viewport.cursorMode)
270 alignPanel.seqPanel.getKeyboardNo1());
272 alignPanel.seqPanel.moveCursor( 1, 0);
275 case KeyEvent.VK_SPACE:
276 if (viewport.cursorMode)
278 alignPanel.seqPanel.insertGapAtCursor(evt.isControlDown()
285 case KeyEvent.VK_DELETE:
286 case KeyEvent.VK_BACK_SPACE:
287 if (viewport.cursorMode)
289 alignPanel.seqPanel.deleteGapAtCursor(evt.isControlDown()
295 cut_actionPerformed();
296 alignPanel.seqPanel.seqCanvas.repaint();
301 if (viewport.cursorMode)
303 alignPanel.seqPanel.setCursorRow();
307 if (viewport.cursorMode)
309 alignPanel.seqPanel.setCursorPosition();
313 case KeyEvent.VK_ENTER:
314 case KeyEvent.VK_COMMA:
315 if (viewport.cursorMode)
317 alignPanel.seqPanel.setCursorRowAndColumn();
322 if (viewport.cursorMode)
324 alignPanel.seqPanel.setSelectionAreaAtCursor(true);
328 if (viewport.cursorMode)
330 alignPanel.seqPanel.setSelectionAreaAtCursor(false);
335 viewport.cursorMode = !viewport.cursorMode;
336 statusBar.setText("Keyboard editing mode is " +
337 (viewport.cursorMode ? "on" : "off"));
338 if (viewport.cursorMode)
340 alignPanel.seqPanel.seqCanvas.cursorX = viewport.startRes;
341 alignPanel.seqPanel.seqCanvas.cursorY = viewport.startSeq;
346 if (evt.isControlDown())
348 findMenuItem_actionPerformed();
354 boolean toggleSeqs = !evt.isControlDown();
355 boolean toggleCols = !evt.isShiftDown();
356 boolean hide = false;
357 SequenceGroup sg = viewport.getSelectionGroup();
361 if (sg != null && sg.getSize() != viewport.alignment.getHeight())
364 viewport.hideAllSelectedSeqs();
366 else if (! (toggleCols && viewport.colSel.getSelected().size() > 0))
368 viewport.showAllHiddenSeqs();
374 if (viewport.colSel.getSelected().size() > 0)
376 viewport.hideSelectedColumns();
379 viewport.selectionGroup = sg;
384 viewport.showAllHiddenColumns();
390 case KeyEvent.VK_PAGE_UP:
391 if (viewport.wrapAlignment)
393 alignPanel.scrollUp(true);
397 alignPanel.setScrollValues(viewport.startRes,
399 - viewport.endSeq + viewport.startSeq);
403 case KeyEvent.VK_PAGE_DOWN:
404 if (viewport.wrapAlignment)
406 alignPanel.scrollUp(false);
410 alignPanel.setScrollValues(viewport.startRes,
412 + viewport.endSeq - viewport.startSeq);
417 if (evt.isControlDown())
419 undoMenuItem_actionPerformed();
424 if (evt.isControlDown())
426 redoMenuItem_actionPerformed();
431 if (evt.isControlDown())
438 if (evt.isControlDown())
440 trimAlignment(false);
445 if (evt.isControlDown())
447 if (evt.isShiftDown())
449 this.removeAllGapsMenuItem_actionPerformed();
453 removeGappedColumnMenuItem_actionPerformed();
458 if (evt.isControlDown())
462 viewport.invertColumnSelection();
466 this.invertSequenceMenuItem_actionPerformed();
472 if (evt.isControlDown())
474 this.deleteGroups_actionPerformed();
479 if (evt.isControlDown())
486 alignPanel.paintAlignment(true);
489 public void keyReleased(KeyEvent evt)
492 public void keyTyped(KeyEvent evt)
495 public void itemStateChanged(ItemEvent evt)
497 if (evt.getSource() == colourTextMenuItem)
499 colourTextMenuItem_actionPerformed();
501 else if (evt.getSource() == wrapMenuItem)
503 wrapMenuItem_actionPerformed();
505 else if (evt.getSource() == scaleAbove)
507 viewport.setScaleAboveWrapped(scaleAbove.getState());
509 else if (evt.getSource() == scaleLeft)
511 viewport.setScaleLeftWrapped(scaleLeft.getState());
513 else if (evt.getSource() == scaleRight)
515 viewport.setScaleRightWrapped(scaleRight.getState());
517 else if (evt.getSource() == seqLimits)
519 seqLimits_itemStateChanged();
521 else if (evt.getSource() == viewBoxesMenuItem)
523 viewport.setShowBoxes(viewBoxesMenuItem.getState());
525 else if (evt.getSource() == viewTextMenuItem)
527 viewport.setShowText(viewTextMenuItem.getState());
529 else if (evt.getSource() == renderGapsMenuItem)
531 viewport.setRenderGaps(renderGapsMenuItem.getState());
533 else if (evt.getSource() == annotationPanelMenuItem)
535 viewport.setShowAnnotation(annotationPanelMenuItem.getState());
536 alignPanel.setAnnotationVisible(annotationPanelMenuItem.getState());
538 else if (evt.getSource() == sequenceFeatures)
540 viewport.showSequenceFeatures(sequenceFeatures.getState());
541 alignPanel.seqPanel.seqCanvas.repaint();
543 else if (evt.getSource() == conservationMenuItem)
545 conservationMenuItem_actionPerformed();
547 else if (evt.getSource() == abovePIDThreshold)
549 abovePIDThreshold_actionPerformed();
551 else if (evt.getSource() == applyToAllGroups)
553 viewport.setColourAppliesToAllGroups(applyToAllGroups.getState());
555 else if (evt.getSource() == autoCalculate)
557 viewport.autocalculateConsensus = autoCalculate.getState();
560 alignPanel.paintAlignment(true);
563 public void actionPerformed(ActionEvent evt)
565 Object source = evt.getSource();
567 if (source == inputText)
569 inputText_actionPerformed();
571 else if (source == loadTree)
573 loadTree_actionPerformed();
575 else if (source == loadApplication)
577 launchFullApplication();
579 else if (source == loadAnnotations)
583 else if (source == outputAnnotations)
585 outputAnnotations(true);
587 else if (source == outputFeatures)
589 outputFeatures(true, "Jalview");
591 else if (source == closeMenuItem)
593 closeMenuItem_actionPerformed();
595 else if (source == copy)
597 copy_actionPerformed();
599 else if (source == undoMenuItem)
601 undoMenuItem_actionPerformed();
603 else if (source == redoMenuItem)
605 redoMenuItem_actionPerformed();
607 else if (source == inputText)
609 inputText_actionPerformed();
611 else if (source == closeMenuItem)
613 closeMenuItem_actionPerformed();
615 else if (source == undoMenuItem)
617 undoMenuItem_actionPerformed();
619 else if (source == redoMenuItem)
621 redoMenuItem_actionPerformed();
623 else if (source == copy)
625 copy_actionPerformed();
627 else if (source == pasteNew)
629 pasteNew_actionPerformed();
631 else if (source == pasteThis)
633 pasteThis_actionPerformed();
635 else if (source == cut)
637 cut_actionPerformed();
639 else if (source == delete)
641 delete_actionPerformed();
643 else if (source == deleteGroups)
645 deleteGroups_actionPerformed();
647 else if (source == selectAllSequenceMenuItem)
649 selectAllSequenceMenuItem_actionPerformed();
651 else if (source == deselectAllSequenceMenuItem)
653 deselectAllSequenceMenuItem_actionPerformed();
655 else if (source == invertSequenceMenuItem)
657 invertSequenceMenuItem_actionPerformed();
659 else if (source == invertColSel)
661 viewport.invertColumnSelection();
662 alignPanel.paintAlignment(true);
664 else if (source == remove2LeftMenuItem)
668 else if (source == remove2RightMenuItem)
670 trimAlignment(false);
672 else if (source == removeGappedColumnMenuItem)
674 removeGappedColumnMenuItem_actionPerformed();
676 else if (source == removeAllGapsMenuItem)
678 removeAllGapsMenuItem_actionPerformed();
680 else if (source == findMenuItem)
682 findMenuItem_actionPerformed();
684 else if (source == font)
686 new FontChooser(alignPanel);
688 else if (source == newView)
692 else if (source == showColumns)
694 viewport.showAllHiddenColumns();
695 alignPanel.paintAlignment(true);
697 else if (source == showSeqs)
699 viewport.showAllHiddenSeqs();
701 else if (source == hideColumns)
703 viewport.hideSelectedColumns();
704 alignPanel.paintAlignment(true);
706 else if (source == hideSequences && viewport.getSelectionGroup() != null)
708 viewport.hideAllSelectedSeqs();
710 else if (source == featureSettings)
712 new FeatureSettings(alignPanel);
714 else if(source== alProperties)
716 StringBuffer contents = new StringBuffer();
719 int min=Integer.MAX_VALUE, max=0;
720 for(int i=0; i<viewport.alignment.getHeight(); i++)
722 int size = viewport.alignment.getSequenceAt(i).getEnd()
723 -viewport.alignment.getSequenceAt(i).getStart();
730 avg = avg/(float)viewport.alignment.getHeight();
732 contents.append("\nSequences: "+ viewport.alignment.getHeight());
733 contents.append("\nMinimum Sequence Length: "+min);
734 contents.append("\nMaximum Sequence Length: "+max);
735 contents.append("\nAverage Length: "+(int)avg);
737 if (((Alignment)viewport.alignment).alignmentProperties != null)
739 Hashtable props = ((Alignment)viewport.alignment).alignmentProperties;
740 Enumeration en = props.keys();
741 while(en.hasMoreElements())
743 String key = en.nextElement().toString();
744 contents.append("\n"+key+"\t"+props.get(key));
748 CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this);
749 cap.setText(contents.toString());
750 Frame frame = new Frame();
752 jalview.bin.JalviewLite.addFrame(frame,
753 "Alignment Properties: "+getTitle()
756 else if (source == overviewMenuItem)
758 overviewMenuItem_actionPerformed();
760 else if (source == noColourmenuItem)
764 else if (source == clustalColour)
766 abovePIDThreshold.setState(false);
767 changeColour(new ClustalxColourScheme(viewport.alignment.getSequences(),
768 viewport.alignment.getWidth()));
770 else if (source == zappoColour)
772 changeColour(new ZappoColourScheme());
774 else if (source == taylorColour)
776 changeColour(new TaylorColourScheme());
778 else if (source == hydrophobicityColour)
780 changeColour(new HydrophobicColourScheme());
782 else if (source == helixColour)
784 changeColour(new HelixColourScheme());
786 else if (source == strandColour)
788 changeColour(new StrandColourScheme());
790 else if (source == turnColour)
792 changeColour(new TurnColourScheme());
794 else if (source == buriedColour)
796 changeColour(new BuriedColourScheme());
798 else if (source == nucleotideColour)
800 changeColour(new NucleotideColourScheme());
802 else if (source == modifyPID)
804 modifyPID_actionPerformed();
806 else if (source == modifyConservation)
808 modifyConservation_actionPerformed();
810 else if (source == userDefinedColour)
812 new UserDefinedColours(alignPanel, null);
814 else if (source == PIDColour)
816 changeColour(new PIDColourScheme());
818 else if (source == BLOSUM62Colour)
820 changeColour(new Blosum62ColourScheme());
822 else if (source == annotationColour)
824 new AnnotationColourChooser(viewport, alignPanel);
826 else if (source == sortPairwiseMenuItem)
828 sortPairwiseMenuItem_actionPerformed();
830 else if (source == sortIDMenuItem)
832 sortIDMenuItem_actionPerformed();
834 else if (source == sortGroupMenuItem)
836 sortGroupMenuItem_actionPerformed();
838 else if (source == removeRedundancyMenuItem)
840 removeRedundancyMenuItem_actionPerformed();
842 else if (source == pairwiseAlignmentMenuItem)
844 pairwiseAlignmentMenuItem_actionPerformed();
846 else if (source == PCAMenuItem)
848 PCAMenuItem_actionPerformed();
850 else if (source == averageDistanceTreeMenuItem)
852 averageDistanceTreeMenuItem_actionPerformed();
854 else if (source == neighbourTreeMenuItem)
856 neighbourTreeMenuItem_actionPerformed();
858 else if (source == njTreeBlosumMenuItem)
860 njTreeBlosumMenuItem_actionPerformed();
862 else if (source == avDistanceTreeBlosumMenuItem)
864 avTreeBlosumMenuItem_actionPerformed();
866 else if (source == documentation)
868 documentation_actionPerformed();
870 else if (source == about)
872 about_actionPerformed();
877 public void inputText_actionPerformed()
879 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
880 Frame frame = new Frame();
882 jalview.bin.JalviewLite.addFrame(frame, "Cut & Paste Input", 500, 500);
885 protected void outputText_actionPerformed(ActionEvent e)
887 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
888 Frame frame = new Frame();
890 jalview.bin.JalviewLite.addFrame(frame,
891 "Alignment output - " + e.getActionCommand(),
893 cap.setText(new AppletFormatAdapter().formatSequences(e.getActionCommand(),
894 viewport.getAlignment(),
895 viewport.showJVSuffix));
898 public void loadAnnotations()
900 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
901 cap.setText("Paste your features / annotations file here.");
902 cap.setAnnotationImport();
903 Frame frame = new Frame();
905 jalview.bin.JalviewLite.addFrame(frame, "Paste Annotations ", 400, 300);
909 public String outputAnnotations(boolean displayTextbox)
911 String annotation = new AnnotationFile().printAnnotations(
912 viewport.showAnnotation ? viewport.alignment.getAlignmentAnnotation() : null,
913 viewport.alignment.getGroups(),
914 ((Alignment) viewport.alignment).alignmentProperties);
918 CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this);
919 Frame frame = new Frame();
921 jalview.bin.JalviewLite.addFrame(frame,
924 cap.setText(annotation);
930 public String outputFeatures(boolean displayTextbox, String format)
933 if (format.equalsIgnoreCase("Jalview"))
935 features = new FeaturesFile().printJalviewFormat(
936 viewport.alignment.getSequencesArray(),
937 viewport.featuresDisplayed);
941 features = new FeaturesFile().printGFFFormat(
942 viewport.alignment.getSequencesArray(),
943 viewport.featuresDisplayed);
948 CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this);
949 Frame frame = new Frame();
951 jalview.bin.JalviewLite.addFrame(frame,
955 cap.setText(features);
961 void launchFullApplication()
963 StringBuffer url = new StringBuffer(jalviewServletURL);
965 url.append("?open=" +
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=");
977 url.append(appendProtocol(viewport.applet.getParameter("annotations")));
980 if (viewport.applet.getParameter("jnetfile") != null)
982 url.append("&annotations=");
983 url.append(appendProtocol(viewport.applet.getParameter("jnetfile")));
986 if (viewport.applet.getParameter("defaultColour") != null)
988 url.append("&colour=" +
989 removeWhiteSpace(viewport.applet.getParameter("defaultColour"))
993 if (viewport.applet.getParameter("userDefinedColour") != null)
995 url.append("&colour=" +
996 removeWhiteSpace(viewport.applet.getParameter(
997 "userDefinedColour"))
1001 showURL(url.toString(), "FULL_APP");
1004 String removeWhiteSpace(String colour)
1006 StringBuffer sb = new StringBuffer();
1007 for (int i = 0; i < colour.length(); i++)
1009 if (Character.isWhitespace(colour.charAt(i)))
1015 sb.append(colour.charAt(i));
1019 return sb.toString();
1022 String appendProtocol(String url)
1028 catch (java.net.MalformedURLException ex)
1030 url = viewport.applet.getCodeBase() + url;
1035 public void closeMenuItem_actionPerformed()
1037 PaintRefresher.RemoveComponent(alignPanel);
1038 PaintRefresher.RemoveComponent(alignPanel.seqPanel.seqCanvas);
1039 PaintRefresher.RemoveComponent(alignPanel.idPanel.idCanvas);
1041 if (PaintRefresher.components.size() == 0 && viewport.applet == null)
1052 void updateEditMenuBar()
1055 if (viewport.historyList.size() > 0)
1057 undoMenuItem.setEnabled(true);
1058 CommandI command = (CommandI) viewport.historyList.peek();
1059 undoMenuItem.setLabel("Undo " + command.getDescription());
1063 undoMenuItem.setEnabled(false);
1064 undoMenuItem.setLabel("Undo");
1067 if (viewport.redoList.size() > 0)
1069 redoMenuItem.setEnabled(true);
1071 CommandI command = (CommandI) viewport.redoList.peek();
1072 redoMenuItem.setLabel("Redo " + command.getDescription());
1076 redoMenuItem.setEnabled(false);
1077 redoMenuItem.setLabel("Redo");
1081 public void addHistoryItem(CommandI command)
1083 if (command.getSize() > 0)
1085 viewport.historyList.push(command);
1086 viewport.redoList.removeAllElements();
1087 updateEditMenuBar();
1088 viewport.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;
1094 * @param e DOCUMENT ME!
1096 protected void undoMenuItem_actionPerformed()
1098 if (viewport.historyList.size() < 1)
1103 CommandI command = (CommandI) viewport.historyList.pop();
1104 viewport.redoList.push(command);
1105 command.undoCommand(null);
1107 AlignViewport originalSource = getOriginatingSource(command);
1109 originalSource.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;
1110 updateEditMenuBar();
1111 originalSource.firePropertyChange("alignment", null,
1112 originalSource.alignment.getSequences());
1118 * @param e DOCUMENT ME!
1120 protected void redoMenuItem_actionPerformed()
1122 if (viewport.redoList.size() < 1)
1127 CommandI command = (CommandI) viewport.redoList.pop();
1128 viewport.historyList.push(command);
1129 command.doCommand(null);
1131 AlignViewport originalSource = getOriginatingSource(command);
1132 originalSource.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;
1134 updateEditMenuBar();
1135 originalSource.firePropertyChange("alignment", null,
1136 originalSource.alignment.getSequences());
1139 AlignViewport getOriginatingSource(CommandI command)
1141 AlignViewport originalSource = null;
1142 //For sequence removal and addition, we need to fire
1143 //the property change event FROM the viewport where the
1144 //original alignment was altered
1145 AlignmentI al = null;
1146 if (command instanceof EditCommand)
1148 EditCommand editCommand = (EditCommand) command;
1149 al = editCommand.getAlignment();
1150 Vector comps = (Vector) PaintRefresher.components
1151 .get(viewport.getSequenceSetId());
1152 for (int i = 0; i < comps.size(); i++)
1154 if (comps.elementAt(i) instanceof AlignmentPanel)
1156 if (al == ( (AlignmentPanel) comps.elementAt(i)).av.alignment)
1158 originalSource = ( (AlignmentPanel) comps.elementAt(i)).av;
1165 if (originalSource == null)
1167 //The original view is closed, we must validate
1168 //the current view against the closed view first
1171 PaintRefresher.validateSequences(al, viewport.alignment);
1174 originalSource = viewport;
1177 return originalSource;
1180 public void moveSelectedSequences(boolean up)
1182 SequenceGroup sg = viewport.getSelectionGroup();
1190 for (int i = 1; i < viewport.alignment.getHeight(); i++)
1192 SequenceI seq = viewport.alignment.getSequenceAt(i);
1193 if (!sg.getSequences(null).contains(seq))
1198 SequenceI temp = viewport.alignment.getSequenceAt(i - 1);
1199 if (sg.getSequences(null).contains(temp))
1204 viewport.alignment.getSequences().setElementAt(temp, i);
1205 viewport.alignment.getSequences().setElementAt(seq, i - 1);
1210 for (int i = viewport.alignment.getHeight() - 2; i > -1; i--)
1212 SequenceI seq = viewport.alignment.getSequenceAt(i);
1213 if (!sg.getSequences(viewport.hiddenRepSequences).contains(seq))
1218 SequenceI temp = viewport.alignment.getSequenceAt(i + 1);
1219 if (sg.getSequences(viewport.hiddenRepSequences).contains(temp))
1224 viewport.alignment.getSequences().setElementAt(temp, i);
1225 viewport.alignment.getSequences().setElementAt(seq, i + 1);
1229 alignPanel.paintAlignment(true);
1232 synchronized void slideSequences(boolean right, int size)
1234 Vector sg = new Vector();
1235 if(viewport.cursorMode)
1237 sg.addElement(viewport.alignment.getSequenceAt(
1238 alignPanel.seqPanel.seqCanvas.cursorY));
1240 else if(viewport.getSelectionGroup()!=null
1241 && viewport.getSelectionGroup().getSize()!=viewport.alignment.getHeight())
1243 sg = viewport.getSelectionGroup().getSequences(
1244 viewport.hiddenRepSequences);
1252 Vector invertGroup = new Vector();
1254 for (int i = 0; i < viewport.alignment.getHeight(); i++)
1256 if(!sg.contains(viewport.alignment.getSequenceAt(i)))
1257 invertGroup.addElement(viewport.alignment.getSequenceAt(i));
1260 SequenceI[] seqs1 = new SequenceI[sg.size()];
1261 for (int i = 0; i < sg.size(); i++)
1262 seqs1[i] = (SequenceI) sg.elementAt(i);
1264 SequenceI[] seqs2 = new SequenceI[invertGroup.size()];
1265 for (int i = 0; i < invertGroup.size(); i++)
1266 seqs2[i] = (SequenceI) invertGroup.elementAt(i);
1268 SlideSequencesCommand ssc;
1270 ssc = new SlideSequencesCommand("Slide Sequences",
1272 viewport.getGapCharacter()
1275 ssc = new SlideSequencesCommand("Slide Sequences",
1277 viewport.getGapCharacter()
1280 int groupAdjustment = 0;
1281 if (ssc.getGapsInsertedBegin() && right)
1283 if (viewport.cursorMode)
1284 alignPanel.seqPanel.moveCursor(size, 0);
1286 groupAdjustment = size;
1288 else if (!ssc.getGapsInsertedBegin() && !right)
1290 if (viewport.cursorMode)
1291 alignPanel.seqPanel.moveCursor( -size, 0);
1293 groupAdjustment = -size;
1296 if (groupAdjustment != 0)
1298 viewport.getSelectionGroup().setStartRes(
1299 viewport.getSelectionGroup().getStartRes() + groupAdjustment);
1300 viewport.getSelectionGroup().setEndRes(
1301 viewport.getSelectionGroup().getEndRes() + groupAdjustment);
1305 boolean appendHistoryItem = false;
1306 if(viewport.historyList!=null
1307 && viewport.historyList.size()>0
1308 && viewport.historyList.peek() instanceof SlideSequencesCommand)
1310 appendHistoryItem = ssc.appendSlideCommand(
1311 (SlideSequencesCommand)viewport.historyList.peek())
1315 if(!appendHistoryItem)
1316 addHistoryItem(ssc);
1321 static StringBuffer copiedSequences;
1322 static Vector copiedHiddenColumns;
1323 protected void copy_actionPerformed()
1325 if (viewport.getSelectionGroup() == null)
1330 SequenceGroup sg = viewport.getSelectionGroup();
1331 copiedSequences = new StringBuffer();
1332 Hashtable orderedSeqs = new Hashtable();
1333 for (int i = 0; i < sg.getSize(); i++)
1335 SequenceI seq = sg.getSequenceAt(i);
1336 int index = viewport.alignment.findIndex(seq);
1337 orderedSeqs.put(index + "", seq);
1340 int index = 0, startRes, endRes;
1343 if (viewport.hasHiddenColumns && viewport.getSelectionGroup() != null)
1345 copiedHiddenColumns = new Vector();
1346 int hiddenOffset = viewport.getSelectionGroup().getStartRes();
1347 for (int i = 0; i < viewport.getColumnSelection().getHiddenColumns().size();
1350 int[] region = (int[])
1351 viewport.getColumnSelection().getHiddenColumns().elementAt(i);
1353 copiedHiddenColumns.addElement(new int[]
1354 {region[0] - hiddenOffset,
1355 region[1] - hiddenOffset});
1360 copiedHiddenColumns = null;
1363 for (int i = 0; i < sg.getSize(); i++)
1365 SequenceI seq = null;
1369 if (orderedSeqs.containsKey(index + ""))
1371 seq = (SequenceI) orderedSeqs.get(index + "");
1383 //Returns residue following index if gap
1384 startRes = seq.findPosition(sg.getStartRes());
1387 //Need to find the residue preceeding index if gap
1390 for (int j = 0; j < sg.getEndRes() + 1 && j < seq.getLength(); j++)
1392 ch = seq.getCharAt(j);
1393 if (!jalview.util.Comparison.isGap( (ch)))
1401 endRes += seq.getStart() - 1;
1404 copiedSequences.append(seq.getName() + "\t" +
1407 seq.getSequenceAsString(sg.getStartRes(),
1408 sg.getEndRes() + 1) + "\n");
1413 protected void pasteNew_actionPerformed()
1418 protected void pasteThis_actionPerformed()
1423 void paste(boolean newAlignment)
1428 if (copiedSequences == null)
1433 StringTokenizer st = new StringTokenizer(copiedSequences.toString());
1434 Vector seqs = new Vector();
1435 while (st.hasMoreElements())
1437 String name = st.nextToken();
1438 int start = Integer.parseInt(st.nextToken());
1439 int end = Integer.parseInt(st.nextToken());
1440 seqs.addElement(new Sequence(name, st.nextToken(), start, end));
1442 SequenceI[] newSeqs = new SequenceI[seqs.size()];
1443 for (int i = 0; i < seqs.size(); i++)
1445 newSeqs[i] = (SequenceI) seqs.elementAt(i);
1450 String newtitle = new String("Copied sequences");
1451 if (getTitle().startsWith("Copied sequences"))
1453 newtitle = getTitle();
1457 newtitle = newtitle.concat("- from " + getTitle());
1459 AlignFrame af = new AlignFrame(new Alignment(newSeqs),
1463 if (copiedHiddenColumns != null)
1465 for (int i = 0; i < copiedHiddenColumns.size(); i++)
1467 int[] region = (int[]) copiedHiddenColumns.elementAt(i);
1468 af.viewport.hideColumns(region[0], region[1]);
1472 jalview.bin.JalviewLite.addFrame(af, newtitle, DEFAULT_WIDTH,
1477 addSequences(newSeqs);
1481 catch (Exception ex)
1482 {} // could be anything being pasted in here
1486 void addSequences(SequenceI[] seqs)
1488 for (int i = 0; i < seqs.length; i++)
1490 viewport.alignment.addSequence(seqs[i]);
1494 addHistoryItem(new EditCommand(
1499 viewport.alignment.getWidth(),
1503 viewport.setEndSeq(viewport.alignment.getHeight());
1504 viewport.alignment.getWidth();
1505 viewport.firePropertyChange("alignment", null,
1506 viewport.alignment.getSequences());
1510 protected void cut_actionPerformed()
1512 copy_actionPerformed();
1513 delete_actionPerformed();
1516 protected void delete_actionPerformed()
1519 SequenceGroup sg = viewport.getSelectionGroup();
1525 Vector seqs = new Vector();
1527 for (int i = 0; i < sg.getSize(); i++)
1529 seq = sg.getSequenceAt(i);
1530 seqs.addElement(seq);
1533 // If the cut affects all sequences, remove highlighted columns
1534 if (sg.getSize() == viewport.alignment.getHeight())
1536 viewport.getColumnSelection().removeElements(sg.getStartRes(),
1537 sg.getEndRes() + 1);
1540 SequenceI[] cut = new SequenceI[seqs.size()];
1541 for (int i = 0; i < seqs.size(); i++)
1543 cut[i] = (SequenceI) seqs.elementAt(i);
1549 addHistoryItem(new EditCommand("Cut Sequences",
1553 sg.getEndRes() - sg.getStartRes() + 1,
1554 viewport.alignment));
1556 viewport.setSelectionGroup(null);
1557 viewport.alignment.deleteGroup(sg);
1559 viewport.firePropertyChange("alignment", null,
1560 viewport.getAlignment().getSequences());
1562 if (viewport.getAlignment().getHeight() < 1)
1564 this.setVisible(false);
1568 protected void deleteGroups_actionPerformed()
1570 viewport.alignment.deleteAllGroups();
1571 viewport.sequenceColours = null;
1572 viewport.setSelectionGroup(null);
1574 alignPanel.paintAlignment(true);
1577 public void selectAllSequenceMenuItem_actionPerformed()
1579 SequenceGroup sg = new SequenceGroup();
1580 for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++)
1582 sg.addSequence(viewport.getAlignment().getSequenceAt(i), false);
1584 sg.setEndRes(viewport.alignment.getWidth() - 1);
1585 viewport.setSelectionGroup(sg);
1586 alignPanel.paintAlignment(true);
1587 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
1590 public void deselectAllSequenceMenuItem_actionPerformed()
1592 if (viewport.cursorMode)
1594 alignPanel.seqPanel.keyboardNo1 = null;
1595 alignPanel.seqPanel.keyboardNo2 = null;
1597 viewport.setSelectionGroup(null);
1598 viewport.getColumnSelection().clear();
1599 viewport.setSelectionGroup(null);
1600 alignPanel.idPanel.idCanvas.searchResults = null;
1601 alignPanel.seqPanel.seqCanvas.highlightSearchResults(null);
1602 alignPanel.paintAlignment(true);
1603 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
1606 public void invertSequenceMenuItem_actionPerformed()
1608 SequenceGroup sg = viewport.getSelectionGroup();
1609 for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++)
1611 sg.addOrRemove(viewport.getAlignment().getSequenceAt(i), false);
1614 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
1617 void trimAlignment(boolean trimLeft)
1619 ColumnSelection colSel = viewport.getColumnSelection();
1622 if (colSel.size() > 0)
1626 column = colSel.getMin();
1630 column = colSel.getMax();
1634 if (viewport.getSelectionGroup() != null)
1636 seqs = viewport.getSelectionGroup().getSequencesAsArray(viewport.
1637 hiddenRepSequences);
1641 seqs = viewport.alignment.getSequencesArray();
1644 TrimRegionCommand trimRegion;
1647 trimRegion = new TrimRegionCommand("Remove Left",
1648 TrimRegionCommand.TRIM_LEFT,
1653 viewport.selectionGroup);
1654 viewport.setStartRes(0);
1658 trimRegion = new TrimRegionCommand("Remove Right",
1659 TrimRegionCommand.TRIM_RIGHT,
1664 viewport.selectionGroup);
1667 statusBar.setText("Removed " + trimRegion.getSize() + " columns.");
1669 addHistoryItem(trimRegion);
1671 Vector groups = viewport.alignment.getGroups();
1673 for (int i = 0; i < groups.size(); i++)
1675 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
1677 if ( (trimLeft && !sg.adjustForRemoveLeft(column))
1678 || (!trimLeft && !sg.adjustForRemoveRight(column)))
1680 viewport.alignment.deleteGroup(sg);
1684 viewport.firePropertyChange("alignment", null,
1685 viewport.getAlignment().getSequences());
1689 public void removeGappedColumnMenuItem_actionPerformed()
1691 int start = 0, end = viewport.alignment.getWidth() - 1;
1694 if (viewport.getSelectionGroup() != null)
1696 seqs = viewport.getSelectionGroup().getSequencesAsArray(viewport.
1697 hiddenRepSequences);
1698 start = viewport.getSelectionGroup().getStartRes();
1699 end = viewport.getSelectionGroup().getEndRes();
1703 seqs = viewport.alignment.getSequencesArray();
1706 RemoveGapColCommand removeGapCols =
1707 new RemoveGapColCommand("Remove Gapped Columns",
1710 viewport.alignment);
1712 addHistoryItem(removeGapCols);
1714 statusBar.setText("Removed " + removeGapCols.getSize() + " empty columns.");
1716 //This is to maintain viewport position on first residue
1718 SequenceI seq = viewport.alignment.getSequenceAt(0);
1719 int startRes = seq.findPosition(viewport.startRes);
1720 // ShiftList shifts;
1721 // viewport.getAlignment().removeGaps(shifts=new ShiftList());
1722 // edit.alColumnChanges=shifts.getInverse();
1723 // if (viewport.hasHiddenColumns)
1724 // viewport.getColumnSelection().compensateForEdits(shifts);
1725 viewport.setStartRes(seq.findIndex(startRes) - 1);
1726 viewport.firePropertyChange("alignment", null,
1727 viewport.getAlignment().getSequences());
1731 public void removeAllGapsMenuItem_actionPerformed()
1733 int start = 0, end = viewport.alignment.getWidth() - 1;
1736 if (viewport.getSelectionGroup() != null)
1738 seqs = viewport.getSelectionGroup().getSequencesAsArray(viewport.
1739 hiddenRepSequences);
1740 start = viewport.getSelectionGroup().getStartRes();
1741 end = viewport.getSelectionGroup().getEndRes();
1745 seqs = viewport.alignment.getSequencesArray();
1748 //This is to maintain viewport position on first residue
1750 SequenceI seq = viewport.alignment.getSequenceAt(0);
1751 int startRes = seq.findPosition(viewport.startRes);
1753 addHistoryItem(new RemoveGapsCommand("Remove Gaps",
1756 viewport.alignment));
1758 viewport.setStartRes(seq.findIndex(startRes) - 1);
1760 viewport.firePropertyChange("alignment", null,
1761 viewport.getAlignment().getSequences());
1765 public void findMenuItem_actionPerformed()
1767 new Finder(alignPanel);
1770 public void newView()
1773 if (viewport.hasHiddenRows)
1775 newal = new Alignment(viewport.getAlignment().
1776 getHiddenSequences()
1777 .getFullAlignment().
1778 getSequencesArray());
1782 newal = new Alignment(viewport.alignment.getSequencesArray());
1785 if (viewport.alignment.getAlignmentAnnotation() != null)
1787 for (int i = 0; i < viewport.alignment.getAlignmentAnnotation().length; i++)
1789 if (!viewport.alignment.getAlignmentAnnotation()[i].autoCalculated)
1791 newal.addAnnotation(viewport.alignment.getAlignmentAnnotation()[i]);
1796 AlignFrame newaf = new AlignFrame(newal,
1801 newaf.viewport.sequenceSetID = alignPanel.av.getSequenceSetId();
1802 PaintRefresher.Register(alignPanel, alignPanel.av.getSequenceSetId());
1803 PaintRefresher.Register(newaf.alignPanel,
1804 newaf.alignPanel.av.getSequenceSetId());
1806 PaintRefresher.Register(newaf.alignPanel.idPanel.idCanvas,
1807 newaf.alignPanel.av.getSequenceSetId());
1808 PaintRefresher.Register(newaf.alignPanel.seqPanel.seqCanvas,
1809 newaf.alignPanel.av.getSequenceSetId());
1811 Vector comps = (Vector) PaintRefresher.components.get(viewport.
1812 getSequenceSetId());
1814 for (int i = 0; i < comps.size(); i++)
1816 if (comps.elementAt(i) instanceof AlignmentPanel)
1822 String title = new String(this.getTitle());
1823 if (title.indexOf("(View") > -1)
1825 title = title.substring(0, title.indexOf("(View"));
1828 title += "(View " + viewSize + ")";
1830 newaf.setTitle(title.toString());
1832 newaf.viewport.historyList = viewport.historyList;
1833 newaf.viewport.redoList = viewport.redoList;
1837 public void seqLimits_itemStateChanged()
1839 viewport.setShowJVSuffix(seqLimits.getState());
1840 alignPanel.fontChanged();
1841 alignPanel.paintAlignment(true);
1844 protected void colourTextMenuItem_actionPerformed()
1846 viewport.setColourText(colourTextMenuItem.getState());
1847 alignPanel.paintAlignment(true);
1850 protected void wrapMenuItem_actionPerformed()
1852 viewport.setWrapAlignment(wrapMenuItem.getState());
1853 alignPanel.setWrapAlignment(wrapMenuItem.getState());
1854 scaleAbove.setEnabled(wrapMenuItem.getState());
1855 scaleLeft.setEnabled(wrapMenuItem.getState());
1856 scaleRight.setEnabled(wrapMenuItem.getState());
1857 alignPanel.paintAlignment(true);
1860 public void overviewMenuItem_actionPerformed()
1862 if (alignPanel.overviewPanel != null)
1867 Frame frame = new Frame();
1868 OverviewPanel overview = new OverviewPanel(alignPanel);
1869 frame.add(overview);
1870 // +50 must allow for applet frame window
1871 jalview.bin.JalviewLite.addFrame(frame, "Overview " + this.getTitle(),
1872 overview.getPreferredSize().width,
1873 overview.getPreferredSize().height + 50);
1876 frame.addWindowListener(new WindowAdapter()
1878 public void windowClosing(WindowEvent e)
1880 alignPanel.setOverviewPanel(null);
1884 alignPanel.setOverviewPanel(overview);
1888 void changeColour(ColourSchemeI cs)
1894 if (viewport.getAbovePIDThreshold())
1896 threshold = SliderPanel.setPIDSliderSource(alignPanel, cs, "Background");
1898 cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus());
1900 viewport.setGlobalColourScheme(cs);
1904 cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
1907 if (viewport.getConservationSelected())
1910 Alignment al = (Alignment) viewport.alignment;
1911 Conservation c = new Conservation("All",
1912 ResidueProperties.propHash, 3,
1913 al.getSequences(), 0,
1917 c.verdict(false, viewport.ConsPercGaps);
1919 cs.setConservation(c);
1921 cs.setConservationInc(SliderPanel.setConservationSlider(alignPanel, cs,
1927 cs.setConservation(null);
1930 cs.setConsensus(viewport.hconsensus);
1933 viewport.setGlobalColourScheme(cs);
1935 if (viewport.getColourAppliesToAllGroups())
1937 Vector groups = viewport.alignment.getGroups();
1938 for (int i = 0; i < groups.size(); i++)
1940 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
1947 if (cs instanceof ClustalxColourScheme)
1949 sg.cs = new ClustalxColourScheme(
1950 sg.getSequences(viewport.hiddenRepSequences),
1957 sg.cs = (ColourSchemeI) cs.getClass().newInstance();
1959 catch (Exception ex)
1961 ex.printStackTrace();
1966 if (viewport.getAbovePIDThreshold()
1967 || cs instanceof PIDColourScheme
1968 || cs instanceof Blosum62ColourScheme)
1970 sg.cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus());
1971 sg.cs.setConsensus(AAFrequency.calculate(
1972 sg.getSequences(viewport.hiddenRepSequences), 0, sg.getWidth()));
1976 sg.cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
1979 if (viewport.getConservationSelected())
1981 Conservation c = new Conservation("Group",
1982 ResidueProperties.propHash, 3,
1983 sg.getSequences(viewport.
1984 hiddenRepSequences), 0,
1985 viewport.alignment.getWidth() - 1);
1987 c.verdict(false, viewport.ConsPercGaps);
1988 sg.cs.setConservation(c);
1992 sg.cs.setConservation(null);
1993 sg.cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
1999 if (alignPanel.getOverviewPanel() != null)
2001 alignPanel.getOverviewPanel().updateOverviewImage();
2004 jalview.structure.StructureSelectionManager.getStructureSelectionManager()
2005 .sequenceColoursChanged(alignPanel);
2007 alignPanel.paintAlignment(true);
2010 protected void modifyPID_actionPerformed()
2012 if (viewport.getAbovePIDThreshold() && viewport.globalColourScheme != null)
2014 SliderPanel.setPIDSliderSource(alignPanel, viewport.getGlobalColourScheme(),
2016 SliderPanel.showPIDSlider();
2020 protected void modifyConservation_actionPerformed()
2022 if (viewport.getConservationSelected() && viewport.globalColourScheme != null)
2024 SliderPanel.setConservationSlider(alignPanel, viewport.globalColourScheme,
2026 SliderPanel.showConservationSlider();
2030 protected void conservationMenuItem_actionPerformed()
2032 viewport.setConservationSelected(conservationMenuItem.getState());
2034 viewport.setAbovePIDThreshold(false);
2035 abovePIDThreshold.setState(false);
2037 changeColour(viewport.getGlobalColourScheme());
2039 modifyConservation_actionPerformed();
2042 public void abovePIDThreshold_actionPerformed()
2044 viewport.setAbovePIDThreshold(abovePIDThreshold.getState());
2046 conservationMenuItem.setState(false);
2047 viewport.setConservationSelected(false);
2049 changeColour(viewport.getGlobalColourScheme());
2051 modifyPID_actionPerformed();
2054 public void sortPairwiseMenuItem_actionPerformed()
2056 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
2057 AlignmentSorter.sortByPID(viewport.getAlignment(),
2058 viewport.getAlignment().getSequenceAt(0));
2059 addHistoryItem(new OrderCommand("Pairwise Sort", oldOrder,
2060 viewport.alignment));
2061 alignPanel.paintAlignment(true);
2064 public void sortIDMenuItem_actionPerformed()
2066 // addHistoryItem(new HistoryItem("ID Sort", viewport.alignment,
2067 // HistoryItem.SORT));
2068 AlignmentSorter.sortByID(viewport.getAlignment());
2069 alignPanel.paintAlignment(true);
2072 public void sortGroupMenuItem_actionPerformed()
2074 // addHistoryItem(new HistoryItem("Group Sort", viewport.alignment,
2075 // HistoryItem.SORT));
2076 AlignmentSorter.sortByGroup(viewport.getAlignment());
2077 alignPanel.paintAlignment(true);
2081 public void removeRedundancyMenuItem_actionPerformed()
2083 new RedundancyPanel(alignPanel);
2086 public void pairwiseAlignmentMenuItem_actionPerformed()
2088 if (viewport.getSelectionGroup() != null
2089 && viewport.getSelectionGroup().getSize() > 1)
2091 Frame frame = new Frame();
2092 frame.add(new PairwiseAlignPanel(alignPanel));
2093 jalview.bin.JalviewLite.addFrame(frame, "Pairwise Alignment", 600, 500);
2097 public void PCAMenuItem_actionPerformed()
2099 //are the sequences aligned?
2100 if (!viewport.alignment.isAligned())
2103 int Width = viewport.getAlignment().getWidth();
2105 for (int i = 0; i < viewport.getAlignment().getSequences().size();
2108 current = viewport.getAlignment().getSequenceAt(i);
2110 if (current.getLength() < Width)
2112 current.insertCharAt(Width - 1, viewport.getGapCharacter());
2115 alignPanel.paintAlignment(true);
2118 if ( (viewport.getSelectionGroup() != null &&
2119 viewport.getSelectionGroup().getSize() < 4 &&
2120 viewport.getSelectionGroup().getSize() > 0)
2121 || viewport.getAlignment().getHeight() < 4)
2128 new PCAPanel(viewport);
2130 catch (java.lang.OutOfMemoryError ex)
2136 public void averageDistanceTreeMenuItem_actionPerformed()
2138 NewTreePanel("AV", "PID", "Average distance tree using PID");
2141 public void neighbourTreeMenuItem_actionPerformed()
2143 NewTreePanel("NJ", "PID", "Neighbour joining tree using PID");
2146 protected void njTreeBlosumMenuItem_actionPerformed()
2148 NewTreePanel("NJ", "BL", "Neighbour joining tree using BLOSUM62");
2151 protected void avTreeBlosumMenuItem_actionPerformed()
2153 NewTreePanel("AV", "BL", "Average distance tree using BLOSUM62");
2156 void NewTreePanel(String type, String pwType, String title)
2158 //are the sequences aligned?
2159 if (!viewport.alignment.isAligned())
2162 int Width = viewport.getAlignment().getWidth();
2164 for (int i = 0; i < viewport.getAlignment().getSequences().size();
2167 current = viewport.getAlignment().getSequenceAt(i);
2169 if (current.getLength() < Width)
2171 current.insertCharAt(Width - 1, viewport.getGapCharacter());
2174 alignPanel.paintAlignment(true);
2178 if ( (viewport.getSelectionGroup() != null &&
2179 viewport.getSelectionGroup().getSize() > 1)
2180 || (viewport.getSelectionGroup() == null
2181 && viewport.alignment.getHeight() > 1))
2183 final TreePanel tp = new TreePanel(viewport,
2187 addTreeMenuItem(tp, title);
2189 jalview.bin.JalviewLite.addFrame(tp, title, 600, 500);
2193 void loadTree_actionPerformed()
2195 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
2196 cap.setText("Paste your Newick tree file here.");
2197 cap.setTreeImport();
2198 Frame frame = new Frame();
2200 jalview.bin.JalviewLite.addFrame(frame, "Paste Newick file ", 400, 300);
2203 public void loadTree(jalview.io.NewickFile tree, String treeFile)
2205 TreePanel tp = new TreePanel(viewport,
2209 jalview.bin.JalviewLite.addFrame(tp, treeFile, 600, 500);
2210 addTreeMenuItem(tp, treeFile);
2213 void addTreeMenuItem(final TreePanel treePanel, String title)
2215 final MenuItem item = new MenuItem(title);
2216 sortByTreeMenu.add(item);
2217 item.addActionListener(new java.awt.event.ActionListener()
2219 public void actionPerformed(ActionEvent evt)
2221 // addHistoryItem(new HistoryItem("Sort", viewport.alignment,
2222 // HistoryItem.SORT));
2223 AlignmentSorter.sortByTree(viewport.getAlignment(), treePanel.getTree());
2224 alignPanel.paintAlignment(true);
2228 treePanel.addWindowListener(new WindowAdapter()
2230 public void windowClosing(WindowEvent e)
2232 sortByTreeMenu.remove(item);
2237 protected void documentation_actionPerformed()
2239 showURL("http://www.jalview.org/help.html", "HELP");
2242 protected void about_actionPerformed()
2249 public AboutPanel(String version)
2251 this.version = version;
2254 public void paint(Graphics g)
2256 g.setColor(Color.white);
2257 g.fillRect(0, 0, getSize().width, getSize().height);
2258 g.setFont(new Font("Helvetica", Font.PLAIN, 12));
2259 FontMetrics fm = g.getFontMetrics();
2260 int fh = fm.getHeight();
2262 g.setColor(Color.black);
2263 g.setFont(new Font("Helvetica", Font.BOLD, 14));
2264 g.drawString("Jalview - Release " + version, 200, y += fh);
2265 g.setFont(new Font("Helvetica", Font.PLAIN, 12));
2266 g.drawString("Authors: Michele Clamp, James Cuff, Steve Searle, Andrew Waterhouse, Jim Procter & Geoff Barton.",
2268 g.drawString("Current development managed by Andrew Waterhouse; Barton Group, University of Dundee.",
2271 "For any issues relating to Jalview, email help@jalview.org", x,
2273 g.drawString("If you use JalView, please cite:", x, y += fh + 8);
2274 g.drawString("\"Clamp, M., Cuff, J., Searle, S. M. and Barton, G. J. (2004), The Jalview Java Alignment Editor\"",
2276 g.drawString("Bioinformatics, 2004 20;426-7.", x, y += fh);
2280 String version = "test";
2281 java.net.URL url = getClass().getResource("/.build_properties");
2286 BufferedReader reader = new BufferedReader(new InputStreamReader(
2289 while ( (line = reader.readLine()) != null)
2291 if (line.indexOf("VERSION") > -1)
2293 version = line.substring(line.indexOf("=") + 1);
2297 catch (Exception ex)
2299 ex.printStackTrace();
2303 Frame frame = new Frame();
2304 frame.add(new AboutPanel(version));
2305 jalview.bin.JalviewLite.addFrame(frame, "Jalview", 580, 200);
2309 public void showURL(String url, String target)
2311 if (viewport.applet == null)
2313 System.out.println("Not running as applet - no browser available.");
2319 System.out.println("Show url: " + url);
2320 viewport.applet.getAppletContext().showDocument(new java.net.URL(url),
2323 catch (Exception ex)
2325 ex.printStackTrace();
2330 //////////////////////////////////////////////////////////////////////////////////
2331 //JBuilder Graphics here
2333 MenuBar alignFrameMenuBar = new MenuBar();
2334 Menu fileMenu = new Menu("File");
2335 MenuItem loadApplication = new MenuItem("View in Full Application");
2336 MenuItem loadTree = new MenuItem("Load Associated Tree ...");
2337 MenuItem loadAnnotations = new MenuItem(
2338 "Load Features/Annotations ...");
2339 MenuItem outputFeatures = new MenuItem("Export Features ...");
2340 MenuItem outputAnnotations = new MenuItem("Export Annotations ...");
2342 MenuItem closeMenuItem = new MenuItem("Close");
2343 Menu editMenu = new Menu("Edit");
2344 Menu viewMenu = new Menu("View");
2345 Menu colourMenu = new Menu("Colour");
2346 Menu calculateMenu = new Menu("Calculate");
2347 MenuItem selectAllSequenceMenuItem = new MenuItem("Select all");
2348 MenuItem deselectAllSequenceMenuItem = new MenuItem("Deselect All");
2349 MenuItem invertSequenceMenuItem = new MenuItem("Invert Selection");
2350 MenuItem remove2LeftMenuItem = new MenuItem();
2351 MenuItem remove2RightMenuItem = new MenuItem();
2352 MenuItem removeGappedColumnMenuItem = new MenuItem();
2353 MenuItem removeAllGapsMenuItem = new MenuItem();
2354 CheckboxMenuItem viewBoxesMenuItem = new CheckboxMenuItem();
2355 CheckboxMenuItem viewTextMenuItem = new CheckboxMenuItem();
2356 MenuItem sortPairwiseMenuItem = new MenuItem();
2357 MenuItem sortIDMenuItem = new MenuItem();
2358 MenuItem sortGroupMenuItem = new MenuItem();
2359 MenuItem removeRedundancyMenuItem = new MenuItem();
2360 MenuItem pairwiseAlignmentMenuItem = new MenuItem();
2361 MenuItem PCAMenuItem = new MenuItem();
2362 MenuItem averageDistanceTreeMenuItem = new MenuItem();
2363 MenuItem neighbourTreeMenuItem = new MenuItem();
2364 BorderLayout borderLayout1 = new BorderLayout();
2365 public Label statusBar = new Label();
2366 Menu outputTextboxMenu = new Menu();
2367 MenuItem clustalColour = new MenuItem();
2368 MenuItem zappoColour = new MenuItem();
2369 MenuItem taylorColour = new MenuItem();
2370 MenuItem hydrophobicityColour = new MenuItem();
2371 MenuItem helixColour = new MenuItem();
2372 MenuItem strandColour = new MenuItem();
2373 MenuItem turnColour = new MenuItem();
2374 MenuItem buriedColour = new MenuItem();
2375 MenuItem userDefinedColour = new MenuItem();
2376 MenuItem PIDColour = new MenuItem();
2377 MenuItem BLOSUM62Colour = new MenuItem();
2378 MenuItem njTreeBlosumMenuItem = new MenuItem();
2379 MenuItem avDistanceTreeBlosumMenuItem = new MenuItem();
2380 CheckboxMenuItem annotationPanelMenuItem = new CheckboxMenuItem();
2381 CheckboxMenuItem colourTextMenuItem = new CheckboxMenuItem();
2382 MenuItem alProperties = new MenuItem("Alignment Properties...");
2383 MenuItem overviewMenuItem = new MenuItem();
2384 MenuItem undoMenuItem = new MenuItem();
2385 MenuItem redoMenuItem = new MenuItem();
2386 CheckboxMenuItem conservationMenuItem = new CheckboxMenuItem();
2387 MenuItem noColourmenuItem = new MenuItem();
2388 CheckboxMenuItem wrapMenuItem = new CheckboxMenuItem();
2389 CheckboxMenuItem renderGapsMenuItem = new CheckboxMenuItem();
2390 MenuItem findMenuItem = new MenuItem();
2391 CheckboxMenuItem abovePIDThreshold = new CheckboxMenuItem();
2392 MenuItem nucleotideColour = new MenuItem();
2393 MenuItem deleteGroups = new MenuItem();
2394 MenuItem delete = new MenuItem();
2395 MenuItem copy = new MenuItem();
2396 MenuItem cut = new MenuItem();
2397 Menu pasteMenu = new Menu();
2398 MenuItem pasteNew = new MenuItem();
2399 MenuItem pasteThis = new MenuItem();
2400 CheckboxMenuItem applyToAllGroups = new CheckboxMenuItem();
2401 MenuItem font = new MenuItem();
2402 CheckboxMenuItem scaleAbove = new CheckboxMenuItem();
2403 CheckboxMenuItem scaleLeft = new CheckboxMenuItem();
2404 CheckboxMenuItem scaleRight = new CheckboxMenuItem();
2405 MenuItem modifyPID = new MenuItem();
2406 MenuItem modifyConservation = new MenuItem();
2407 CheckboxMenuItem autoCalculate
2408 = new CheckboxMenuItem("Autocalculate Consensus", true);
2409 Menu sortByTreeMenu = new Menu();
2410 Menu sort = new Menu();
2411 Menu calculate = new Menu();
2412 MenuItem inputText = new MenuItem();
2413 Menu helpMenu = new Menu();
2414 MenuItem documentation = new MenuItem();
2415 MenuItem about = new MenuItem();
2416 CheckboxMenuItem seqLimits = new CheckboxMenuItem();
2419 Label embeddedSelect;
2421 Label embeddedFormat;
2422 Label embeddedColour;
2425 Label embeddedCalculate;
2426 FlowLayout flowLayout1;
2428 private void jbInit()
2432 setMenuBar(alignFrameMenuBar);
2436 // dynamically fill save as menu with available formats
2437 for (int i = 0; i < jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS.length;
2441 item = new MenuItem(jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS[i]);
2443 item.addActionListener(new java.awt.event.ActionListener()
2445 public void actionPerformed(ActionEvent e)
2447 outputText_actionPerformed(e);
2451 outputTextboxMenu.add(item);
2453 closeMenuItem.addActionListener(this);
2454 loadApplication.addActionListener(this);
2456 loadTree.addActionListener(this);
2457 loadAnnotations.addActionListener(this);
2458 outputFeatures.addActionListener(this);
2459 outputAnnotations.addActionListener(this);
2460 selectAllSequenceMenuItem.addActionListener(this);
2461 deselectAllSequenceMenuItem.addActionListener(this);
2462 invertSequenceMenuItem.addActionListener(this);
2463 remove2LeftMenuItem.setLabel("Remove Left");
2464 remove2LeftMenuItem.addActionListener(this);
2465 remove2RightMenuItem.setLabel("Remove Right");
2466 remove2RightMenuItem.addActionListener(this);
2467 removeGappedColumnMenuItem.setLabel("Remove Empty Columns");
2468 removeGappedColumnMenuItem.addActionListener(this);
2469 removeAllGapsMenuItem.setLabel("Remove All Gaps");
2470 removeAllGapsMenuItem.addActionListener(this);
2471 viewBoxesMenuItem.setLabel("Boxes");
2472 viewBoxesMenuItem.setState(true);
2473 viewBoxesMenuItem.addItemListener(this);
2474 viewTextMenuItem.setLabel("Text");
2475 viewTextMenuItem.setState(true);
2476 viewTextMenuItem.addItemListener(this);
2477 sortPairwiseMenuItem.setLabel("by Pairwise Identity");
2478 sortPairwiseMenuItem.addActionListener(this);
2479 sortIDMenuItem.setLabel("by ID");
2480 sortIDMenuItem.addActionListener(this);
2481 sortGroupMenuItem.setLabel("by Group");
2482 sortGroupMenuItem.addActionListener(this);
2483 removeRedundancyMenuItem.setLabel("Remove Redundancy...");
2484 removeRedundancyMenuItem.addActionListener(this);
2485 pairwiseAlignmentMenuItem.setLabel("Pairwise Alignments...");
2486 pairwiseAlignmentMenuItem.addActionListener(this);
2487 PCAMenuItem.setLabel("Principal Component Analysis");
2488 PCAMenuItem.addActionListener(this);
2489 averageDistanceTreeMenuItem.setLabel(
2490 "Average Distance Using % Identity");
2491 averageDistanceTreeMenuItem.addActionListener(this);
2492 neighbourTreeMenuItem.setLabel("Neighbour Joining Using % Identity");
2493 neighbourTreeMenuItem.addActionListener(this);
2494 statusBar.setBackground(Color.white);
2495 statusBar.setFont(new java.awt.Font("Verdana", 0, 11));
2496 statusBar.setText("Status bar");
2497 outputTextboxMenu.setLabel("Output to Textbox");
2498 clustalColour.setLabel("Clustalx");
2500 clustalColour.addActionListener(this);
2501 zappoColour.setLabel("Zappo");
2502 zappoColour.addActionListener(this);
2503 taylorColour.setLabel("Taylor");
2504 taylorColour.addActionListener(this);
2505 hydrophobicityColour.setLabel("Hydrophobicity");
2506 hydrophobicityColour.addActionListener(this);
2507 helixColour.setLabel("Helix Propensity");
2508 helixColour.addActionListener(this);
2509 strandColour.setLabel("Strand Propensity");
2510 strandColour.addActionListener(this);
2511 turnColour.setLabel("Turn Propensity");
2512 turnColour.addActionListener(this);
2513 buriedColour.setLabel("Buried Index");
2514 buriedColour.addActionListener(this);
2515 userDefinedColour.setLabel("User Defined...");
2516 userDefinedColour.addActionListener(this);
2517 PIDColour.setLabel("Percentage Identity");
2518 PIDColour.addActionListener(this);
2519 BLOSUM62Colour.setLabel("BLOSUM62 Score");
2520 BLOSUM62Colour.addActionListener(this);
2521 avDistanceTreeBlosumMenuItem.setLabel(
2522 "Average Distance Using BLOSUM62");
2523 avDistanceTreeBlosumMenuItem.addActionListener(this);
2524 njTreeBlosumMenuItem.setLabel("Neighbour Joining Using BLOSUM62");
2525 njTreeBlosumMenuItem.addActionListener(this);
2526 annotationPanelMenuItem.setLabel("Show Annotations");
2527 annotationPanelMenuItem.addItemListener(this);
2528 colourTextMenuItem.setLabel("Colour Text");
2529 colourTextMenuItem.addItemListener(this);
2530 alProperties.addActionListener(this);
2531 overviewMenuItem.setLabel("Overview Window");
2532 overviewMenuItem.addActionListener(this);
2533 undoMenuItem.setEnabled(false);
2534 undoMenuItem.setLabel("Undo");
2535 undoMenuItem.addActionListener(this);
2536 redoMenuItem.setEnabled(false);
2537 redoMenuItem.setLabel("Redo");
2538 redoMenuItem.addActionListener(this);
2539 conservationMenuItem.setLabel("by Conservation");
2540 conservationMenuItem.addItemListener(this);
2541 noColourmenuItem.setLabel("None");
2542 noColourmenuItem.addActionListener(this);
2543 wrapMenuItem.setLabel("Wrap");
2544 wrapMenuItem.addItemListener(this);
2545 renderGapsMenuItem.setLabel("Show Gaps");
2546 renderGapsMenuItem.setState(true);
2547 renderGapsMenuItem.addItemListener(this);
2548 findMenuItem.setLabel("Find...");
2549 findMenuItem.addActionListener(this);
2550 abovePIDThreshold.setLabel("Above Identity Threshold");
2551 abovePIDThreshold.addItemListener(this);
2552 nucleotideColour.setLabel("Nucleotide");
2553 nucleotideColour.addActionListener(this);
2554 deleteGroups.setLabel("Undefine Groups");
2555 deleteGroups.addActionListener(this);
2556 copy.setLabel("Copy");
2557 copy.addActionListener(this);
2558 cut.setLabel("Cut");
2559 cut.addActionListener(this);
2560 delete.setLabel("Delete");
2561 delete.addActionListener(this);
2562 pasteMenu.setLabel("Paste");
2563 pasteNew.setLabel("To New Alignment");
2564 pasteNew.addActionListener(this);
2565 pasteThis.setLabel("Add To This Alignment");
2566 pasteThis.addActionListener(this);
2567 applyToAllGroups.setLabel("Apply Colour To All Groups");
2568 applyToAllGroups.setState(true);
2569 applyToAllGroups.addItemListener(this);
2570 font.setLabel("Font...");
2571 font.addActionListener(this);
2572 scaleAbove.setLabel("Scale Above");
2573 scaleAbove.setState(true);
2574 scaleAbove.setEnabled(false);
2575 scaleAbove.addItemListener(this);
2576 scaleLeft.setEnabled(false);
2577 scaleLeft.setState(true);
2578 scaleLeft.setLabel("Scale Left");
2579 scaleLeft.addItemListener(this);
2580 scaleRight.setEnabled(false);
2581 scaleRight.setState(true);
2582 scaleRight.setLabel("Scale Right");
2583 scaleRight.addItemListener(this);
2584 modifyPID.setLabel("Modify Identity Threshold...");
2585 modifyPID.addActionListener(this);
2586 modifyConservation.setLabel("Modify Conservation Threshold...");
2587 modifyConservation.addActionListener(this);
2588 sortByTreeMenu.setLabel("By Tree Order");
2589 sort.setLabel("Sort");
2590 calculate.setLabel("Calculate Tree");
2591 autoCalculate.addItemListener(this);
2592 inputText.setLabel("Input from textbox");
2593 inputText.addActionListener(this);
2595 helpMenu.setLabel("Help");
2596 documentation.setLabel("Documentation");
2597 documentation.addActionListener(this);
2599 about.setLabel("About...");
2600 about.addActionListener(this);
2601 seqLimits.setState(true);
2602 seqLimits.setLabel("Show Sequence Limits");
2603 seqLimits.addItemListener(this);
2604 featureSettings.setLabel("Feature Settings...");
2605 featureSettings.addActionListener(this);
2606 sequenceFeatures.setLabel("Sequence Features");
2607 sequenceFeatures.addItemListener(this);
2608 sequenceFeatures.setState(false);
2609 annotationColour.setLabel("by Annotation...");
2610 annotationColour.addActionListener(this);
2611 invertSequenceMenuItem.setLabel("Invert Sequence Selection");
2612 invertColSel.setLabel("Invert Column Selection");
2613 menu1.setLabel("Show");
2614 showColumns.setLabel("All Columns ");
2615 showSeqs.setLabel("All Sequences");
2616 menu2.setLabel("Hide");
2617 hideColumns.setLabel("Selected Columns");
2618 hideSequences.setLabel("Selected Sequences");
2619 invertColSel.addActionListener(this);
2620 showColumns.addActionListener(this);
2621 showSeqs.addActionListener(this);
2622 hideColumns.addActionListener(this);
2623 hideSequences.addActionListener(this);
2624 formatMenu.setLabel("Format");
2625 selectMenu.setLabel("Select");
2626 newView.setLabel("New View");
2627 newView.addActionListener(this);
2628 alignFrameMenuBar.add(fileMenu);
2629 alignFrameMenuBar.add(editMenu);
2630 alignFrameMenuBar.add(selectMenu);
2631 alignFrameMenuBar.add(viewMenu);
2632 alignFrameMenuBar.add(formatMenu);
2633 alignFrameMenuBar.add(colourMenu);
2634 alignFrameMenuBar.add(calculateMenu);
2635 alignFrameMenuBar.add(helpMenu);
2637 fileMenu.add(inputText);
2638 fileMenu.add(loadTree);
2639 fileMenu.add(loadAnnotations);
2641 fileMenu.addSeparator();
2642 fileMenu.add(outputTextboxMenu);
2643 fileMenu.add(outputFeatures);
2644 fileMenu.add(outputAnnotations);
2646 if (jalviewServletURL != null)
2648 fileMenu.add(loadApplication);
2651 fileMenu.addSeparator();
2652 fileMenu.add(closeMenuItem);
2654 editMenu.add(undoMenuItem);
2655 editMenu.add(redoMenuItem);
2658 editMenu.add(pasteMenu);
2659 editMenu.add(delete);
2660 editMenu.addSeparator();
2661 editMenu.add(remove2LeftMenuItem);
2662 editMenu.add(remove2RightMenuItem);
2663 editMenu.add(removeGappedColumnMenuItem);
2664 editMenu.add(removeAllGapsMenuItem);
2665 editMenu.add(removeRedundancyMenuItem);
2666 viewMenu.add(newView);
2667 viewMenu.addSeparator();
2668 viewMenu.add(menu1);
2669 viewMenu.add(menu2);
2670 viewMenu.addSeparator();
2671 viewMenu.add(annotationPanelMenuItem);
2672 viewMenu.addSeparator();
2673 viewMenu.add(sequenceFeatures);
2674 viewMenu.add(featureSettings);
2675 viewMenu.addSeparator();
2676 viewMenu.add(alProperties);
2677 viewMenu.addSeparator();
2678 viewMenu.add(overviewMenuItem);
2679 colourMenu.add(applyToAllGroups);
2680 colourMenu.addSeparator();
2681 colourMenu.add(noColourmenuItem);
2682 colourMenu.add(clustalColour);
2683 colourMenu.add(BLOSUM62Colour);
2684 colourMenu.add(PIDColour);
2685 colourMenu.add(zappoColour);
2686 colourMenu.add(taylorColour);
2687 colourMenu.add(hydrophobicityColour);
2688 colourMenu.add(helixColour);
2689 colourMenu.add(strandColour);
2690 colourMenu.add(turnColour);
2691 colourMenu.add(buriedColour);
2692 colourMenu.add(nucleotideColour);
2693 colourMenu.add(userDefinedColour);
2694 colourMenu.addSeparator();
2695 colourMenu.add(conservationMenuItem);
2696 colourMenu.add(modifyConservation);
2697 colourMenu.add(abovePIDThreshold);
2698 colourMenu.add(modifyPID);
2699 colourMenu.add(annotationColour);
2700 calculateMenu.add(sort);
2701 calculateMenu.add(calculate);
2702 calculateMenu.addSeparator();
2703 calculateMenu.add(pairwiseAlignmentMenuItem);
2704 calculateMenu.add(PCAMenuItem);
2705 calculateMenu.add(autoCalculate);
2706 this.add(statusBar, BorderLayout.SOUTH);
2707 pasteMenu.add(pasteNew);
2708 pasteMenu.add(pasteThis);
2709 sort.add(sortIDMenuItem);
2710 sort.add(sortByTreeMenu);
2711 sort.add(sortGroupMenuItem);
2712 sort.add(sortPairwiseMenuItem);
2713 calculate.add(averageDistanceTreeMenuItem);
2714 calculate.add(neighbourTreeMenuItem);
2715 calculate.add(avDistanceTreeBlosumMenuItem);
2716 calculate.add(njTreeBlosumMenuItem);
2717 helpMenu.add(documentation);
2718 helpMenu.add(about);
2719 menu1.add(showColumns);
2720 menu1.add(showSeqs);
2721 menu2.add(hideColumns);
2722 menu2.add(hideSequences);
2723 formatMenu.add(font);
2724 formatMenu.add(seqLimits);
2725 formatMenu.add(wrapMenuItem);
2726 formatMenu.add(scaleAbove);
2727 formatMenu.add(scaleLeft);
2728 formatMenu.add(scaleRight);
2729 formatMenu.add(viewBoxesMenuItem);
2730 formatMenu.add(viewTextMenuItem);
2731 formatMenu.add(colourTextMenuItem);
2732 formatMenu.add(renderGapsMenuItem);
2733 selectMenu.add(findMenuItem);
2734 selectMenu.addSeparator();
2735 selectMenu.add(selectAllSequenceMenuItem);
2736 selectMenu.add(deselectAllSequenceMenuItem);
2737 selectMenu.add(invertSequenceMenuItem);
2738 selectMenu.add(invertColSel);
2739 selectMenu.add(deleteGroups);
2742 public void setEmbedded()
2745 embeddedMenu = new Panel();
2746 embeddedEdit = new Label("Edit");
2747 embeddedSelect = new Label("Select");
2748 embeddedView = new Label("View");
2749 embeddedFormat = new Label("Format");
2750 embeddedColour = new Label("Colour");
2751 embeddedFile = new Label("File");
2752 embeddedHelp = new Label("Help");
2753 embeddedCalculate = new Label("Calculate");
2754 flowLayout1 = new FlowLayout();
2755 embeddedMenu.setBackground(Color.lightGray);
2756 embeddedMenu.setLayout(flowLayout1);
2757 embeddedEdit.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
2758 embeddedSelect.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
2759 embeddedView.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
2760 embeddedFormat.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
2761 embeddedColour.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
2762 embeddedFile.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
2763 embeddedHelp.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
2764 embeddedCalculate.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
2765 embeddedMenu.add(embeddedFile);
2766 embeddedMenu.add(embeddedEdit);
2767 embeddedMenu.add(embeddedSelect);
2768 embeddedMenu.add(embeddedView);
2769 embeddedMenu.add(embeddedFormat);
2770 embeddedMenu.add(embeddedColour);
2771 embeddedMenu.add(embeddedCalculate);
2772 embeddedMenu.add(embeddedHelp);
2773 flowLayout1.setAlignment(FlowLayout.LEFT);
2774 flowLayout1.setHgap(2);
2775 flowLayout1.setVgap(0);
2776 embeddedFile.addMouseListener(this);
2777 embeddedEdit.addMouseListener(this);
2778 embeddedSelect.addMouseListener(this);
2779 embeddedView.addMouseListener(this);
2780 embeddedFormat.addMouseListener(this);
2781 embeddedColour.addMouseListener(this);
2782 embeddedCalculate.addMouseListener(this);
2783 embeddedHelp.addMouseListener(this);
2785 fileMenu.remove(closeMenuItem);
2786 fileMenu.remove(3); // Seperator
2788 viewport.applet.setLayout(new BorderLayout());
2789 viewport.applet.add(embeddedMenu, BorderLayout.NORTH);
2790 viewport.applet.add(statusBar, BorderLayout.SOUTH);
2792 alignPanel.setSize(viewport.applet.getSize().width,
2793 viewport.applet.getSize().height
2794 - embeddedMenu.HEIGHT - statusBar.HEIGHT);
2796 viewport.applet.add(alignPanel, BorderLayout.CENTER);
2797 viewport.applet.validate();
2801 PopupMenu filePopup, editPopup, searchPopup,
2802 viewPopup, formatPopup, colourPopup, calculatePopup, helpPopup;
2803 MenuItem featureSettings = new MenuItem();
2804 CheckboxMenuItem sequenceFeatures = new CheckboxMenuItem();
2805 MenuItem annotationColour = new MenuItem();
2806 MenuItem invertColSel = new MenuItem();
2807 Menu menu1 = new Menu();
2808 MenuItem showColumns = new MenuItem();
2809 MenuItem showSeqs = new MenuItem();
2810 Menu menu2 = new Menu();
2811 MenuItem hideColumns = new MenuItem();
2812 MenuItem hideSequences = new MenuItem();
2813 Menu formatMenu = new Menu();
2814 Menu selectMenu = new Menu();
2815 MenuItem newView = new MenuItem();
2817 public void mousePressed(MouseEvent evt)
2819 PopupMenu popup = null;
2820 Label source = (Label) evt.getSource();
2821 if (source == embeddedFile)
2823 popup = filePopup = genPopupMenu(filePopup, fileMenu);
2825 else if (source == embeddedEdit)
2827 popup = editPopup = genPopupMenu(editPopup, editMenu);
2829 else if (source == embeddedSelect)
2831 popup = searchPopup = genPopupMenu(searchPopup, selectMenu);
2833 else if (source == embeddedView)
2835 popup = viewPopup = genPopupMenu(viewPopup, viewMenu);
2837 else if (source == embeddedFormat)
2839 popup = formatPopup = genPopupMenu(formatPopup, formatMenu);
2841 else if (source == embeddedColour)
2843 popup = colourPopup = genPopupMenu(colourPopup, colourMenu);
2845 else if (source == embeddedCalculate)
2847 popup = calculatePopup = genPopupMenu(calculatePopup, calculateMenu);
2849 else if (source == embeddedHelp)
2851 popup = helpPopup = genPopupMenu(helpPopup, helpMenu);
2854 embeddedMenu.add(popup);
2855 popup.show(embeddedMenu,
2856 source.getBounds().x,
2857 source.getBounds().y + source.getBounds().getSize().height);
2860 PopupMenu genPopupMenu(PopupMenu popup, Menu original)
2866 popup = new PopupMenu();
2867 int m, mSize = original.getItemCount();
2868 for (m = 0; m < mSize; m++)
2870 popup.add(original.getItem(m));
2878 public void mouseClicked(MouseEvent evt)
2881 public void mouseReleased(MouseEvent evt)
2884 public void mouseEntered(MouseEvent evt)
2887 public void mouseExited(MouseEvent evt)