2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
20 package jalview.appletgui;
\r
27 import java.awt.event.*;
\r
29 import jalview.analysis.*;
\r
30 import jalview.commands.*;
\r
31 import jalview.datamodel.*;
\r
32 import jalview.io.*;
\r
33 import jalview.schemes.*;
\r
35 public class AlignFrame
\r
36 extends Frame implements ActionListener,
\r
37 ItemListener, KeyListener, MouseListener
\r
39 public AlignmentPanel alignPanel;
\r
40 public AlignViewport viewport;
\r
41 int DEFAULT_WIDTH = 700;
\r
42 int DEFAULT_HEIGHT = 500;
\r
44 String jalviewServletURL;
\r
46 public AlignFrame(AlignmentI al,
\r
47 jalview.bin.JalviewLite applet,
\r
54 jalviewServletURL = applet.getParameter("APPLICATION_URL");
\r
61 catch (Exception ex)
\r
63 ex.printStackTrace();
\r
66 viewport = new AlignViewport(al, applet);
\r
67 alignPanel = new AlignmentPanel(this, viewport);
\r
69 viewport.updateConservation(alignPanel);
\r
70 viewport.updateConsensus(alignPanel);
\r
72 annotationPanelMenuItem.setState(viewport.showAnnotation);
\r
74 seqLimits.setState(viewport.showJVSuffix);
\r
78 String param = applet.getParameter("sortBy");
\r
81 if (param.equalsIgnoreCase("Id"))
\r
83 sortIDMenuItem_actionPerformed();
\r
85 else if (param.equalsIgnoreCase("Pairwise Identity"))
\r
87 sortPairwiseMenuItem_actionPerformed();
\r
91 param = applet.getParameter("wrap");
\r
94 if (param.equalsIgnoreCase("true"))
\r
96 wrapMenuItem.setState(true);
\r
97 wrapMenuItem_actionPerformed();
\r
103 param = applet.getParameter("windowWidth");
\r
106 int width = Integer.parseInt(param);
\r
107 DEFAULT_WIDTH = width;
\r
109 param = applet.getParameter("windowHeight");
\r
112 int height = Integer.parseInt(param);
\r
113 DEFAULT_HEIGHT = height;
\r
116 catch (Exception ex)
\r
121 //Some JVMS send keyevents to Top frame or lowest panel,
\r
122 //Havent worked out why yet. So add to both this frame and seqCanvas for now
\r
123 this.addKeyListener(this);
\r
124 alignPanel.seqPanel.seqCanvas.addKeyListener(this);
\r
125 alignPanel.idPanel.idCanvas.addKeyListener(this);
\r
126 alignPanel.scalePanel.addKeyListener(this);
\r
127 alignPanel.annotationPanel.addKeyListener(this);
\r
135 add(alignPanel, BorderLayout.CENTER);
\r
136 jalview.bin.JalviewLite.addFrame(this, title, DEFAULT_WIDTH,
\r
139 alignPanel.validate();
\r
140 alignPanel.paintAlignment(true);
\r
143 public AlignViewport getAlignViewport()
\r
148 public SeqCanvas getSeqcanvas()
\r
150 return alignPanel.seqPanel.seqCanvas;
\r
156 * @param String DOCUMENT ME!
\r
159 public void parseFeaturesFile(String file, String type)
\r
161 Hashtable featureLinks = new Hashtable();
\r
162 boolean featuresFile = false;
\r
165 featuresFile = new jalview.io.FeaturesFile(file,
\r
166 type).parse(viewport.alignment,
\r
167 alignPanel.seqPanel.seqCanvas.
\r
168 getFeatureRenderer().featureColours,
\r
172 catch (Exception ex)
\r
174 ex.printStackTrace();
\r
179 if (featureLinks.size() > 0)
\r
181 alignPanel.seqPanel.seqCanvas
\r
182 .getFeatureRenderer().featureLinks = featureLinks;
\r
184 viewport.showSequenceFeatures = true;
\r
185 sequenceFeatures.setState(true);
\r
186 alignPanel.paintAlignment(true);
\r
191 public void keyPressed(KeyEvent evt)
\r
193 if (viewport.cursorMode
\r
194 && evt.getKeyCode() >= KeyEvent.VK_0
\r
195 && evt.getKeyCode() <= KeyEvent.VK_9)
\r
197 alignPanel.seqPanel.numberPressed(evt.getKeyChar());
\r
200 switch (evt.getKeyCode())
\r
202 case 27: // escape key
\r
203 deselectAllSequenceMenuItem_actionPerformed();
\r
205 case KeyEvent.VK_X:
\r
206 if (evt.isControlDown() || evt.isMetaDown())
\r
208 cut_actionPerformed();
\r
211 case KeyEvent.VK_C:
\r
212 if (viewport.cursorMode && !evt.isControlDown())
\r
214 alignPanel.seqPanel.setCursorColumn();
\r
216 if (evt.isControlDown() || evt.isMetaDown())
\r
218 copy_actionPerformed();
\r
221 case KeyEvent.VK_V:
\r
222 if (evt.isControlDown())
\r
224 paste(evt.isShiftDown());
\r
227 case KeyEvent.VK_A:
\r
228 if (evt.isControlDown() || evt.isMetaDown())
\r
230 selectAllSequenceMenuItem_actionPerformed();
\r
233 case KeyEvent.VK_DOWN:
\r
234 if (viewport.cursorMode)
\r
236 alignPanel.seqPanel.moveCursor(0, 1);
\r
240 moveSelectedSequences(false);
\r
244 case KeyEvent.VK_UP:
\r
245 if (viewport.cursorMode)
\r
247 alignPanel.seqPanel.moveCursor(0, -1);
\r
251 moveSelectedSequences(true);
\r
255 case KeyEvent.VK_LEFT:
\r
256 if (evt.isAltDown() || !viewport.cursorMode)
\r
257 slideSequences(false,
\r
258 alignPanel.seqPanel.getKeyboardNo1());
\r
260 alignPanel.seqPanel.moveCursor( -1, 0);
\r
263 case KeyEvent.VK_RIGHT:
\r
264 if (evt.isAltDown() || !viewport.cursorMode)
\r
265 slideSequences(true,
\r
266 alignPanel.seqPanel.getKeyboardNo1());
\r
268 alignPanel.seqPanel.moveCursor( 1, 0);
\r
271 case KeyEvent.VK_SPACE:
\r
272 if (viewport.cursorMode)
\r
274 alignPanel.seqPanel.insertGapAtCursor(evt.isControlDown()
\r
275 || evt.isShiftDown()
\r
281 case KeyEvent.VK_DELETE:
\r
282 case KeyEvent.VK_BACK_SPACE:
\r
283 if (viewport.cursorMode)
\r
285 alignPanel.seqPanel.deleteGapAtCursor(evt.isControlDown()
\r
286 || evt.isShiftDown()
\r
287 || evt.isAltDown());
\r
291 cut_actionPerformed();
\r
292 alignPanel.seqPanel.seqCanvas.repaint();
\r
296 case KeyEvent.VK_S:
\r
297 if (viewport.cursorMode)
\r
299 alignPanel.seqPanel.setCursorRow();
\r
302 case KeyEvent.VK_P:
\r
303 if (viewport.cursorMode)
\r
305 alignPanel.seqPanel.setCursorPosition();
\r
309 case KeyEvent.VK_ENTER:
\r
310 case KeyEvent.VK_COMMA:
\r
311 if (viewport.cursorMode)
\r
313 alignPanel.seqPanel.setCursorRowAndColumn();
\r
317 case KeyEvent.VK_Q:
\r
318 if (viewport.cursorMode)
\r
320 alignPanel.seqPanel.setSelectionAreaAtCursor(true);
\r
323 case KeyEvent.VK_M:
\r
324 if (viewport.cursorMode)
\r
326 alignPanel.seqPanel.setSelectionAreaAtCursor(false);
\r
330 case KeyEvent.VK_F2:
\r
331 viewport.cursorMode = !viewport.cursorMode;
\r
332 statusBar.setText("Keyboard editing mode is " +
\r
333 (viewport.cursorMode ? "on" : "off"));
\r
334 if (viewport.cursorMode)
\r
336 alignPanel.seqPanel.seqCanvas.cursorX = viewport.startRes;
\r
337 alignPanel.seqPanel.seqCanvas.cursorY = viewport.startSeq;
\r
341 case KeyEvent.VK_F:
\r
342 if (evt.isControlDown())
\r
344 findMenuItem_actionPerformed();
\r
348 case KeyEvent.VK_H:
\r
350 boolean toggleSeqs = !evt.isControlDown();
\r
351 boolean toggleCols = !evt.isShiftDown();
\r
352 boolean hide = false;
\r
353 SequenceGroup sg = viewport.getSelectionGroup();
\r
357 if (sg != null && sg.getSize() != viewport.alignment.getHeight())
\r
360 viewport.hideAllSelectedSeqs();
\r
362 else if (! (toggleCols && viewport.colSel.getSelected().size() > 0))
\r
364 viewport.showAllHiddenSeqs();
\r
370 if (viewport.colSel.getSelected().size() > 0)
\r
372 viewport.hideSelectedColumns();
\r
375 viewport.selectionGroup = sg;
\r
380 viewport.showAllHiddenColumns();
\r
386 case KeyEvent.VK_PAGE_UP:
\r
387 if (viewport.wrapAlignment)
\r
389 alignPanel.scrollUp(true);
\r
393 alignPanel.setScrollValues(viewport.startRes,
\r
395 - viewport.endSeq + viewport.startSeq);
\r
399 case KeyEvent.VK_PAGE_DOWN:
\r
400 if (viewport.wrapAlignment)
\r
402 alignPanel.scrollUp(false);
\r
406 alignPanel.setScrollValues(viewport.startRes,
\r
408 + viewport.endSeq - viewport.startSeq);
\r
412 case KeyEvent.VK_Z:
\r
413 if (evt.isControlDown())
\r
415 undoMenuItem_actionPerformed();
\r
419 case KeyEvent.VK_Y:
\r
420 if (evt.isControlDown())
\r
422 redoMenuItem_actionPerformed();
\r
426 case KeyEvent.VK_L:
\r
427 if (evt.isControlDown())
\r
429 trimAlignment(true);
\r
433 case KeyEvent.VK_R:
\r
434 if (evt.isControlDown())
\r
436 trimAlignment(false);
\r
440 case KeyEvent.VK_E:
\r
441 if (evt.isControlDown())
\r
443 if (evt.isShiftDown())
\r
445 this.removeAllGapsMenuItem_actionPerformed();
\r
449 removeGappedColumnMenuItem_actionPerformed();
\r
453 case KeyEvent.VK_I:
\r
454 if (evt.isControlDown())
\r
456 if (evt.isAltDown())
\r
458 viewport.invertColumnSelection();
\r
462 this.invertSequenceMenuItem_actionPerformed();
\r
467 case KeyEvent.VK_U:
\r
468 if (evt.isControlDown())
\r
470 this.deleteGroups_actionPerformed();
\r
474 case KeyEvent.VK_T:
\r
475 if (evt.isControlDown())
\r
482 alignPanel.paintAlignment(true);
\r
485 public void keyReleased(KeyEvent evt)
\r
488 public void keyTyped(KeyEvent evt)
\r
491 public void itemStateChanged(ItemEvent evt)
\r
493 if (evt.getSource() == colourTextMenuItem)
\r
495 colourTextMenuItem_actionPerformed();
\r
497 else if (evt.getSource() == wrapMenuItem)
\r
499 wrapMenuItem_actionPerformed();
\r
501 else if (evt.getSource() == scaleAbove)
\r
503 viewport.setScaleAboveWrapped(scaleAbove.getState());
\r
505 else if (evt.getSource() == scaleLeft)
\r
507 viewport.setScaleLeftWrapped(scaleLeft.getState());
\r
509 else if (evt.getSource() == scaleRight)
\r
511 viewport.setScaleRightWrapped(scaleRight.getState());
\r
513 else if (evt.getSource() == seqLimits)
\r
515 seqLimits_itemStateChanged();
\r
517 else if (evt.getSource() == viewBoxesMenuItem)
\r
519 viewport.setShowBoxes(viewBoxesMenuItem.getState());
\r
521 else if (evt.getSource() == viewTextMenuItem)
\r
523 viewport.setShowText(viewTextMenuItem.getState());
\r
525 else if (evt.getSource() == renderGapsMenuItem)
\r
527 viewport.setRenderGaps(renderGapsMenuItem.getState());
\r
529 else if (evt.getSource() == annotationPanelMenuItem)
\r
531 viewport.setShowAnnotation(annotationPanelMenuItem.getState());
\r
532 alignPanel.setAnnotationVisible(annotationPanelMenuItem.getState());
\r
534 else if (evt.getSource() == sequenceFeatures)
\r
536 viewport.showSequenceFeatures(sequenceFeatures.getState());
\r
537 alignPanel.seqPanel.seqCanvas.repaint();
\r
539 else if (evt.getSource() == conservationMenuItem)
\r
541 conservationMenuItem_actionPerformed();
\r
543 else if (evt.getSource() == abovePIDThreshold)
\r
545 abovePIDThreshold_actionPerformed();
\r
547 else if (evt.getSource() == applyToAllGroups)
\r
549 viewport.setColourAppliesToAllGroups(applyToAllGroups.getState());
\r
551 else if (evt.getSource() == autoCalculate)
\r
553 viewport.autocalculateConsensus = autoCalculate.getState();
\r
556 alignPanel.paintAlignment(true);
\r
559 public void actionPerformed(ActionEvent evt)
\r
561 Object source = evt.getSource();
\r
563 if (source == inputText)
\r
565 inputText_actionPerformed();
\r
567 else if (source == loadTree)
\r
569 loadTree_actionPerformed();
\r
571 else if (source == loadApplication)
\r
573 launchFullApplication();
\r
575 else if (source == loadAnnotations)
\r
579 else if (source == outputAnnotations)
\r
581 outputAnnotations(true);
\r
583 else if (source == outputFeatures)
\r
585 outputFeatures(true, "Jalview");
\r
587 else if (source == closeMenuItem)
\r
589 closeMenuItem_actionPerformed();
\r
591 else if (source == copy)
\r
593 copy_actionPerformed();
\r
595 else if (source == undoMenuItem)
\r
597 undoMenuItem_actionPerformed();
\r
599 else if (source == redoMenuItem)
\r
601 redoMenuItem_actionPerformed();
\r
603 else if (source == inputText)
\r
605 inputText_actionPerformed();
\r
607 else if (source == closeMenuItem)
\r
609 closeMenuItem_actionPerformed();
\r
611 else if (source == undoMenuItem)
\r
613 undoMenuItem_actionPerformed();
\r
615 else if (source == redoMenuItem)
\r
617 redoMenuItem_actionPerformed();
\r
619 else if (source == copy)
\r
621 copy_actionPerformed();
\r
623 else if (source == pasteNew)
\r
625 pasteNew_actionPerformed();
\r
627 else if (source == pasteThis)
\r
629 pasteThis_actionPerformed();
\r
631 else if (source == cut)
\r
633 cut_actionPerformed();
\r
635 else if (source == delete)
\r
637 delete_actionPerformed();
\r
639 else if (source == deleteGroups)
\r
641 deleteGroups_actionPerformed();
\r
643 else if (source == selectAllSequenceMenuItem)
\r
645 selectAllSequenceMenuItem_actionPerformed();
\r
647 else if (source == deselectAllSequenceMenuItem)
\r
649 deselectAllSequenceMenuItem_actionPerformed();
\r
651 else if (source == invertSequenceMenuItem)
\r
653 invertSequenceMenuItem_actionPerformed();
\r
655 else if (source == invertColSel)
\r
657 viewport.invertColumnSelection();
\r
658 alignPanel.paintAlignment(true);
\r
660 else if (source == remove2LeftMenuItem)
\r
662 trimAlignment(true);
\r
664 else if (source == remove2RightMenuItem)
\r
666 trimAlignment(false);
\r
668 else if (source == removeGappedColumnMenuItem)
\r
670 removeGappedColumnMenuItem_actionPerformed();
\r
672 else if (source == removeAllGapsMenuItem)
\r
674 removeAllGapsMenuItem_actionPerformed();
\r
676 else if (source == findMenuItem)
\r
678 findMenuItem_actionPerformed();
\r
680 else if (source == font)
\r
682 new FontChooser(alignPanel);
\r
684 else if (source == newView)
\r
688 else if (source == showColumns)
\r
690 viewport.showAllHiddenColumns();
\r
691 alignPanel.paintAlignment(true);
\r
693 else if (source == showSeqs)
\r
695 viewport.showAllHiddenSeqs();
\r
697 else if (source == hideColumns)
\r
699 viewport.hideSelectedColumns();
\r
700 alignPanel.paintAlignment(true);
\r
702 else if (source == hideSequences && viewport.getSelectionGroup() != null)
\r
704 viewport.hideAllSelectedSeqs();
\r
706 else if (source == featureSettings)
\r
708 new FeatureSettings(alignPanel);
\r
710 else if (source == overviewMenuItem)
\r
712 overviewMenuItem_actionPerformed();
\r
714 else if (source == noColourmenuItem)
\r
716 changeColour(null);
\r
718 else if (source == clustalColour)
\r
720 abovePIDThreshold.setState(false);
\r
721 changeColour(new ClustalxColourScheme(viewport.alignment.getSequences(),
\r
722 viewport.alignment.getWidth()));
\r
724 else if (source == zappoColour)
\r
726 changeColour(new ZappoColourScheme());
\r
728 else if (source == taylorColour)
\r
730 changeColour(new TaylorColourScheme());
\r
732 else if (source == hydrophobicityColour)
\r
734 changeColour(new HydrophobicColourScheme());
\r
736 else if (source == helixColour)
\r
738 changeColour(new HelixColourScheme());
\r
740 else if (source == strandColour)
\r
742 changeColour(new StrandColourScheme());
\r
744 else if (source == turnColour)
\r
746 changeColour(new TurnColourScheme());
\r
748 else if (source == buriedColour)
\r
750 changeColour(new BuriedColourScheme());
\r
752 else if (source == nucleotideColour)
\r
754 changeColour(new NucleotideColourScheme());
\r
756 else if (source == modifyPID)
\r
758 modifyPID_actionPerformed();
\r
760 else if (source == modifyConservation)
\r
762 modifyConservation_actionPerformed();
\r
764 else if (source == userDefinedColour)
\r
766 new UserDefinedColours(alignPanel, null);
\r
768 else if (source == PIDColour)
\r
770 changeColour(new PIDColourScheme());
\r
772 else if (source == BLOSUM62Colour)
\r
774 changeColour(new Blosum62ColourScheme());
\r
776 else if (source == annotationColour)
\r
778 new AnnotationColourChooser(viewport, alignPanel);
\r
780 else if (source == sortPairwiseMenuItem)
\r
782 sortPairwiseMenuItem_actionPerformed();
\r
784 else if (source == sortIDMenuItem)
\r
786 sortIDMenuItem_actionPerformed();
\r
788 else if (source == sortGroupMenuItem)
\r
790 sortGroupMenuItem_actionPerformed();
\r
792 else if (source == removeRedundancyMenuItem)
\r
794 removeRedundancyMenuItem_actionPerformed();
\r
796 else if (source == pairwiseAlignmentMenuItem)
\r
798 pairwiseAlignmentMenuItem_actionPerformed();
\r
800 else if (source == PCAMenuItem)
\r
802 PCAMenuItem_actionPerformed();
\r
804 else if (source == averageDistanceTreeMenuItem)
\r
806 averageDistanceTreeMenuItem_actionPerformed();
\r
808 else if (source == neighbourTreeMenuItem)
\r
810 neighbourTreeMenuItem_actionPerformed();
\r
812 else if (source == njTreeBlosumMenuItem)
\r
814 njTreeBlosumMenuItem_actionPerformed();
\r
816 else if (source == avDistanceTreeBlosumMenuItem)
\r
818 avTreeBlosumMenuItem_actionPerformed();
\r
820 else if (source == documentation)
\r
822 documentation_actionPerformed();
\r
824 else if (source == about)
\r
826 about_actionPerformed();
\r
831 public void inputText_actionPerformed()
\r
833 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
\r
834 Frame frame = new Frame();
\r
836 jalview.bin.JalviewLite.addFrame(frame, "Cut & Paste Input", 500, 500);
\r
839 protected void outputText_actionPerformed(ActionEvent e)
\r
841 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
\r
842 Frame frame = new Frame();
\r
844 jalview.bin.JalviewLite.addFrame(frame,
\r
845 "Alignment output - " + e.getActionCommand(),
\r
847 cap.setText(new AppletFormatAdapter().formatSequences(e.getActionCommand(),
\r
848 viewport.getAlignment(),
\r
849 viewport.showJVSuffix));
\r
852 public void loadAnnotations()
\r
854 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
\r
855 cap.setText("Paste your features / annotations file here.");
\r
856 cap.setAnnotationImport();
\r
857 Frame frame = new Frame();
\r
859 jalview.bin.JalviewLite.addFrame(frame, "Paste Annotations ", 400, 300);
\r
863 public String outputAnnotations(boolean displayTextbox)
\r
865 String annotation = new AnnotationFile().printAnnotations(
\r
866 viewport.showAnnotation ? viewport.alignment.getAlignmentAnnotation() : null,
\r
867 viewport.alignment.getGroups());
\r
869 if (displayTextbox)
\r
871 CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this);
\r
872 Frame frame = new Frame();
\r
874 jalview.bin.JalviewLite.addFrame(frame,
\r
877 cap.setText(annotation);
\r
883 public String outputFeatures(boolean displayTextbox, String format)
\r
886 if (format.equalsIgnoreCase("Jalview"))
\r
888 features = new FeaturesFile().printJalviewFormat(
\r
889 viewport.alignment.getSequencesArray(),
\r
890 viewport.featuresDisplayed);
\r
894 features = new FeaturesFile().printGFFFormat(
\r
895 viewport.alignment.getSequencesArray(),
\r
896 viewport.featuresDisplayed);
\r
899 if (displayTextbox)
\r
901 CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this);
\r
902 Frame frame = new Frame();
\r
904 jalview.bin.JalviewLite.addFrame(frame,
\r
908 cap.setText(features);
\r
914 void launchFullApplication()
\r
916 StringBuffer url = new StringBuffer(jalviewServletURL);
\r
918 url.append("?open=" +
\r
919 appendProtocol(viewport.applet.getParameter("file")));
\r
921 if (viewport.applet.getParameter("features") != null)
\r
923 url.append("&features=");
\r
924 url.append(appendProtocol(viewport.applet.getParameter("features")));
\r
927 if (viewport.applet.getParameter("annotations") != null)
\r
929 url.append("&annotations=");
\r
930 url.append(appendProtocol(viewport.applet.getParameter("annotations")));
\r
933 if (viewport.applet.getParameter("jnetfile") != null)
\r
935 url.append("&annotations=");
\r
936 url.append(appendProtocol(viewport.applet.getParameter("jnetfile")));
\r
939 if (viewport.applet.getParameter("defaultColour") != null)
\r
941 url.append("&colour=" +
\r
942 removeWhiteSpace(viewport.applet.getParameter("defaultColour"))
\r
946 if (viewport.applet.getParameter("userDefinedColour") != null)
\r
948 url.append("&colour=" +
\r
949 removeWhiteSpace(viewport.applet.getParameter(
\r
950 "userDefinedColour"))
\r
954 showURL(url.toString(), "FULL_APP");
\r
957 String removeWhiteSpace(String colour)
\r
959 StringBuffer sb = new StringBuffer();
\r
960 for (int i = 0; i < colour.length(); i++)
\r
962 if (Character.isWhitespace(colour.charAt(i)))
\r
968 sb.append(colour.charAt(i));
\r
972 return sb.toString();
\r
975 String appendProtocol(String url)
\r
981 catch (java.net.MalformedURLException ex)
\r
983 url = viewport.applet.getCodeBase() + url;
\r
988 public void closeMenuItem_actionPerformed()
\r
990 PaintRefresher.RemoveComponent(alignPanel);
\r
991 PaintRefresher.RemoveComponent(alignPanel.seqPanel.seqCanvas);
\r
992 PaintRefresher.RemoveComponent(alignPanel.idPanel.idCanvas);
\r
994 if (PaintRefresher.components.size() == 0 && viewport.applet == null)
\r
1005 void updateEditMenuBar()
\r
1008 if (viewport.historyList.size() > 0)
\r
1010 undoMenuItem.setEnabled(true);
\r
1011 CommandI command = (CommandI) viewport.historyList.peek();
\r
1012 undoMenuItem.setLabel("Undo " + command.getDescription());
\r
1016 undoMenuItem.setEnabled(false);
\r
1017 undoMenuItem.setLabel("Undo");
\r
1020 if (viewport.redoList.size() > 0)
\r
1022 redoMenuItem.setEnabled(true);
\r
1024 CommandI command = (CommandI) viewport.redoList.peek();
\r
1025 redoMenuItem.setLabel("Redo " + command.getDescription());
\r
1029 redoMenuItem.setEnabled(false);
\r
1030 redoMenuItem.setLabel("Redo");
\r
1034 public void addHistoryItem(CommandI command)
\r
1036 if (command.getSize() > 0)
\r
1038 viewport.historyList.push(command);
\r
1039 viewport.redoList.removeAllElements();
\r
1040 updateEditMenuBar();
\r
1041 viewport.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;
\r
1048 * @param e DOCUMENT ME!
\r
1050 protected void undoMenuItem_actionPerformed()
\r
1052 if (viewport.historyList.size() < 1)
\r
1057 CommandI command = (CommandI) viewport.historyList.pop();
\r
1058 viewport.redoList.push(command);
\r
1059 command.undoCommand();
\r
1061 AlignViewport originalSource = getOriginatingSource(command);
\r
1063 originalSource.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;
\r
1064 updateEditMenuBar();
\r
1065 originalSource.firePropertyChange("alignment", null,
\r
1066 originalSource.alignment.getSequences());
\r
1072 * @param e DOCUMENT ME!
\r
1074 protected void redoMenuItem_actionPerformed()
\r
1076 if (viewport.redoList.size() < 1)
\r
1081 CommandI command = (CommandI) viewport.redoList.pop();
\r
1082 viewport.historyList.push(command);
\r
1083 command.doCommand();
\r
1085 AlignViewport originalSource = getOriginatingSource(command);
\r
1086 originalSource.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;
\r
1088 updateEditMenuBar();
\r
1089 originalSource.firePropertyChange("alignment", null,
\r
1090 originalSource.alignment.getSequences());
\r
1093 AlignViewport getOriginatingSource(CommandI command)
\r
1095 AlignViewport originalSource = null;
\r
1096 //For sequence removal and addition, we need to fire
\r
1097 //the property change event FROM the viewport where the
\r
1098 //original alignment was altered
\r
1099 AlignmentI al = null;
\r
1100 if (command instanceof EditCommand)
\r
1102 EditCommand editCommand = (EditCommand) command;
\r
1103 al = editCommand.getAlignment();
\r
1104 Vector comps = (Vector) PaintRefresher.components
\r
1105 .get(viewport.getSequenceSetId());
\r
1106 for (int i = 0; i < comps.size(); i++)
\r
1108 if (comps.elementAt(i) instanceof AlignmentPanel)
\r
1110 if (al == ( (AlignmentPanel) comps.elementAt(i)).av.alignment)
\r
1112 originalSource = ( (AlignmentPanel) comps.elementAt(i)).av;
\r
1119 if (originalSource == null)
\r
1121 //The original view is closed, we must validate
\r
1122 //the current view against the closed view first
\r
1125 PaintRefresher.validateSequences(al, viewport.alignment);
\r
1128 originalSource = viewport;
\r
1131 return originalSource;
\r
1134 public void moveSelectedSequences(boolean up)
\r
1136 SequenceGroup sg = viewport.getSelectionGroup();
\r
1144 for (int i = 1; i < viewport.alignment.getHeight(); i++)
\r
1146 SequenceI seq = viewport.alignment.getSequenceAt(i);
\r
1147 if (!sg.getSequences(null).contains(seq))
\r
1152 SequenceI temp = viewport.alignment.getSequenceAt(i - 1);
\r
1153 if (sg.getSequences(null).contains(temp))
\r
1158 viewport.alignment.getSequences().setElementAt(temp, i);
\r
1159 viewport.alignment.getSequences().setElementAt(seq, i - 1);
\r
1164 for (int i = viewport.alignment.getHeight() - 2; i > -1; i--)
\r
1166 SequenceI seq = viewport.alignment.getSequenceAt(i);
\r
1167 if (!sg.getSequences(viewport.hiddenRepSequences).contains(seq))
\r
1172 SequenceI temp = viewport.alignment.getSequenceAt(i + 1);
\r
1173 if (sg.getSequences(viewport.hiddenRepSequences).contains(temp))
\r
1178 viewport.alignment.getSequences().setElementAt(temp, i);
\r
1179 viewport.alignment.getSequences().setElementAt(seq, i + 1);
\r
1183 alignPanel.paintAlignment(true);
\r
1186 synchronized void slideSequences(boolean right, int size)
\r
1188 Vector sg = new Vector();
\r
1189 if(viewport.cursorMode)
\r
1191 sg.addElement(viewport.alignment.getSequenceAt(
\r
1192 alignPanel.seqPanel.seqCanvas.cursorY));
\r
1194 else if(viewport.getSelectionGroup()!=null
\r
1195 && viewport.getSelectionGroup().getSize()!=viewport.alignment.getHeight())
\r
1197 sg = viewport.getSelectionGroup().getSequences(
\r
1198 viewport.hiddenRepSequences);
\r
1206 Vector invertGroup = new Vector();
\r
1208 for (int i = 0; i < viewport.alignment.getHeight(); i++)
\r
1210 if(!sg.contains(viewport.alignment.getSequenceAt(i)))
\r
1211 invertGroup.addElement(viewport.alignment.getSequenceAt(i));
\r
1214 SequenceI[] seqs1 = new SequenceI[sg.size()];
\r
1215 for (int i = 0; i < sg.size(); i++)
\r
1216 seqs1[i] = (SequenceI) sg.elementAt(i);
\r
1218 SequenceI[] seqs2 = new SequenceI[invertGroup.size()];
\r
1219 for (int i = 0; i < invertGroup.size(); i++)
\r
1220 seqs2[i] = (SequenceI) invertGroup.elementAt(i);
\r
1222 SlideSequencesCommand ssc;
\r
1224 ssc = new SlideSequencesCommand("Slide Sequences",
\r
1225 seqs2, seqs1, size,
\r
1226 viewport.getGapCharacter()
\r
1229 ssc = new SlideSequencesCommand("Slide Sequences",
\r
1230 seqs1, seqs2, size,
\r
1231 viewport.getGapCharacter()
\r
1234 int groupAdjustment = 0;
\r
1235 if (ssc.getGapsInsertedBegin() && right)
\r
1237 if (viewport.cursorMode)
\r
1238 alignPanel.seqPanel.moveCursor(size, 0);
\r
1240 groupAdjustment = size;
\r
1242 else if (!ssc.getGapsInsertedBegin() && !right)
\r
1244 if (viewport.cursorMode)
\r
1245 alignPanel.seqPanel.moveCursor( -size, 0);
\r
1247 groupAdjustment = -size;
\r
1250 if (groupAdjustment != 0)
\r
1252 viewport.getSelectionGroup().setStartRes(
\r
1253 viewport.getSelectionGroup().getStartRes() + groupAdjustment);
\r
1254 viewport.getSelectionGroup().setEndRes(
\r
1255 viewport.getSelectionGroup().getEndRes() + groupAdjustment);
\r
1259 boolean appendHistoryItem = false;
\r
1260 if(viewport.historyList!=null
\r
1261 && viewport.historyList.size()>0
\r
1262 && viewport.historyList.peek() instanceof SlideSequencesCommand)
\r
1264 appendHistoryItem = ssc.appendSlideCommand(
\r
1265 (SlideSequencesCommand)viewport.historyList.peek())
\r
1269 if(!appendHistoryItem)
\r
1270 addHistoryItem(ssc);
\r
1275 static StringBuffer copiedSequences;
\r
1276 static Vector copiedHiddenColumns;
\r
1277 protected void copy_actionPerformed()
\r
1279 if (viewport.getSelectionGroup() == null)
\r
1284 SequenceGroup sg = viewport.getSelectionGroup();
\r
1285 copiedSequences = new StringBuffer();
\r
1286 Hashtable orderedSeqs = new Hashtable();
\r
1287 for (int i = 0; i < sg.getSize(); i++)
\r
1289 SequenceI seq = sg.getSequenceAt(i);
\r
1290 int index = viewport.alignment.findIndex(seq);
\r
1291 orderedSeqs.put(index + "", seq);
\r
1294 int index = 0, startRes, endRes;
\r
1297 if (viewport.hasHiddenColumns && viewport.getSelectionGroup() != null)
\r
1299 copiedHiddenColumns = new Vector();
\r
1300 int hiddenOffset = viewport.getSelectionGroup().getStartRes();
\r
1301 for (int i = 0; i < viewport.getColumnSelection().getHiddenColumns().size();
\r
1304 int[] region = (int[])
\r
1305 viewport.getColumnSelection().getHiddenColumns().elementAt(i);
\r
1307 copiedHiddenColumns.addElement(new int[]
\r
1308 {region[0] - hiddenOffset,
\r
1309 region[1] - hiddenOffset});
\r
1314 copiedHiddenColumns = null;
\r
1317 for (int i = 0; i < sg.getSize(); i++)
\r
1319 SequenceI seq = null;
\r
1321 while (seq == null)
\r
1323 if (orderedSeqs.containsKey(index + ""))
\r
1325 seq = (SequenceI) orderedSeqs.get(index + "");
\r
1337 //Returns residue following index if gap
\r
1338 startRes = seq.findPosition(sg.getStartRes());
\r
1341 //Need to find the residue preceeding index if gap
\r
1344 for (int j = 0; j < sg.getEndRes() + 1 && j < seq.getLength(); j++)
\r
1346 ch = seq.getCharAt(j);
\r
1347 if (!jalview.util.Comparison.isGap( (ch)))
\r
1355 endRes += seq.getStart() - 1;
\r
1358 copiedSequences.append(seq.getName() + "\t" +
\r
1361 seq.getSequenceAsString(sg.getStartRes(),
\r
1362 sg.getEndRes() + 1) + "\n");
\r
1367 protected void pasteNew_actionPerformed()
\r
1372 protected void pasteThis_actionPerformed()
\r
1377 void paste(boolean newAlignment)
\r
1382 if (copiedSequences == null)
\r
1387 StringTokenizer st = new StringTokenizer(copiedSequences.toString());
\r
1388 Vector seqs = new Vector();
\r
1389 while (st.hasMoreElements())
\r
1391 String name = st.nextToken();
\r
1392 int start = Integer.parseInt(st.nextToken());
\r
1393 int end = Integer.parseInt(st.nextToken());
\r
1394 seqs.addElement(new Sequence(name, st.nextToken(), start, end));
\r
1396 SequenceI[] newSeqs = new SequenceI[seqs.size()];
\r
1397 for (int i = 0; i < seqs.size(); i++)
\r
1399 newSeqs[i] = (SequenceI) seqs.elementAt(i);
\r
1404 String newtitle = new String("Copied sequences");
\r
1405 if (getTitle().startsWith("Copied sequences"))
\r
1407 newtitle = getTitle();
\r
1411 newtitle = newtitle.concat("- from " + getTitle());
\r
1413 AlignFrame af = new AlignFrame(new Alignment(newSeqs),
\r
1417 if (copiedHiddenColumns != null)
\r
1419 for (int i = 0; i < copiedHiddenColumns.size(); i++)
\r
1421 int[] region = (int[]) copiedHiddenColumns.elementAt(i);
\r
1422 af.viewport.hideColumns(region[0], region[1]);
\r
1426 jalview.bin.JalviewLite.addFrame(af, newtitle, DEFAULT_WIDTH,
\r
1431 addSequences(newSeqs);
\r
1435 catch (Exception ex)
\r
1436 {} // could be anything being pasted in here
\r
1440 void addSequences(SequenceI[] seqs)
\r
1442 for (int i = 0; i < seqs.length; i++)
\r
1444 viewport.alignment.addSequence(seqs[i]);
\r
1448 addHistoryItem(new EditCommand(
\r
1450 EditCommand.PASTE,
\r
1453 viewport.alignment.getWidth(),
\r
1454 viewport.alignment)
\r
1457 viewport.setEndSeq(viewport.alignment.getHeight());
\r
1458 viewport.alignment.getWidth();
\r
1459 viewport.firePropertyChange("alignment", null,
\r
1460 viewport.alignment.getSequences());
\r
1464 protected void cut_actionPerformed()
\r
1466 copy_actionPerformed();
\r
1467 delete_actionPerformed();
\r
1470 protected void delete_actionPerformed()
\r
1473 SequenceGroup sg = viewport.getSelectionGroup();
\r
1479 Vector seqs = new Vector();
\r
1481 for (int i = 0; i < sg.getSize(); i++)
\r
1483 seq = sg.getSequenceAt(i);
\r
1484 seqs.addElement(seq);
\r
1487 // If the cut affects all sequences, remove highlighted columns
\r
1488 if (sg.getSize() == viewport.alignment.getHeight())
\r
1490 viewport.getColumnSelection().removeElements(sg.getStartRes(),
\r
1491 sg.getEndRes() + 1);
\r
1494 SequenceI[] cut = new SequenceI[seqs.size()];
\r
1495 for (int i = 0; i < seqs.size(); i++)
\r
1497 cut[i] = (SequenceI) seqs.elementAt(i);
\r
1501 //ADD HISTORY ITEM
\r
1503 addHistoryItem(new EditCommand("Cut Sequences",
\r
1507 sg.getEndRes() - sg.getStartRes() + 1,
\r
1508 viewport.alignment));
\r
1510 viewport.setSelectionGroup(null);
\r
1511 viewport.alignment.deleteGroup(sg);
\r
1513 viewport.firePropertyChange("alignment", null,
\r
1514 viewport.getAlignment().getSequences());
\r
1516 if (viewport.getAlignment().getHeight() < 1)
\r
1518 this.setVisible(false);
\r
1522 protected void deleteGroups_actionPerformed()
\r
1524 viewport.alignment.deleteAllGroups();
\r
1525 viewport.sequenceColours = null;
\r
1526 viewport.setSelectionGroup(null);
\r
1528 alignPanel.paintAlignment(true);
\r
1531 public void selectAllSequenceMenuItem_actionPerformed()
\r
1533 SequenceGroup sg = new SequenceGroup();
\r
1534 for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++)
\r
1536 sg.addSequence(viewport.getAlignment().getSequenceAt(i), false);
\r
1538 sg.setEndRes(viewport.alignment.getWidth() - 1);
\r
1539 viewport.setSelectionGroup(sg);
\r
1540 alignPanel.paintAlignment(true);
\r
1541 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
\r
1544 public void deselectAllSequenceMenuItem_actionPerformed()
\r
1546 if (viewport.cursorMode)
\r
1548 alignPanel.seqPanel.keyboardNo1 = null;
\r
1549 alignPanel.seqPanel.keyboardNo2 = null;
\r
1551 viewport.setSelectionGroup(null);
\r
1552 viewport.getColumnSelection().clear();
\r
1553 viewport.setSelectionGroup(null);
\r
1554 alignPanel.idPanel.idCanvas.searchResults = null;
\r
1555 alignPanel.seqPanel.seqCanvas.highlightSearchResults(null);
\r
1556 alignPanel.paintAlignment(true);
\r
1557 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
\r
1560 public void invertSequenceMenuItem_actionPerformed()
\r
1562 SequenceGroup sg = viewport.getSelectionGroup();
\r
1563 for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++)
\r
1565 sg.addOrRemove(viewport.getAlignment().getSequenceAt(i), false);
\r
1568 PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
\r
1571 void trimAlignment(boolean trimLeft)
\r
1573 ColumnSelection colSel = viewport.getColumnSelection();
\r
1576 if (colSel.size() > 0)
\r
1580 column = colSel.getMin();
\r
1584 column = colSel.getMax();
\r
1588 if (viewport.getSelectionGroup() != null)
\r
1590 seqs = viewport.getSelectionGroup().getSequencesAsArray(viewport.
\r
1591 hiddenRepSequences);
\r
1595 seqs = viewport.alignment.getSequencesArray();
\r
1598 TrimRegionCommand trimRegion;
\r
1601 trimRegion = new TrimRegionCommand("Remove Left",
\r
1602 TrimRegionCommand.TRIM_LEFT,
\r
1605 viewport.alignment,
\r
1607 viewport.selectionGroup);
\r
1608 viewport.setStartRes(0);
\r
1612 trimRegion = new TrimRegionCommand("Remove Right",
\r
1613 TrimRegionCommand.TRIM_RIGHT,
\r
1616 viewport.alignment,
\r
1618 viewport.selectionGroup);
\r
1621 statusBar.setText("Removed " + trimRegion.getSize() + " columns.");
\r
1623 addHistoryItem(trimRegion);
\r
1625 Vector groups = viewport.alignment.getGroups();
\r
1627 for (int i = 0; i < groups.size(); i++)
\r
1629 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
\r
1631 if ( (trimLeft && !sg.adjustForRemoveLeft(column))
\r
1632 || (!trimLeft && !sg.adjustForRemoveRight(column)))
\r
1634 viewport.alignment.deleteGroup(sg);
\r
1638 viewport.firePropertyChange("alignment", null,
\r
1639 viewport.getAlignment().getSequences());
\r
1643 public void removeGappedColumnMenuItem_actionPerformed()
\r
1645 int start = 0, end = viewport.alignment.getWidth() - 1;
\r
1648 if (viewport.getSelectionGroup() != null)
\r
1650 seqs = viewport.getSelectionGroup().getSequencesAsArray(viewport.
\r
1651 hiddenRepSequences);
\r
1652 start = viewport.getSelectionGroup().getStartRes();
\r
1653 end = viewport.getSelectionGroup().getEndRes();
\r
1657 seqs = viewport.alignment.getSequencesArray();
\r
1660 RemoveGapColCommand removeGapCols =
\r
1661 new RemoveGapColCommand("Remove Gapped Columns",
\r
1664 viewport.alignment);
\r
1666 addHistoryItem(removeGapCols);
\r
1668 statusBar.setText("Removed " + removeGapCols.getSize() + " empty columns.");
\r
1670 //This is to maintain viewport position on first residue
\r
1671 //of first sequence
\r
1672 SequenceI seq = viewport.alignment.getSequenceAt(0);
\r
1673 int startRes = seq.findPosition(viewport.startRes);
\r
1674 // ShiftList shifts;
\r
1675 // viewport.getAlignment().removeGaps(shifts=new ShiftList());
\r
1676 // edit.alColumnChanges=shifts.getInverse();
\r
1677 // if (viewport.hasHiddenColumns)
\r
1678 // viewport.getColumnSelection().compensateForEdits(shifts);
\r
1679 viewport.setStartRes(seq.findIndex(startRes) - 1);
\r
1680 viewport.firePropertyChange("alignment", null,
\r
1681 viewport.getAlignment().getSequences());
\r
1685 public void removeAllGapsMenuItem_actionPerformed()
\r
1687 int start = 0, end = viewport.alignment.getWidth() - 1;
\r
1690 if (viewport.getSelectionGroup() != null)
\r
1692 seqs = viewport.getSelectionGroup().getSequencesAsArray(viewport.
\r
1693 hiddenRepSequences);
\r
1694 start = viewport.getSelectionGroup().getStartRes();
\r
1695 end = viewport.getSelectionGroup().getEndRes();
\r
1699 seqs = viewport.alignment.getSequencesArray();
\r
1702 //This is to maintain viewport position on first residue
\r
1703 //of first sequence
\r
1704 SequenceI seq = viewport.alignment.getSequenceAt(0);
\r
1705 int startRes = seq.findPosition(viewport.startRes);
\r
1707 addHistoryItem(new RemoveGapsCommand("Remove Gaps",
\r
1710 viewport.alignment));
\r
1712 viewport.setStartRes(seq.findIndex(startRes) - 1);
\r
1714 viewport.firePropertyChange("alignment", null,
\r
1715 viewport.getAlignment().getSequences());
\r
1719 public void findMenuItem_actionPerformed()
\r
1721 new Finder(alignPanel);
\r
1724 public void newView()
\r
1727 if (viewport.hasHiddenRows)
\r
1729 newal = new Alignment(viewport.getAlignment().
\r
1730 getHiddenSequences()
\r
1731 .getFullAlignment().
\r
1732 getSequencesArray());
\r
1736 newal = new Alignment(viewport.alignment.getSequencesArray());
\r
1739 if (viewport.alignment.getAlignmentAnnotation() != null)
\r
1741 for (int i = 0; i < viewport.alignment.getAlignmentAnnotation().length; i++)
\r
1743 if (!viewport.alignment.getAlignmentAnnotation()[i].autoCalculated)
\r
1745 newal.addAnnotation(viewport.alignment.getAlignmentAnnotation()[i]);
\r
1750 AlignFrame newaf = new AlignFrame(newal,
\r
1755 newaf.viewport.sequenceSetID = alignPanel.av.getSequenceSetId();
\r
1756 PaintRefresher.Register(alignPanel, alignPanel.av.getSequenceSetId());
\r
1757 PaintRefresher.Register(newaf.alignPanel,
\r
1758 newaf.alignPanel.av.getSequenceSetId());
\r
1760 PaintRefresher.Register(newaf.alignPanel.idPanel.idCanvas,
\r
1761 newaf.alignPanel.av.getSequenceSetId());
\r
1762 PaintRefresher.Register(newaf.alignPanel.seqPanel.seqCanvas,
\r
1763 newaf.alignPanel.av.getSequenceSetId());
\r
1765 Vector comps = (Vector) PaintRefresher.components.get(viewport.
\r
1766 getSequenceSetId());
\r
1767 int viewSize = -1;
\r
1768 for (int i = 0; i < comps.size(); i++)
\r
1770 if (comps.elementAt(i) instanceof AlignmentPanel)
\r
1776 String title = new String(this.getTitle());
\r
1777 if (title.indexOf("(View") > -1)
\r
1779 title = title.substring(0, title.indexOf("(View"));
\r
1782 title += "(View " + viewSize + ")";
\r
1784 newaf.setTitle(title.toString());
\r
1786 newaf.viewport.historyList = viewport.historyList;
\r
1787 newaf.viewport.redoList = viewport.redoList;
\r
1791 public void seqLimits_itemStateChanged()
\r
1793 viewport.setShowJVSuffix(seqLimits.getState());
\r
1794 alignPanel.fontChanged();
\r
1795 alignPanel.paintAlignment(true);
\r
1798 protected void colourTextMenuItem_actionPerformed()
\r
1800 viewport.setColourText(colourTextMenuItem.getState());
\r
1801 alignPanel.paintAlignment(true);
\r
1804 protected void wrapMenuItem_actionPerformed()
\r
1806 viewport.setWrapAlignment(wrapMenuItem.getState());
\r
1807 alignPanel.setWrapAlignment(wrapMenuItem.getState());
\r
1808 scaleAbove.setEnabled(wrapMenuItem.getState());
\r
1809 scaleLeft.setEnabled(wrapMenuItem.getState());
\r
1810 scaleRight.setEnabled(wrapMenuItem.getState());
\r
1811 alignPanel.paintAlignment(true);
\r
1814 public void overviewMenuItem_actionPerformed()
\r
1816 if (alignPanel.overviewPanel != null)
\r
1821 Frame frame = new Frame();
\r
1822 OverviewPanel overview = new OverviewPanel(alignPanel);
\r
1823 frame.add(overview);
\r
1824 // +50 must allow for applet frame window
\r
1825 jalview.bin.JalviewLite.addFrame(frame, "Overview " + this.getTitle(),
\r
1826 overview.getPreferredSize().width,
\r
1827 overview.getPreferredSize().height + 50);
\r
1830 frame.addWindowListener(new WindowAdapter()
\r
1832 public void windowClosing(WindowEvent e)
\r
1834 alignPanel.setOverviewPanel(null);
\r
1838 alignPanel.setOverviewPanel(overview);
\r
1842 void changeColour(ColourSchemeI cs)
\r
1844 int threshold = 0;
\r
1848 if (viewport.getAbovePIDThreshold())
\r
1850 threshold = SliderPanel.setPIDSliderSource(alignPanel, cs, "Background");
\r
1852 cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus());
\r
1854 viewport.setGlobalColourScheme(cs);
\r
1858 cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
\r
1861 if (viewport.getConservationSelected())
\r
1864 Alignment al = (Alignment) viewport.alignment;
\r
1865 Conservation c = new Conservation("All",
\r
1866 ResidueProperties.propHash, 3,
\r
1867 al.getSequences(), 0,
\r
1868 al.getWidth() - 1);
\r
1871 c.verdict(false, viewport.ConsPercGaps);
\r
1873 cs.setConservation(c);
\r
1875 cs.setConservationInc(SliderPanel.setConservationSlider(alignPanel, cs,
\r
1881 cs.setConservation(null);
\r
1884 cs.setConsensus(viewport.hconsensus);
\r
1887 viewport.setGlobalColourScheme(cs);
\r
1889 if (viewport.getColourAppliesToAllGroups())
\r
1891 Vector groups = viewport.alignment.getGroups();
\r
1892 for (int i = 0; i < groups.size(); i++)
\r
1894 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
\r
1901 if (cs instanceof ClustalxColourScheme)
\r
1903 sg.cs = new ClustalxColourScheme(
\r
1904 sg.getSequences(viewport.hiddenRepSequences),
\r
1911 sg.cs = (ColourSchemeI) cs.getClass().newInstance();
\r
1913 catch (Exception ex)
\r
1915 ex.printStackTrace();
\r
1920 if (viewport.getAbovePIDThreshold()
\r
1921 || cs instanceof PIDColourScheme
\r
1922 || cs instanceof Blosum62ColourScheme)
\r
1924 sg.cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus());
\r
1925 sg.cs.setConsensus(AAFrequency.calculate(
\r
1926 sg.getSequences(viewport.hiddenRepSequences), 0, sg.getWidth()));
\r
1930 sg.cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
\r
1933 if (viewport.getConservationSelected())
\r
1935 Conservation c = new Conservation("Group",
\r
1936 ResidueProperties.propHash, 3,
\r
1937 sg.getSequences(viewport.
\r
1938 hiddenRepSequences), 0,
\r
1939 viewport.alignment.getWidth() - 1);
\r
1941 c.verdict(false, viewport.ConsPercGaps);
\r
1942 sg.cs.setConservation(c);
\r
1946 sg.cs.setConservation(null);
\r
1947 sg.cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
\r
1953 if (alignPanel.getOverviewPanel() != null)
\r
1955 alignPanel.getOverviewPanel().updateOverviewImage();
\r
1958 jalview.structure.StructureSelectionManager.getStructureSelectionManager()
\r
1959 .sequenceColoursChanged(alignPanel);
\r
1961 alignPanel.paintAlignment(true);
\r
1964 protected void modifyPID_actionPerformed()
\r
1966 if (viewport.getAbovePIDThreshold() && viewport.globalColourScheme != null)
\r
1968 SliderPanel.setPIDSliderSource(alignPanel, viewport.getGlobalColourScheme(),
\r
1970 SliderPanel.showPIDSlider();
\r
1974 protected void modifyConservation_actionPerformed()
\r
1976 if (viewport.getConservationSelected() && viewport.globalColourScheme != null)
\r
1978 SliderPanel.setConservationSlider(alignPanel, viewport.globalColourScheme,
\r
1980 SliderPanel.showConservationSlider();
\r
1984 protected void conservationMenuItem_actionPerformed()
\r
1986 viewport.setConservationSelected(conservationMenuItem.getState());
\r
1988 viewport.setAbovePIDThreshold(false);
\r
1989 abovePIDThreshold.setState(false);
\r
1991 changeColour(viewport.getGlobalColourScheme());
\r
1993 modifyConservation_actionPerformed();
\r
1996 public void abovePIDThreshold_actionPerformed()
\r
1998 viewport.setAbovePIDThreshold(abovePIDThreshold.getState());
\r
2000 conservationMenuItem.setState(false);
\r
2001 viewport.setConservationSelected(false);
\r
2003 changeColour(viewport.getGlobalColourScheme());
\r
2005 modifyPID_actionPerformed();
\r
2008 public void sortPairwiseMenuItem_actionPerformed()
\r
2010 SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
\r
2011 AlignmentSorter.sortByPID(viewport.getAlignment(),
\r
2012 viewport.getAlignment().getSequenceAt(0));
\r
2013 addHistoryItem(new OrderCommand("Pairwise Sort", oldOrder,
\r
2014 viewport.alignment));
\r
2015 alignPanel.paintAlignment(true);
\r
2018 public void sortIDMenuItem_actionPerformed()
\r
2020 // addHistoryItem(new HistoryItem("ID Sort", viewport.alignment,
\r
2021 // HistoryItem.SORT));
\r
2022 AlignmentSorter.sortByID(viewport.getAlignment());
\r
2023 alignPanel.paintAlignment(true);
\r
2026 public void sortGroupMenuItem_actionPerformed()
\r
2028 // addHistoryItem(new HistoryItem("Group Sort", viewport.alignment,
\r
2029 // HistoryItem.SORT));
\r
2030 AlignmentSorter.sortByGroup(viewport.getAlignment());
\r
2031 alignPanel.paintAlignment(true);
\r
2035 public void removeRedundancyMenuItem_actionPerformed()
\r
2037 new RedundancyPanel(alignPanel);
\r
2040 public void pairwiseAlignmentMenuItem_actionPerformed()
\r
2042 if (viewport.getSelectionGroup() != null
\r
2043 && viewport.getSelectionGroup().getSize() > 1)
\r
2045 Frame frame = new Frame();
\r
2046 frame.add(new PairwiseAlignPanel(alignPanel));
\r
2047 jalview.bin.JalviewLite.addFrame(frame, "Pairwise Alignment", 600, 500);
\r
2051 public void PCAMenuItem_actionPerformed()
\r
2053 //are the sequences aligned?
\r
2054 if (!viewport.alignment.isAligned())
\r
2056 SequenceI current;
\r
2057 int Width = viewport.getAlignment().getWidth();
\r
2059 for (int i = 0; i < viewport.getAlignment().getSequences().size();
\r
2062 current = viewport.getAlignment().getSequenceAt(i);
\r
2064 if (current.getLength() < Width)
\r
2066 current.insertCharAt(Width - 1, viewport.getGapCharacter());
\r
2069 alignPanel.paintAlignment(true);
\r
2072 if ( (viewport.getSelectionGroup() != null &&
\r
2073 viewport.getSelectionGroup().getSize() < 4 &&
\r
2074 viewport.getSelectionGroup().getSize() > 0)
\r
2075 || viewport.getAlignment().getHeight() < 4)
\r
2082 new PCAPanel(viewport);
\r
2084 catch (java.lang.OutOfMemoryError ex)
\r
2090 public void averageDistanceTreeMenuItem_actionPerformed()
\r
2092 NewTreePanel("AV", "PID", "Average distance tree using PID");
\r
2095 public void neighbourTreeMenuItem_actionPerformed()
\r
2097 NewTreePanel("NJ", "PID", "Neighbour joining tree using PID");
\r
2100 protected void njTreeBlosumMenuItem_actionPerformed()
\r
2102 NewTreePanel("NJ", "BL", "Neighbour joining tree using BLOSUM62");
\r
2105 protected void avTreeBlosumMenuItem_actionPerformed()
\r
2107 NewTreePanel("AV", "BL", "Average distance tree using BLOSUM62");
\r
2110 void NewTreePanel(String type, String pwType, String title)
\r
2112 //are the sequences aligned?
\r
2113 if (!viewport.alignment.isAligned())
\r
2115 SequenceI current;
\r
2116 int Width = viewport.getAlignment().getWidth();
\r
2118 for (int i = 0; i < viewport.getAlignment().getSequences().size();
\r
2121 current = viewport.getAlignment().getSequenceAt(i);
\r
2123 if (current.getLength() < Width)
\r
2125 current.insertCharAt(Width - 1, viewport.getGapCharacter());
\r
2128 alignPanel.paintAlignment(true);
\r
2132 if ( (viewport.getSelectionGroup() != null &&
\r
2133 viewport.getSelectionGroup().getSize() > 1)
\r
2134 || (viewport.getSelectionGroup() == null
\r
2135 && viewport.alignment.getHeight() > 1))
\r
2137 final TreePanel tp = new TreePanel(viewport,
\r
2141 addTreeMenuItem(tp, title);
\r
2143 jalview.bin.JalviewLite.addFrame(tp, title, 600, 500);
\r
2147 void loadTree_actionPerformed()
\r
2149 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
\r
2150 cap.setText("Paste your Newick tree file here.");
\r
2151 cap.setTreeImport();
\r
2152 Frame frame = new Frame();
\r
2154 jalview.bin.JalviewLite.addFrame(frame, "Paste Newick file ", 400, 300);
\r
2157 public void loadTree(jalview.io.NewickFile tree, String treeFile)
\r
2159 TreePanel tp = new TreePanel(viewport,
\r
2163 jalview.bin.JalviewLite.addFrame(tp, treeFile, 600, 500);
\r
2164 addTreeMenuItem(tp, treeFile);
\r
2167 void addTreeMenuItem(final TreePanel treePanel, String title)
\r
2169 final MenuItem item = new MenuItem(title);
\r
2170 sortByTreeMenu.add(item);
\r
2171 item.addActionListener(new java.awt.event.ActionListener()
\r
2173 public void actionPerformed(ActionEvent evt)
\r
2175 // addHistoryItem(new HistoryItem("Sort", viewport.alignment,
\r
2176 // HistoryItem.SORT));
\r
2177 AlignmentSorter.sortByTree(viewport.getAlignment(), treePanel.getTree());
\r
2178 alignPanel.paintAlignment(true);
\r
2182 treePanel.addWindowListener(new WindowAdapter()
\r
2184 public void windowClosing(WindowEvent e)
\r
2186 sortByTreeMenu.remove(item);
\r
2191 protected void documentation_actionPerformed()
\r
2193 showURL("http://www.jalview.org/help.html", "HELP");
\r
2196 protected void about_actionPerformed()
\r
2203 public AboutPanel(String version)
\r
2205 this.version = version;
\r
2208 public void paint(Graphics g)
\r
2210 g.setColor(Color.white);
\r
2211 g.fillRect(0, 0, getSize().width, getSize().height);
\r
2212 g.setFont(new Font("Helvetica", Font.PLAIN, 12));
\r
2213 FontMetrics fm = g.getFontMetrics();
\r
2214 int fh = fm.getHeight();
\r
2216 g.setColor(Color.black);
\r
2217 g.setFont(new Font("Helvetica", Font.BOLD, 14));
\r
2218 g.drawString("Jalview - Release " + version, 200, y += fh);
\r
2219 g.setFont(new Font("Helvetica", Font.PLAIN, 12));
\r
2220 g.drawString("Authors: Michele Clamp, James Cuff, Steve Searle, Andrew Waterhouse, Jim Procter & Geoff Barton.",
\r
2222 g.drawString("Current development managed by Andrew Waterhouse; Barton Group, University of Dundee.",
\r
2225 "For any issues relating to Jalview, email help@jalview.org", x,
\r
2227 g.drawString("If you use JalView, please cite:", x, y += fh + 8);
\r
2228 g.drawString("\"Clamp, M., Cuff, J., Searle, S. M. and Barton, G. J. (2004), The Jalview Java Alignment Editor\"",
\r
2230 g.drawString("Bioinformatics, 2004 20;426-7.", x, y += fh);
\r
2234 String version = "test";
\r
2235 java.net.URL url = getClass().getResource("/.build_properties");
\r
2240 BufferedReader reader = new BufferedReader(new InputStreamReader(
\r
2241 url.openStream()));
\r
2243 while ( (line = reader.readLine()) != null)
\r
2245 if (line.indexOf("VERSION") > -1)
\r
2247 version = line.substring(line.indexOf("=") + 1);
\r
2251 catch (Exception ex)
\r
2253 ex.printStackTrace();
\r
2257 Frame frame = new Frame();
\r
2258 frame.add(new AboutPanel(version));
\r
2259 jalview.bin.JalviewLite.addFrame(frame, "Jalview", 580, 200);
\r
2263 public void showURL(String url, String target)
\r
2265 if (viewport.applet == null)
\r
2267 System.out.println("Not running as applet - no browser available.");
\r
2273 System.out.println("Show url: " + url);
\r
2274 viewport.applet.getAppletContext().showDocument(new java.net.URL(url),
\r
2277 catch (Exception ex)
\r
2279 ex.printStackTrace();
\r
2284 //////////////////////////////////////////////////////////////////////////////////
\r
2285 //JBuilder Graphics here
\r
2287 protected MenuBar alignFrameMenuBar = new MenuBar();
\r
2288 protected Menu fileMenu = new Menu("File");
\r
2289 protected MenuItem loadApplication = new MenuItem("View in Full Application");
\r
2290 protected MenuItem loadTree = new MenuItem("Load Associated Tree ...");
\r
2291 protected MenuItem loadAnnotations = new MenuItem(
\r
2292 "Load Features/Annotations ...");
\r
2293 protected MenuItem outputFeatures = new MenuItem("Export Features ...");
\r
2294 protected MenuItem outputAnnotations = new MenuItem("Export Annotations ...");
\r
2296 protected MenuItem closeMenuItem = new MenuItem("Close");
\r
2297 protected Menu editMenu = new Menu("Edit");
\r
2298 protected Menu viewMenu = new Menu("View");
\r
2299 protected Menu colourMenu = new Menu("Colour");
\r
2300 protected Menu calculateMenu = new Menu("Calculate");
\r
2301 protected MenuItem selectAllSequenceMenuItem = new MenuItem("Select all");
\r
2302 protected MenuItem deselectAllSequenceMenuItem = new MenuItem("Deselect All");
\r
2303 protected MenuItem invertSequenceMenuItem = new MenuItem("Invert Selection");
\r
2304 protected MenuItem remove2LeftMenuItem = new MenuItem();
\r
2305 protected MenuItem remove2RightMenuItem = new MenuItem();
\r
2306 protected MenuItem removeGappedColumnMenuItem = new MenuItem();
\r
2307 protected MenuItem removeAllGapsMenuItem = new MenuItem();
\r
2308 protected CheckboxMenuItem viewBoxesMenuItem = new CheckboxMenuItem();
\r
2309 protected CheckboxMenuItem viewTextMenuItem = new CheckboxMenuItem();
\r
2310 protected MenuItem sortPairwiseMenuItem = new MenuItem();
\r
2311 protected MenuItem sortIDMenuItem = new MenuItem();
\r
2312 protected MenuItem sortGroupMenuItem = new MenuItem();
\r
2313 protected MenuItem removeRedundancyMenuItem = new MenuItem();
\r
2314 protected MenuItem pairwiseAlignmentMenuItem = new MenuItem();
\r
2315 protected MenuItem PCAMenuItem = new MenuItem();
\r
2316 protected MenuItem averageDistanceTreeMenuItem = new MenuItem();
\r
2317 protected MenuItem neighbourTreeMenuItem = new MenuItem();
\r
2318 BorderLayout borderLayout1 = new BorderLayout();
\r
2319 public Label statusBar = new Label();
\r
2320 protected Menu outputTextboxMenu = new Menu();
\r
2321 protected MenuItem clustalColour = new MenuItem();
\r
2322 protected MenuItem zappoColour = new MenuItem();
\r
2323 protected MenuItem taylorColour = new MenuItem();
\r
2324 protected MenuItem hydrophobicityColour = new MenuItem();
\r
2325 protected MenuItem helixColour = new MenuItem();
\r
2326 protected MenuItem strandColour = new MenuItem();
\r
2327 protected MenuItem turnColour = new MenuItem();
\r
2328 protected MenuItem buriedColour = new MenuItem();
\r
2329 protected MenuItem userDefinedColour = new MenuItem();
\r
2330 protected MenuItem PIDColour = new MenuItem();
\r
2331 protected MenuItem BLOSUM62Colour = new MenuItem();
\r
2332 MenuItem njTreeBlosumMenuItem = new MenuItem();
\r
2333 MenuItem avDistanceTreeBlosumMenuItem = new MenuItem();
\r
2334 protected CheckboxMenuItem annotationPanelMenuItem = new CheckboxMenuItem();
\r
2335 protected CheckboxMenuItem colourTextMenuItem = new CheckboxMenuItem();
\r
2336 MenuItem overviewMenuItem = new MenuItem();
\r
2337 protected MenuItem undoMenuItem = new MenuItem();
\r
2338 protected MenuItem redoMenuItem = new MenuItem();
\r
2339 protected CheckboxMenuItem conservationMenuItem = new CheckboxMenuItem();
\r
2340 MenuItem noColourmenuItem = new MenuItem();
\r
2341 protected CheckboxMenuItem wrapMenuItem = new CheckboxMenuItem();
\r
2342 protected CheckboxMenuItem renderGapsMenuItem = new CheckboxMenuItem();
\r
2343 MenuItem findMenuItem = new MenuItem();
\r
2344 protected CheckboxMenuItem abovePIDThreshold = new CheckboxMenuItem();
\r
2345 protected MenuItem nucleotideColour = new MenuItem();
\r
2346 MenuItem deleteGroups = new MenuItem();
\r
2347 MenuItem delete = new MenuItem();
\r
2348 MenuItem copy = new MenuItem();
\r
2349 MenuItem cut = new MenuItem();
\r
2350 Menu pasteMenu = new Menu();
\r
2351 MenuItem pasteNew = new MenuItem();
\r
2352 MenuItem pasteThis = new MenuItem();
\r
2353 protected CheckboxMenuItem applyToAllGroups = new CheckboxMenuItem();
\r
2354 protected MenuItem font = new MenuItem();
\r
2355 protected CheckboxMenuItem scaleAbove = new CheckboxMenuItem();
\r
2356 protected CheckboxMenuItem scaleLeft = new CheckboxMenuItem();
\r
2357 protected CheckboxMenuItem scaleRight = new CheckboxMenuItem();
\r
2358 MenuItem modifyPID = new MenuItem();
\r
2359 MenuItem modifyConservation = new MenuItem();
\r
2360 protected CheckboxMenuItem autoCalculate
\r
2361 = new CheckboxMenuItem("Autocalculate Consensus", true);
\r
2362 protected Menu sortByTreeMenu = new Menu();
\r
2363 Menu sort = new Menu();
\r
2364 Menu calculate = new Menu();
\r
2365 MenuItem inputText = new MenuItem();
\r
2366 Menu helpMenu = new Menu();
\r
2367 MenuItem documentation = new MenuItem();
\r
2368 MenuItem about = new MenuItem();
\r
2369 protected CheckboxMenuItem seqLimits = new CheckboxMenuItem();
\r
2370 Panel embeddedMenu;
\r
2371 Label embeddedEdit;
\r
2372 Label embeddedSelect;
\r
2373 Label embeddedView;
\r
2374 Label embeddedFormat;
\r
2375 Label embeddedColour;
\r
2376 Label embeddedFile;
\r
2377 Label embeddedHelp;
\r
2378 Label embeddedCalculate;
\r
2379 FlowLayout flowLayout1;
\r
2381 private void jbInit()
\r
2385 setMenuBar(alignFrameMenuBar);
\r
2389 // dynamically fill save as menu with available formats
\r
2390 for (int i = 0; i < jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS.length;
\r
2394 item = new MenuItem(jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS[i]);
\r
2396 item.addActionListener(new java.awt.event.ActionListener()
\r
2398 public void actionPerformed(ActionEvent e)
\r
2400 outputText_actionPerformed(e);
\r
2404 outputTextboxMenu.add(item);
\r
2406 closeMenuItem.addActionListener(this);
\r
2407 loadApplication.addActionListener(this);
\r
2409 loadTree.addActionListener(this);
\r
2410 loadAnnotations.addActionListener(this);
\r
2411 outputFeatures.addActionListener(this);
\r
2412 outputAnnotations.addActionListener(this);
\r
2413 selectAllSequenceMenuItem.addActionListener(this);
\r
2414 deselectAllSequenceMenuItem.addActionListener(this);
\r
2415 invertSequenceMenuItem.addActionListener(this);
\r
2416 remove2LeftMenuItem.setLabel("Remove Left");
\r
2417 remove2LeftMenuItem.addActionListener(this);
\r
2418 remove2RightMenuItem.setLabel("Remove Right");
\r
2419 remove2RightMenuItem.addActionListener(this);
\r
2420 removeGappedColumnMenuItem.setLabel("Remove Empty Columns");
\r
2421 removeGappedColumnMenuItem.addActionListener(this);
\r
2422 removeAllGapsMenuItem.setLabel("Remove All Gaps");
\r
2423 removeAllGapsMenuItem.addActionListener(this);
\r
2424 viewBoxesMenuItem.setLabel("Boxes");
\r
2425 viewBoxesMenuItem.setState(true);
\r
2426 viewBoxesMenuItem.addItemListener(this);
\r
2427 viewTextMenuItem.setLabel("Text");
\r
2428 viewTextMenuItem.setState(true);
\r
2429 viewTextMenuItem.addItemListener(this);
\r
2430 sortPairwiseMenuItem.setLabel("by Pairwise Identity");
\r
2431 sortPairwiseMenuItem.addActionListener(this);
\r
2432 sortIDMenuItem.setLabel("by ID");
\r
2433 sortIDMenuItem.addActionListener(this);
\r
2434 sortGroupMenuItem.setLabel("by Group");
\r
2435 sortGroupMenuItem.addActionListener(this);
\r
2436 removeRedundancyMenuItem.setLabel("Remove Redundancy...");
\r
2437 removeRedundancyMenuItem.addActionListener(this);
\r
2438 pairwiseAlignmentMenuItem.setLabel("Pairwise Alignments...");
\r
2439 pairwiseAlignmentMenuItem.addActionListener(this);
\r
2440 PCAMenuItem.setLabel("Principal Component Analysis");
\r
2441 PCAMenuItem.addActionListener(this);
\r
2442 averageDistanceTreeMenuItem.setLabel(
\r
2443 "Average Distance Using % Identity");
\r
2444 averageDistanceTreeMenuItem.addActionListener(this);
\r
2445 neighbourTreeMenuItem.setLabel("Neighbour Joining Using % Identity");
\r
2446 neighbourTreeMenuItem.addActionListener(this);
\r
2447 statusBar.setBackground(Color.white);
\r
2448 statusBar.setFont(new java.awt.Font("Verdana", 0, 11));
\r
2449 statusBar.setText("Status bar");
\r
2450 outputTextboxMenu.setLabel("Output to Textbox");
\r
2451 clustalColour.setLabel("Clustalx");
\r
2453 clustalColour.addActionListener(this);
\r
2454 zappoColour.setLabel("Zappo");
\r
2455 zappoColour.addActionListener(this);
\r
2456 taylorColour.setLabel("Taylor");
\r
2457 taylorColour.addActionListener(this);
\r
2458 hydrophobicityColour.setLabel("Hydrophobicity");
\r
2459 hydrophobicityColour.addActionListener(this);
\r
2460 helixColour.setLabel("Helix Propensity");
\r
2461 helixColour.addActionListener(this);
\r
2462 strandColour.setLabel("Strand Propensity");
\r
2463 strandColour.addActionListener(this);
\r
2464 turnColour.setLabel("Turn Propensity");
\r
2465 turnColour.addActionListener(this);
\r
2466 buriedColour.setLabel("Buried Index");
\r
2467 buriedColour.addActionListener(this);
\r
2468 userDefinedColour.setLabel("User Defined...");
\r
2469 userDefinedColour.addActionListener(this);
\r
2470 PIDColour.setLabel("Percentage Identity");
\r
2471 PIDColour.addActionListener(this);
\r
2472 BLOSUM62Colour.setLabel("BLOSUM62 Score");
\r
2473 BLOSUM62Colour.addActionListener(this);
\r
2474 avDistanceTreeBlosumMenuItem.setLabel(
\r
2475 "Average Distance Using BLOSUM62");
\r
2476 avDistanceTreeBlosumMenuItem.addActionListener(this);
\r
2477 njTreeBlosumMenuItem.setLabel("Neighbour Joining Using BLOSUM62");
\r
2478 njTreeBlosumMenuItem.addActionListener(this);
\r
2479 annotationPanelMenuItem.setLabel("Show Annotations");
\r
2480 annotationPanelMenuItem.addItemListener(this);
\r
2481 colourTextMenuItem.setLabel("Colour Text");
\r
2482 colourTextMenuItem.addItemListener(this);
\r
2483 overviewMenuItem.setLabel("Overview Window");
\r
2484 overviewMenuItem.addActionListener(this);
\r
2485 undoMenuItem.setEnabled(false);
\r
2486 undoMenuItem.setLabel("Undo");
\r
2487 undoMenuItem.addActionListener(this);
\r
2488 redoMenuItem.setEnabled(false);
\r
2489 redoMenuItem.setLabel("Redo");
\r
2490 redoMenuItem.addActionListener(this);
\r
2491 conservationMenuItem.setLabel("by Conservation");
\r
2492 conservationMenuItem.addItemListener(this);
\r
2493 noColourmenuItem.setLabel("None");
\r
2494 noColourmenuItem.addActionListener(this);
\r
2495 wrapMenuItem.setLabel("Wrap");
\r
2496 wrapMenuItem.addItemListener(this);
\r
2497 renderGapsMenuItem.setLabel("Show Gaps");
\r
2498 renderGapsMenuItem.setState(true);
\r
2499 renderGapsMenuItem.addItemListener(this);
\r
2500 findMenuItem.setLabel("Find...");
\r
2501 findMenuItem.addActionListener(this);
\r
2502 abovePIDThreshold.setLabel("Above Identity Threshold");
\r
2503 abovePIDThreshold.addItemListener(this);
\r
2504 nucleotideColour.setLabel("Nucleotide");
\r
2505 nucleotideColour.addActionListener(this);
\r
2506 deleteGroups.setLabel("Undefine Groups");
\r
2507 deleteGroups.addActionListener(this);
\r
2508 copy.setLabel("Copy");
\r
2509 copy.addActionListener(this);
\r
2510 cut.setLabel("Cut");
\r
2511 cut.addActionListener(this);
\r
2512 delete.setLabel("Delete");
\r
2513 delete.addActionListener(this);
\r
2514 pasteMenu.setLabel("Paste");
\r
2515 pasteNew.setLabel("To New Alignment");
\r
2516 pasteNew.addActionListener(this);
\r
2517 pasteThis.setLabel("Add To This Alignment");
\r
2518 pasteThis.addActionListener(this);
\r
2519 applyToAllGroups.setLabel("Apply Colour To All Groups");
\r
2520 applyToAllGroups.setState(true);
\r
2521 applyToAllGroups.addItemListener(this);
\r
2522 font.setLabel("Font...");
\r
2523 font.addActionListener(this);
\r
2524 scaleAbove.setLabel("Scale Above");
\r
2525 scaleAbove.setState(true);
\r
2526 scaleAbove.setEnabled(false);
\r
2527 scaleAbove.addItemListener(this);
\r
2528 scaleLeft.setEnabled(false);
\r
2529 scaleLeft.setState(true);
\r
2530 scaleLeft.setLabel("Scale Left");
\r
2531 scaleLeft.addItemListener(this);
\r
2532 scaleRight.setEnabled(false);
\r
2533 scaleRight.setState(true);
\r
2534 scaleRight.setLabel("Scale Right");
\r
2535 scaleRight.addItemListener(this);
\r
2536 modifyPID.setLabel("Modify Identity Threshold...");
\r
2537 modifyPID.addActionListener(this);
\r
2538 modifyConservation.setLabel("Modify Conservation Threshold...");
\r
2539 modifyConservation.addActionListener(this);
\r
2540 sortByTreeMenu.setLabel("By Tree Order");
\r
2541 sort.setLabel("Sort");
\r
2542 calculate.setLabel("Calculate Tree");
\r
2543 autoCalculate.addItemListener(this);
\r
2544 inputText.setLabel("Input from textbox");
\r
2545 inputText.addActionListener(this);
\r
2547 helpMenu.setLabel("Help");
\r
2548 documentation.setLabel("Documentation");
\r
2549 documentation.addActionListener(this);
\r
2551 about.setLabel("About...");
\r
2552 about.addActionListener(this);
\r
2553 seqLimits.setState(true);
\r
2554 seqLimits.setLabel("Show Sequence Limits");
\r
2555 seqLimits.addItemListener(this);
\r
2556 featureSettings.setLabel("Feature Settings...");
\r
2557 featureSettings.addActionListener(this);
\r
2558 sequenceFeatures.setLabel("Sequence Features");
\r
2559 sequenceFeatures.addItemListener(this);
\r
2560 sequenceFeatures.setState(false);
\r
2561 annotationColour.setLabel("by Annotation...");
\r
2562 annotationColour.addActionListener(this);
\r
2563 invertSequenceMenuItem.setLabel("Invert Sequence Selection");
\r
2564 invertColSel.setLabel("Invert Column Selection");
\r
2565 menu1.setLabel("Show");
\r
2566 showColumns.setLabel("All Columns ");
\r
2567 showSeqs.setLabel("All Sequences");
\r
2568 menu2.setLabel("Hide");
\r
2569 hideColumns.setLabel("Selected Columns");
\r
2570 hideSequences.setLabel("Selected Sequences");
\r
2571 invertColSel.addActionListener(this);
\r
2572 showColumns.addActionListener(this);
\r
2573 showSeqs.addActionListener(this);
\r
2574 hideColumns.addActionListener(this);
\r
2575 hideSequences.addActionListener(this);
\r
2576 formatMenu.setLabel("Format");
\r
2577 selectMenu.setLabel("Select");
\r
2578 newView.setLabel("New View");
\r
2579 newView.addActionListener(this);
\r
2580 alignFrameMenuBar.add(fileMenu);
\r
2581 alignFrameMenuBar.add(editMenu);
\r
2582 alignFrameMenuBar.add(selectMenu);
\r
2583 alignFrameMenuBar.add(viewMenu);
\r
2584 alignFrameMenuBar.add(formatMenu);
\r
2585 alignFrameMenuBar.add(colourMenu);
\r
2586 alignFrameMenuBar.add(calculateMenu);
\r
2587 alignFrameMenuBar.add(helpMenu);
\r
2589 fileMenu.add(inputText);
\r
2590 fileMenu.add(loadTree);
\r
2591 fileMenu.add(loadAnnotations);
\r
2593 fileMenu.addSeparator();
\r
2594 fileMenu.add(outputTextboxMenu);
\r
2595 fileMenu.add(outputFeatures);
\r
2596 fileMenu.add(outputAnnotations);
\r
2598 if (jalviewServletURL != null)
\r
2600 fileMenu.add(loadApplication);
\r
2603 fileMenu.addSeparator();
\r
2604 fileMenu.add(closeMenuItem);
\r
2606 editMenu.add(undoMenuItem);
\r
2607 editMenu.add(redoMenuItem);
\r
2608 editMenu.add(cut);
\r
2609 editMenu.add(copy);
\r
2610 editMenu.add(pasteMenu);
\r
2611 editMenu.add(delete);
\r
2612 editMenu.addSeparator();
\r
2613 editMenu.add(remove2LeftMenuItem);
\r
2614 editMenu.add(remove2RightMenuItem);
\r
2615 editMenu.add(removeGappedColumnMenuItem);
\r
2616 editMenu.add(removeAllGapsMenuItem);
\r
2617 editMenu.add(removeRedundancyMenuItem);
\r
2618 viewMenu.add(newView);
\r
2619 viewMenu.addSeparator();
\r
2620 viewMenu.add(menu1);
\r
2621 viewMenu.add(menu2);
\r
2622 viewMenu.addSeparator();
\r
2623 viewMenu.add(annotationPanelMenuItem);
\r
2624 viewMenu.addSeparator();
\r
2625 viewMenu.add(sequenceFeatures);
\r
2626 viewMenu.add(featureSettings);
\r
2627 viewMenu.addSeparator();
\r
2628 viewMenu.add(overviewMenuItem);
\r
2629 colourMenu.add(applyToAllGroups);
\r
2630 colourMenu.addSeparator();
\r
2631 colourMenu.add(noColourmenuItem);
\r
2632 colourMenu.add(clustalColour);
\r
2633 colourMenu.add(BLOSUM62Colour);
\r
2634 colourMenu.add(PIDColour);
\r
2635 colourMenu.add(zappoColour);
\r
2636 colourMenu.add(taylorColour);
\r
2637 colourMenu.add(hydrophobicityColour);
\r
2638 colourMenu.add(helixColour);
\r
2639 colourMenu.add(strandColour);
\r
2640 colourMenu.add(turnColour);
\r
2641 colourMenu.add(buriedColour);
\r
2642 colourMenu.add(nucleotideColour);
\r
2643 colourMenu.add(userDefinedColour);
\r
2644 colourMenu.addSeparator();
\r
2645 colourMenu.add(conservationMenuItem);
\r
2646 colourMenu.add(modifyConservation);
\r
2647 colourMenu.add(abovePIDThreshold);
\r
2648 colourMenu.add(modifyPID);
\r
2649 colourMenu.add(annotationColour);
\r
2650 calculateMenu.add(sort);
\r
2651 calculateMenu.add(calculate);
\r
2652 calculateMenu.addSeparator();
\r
2653 calculateMenu.add(pairwiseAlignmentMenuItem);
\r
2654 calculateMenu.add(PCAMenuItem);
\r
2655 calculateMenu.add(autoCalculate);
\r
2656 this.add(statusBar, BorderLayout.SOUTH);
\r
2657 pasteMenu.add(pasteNew);
\r
2658 pasteMenu.add(pasteThis);
\r
2659 sort.add(sortIDMenuItem);
\r
2660 sort.add(sortByTreeMenu);
\r
2661 sort.add(sortGroupMenuItem);
\r
2662 sort.add(sortPairwiseMenuItem);
\r
2663 calculate.add(averageDistanceTreeMenuItem);
\r
2664 calculate.add(neighbourTreeMenuItem);
\r
2665 calculate.add(avDistanceTreeBlosumMenuItem);
\r
2666 calculate.add(njTreeBlosumMenuItem);
\r
2667 helpMenu.add(documentation);
\r
2668 helpMenu.add(about);
\r
2669 menu1.add(showColumns);
\r
2670 menu1.add(showSeqs);
\r
2671 menu2.add(hideColumns);
\r
2672 menu2.add(hideSequences);
\r
2673 formatMenu.add(font);
\r
2674 formatMenu.add(seqLimits);
\r
2675 formatMenu.add(wrapMenuItem);
\r
2676 formatMenu.add(scaleAbove);
\r
2677 formatMenu.add(scaleLeft);
\r
2678 formatMenu.add(scaleRight);
\r
2679 formatMenu.add(viewBoxesMenuItem);
\r
2680 formatMenu.add(viewTextMenuItem);
\r
2681 formatMenu.add(colourTextMenuItem);
\r
2682 formatMenu.add(renderGapsMenuItem);
\r
2683 selectMenu.add(findMenuItem);
\r
2684 selectMenu.addSeparator();
\r
2685 selectMenu.add(selectAllSequenceMenuItem);
\r
2686 selectMenu.add(deselectAllSequenceMenuItem);
\r
2687 selectMenu.add(invertSequenceMenuItem);
\r
2688 selectMenu.add(invertColSel);
\r
2689 selectMenu.add(deleteGroups);
\r
2692 public void setEmbedded()
\r
2695 embeddedMenu = new Panel();
\r
2696 embeddedEdit = new Label("Edit");
\r
2697 embeddedSelect = new Label("Select");
\r
2698 embeddedView = new Label("View");
\r
2699 embeddedFormat = new Label("Format");
\r
2700 embeddedColour = new Label("Colour");
\r
2701 embeddedFile = new Label("File");
\r
2702 embeddedHelp = new Label("Help");
\r
2703 embeddedCalculate = new Label("Calculate");
\r
2704 flowLayout1 = new FlowLayout();
\r
2705 embeddedMenu.setBackground(Color.lightGray);
\r
2706 embeddedMenu.setLayout(flowLayout1);
\r
2707 embeddedEdit.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
\r
2708 embeddedSelect.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
\r
2709 embeddedView.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
\r
2710 embeddedFormat.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
\r
2711 embeddedColour.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
\r
2712 embeddedFile.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
\r
2713 embeddedHelp.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
\r
2714 embeddedCalculate.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
\r
2715 embeddedMenu.add(embeddedFile);
\r
2716 embeddedMenu.add(embeddedEdit);
\r
2717 embeddedMenu.add(embeddedSelect);
\r
2718 embeddedMenu.add(embeddedView);
\r
2719 embeddedMenu.add(embeddedFormat);
\r
2720 embeddedMenu.add(embeddedColour);
\r
2721 embeddedMenu.add(embeddedCalculate);
\r
2722 embeddedMenu.add(embeddedHelp);
\r
2723 flowLayout1.setAlignment(FlowLayout.LEFT);
\r
2724 flowLayout1.setHgap(2);
\r
2725 flowLayout1.setVgap(0);
\r
2726 embeddedFile.addMouseListener(this);
\r
2727 embeddedEdit.addMouseListener(this);
\r
2728 embeddedSelect.addMouseListener(this);
\r
2729 embeddedView.addMouseListener(this);
\r
2730 embeddedFormat.addMouseListener(this);
\r
2731 embeddedColour.addMouseListener(this);
\r
2732 embeddedCalculate.addMouseListener(this);
\r
2733 embeddedHelp.addMouseListener(this);
\r
2735 fileMenu.remove(closeMenuItem);
\r
2736 fileMenu.remove(3); // Seperator
\r
2738 viewport.applet.setLayout(new BorderLayout());
\r
2739 viewport.applet.add(embeddedMenu, BorderLayout.NORTH);
\r
2740 viewport.applet.add(statusBar, BorderLayout.SOUTH);
\r
2742 alignPanel.setSize(viewport.applet.getSize().width,
\r
2743 viewport.applet.getSize().height
\r
2744 - embeddedMenu.HEIGHT - statusBar.HEIGHT);
\r
2746 viewport.applet.add(alignPanel, BorderLayout.CENTER);
\r
2747 viewport.applet.validate();
\r
2751 PopupMenu filePopup, editPopup, searchPopup,
\r
2752 viewPopup, formatPopup, colourPopup, calculatePopup, helpPopup;
\r
2753 MenuItem featureSettings = new MenuItem();
\r
2754 CheckboxMenuItem sequenceFeatures = new CheckboxMenuItem();
\r
2755 MenuItem annotationColour = new MenuItem();
\r
2756 MenuItem invertColSel = new MenuItem();
\r
2757 Menu menu1 = new Menu();
\r
2758 MenuItem showColumns = new MenuItem();
\r
2759 MenuItem showSeqs = new MenuItem();
\r
2760 Menu menu2 = new Menu();
\r
2761 MenuItem hideColumns = new MenuItem();
\r
2762 MenuItem hideSequences = new MenuItem();
\r
2763 Menu formatMenu = new Menu();
\r
2764 Menu selectMenu = new Menu();
\r
2765 MenuItem newView = new MenuItem();
\r
2767 public void mousePressed(MouseEvent evt)
\r
2769 PopupMenu popup = null;
\r
2770 Label source = (Label) evt.getSource();
\r
2771 if (source == embeddedFile)
\r
2773 popup = filePopup = genPopupMenu(filePopup, fileMenu);
\r
2775 else if (source == embeddedEdit)
\r
2777 popup = editPopup = genPopupMenu(editPopup, editMenu);
\r
2779 else if (source == embeddedSelect)
\r
2781 popup = searchPopup = genPopupMenu(searchPopup, selectMenu);
\r
2783 else if (source == embeddedView)
\r
2785 popup = viewPopup = genPopupMenu(viewPopup, viewMenu);
\r
2787 else if (source == embeddedFormat)
\r
2789 popup = formatPopup = genPopupMenu(formatPopup, formatMenu);
\r
2791 else if (source == embeddedColour)
\r
2793 popup = colourPopup = genPopupMenu(colourPopup, colourMenu);
\r
2795 else if (source == embeddedCalculate)
\r
2797 popup = calculatePopup = genPopupMenu(calculatePopup, calculateMenu);
\r
2799 else if (source == embeddedHelp)
\r
2801 popup = helpPopup = genPopupMenu(helpPopup, helpMenu);
\r
2804 embeddedMenu.add(popup);
\r
2805 popup.show(embeddedMenu,
\r
2806 source.getBounds().x,
\r
2807 source.getBounds().y + source.getBounds().getSize().height);
\r
2810 PopupMenu genPopupMenu(PopupMenu popup, Menu original)
\r
2812 if (popup != null)
\r
2816 popup = new PopupMenu();
\r
2817 int m, mSize = original.getItemCount();
\r
2818 for (m = 0; m < mSize; m++)
\r
2820 popup.add(original.getItem(m));
\r
2828 public void mouseClicked(MouseEvent evt)
\r
2831 public void mouseReleased(MouseEvent evt)
\r
2834 public void mouseEntered(MouseEvent evt)
\r
2837 public void mouseExited(MouseEvent evt)
\r