2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2005 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
22 import jalview.schemes.*;
\r
23 import jalview.datamodel.*;
\r
24 import jalview.analysis.*;
\r
25 import jalview.io.*;
\r
27 import java.awt.event.*;
\r
29 import java.io.InputStreamReader;
\r
30 import java.io.BufferedReader;
\r
31 import java.net.URL;
\r
34 public class AlignFrame extends Frame implements ActionListener,
\r
35 ItemListener, KeyListener, MouseListener
\r
37 public AlignmentPanel alignPanel;
\r
38 public AlignViewport viewport;
\r
39 int NEW_WINDOW_WIDTH = 700;
\r
40 int NEW_WINDOW_HEIGHT = 500;
\r
42 String jalviewServletURL;
\r
45 public AlignFrame(AlignmentI al,
\r
46 jalview.bin.JalviewLite applet,
\r
51 jalviewServletURL = applet.getParameter("APPLICATION_URL");
\r
55 }catch(Exception ex)
\r
57 ex.printStackTrace();
\r
60 viewport = new AlignViewport(al, applet);
\r
61 alignPanel = new AlignmentPanel(this, viewport);
\r
63 annotationPanelMenuItem.setState(viewport.showAnnotation);
\r
65 seqLimits.setState(viewport.showJVSuffix);
\r
69 String param = applet.getParameter("sortBy");
\r
72 if (param.equalsIgnoreCase("Id"))
\r
73 sortIDMenuItem_actionPerformed();
\r
74 else if (param.equalsIgnoreCase("Pairwise Identity"))
\r
75 sortPairwiseMenuItem_actionPerformed();
\r
78 param = applet.getParameter("wrap");
\r
81 if (param.equalsIgnoreCase("true"))
\r
83 wrapMenuItem.setState(true);
\r
84 wrapMenuItem_actionPerformed();
\r
90 param = applet.getParameter("windowWidth");
\r
93 int width = Integer.parseInt(param);
\r
94 NEW_WINDOW_WIDTH = width;
\r
96 param = applet.getParameter("windowHeight");
\r
99 int height = Integer.parseInt(param);
\r
100 NEW_WINDOW_HEIGHT = height;
\r
103 catch (Exception ex)
\r
108 //Some JVMS send keyevents to Top frame or lowest panel,
\r
109 //Havent worked out why yet. So add to both this frame and seqCanvas for now
\r
110 this.addKeyListener(this);
\r
111 alignPanel.seqPanel.seqCanvas.addKeyListener(this);
\r
112 alignPanel.idPanel.idCanvas.addKeyListener(this);
\r
114 viewport.addPropertyChangeListener(new java.beans.PropertyChangeListener()
\r
116 public void propertyChange(java.beans.PropertyChangeEvent evt)
\r
118 if (evt.getPropertyName().equals("alignment"))
\r
120 alignmentChanged();
\r
132 add(alignPanel, BorderLayout.CENTER);
\r
133 jalview.bin.JalviewLite.addFrame(this, title, NEW_WINDOW_WIDTH,
\r
134 NEW_WINDOW_HEIGHT);
\r
136 alignPanel.validate();
\r
137 alignPanel.repaint();
\r
139 public AlignViewport getAlignViewport()
\r
144 public SeqCanvas getSeqcanvas()
\r
146 return alignPanel.seqPanel.seqCanvas;
\r
153 * @param String DOCUMENT ME!
\r
156 public void parseFeaturesFile(String file, String type)
\r
158 Hashtable featureLinks = new Hashtable();
\r
159 boolean featuresFile = false;
\r
161 featuresFile = new jalview.io.FeaturesFile(file, type).parse(viewport.alignment,
\r
162 alignPanel.seqPanel.seqCanvas.
\r
163 getFeatureRenderer().featureColours,
\r
167 catch(Exception ex)
\r
169 ex.printStackTrace();
\r
174 if(featureLinks.size()>0)
\r
175 alignPanel.seqPanel.seqCanvas
\r
176 .getFeatureRenderer().featureLinks = featureLinks;
\r
177 viewport.showSequenceFeatures = true;
\r
178 sequenceFeatures.setState(true);
\r
179 alignPanel.repaint();
\r
185 public void keyPressed(KeyEvent evt)
\r
187 if (viewport.cursorMode
\r
188 && evt.getKeyCode() >= KeyEvent.VK_0
\r
189 && evt.getKeyCode() <= KeyEvent.VK_9)
\r
191 alignPanel.seqPanel.numberPressed(evt.getKeyChar());
\r
194 switch (evt.getKeyCode())
\r
196 case 27: // escape key
\r
197 deselectAllSequenceMenuItem_actionPerformed();
\r
199 case KeyEvent.VK_X:
\r
200 if (evt.isControlDown() || evt.isMetaDown())
\r
202 cut_actionPerformed();
\r
205 case KeyEvent.VK_C:
\r
206 if (viewport.cursorMode && !evt.isControlDown())
\r
208 alignPanel.seqPanel.setCursorColumn();
\r
210 if (evt.isControlDown() || evt.isMetaDown())
\r
212 copy_actionPerformed();
\r
215 case KeyEvent.VK_V:
\r
216 if (evt.isControlDown() || evt.isMetaDown())
\r
221 case KeyEvent.VK_A:
\r
222 if (evt.isControlDown() || evt.isMetaDown())
\r
224 selectAllSequenceMenuItem_actionPerformed();
\r
227 case KeyEvent.VK_DOWN:
\r
228 if(viewport.cursorMode)
\r
230 alignPanel.seqPanel.moveCursor(0,1);
\r
233 moveSelectedSequences(false);
\r
236 case KeyEvent.VK_UP:
\r
237 if (viewport.cursorMode)
\r
239 alignPanel.seqPanel.moveCursor(0,-1);
\r
242 moveSelectedSequences(true);
\r
245 case KeyEvent.VK_LEFT:
\r
246 if(viewport.cursorMode)
\r
248 alignPanel.seqPanel.moveCursor(-1,0);
\r
252 case KeyEvent.VK_RIGHT:
\r
253 if (viewport.cursorMode)
\r
255 alignPanel.seqPanel.moveCursor(1,0);
\r
258 case KeyEvent.VK_SPACE:
\r
259 if(viewport.cursorMode)
\r
261 alignPanel.seqPanel.insertGapAtCursor(evt.isControlDown());
\r
265 case KeyEvent.VK_DELETE:
\r
266 case KeyEvent.VK_BACK_SPACE:
\r
267 if(viewport.cursorMode)
\r
269 alignPanel.seqPanel.deleteGapAtCursor(evt.isControlDown());
\r
273 cut_actionPerformed();
\r
274 alignPanel.seqPanel.seqCanvas.repaint();
\r
278 case KeyEvent.VK_S:
\r
279 if(viewport.cursorMode)
\r
281 alignPanel.seqPanel.setCursorRow();
\r
284 case KeyEvent.VK_P:
\r
285 if(viewport.cursorMode)
\r
287 alignPanel.seqPanel.setCursorPosition();
\r
291 case KeyEvent.VK_ENTER:
\r
292 case KeyEvent.VK_COMMA:
\r
293 if(viewport.cursorMode)
\r
295 alignPanel.seqPanel.setCursorRowAndColumn();
\r
299 case KeyEvent.VK_Q:
\r
300 if(viewport.cursorMode)
\r
302 alignPanel.seqPanel.setSelectionAreaAtCursor(true);
\r
305 case KeyEvent.VK_M:
\r
306 if(viewport.cursorMode)
\r
308 alignPanel.seqPanel.setSelectionAreaAtCursor(false);
\r
312 case KeyEvent.VK_F2:
\r
313 viewport.cursorMode = ! viewport.cursorMode;
\r
314 statusBar.setText("Keyboard editing mode is "+
\r
315 (viewport.cursorMode ? "on" : "off"));
\r
316 if(viewport.cursorMode)
\r
318 alignPanel.seqPanel.seqCanvas.cursorX = viewport.startRes;
\r
319 alignPanel.seqPanel.seqCanvas.cursorY = viewport.startSeq;
\r
321 alignPanel.seqPanel.seqCanvas.repaint();
\r
324 case KeyEvent.VK_F:
\r
325 if (evt.isControlDown())
\r
327 findMenuItem_actionPerformed();
\r
332 public void keyReleased(KeyEvent evt)
\r
334 public void keyTyped(KeyEvent evt)
\r
337 public void itemStateChanged(ItemEvent evt)
\r
339 if(evt.getSource()==colourTextMenuItem)
\r
340 colourTextMenuItem_actionPerformed();
\r
341 else if(evt.getSource()==wrapMenuItem)
\r
342 wrapMenuItem_actionPerformed();
\r
343 else if(evt.getSource()==scaleAbove)
\r
344 scaleAbove_actionPerformed();
\r
345 else if(evt.getSource()==scaleLeft)
\r
346 scaleLeft_actionPerformed();
\r
347 else if(evt.getSource()==scaleRight)
\r
348 scaleRight_actionPerformed();
\r
349 else if(evt.getSource()==seqLimits)
\r
350 seqLimits_itemStateChanged();
\r
351 else if(evt.getSource()==viewBoxesMenuItem)
\r
352 viewBoxesMenuItem_actionPerformed();
\r
353 else if(evt.getSource()==viewTextMenuItem)
\r
354 viewTextMenuItem_actionPerformed();
\r
355 else if(evt.getSource()==renderGapsMenuItem)
\r
356 renderGapsMenuItem_actionPerformed();
\r
357 else if(evt.getSource()==annotationPanelMenuItem)
\r
358 annotationPanelMenuItem_actionPerformed();
\r
359 else if(evt.getSource()==sequenceFeatures)
\r
361 viewport.showSequenceFeatures(sequenceFeatures.getState());
\r
362 alignPanel.seqPanel.seqCanvas.repaint();
\r
364 else if(evt.getSource()==conservationMenuItem)
\r
365 conservationMenuItem_actionPerformed();
\r
366 else if(evt.getSource()==abovePIDThreshold)
\r
367 abovePIDThreshold_actionPerformed();
\r
368 else if(evt.getSource()==applyToAllGroups)
\r
369 applyToAllGroups_actionPerformed();
\r
370 else if(evt.getSource()==autoCalculate)
\r
371 viewport.autocalculateConsensus = autoCalculate.getState();
\r
373 public void actionPerformed(ActionEvent evt)
\r
375 Object source = evt.getSource();
\r
377 if(source==inputText)
\r
378 inputText_actionPerformed();
\r
379 else if(source==loadTree)
\r
380 loadTree_actionPerformed();
\r
381 else if(source==loadApplication)
\r
382 launchFullApplication();
\r
383 else if(source==closeMenuItem)
\r
384 closeMenuItem_actionPerformed();
\r
385 else if(source==copy)
\r
386 copy_actionPerformed();
\r
387 else if(source==undoMenuItem)
\r
388 undoMenuItem_actionPerformed();
\r
389 else if(source==redoMenuItem)
\r
390 redoMenuItem_actionPerformed();
\r
391 else if(source==inputText)
\r
392 inputText_actionPerformed();
\r
393 else if(source==closeMenuItem)
\r
394 closeMenuItem_actionPerformed();
\r
395 else if(source==undoMenuItem)
\r
396 undoMenuItem_actionPerformed();
\r
397 else if(source==redoMenuItem)
\r
398 redoMenuItem_actionPerformed();
\r
399 else if(source==copy)
\r
400 copy_actionPerformed();
\r
401 else if(source==pasteNew)
\r
402 pasteNew_actionPerformed();
\r
403 else if(source==pasteThis)
\r
404 pasteThis_actionPerformed();
\r
405 else if(source==cut)
\r
406 cut_actionPerformed();
\r
407 else if(source==delete)
\r
408 delete_actionPerformed();
\r
409 else if(source==deleteGroups)
\r
410 deleteGroups_actionPerformed();
\r
411 else if(source==selectAllSequenceMenuItem)
\r
412 selectAllSequenceMenuItem_actionPerformed();
\r
413 else if(source==deselectAllSequenceMenuItem)
\r
414 deselectAllSequenceMenuItem_actionPerformed();
\r
415 else if(source==invertSequenceMenuItem)
\r
416 invertSequenceMenuItem_actionPerformed();
\r
417 else if(source==invertColSel)
\r
418 { viewport.invertColumnSelection(); alignPanel.repaint(); }
\r
419 else if(source==remove2LeftMenuItem)
\r
420 remove2LeftMenuItem_actionPerformed();
\r
421 else if(source==remove2RightMenuItem)
\r
422 remove2RightMenuItem_actionPerformed();
\r
423 else if(source==removeGappedColumnMenuItem)
\r
424 removeGappedColumnMenuItem_actionPerformed();
\r
425 else if(source==removeAllGapsMenuItem)
\r
426 removeAllGapsMenuItem_actionPerformed();
\r
427 else if(source==findMenuItem)
\r
428 findMenuItem_actionPerformed();
\r
429 else if(source==font)
\r
430 font_actionPerformed();
\r
431 else if(source==showColumns)
\r
433 viewport.showAllHiddenColumns(); alignPanel.repaint();
\r
435 else if(source==showSeqs)
\r
437 viewport.showAllHiddenSeqs(); alignPanel.repaint();
\r
439 else if(source == hideColumns)
\r
441 viewport.hideSelectedColumns(); alignPanel.repaint();
\r
443 else if(source == hideSequences && viewport.getSelectionGroup()!=null)
\r
445 SequenceI[] seqs = viewport.getSelectionGroup().getSequencesInOrder(
\r
449 for (int i = 0; i < seqs.length; i++)
\r
451 viewport.hideSequence(seqs[i]);
\r
454 alignPanel.repaint();
\r
456 else if(source==featureSettings)
\r
457 featureSettings_actionPerformed();
\r
458 else if(source==overviewMenuItem)
\r
459 overviewMenuItem_actionPerformed();
\r
460 else if(source==noColourmenuItem)
\r
461 noColourmenuItem_actionPerformed();
\r
462 else if(source==clustalColour)
\r
463 clustalColour_actionPerformed();
\r
464 else if(source==zappoColour)
\r
465 zappoColour_actionPerformed();
\r
466 else if(source==taylorColour)
\r
467 taylorColour_actionPerformed();
\r
468 else if(source==hydrophobicityColour)
\r
469 hydrophobicityColour_actionPerformed();
\r
470 else if(source==helixColour)
\r
471 helixColour_actionPerformed();
\r
472 else if(source==strandColour)
\r
473 strandColour_actionPerformed();
\r
474 else if(source==turnColour)
\r
475 turnColour_actionPerformed();
\r
476 else if(source==buriedColour)
\r
477 buriedColour_actionPerformed();
\r
478 else if(source==nucleotideColour)
\r
479 nucleotideColour_actionPerformed();
\r
480 else if(source==modifyPID)
\r
481 modifyPID_actionPerformed();
\r
482 else if(source==modifyConservation)
\r
483 modifyConservation_actionPerformed();
\r
484 else if(source==userDefinedColour)
\r
485 userDefinedColour_actionPerformed();
\r
486 else if(source==PIDColour)
\r
487 PIDColour_actionPerformed();
\r
488 else if(source==BLOSUM62Colour)
\r
489 BLOSUM62Colour_actionPerformed();
\r
490 else if(source==annotationColour)
\r
491 new AnnotationColourChooser(viewport, alignPanel);
\r
492 else if(source==sortPairwiseMenuItem)
\r
493 sortPairwiseMenuItem_actionPerformed();
\r
494 else if(source==sortIDMenuItem)
\r
495 sortIDMenuItem_actionPerformed();
\r
496 else if(source==sortGroupMenuItem)
\r
497 sortGroupMenuItem_actionPerformed();
\r
498 else if(source==removeRedundancyMenuItem)
\r
499 removeRedundancyMenuItem_actionPerformed();
\r
500 else if(source==pairwiseAlignmentMenuItem)
\r
501 pairwiseAlignmentMenuItem_actionPerformed();
\r
502 else if(source==PCAMenuItem)
\r
503 PCAMenuItem_actionPerformed();
\r
504 else if(source==averageDistanceTreeMenuItem)
\r
505 averageDistanceTreeMenuItem_actionPerformed();
\r
506 else if(source==neighbourTreeMenuItem)
\r
507 neighbourTreeMenuItem_actionPerformed();
\r
508 else if(source==njTreeBlosumMenuItem)
\r
509 njTreeBlosumMenuItem_actionPerformed();
\r
510 else if(source==avDistanceTreeBlosumMenuItem)
\r
511 avTreeBlosumMenuItem_actionPerformed();
\r
512 else if(source==documentation)
\r
513 documentation_actionPerformed();
\r
514 else if(source==about)
\r
515 about_actionPerformed();
\r
519 public void inputText_actionPerformed()
\r
521 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
\r
522 Frame frame = new Frame();
\r
524 jalview.bin.JalviewLite.addFrame(frame, "Cut & Paste Input", 500, 500);
\r
527 protected void outputText_actionPerformed(ActionEvent e)
\r
529 CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this);
\r
530 Frame frame = new Frame();
\r
532 jalview.bin.JalviewLite.addFrame(frame,
\r
533 "Alignment output - " + e.getActionCommand(),
\r
535 cap.setText(new AppletFormatAdapter().formatSequences(e.getActionCommand(),
\r
536 viewport.getAlignment().getSequences(),
\r
537 viewport.showJVSuffix));
\r
540 void launchFullApplication()
\r
542 StringBuffer url = new StringBuffer(jalviewServletURL);
\r
544 url.append("?open="+
\r
545 appendProtocol( viewport.applet.getParameter("file") ) );
\r
547 if(viewport.applet.getParameter("features")!=null)
\r
549 url.append( "&features=" );
\r
550 url.append( appendProtocol( viewport.applet.getParameter("features") ) );
\r
553 if(viewport.applet.getParameter("annotations")!=null)
\r
555 url.append( "&annotations=" );
\r
556 url.append( appendProtocol( viewport.applet.getParameter("annotations") ) );
\r
559 if(viewport.applet.getParameter("defaultColour")!=null)
\r
561 url.append("&colour=" +
\r
562 removeWhiteSpace(viewport.applet.getParameter("defaultColour"))
\r
566 if(viewport.applet.getParameter("userDefinedColour")!=null)
\r
568 url.append( "&colour=" +
\r
569 removeWhiteSpace( viewport.applet.getParameter("userDefinedColour") )
\r
573 showURL(url.toString(), "FULL_APP");
\r
577 String removeWhiteSpace(String colour)
\r
579 StringBuffer sb = new StringBuffer();
\r
580 for (int i = 0; i < colour.length(); i++)
\r
582 if (Character.isWhitespace(colour.charAt(i)))
\r
585 sb.append(colour.charAt(i));
\r
588 return sb.toString();
\r
592 String appendProtocol(String url)
\r
596 }catch(java.net.MalformedURLException ex)
\r
598 url = viewport.applet.getCodeBase()+url;
\r
603 public void closeMenuItem_actionPerformed()
\r
605 PaintRefresher.components.remove(viewport.alignment);
\r
606 if(PaintRefresher.components.size()==0 && viewport.applet==null)
\r
612 Stack historyList = new Stack();
\r
613 Stack redoList = new Stack();
\r
615 void updateEditMenuBar()
\r
617 if (historyList.size() > 0)
\r
619 undoMenuItem.setEnabled(true);
\r
620 HistoryItem hi = (HistoryItem) historyList.peek();
\r
621 undoMenuItem.setLabel("Undo " + hi.getDescription());
\r
625 undoMenuItem.setEnabled(false);
\r
626 undoMenuItem.setLabel("Undo");
\r
629 if (redoList.size() > 0)
\r
631 redoMenuItem.setEnabled(true);
\r
632 HistoryItem hi = (HistoryItem) redoList.peek();
\r
633 redoMenuItem.setLabel("Redo " + hi.getDescription());
\r
637 redoMenuItem.setEnabled(false);
\r
638 redoMenuItem.setLabel("Redo");
\r
642 public void addHistoryItem(HistoryItem hi)
\r
644 historyList.push(hi);
\r
645 updateEditMenuBar();
\r
648 protected void undoMenuItem_actionPerformed()
\r
650 HistoryItem hi = (HistoryItem) historyList.pop();
\r
651 redoList.push(new HistoryItem(hi.getDescription(), viewport.alignment,
\r
652 HistoryItem.HIDE));
\r
653 restoreHistoryItem(hi);
\r
654 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
\r
657 protected void redoMenuItem_actionPerformed()
\r
659 HistoryItem hi = (HistoryItem) redoList.pop();
\r
660 restoreHistoryItem(hi);
\r
661 updateEditMenuBar();
\r
662 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
\r
665 // used by undo and redo
\r
666 void restoreHistoryItem(HistoryItem hi)
\r
670 updateEditMenuBar();
\r
672 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
\r
675 public void moveSelectedSequences(boolean up)
\r
677 SequenceGroup sg = viewport.getSelectionGroup();
\r
685 for (int i = 1; i < viewport.alignment.getHeight(); i++)
\r
687 SequenceI seq = viewport.alignment.getSequenceAt(i);
\r
688 if (!sg.getSequences(false).contains(seq))
\r
693 SequenceI temp = viewport.alignment.getSequenceAt(i - 1);
\r
694 if (sg.getSequences(false).contains(temp))
\r
699 viewport.alignment.getSequences().setElementAt(temp, i);
\r
700 viewport.alignment.getSequences().setElementAt(seq, i - 1);
\r
705 for (int i = viewport.alignment.getHeight() - 2; i > -1; i--)
\r
707 SequenceI seq = viewport.alignment.getSequenceAt(i);
\r
708 if (!sg.getSequences(true).contains(seq))
\r
713 SequenceI temp = viewport.alignment.getSequenceAt(i + 1);
\r
714 if (sg.getSequences(true).contains(temp))
\r
719 viewport.alignment.getSequences().setElementAt(temp, i);
\r
720 viewport.alignment.getSequences().setElementAt(seq, i + 1);
\r
724 alignPanel.repaint();
\r
727 static StringBuffer copiedSequences;
\r
728 static Vector copiedHiddenColumns;
\r
729 protected void copy_actionPerformed()
\r
731 if (viewport.getSelectionGroup() == null)
\r
736 SequenceGroup sg = viewport.getSelectionGroup();
\r
737 copiedSequences = new StringBuffer();
\r
738 Hashtable orderedSeqs = new Hashtable();
\r
739 for (int i = 0; i < sg.getSize(false); i++)
\r
741 SequenceI seq = sg.getSequenceAt(i);
\r
742 int index = viewport.alignment.findIndex(seq);
\r
743 orderedSeqs.put(index + "", seq);
\r
746 int index = 0, startRes, endRes;
\r
749 if (viewport.hasHiddenColumns && viewport.getSelectionGroup() != null)
\r
751 copiedHiddenColumns = new Vector();
\r
752 int hiddenOffset = viewport.getSelectionGroup().getStartRes();
\r
753 for (int i = 0; i < viewport.getColumnSelection().getHiddenColumns().size();
\r
756 int[] region = (int[])
\r
757 viewport.getColumnSelection().getHiddenColumns().elementAt(i);
\r
759 copiedHiddenColumns.addElement(new int[]
\r
760 {region[0] - hiddenOffset,
\r
761 region[1] - hiddenOffset});
\r
765 copiedHiddenColumns = null;
\r
768 for (int i = 0; i < sg.getSize(false); i++)
\r
770 SequenceI seq = null;
\r
772 while (seq == null)
\r
774 if (orderedSeqs.containsKey(index + ""))
\r
776 seq = (SequenceI) orderedSeqs.get(index + "");
\r
788 //Returns residue following index if gap
\r
789 startRes = seq.findPosition(sg.getStartRes());
\r
792 //Need to find the residue preceeding index if gap
\r
795 for (int j = 0; j < sg.getEndRes()+1 && j < seq.getLength(); j++)
\r
797 ch = seq.getCharAt(j);
\r
798 if (!jalview.util.Comparison.isGap( (ch)))
\r
806 endRes += seq.getStart() -1;
\r
809 copiedSequences.append(seq.getName() + "\t" +
\r
812 seq.getSequence(sg.getStartRes(),
\r
813 sg.getEndRes() + 1) + "\n");
\r
818 protected void pasteNew_actionPerformed()
\r
823 protected void pasteThis_actionPerformed()
\r
825 addHistoryItem(new HistoryItem("Paste Sequences", viewport.alignment,
\r
826 HistoryItem.PASTE));
\r
830 void paste(boolean newAlignment)
\r
834 if (copiedSequences == null)
\r
839 StringTokenizer st = new StringTokenizer(copiedSequences.toString());
\r
840 Vector seqs = new Vector();
\r
841 while (st.hasMoreElements())
\r
843 String name = st.nextToken();
\r
844 int start = Integer.parseInt(st.nextToken());
\r
845 int end = Integer.parseInt(st.nextToken());
\r
846 Sequence sequence = new Sequence(name, st.nextToken(), start, end);
\r
850 viewport.alignment.addSequence(sequence);
\r
854 seqs.addElement(sequence);
\r
860 SequenceI[] newSeqs = new SequenceI[seqs.size()];
\r
861 for (int i = 0; i < seqs.size(); i++)
\r
863 newSeqs[i] = (SequenceI) seqs.elementAt(i);
\r
866 String newtitle = new String("Copied sequences");
\r
867 if (getTitle().startsWith("Copied sequences"))
\r
869 newtitle = getTitle();
\r
873 newtitle = newtitle.concat("- from " + getTitle());
\r
875 AlignFrame af = new AlignFrame(new Alignment(newSeqs),
\r
879 if (copiedHiddenColumns != null)
\r
881 for (int i = 0; i < copiedHiddenColumns.size(); i++)
\r
883 int[] region = (int[]) copiedHiddenColumns.elementAt(i);
\r
884 af.viewport.hideColumns(region[0], region[1]);
\r
889 jalview.bin.JalviewLite.addFrame(af, newtitle, NEW_WINDOW_WIDTH,
\r
890 NEW_WINDOW_HEIGHT);
\r
894 viewport.setEndSeq(viewport.alignment.getHeight());
\r
895 viewport.alignment.getWidth();
\r
896 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
\r
900 catch (Exception ex)
\r
901 {} // could be anything being pasted in here
\r
905 protected void cut_actionPerformed()
\r
907 copy_actionPerformed();
\r
908 delete_actionPerformed();
\r
911 protected void delete_actionPerformed()
\r
913 addHistoryItem(new HistoryItem("Delete Sequences", viewport.alignment,
\r
914 HistoryItem.HIDE));
\r
915 if (viewport.getSelectionGroup() == null)
\r
921 SequenceGroup sg = viewport.getSelectionGroup();
\r
922 boolean allSequences = false;
\r
923 if(sg.getSize(false)==viewport.alignment.getHeight())
\r
924 allSequences = true;
\r
926 for (int i = 0; i < sg.getSize(false); i++)
\r
928 SequenceI seq = sg.getSequenceAt(i);
\r
929 int index = viewport.getAlignment().findIndex(seq);
\r
930 seq.deleteChars(sg.getStartRes(), sg.getEndRes() + 1);
\r
932 // If the cut affects all sequences, remove highlighted columns
\r
935 viewport.getColumnSelection().removeElements(sg.getStartRes(),
\r
936 sg.getEndRes() + 1);
\r
940 if (seq.getSequence().length() < 1)
\r
942 viewport.getAlignment().deleteSequence(seq);
\r
946 viewport.getAlignment().getSequences().setElementAt(seq, index);
\r
950 viewport.setSelectionGroup(null);
\r
951 viewport.alignment.deleteGroup(sg);
\r
952 viewport.resetSeqLimits(alignPanel.seqPanel.seqCanvas.getSize().height);
\r
953 if (viewport.getAlignment().getHeight() < 1)
\r
957 this.setVisible(false);
\r
959 catch (Exception ex)
\r
962 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
\r
966 protected void deleteGroups_actionPerformed()
\r
968 viewport.alignment.deleteAllGroups();
\r
969 viewport.setSelectionGroup(null);
\r
971 alignPanel.repaint();
\r
974 public void selectAllSequenceMenuItem_actionPerformed()
\r
976 SequenceGroup sg = new SequenceGroup();
\r
977 for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++)
\r
979 sg.addSequence(viewport.getAlignment().getSequenceAt(i), false);
\r
981 sg.setEndRes(viewport.alignment.getWidth()-1);
\r
982 viewport.setSelectionGroup(sg);
\r
983 alignPanel.repaint();
\r
984 PaintRefresher.Refresh(null, viewport.alignment);
\r
987 public void deselectAllSequenceMenuItem_actionPerformed()
\r
989 if(viewport.cursorMode)
\r
991 alignPanel.seqPanel.keyboardNo1=null;
\r
992 alignPanel.seqPanel.keyboardNo2=null;
\r
994 viewport.setSelectionGroup(null);
\r
995 viewport.getColumnSelection().clear();
\r
996 viewport.setSelectionGroup(null);
\r
997 alignPanel.idPanel.idCanvas.searchResults = null;
\r
998 alignPanel.seqPanel.seqCanvas.highlightSearchResults(null);
\r
999 alignPanel.repaint();
\r
1000 PaintRefresher.Refresh(null, viewport.alignment);
\r
1003 public void invertSequenceMenuItem_actionPerformed()
\r
1005 SequenceGroup sg = viewport.getSelectionGroup();
\r
1006 for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++)
\r
1008 sg.addOrRemove(viewport.getAlignment().getSequenceAt(i), false);
\r
1011 PaintRefresher.Refresh(null, viewport.alignment);
\r
1014 public void remove2LeftMenuItem_actionPerformed()
\r
1016 ColumnSelection colSel = viewport.getColumnSelection();
\r
1017 if (colSel.size() > 0)
\r
1019 addHistoryItem(new HistoryItem("Remove Left", viewport.alignment,
\r
1020 HistoryItem.HIDE));
\r
1021 int min = colSel.getMin();
\r
1022 viewport.getAlignment().trimLeft(min);
\r
1023 colSel.compensateForEdit(0, min);
\r
1025 if (viewport.getSelectionGroup() != null)
\r
1027 viewport.getSelectionGroup().adjustForRemoveLeft(min);
\r
1030 Vector groups = viewport.alignment.getGroups();
\r
1031 for (int i = 0; i < groups.size(); i++)
\r
1033 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
\r
1034 if (!sg.adjustForRemoveLeft(min))
\r
1036 viewport.alignment.deleteGroup(sg);
\r
1039 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
\r
1043 public void remove2RightMenuItem_actionPerformed()
\r
1045 ColumnSelection colSel = viewport.getColumnSelection();
\r
1046 if (colSel.size() > 0)
\r
1048 addHistoryItem(new HistoryItem("Remove Right", viewport.alignment,
\r
1049 HistoryItem.HIDE));
\r
1050 int max = colSel.getMax();
\r
1051 viewport.getAlignment().trimRight(max);
\r
1052 if (viewport.getSelectionGroup() != null)
\r
1054 viewport.getSelectionGroup().adjustForRemoveRight(max);
\r
1057 Vector groups = viewport.alignment.getGroups();
\r
1058 for (int i = 0; i < groups.size(); i++)
\r
1060 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
\r
1061 if (!sg.adjustForRemoveRight(max))
\r
1063 viewport.alignment.deleteGroup(sg);
\r
1066 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
\r
1071 public void removeGappedColumnMenuItem_actionPerformed()
\r
1073 addHistoryItem(new HistoryItem("Remove Gapped Columns",
\r
1074 viewport.alignment,
\r
1075 HistoryItem.HIDE));
\r
1077 //This is to maintain viewport position on first residue
\r
1078 //of first sequence
\r
1079 SequenceI seq = viewport.alignment.getSequenceAt(0);
\r
1080 int startRes = seq.findPosition(viewport.startRes);
\r
1082 viewport.getAlignment().removeGaps();
\r
1084 viewport.setStartRes(seq.findIndex(startRes)-1);
\r
1086 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
\r
1089 public void removeAllGapsMenuItem_actionPerformed()
\r
1091 addHistoryItem(new HistoryItem("Remove Gaps", viewport.alignment,
\r
1092 HistoryItem.HIDE));
\r
1094 //This is to maintain viewport position on first residue
\r
1095 //of first sequence
\r
1096 SequenceI seq = viewport.alignment.getSequenceAt(0);
\r
1097 int startRes = seq.findPosition(viewport.startRes);
\r
1099 SequenceI current;
\r
1104 int start=0, end = viewport.alignment.getWidth();
\r
1106 if (viewport.getSelectionGroup() != null
\r
1107 && viewport.getSelectionGroup().getSequences(false) != null
\r
1108 && viewport.getSelectionGroup().getSize(false)>0)
\r
1110 seqs = viewport.getSelectionGroup().getSequences(true);
\r
1111 start = viewport.getSelectionGroup().getStartRes();
\r
1112 end = viewport.getSelectionGroup().getEndRes()+1;
\r
1115 seqs = viewport.alignment.getSequences();
\r
1117 for (int i = 0; i < seqs.size(); i++)
\r
1119 current = (SequenceI) seqs.elementAt(i);
\r
1120 jSize = current.getLength();
\r
1122 // Removing a range is much quicker than removing gaps
\r
1123 // one by one for long sequences
\r
1125 int rangeStart=-1, rangeEnd=-1;
\r
1129 if (jalview.util.Comparison.isGap(current.getCharAt(j)))
\r
1131 if(rangeStart==-1)
\r
1146 current.deleteChars(rangeStart, rangeEnd);
\r
1147 j-=rangeEnd-rangeStart;
\r
1148 jSize-=rangeEnd-rangeStart;
\r
1156 while (j < end && j < jSize);
\r
1159 current.deleteChars(rangeStart, rangeEnd);
\r
1162 viewport.setStartRes(seq.findIndex(startRes)-1);
\r
1163 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
\r
1166 public void alignmentChanged()
\r
1168 viewport.alignment.padGaps();
\r
1169 if(viewport.autocalculateConsensus)
\r
1171 viewport.updateConsensus();
\r
1172 viewport.updateConservation();
\r
1175 resetAllColourSchemes();
\r
1176 if(alignPanel.overviewPanel!=null)
\r
1177 alignPanel.overviewPanel.updateOverviewImage();
\r
1179 viewport.alignment.adjustSequenceAnnotations();
\r
1180 alignPanel.repaint();
\r
1183 void resetAllColourSchemes()
\r
1185 ColourSchemeI cs = viewport.globalColourScheme;
\r
1188 if (cs instanceof ClustalxColourScheme)
\r
1190 ( (ClustalxColourScheme) viewport.getGlobalColourScheme()).
\r
1191 resetClustalX(viewport.alignment.getSequences(),
\r
1192 viewport.alignment.getWidth());
\r
1195 cs.setConsensus(viewport.vconsensus);
\r
1196 if (cs.conservationApplied())
\r
1198 Alignment al = (Alignment) viewport.alignment;
\r
1199 Conservation c = new Conservation("All",
\r
1200 ResidueProperties.propHash, 3,
\r
1201 al.getSequences(), 0,
\r
1202 al.getWidth() - 1);
\r
1204 c.verdict(false, viewport.ConsPercGaps);
\r
1206 cs.setConservation(c);
\r
1210 int s, sSize = viewport.alignment.getGroups().size();
\r
1211 for(s=0; s<sSize; s++)
\r
1213 SequenceGroup sg = (SequenceGroup)viewport.alignment.getGroups().elementAt(s);
\r
1214 if(sg.cs!=null && sg.cs instanceof ClustalxColourScheme)
\r
1216 ((ClustalxColourScheme)sg.cs).resetClustalX(
\r
1217 sg.getSequences(true), sg.getWidth());
\r
1219 sg.recalcConservation();
\r
1225 public void findMenuItem_actionPerformed()
\r
1227 new Finder(alignPanel);
\r
1230 public void font_actionPerformed()
\r
1232 new FontChooser(alignPanel);
\r
1236 public void seqLimits_itemStateChanged()
\r
1238 viewport.setShowJVSuffix(seqLimits.getState());
\r
1239 alignPanel.fontChanged();
\r
1240 alignPanel.repaint();
\r
1244 protected void colourTextMenuItem_actionPerformed()
\r
1246 viewport.setColourText(colourTextMenuItem.getState());
\r
1247 alignPanel.repaint();
\r
1250 protected void wrapMenuItem_actionPerformed()
\r
1252 viewport.setWrapAlignment(wrapMenuItem.getState());
\r
1253 alignPanel.setWrapAlignment(wrapMenuItem.getState());
\r
1254 scaleAbove.setEnabled(wrapMenuItem.getState());
\r
1255 scaleLeft.setEnabled(wrapMenuItem.getState());
\r
1256 scaleRight.setEnabled(wrapMenuItem.getState());
\r
1257 alignPanel.repaint();
\r
1260 protected void scaleAbove_actionPerformed()
\r
1262 viewport.setScaleAboveWrapped(scaleAbove.getState());
\r
1263 alignPanel.repaint();
\r
1266 protected void scaleLeft_actionPerformed()
\r
1268 viewport.setScaleLeftWrapped(scaleLeft.getState());
\r
1269 alignPanel.repaint();
\r
1272 protected void scaleRight_actionPerformed()
\r
1274 viewport.setScaleRightWrapped(scaleRight.getState());
\r
1275 alignPanel.repaint();
\r
1278 public void viewBoxesMenuItem_actionPerformed()
\r
1280 viewport.setShowBoxes(viewBoxesMenuItem.getState());
\r
1281 alignPanel.repaint();
\r
1284 public void viewTextMenuItem_actionPerformed()
\r
1286 viewport.setShowText(viewTextMenuItem.getState());
\r
1287 alignPanel.repaint();
\r
1290 protected void renderGapsMenuItem_actionPerformed()
\r
1292 viewport.setRenderGaps(renderGapsMenuItem.getState());
\r
1293 alignPanel.repaint();
\r
1296 public void annotationPanelMenuItem_actionPerformed()
\r
1298 viewport.setShowAnnotation(annotationPanelMenuItem.getState());
\r
1299 alignPanel.setAnnotationVisible(annotationPanelMenuItem.getState());
\r
1302 public void featureSettings_actionPerformed()
\r
1304 new FeatureSettings(viewport, alignPanel);
\r
1307 public void overviewMenuItem_actionPerformed()
\r
1309 if (alignPanel.overviewPanel != null)
\r
1314 Frame frame = new Frame();
\r
1315 OverviewPanel overview = new OverviewPanel(alignPanel);
\r
1316 frame.add(overview);
\r
1317 // +50 must allow for applet frame window
\r
1318 jalview.bin.JalviewLite.addFrame(frame, "Overview " + this.getTitle(),
\r
1319 overview.preferredSize().width,
\r
1320 overview.preferredSize().height + 50);
\r
1323 frame.addWindowListener(new WindowAdapter()
\r
1325 public void windowClosing(WindowEvent e)
\r
1327 alignPanel.setOverviewPanel(null);
\r
1331 alignPanel.setOverviewPanel(overview);
\r
1335 protected void noColourmenuItem_actionPerformed()
\r
1337 changeColour(null);
\r
1340 public void clustalColour_actionPerformed()
\r
1342 abovePIDThreshold.setState(false);
\r
1343 changeColour(new ClustalxColourScheme(viewport.alignment.getSequences(),
\r
1344 viewport.alignment.getWidth()));
\r
1347 public void zappoColour_actionPerformed()
\r
1349 changeColour(new ZappoColourScheme());
\r
1352 public void taylorColour_actionPerformed()
\r
1354 changeColour(new TaylorColourScheme());
\r
1357 public void hydrophobicityColour_actionPerformed()
\r
1359 changeColour(new HydrophobicColourScheme());
\r
1362 public void helixColour_actionPerformed()
\r
1364 changeColour(new HelixColourScheme());
\r
1367 public void strandColour_actionPerformed()
\r
1369 changeColour(new StrandColourScheme());
\r
1372 public void turnColour_actionPerformed()
\r
1374 changeColour(new TurnColourScheme());
\r
1377 public void buriedColour_actionPerformed()
\r
1379 changeColour(new BuriedColourScheme());
\r
1382 public void nucleotideColour_actionPerformed()
\r
1384 changeColour(new NucleotideColourScheme());
\r
1387 protected void applyToAllGroups_actionPerformed()
\r
1389 viewport.setColourAppliesToAllGroups(applyToAllGroups.getState());
\r
1392 void changeColour(ColourSchemeI cs)
\r
1394 int threshold = 0;
\r
1398 if (viewport.getAbovePIDThreshold())
\r
1400 threshold = SliderPanel.setPIDSliderSource(alignPanel, cs, "Background");
\r
1402 cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus());
\r
1404 viewport.setGlobalColourScheme(cs);
\r
1408 cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
\r
1411 if (viewport.getConservationSelected())
\r
1414 Alignment al = (Alignment) viewport.alignment;
\r
1415 Conservation c = new Conservation("All",
\r
1416 ResidueProperties.propHash, 3,
\r
1417 al.getSequences(), 0,
\r
1418 al.getWidth() - 1);
\r
1421 c.verdict(false, viewport.ConsPercGaps);
\r
1423 cs.setConservation(c);
\r
1425 cs.setConservationInc(SliderPanel.setConservationSlider(alignPanel, cs,
\r
1431 cs.setConservation(null);
\r
1434 cs.setConsensus(viewport.vconsensus);
\r
1437 viewport.setGlobalColourScheme(cs);
\r
1439 if (viewport.getColourAppliesToAllGroups())
\r
1441 Vector groups = viewport.alignment.getGroups();
\r
1442 for (int i = 0; i < groups.size(); i++)
\r
1444 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
\r
1451 if (cs instanceof ClustalxColourScheme)
\r
1453 sg.cs = new ClustalxColourScheme(sg.getSequences(true), sg.getWidth());
\r
1459 sg.cs = (ColourSchemeI) cs.getClass().newInstance();
\r
1461 catch (Exception ex)
\r
1463 ex.printStackTrace();
\r
1468 if (viewport.getAbovePIDThreshold()
\r
1469 || cs instanceof PIDColourScheme
\r
1470 || cs instanceof Blosum62ColourScheme)
\r
1472 sg.cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus());
\r
1473 sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(true), 0, sg.getWidth()));
\r
1476 sg.cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
\r
1478 if (viewport.getConservationSelected())
\r
1480 Conservation c = new Conservation("Group",
\r
1481 ResidueProperties.propHash, 3,
\r
1482 sg.getSequences(true), 0,
\r
1483 viewport.alignment.getWidth() - 1);
\r
1485 c.verdict(false, viewport.ConsPercGaps);
\r
1486 sg.cs.setConservation(c);
\r
1490 sg.cs.setConservation(null);
\r
1491 sg.cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
\r
1498 if (alignPanel.getOverviewPanel() != null)
\r
1500 alignPanel.getOverviewPanel().updateOverviewImage();
\r
1503 alignPanel.repaint();
\r
1508 protected void modifyPID_actionPerformed()
\r
1510 if (viewport.getAbovePIDThreshold() && viewport.globalColourScheme!=null)
\r
1512 SliderPanel.setPIDSliderSource(alignPanel, viewport.getGlobalColourScheme(),
\r
1514 SliderPanel.showPIDSlider();
\r
1518 protected void modifyConservation_actionPerformed()
\r
1520 if (viewport.getConservationSelected() && viewport.globalColourScheme!=null)
\r
1522 SliderPanel.setConservationSlider(alignPanel, viewport.globalColourScheme,
\r
1524 SliderPanel.showConservationSlider();
\r
1528 protected void conservationMenuItem_actionPerformed()
\r
1530 viewport.setConservationSelected(conservationMenuItem.getState());
\r
1532 viewport.setAbovePIDThreshold(false);
\r
1533 abovePIDThreshold.setState(false);
\r
1535 changeColour(viewport.getGlobalColourScheme());
\r
1537 modifyConservation_actionPerformed();
\r
1540 public void abovePIDThreshold_actionPerformed()
\r
1542 viewport.setAbovePIDThreshold(abovePIDThreshold.getState());
\r
1544 conservationMenuItem.setState(false);
\r
1545 viewport.setConservationSelected(false);
\r
1547 changeColour(viewport.getGlobalColourScheme());
\r
1549 modifyPID_actionPerformed();
\r
1552 public void userDefinedColour_actionPerformed()
\r
1554 new UserDefinedColours(alignPanel, null);
\r
1557 public void PIDColour_actionPerformed()
\r
1559 changeColour(new PIDColourScheme());
\r
1562 public void BLOSUM62Colour_actionPerformed()
\r
1564 changeColour(new Blosum62ColourScheme());
\r
1567 public void sortPairwiseMenuItem_actionPerformed()
\r
1569 addHistoryItem(new HistoryItem("Pairwise Sort", viewport.alignment,
\r
1570 HistoryItem.SORT));
\r
1571 AlignmentSorter.sortByPID(viewport.getAlignment(),
\r
1572 viewport.getAlignment().getSequenceAt(0));
\r
1573 alignPanel.repaint();
\r
1576 public void sortIDMenuItem_actionPerformed()
\r
1578 addHistoryItem(new HistoryItem("ID Sort", viewport.alignment,
\r
1579 HistoryItem.SORT));
\r
1580 AlignmentSorter.sortByID(viewport.getAlignment());
\r
1581 alignPanel.repaint();
\r
1584 public void sortGroupMenuItem_actionPerformed()
\r
1586 addHistoryItem(new HistoryItem("Group Sort", viewport.alignment,
\r
1587 HistoryItem.SORT));
\r
1588 AlignmentSorter.sortByGroup(viewport.getAlignment());
\r
1589 alignPanel.repaint();
\r
1593 public void removeRedundancyMenuItem_actionPerformed()
\r
1595 new RedundancyPanel(alignPanel);
\r
1598 public void pairwiseAlignmentMenuItem_actionPerformed()
\r
1600 if (viewport.getSelectionGroup()!=null
\r
1601 && viewport.getSelectionGroup().getSize(false) > 1)
\r
1603 Frame frame = new Frame();
\r
1604 frame.add(new PairwiseAlignPanel(alignPanel));
\r
1605 jalview.bin.JalviewLite.addFrame(frame, "Pairwise Alignment", 600, 500);
\r
1609 public void PCAMenuItem_actionPerformed()
\r
1611 //are the sequences aligned?
\r
1612 if (!viewport.alignment.isAligned())
\r
1614 SequenceI current;
\r
1615 int Width = viewport.getAlignment().getWidth();
\r
1617 for (int i = 0; i < viewport.getAlignment().getSequences().size();
\r
1620 current = viewport.getAlignment().getSequenceAt(i);
\r
1622 if (current.getLength() < Width)
\r
1624 current.insertCharAt(Width - 1, viewport.getGapCharacter());
\r
1627 alignPanel.repaint();
\r
1630 if ( (viewport.getSelectionGroup() != null &&
\r
1631 viewport.getSelectionGroup().getSize(false) < 4 &&
\r
1632 viewport.getSelectionGroup().getSize(false) > 0)
\r
1633 || viewport.getAlignment().getHeight() < 4)
\r
1640 new PCAPanel(viewport);
\r
1642 catch (java.lang.OutOfMemoryError ex)
\r
1648 public void averageDistanceTreeMenuItem_actionPerformed()
\r
1650 NewTreePanel("AV", "PID", "Average distance tree using PID");
\r
1653 public void neighbourTreeMenuItem_actionPerformed()
\r
1655 NewTreePanel("NJ", "PID", "Neighbour joining tree using PID");
\r
1658 protected void njTreeBlosumMenuItem_actionPerformed()
\r
1660 NewTreePanel("NJ", "BL", "Neighbour joining tree using BLOSUM62");
\r
1663 protected void avTreeBlosumMenuItem_actionPerformed()
\r
1665 NewTreePanel("AV", "BL", "Average distance tree using BLOSUM62PID");
\r
1668 void NewTreePanel(String type, String pwType, String title)
\r
1670 //are the sequences aligned?
\r
1671 if (!viewport.alignment.isAligned())
\r
1673 SequenceI current;
\r
1674 int Width = viewport.getAlignment().getWidth();
\r
1676 for (int i = 0; i < viewport.getAlignment().getSequences().size();
\r
1679 current = viewport.getAlignment().getSequenceAt(i);
\r
1681 if (current.getLength() < Width)
\r
1683 current.insertCharAt(Width - 1, viewport.getGapCharacter());
\r
1686 alignPanel.repaint();
\r
1690 if ( (viewport.getSelectionGroup() != null &&
\r
1691 viewport.getSelectionGroup().getSize(false) > 1)
\r
1692 || (viewport.getSelectionGroup() == null
\r
1693 && viewport.alignment.getHeight() > 1))
\r
1695 final TreePanel tp = new TreePanel(viewport,
\r
1699 addTreeMenuItem(tp, title);
\r
1701 jalview.bin.JalviewLite.addFrame(tp, title, 600, 500);
\r
1705 void loadTree_actionPerformed()
\r
1707 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
\r
1708 cap.setText("Paste your Newick tree file here.");
\r
1709 cap.treeImport = true;
\r
1710 Frame frame = new Frame();
\r
1712 jalview.bin.JalviewLite.addFrame(frame, "Paste Newick file ", 400, 300);
\r
1715 public void loadTree(jalview.io.NewickFile tree, String treeFile)
\r
1717 TreePanel tp = new TreePanel(viewport,
\r
1721 jalview.bin.JalviewLite.addFrame(tp, treeFile, 600, 500);
\r
1722 addTreeMenuItem(tp, treeFile);
\r
1725 void addTreeMenuItem(final TreePanel treePanel, String title)
\r
1727 final MenuItem item = new MenuItem(title);
\r
1728 sortByTreeMenu.add(item);
\r
1729 item.addActionListener(new java.awt.event.ActionListener()
\r
1731 public void actionPerformed(ActionEvent evt)
\r
1733 addHistoryItem(new HistoryItem("Sort", viewport.alignment,
\r
1734 HistoryItem.SORT));
\r
1735 AlignmentSorter.sortByTree(viewport.getAlignment(), treePanel.getTree());
\r
1736 alignPanel.repaint();
\r
1740 treePanel.addWindowListener(new WindowAdapter()
\r
1742 public void windowClosing(WindowEvent e)
\r
1744 sortByTreeMenu.remove(item);
\r
1749 protected void documentation_actionPerformed()
\r
1751 showURL("http://www.jalview.org/help.html", "HELP");
\r
1754 protected void about_actionPerformed()
\r
1757 class AboutPanel extends Canvas
\r
1760 public AboutPanel(String version)
\r
1761 { this.version = version; }
\r
1763 public void paint(Graphics g)
\r
1765 g.setColor(Color.white);
\r
1766 g.fillRect(0, 0, getSize().width, getSize().height);
\r
1767 g.setFont(new Font("Helvetica", Font.PLAIN, 12));
\r
1768 FontMetrics fm = g.getFontMetrics();
\r
1769 int fh = fm.getHeight();
\r
1771 g.setColor(Color.black);
\r
1772 g.setFont(new Font("Helvetica", Font.BOLD, 14));
\r
1773 g.drawString("Jalview - Release "+version, 200, y += fh);
\r
1774 g.setFont(new Font("Helvetica", Font.PLAIN, 12));
\r
1775 g.drawString("Authors: Michele Clamp, James Cuff, Steve Searle, Andrew Waterhouse, Jim Procter & Geoff Barton.",
\r
1777 g.drawString("Current development managed by Andrew Waterhouse; Barton Group, University of Dundee.",
\r
1780 "For any issues relating to Jalview, email help@jalview.org", x,
\r
1782 g.drawString("If you use JalView, please cite:", x, y += fh + 8);
\r
1783 g.drawString("\"Clamp, M., Cuff, J., Searle, S. M. and Barton, G. J. (2004), The Jalview Java Alignment Editor\"",
\r
1785 g.drawString("Bioinformatics, 2004 20;426-7.", x, y += fh);
\r
1789 String version = "test";
\r
1790 java.net.URL url = getClass().getResource("/.build_properties");
\r
1795 BufferedReader reader = new BufferedReader(new InputStreamReader(
\r
1796 url.openStream()));
\r
1798 while ( (line = reader.readLine()) != null)
\r
1800 if (line.indexOf("VERSION") > -1)
\r
1802 version = line.substring(line.indexOf("=") + 1);
\r
1806 catch (Exception ex)
\r
1808 ex.printStackTrace();
\r
1813 Frame frame = new Frame();
\r
1814 frame.add(new AboutPanel(version));
\r
1815 jalview.bin.JalviewLite.addFrame(frame, "Jalview", 580, 200);
\r
1819 public void showURL(String url, String target)
\r
1821 if (viewport.applet == null)
\r
1823 System.out.println("Not running as applet - no browser available.");
\r
1829 System.out.println("Show url: "+url);
\r
1830 viewport.applet.getAppletContext().showDocument(new java.net.URL(url),
\r
1833 catch (Exception ex)
\r
1835 ex.printStackTrace();
\r
1841 //////////////////////////////////////////////////////////////////////////////////
\r
1842 //JBuilder Graphics here
\r
1844 protected MenuBar alignFrameMenuBar = new MenuBar();
\r
1845 protected Menu fileMenu = new Menu("File");
\r
1846 protected MenuItem loadApplication = new MenuItem("View in Full Application");
\r
1847 protected MenuItem loadTree = new MenuItem("Load Associated Tree");
\r
1848 protected MenuItem closeMenuItem = new MenuItem("Close");
\r
1849 protected Menu editMenu = new Menu("Edit");
\r
1850 protected Menu viewMenu = new Menu("View");
\r
1851 protected Menu colourMenu = new Menu("Colour");
\r
1852 protected Menu calculateMenu = new Menu("Calculate");
\r
1853 protected MenuItem selectAllSequenceMenuItem = new MenuItem("Select all");
\r
1854 protected MenuItem deselectAllSequenceMenuItem = new MenuItem("Deselect All");
\r
1855 protected MenuItem invertSequenceMenuItem = new MenuItem("Invert Selection");
\r
1856 protected MenuItem remove2LeftMenuItem = new MenuItem();
\r
1857 protected MenuItem remove2RightMenuItem = new MenuItem();
\r
1858 protected MenuItem removeGappedColumnMenuItem = new MenuItem();
\r
1859 protected MenuItem removeAllGapsMenuItem = new MenuItem();
\r
1860 protected CheckboxMenuItem viewBoxesMenuItem = new CheckboxMenuItem();
\r
1861 protected CheckboxMenuItem viewTextMenuItem = new CheckboxMenuItem();
\r
1862 protected MenuItem sortPairwiseMenuItem = new MenuItem();
\r
1863 protected MenuItem sortIDMenuItem = new MenuItem();
\r
1864 protected MenuItem sortGroupMenuItem = new MenuItem();
\r
1865 protected MenuItem removeRedundancyMenuItem = new MenuItem();
\r
1866 protected MenuItem pairwiseAlignmentMenuItem = new MenuItem();
\r
1867 protected MenuItem PCAMenuItem = new MenuItem();
\r
1868 protected MenuItem averageDistanceTreeMenuItem = new MenuItem();
\r
1869 protected MenuItem neighbourTreeMenuItem = new MenuItem();
\r
1870 BorderLayout borderLayout1 = new BorderLayout();
\r
1871 public Label statusBar = new Label();
\r
1872 protected Menu outputTextboxMenu = new Menu();
\r
1873 protected MenuItem clustalColour = new MenuItem();
\r
1874 protected MenuItem zappoColour = new MenuItem();
\r
1875 protected MenuItem taylorColour = new MenuItem();
\r
1876 protected MenuItem hydrophobicityColour = new MenuItem();
\r
1877 protected MenuItem helixColour = new MenuItem();
\r
1878 protected MenuItem strandColour = new MenuItem();
\r
1879 protected MenuItem turnColour = new MenuItem();
\r
1880 protected MenuItem buriedColour = new MenuItem();
\r
1881 protected MenuItem userDefinedColour = new MenuItem();
\r
1882 protected MenuItem PIDColour = new MenuItem();
\r
1883 protected MenuItem BLOSUM62Colour = new MenuItem();
\r
1884 MenuItem njTreeBlosumMenuItem = new MenuItem();
\r
1885 MenuItem avDistanceTreeBlosumMenuItem = new MenuItem();
\r
1886 protected CheckboxMenuItem annotationPanelMenuItem = new CheckboxMenuItem();
\r
1887 protected CheckboxMenuItem colourTextMenuItem = new CheckboxMenuItem();
\r
1888 MenuItem overviewMenuItem = new MenuItem();
\r
1889 protected MenuItem undoMenuItem = new MenuItem();
\r
1890 protected MenuItem redoMenuItem = new MenuItem();
\r
1891 protected CheckboxMenuItem conservationMenuItem = new CheckboxMenuItem();
\r
1892 MenuItem noColourmenuItem = new MenuItem();
\r
1893 protected CheckboxMenuItem wrapMenuItem = new CheckboxMenuItem();
\r
1894 protected CheckboxMenuItem renderGapsMenuItem = new CheckboxMenuItem();
\r
1895 MenuItem findMenuItem = new MenuItem();
\r
1896 Menu searchMenu = new Menu();
\r
1897 protected CheckboxMenuItem abovePIDThreshold = new CheckboxMenuItem();
\r
1898 protected MenuItem nucleotideColour = new MenuItem();
\r
1899 MenuItem deleteGroups = new MenuItem();
\r
1900 MenuItem delete = new MenuItem();
\r
1901 MenuItem copy = new MenuItem();
\r
1902 MenuItem cut = new MenuItem();
\r
1903 Menu pasteMenu = new Menu();
\r
1904 MenuItem pasteNew = new MenuItem();
\r
1905 MenuItem pasteThis = new MenuItem();
\r
1906 protected CheckboxMenuItem applyToAllGroups = new CheckboxMenuItem();
\r
1907 protected MenuItem font = new MenuItem();
\r
1908 protected CheckboxMenuItem scaleAbove = new CheckboxMenuItem();
\r
1909 protected CheckboxMenuItem scaleLeft = new CheckboxMenuItem();
\r
1910 protected CheckboxMenuItem scaleRight = new CheckboxMenuItem();
\r
1911 MenuItem modifyPID = new MenuItem();
\r
1912 MenuItem modifyConservation = new MenuItem();
\r
1913 protected CheckboxMenuItem autoCalculate
\r
1914 = new CheckboxMenuItem("Autocalculate Consensus", true);
\r
1915 protected Menu sortByTreeMenu = new Menu();
\r
1916 Menu sort = new Menu();
\r
1917 Menu calculate = new Menu();
\r
1918 MenuItem inputText = new MenuItem();
\r
1919 Menu helpMenu = new Menu();
\r
1920 MenuItem documentation = new MenuItem();
\r
1921 MenuItem about = new MenuItem();
\r
1922 protected CheckboxMenuItem seqLimits = new CheckboxMenuItem();
\r
1923 Panel embeddedMenu;
\r
1924 Label embeddedEdit;
\r
1925 Label embeddedSearch;
\r
1926 Label embeddedView;
\r
1927 Label embeddedColour;
\r
1928 Label embeddedFile;
\r
1929 Label embeddedHelp;
\r
1930 Label embeddedCalculate;
\r
1931 FlowLayout flowLayout1;
\r
1933 private void jbInit() throws Exception {
\r
1935 setMenuBar(alignFrameMenuBar);
\r
1939 // dynamically fill save as menu with available formats
\r
1940 for (int i = 0; i < jalview.io.AppletFormatAdapter.formats.size(); i++)
\r
1943 item = new MenuItem( (String) jalview.io.AppletFormatAdapter.formats.
\r
1946 item.addActionListener(new java.awt.event.ActionListener()
\r
1948 public void actionPerformed(ActionEvent e)
\r
1950 outputText_actionPerformed(e);
\r
1954 outputTextboxMenu.add(item);
\r
1956 closeMenuItem.addActionListener(this);
\r
1957 loadApplication.addActionListener(this);
\r
1959 loadTree.addActionListener(this);
\r
1960 selectAllSequenceMenuItem.addActionListener(this);
\r
1961 deselectAllSequenceMenuItem.addActionListener(this);
\r
1962 invertSequenceMenuItem.addActionListener(this);
\r
1963 remove2LeftMenuItem.setLabel("Remove Left");
\r
1964 remove2LeftMenuItem.addActionListener(this);
\r
1965 remove2RightMenuItem.setLabel("Remove Right");
\r
1966 remove2RightMenuItem.addActionListener(this);
\r
1967 removeGappedColumnMenuItem.setLabel("Remove Empty Columns");
\r
1968 removeGappedColumnMenuItem.addActionListener(this);
\r
1969 removeAllGapsMenuItem.setLabel("Remove All Gaps");
\r
1970 removeAllGapsMenuItem.addActionListener(this);
\r
1971 viewBoxesMenuItem.setLabel("Boxes");
\r
1972 viewBoxesMenuItem.setState(true);
\r
1973 viewBoxesMenuItem.addItemListener(this);
\r
1974 viewTextMenuItem.setLabel("Text");
\r
1975 viewTextMenuItem.setState(true);
\r
1976 viewTextMenuItem.addItemListener(this);
\r
1977 sortPairwiseMenuItem.setLabel("by Pairwise Identity");
\r
1978 sortPairwiseMenuItem.addActionListener(this);
\r
1979 sortIDMenuItem.setLabel("by ID");
\r
1980 sortIDMenuItem.addActionListener(this);
\r
1981 sortGroupMenuItem.setLabel("by Group");
\r
1982 sortGroupMenuItem.addActionListener(this);
\r
1983 removeRedundancyMenuItem.setLabel("Remove Redundancy...");
\r
1984 removeRedundancyMenuItem.addActionListener(this);
\r
1985 pairwiseAlignmentMenuItem.setLabel("Pairwise Alignments...");
\r
1986 pairwiseAlignmentMenuItem.addActionListener(this);
\r
1987 PCAMenuItem.setLabel("Principal Component Analysis");
\r
1988 PCAMenuItem.addActionListener(this);
\r
1989 averageDistanceTreeMenuItem.setLabel(
\r
1990 "Average Distance Using % Identity");
\r
1991 averageDistanceTreeMenuItem.addActionListener(this);
\r
1992 neighbourTreeMenuItem.setLabel("Neighbour Joining Using % Identity");
\r
1993 neighbourTreeMenuItem.addActionListener(this);
\r
1994 alignFrameMenuBar.setFont(new java.awt.Font("Verdana", 0, 11));
\r
1995 statusBar.setBackground(Color.white);
\r
1996 statusBar.setFont(new java.awt.Font("Verdana", 0, 11));
\r
1997 statusBar.setText("Status bar");
\r
1998 outputTextboxMenu.setLabel("Output to Textbox");
\r
1999 clustalColour.setLabel("Clustalx");
\r
2001 clustalColour.addActionListener(this);
\r
2002 zappoColour.setLabel("Zappo");
\r
2003 zappoColour.addActionListener(this);
\r
2004 taylorColour.setLabel("Taylor");
\r
2005 taylorColour.addActionListener(this);
\r
2006 hydrophobicityColour.setLabel("Hydrophobicity");
\r
2007 hydrophobicityColour.addActionListener(this);
\r
2008 helixColour.setLabel("Helix Propensity");
\r
2009 helixColour.addActionListener(this);
\r
2010 strandColour.setLabel("Strand Propensity");
\r
2011 strandColour.addActionListener(this);
\r
2012 turnColour.setLabel("Turn Propensity");
\r
2013 turnColour.addActionListener(this);
\r
2014 buriedColour.setLabel("Buried Index");
\r
2015 buriedColour.addActionListener(this);
\r
2016 userDefinedColour.setLabel("User Defined...");
\r
2017 userDefinedColour.addActionListener(this);
\r
2018 PIDColour.setLabel("Percentage Identity");
\r
2019 PIDColour.addActionListener(this);
\r
2020 BLOSUM62Colour.setLabel("BLOSUM62 Score");
\r
2021 BLOSUM62Colour.addActionListener(this);
\r
2022 avDistanceTreeBlosumMenuItem.setLabel(
\r
2023 "Average Distance Using BLOSUM62");
\r
2024 avDistanceTreeBlosumMenuItem.addActionListener(this);
\r
2025 njTreeBlosumMenuItem.setLabel("Neighbour Joining Using BLOSUM62");
\r
2026 njTreeBlosumMenuItem.addActionListener(this);
\r
2027 annotationPanelMenuItem.setLabel("Show Annotations");
\r
2028 annotationPanelMenuItem.addItemListener(this);
\r
2029 colourTextMenuItem.setLabel("Colour Text");
\r
2030 colourTextMenuItem.addItemListener(this);
\r
2031 overviewMenuItem.setLabel("Overview Window");
\r
2032 overviewMenuItem.addActionListener(this);
\r
2033 undoMenuItem.setEnabled(false);
\r
2034 undoMenuItem.setLabel("Undo");
\r
2035 undoMenuItem.addActionListener(this);
\r
2036 redoMenuItem.setEnabled(false);
\r
2037 redoMenuItem.setLabel("Redo");
\r
2038 redoMenuItem.addActionListener(this);
\r
2039 conservationMenuItem.setLabel("by Conservation");
\r
2040 conservationMenuItem.addItemListener(this);
\r
2041 noColourmenuItem.setLabel("None");
\r
2042 noColourmenuItem.addActionListener(this);
\r
2043 wrapMenuItem.setLabel("Wrap");
\r
2044 wrapMenuItem.addItemListener(this);
\r
2045 renderGapsMenuItem.setLabel("Show Gaps");
\r
2046 renderGapsMenuItem.setState(true);
\r
2047 renderGapsMenuItem.addItemListener(this);
\r
2048 findMenuItem.setLabel("Find...");
\r
2049 findMenuItem.addActionListener(this);
\r
2050 searchMenu.setLabel("Search");
\r
2052 abovePIDThreshold.setLabel("Above Identity Threshold");
\r
2053 abovePIDThreshold.addItemListener(this);
\r
2054 nucleotideColour.setLabel("Nucleotide");
\r
2055 nucleotideColour.addActionListener(this);
\r
2056 deleteGroups.setLabel("Undefine Groups");
\r
2057 deleteGroups.addActionListener(this);
\r
2058 copy.setLabel("Copy");
\r
2059 copy.addActionListener(this);
\r
2060 cut.setLabel("Cut");
\r
2061 cut.addActionListener(this);
\r
2062 delete.setLabel("Delete");
\r
2063 delete.addActionListener(this);
\r
2064 pasteMenu.setLabel("Paste");
\r
2065 pasteNew.setLabel("To New Alignment");
\r
2066 pasteNew.addActionListener(this);
\r
2067 pasteThis.setLabel("Add To This Alignment");
\r
2068 pasteThis.addActionListener(this);
\r
2069 applyToAllGroups.setLabel("Apply Colour To All Groups");
\r
2070 applyToAllGroups.setState(true);
\r
2071 applyToAllGroups.addItemListener(this);
\r
2072 font.setLabel("Font...");
\r
2073 font.addActionListener(this);
\r
2074 scaleAbove.setLabel("Scale Above");
\r
2075 scaleAbove.setState(true);
\r
2076 scaleAbove.setEnabled(false);
\r
2077 scaleAbove.addItemListener(this);
\r
2078 scaleLeft.setEnabled(false);
\r
2079 scaleLeft.setState(true);
\r
2080 scaleLeft.setLabel("Scale Left");
\r
2081 scaleLeft.addItemListener(this);
\r
2082 scaleRight.setEnabled(false);
\r
2083 scaleRight.setState(true);
\r
2084 scaleRight.setLabel("Scale Right");
\r
2085 scaleRight.addItemListener(this);
\r
2086 modifyPID.setLabel("Modify Identity Threshold...");
\r
2087 modifyPID.addActionListener(this);
\r
2088 modifyConservation.setLabel("Modify Conservation Threshold...");
\r
2089 modifyConservation.addActionListener(this);
\r
2090 sortByTreeMenu.setLabel("By Tree Order");
\r
2091 sort.setLabel("Sort");
\r
2092 calculate.setLabel("Calculate Tree");
\r
2093 autoCalculate.addItemListener(this);
\r
2094 inputText.setLabel("Input from textbox");
\r
2095 inputText.addActionListener(this);
\r
2097 helpMenu.setLabel("Help");
\r
2098 documentation.setLabel("Documentation");
\r
2099 documentation.addActionListener(this);
\r
2101 about.setLabel("About...");
\r
2102 about.addActionListener(this);
\r
2103 seqLimits.setState(true);
\r
2104 seqLimits.setLabel("Show Sequence Limits");
\r
2105 seqLimits.addItemListener(this);
\r
2106 featureSettings.setLabel("Feature Settings...");
\r
2107 featureSettings.addActionListener(this);
\r
2108 sequenceFeatures.setLabel("Sequence Features");
\r
2109 sequenceFeatures.addItemListener(this);
\r
2110 sequenceFeatures.setState(false);
\r
2111 annotationColour.setLabel("by Annotation...");
\r
2112 annotationColour.addActionListener(this);
\r
2113 invertSequenceMenuItem.setLabel("Invert Sequence Selection");
\r
2114 invertColSel.setLabel("Invert Column Selection");
\r
2115 menu1.setLabel("Show");
\r
2116 showColumns.setLabel("All Columns ");
\r
2117 showSeqs.setLabel("All Sequences");
\r
2118 menu2.setLabel("Hide");
\r
2119 hideColumns.setLabel("Selected Columns");
\r
2120 hideSequences.setLabel("Selected Sequences");
\r
2121 invertColSel.addActionListener(this);
\r
2122 showColumns.addActionListener(this);
\r
2123 showSeqs.addActionListener(this);
\r
2124 hideColumns.addActionListener(this);
\r
2125 hideSequences.addActionListener(this);
\r
2128 alignFrameMenuBar.add(fileMenu);
\r
2129 alignFrameMenuBar.add(editMenu);
\r
2130 alignFrameMenuBar.add(searchMenu);
\r
2131 alignFrameMenuBar.add(viewMenu);
\r
2132 alignFrameMenuBar.add(colourMenu);
\r
2133 alignFrameMenuBar.add(calculateMenu);
\r
2134 alignFrameMenuBar.add(helpMenu);
\r
2135 fileMenu.add(inputText);
\r
2136 fileMenu.add(outputTextboxMenu);
\r
2137 if(jalviewServletURL!=null)
\r
2138 fileMenu.add(loadApplication);
\r
2139 fileMenu.addSeparator();
\r
2140 fileMenu.add(loadTree);
\r
2141 fileMenu.add(closeMenuItem);
\r
2142 editMenu.add(undoMenuItem);
\r
2143 editMenu.add(redoMenuItem);
\r
2144 editMenu.add(cut);
\r
2145 editMenu.add(copy);
\r
2146 editMenu.add(pasteMenu);
\r
2147 editMenu.add(delete);
\r
2148 editMenu.addSeparator();
\r
2149 editMenu.add(selectAllSequenceMenuItem);
\r
2150 editMenu.add(deselectAllSequenceMenuItem);
\r
2151 editMenu.add(invertSequenceMenuItem);
\r
2152 editMenu.add(invertColSel);
\r
2153 editMenu.add(deleteGroups);
\r
2154 editMenu.addSeparator();
\r
2155 editMenu.add(remove2LeftMenuItem);
\r
2156 editMenu.add(remove2RightMenuItem);
\r
2157 editMenu.add(removeGappedColumnMenuItem);
\r
2158 editMenu.add(removeAllGapsMenuItem);
\r
2159 editMenu.add(removeRedundancyMenuItem);
\r
2160 searchMenu.add(findMenuItem);
\r
2161 viewMenu.add(font);
\r
2162 viewMenu.addSeparator();
\r
2163 viewMenu.add(menu1);
\r
2164 viewMenu.add(menu2);
\r
2165 viewMenu.addSeparator();
\r
2166 viewMenu.add(wrapMenuItem);
\r
2167 viewMenu.add(scaleAbove);
\r
2168 viewMenu.add(scaleLeft);
\r
2169 viewMenu.add(scaleRight);
\r
2170 viewMenu.addSeparator();
\r
2171 viewMenu.add(seqLimits);
\r
2172 viewMenu.add(viewBoxesMenuItem);
\r
2173 viewMenu.add(viewTextMenuItem);
\r
2174 viewMenu.add(colourTextMenuItem);
\r
2175 viewMenu.add(renderGapsMenuItem);
\r
2176 viewMenu.add(annotationPanelMenuItem);
\r
2177 viewMenu.addSeparator();
\r
2178 viewMenu.add(sequenceFeatures);
\r
2179 viewMenu.add(featureSettings);
\r
2180 viewMenu.addSeparator();
\r
2181 viewMenu.add(overviewMenuItem);
\r
2182 colourMenu.add(applyToAllGroups);
\r
2183 colourMenu.addSeparator();
\r
2184 colourMenu.add(noColourmenuItem);
\r
2185 colourMenu.add(clustalColour);
\r
2186 colourMenu.add(BLOSUM62Colour);
\r
2187 colourMenu.add(PIDColour);
\r
2188 colourMenu.add(zappoColour);
\r
2189 colourMenu.add(taylorColour);
\r
2190 colourMenu.add(hydrophobicityColour);
\r
2191 colourMenu.add(helixColour);
\r
2192 colourMenu.add(strandColour);
\r
2193 colourMenu.add(turnColour);
\r
2194 colourMenu.add(buriedColour);
\r
2195 colourMenu.add(nucleotideColour);
\r
2196 colourMenu.add(userDefinedColour);
\r
2197 colourMenu.addSeparator();
\r
2198 colourMenu.add(conservationMenuItem);
\r
2199 colourMenu.add(modifyConservation);
\r
2200 colourMenu.add(abovePIDThreshold);
\r
2201 colourMenu.add(modifyPID);
\r
2202 colourMenu.add(annotationColour);
\r
2203 calculateMenu.add(sort);
\r
2204 calculateMenu.add(calculate);
\r
2205 calculateMenu.addSeparator();
\r
2206 calculateMenu.add(pairwiseAlignmentMenuItem);
\r
2207 calculateMenu.add(PCAMenuItem);
\r
2208 calculateMenu.add(autoCalculate);
\r
2209 this.add(statusBar, BorderLayout.SOUTH);
\r
2210 pasteMenu.add(pasteNew);
\r
2211 pasteMenu.add(pasteThis);
\r
2212 sort.add(sortIDMenuItem);
\r
2213 sort.add(sortByTreeMenu);
\r
2214 sort.add(sortGroupMenuItem);
\r
2215 sort.add(sortPairwiseMenuItem);
\r
2216 calculate.add(averageDistanceTreeMenuItem);
\r
2217 calculate.add(neighbourTreeMenuItem);
\r
2218 calculate.add(avDistanceTreeBlosumMenuItem);
\r
2219 calculate.add(njTreeBlosumMenuItem);
\r
2220 helpMenu.add(documentation);
\r
2221 helpMenu.add(about);
\r
2222 menu1.add(showColumns);
\r
2223 menu1.add(showSeqs);
\r
2224 menu2.add(hideColumns);
\r
2225 menu2.add(hideSequences);
\r
2228 public void setEmbedded()
\r
2231 embeddedMenu = new Panel();
\r
2232 embeddedEdit = new Label();
\r
2233 embeddedSearch = new Label();
\r
2234 embeddedView = new Label();
\r
2235 embeddedColour = new Label();
\r
2236 embeddedFile = new Label();
\r
2237 embeddedHelp = new Label();
\r
2238 embeddedCalculate = new Label();
\r
2239 flowLayout1 = new FlowLayout();
\r
2240 embeddedMenu.setBackground(Color.lightGray);
\r
2241 embeddedMenu.setLayout(flowLayout1);
\r
2242 embeddedEdit.setText("Edit");
\r
2243 embeddedEdit.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
\r
2244 embeddedSearch.setText("Search");
\r
2245 embeddedSearch.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
\r
2246 embeddedView.setText("View");
\r
2247 embeddedView.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
\r
2248 embeddedColour.setText("Colour");
\r
2249 embeddedColour.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
\r
2250 embeddedFile.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
\r
2251 embeddedFile.setText("File");
\r
2252 embeddedHelp.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
\r
2253 embeddedHelp.setText("Help");
\r
2254 embeddedCalculate.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
\r
2255 embeddedCalculate.setText("Calculate");
\r
2256 embeddedMenu.add(embeddedFile);
\r
2257 embeddedMenu.add(embeddedEdit);
\r
2258 embeddedMenu.add(embeddedSearch);
\r
2259 embeddedMenu.add(embeddedView);
\r
2260 embeddedMenu.add(embeddedColour);
\r
2261 embeddedMenu.add(embeddedCalculate);
\r
2262 embeddedMenu.add(embeddedHelp);
\r
2263 flowLayout1.setAlignment(FlowLayout.LEFT);
\r
2264 flowLayout1.setHgap(2);
\r
2265 flowLayout1.setVgap(0);
\r
2266 embeddedFile.addMouseListener(this);
\r
2267 embeddedEdit.addMouseListener(this);
\r
2268 embeddedSearch.addMouseListener(this);
\r
2269 embeddedView.addMouseListener(this);
\r
2270 embeddedColour.addMouseListener(this);
\r
2271 embeddedCalculate.addMouseListener(this);
\r
2272 embeddedHelp.addMouseListener(this);
\r
2274 // setVisible(false);
\r
2275 fileMenu.remove(closeMenuItem);
\r
2276 fileMenu.remove(3); // Seperator
\r
2278 viewport.applet.setLayout(new BorderLayout());
\r
2279 viewport.applet.add(embeddedMenu, BorderLayout.NORTH);
\r
2280 viewport.applet.add(statusBar, BorderLayout.SOUTH);
\r
2281 // viewport.applet.validate();
\r
2283 alignPanel.setSize(viewport.applet.size().width, viewport.applet.size().height
\r
2284 - embeddedMenu.HEIGHT - statusBar.HEIGHT);
\r
2286 viewport.applet.add(alignPanel, BorderLayout.CENTER);
\r
2287 viewport.applet.validate();
\r
2293 PopupMenu filePopup, editPopup, searchPopup,
\r
2294 viewPopup, colourPopup, calculatePopup, helpPopup;
\r
2295 MenuItem featureSettings = new MenuItem();
\r
2296 CheckboxMenuItem sequenceFeatures = new CheckboxMenuItem();
\r
2297 MenuItem annotationColour = new MenuItem();
\r
2298 MenuItem invertColSel = new MenuItem();
\r
2299 Menu menu1 = new Menu();
\r
2300 MenuItem showColumns = new MenuItem();
\r
2301 MenuItem showSeqs = new MenuItem();
\r
2302 Menu menu2 = new Menu();
\r
2303 MenuItem hideColumns = new MenuItem();
\r
2304 MenuItem hideSequences = new MenuItem();
\r
2306 public void mousePressed(MouseEvent evt)
\r
2308 PopupMenu popup = null;
\r
2309 Label source = (Label)evt.getSource();
\r
2310 if(source==embeddedFile)
\r
2312 popup = filePopup = genPopupMenu(filePopup, fileMenu);
\r
2314 else if(source==embeddedEdit)
\r
2316 popup = editPopup = genPopupMenu(editPopup, editMenu);
\r
2318 else if(source==embeddedSearch)
\r
2320 popup = searchPopup = genPopupMenu(searchPopup, searchMenu);
\r
2322 else if(source==embeddedView)
\r
2324 popup = viewPopup = genPopupMenu(viewPopup, viewMenu);
\r
2326 else if(source==embeddedColour)
\r
2328 popup = colourPopup = genPopupMenu(colourPopup, colourMenu);
\r
2330 else if(source==embeddedCalculate)
\r
2332 popup = calculatePopup = genPopupMenu(calculatePopup, calculateMenu);
\r
2334 else if(source==embeddedHelp)
\r
2336 popup = helpPopup = genPopupMenu(helpPopup, helpMenu);
\r
2339 embeddedMenu.add(popup);
\r
2340 popup.show(embeddedMenu,
\r
2341 source.getBounds().x,
\r
2342 source.getBounds().y + source.getBounds().getSize().height);
\r
2345 PopupMenu genPopupMenu(PopupMenu popup, Menu original)
\r
2351 popup = new PopupMenu();
\r
2352 int m, mSize = original.getItemCount();
\r
2353 for(m=0; m<mSize; m++)
\r
2355 popup.add(original.getItem(m));
\r
2362 public void mouseClicked(MouseEvent evt)
\r
2364 public void mouseReleased(MouseEvent evt)
\r
2366 public void mouseEntered(MouseEvent evt)
\r
2368 public void mouseExited(MouseEvent evt)
\r