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 = new TreePanel(viewport,
\r
1631 addTreeMenuItem(tp, title);
\r
1633 jalview.bin.JalviewLite.addFrame(tp, title, 600, 500);
\r
1636 void loadTree_actionPerformed()
\r
1638 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
\r
1639 cap.setText("Paste your Newick tree file here.");
\r
1640 cap.treeImport = true;
\r
1641 Frame frame = new Frame();
\r
1643 jalview.bin.JalviewLite.addFrame(frame, "Paste Newick file ", 400, 300);
\r
1646 public void loadTree(jalview.io.NewickFile tree, String treeFile)
\r
1648 TreePanel tp = new TreePanel(viewport,
\r
1652 jalview.bin.JalviewLite.addFrame(tp, treeFile, 600, 500);
\r
1653 addTreeMenuItem(tp, treeFile);
\r
1656 void addTreeMenuItem(final TreePanel treePanel, String title)
\r
1658 final MenuItem item = new MenuItem(title);
\r
1659 sortByTreeMenu.add(item);
\r
1660 item.addActionListener(new java.awt.event.ActionListener()
\r
1662 public void actionPerformed(ActionEvent evt)
\r
1664 addHistoryItem(new HistoryItem("Sort", viewport.alignment,
\r
1665 HistoryItem.SORT));
\r
1666 AlignmentSorter.sortByTree(viewport.getAlignment(), treePanel.getTree());
\r
1667 alignPanel.repaint();
\r
1671 treePanel.addWindowListener(new WindowAdapter()
\r
1673 public void windowClosing(WindowEvent e)
\r
1675 sortByTreeMenu.remove(item);
\r
1680 protected void documentation_actionPerformed()
\r
1682 showURL("http://www.jalview.org/help.html", "HELP");
\r
1685 protected void about_actionPerformed()
\r
1688 class AboutPanel extends Canvas
\r
1691 public AboutPanel(String version)
\r
1692 { this.version = version; }
\r
1694 public void paint(Graphics g)
\r
1696 g.setColor(Color.white);
\r
1697 g.fillRect(0, 0, getSize().width, getSize().height);
\r
1698 g.setFont(new Font("Helvetica", Font.PLAIN, 12));
\r
1699 FontMetrics fm = g.getFontMetrics();
\r
1700 int fh = fm.getHeight();
\r
1702 g.setColor(Color.black);
\r
1703 g.setFont(new Font("Helvetica", Font.BOLD, 14));
\r
1704 g.drawString("Jalview - Release "+version, 200, y += fh);
\r
1705 g.setFont(new Font("Helvetica", Font.PLAIN, 12));
\r
1706 g.drawString("Authors: Michele Clamp, James Cuff, Steve Searle, Andrew Waterhouse, Jim Procter & Geoff Barton.",
\r
1708 g.drawString("Current development managed by Andrew Waterhouse; Barton Group, University of Dundee.",
\r
1711 "For any issues relating to Jalview, email help@jalview.org", x,
\r
1713 g.drawString("If you use JalView, please cite:", x, y += fh + 8);
\r
1714 g.drawString("\"Clamp, M., Cuff, J., Searle, S. M. and Barton, G. J. (2004), The Jalview Java Alignment Editor\"",
\r
1716 g.drawString("Bioinformatics, 2004 20;426-7.", x, y += fh);
\r
1720 String version = "test";
\r
1721 java.net.URL url = getClass().getResource("/.build_properties");
\r
1726 BufferedReader reader = new BufferedReader(new InputStreamReader(
\r
1727 url.openStream()));
\r
1729 while ( (line = reader.readLine()) != null)
\r
1731 if (line.indexOf("VERSION") > -1)
\r
1733 version = line.substring(line.indexOf("=") + 1);
\r
1737 catch (Exception ex)
\r
1739 ex.printStackTrace();
\r
1744 Frame frame = new Frame();
\r
1745 frame.add(new AboutPanel(version));
\r
1746 jalview.bin.JalviewLite.addFrame(frame, "Jalview", 580, 200);
\r
1750 public void showURL(String url, String target)
\r
1752 if (applet == null)
\r
1754 System.out.println("Not running as applet - no browser available.");
\r
1760 System.out.println("Show url: "+url);
\r
1761 applet.getAppletContext().showDocument(new java.net.URL(url),
\r
1764 catch (Exception ex)
\r
1766 ex.printStackTrace();
\r
1772 //////////////////////////////////////////////////////////////////////////////////
\r
1773 //JBuilder Graphics here
\r
1775 protected MenuBar alignFrameMenuBar = new MenuBar();
\r
1776 protected Menu fileMenu = new Menu("File");
\r
1777 protected MenuItem loadApplication = new MenuItem("View in Full Application");
\r
1778 protected MenuItem loadTree = new MenuItem("Load Associated Tree");
\r
1779 protected MenuItem closeMenuItem = new MenuItem("Close");
\r
1780 protected Menu editMenu = new Menu("Edit");
\r
1781 protected Menu viewMenu = new Menu("View");
\r
1782 protected Menu colourMenu = new Menu("Colour");
\r
1783 protected Menu calculateMenu = new Menu("Calculate");
\r
1784 protected MenuItem selectAllSequenceMenuItem = new MenuItem("Select all");
\r
1785 protected MenuItem deselectAllSequenceMenuItem = new MenuItem("Deselect All");
\r
1786 protected MenuItem invertSequenceMenuItem = new MenuItem("Invert Selection");
\r
1787 protected MenuItem remove2LeftMenuItem = new MenuItem();
\r
1788 protected MenuItem remove2RightMenuItem = new MenuItem();
\r
1789 protected MenuItem removeGappedColumnMenuItem = new MenuItem();
\r
1790 protected MenuItem removeAllGapsMenuItem = new MenuItem();
\r
1791 protected CheckboxMenuItem viewBoxesMenuItem = new CheckboxMenuItem();
\r
1792 protected CheckboxMenuItem viewTextMenuItem = new CheckboxMenuItem();
\r
1793 protected MenuItem sortPairwiseMenuItem = new MenuItem();
\r
1794 protected MenuItem sortIDMenuItem = new MenuItem();
\r
1795 protected MenuItem sortGroupMenuItem = new MenuItem();
\r
1796 protected MenuItem removeRedundancyMenuItem = new MenuItem();
\r
1797 protected MenuItem pairwiseAlignmentMenuItem = new MenuItem();
\r
1798 protected MenuItem PCAMenuItem = new MenuItem();
\r
1799 protected MenuItem averageDistanceTreeMenuItem = new MenuItem();
\r
1800 protected MenuItem neighbourTreeMenuItem = new MenuItem();
\r
1801 BorderLayout borderLayout1 = new BorderLayout();
\r
1802 public Label statusBar = new Label();
\r
1803 protected Menu outputTextboxMenu = new Menu();
\r
1804 protected MenuItem clustalColour = new MenuItem();
\r
1805 protected MenuItem zappoColour = new MenuItem();
\r
1806 protected MenuItem taylorColour = new MenuItem();
\r
1807 protected MenuItem hydrophobicityColour = new MenuItem();
\r
1808 protected MenuItem helixColour = new MenuItem();
\r
1809 protected MenuItem strandColour = new MenuItem();
\r
1810 protected MenuItem turnColour = new MenuItem();
\r
1811 protected MenuItem buriedColour = new MenuItem();
\r
1812 protected MenuItem userDefinedColour = new MenuItem();
\r
1813 protected MenuItem PIDColour = new MenuItem();
\r
1814 protected MenuItem BLOSUM62Colour = new MenuItem();
\r
1815 MenuItem njTreeBlosumMenuItem = new MenuItem();
\r
1816 MenuItem avDistanceTreeBlosumMenuItem = new MenuItem();
\r
1817 protected CheckboxMenuItem annotationPanelMenuItem = new CheckboxMenuItem();
\r
1818 protected CheckboxMenuItem colourTextMenuItem = new CheckboxMenuItem();
\r
1819 MenuItem overviewMenuItem = new MenuItem();
\r
1820 protected MenuItem undoMenuItem = new MenuItem();
\r
1821 protected MenuItem redoMenuItem = new MenuItem();
\r
1822 protected CheckboxMenuItem conservationMenuItem = new CheckboxMenuItem();
\r
1823 MenuItem noColourmenuItem = new MenuItem();
\r
1824 protected CheckboxMenuItem wrapMenuItem = new CheckboxMenuItem();
\r
1825 protected CheckboxMenuItem renderGapsMenuItem = new CheckboxMenuItem();
\r
1826 MenuItem findMenuItem = new MenuItem();
\r
1827 Menu searchMenu = new Menu();
\r
1828 protected CheckboxMenuItem abovePIDThreshold = new CheckboxMenuItem();
\r
1829 protected MenuItem nucleotideColour = new MenuItem();
\r
1830 MenuItem deleteGroups = new MenuItem();
\r
1831 MenuItem delete = new MenuItem();
\r
1832 MenuItem copy = new MenuItem();
\r
1833 MenuItem cut = new MenuItem();
\r
1834 Menu pasteMenu = new Menu();
\r
1835 MenuItem pasteNew = new MenuItem();
\r
1836 MenuItem pasteThis = new MenuItem();
\r
1837 protected CheckboxMenuItem applyToAllGroups = new CheckboxMenuItem();
\r
1838 protected MenuItem font = new MenuItem();
\r
1839 protected CheckboxMenuItem scaleAbove = new CheckboxMenuItem();
\r
1840 protected CheckboxMenuItem scaleLeft = new CheckboxMenuItem();
\r
1841 protected CheckboxMenuItem scaleRight = new CheckboxMenuItem();
\r
1842 MenuItem modifyPID = new MenuItem();
\r
1843 MenuItem modifyConservation = new MenuItem();
\r
1844 protected CheckboxMenuItem autoCalculate
\r
1845 = new CheckboxMenuItem("Autocalculate Consensus", true);
\r
1846 protected Menu sortByTreeMenu = new Menu();
\r
1847 Menu sort = new Menu();
\r
1848 Menu calculate = new Menu();
\r
1849 MenuItem inputText = new MenuItem();
\r
1850 Menu helpMenu = new Menu();
\r
1851 MenuItem documentation = new MenuItem();
\r
1852 MenuItem about = new MenuItem();
\r
1853 protected CheckboxMenuItem seqLimits = new CheckboxMenuItem();
\r
1854 Panel embeddedMenu;
\r
1855 Label embeddedEdit;
\r
1856 Label embeddedSearch;
\r
1857 Label embeddedView;
\r
1858 Label embeddedColour;
\r
1859 Label embeddedFile;
\r
1860 Label embeddedHelp;
\r
1861 Label embeddedCalculate;
\r
1862 FlowLayout flowLayout1;
\r
1864 private void jbInit() throws Exception {
\r
1866 setMenuBar(alignFrameMenuBar);
\r
1870 // dynamically fill save as menu with available formats
\r
1871 for (int i = 0; i < jalview.io.AppletFormatAdapter.formats.size(); i++)
\r
1874 item = new MenuItem( (String) jalview.io.AppletFormatAdapter.formats.
\r
1877 item.addActionListener(new java.awt.event.ActionListener()
\r
1879 public void actionPerformed(ActionEvent e)
\r
1881 outputText_actionPerformed(e);
\r
1885 outputTextboxMenu.add(item);
\r
1887 closeMenuItem.addActionListener(this);
\r
1888 loadApplication.addActionListener(this);
\r
1890 loadTree.addActionListener(this);
\r
1891 selectAllSequenceMenuItem.addActionListener(this);
\r
1892 deselectAllSequenceMenuItem.addActionListener(this);
\r
1893 invertSequenceMenuItem.addActionListener(this);
\r
1894 remove2LeftMenuItem.setLabel("Remove Left");
\r
1895 remove2LeftMenuItem.addActionListener(this);
\r
1896 remove2RightMenuItem.setLabel("Remove Right");
\r
1897 remove2RightMenuItem.addActionListener(this);
\r
1898 removeGappedColumnMenuItem.setLabel("Remove Empty Columns");
\r
1899 removeGappedColumnMenuItem.addActionListener(this);
\r
1900 removeAllGapsMenuItem.setLabel("Remove All Gaps");
\r
1901 removeAllGapsMenuItem.addActionListener(this);
\r
1902 viewBoxesMenuItem.setLabel("Boxes");
\r
1903 viewBoxesMenuItem.setState(true);
\r
1904 viewBoxesMenuItem.addItemListener(this);
\r
1905 viewTextMenuItem.setLabel("Text");
\r
1906 viewTextMenuItem.setState(true);
\r
1907 viewTextMenuItem.addItemListener(this);
\r
1908 sortPairwiseMenuItem.setLabel("by Pairwise Identity");
\r
1909 sortPairwiseMenuItem.addActionListener(this);
\r
1910 sortIDMenuItem.setLabel("by ID");
\r
1911 sortIDMenuItem.addActionListener(this);
\r
1912 sortGroupMenuItem.setLabel("by Group");
\r
1913 sortGroupMenuItem.addActionListener(this);
\r
1914 removeRedundancyMenuItem.setLabel("Remove Redundancy...");
\r
1915 removeRedundancyMenuItem.addActionListener(this);
\r
1916 pairwiseAlignmentMenuItem.setLabel("Pairwise Alignments...");
\r
1917 pairwiseAlignmentMenuItem.addActionListener(this);
\r
1918 PCAMenuItem.setLabel("Principal Component Analysis");
\r
1919 PCAMenuItem.addActionListener(this);
\r
1920 averageDistanceTreeMenuItem.setLabel(
\r
1921 "Average Distance Using % Identity");
\r
1922 averageDistanceTreeMenuItem.addActionListener(this);
\r
1923 neighbourTreeMenuItem.setLabel("Neighbour Joining Using % Identity");
\r
1924 neighbourTreeMenuItem.addActionListener(this);
\r
1925 alignFrameMenuBar.setFont(new java.awt.Font("Verdana", 0, 11));
\r
1926 statusBar.setBackground(Color.white);
\r
1927 statusBar.setFont(new java.awt.Font("Verdana", 0, 11));
\r
1928 statusBar.setText("Status bar");
\r
1929 outputTextboxMenu.setLabel("Output to Textbox");
\r
1930 clustalColour.setLabel("Clustalx");
\r
1932 clustalColour.addActionListener(this);
\r
1933 zappoColour.setLabel("Zappo");
\r
1934 zappoColour.addActionListener(this);
\r
1935 taylorColour.setLabel("Taylor");
\r
1936 taylorColour.addActionListener(this);
\r
1937 hydrophobicityColour.setLabel("Hydrophobicity");
\r
1938 hydrophobicityColour.addActionListener(this);
\r
1939 helixColour.setLabel("Helix Propensity");
\r
1940 helixColour.addActionListener(this);
\r
1941 strandColour.setLabel("Strand Propensity");
\r
1942 strandColour.addActionListener(this);
\r
1943 turnColour.setLabel("Turn Propensity");
\r
1944 turnColour.addActionListener(this);
\r
1945 buriedColour.setLabel("Buried Index");
\r
1946 buriedColour.addActionListener(this);
\r
1947 userDefinedColour.setLabel("User Defined...");
\r
1948 userDefinedColour.addActionListener(this);
\r
1949 PIDColour.setLabel("Percentage Identity");
\r
1950 PIDColour.addActionListener(this);
\r
1951 BLOSUM62Colour.setLabel("BLOSUM62 Score");
\r
1952 BLOSUM62Colour.addActionListener(this);
\r
1953 avDistanceTreeBlosumMenuItem.setLabel(
\r
1954 "Average Distance Using BLOSUM62");
\r
1955 avDistanceTreeBlosumMenuItem.addActionListener(this);
\r
1956 njTreeBlosumMenuItem.setLabel("Neighbour Joining Using BLOSUM62");
\r
1957 njTreeBlosumMenuItem.addActionListener(this);
\r
1958 annotationPanelMenuItem.setLabel("Show Annotations");
\r
1959 annotationPanelMenuItem.addItemListener(this);
\r
1960 colourTextMenuItem.setLabel("Colour Text");
\r
1961 colourTextMenuItem.addItemListener(this);
\r
1962 overviewMenuItem.setLabel("Overview Window");
\r
1963 overviewMenuItem.addActionListener(this);
\r
1964 undoMenuItem.setEnabled(false);
\r
1965 undoMenuItem.setLabel("Undo");
\r
1966 undoMenuItem.addActionListener(this);
\r
1967 redoMenuItem.setEnabled(false);
\r
1968 redoMenuItem.setLabel("Redo");
\r
1969 redoMenuItem.addActionListener(this);
\r
1970 conservationMenuItem.setLabel("by Conservation");
\r
1971 conservationMenuItem.addItemListener(this);
\r
1972 noColourmenuItem.setLabel("None");
\r
1973 noColourmenuItem.addActionListener(this);
\r
1974 wrapMenuItem.setLabel("Wrap");
\r
1975 wrapMenuItem.addItemListener(this);
\r
1976 renderGapsMenuItem.setLabel("Show Gaps");
\r
1977 renderGapsMenuItem.setState(true);
\r
1978 renderGapsMenuItem.addItemListener(this);
\r
1979 findMenuItem.setLabel("Find...");
\r
1980 findMenuItem.addActionListener(this);
\r
1981 searchMenu.setLabel("Search");
\r
1983 abovePIDThreshold.setLabel("Above Identity Threshold");
\r
1984 abovePIDThreshold.addItemListener(this);
\r
1985 nucleotideColour.setLabel("Nucleotide");
\r
1986 nucleotideColour.addActionListener(this);
\r
1987 deleteGroups.setLabel("Undefine Groups");
\r
1988 deleteGroups.addActionListener(this);
\r
1989 copy.setLabel("Copy");
\r
1990 copy.addActionListener(this);
\r
1991 cut.setLabel("Cut");
\r
1992 cut.addActionListener(this);
\r
1993 delete.setLabel("Delete");
\r
1994 delete.addActionListener(this);
\r
1995 pasteMenu.setLabel("Paste");
\r
1996 pasteNew.setLabel("To New Alignment");
\r
1997 pasteNew.addActionListener(this);
\r
1998 pasteThis.setLabel("Add To This Alignment");
\r
1999 pasteThis.addActionListener(this);
\r
2000 applyToAllGroups.setLabel("Apply Colour To All Groups");
\r
2001 applyToAllGroups.setState(true);
\r
2002 applyToAllGroups.addItemListener(this);
\r
2003 font.setLabel("Font...");
\r
2004 font.addActionListener(this);
\r
2005 scaleAbove.setLabel("Scale Above");
\r
2006 scaleAbove.setState(true);
\r
2007 scaleAbove.setEnabled(false);
\r
2008 scaleAbove.addItemListener(this);
\r
2009 scaleLeft.setEnabled(false);
\r
2010 scaleLeft.setState(true);
\r
2011 scaleLeft.setLabel("Scale Left");
\r
2012 scaleLeft.addItemListener(this);
\r
2013 scaleRight.setEnabled(false);
\r
2014 scaleRight.setState(true);
\r
2015 scaleRight.setLabel("Scale Right");
\r
2016 scaleRight.addItemListener(this);
\r
2017 modifyPID.setLabel("Modify Identity Threshold...");
\r
2018 modifyPID.addActionListener(this);
\r
2019 modifyConservation.setLabel("Modify Conservation Threshold...");
\r
2020 modifyConservation.addActionListener(this);
\r
2021 sortByTreeMenu.setLabel("By Tree Order");
\r
2022 sort.setLabel("Sort");
\r
2023 calculate.setLabel("Calculate Tree");
\r
2024 autoCalculate.addItemListener(this);
\r
2025 inputText.setLabel("Input from textbox");
\r
2026 inputText.addActionListener(this);
\r
2028 helpMenu.setLabel("Help");
\r
2029 documentation.setLabel("Documentation");
\r
2030 documentation.addActionListener(this);
\r
2032 about.setLabel("About...");
\r
2033 about.addActionListener(this);
\r
2034 seqLimits.setState(true);
\r
2035 seqLimits.setLabel("Show Sequence Limits");
\r
2036 seqLimits.addItemListener(this);
\r
2037 featureSettings.setLabel("Feature Settings...");
\r
2038 featureSettings.addActionListener(this);
\r
2039 sequenceFeatures.setLabel("Sequence Features");
\r
2040 sequenceFeatures.addItemListener(this);
\r
2041 sequenceFeatures.setState(false);
\r
2042 annotationColour.setLabel("by Annotation...");
\r
2043 annotationColour.addActionListener(this);
\r
2045 alignFrameMenuBar.add(fileMenu);
\r
2046 alignFrameMenuBar.add(editMenu);
\r
2047 alignFrameMenuBar.add(searchMenu);
\r
2048 alignFrameMenuBar.add(viewMenu);
\r
2049 alignFrameMenuBar.add(colourMenu);
\r
2050 alignFrameMenuBar.add(calculateMenu);
\r
2051 alignFrameMenuBar.add(helpMenu);
\r
2052 fileMenu.add(inputText);
\r
2053 fileMenu.add(outputTextboxMenu);
\r
2054 if(jalviewServletURL!=null)
\r
2055 fileMenu.add(loadApplication);
\r
2056 fileMenu.addSeparator();
\r
2057 fileMenu.add(loadTree);
\r
2058 fileMenu.add(closeMenuItem);
\r
2059 editMenu.add(undoMenuItem);
\r
2060 editMenu.add(redoMenuItem);
\r
2061 editMenu.add(cut);
\r
2062 editMenu.add(copy);
\r
2063 editMenu.add(pasteMenu);
\r
2064 editMenu.add(delete);
\r
2065 editMenu.addSeparator();
\r
2066 editMenu.add(selectAllSequenceMenuItem);
\r
2067 editMenu.add(deselectAllSequenceMenuItem);
\r
2068 editMenu.add(invertSequenceMenuItem);
\r
2069 editMenu.add(deleteGroups);
\r
2070 editMenu.addSeparator();
\r
2071 editMenu.add(remove2LeftMenuItem);
\r
2072 editMenu.add(remove2RightMenuItem);
\r
2073 editMenu.add(removeGappedColumnMenuItem);
\r
2074 editMenu.add(removeAllGapsMenuItem);
\r
2075 editMenu.add(removeRedundancyMenuItem);
\r
2076 searchMenu.add(findMenuItem);
\r
2077 viewMenu.add(font);
\r
2078 viewMenu.addSeparator();
\r
2079 viewMenu.add(seqLimits);
\r
2080 viewMenu.addSeparator();
\r
2081 viewMenu.add(wrapMenuItem);
\r
2082 viewMenu.add(scaleAbove);
\r
2083 viewMenu.add(scaleLeft);
\r
2084 viewMenu.add(scaleRight);
\r
2085 viewMenu.addSeparator();
\r
2086 viewMenu.add(viewBoxesMenuItem);
\r
2087 viewMenu.add(viewTextMenuItem);
\r
2088 viewMenu.add(colourTextMenuItem);
\r
2089 viewMenu.add(renderGapsMenuItem);
\r
2090 viewMenu.add(annotationPanelMenuItem);
\r
2091 viewMenu.addSeparator();
\r
2092 viewMenu.add(sequenceFeatures);
\r
2093 viewMenu.add(featureSettings);
\r
2094 viewMenu.addSeparator();
\r
2095 viewMenu.add(overviewMenuItem);
\r
2096 colourMenu.add(applyToAllGroups);
\r
2097 colourMenu.addSeparator();
\r
2098 colourMenu.add(noColourmenuItem);
\r
2099 colourMenu.add(clustalColour);
\r
2100 colourMenu.add(BLOSUM62Colour);
\r
2101 colourMenu.add(PIDColour);
\r
2102 colourMenu.add(zappoColour);
\r
2103 colourMenu.add(taylorColour);
\r
2104 colourMenu.add(hydrophobicityColour);
\r
2105 colourMenu.add(helixColour);
\r
2106 colourMenu.add(strandColour);
\r
2107 colourMenu.add(turnColour);
\r
2108 colourMenu.add(buriedColour);
\r
2109 colourMenu.add(nucleotideColour);
\r
2110 colourMenu.add(userDefinedColour);
\r
2111 colourMenu.addSeparator();
\r
2112 colourMenu.add(conservationMenuItem);
\r
2113 colourMenu.add(modifyConservation);
\r
2114 colourMenu.add(abovePIDThreshold);
\r
2115 colourMenu.add(modifyPID);
\r
2116 colourMenu.add(annotationColour);
\r
2117 calculateMenu.add(sort);
\r
2118 calculateMenu.add(calculate);
\r
2119 calculateMenu.addSeparator();
\r
2120 calculateMenu.add(pairwiseAlignmentMenuItem);
\r
2121 calculateMenu.add(PCAMenuItem);
\r
2122 calculateMenu.add(autoCalculate);
\r
2123 this.add(statusBar, BorderLayout.SOUTH);
\r
2124 pasteMenu.add(pasteNew);
\r
2125 pasteMenu.add(pasteThis);
\r
2126 sort.add(sortIDMenuItem);
\r
2127 sort.add(sortByTreeMenu);
\r
2128 sort.add(sortGroupMenuItem);
\r
2129 sort.add(sortPairwiseMenuItem);
\r
2130 calculate.add(averageDistanceTreeMenuItem);
\r
2131 calculate.add(neighbourTreeMenuItem);
\r
2132 calculate.add(avDistanceTreeBlosumMenuItem);
\r
2133 calculate.add(njTreeBlosumMenuItem);
\r
2134 helpMenu.add(documentation);
\r
2135 helpMenu.add(about);
\r
2138 public void setEmbedded()
\r
2141 embeddedMenu = new Panel();
\r
2142 embeddedEdit = new Label();
\r
2143 embeddedSearch = new Label();
\r
2144 embeddedView = new Label();
\r
2145 embeddedColour = new Label();
\r
2146 embeddedFile = new Label();
\r
2147 embeddedHelp = new Label();
\r
2148 embeddedCalculate = new Label();
\r
2149 flowLayout1 = new FlowLayout();
\r
2150 embeddedMenu.setBackground(Color.lightGray);
\r
2151 embeddedMenu.setLayout(flowLayout1);
\r
2152 embeddedEdit.setText("Edit");
\r
2153 embeddedEdit.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
\r
2154 embeddedSearch.setText("Search");
\r
2155 embeddedSearch.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
\r
2156 embeddedView.setText("View");
\r
2157 embeddedView.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
\r
2158 embeddedColour.setText("Colour");
\r
2159 embeddedColour.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
\r
2160 embeddedFile.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
\r
2161 embeddedFile.setText("File");
\r
2162 embeddedHelp.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
\r
2163 embeddedHelp.setText("Help");
\r
2164 embeddedCalculate.setFont(new java.awt.Font("Arial", Font.PLAIN, 10));
\r
2165 embeddedCalculate.setText("Calculate");
\r
2166 embeddedMenu.add(embeddedFile);
\r
2167 embeddedMenu.add(embeddedEdit);
\r
2168 embeddedMenu.add(embeddedSearch);
\r
2169 embeddedMenu.add(embeddedView);
\r
2170 embeddedMenu.add(embeddedColour);
\r
2171 embeddedMenu.add(embeddedCalculate);
\r
2172 embeddedMenu.add(embeddedHelp);
\r
2173 flowLayout1.setAlignment(FlowLayout.LEFT);
\r
2174 flowLayout1.setHgap(2);
\r
2175 flowLayout1.setVgap(0);
\r
2176 embeddedFile.addMouseListener(this);
\r
2177 embeddedEdit.addMouseListener(this);
\r
2178 embeddedSearch.addMouseListener(this);
\r
2179 embeddedView.addMouseListener(this);
\r
2180 embeddedColour.addMouseListener(this);
\r
2181 embeddedCalculate.addMouseListener(this);
\r
2182 embeddedHelp.addMouseListener(this);
\r
2184 // setVisible(false);
\r
2185 fileMenu.remove(closeMenuItem);
\r
2186 fileMenu.remove(3); // Seperator
\r
2188 applet.setLayout(new BorderLayout());
\r
2189 applet.add(embeddedMenu, BorderLayout.NORTH);
\r
2190 applet.add(statusBar, BorderLayout.SOUTH);
\r
2191 // applet.validate();
\r
2193 alignPanel.setSize(applet.size().width, applet.size().height
\r
2194 - embeddedMenu.HEIGHT - statusBar.HEIGHT);
\r
2196 applet.add(alignPanel, BorderLayout.CENTER);
\r
2197 applet.validate();
\r
2203 PopupMenu filePopup, editPopup, searchPopup,
\r
2204 viewPopup, colourPopup, calculatePopup, helpPopup;
\r
2205 MenuItem featureSettings = new MenuItem();
\r
2206 CheckboxMenuItem sequenceFeatures = new CheckboxMenuItem();
\r
2207 MenuItem annotationColour = new MenuItem();
\r
2209 public void mousePressed(MouseEvent evt)
\r
2211 PopupMenu popup = null;
\r
2212 Label source = (Label)evt.getSource();
\r
2213 if(source==embeddedFile)
\r
2215 popup = filePopup = genPopupMenu(filePopup, fileMenu);
\r
2217 else if(source==embeddedEdit)
\r
2219 popup = editPopup = genPopupMenu(editPopup, editMenu);
\r
2221 else if(source==embeddedSearch)
\r
2223 popup = searchPopup = genPopupMenu(searchPopup, searchMenu);
\r
2225 else if(source==embeddedView)
\r
2227 popup = viewPopup = genPopupMenu(viewPopup, viewMenu);
\r
2229 else if(source==embeddedColour)
\r
2231 popup = colourPopup = genPopupMenu(colourPopup, colourMenu);
\r
2233 else if(source==embeddedCalculate)
\r
2235 popup = calculatePopup = genPopupMenu(calculatePopup, calculateMenu);
\r
2237 else if(source==embeddedHelp)
\r
2239 popup = helpPopup = genPopupMenu(helpPopup, helpMenu);
\r
2242 embeddedMenu.add(popup);
\r
2243 popup.show(embeddedMenu,
\r
2244 source.getBounds().x,
\r
2245 source.getBounds().y + source.getBounds().getSize().height);
\r
2248 PopupMenu genPopupMenu(PopupMenu popup, Menu original)
\r
2254 popup = new PopupMenu();
\r
2255 int m, mSize = original.getItemCount();
\r
2256 for(m=0; m<mSize; m++)
\r
2258 popup.add(original.getItem(m));
\r
2265 public void mouseClicked(MouseEvent evt)
\r
2267 public void mouseReleased(MouseEvent evt)
\r
2269 public void mouseEntered(MouseEvent evt)
\r
2271 public void mouseExited(MouseEvent evt)
\r