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
41 jalview.bin.JalviewLite applet;
\r
43 String jalviewServletURL;
\r
46 public AlignFrame(AlignmentI al,
\r
47 jalview.bin.JalviewLite applet,
\r
52 jalviewServletURL = applet.getParameter("APPLICATION_URL");
\r
56 }catch(Exception ex)
\r
58 ex.printStackTrace();
\r
61 this.applet = applet;
\r
62 viewport = new AlignViewport(al, applet);
\r
63 alignPanel = new AlignmentPanel(this, viewport);
\r
65 annotationPanelMenuItem.setState(viewport.showAnnotation);
\r
67 seqLimits.setState(viewport.showJVSuffix);
\r
71 String param = applet.getParameter("sortBy");
\r
74 if (param.equalsIgnoreCase("Id"))
\r
75 sortIDMenuItem_actionPerformed();
\r
76 else if (param.equalsIgnoreCase("Pairwise Identity"))
\r
77 sortPairwiseMenuItem_actionPerformed();
\r
80 param = applet.getParameter("wrap");
\r
83 if (param.equalsIgnoreCase("true"))
\r
85 wrapMenuItem.setState(true);
\r
86 wrapMenuItem_actionPerformed();
\r
92 param = applet.getParameter("windowWidth");
\r
95 int width = Integer.parseInt(param);
\r
96 NEW_WINDOW_WIDTH = width;
\r
98 param = applet.getParameter("windowHeight");
\r
101 int height = Integer.parseInt(param);
\r
102 NEW_WINDOW_HEIGHT = height;
\r
105 catch (Exception ex)
\r
110 //Some JVMS send keyevents to Top frame or lowest panel,
\r
111 //Havent worked out why yet. So add to both this frame and seqCanvas for now
\r
112 this.addKeyListener(this);
\r
113 alignPanel.seqPanel.seqCanvas.addKeyListener(this);
\r
114 alignPanel.idPanel.idCanvas.addKeyListener(this);
\r
116 viewport.addPropertyChangeListener(new java.beans.PropertyChangeListener()
\r
118 public void propertyChange(java.beans.PropertyChangeEvent evt)
\r
120 if (evt.getPropertyName().equals("alignment"))
\r
122 alignmentChanged();
\r
134 add(alignPanel, BorderLayout.CENTER);
\r
135 jalview.bin.JalviewLite.addFrame(this, title, NEW_WINDOW_WIDTH,
\r
136 NEW_WINDOW_HEIGHT);
\r
138 alignPanel.validate();
\r
139 alignPanel.repaint();
\r
141 public AlignViewport getAlignViewport()
\r
146 public SeqCanvas getSeqcanvas()
\r
148 return alignPanel.seqPanel.seqCanvas;
\r
155 * @param String DOCUMENT ME!
\r
158 public void parseFeaturesFile(String file, String type)
\r
160 Hashtable featureLinks = new Hashtable();
\r
161 boolean featuresFile = false;
\r
163 featuresFile = new jalview.io.FeaturesFile(file, type).parse(viewport.alignment,
\r
164 alignPanel.seqPanel.seqCanvas.
\r
165 getFeatureRenderer().featureColours,
\r
169 catch(Exception ex)
\r
171 ex.printStackTrace();
\r
176 if(featureLinks.size()>0)
\r
177 alignPanel.seqPanel.seqCanvas
\r
178 .getFeatureRenderer().featureLinks = featureLinks;
\r
179 viewport.showSequenceFeatures = true;
\r
180 sequenceFeatures.setState(true);
\r
181 alignPanel.repaint();
\r
187 public void keyPressed(KeyEvent evt)
\r
189 if (viewport.cursorMode
\r
190 && evt.getKeyCode() >= KeyEvent.VK_0
\r
191 && evt.getKeyCode() <= KeyEvent.VK_9)
\r
193 alignPanel.seqPanel.numberPressed(evt.getKeyChar());
\r
196 switch (evt.getKeyCode())
\r
198 case 27: // escape key
\r
199 deselectAllSequenceMenuItem_actionPerformed();
\r
201 case KeyEvent.VK_X:
\r
202 if (evt.isControlDown() || evt.isMetaDown())
\r
204 cut_actionPerformed();
\r
207 case KeyEvent.VK_C:
\r
208 if (viewport.cursorMode && !evt.isControlDown())
\r
210 alignPanel.seqPanel.setCursorColumn();
\r
212 if (evt.isControlDown() || evt.isMetaDown())
\r
214 copy_actionPerformed();
\r
217 case KeyEvent.VK_V:
\r
218 if (evt.isControlDown() || evt.isMetaDown())
\r
223 case KeyEvent.VK_A:
\r
224 if (evt.isControlDown() || evt.isMetaDown())
\r
226 selectAllSequenceMenuItem_actionPerformed();
\r
229 case KeyEvent.VK_DOWN:
\r
230 if(viewport.cursorMode)
\r
232 alignPanel.seqPanel.moveCursor(0,1);
\r
235 moveSelectedSequences(false);
\r
238 case KeyEvent.VK_UP:
\r
239 if (viewport.cursorMode)
\r
241 alignPanel.seqPanel.moveCursor(0,-1);
\r
244 moveSelectedSequences(true);
\r
247 case KeyEvent.VK_LEFT:
\r
248 if(viewport.cursorMode)
\r
250 alignPanel.seqPanel.moveCursor(-1,0);
\r
254 case KeyEvent.VK_RIGHT:
\r
255 if (viewport.cursorMode)
\r
257 alignPanel.seqPanel.moveCursor(1,0);
\r
260 case KeyEvent.VK_SPACE:
\r
261 if(viewport.cursorMode)
\r
263 alignPanel.seqPanel.insertGapAtCursor(evt.isControlDown());
\r
267 case KeyEvent.VK_DELETE:
\r
268 case KeyEvent.VK_BACK_SPACE:
\r
269 if(viewport.cursorMode)
\r
271 alignPanel.seqPanel.deleteGapAtCursor(evt.isControlDown());
\r
275 cut_actionPerformed();
\r
276 alignPanel.seqPanel.seqCanvas.repaint();
\r
280 case KeyEvent.VK_S:
\r
281 if(viewport.cursorMode)
\r
283 alignPanel.seqPanel.setCursorRow();
\r
286 case KeyEvent.VK_P:
\r
287 if(viewport.cursorMode)
\r
289 alignPanel.seqPanel.setCursorPosition();
\r
293 case KeyEvent.VK_ENTER:
\r
294 case KeyEvent.VK_COMMA:
\r
295 if(viewport.cursorMode)
\r
297 alignPanel.seqPanel.setCursorRowAndColumn();
\r
301 case KeyEvent.VK_Q:
\r
302 if(viewport.cursorMode)
\r
304 alignPanel.seqPanel.setSelectionAreaAtCursor(true);
\r
307 case KeyEvent.VK_M:
\r
308 if(viewport.cursorMode)
\r
310 alignPanel.seqPanel.setSelectionAreaAtCursor(false);
\r
314 case KeyEvent.VK_F2:
\r
315 viewport.cursorMode = ! viewport.cursorMode;
\r
316 statusBar.setText("Keyboard editing mode is "+
\r
317 (viewport.cursorMode ? "on" : "off"));
\r
318 if(viewport.cursorMode)
\r
320 alignPanel.seqPanel.seqCanvas.cursorX = viewport.startRes;
\r
321 alignPanel.seqPanel.seqCanvas.cursorY = viewport.startSeq;
\r
323 alignPanel.seqPanel.seqCanvas.repaint();
\r
326 case KeyEvent.VK_F:
\r
327 if (evt.isControlDown())
\r
329 findMenuItem_actionPerformed();
\r
334 public void keyReleased(KeyEvent evt)
\r
336 public void keyTyped(KeyEvent evt)
\r
339 public void itemStateChanged(ItemEvent evt)
\r
341 if(evt.getSource()==colourTextMenuItem)
\r
342 colourTextMenuItem_actionPerformed();
\r
343 else if(evt.getSource()==wrapMenuItem)
\r
344 wrapMenuItem_actionPerformed();
\r
345 else if(evt.getSource()==scaleAbove)
\r
346 scaleAbove_actionPerformed();
\r
347 else if(evt.getSource()==scaleLeft)
\r
348 scaleLeft_actionPerformed();
\r
349 else if(evt.getSource()==scaleRight)
\r
350 scaleRight_actionPerformed();
\r
351 else if(evt.getSource()==seqLimits)
\r
352 seqLimits_itemStateChanged();
\r
353 else if(evt.getSource()==viewBoxesMenuItem)
\r
354 viewBoxesMenuItem_actionPerformed();
\r
355 else if(evt.getSource()==viewTextMenuItem)
\r
356 viewTextMenuItem_actionPerformed();
\r
357 else if(evt.getSource()==renderGapsMenuItem)
\r
358 renderGapsMenuItem_actionPerformed();
\r
359 else if(evt.getSource()==annotationPanelMenuItem)
\r
360 annotationPanelMenuItem_actionPerformed();
\r
361 else if(evt.getSource()==sequenceFeatures)
\r
363 viewport.showSequenceFeatures(sequenceFeatures.getState());
\r
364 alignPanel.seqPanel.seqCanvas.repaint();
\r
366 else if(evt.getSource()==conservationMenuItem)
\r
367 conservationMenuItem_actionPerformed();
\r
368 else if(evt.getSource()==abovePIDThreshold)
\r
369 abovePIDThreshold_actionPerformed();
\r
370 else if(evt.getSource()==applyToAllGroups)
\r
371 applyToAllGroups_actionPerformed();
\r
372 else if(evt.getSource()==autoCalculate)
\r
373 viewport.autocalculateConsensus = autoCalculate.getState();
\r
375 public void actionPerformed(ActionEvent evt)
\r
377 if(evt.getSource()==inputText)
\r
378 inputText_actionPerformed();
\r
379 else if(evt.getSource()==loadTree)
\r
380 loadTree_actionPerformed();
\r
381 else if(evt.getSource()==loadApplication)
\r
382 launchFullApplication();
\r
383 else if(evt.getSource()==closeMenuItem)
\r
384 closeMenuItem_actionPerformed();
\r
385 else if(evt.getSource()==copy)
\r
386 copy_actionPerformed();
\r
387 else if(evt.getSource()==undoMenuItem)
\r
388 undoMenuItem_actionPerformed();
\r
389 else if(evt.getSource()==redoMenuItem)
\r
390 redoMenuItem_actionPerformed();
\r
391 else if(evt.getSource()==inputText)
\r
392 inputText_actionPerformed();
\r
393 else if(evt.getSource()==closeMenuItem)
\r
394 closeMenuItem_actionPerformed();
\r
395 else if(evt.getSource()==undoMenuItem)
\r
396 undoMenuItem_actionPerformed();
\r
397 else if(evt.getSource()==redoMenuItem)
\r
398 redoMenuItem_actionPerformed();
\r
399 else if(evt.getSource()==copy)
\r
400 copy_actionPerformed();
\r
401 else if(evt.getSource()==pasteNew)
\r
402 pasteNew_actionPerformed();
\r
403 else if(evt.getSource()==pasteThis)
\r
404 pasteThis_actionPerformed();
\r
405 else if(evt.getSource()==cut)
\r
406 cut_actionPerformed();
\r
407 else if(evt.getSource()==delete)
\r
408 delete_actionPerformed();
\r
409 else if(evt.getSource()==deleteGroups)
\r
410 deleteGroups_actionPerformed();
\r
411 else if(evt.getSource()==selectAllSequenceMenuItem)
\r
412 selectAllSequenceMenuItem_actionPerformed();
\r
413 else if(evt.getSource()==deselectAllSequenceMenuItem)
\r
414 deselectAllSequenceMenuItem_actionPerformed();
\r
415 else if(evt.getSource()==invertSequenceMenuItem)
\r
416 invertSequenceMenuItem_actionPerformed();
\r
417 else if(evt.getSource()==remove2LeftMenuItem)
\r
418 remove2LeftMenuItem_actionPerformed();
\r
419 else if(evt.getSource()==remove2RightMenuItem)
\r
420 remove2RightMenuItem_actionPerformed();
\r
421 else if(evt.getSource()==removeGappedColumnMenuItem)
\r
422 removeGappedColumnMenuItem_actionPerformed();
\r
423 else if(evt.getSource()==removeAllGapsMenuItem)
\r
424 removeAllGapsMenuItem_actionPerformed();
\r
425 else if(evt.getSource()==findMenuItem)
\r
426 findMenuItem_actionPerformed();
\r
427 else if(evt.getSource()==font)
\r
428 font_actionPerformed();
\r
429 else if(evt.getSource()==featureSettings)
\r
430 featureSettings_actionPerformed();
\r
431 else if(evt.getSource()==overviewMenuItem)
\r
432 overviewMenuItem_actionPerformed();
\r
433 else if(evt.getSource()==noColourmenuItem)
\r
434 noColourmenuItem_actionPerformed();
\r
435 else if(evt.getSource()==clustalColour)
\r
436 clustalColour_actionPerformed();
\r
437 else if(evt.getSource()==zappoColour)
\r
438 zappoColour_actionPerformed();
\r
439 else if(evt.getSource()==taylorColour)
\r
440 taylorColour_actionPerformed();
\r
441 else if(evt.getSource()==hydrophobicityColour)
\r
442 hydrophobicityColour_actionPerformed();
\r
443 else if(evt.getSource()==helixColour)
\r
444 helixColour_actionPerformed();
\r
445 else if(evt.getSource()==strandColour)
\r
446 strandColour_actionPerformed();
\r
447 else if(evt.getSource()==turnColour)
\r
448 turnColour_actionPerformed();
\r
449 else if(evt.getSource()==buriedColour)
\r
450 buriedColour_actionPerformed();
\r
451 else if(evt.getSource()==nucleotideColour)
\r
452 nucleotideColour_actionPerformed();
\r
453 else if(evt.getSource()==modifyPID)
\r
454 modifyPID_actionPerformed();
\r
455 else if(evt.getSource()==modifyConservation)
\r
456 modifyConservation_actionPerformed();
\r
457 else if(evt.getSource()==userDefinedColour)
\r
458 userDefinedColour_actionPerformed();
\r
459 else if(evt.getSource()==PIDColour)
\r
460 PIDColour_actionPerformed();
\r
461 else if(evt.getSource()==BLOSUM62Colour)
\r
462 BLOSUM62Colour_actionPerformed();
\r
463 else if(evt.getSource()==annotationColour)
\r
464 new AnnotationColourChooser(viewport, alignPanel);
\r
465 else if(evt.getSource()==sortPairwiseMenuItem)
\r
466 sortPairwiseMenuItem_actionPerformed();
\r
467 else if(evt.getSource()==sortIDMenuItem)
\r
468 sortIDMenuItem_actionPerformed();
\r
469 else if(evt.getSource()==sortGroupMenuItem)
\r
470 sortGroupMenuItem_actionPerformed();
\r
471 else if(evt.getSource()==removeRedundancyMenuItem)
\r
472 removeRedundancyMenuItem_actionPerformed();
\r
473 else if(evt.getSource()==pairwiseAlignmentMenuItem)
\r
474 pairwiseAlignmentMenuItem_actionPerformed();
\r
475 else if(evt.getSource()==PCAMenuItem)
\r
476 PCAMenuItem_actionPerformed();
\r
477 else if(evt.getSource()==averageDistanceTreeMenuItem)
\r
478 averageDistanceTreeMenuItem_actionPerformed();
\r
479 else if(evt.getSource()==neighbourTreeMenuItem)
\r
480 neighbourTreeMenuItem_actionPerformed();
\r
481 else if(evt.getSource()==njTreeBlosumMenuItem)
\r
482 njTreeBlosumMenuItem_actionPerformed();
\r
483 else if(evt.getSource()==avDistanceTreeBlosumMenuItem)
\r
484 avTreeBlosumMenuItem_actionPerformed();
\r
485 else if(evt.getSource()==documentation)
\r
486 documentation_actionPerformed();
\r
487 else if(evt.getSource()==about)
\r
488 about_actionPerformed();
\r
492 public void inputText_actionPerformed()
\r
494 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
\r
495 Frame frame = new Frame();
\r
497 jalview.bin.JalviewLite.addFrame(frame, "Cut & Paste Input", 500, 500);
\r
500 protected void outputText_actionPerformed(ActionEvent e)
\r
502 CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this);
\r
503 Frame frame = new Frame();
\r
505 jalview.bin.JalviewLite.addFrame(frame,
\r
506 "Alignment output - " + e.getActionCommand(),
\r
508 cap.setText(new AppletFormatAdapter().formatSequences(e.getActionCommand(),
\r
509 viewport.getAlignment().getSequences(),
\r
510 viewport.showJVSuffix));
\r
513 void launchFullApplication()
\r
515 StringBuffer url = new StringBuffer(jalviewServletURL);
\r
517 url.append("?open="+
\r
518 appendProtocol( applet.getParameter("file") ) );
\r
520 if(applet.getParameter("features")!=null)
\r
522 url.append( "&features=" );
\r
523 url.append( appendProtocol( applet.getParameter("features") ) );
\r
526 if(applet.getParameter("defaultColour")!=null)
\r
528 url.append("&colour=" +
\r
529 removeWhiteSpace(applet.getParameter("defaultColour"))
\r
533 if(applet.getParameter("userDefinedColour")!=null)
\r
535 url.append( "&colour=" +
\r
536 removeWhiteSpace( applet.getParameter("userDefinedColour") )
\r
540 showURL(url.toString(), "FULL_APP");
\r
544 String removeWhiteSpace(String colour)
\r
546 StringBuffer sb = new StringBuffer();
\r
547 for (int i = 0; i < colour.length(); i++)
\r
549 if (Character.isWhitespace(colour.charAt(i)))
\r
552 sb.append(colour.charAt(i));
\r
555 return sb.toString();
\r
559 String appendProtocol(String url)
\r
563 }catch(java.net.MalformedURLException ex)
\r
565 url = applet.getCodeBase()+url;
\r
570 public void closeMenuItem_actionPerformed()
\r
572 PaintRefresher.components.remove(viewport.alignment);
\r
573 if(PaintRefresher.components.size()==0 && applet==null)
\r
579 Stack historyList = new Stack();
\r
580 Stack redoList = new Stack();
\r
582 void updateEditMenuBar()
\r
584 if (historyList.size() > 0)
\r
586 undoMenuItem.setEnabled(true);
\r
587 HistoryItem hi = (HistoryItem) historyList.peek();
\r
588 undoMenuItem.setLabel("Undo " + hi.getDescription());
\r
592 undoMenuItem.setEnabled(false);
\r
593 undoMenuItem.setLabel("Undo");
\r
596 if (redoList.size() > 0)
\r
598 redoMenuItem.setEnabled(true);
\r
599 HistoryItem hi = (HistoryItem) redoList.peek();
\r
600 redoMenuItem.setLabel("Redo " + hi.getDescription());
\r
604 redoMenuItem.setEnabled(false);
\r
605 redoMenuItem.setLabel("Redo");
\r
609 public void addHistoryItem(HistoryItem hi)
\r
611 historyList.push(hi);
\r
612 updateEditMenuBar();
\r
615 protected void undoMenuItem_actionPerformed()
\r
617 HistoryItem hi = (HistoryItem) historyList.pop();
\r
618 redoList.push(new HistoryItem(hi.getDescription(), viewport.alignment,
\r
619 HistoryItem.HIDE));
\r
620 restoreHistoryItem(hi);
\r
621 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
\r
624 protected void redoMenuItem_actionPerformed()
\r
626 HistoryItem hi = (HistoryItem) redoList.pop();
\r
627 restoreHistoryItem(hi);
\r
628 updateEditMenuBar();
\r
629 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
\r
632 // used by undo and redo
\r
633 void restoreHistoryItem(HistoryItem hi)
\r
637 updateEditMenuBar();
\r
639 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
\r
642 public void moveSelectedSequences(boolean up)
\r
644 SequenceGroup sg = viewport.getSelectionGroup();
\r
652 for (int i = 1; i < viewport.alignment.getHeight(); i++)
\r
654 SequenceI seq = viewport.alignment.getSequenceAt(i);
\r
655 if (!sg.getSequences(false).contains(seq))
\r
660 SequenceI temp = viewport.alignment.getSequenceAt(i - 1);
\r
661 if (sg.getSequences(false).contains(temp))
\r
666 viewport.alignment.getSequences().setElementAt(temp, i);
\r
667 viewport.alignment.getSequences().setElementAt(seq, i - 1);
\r
672 for (int i = viewport.alignment.getHeight() - 2; i > -1; i--)
\r
674 SequenceI seq = viewport.alignment.getSequenceAt(i);
\r
675 if (!sg.getSequences(true).contains(seq))
\r
680 SequenceI temp = viewport.alignment.getSequenceAt(i + 1);
\r
681 if (sg.getSequences(true).contains(temp))
\r
686 viewport.alignment.getSequences().setElementAt(temp, i);
\r
687 viewport.alignment.getSequences().setElementAt(seq, i + 1);
\r
691 alignPanel.repaint();
\r
694 StringBuffer copiedSequences;
\r
695 protected void copy_actionPerformed()
\r
697 if (viewport.getSelectionGroup() == null)
\r
702 SequenceGroup sg = viewport.getSelectionGroup();
\r
703 copiedSequences = new StringBuffer();
\r
704 Hashtable orderedSeqs = new Hashtable();
\r
705 for (int i = 0; i < sg.getSize(false); i++)
\r
707 SequenceI seq = sg.getSequenceAt(i);
\r
708 int index = viewport.alignment.findIndex(seq);
\r
709 orderedSeqs.put(index + "", seq);
\r
712 int index = 0, startRes, endRes;
\r
715 for (int i = 0; i < sg.getSize(false); i++)
\r
717 SequenceI seq = null;
\r
719 while (seq == null)
\r
721 if (orderedSeqs.containsKey(index + ""))
\r
723 seq = (SequenceI) orderedSeqs.get(index + "");
\r
735 //Returns residue following index if gap
\r
736 startRes = seq.findPosition(sg.getStartRes());
\r
739 //Need to find the residue preceeding index if gap
\r
742 for (int j = 0; j < sg.getEndRes()+1 && j < seq.getLength(); j++)
\r
744 ch = seq.getCharAt(j);
\r
745 if (!jalview.util.Comparison.isGap( (ch)))
\r
753 endRes += seq.getStart() -1;
\r
756 copiedSequences.append(seq.getName() + "\t" +
\r
759 seq.getSequence(sg.getStartRes(),
\r
760 sg.getEndRes() + 1) + "\n");
\r
765 protected void pasteNew_actionPerformed()
\r
770 protected void pasteThis_actionPerformed()
\r
772 addHistoryItem(new HistoryItem("Paste Sequences", viewport.alignment,
\r
773 HistoryItem.PASTE));
\r
777 void paste(boolean newAlignment)
\r
781 if (copiedSequences == null)
\r
786 StringTokenizer st = new StringTokenizer(copiedSequences.toString());
\r
787 Vector seqs = new Vector();
\r
788 while (st.hasMoreElements())
\r
790 String name = st.nextToken();
\r
791 int start = Integer.parseInt(st.nextToken());
\r
792 int end = Integer.parseInt(st.nextToken());
\r
793 Sequence sequence = new Sequence(name, st.nextToken(), start, end);
\r
797 viewport.alignment.addSequence(sequence);
\r
801 seqs.addElement(sequence);
\r
807 SequenceI[] newSeqs = new SequenceI[seqs.size()];
\r
808 for (int i = 0; i < seqs.size(); i++)
\r
810 newSeqs[i] = (SequenceI) seqs.elementAt(i);
\r
813 String newtitle = new String("Copied sequences");
\r
814 if (getTitle().startsWith("Copied sequences"))
\r
816 newtitle = getTitle();
\r
820 newtitle = newtitle.concat("- from " + getTitle());
\r
822 AlignFrame af = new AlignFrame(new Alignment(newSeqs),
\r
827 jalview.bin.JalviewLite.addFrame(af, newtitle, NEW_WINDOW_WIDTH,
\r
828 NEW_WINDOW_HEIGHT);
\r
832 viewport.setEndSeq(viewport.alignment.getHeight());
\r
833 viewport.alignment.getWidth();
\r
834 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
\r
838 catch (Exception ex)
\r
839 {} // could be anything being pasted in here
\r
843 protected void cut_actionPerformed()
\r
845 copy_actionPerformed();
\r
846 delete_actionPerformed();
\r
849 protected void delete_actionPerformed()
\r
851 addHistoryItem(new HistoryItem("Delete Sequences", viewport.alignment,
\r
852 HistoryItem.HIDE));
\r
853 if (viewport.getSelectionGroup() == null)
\r
859 SequenceGroup sg = viewport.getSelectionGroup();
\r
860 boolean allSequences = false;
\r
861 if(sg.getSize(false)==viewport.alignment.getHeight())
\r
862 allSequences = true;
\r
864 for (int i = 0; i < sg.getSize(false); i++)
\r
866 SequenceI seq = sg.getSequenceAt(i);
\r
867 int index = viewport.getAlignment().findIndex(seq);
\r
868 seq.deleteChars(sg.getStartRes(), sg.getEndRes() + 1);
\r
870 // If the cut affects all sequences, remove highlighted columns
\r
873 viewport.getColumnSelection().removeElements(sg.getStartRes(),
\r
874 sg.getEndRes() + 1);
\r
878 if (seq.getSequence().length() < 1)
\r
880 viewport.getAlignment().deleteSequence(seq);
\r
884 viewport.getAlignment().getSequences().setElementAt(seq, index);
\r
888 viewport.setSelectionGroup(null);
\r
889 viewport.alignment.deleteGroup(sg);
\r
890 viewport.resetSeqLimits(alignPanel.seqPanel.seqCanvas.getSize().height);
\r
891 if (viewport.getAlignment().getHeight() < 1)
\r
895 this.setVisible(false);
\r
897 catch (Exception ex)
\r
900 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
\r
904 protected void deleteGroups_actionPerformed()
\r
906 viewport.alignment.deleteAllGroups();
\r
907 viewport.setSelectionGroup(null);
\r
909 alignPanel.repaint();
\r
912 public void selectAllSequenceMenuItem_actionPerformed()
\r
914 SequenceGroup sg = new SequenceGroup();
\r
915 for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++)
\r
917 sg.addSequence(viewport.getAlignment().getSequenceAt(i), false);
\r
919 sg.setEndRes(viewport.alignment.getWidth()-1);
\r
920 viewport.setSelectionGroup(sg);
\r
921 alignPanel.repaint();
\r
922 PaintRefresher.Refresh(null, viewport.alignment);
\r
925 public void deselectAllSequenceMenuItem_actionPerformed()
\r
927 if(viewport.cursorMode)
\r
929 alignPanel.seqPanel.keyboardNo1=null;
\r
930 alignPanel.seqPanel.keyboardNo2=null;
\r
932 viewport.setSelectionGroup(null);
\r
933 viewport.getColumnSelection().clear();
\r
934 viewport.setSelectionGroup(null);
\r
935 alignPanel.idPanel.idCanvas.searchResults = null;
\r
936 alignPanel.seqPanel.seqCanvas.highlightSearchResults(null);
\r
937 alignPanel.repaint();
\r
938 PaintRefresher.Refresh(null, viewport.alignment);
\r
941 public void invertSequenceMenuItem_actionPerformed()
\r
943 SequenceGroup sg = viewport.getSelectionGroup();
\r
944 for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++)
\r
946 sg.addOrRemove(viewport.getAlignment().getSequenceAt(i), false);
\r
949 PaintRefresher.Refresh(null, viewport.alignment);
\r
952 public void remove2LeftMenuItem_actionPerformed()
\r
954 ColumnSelection colSel = viewport.getColumnSelection();
\r
955 if (colSel.size() > 0)
\r
957 addHistoryItem(new HistoryItem("Remove Left", viewport.alignment,
\r
958 HistoryItem.HIDE));
\r
959 int min = colSel.getMin();
\r
960 viewport.getAlignment().trimLeft(min);
\r
961 colSel.compensateForEdit(0, min);
\r
963 if (viewport.getSelectionGroup() != null)
\r
965 viewport.getSelectionGroup().adjustForRemoveLeft(min);
\r
968 Vector groups = viewport.alignment.getGroups();
\r
969 for (int i = 0; i < groups.size(); i++)
\r
971 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
\r
972 if (!sg.adjustForRemoveLeft(min))
\r
974 viewport.alignment.deleteGroup(sg);
\r
977 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
\r
981 public void remove2RightMenuItem_actionPerformed()
\r
983 ColumnSelection colSel = viewport.getColumnSelection();
\r
984 if (colSel.size() > 0)
\r
986 addHistoryItem(new HistoryItem("Remove Right", viewport.alignment,
\r
987 HistoryItem.HIDE));
\r
988 int max = colSel.getMax();
\r
989 viewport.getAlignment().trimRight(max);
\r
990 if (viewport.getSelectionGroup() != null)
\r
992 viewport.getSelectionGroup().adjustForRemoveRight(max);
\r
995 Vector groups = viewport.alignment.getGroups();
\r
996 for (int i = 0; i < groups.size(); i++)
\r
998 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
\r
999 if (!sg.adjustForRemoveRight(max))
\r
1001 viewport.alignment.deleteGroup(sg);
\r
1004 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
\r
1009 public void removeGappedColumnMenuItem_actionPerformed()
\r
1011 addHistoryItem(new HistoryItem("Remove Gapped Columns",
\r
1012 viewport.alignment,
\r
1013 HistoryItem.HIDE));
\r
1015 //This is to maintain viewport position on first residue
\r
1016 //of first sequence
\r
1017 SequenceI seq = viewport.alignment.getSequenceAt(0);
\r
1018 int startRes = seq.findPosition(viewport.startRes);
\r
1020 viewport.getAlignment().removeGaps();
\r
1022 viewport.setStartRes(seq.findIndex(startRes)-1);
\r
1024 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
\r
1027 public void removeAllGapsMenuItem_actionPerformed()
\r
1029 addHistoryItem(new HistoryItem("Remove Gaps", viewport.alignment,
\r
1030 HistoryItem.HIDE));
\r
1032 //This is to maintain viewport position on first residue
\r
1033 //of first sequence
\r
1034 SequenceI seq = viewport.alignment.getSequenceAt(0);
\r
1035 int startRes = seq.findPosition(viewport.startRes);
\r
1037 SequenceI current;
\r
1042 int start=0, end = viewport.alignment.getWidth();
\r
1044 if (viewport.getSelectionGroup() != null
\r
1045 && viewport.getSelectionGroup().getSequences(false) != null
\r
1046 && viewport.getSelectionGroup().getSize(false)>0)
\r
1048 seqs = viewport.getSelectionGroup().getSequences(true);
\r
1049 start = viewport.getSelectionGroup().getStartRes();
\r
1050 end = viewport.getSelectionGroup().getEndRes()+1;
\r
1053 seqs = viewport.alignment.getSequences();
\r
1055 for (int i = 0; i < seqs.size(); i++)
\r
1057 current = (SequenceI) seqs.elementAt(i);
\r
1058 jSize = current.getLength();
\r
1060 // Removing a range is much quicker than removing gaps
\r
1061 // one by one for long sequences
\r
1063 int rangeStart=-1, rangeEnd=-1;
\r
1067 if (jalview.util.Comparison.isGap(current.getCharAt(j)))
\r
1069 if(rangeStart==-1)
\r
1084 current.deleteChars(rangeStart, rangeEnd);
\r
1085 j-=rangeEnd-rangeStart;
\r
1086 jSize-=rangeEnd-rangeStart;
\r
1094 while (j < end && j < jSize);
\r
1097 current.deleteChars(rangeStart, rangeEnd);
\r
1100 viewport.setStartRes(seq.findIndex(startRes)-1);
\r
1101 viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
\r
1104 public void alignmentChanged()
\r
1106 viewport.alignment.padGaps();
\r
1107 if(viewport.autocalculateConsensus)
\r
1109 viewport.updateConsensus();
\r
1110 viewport.updateConservation();
\r
1113 resetAllColourSchemes();
\r
1114 if(alignPanel.overviewPanel!=null)
\r
1115 alignPanel.overviewPanel.updateOverviewImage();
\r
1117 viewport.alignment.adjustSequenceAnnotations();
\r
1118 alignPanel.repaint();
\r
1121 void resetAllColourSchemes()
\r
1123 ColourSchemeI cs = viewport.globalColourScheme;
\r
1126 if (cs instanceof ClustalxColourScheme)
\r
1128 ( (ClustalxColourScheme) viewport.getGlobalColourScheme()).
\r
1129 resetClustalX(viewport.alignment.getSequences(),
\r
1130 viewport.alignment.getWidth());
\r
1133 cs.setConsensus(viewport.vconsensus);
\r
1134 if (cs.conservationApplied())
\r
1136 Alignment al = (Alignment) viewport.alignment;
\r
1137 Conservation c = new Conservation("All",
\r
1138 ResidueProperties.propHash, 3,
\r
1139 al.getSequences(), 0,
\r
1140 al.getWidth() - 1);
\r
1142 c.verdict(false, viewport.ConsPercGaps);
\r
1144 cs.setConservation(c);
\r
1148 int s, sSize = viewport.alignment.getGroups().size();
\r
1149 for(s=0; s<sSize; s++)
\r
1151 SequenceGroup sg = (SequenceGroup)viewport.alignment.getGroups().elementAt(s);
\r
1152 if(sg.cs!=null && sg.cs instanceof ClustalxColourScheme)
\r
1154 ((ClustalxColourScheme)sg.cs).resetClustalX(
\r
1155 sg.getSequences(true), sg.getWidth());
\r
1157 sg.recalcConservation();
\r
1163 public void findMenuItem_actionPerformed()
\r
1165 new Finder(alignPanel);
\r
1168 public void font_actionPerformed()
\r
1170 new FontChooser(alignPanel);
\r
1174 public void seqLimits_itemStateChanged()
\r
1176 viewport.setShowJVSuffix(seqLimits.getState());
\r
1177 alignPanel.fontChanged();
\r
1178 alignPanel.repaint();
\r
1182 protected void colourTextMenuItem_actionPerformed()
\r
1184 viewport.setColourText(colourTextMenuItem.getState());
\r
1185 alignPanel.repaint();
\r
1188 protected void wrapMenuItem_actionPerformed()
\r
1190 viewport.setWrapAlignment(wrapMenuItem.getState());
\r
1191 alignPanel.setWrapAlignment(wrapMenuItem.getState());
\r
1192 scaleAbove.setEnabled(wrapMenuItem.getState());
\r
1193 scaleLeft.setEnabled(wrapMenuItem.getState());
\r
1194 scaleRight.setEnabled(wrapMenuItem.getState());
\r
1195 alignPanel.repaint();
\r
1198 protected void scaleAbove_actionPerformed()
\r
1200 viewport.setScaleAboveWrapped(scaleAbove.getState());
\r
1201 alignPanel.repaint();
\r
1204 protected void scaleLeft_actionPerformed()
\r
1206 viewport.setScaleLeftWrapped(scaleLeft.getState());
\r
1207 alignPanel.repaint();
\r
1210 protected void scaleRight_actionPerformed()
\r
1212 viewport.setScaleRightWrapped(scaleRight.getState());
\r
1213 alignPanel.repaint();
\r
1216 public void viewBoxesMenuItem_actionPerformed()
\r
1218 viewport.setShowBoxes(viewBoxesMenuItem.getState());
\r
1219 alignPanel.repaint();
\r
1222 public void viewTextMenuItem_actionPerformed()
\r
1224 viewport.setShowText(viewTextMenuItem.getState());
\r
1225 alignPanel.repaint();
\r
1228 protected void renderGapsMenuItem_actionPerformed()
\r
1230 viewport.setRenderGaps(renderGapsMenuItem.getState());
\r
1231 alignPanel.repaint();
\r
1234 public void annotationPanelMenuItem_actionPerformed()
\r
1236 viewport.setShowAnnotation(annotationPanelMenuItem.getState());
\r
1237 alignPanel.setAnnotationVisible(annotationPanelMenuItem.getState());
\r
1240 public void featureSettings_actionPerformed()
\r
1242 new FeatureSettings(viewport, alignPanel);
\r
1245 public void overviewMenuItem_actionPerformed()
\r
1247 if (alignPanel.overviewPanel != null)
\r
1252 Frame frame = new Frame();
\r
1253 OverviewPanel overview = new OverviewPanel(alignPanel);
\r
1254 frame.add(overview);
\r
1255 // +50 must allow for applet frame window
\r
1256 jalview.bin.JalviewLite.addFrame(frame, "Overview " + this.getTitle(),
\r
1257 overview.preferredSize().width,
\r
1258 overview.preferredSize().height + 50);
\r
1261 frame.addWindowListener(new WindowAdapter()
\r
1263 public void windowClosing(WindowEvent e)
\r
1265 alignPanel.setOverviewPanel(null);
\r
1269 alignPanel.setOverviewPanel(overview);
\r
1273 protected void noColourmenuItem_actionPerformed()
\r
1275 changeColour(null);
\r
1278 public void clustalColour_actionPerformed()
\r
1280 abovePIDThreshold.setState(false);
\r
1281 changeColour(new ClustalxColourScheme(viewport.alignment.getSequences(),
\r
1282 viewport.alignment.getWidth()));
\r
1285 public void zappoColour_actionPerformed()
\r
1287 changeColour(new ZappoColourScheme());
\r
1290 public void taylorColour_actionPerformed()
\r
1292 changeColour(new TaylorColourScheme());
\r
1295 public void hydrophobicityColour_actionPerformed()
\r
1297 changeColour(new HydrophobicColourScheme());
\r
1300 public void helixColour_actionPerformed()
\r
1302 changeColour(new HelixColourScheme());
\r
1305 public void strandColour_actionPerformed()
\r
1307 changeColour(new StrandColourScheme());
\r
1310 public void turnColour_actionPerformed()
\r
1312 changeColour(new TurnColourScheme());
\r
1315 public void buriedColour_actionPerformed()
\r
1317 changeColour(new BuriedColourScheme());
\r
1320 public void nucleotideColour_actionPerformed()
\r
1322 changeColour(new NucleotideColourScheme());
\r
1325 protected void applyToAllGroups_actionPerformed()
\r
1327 viewport.setColourAppliesToAllGroups(applyToAllGroups.getState());
\r
1330 void changeColour(ColourSchemeI cs)
\r
1332 int threshold = 0;
\r
1336 if (viewport.getAbovePIDThreshold())
\r
1338 threshold = SliderPanel.setPIDSliderSource(alignPanel, cs, "Background");
\r
1340 cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus());
\r
1342 viewport.setGlobalColourScheme(cs);
\r
1346 cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
\r
1349 if (viewport.getConservationSelected())
\r
1352 Alignment al = (Alignment) viewport.alignment;
\r
1353 Conservation c = new Conservation("All",
\r
1354 ResidueProperties.propHash, 3,
\r
1355 al.getSequences(), 0,
\r
1356 al.getWidth() - 1);
\r
1359 c.verdict(false, viewport.ConsPercGaps);
\r
1361 cs.setConservation(c);
\r
1363 cs.setConservationInc(SliderPanel.setConservationSlider(alignPanel, cs,
\r
1369 cs.setConservation(null);
\r
1372 cs.setConsensus(viewport.vconsensus);
\r
1375 viewport.setGlobalColourScheme(cs);
\r
1377 if (viewport.getColourAppliesToAllGroups())
\r
1379 Vector groups = viewport.alignment.getGroups();
\r
1380 for (int i = 0; i < groups.size(); i++)
\r
1382 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
\r
1389 if (cs instanceof ClustalxColourScheme)
\r
1391 sg.cs = new ClustalxColourScheme(sg.getSequences(true), sg.getWidth());
\r
1397 sg.cs = (ColourSchemeI) cs.getClass().newInstance();
\r
1399 catch (Exception ex)
\r
1401 ex.printStackTrace();
\r
1406 if (viewport.getAbovePIDThreshold()
\r
1407 || cs instanceof PIDColourScheme
\r
1408 || cs instanceof Blosum62ColourScheme)
\r
1410 sg.cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus());
\r
1411 sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(true), 0, sg.getWidth()));
\r
1414 sg.cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
\r
1416 if (viewport.getConservationSelected())
\r
1418 Conservation c = new Conservation("Group",
\r
1419 ResidueProperties.propHash, 3,
\r
1420 sg.getSequences(true), 0,
\r
1421 viewport.alignment.getWidth() - 1);
\r
1423 c.verdict(false, viewport.ConsPercGaps);
\r
1424 sg.cs.setConservation(c);
\r
1428 sg.cs.setConservation(null);
\r
1429 sg.cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
\r
1436 if (alignPanel.getOverviewPanel() != null)
\r
1438 alignPanel.getOverviewPanel().updateOverviewImage();
\r
1441 alignPanel.repaint();
\r
1446 protected void modifyPID_actionPerformed()
\r
1448 if (viewport.getAbovePIDThreshold() && viewport.globalColourScheme!=null)
\r
1450 SliderPanel.setPIDSliderSource(alignPanel, viewport.getGlobalColourScheme(),
\r
1452 SliderPanel.showPIDSlider();
\r
1456 protected void modifyConservation_actionPerformed()
\r
1458 if (viewport.getConservationSelected() && viewport.globalColourScheme!=null)
\r
1460 SliderPanel.setConservationSlider(alignPanel, viewport.globalColourScheme,
\r
1462 SliderPanel.showConservationSlider();
\r
1466 protected void conservationMenuItem_actionPerformed()
\r
1468 viewport.setConservationSelected(conservationMenuItem.getState());
\r
1470 viewport.setAbovePIDThreshold(false);
\r
1471 abovePIDThreshold.setState(false);
\r
1473 changeColour(viewport.getGlobalColourScheme());
\r
1475 modifyConservation_actionPerformed();
\r
1478 public void abovePIDThreshold_actionPerformed()
\r
1480 viewport.setAbovePIDThreshold(abovePIDThreshold.getState());
\r
1482 conservationMenuItem.setState(false);
\r
1483 viewport.setConservationSelected(false);
\r
1485 changeColour(viewport.getGlobalColourScheme());
\r
1487 modifyPID_actionPerformed();
\r
1490 public void userDefinedColour_actionPerformed()
\r
1492 new UserDefinedColours(alignPanel, null);
\r
1495 public void PIDColour_actionPerformed()
\r
1497 changeColour(new PIDColourScheme());
\r
1500 public void BLOSUM62Colour_actionPerformed()
\r
1502 changeColour(new Blosum62ColourScheme());
\r
1505 public void sortPairwiseMenuItem_actionPerformed()
\r
1507 addHistoryItem(new HistoryItem("Pairwise Sort", viewport.alignment,
\r
1508 HistoryItem.SORT));
\r
1509 AlignmentSorter.sortByPID(viewport.getAlignment(),
\r
1510 viewport.getAlignment().getSequenceAt(0));
\r
1511 alignPanel.repaint();
\r
1514 public void sortIDMenuItem_actionPerformed()
\r
1516 addHistoryItem(new HistoryItem("ID Sort", viewport.alignment,
\r
1517 HistoryItem.SORT));
\r
1518 AlignmentSorter.sortByID(viewport.getAlignment());
\r
1519 alignPanel.repaint();
\r
1522 public void sortGroupMenuItem_actionPerformed()
\r
1524 addHistoryItem(new HistoryItem("Group Sort", viewport.alignment,
\r
1525 HistoryItem.SORT));
\r
1526 AlignmentSorter.sortByGroup(viewport.getAlignment());
\r
1527 alignPanel.repaint();
\r
1531 public void removeRedundancyMenuItem_actionPerformed()
\r
1533 new RedundancyPanel(alignPanel);
\r
1536 public void pairwiseAlignmentMenuItem_actionPerformed()
\r
1538 if (viewport.getSelectionGroup().getSize(false) > 1)
\r
1540 Frame frame = new Frame();
\r
1541 frame.add(new PairwiseAlignPanel(alignPanel));
\r
1542 jalview.bin.JalviewLite.addFrame(frame, "Pairwise Alignment", 600, 500);
\r
1546 public void PCAMenuItem_actionPerformed()
\r
1548 //are the sequences aligned?
\r
1549 if (!viewport.alignment.isAligned())
\r
1551 SequenceI current;
\r
1552 int Width = viewport.getAlignment().getWidth();
\r
1554 for (int i = 0; i < viewport.getAlignment().getSequences().size();
\r
1557 current = viewport.getAlignment().getSequenceAt(i);
\r
1559 if (current.getLength() < Width)
\r
1561 current.insertCharAt(Width - 1, viewport.getGapCharacter());
\r
1564 alignPanel.repaint();
\r
1567 if ( (viewport.getSelectionGroup() != null &&
\r
1568 viewport.getSelectionGroup().getSize(false) < 4 &&
\r
1569 viewport.getSelectionGroup().getSize(false) > 0)
\r
1570 || viewport.getAlignment().getHeight() < 4)
\r
1577 new PCAPanel(viewport);
\r
1579 catch (java.lang.OutOfMemoryError ex)
\r
1585 public void averageDistanceTreeMenuItem_actionPerformed()
\r
1587 NewTreePanel("AV", "PID", "Average distance tree using PID");
\r
1590 public void neighbourTreeMenuItem_actionPerformed()
\r
1592 NewTreePanel("NJ", "PID", "Neighbour joining tree using PID");
\r
1595 protected void njTreeBlosumMenuItem_actionPerformed()
\r
1597 NewTreePanel("NJ", "BL", "Neighbour joining tree using BLOSUM62");
\r
1600 protected void avTreeBlosumMenuItem_actionPerformed()
\r
1602 NewTreePanel("AV", "BL", "Average distance tree using BLOSUM62PID");
\r
1605 void NewTreePanel(String type, String pwType, String title)
\r
1607 //are the sequences aligned?
\r
1608 if (!viewport.alignment.isAligned())
\r
1610 SequenceI current;
\r
1611 int Width = viewport.getAlignment().getWidth();
\r
1613 for (int i = 0; i < viewport.getAlignment().getSequences().size();
\r
1616 current = viewport.getAlignment().getSequenceAt(i);
\r
1618 if (current.getLength() < Width)
\r
1620 current.insertCharAt(Width - 1, viewport.getGapCharacter());
\r
1623 alignPanel.repaint();
\r
1627 final TreePanel tp;
\r
1628 if (viewport.getSelectionGroup() != null &&
\r
1629 viewport.getSelectionGroup().getSize(false) > 3)
\r
1631 tp = new TreePanel(viewport,
\r
1632 viewport.getSelectionGroup().getSequences(false),
\r
1635 0, viewport.alignment.getWidth());
\r
1639 tp = new TreePanel(viewport, viewport.getAlignment().getSequences(),
\r
1640 type, pwType, 0, viewport.alignment.getWidth());
\r
1643 addTreeMenuItem(tp, title);
\r
1645 jalview.bin.JalviewLite.addFrame(tp, title, 600, 500);
\r
1648 void loadTree_actionPerformed()
\r
1650 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
\r
1651 cap.setText("Paste your Newick tree file here.");
\r
1652 cap.treeImport = true;
\r
1653 Frame frame = new Frame();
\r
1655 jalview.bin.JalviewLite.addFrame(frame, "Paste Newick file ", 400, 300);
\r
1658 public void loadTree(jalview.io.NewickFile tree, String treeFile)
\r
1660 TreePanel tp = new TreePanel(viewport,
\r
1661 viewport.getAlignment().getSequences(),
\r
1662 tree, "From File - ", treeFile);
\r
1663 jalview.bin.JalviewLite.addFrame(tp, treeFile, 600, 500);
\r
1664 addTreeMenuItem(tp, treeFile);
\r
1667 void addTreeMenuItem(final TreePanel treePanel, String title)
\r
1669 final MenuItem item = new MenuItem(title);
\r
1670 sortByTreeMenu.add(item);
\r
1671 item.addActionListener(new java.awt.event.ActionListener()
\r
1673 public void actionPerformed(ActionEvent evt)
\r
1675 addHistoryItem(new HistoryItem("Sort", viewport.alignment,
\r
1676 HistoryItem.SORT));
\r
1677 AlignmentSorter.sortByTree(viewport.getAlignment(), treePanel.getTree());
\r
1678 alignPanel.repaint();
\r
1682 treePanel.addWindowListener(new WindowAdapter()
\r
1684 public void windowClosing(WindowEvent e)
\r
1686 sortByTreeMenu.remove(item);
\r
1691 protected void documentation_actionPerformed()
\r
1693 showURL("http://www.jalview.org/help.html", "HELP");
\r
1696 protected void about_actionPerformed()
\r
1699 class AboutPanel extends Canvas
\r
1702 public AboutPanel(String version)
\r
1703 { this.version = version; }
\r
1705 public void paint(Graphics g)
\r
1707 g.setColor(Color.white);
\r
1708 g.fillRect(0, 0, getSize().width, getSize().height);
\r
1709 g.setFont(new Font("Helvetica", Font.PLAIN, 12));
\r
1710 FontMetrics fm = g.getFontMetrics();
\r
1711 int fh = fm.getHeight();
\r
1713 g.setColor(Color.black);
\r
1714 g.setFont(new Font("Helvetica", Font.BOLD, 14));
\r
1715 g.drawString("Jalview - Release "+version, 200, y += fh);
\r
1716 g.setFont(new Font("Helvetica", Font.PLAIN, 12));
\r
1717 g.drawString("Authors: Michele Clamp, James Cuff, Steve Searle, Andrew Waterhouse, Jim Procter & Geoff Barton.",
\r
1719 g.drawString("Current development managed by Andrew Waterhouse; Barton Group, University of Dundee.",
\r
1722 "For any issues relating to Jalview, email help@jalview.org", x,
\r
1724 g.drawString("If you use JalView, please cite:", x, y += fh + 8);
\r
1725 g.drawString("\"Clamp, M., Cuff, J., Searle, S. M. and Barton, G. J. (2004), The Jalview Java Alignment Editor\"",
\r
1727 g.drawString("Bioinformatics, 2004 20;426-7.", x, y += fh);
\r
1731 String version = "test";
\r
1732 java.net.URL url = getClass().getResource("/.build_properties");
\r
1737 BufferedReader reader = new BufferedReader(new InputStreamReader(
\r
1738 url.openStream()));
\r
1740 while ( (line = reader.readLine()) != null)
\r
1742 if (line.indexOf("VERSION") > -1)
\r
1744 version = line.substring(line.indexOf("=") + 1);
\r
1748 catch (Exception ex)
\r
1750 ex.printStackTrace();
\r
1755 Frame frame = new Frame();
\r
1756 frame.add(new AboutPanel(version));
\r
1757 jalview.bin.JalviewLite.addFrame(frame, "Jalview", 580, 200);
\r
1761 public void showURL(String url, String target)
\r
1763 if (applet == null)
\r
1765 System.out.println("Not running as applet - no browser available.");
\r
1771 System.out.println("Show url: "+url);
\r
1772 applet.getAppletContext().showDocument(new java.net.URL(url),
\r
1775 catch (Exception ex)
\r
1777 ex.printStackTrace();
\r
1783 //////////////////////////////////////////////////////////////////////////////////
\r
1784 //JBuilder Graphics here
\r
1786 protected MenuBar alignFrameMenuBar = new MenuBar();
\r
1787 protected Menu fileMenu = new Menu("File");
\r
1788 protected MenuItem loadApplication = new MenuItem("View in Full Application");
\r
1789 protected MenuItem loadTree = new MenuItem("Load Associated Tree");
\r
1790 protected MenuItem closeMenuItem = new MenuItem("Close");
\r
1791 protected Menu editMenu = new Menu("Edit");
\r
1792 protected Menu viewMenu = new Menu("View");
\r
1793 protected Menu colourMenu = new Menu("Colour");
\r
1794 protected Menu calculateMenu = new Menu("Calculate");
\r
1795 protected MenuItem selectAllSequenceMenuItem = new MenuItem("Select all");
\r
1796 protected MenuItem deselectAllSequenceMenuItem = new MenuItem("Deselect All");
\r
1797 protected MenuItem invertSequenceMenuItem = new MenuItem("Invert Selection");
\r
1798 protected MenuItem remove2LeftMenuItem = new MenuItem();
\r
1799 protected MenuItem remove2RightMenuItem = new MenuItem();
\r
1800 protected MenuItem removeGappedColumnMenuItem = new MenuItem();
\r
1801 protected MenuItem removeAllGapsMenuItem = new MenuItem();
\r
1802 protected CheckboxMenuItem viewBoxesMenuItem = new CheckboxMenuItem();
\r
1803 protected CheckboxMenuItem viewTextMenuItem = new CheckboxMenuItem();
\r
1804 protected MenuItem sortPairwiseMenuItem = new MenuItem();
\r
1805 protected MenuItem sortIDMenuItem = new MenuItem();
\r
1806 protected MenuItem sortGroupMenuItem = new MenuItem();
\r
1807 protected MenuItem removeRedundancyMenuItem = new MenuItem();
\r
1808 protected MenuItem pairwiseAlignmentMenuItem = new MenuItem();
\r
1809 protected MenuItem PCAMenuItem = new MenuItem();
\r
1810 protected MenuItem averageDistanceTreeMenuItem = new MenuItem();
\r
1811 protected MenuItem neighbourTreeMenuItem = new MenuItem();
\r
1812 BorderLayout borderLayout1 = new BorderLayout();
\r
1813 public Label statusBar = new Label();
\r
1814 protected Menu outputTextboxMenu = new Menu();
\r
1815 protected MenuItem clustalColour = new MenuItem();
\r
1816 protected MenuItem zappoColour = new MenuItem();
\r
1817 protected MenuItem taylorColour = new MenuItem();
\r
1818 protected MenuItem hydrophobicityColour = new MenuItem();
\r
1819 protected MenuItem helixColour = new MenuItem();
\r
1820 protected MenuItem strandColour = new MenuItem();
\r
1821 protected MenuItem turnColour = new MenuItem();
\r
1822 protected MenuItem buriedColour = new MenuItem();
\r
1823 protected MenuItem userDefinedColour = new MenuItem();
\r
1824 protected MenuItem PIDColour = new MenuItem();
\r
1825 protected MenuItem BLOSUM62Colour = new MenuItem();
\r
1826 MenuItem njTreeBlosumMenuItem = new MenuItem();
\r
1827 MenuItem avDistanceTreeBlosumMenuItem = new MenuItem();
\r
1828 protected CheckboxMenuItem annotationPanelMenuItem = new CheckboxMenuItem();
\r
1829 protected CheckboxMenuItem colourTextMenuItem = new CheckboxMenuItem();
\r
1830 MenuItem overviewMenuItem = new MenuItem();
\r
1831 protected MenuItem undoMenuItem = new MenuItem();
\r
1832 protected MenuItem redoMenuItem = new MenuItem();
\r
1833 protected CheckboxMenuItem conservationMenuItem = new CheckboxMenuItem();
\r
1834 MenuItem noColourmenuItem = new MenuItem();
\r
1835 protected CheckboxMenuItem wrapMenuItem = new CheckboxMenuItem();
\r
1836 protected CheckboxMenuItem renderGapsMenuItem = new CheckboxMenuItem();
\r
1837 MenuItem findMenuItem = new MenuItem();
\r
1838 Menu searchMenu = new Menu();
\r
1839 protected CheckboxMenuItem abovePIDThreshold = new CheckboxMenuItem();
\r
1840 protected MenuItem nucleotideColour = new MenuItem();
\r
1841 MenuItem deleteGroups = new MenuItem();
\r
1842 MenuItem delete = new MenuItem();
\r
1843 MenuItem copy = new MenuItem();
\r
1844 MenuItem cut = new MenuItem();
\r
1845 Menu pasteMenu = new Menu();
\r
1846 MenuItem pasteNew = new MenuItem();
\r
1847 MenuItem pasteThis = new MenuItem();
\r
1848 protected CheckboxMenuItem applyToAllGroups = new CheckboxMenuItem();
\r
1849 protected MenuItem font = new MenuItem();
\r
1850 protected CheckboxMenuItem scaleAbove = new CheckboxMenuItem();
\r
1851 protected CheckboxMenuItem scaleLeft = new CheckboxMenuItem();
\r
1852 protected CheckboxMenuItem scaleRight = new CheckboxMenuItem();
\r
1853 MenuItem modifyPID = new MenuItem();
\r
1854 MenuItem modifyConservation = new MenuItem();
\r
1855 protected CheckboxMenuItem autoCalculate
\r
1856 = new CheckboxMenuItem("Autocalculate Consensus", true);
\r
1857 protected Menu sortByTreeMenu = new Menu();
\r
1858 Menu sort = new Menu();
\r
1859 Menu calculate = new Menu();
\r
1860 MenuItem inputText = new MenuItem();
\r
1861 Menu helpMenu = new Menu();
\r
1862 MenuItem documentation = new MenuItem();
\r
1863 MenuItem about = new MenuItem();
\r
1864 protected CheckboxMenuItem seqLimits = new CheckboxMenuItem();
\r
1865 Panel embeddedMenu;
\r
1866 Label embeddedEdit;
\r
1867 Label embeddedSearch;
\r
1868 Label embeddedView;
\r
1869 Label embeddedColour;
\r
1870 Label embeddedFile;
\r
1871 Label embeddedHelp;
\r
1872 Label embeddedCalculate;
\r
1873 FlowLayout flowLayout1;
\r
1875 private void jbInit() throws Exception {
\r
1877 setMenuBar(alignFrameMenuBar);
\r
1881 // dynamically fill save as menu with available formats
\r
1882 for (int i = 0; i < jalview.io.AppletFormatAdapter.formats.size(); i++)
\r
1885 item = new MenuItem( (String) jalview.io.AppletFormatAdapter.formats.
\r
1888 item.addActionListener(new java.awt.event.ActionListener()
\r
1890 public void actionPerformed(ActionEvent e)
\r
1892 outputText_actionPerformed(e);
\r
1896 outputTextboxMenu.add(item);
\r
1898 closeMenuItem.addActionListener(this);
\r
1899 loadApplication.addActionListener(this);
\r
1901 loadTree.addActionListener(this);
\r
1902 selectAllSequenceMenuItem.addActionListener(this);
\r
1903 deselectAllSequenceMenuItem.addActionListener(this);
\r
1904 invertSequenceMenuItem.addActionListener(this);
\r
1905 remove2LeftMenuItem.setLabel("Remove Left");
\r
1906 remove2LeftMenuItem.addActionListener(this);
\r
1907 remove2RightMenuItem.setLabel("Remove Right");
\r
1908 remove2RightMenuItem.addActionListener(this);
\r
1909 removeGappedColumnMenuItem.setLabel("Remove Empty Columns");
\r
1910 removeGappedColumnMenuItem.addActionListener(this);
\r
1911 removeAllGapsMenuItem.setLabel("Remove All Gaps");
\r
1912 removeAllGapsMenuItem.addActionListener(this);
\r
1913 viewBoxesMenuItem.setLabel("Boxes");
\r
1914 viewBoxesMenuItem.setState(true);
\r
1915 viewBoxesMenuItem.addItemListener(this);
\r
1916 viewTextMenuItem.setLabel("Text");
\r
1917 viewTextMenuItem.setState(true);
\r
1918 viewTextMenuItem.addItemListener(this);
\r
1919 sortPairwiseMenuItem.setLabel("by Pairwise Identity");
\r
1920 sortPairwiseMenuItem.addActionListener(this);
\r
1921 sortIDMenuItem.setLabel("by ID");
\r
1922 sortIDMenuItem.addActionListener(this);
\r
1923 sortGroupMenuItem.setLabel("by Group");
\r
1924 sortGroupMenuItem.addActionListener(this);
\r
1925 removeRedundancyMenuItem.setLabel("Remove Redundancy...");
\r
1926 removeRedundancyMenuItem.addActionListener(this);
\r
1927 pairwiseAlignmentMenuItem.setLabel("Pairwise Alignments...");
\r
1928 pairwiseAlignmentMenuItem.addActionListener(this);
\r
1929 PCAMenuItem.setLabel("Principal Component Analysis");
\r
1930 PCAMenuItem.addActionListener(this);
\r
1931 averageDistanceTreeMenuItem.setLabel(
\r
1932 "Average Distance Using % Identity");
\r
1933 averageDistanceTreeMenuItem.addActionListener(this);
\r
1934 neighbourTreeMenuItem.setLabel("Neighbour Joining Using % Identity");
\r
1935 neighbourTreeMenuItem.addActionListener(this);
\r
1936 alignFrameMenuBar.setFont(new java.awt.Font("Verdana", 0, 11));
\r
1937 statusBar.setBackground(Color.white);
\r
1938 statusBar.setFont(new java.awt.Font("Verdana", 0, 11));
\r
1939 statusBar.setText("Status bar");
\r
1940 outputTextboxMenu.setLabel("Output to Textbox");
\r
1941 clustalColour.setLabel("Clustalx");
\r
1943 clustalColour.addActionListener(this);
\r
1944 zappoColour.setLabel("Zappo");
\r
1945 zappoColour.addActionListener(this);
\r
1946 taylorColour.setLabel("Taylor");
\r
1947 taylorColour.addActionListener(this);
\r
1948 hydrophobicityColour.setLabel("Hydrophobicity");
\r
1949 hydrophobicityColour.addActionListener(this);
\r
1950 helixColour.setLabel("Helix Propensity");
\r
1951 helixColour.addActionListener(this);
\r
1952 strandColour.setLabel("Strand Propensity");
\r
1953 strandColour.addActionListener(this);
\r
1954 turnColour.setLabel("Turn Propensity");
\r
1955 turnColour.addActionListener(this);
\r
1956 buriedColour.setLabel("Buried Index");
\r
1957 buriedColour.addActionListener(this);
\r
1958 userDefinedColour.setLabel("User Defined...");
\r
1959 userDefinedColour.addActionListener(this);
\r
1960 PIDColour.setLabel("Percentage Identity");
\r
1961 PIDColour.addActionListener(this);
\r
1962 BLOSUM62Colour.setLabel("BLOSUM62 Score");
\r
1963 BLOSUM62Colour.addActionListener(this);
\r
1964 avDistanceTreeBlosumMenuItem.setLabel(
\r
1965 "Average Distance Using BLOSUM62");
\r
1966 avDistanceTreeBlosumMenuItem.addActionListener(this);
\r
1967 njTreeBlosumMenuItem.setLabel("Neighbour Joining Using BLOSUM62");
\r
1968 njTreeBlosumMenuItem.addActionListener(this);
\r
1969 annotationPanelMenuItem.setLabel("Show Annotations");
\r
1970 annotationPanelMenuItem.addItemListener(this);
\r
1971 colourTextMenuItem.setLabel("Colour Text");
\r
1972 colourTextMenuItem.addItemListener(this);
\r
1973 overviewMenuItem.setLabel("Overview Window");
\r
1974 overviewMenuItem.addActionListener(this);
\r
1975 undoMenuItem.setEnabled(false);
\r
1976 undoMenuItem.setLabel("Undo");
\r
1977 undoMenuItem.addActionListener(this);
\r
1978 redoMenuItem.setEnabled(false);
\r
1979 redoMenuItem.setLabel("Redo");
\r
1980 redoMenuItem.addActionListener(this);
\r
1981 conservationMenuItem.setLabel("by Conservation");
\r
1982 conservationMenuItem.addItemListener(this);
\r
1983 noColourmenuItem.setLabel("None");
\r
1984 noColourmenuItem.addActionListener(this);
\r
1985 wrapMenuItem.setLabel("Wrap");
\r
1986 wrapMenuItem.addItemListener(this);
\r
1987 renderGapsMenuItem.setLabel("Show Gaps");
\r
1988 renderGapsMenuItem.setState(true);
\r
1989 renderGapsMenuItem.addItemListener(this);
\r
1990 findMenuItem.setLabel("Find...");
\r
1991 findMenuItem.addActionListener(this);
\r
1992 searchMenu.setLabel("Search");
\r
1994 abovePIDThreshold.setLabel("Above Identity Threshold");
\r
1995 abovePIDThreshold.addItemListener(this);
\r
1996 nucleotideColour.setLabel("Nucleotide");
\r
1997 nucleotideColour.addActionListener(this);
\r
1998 deleteGroups.setLabel("Undefine Groups");
\r
1999 deleteGroups.addActionListener(this);
\r
2000 copy.setLabel("Copy");
\r
2001 copy.addActionListener(this);
\r
2002 cut.setLabel("Cut");
\r
2003 cut.addActionListener(this);
\r
2004 delete.setLabel("Delete");
\r
2005 delete.addActionListener(this);
\r
2006 pasteMenu.setLabel("Paste");
\r
2007 pasteNew.setLabel("To New Alignment");
\r
2008 pasteNew.addActionListener(this);
\r
2009 pasteThis.setLabel("Add To This Alignment");
\r
2010 pasteThis.addActionListener(this);
\r
2011 applyToAllGroups.setLabel("Apply Colour To All Groups");
\r
2012 applyToAllGroups.setState(true);
\r
2013 applyToAllGroups.addItemListener(this);
\r
2014 font.setLabel("Font...");
\r
2015 font.addActionListener(this);
\r
2016 scaleAbove.setLabel("Scale Above");
\r
2017 scaleAbove.setState(true);
\r
2018 scaleAbove.setEnabled(false);
\r
2019 scaleAbove.addItemListener(this);
\r
2020 scaleLeft.setEnabled(false);
\r
2021 scaleLeft.setState(true);
\r
2022 scaleLeft.setLabel("Scale Left");
\r
2023 scaleLeft.addItemListener(this);
\r
2024 scaleRight.setEnabled(false);
\r
2025 scaleRight.setState(true);
\r
2026 scaleRight.setLabel("Scale Right");
\r
2027 scaleRight.addItemListener(this);
\r
2028 modifyPID.setLabel("Modify Identity Threshold...");
\r
2029 modifyPID.addActionListener(this);
\r
2030 modifyConservation.setLabel("Modify Conservation Threshold...");
\r
2031 modifyConservation.addActionListener(this);
\r
2032 sortByTreeMenu.setLabel("By Tree Order");
\r
2033 sort.setLabel("Sort");
\r
2034 calculate.setLabel("Calculate Tree");
\r
2035 autoCalculate.addItemListener(this);
\r
2036 inputText.setLabel("Input from textbox");
\r
2037 inputText.addActionListener(this);
\r
2039 helpMenu.setLabel("Help");
\r
2040 documentation.setLabel("Documentation");
\r
2041 documentation.addActionListener(this);
\r
2043 about.setLabel("About...");
\r
2044 about.addActionListener(this);
\r
2045 seqLimits.setState(true);
\r
2046 seqLimits.setLabel("Show Sequence Limits");
\r
2047 seqLimits.addItemListener(this);
\r
2048 featureSettings.setLabel("Feature Settings...");
\r
2049 featureSettings.addActionListener(this);
\r
2050 sequenceFeatures.setLabel("Sequence Features");
\r
2051 sequenceFeatures.addItemListener(this);
\r
2052 sequenceFeatures.setState(false);
\r
2053 annotationColour.setLabel("by Annotation...");
\r
2054 annotationColour.addActionListener(this);
\r
2056 alignFrameMenuBar.add(fileMenu);
\r
2057 alignFrameMenuBar.add(editMenu);
\r
2058 alignFrameMenuBar.add(searchMenu);
\r
2059 alignFrameMenuBar.add(viewMenu);
\r
2060 alignFrameMenuBar.add(colourMenu);
\r
2061 alignFrameMenuBar.add(calculateMenu);
\r
2062 alignFrameMenuBar.add(helpMenu);
\r
2063 fileMenu.add(inputText);
\r
2064 fileMenu.add(outputTextboxMenu);
\r
2065 if(jalviewServletURL!=null)
\r
2066 fileMenu.add(loadApplication);
\r
2067 fileMenu.addSeparator();
\r
2068 fileMenu.add(loadTree);
\r
2069 fileMenu.add(closeMenuItem);
\r
2070 editMenu.add(undoMenuItem);
\r
2071 editMenu.add(redoMenuItem);
\r
2072 editMenu.add(cut);
\r
2073 editMenu.add(copy);
\r
2074 editMenu.add(pasteMenu);
\r
2075 editMenu.add(delete);
\r
2076 editMenu.addSeparator();
\r
2077 editMenu.add(selectAllSequenceMenuItem);
\r
2078 editMenu.add(deselectAllSequenceMenuItem);
\r
2079 editMenu.add(invertSequenceMenuItem);
\r
2080 editMenu.add(deleteGroups);
\r
2081 editMenu.addSeparator();
\r
2082 editMenu.add(remove2LeftMenuItem);
\r
2083 editMenu.add(remove2RightMenuItem);
\r
2084 editMenu.add(removeGappedColumnMenuItem);
\r
2085 editMenu.add(removeAllGapsMenuItem);
\r
2086 editMenu.add(removeRedundancyMenuItem);
\r
2087 searchMenu.add(findMenuItem);
\r
2088 viewMenu.add(font);
\r
2089 viewMenu.addSeparator();
\r
2090 viewMenu.add(seqLimits);
\r
2091 viewMenu.addSeparator();
\r
2092 viewMenu.add(wrapMenuItem);
\r
2093 viewMenu.add(scaleAbove);
\r
2094 viewMenu.add(scaleLeft);
\r
2095 viewMenu.add(scaleRight);
\r
2096 viewMenu.addSeparator();
\r
2097 viewMenu.add(viewBoxesMenuItem);
\r
2098 viewMenu.add(viewTextMenuItem);
\r
2099 viewMenu.add(colourTextMenuItem);
\r
2100 viewMenu.add(renderGapsMenuItem);
\r
2101 viewMenu.add(annotationPanelMenuItem);
\r
2102 viewMenu.addSeparator();
\r
2103 viewMenu.add(sequenceFeatures);
\r
2104 viewMenu.add(featureSettings);
\r
2105 viewMenu.addSeparator();
\r
2106 viewMenu.add(overviewMenuItem);
\r
2107 colourMenu.add(applyToAllGroups);
\r
2108 colourMenu.addSeparator();
\r
2109 colourMenu.add(noColourmenuItem);
\r
2110 colourMenu.add(clustalColour);
\r
2111 colourMenu.add(BLOSUM62Colour);
\r
2112 colourMenu.add(PIDColour);
\r
2113 colourMenu.add(zappoColour);
\r
2114 colourMenu.add(taylorColour);
\r
2115 colourMenu.add(hydrophobicityColour);
\r
2116 colourMenu.add(helixColour);
\r
2117 colourMenu.add(strandColour);
\r
2118 colourMenu.add(turnColour);
\r
2119 colourMenu.add(buriedColour);
\r
2120 colourMenu.add(nucleotideColour);
\r
2121 colourMenu.add(userDefinedColour);
\r
2122 colourMenu.addSeparator();
\r
2123 colourMenu.add(conservationMenuItem);
\r
2124 colourMenu.add(modifyConservation);
\r
2125 colourMenu.add(abovePIDThreshold);
\r
2126 colourMenu.add(modifyPID);
\r
2127 colourMenu.add(annotationColour);
\r
2128 calculateMenu.add(sort);
\r
2129 calculateMenu.add(calculate);
\r
2130 calculateMenu.addSeparator();
\r
2131 calculateMenu.add(pairwiseAlignmentMenuItem);
\r
2132 calculateMenu.add(PCAMenuItem);
\r
2133 calculateMenu.add(autoCalculate);
\r
2134 this.add(statusBar, BorderLayout.SOUTH);
\r
2135 pasteMenu.add(pasteNew);
\r
2136 pasteMenu.add(pasteThis);
\r
2137 sort.add(sortIDMenuItem);
\r
2138 sort.add(sortByTreeMenu);
\r
2139 sort.add(sortGroupMenuItem);
\r
2140 sort.add(sortPairwiseMenuItem);
\r
2141 calculate.add(averageDistanceTreeMenuItem);
\r
2142 calculate.add(neighbourTreeMenuItem);
\r
2143 calculate.add(avDistanceTreeBlosumMenuItem);
\r
2144 calculate.add(njTreeBlosumMenuItem);
\r
2145 helpMenu.add(documentation);
\r
2146 helpMenu.add(about);
\r
2149 public void setEmbedded()
\r
2152 embeddedMenu = new Panel();
\r
2153 embeddedEdit = new Label();
\r
2154 embeddedSearch = new Label();
\r
2155 embeddedView = new Label();
\r
2156 embeddedColour = new Label();
\r
2157 embeddedFile = new Label();
\r
2158 embeddedHelp = new Label();
\r
2159 embeddedCalculate = new Label();
\r
2160 flowLayout1 = new FlowLayout();
\r
2161 embeddedMenu.setBackground(Color.lightGray);
\r
2162 embeddedMenu.setLayout(flowLayout1);
\r
2163 embeddedEdit.setText("Edit");
\r
2164 embeddedEdit.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
\r
2165 embeddedSearch.setText("Search");
\r
2166 embeddedSearch.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
\r
2167 embeddedView.setText("View");
\r
2168 embeddedView.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
\r
2169 embeddedColour.setText("Colour");
\r
2170 embeddedColour.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
\r
2171 embeddedFile.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
\r
2172 embeddedFile.setText("File");
\r
2173 embeddedHelp.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
\r
2174 embeddedHelp.setText("Help");
\r
2175 embeddedCalculate.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
\r
2176 embeddedCalculate.setText("Calculate");
\r
2177 embeddedMenu.add(embeddedFile);
\r
2178 embeddedMenu.add(embeddedEdit);
\r
2179 embeddedMenu.add(embeddedSearch);
\r
2180 embeddedMenu.add(embeddedView);
\r
2181 embeddedMenu.add(embeddedColour);
\r
2182 embeddedMenu.add(embeddedCalculate);
\r
2183 embeddedMenu.add(embeddedHelp);
\r
2184 flowLayout1.setAlignment(FlowLayout.LEFT);
\r
2185 flowLayout1.setHgap(2);
\r
2186 flowLayout1.setVgap(0);
\r
2187 embeddedFile.addMouseListener(this);
\r
2188 embeddedEdit.addMouseListener(this);
\r
2189 embeddedSearch.addMouseListener(this);
\r
2190 embeddedView.addMouseListener(this);
\r
2191 embeddedColour.addMouseListener(this);
\r
2192 embeddedCalculate.addMouseListener(this);
\r
2193 embeddedHelp.addMouseListener(this);
\r
2195 // setVisible(false);
\r
2196 fileMenu.remove(closeMenuItem);
\r
2197 fileMenu.remove(3); // Seperator
\r
2199 applet.setLayout(new BorderLayout());
\r
2200 applet.add(embeddedMenu, BorderLayout.NORTH);
\r
2201 applet.add(statusBar, BorderLayout.SOUTH);
\r
2202 // applet.validate();
\r
2204 alignPanel.setSize(applet.size().width, applet.size().height
\r
2205 - embeddedMenu.HEIGHT - statusBar.HEIGHT);
\r
2207 applet.add(alignPanel, BorderLayout.CENTER);
\r
2208 applet.validate();
\r
2214 PopupMenu filePopup, editPopup, searchPopup,
\r
2215 viewPopup, colourPopup, calculatePopup, helpPopup;
\r
2216 MenuItem featureSettings = new MenuItem();
\r
2217 CheckboxMenuItem sequenceFeatures = new CheckboxMenuItem();
\r
2218 MenuItem annotationColour = new MenuItem();
\r
2220 public void mousePressed(MouseEvent evt)
\r
2222 PopupMenu popup = null;
\r
2223 Label source = (Label)evt.getSource();
\r
2224 if(source==embeddedFile)
\r
2226 popup = filePopup = genPopupMenu(filePopup, fileMenu);
\r
2228 else if(source==embeddedEdit)
\r
2230 popup = editPopup = genPopupMenu(editPopup, editMenu);
\r
2232 else if(source==embeddedSearch)
\r
2234 popup = searchPopup = genPopupMenu(searchPopup, searchMenu);
\r
2236 else if(source==embeddedView)
\r
2238 popup = viewPopup = genPopupMenu(viewPopup, viewMenu);
\r
2240 else if(source==embeddedColour)
\r
2242 popup = colourPopup = genPopupMenu(colourPopup, colourMenu);
\r
2244 else if(source==embeddedCalculate)
\r
2246 popup = calculatePopup = genPopupMenu(calculatePopup, calculateMenu);
\r
2248 else if(source==embeddedHelp)
\r
2250 popup = helpPopup = genPopupMenu(helpPopup, helpMenu);
\r
2253 embeddedMenu.add(popup);
\r
2254 popup.show(embeddedMenu,
\r
2255 source.getBounds().x,
\r
2256 source.getBounds().y + source.getBounds().getSize().height);
\r
2259 PopupMenu genPopupMenu(PopupMenu popup, Menu original)
\r
2265 popup = new PopupMenu();
\r
2266 int m, mSize = original.getItemCount();
\r
2267 for(m=0; m<mSize; m++)
\r
2269 popup.add(original.getItem(m));
\r
2276 public void mouseClicked(MouseEvent evt)
\r
2278 public void mouseReleased(MouseEvent evt)
\r
2280 public void mouseEntered(MouseEvent evt)
\r
2282 public void mouseExited(MouseEvent evt)
\r