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.jbappletgui.GAlignFrame;
\r
23 import jalview.schemes.*;
\r
24 import jalview.datamodel.*;
\r
25 import jalview.analysis.*;
\r
26 import jalview.io.*;
\r
28 import java.awt.event.*;
\r
31 public class AlignFrame
\r
34 final AlignmentPanel alignPanel;
\r
35 final AlignViewport viewport;
\r
36 public static final int NEW_WINDOW_WIDTH = 700;
\r
37 public static final int NEW_WINDOW_HEIGHT = 500;
\r
38 jalview.bin.JalviewLite applet;
\r
40 public AlignFrame(AlignmentI al)
\r
43 viewport = new AlignViewport(al, null);
\r
44 alignPanel = new AlignmentPanel(this, viewport);
\r
46 alignPanel.validate();
\r
49 public AlignFrame(AlignmentI al, jalview.bin.JalviewLite applet)
\r
51 this.applet = applet;
\r
52 viewport = new AlignViewport(al, applet);
\r
53 alignPanel = new AlignmentPanel(this, viewport);
\r
55 alignPanel.validate();
\r
57 String treeFile = applet.getParameter("treeFile");
\r
58 TreePanel treepanel = null;
\r
59 if (treeFile != null)
\r
63 treeFile = treeFile;
\r
64 jalview.io.NewickFile fin = new jalview.io.NewickFile(applet.
\r
65 getCodeBase() + treeFile, "URL");
\r
68 if (fin.getTree() != null)
\r
70 TreePanel tp = null;
\r
71 tp = new TreePanel(viewport, viewport.getAlignment().getSequences(),
\r
72 fin, "FromFile", applet.getCodeBase() + treeFile);
\r
73 jalview.bin.JalviewLite.addFrame(tp, treeFile, 600, 500);
\r
74 addTreeMenuItem(tp, treeFile);
\r
77 catch (Exception ex)
\r
79 ex.printStackTrace();
\r
86 public void inputText_actionPerformed(ActionEvent e)
\r
88 CutAndPasteTransfer cap = new CutAndPasteTransfer(true);
\r
89 Frame frame = new Frame();
\r
91 jalview.bin.JalviewLite.addFrame(frame, "Cut & Paste Input", 500, 500);
\r
94 protected void outputText_actionPerformed(ActionEvent e)
\r
96 CutAndPasteTransfer cap = new CutAndPasteTransfer(false);
\r
97 Frame frame = new Frame();
\r
99 jalview.bin.JalviewLite.addFrame(frame,
\r
100 "Alignment output - " + e.getActionCommand(),
\r
102 cap.setText(FormatAdapter.formatSequences(e.getActionCommand(),
\r
103 viewport.getAlignment().
\r
107 public void closeMenuItem_actionPerformed(ActionEvent e)
\r
112 Stack historyList = new Stack();
\r
113 Stack redoList = new Stack();
\r
115 void updateEditMenuBar()
\r
117 if (historyList.size() > 0)
\r
119 undoMenuItem.setEnabled(true);
\r
120 HistoryItem hi = (HistoryItem) historyList.peek();
\r
121 undoMenuItem.setLabel("Undo " + hi.getDescription());
\r
125 undoMenuItem.setEnabled(false);
\r
126 undoMenuItem.setLabel("Undo");
\r
129 if (redoList.size() > 0)
\r
131 redoMenuItem.setEnabled(true);
\r
132 HistoryItem hi = (HistoryItem) redoList.peek();
\r
133 redoMenuItem.setLabel("Redo " + hi.getDescription());
\r
137 redoMenuItem.setEnabled(false);
\r
138 redoMenuItem.setLabel("Redo");
\r
142 public void addHistoryItem(HistoryItem hi)
\r
144 historyList.push(hi);
\r
145 updateEditMenuBar();
\r
148 protected void undoMenuItem_actionPerformed(ActionEvent e)
\r
150 HistoryItem hi = (HistoryItem) historyList.pop();
\r
151 redoList.push(new HistoryItem(hi.getDescription(), viewport.alignment,
\r
152 HistoryItem.HIDE));
\r
153 restoreHistoryItem(hi);
\r
156 protected void redoMenuItem_actionPerformed(ActionEvent e)
\r
158 HistoryItem hi = (HistoryItem) redoList.pop();
\r
159 restoreHistoryItem(hi);
\r
160 updateEditMenuBar();
\r
161 viewport.updateConsensus();
\r
162 alignPanel.repaint();
\r
163 alignPanel.repaint();
\r
166 // used by undo and redo
\r
167 void restoreHistoryItem(HistoryItem hi)
\r
169 if (hi.getType() == HistoryItem.SORT)
\r
171 for (int i = 0; i < hi.getSequences().size(); i++)
\r
173 viewport.alignment.getSequences().setElementAt(hi.getSequences().
\r
179 for (int i = 0; i < hi.getSequences().size(); i++)
\r
181 SequenceI restore = (SequenceI) hi.getSequences().elementAt(i);
\r
182 if (restore.getLength() == 0)
\r
184 // log.System.out.println(hi.getHidden().elementAt(i));
\r
185 restore.setSequence(hi.getHidden().elementAt(i).toString());
\r
186 viewport.alignment.getSequences().insertElementAt(
\r
188 hi.getAlignIndex(i));
\r
192 restore.setSequence(hi.getHidden().elementAt(i).toString());
\r
195 if (hi.getType() == HistoryItem.PASTE)
\r
197 for (int i = viewport.alignment.getHeight() - 1;
\r
198 i > hi.getSequences().size() - 1; i--)
\r
200 viewport.alignment.deleteSequence(i);
\r
205 updateEditMenuBar();
\r
207 viewport.updateConsensus();
\r
208 viewport.updateConservation();
\r
209 alignPanel.repaint();
\r
212 public void moveSelectedSequences(boolean up)
\r
214 SequenceGroup sg = viewport.getSelectionGroup();
\r
222 for (int i = 1; i < viewport.alignment.getHeight(); i++)
\r
224 SequenceI seq = viewport.alignment.getSequenceAt(i);
\r
225 if (!sg.sequences.contains(seq))
\r
230 SequenceI temp = viewport.alignment.getSequenceAt(i - 1);
\r
231 if (sg.sequences.contains(temp))
\r
236 viewport.alignment.getSequences().setElementAt(temp, i);
\r
237 viewport.alignment.getSequences().setElementAt(seq, i - 1);
\r
242 for (int i = viewport.alignment.getHeight() - 2; i > -1; i--)
\r
244 SequenceI seq = viewport.alignment.getSequenceAt(i);
\r
245 if (!sg.sequences.contains(seq))
\r
250 SequenceI temp = viewport.alignment.getSequenceAt(i + 1);
\r
251 if (sg.sequences.contains(temp))
\r
256 viewport.alignment.getSequences().setElementAt(temp, i);
\r
257 viewport.alignment.getSequences().setElementAt(seq, i + 1);
\r
261 alignPanel.repaint();
\r
264 StringBuffer copiedSequences;
\r
265 protected void copy_actionPerformed(ActionEvent e)
\r
267 if (viewport.getSelectionGroup() == null)
\r
272 SequenceGroup sg = viewport.getSelectionGroup();
\r
273 copiedSequences = new StringBuffer();
\r
274 Hashtable orderedSeqs = new Hashtable();
\r
275 for (int i = 0; i < sg.getSize(); i++)
\r
277 SequenceI seq = sg.getSequenceAt(i);
\r
278 int index = viewport.alignment.findIndex(seq);
\r
279 orderedSeqs.put(index + "", seq);
\r
282 int index = 0, startRes, endRes;
\r
285 for (int i = 0; i < sg.getSize(); i++)
\r
287 SequenceI seq = null;
\r
289 while (seq == null)
\r
291 if (orderedSeqs.containsKey(index + ""))
\r
293 seq = (SequenceI) orderedSeqs.get(index + "");
\r
305 //Returns residue following index if gap
\r
306 startRes = seq.findPosition(sg.getStartRes());
\r
309 //Need to find the residue preceeding index if gap
\r
312 for (int j = 0; j < sg.getEndRes()+1 && j < seq.getLength(); j++)
\r
314 ch = seq.getCharAt(j);
\r
315 if (!jalview.util.Comparison.isGap( (ch)))
\r
323 endRes += seq.getStart() -1;
\r
326 copiedSequences.append(seq.getName() + "\t" +
\r
329 seq.getSequence(sg.getStartRes(),
\r
330 sg.getEndRes() + 1) + "\n");
\r
335 protected void pasteNew_actionPerformed(ActionEvent e)
\r
340 protected void pasteThis_actionPerformed(ActionEvent e)
\r
342 addHistoryItem(new HistoryItem("Paste Sequences", viewport.alignment,
\r
343 HistoryItem.PASTE));
\r
347 void paste(boolean newAlignment)
\r
351 if (copiedSequences == null)
\r
356 StringTokenizer st = new StringTokenizer(copiedSequences.toString());
\r
357 Vector seqs = new Vector();
\r
358 while (st.hasMoreElements())
\r
360 String name = st.nextToken();
\r
361 int start = Integer.parseInt(st.nextToken());
\r
362 int end = Integer.parseInt(st.nextToken());
\r
363 Sequence sequence = new Sequence(name, st.nextToken(), start, end);
\r
367 viewport.alignment.addSequence(sequence);
\r
371 seqs.addElement(sequence);
\r
377 SequenceI[] newSeqs = new SequenceI[seqs.size()];
\r
378 for (int i = 0; i < seqs.size(); i++)
\r
380 newSeqs[i] = (SequenceI) seqs.elementAt(i);
\r
383 AlignFrame af = new AlignFrame(new Alignment(newSeqs), applet);
\r
384 String newtitle = new String("Copied sequences");
\r
385 if (getTitle().startsWith("Copied sequences"))
\r
387 newtitle = getTitle();
\r
391 newtitle = newtitle.concat("- from " + getTitle());
\r
393 jalview.bin.JalviewLite.addFrame(af, newtitle, NEW_WINDOW_WIDTH,
\r
394 NEW_WINDOW_HEIGHT);
\r
398 viewport.setEndSeq(viewport.alignment.getHeight());
\r
399 viewport.alignment.getWidth();
\r
400 viewport.updateConservation();
\r
401 viewport.updateConsensus();
\r
402 alignPanel.repaint();
\r
406 catch (Exception ex)
\r
407 {} // could be anything being pasted in here
\r
411 protected void cut_actionPerformed(ActionEvent e)
\r
413 copy_actionPerformed(null);
\r
414 delete_actionPerformed(null);
\r
417 protected void delete_actionPerformed(ActionEvent e)
\r
419 addHistoryItem(new HistoryItem("Delete Sequences", viewport.alignment,
\r
420 HistoryItem.HIDE));
\r
421 if (viewport.getSelectionGroup() == null)
\r
427 SequenceGroup sg = viewport.getSelectionGroup();
\r
428 boolean allSequences = false;
\r
429 if(sg.sequences.size()==viewport.alignment.getHeight())
\r
430 allSequences = true;
\r
432 for (int i = 0; i < sg.sequences.size(); i++)
\r
434 SequenceI seq = sg.getSequenceAt(i);
\r
435 int index = viewport.getAlignment().findIndex(seq);
\r
436 seq.deleteChars(sg.getStartRes(), sg.getEndRes() + 1);
\r
438 // If the cut affects all sequences, remove highlighted columns
\r
441 viewport.getColumnSelection().removeElements(sg.getStartRes(),
\r
442 sg.getEndRes() + 1);
\r
446 if (seq.getSequence().length() < 1)
\r
448 viewport.getAlignment().deleteSequence(seq);
\r
452 viewport.getAlignment().getSequences().setElementAt(seq, index);
\r
456 viewport.setSelectionGroup(null);
\r
457 viewport.alignment.deleteGroup(sg);
\r
458 viewport.resetSeqLimits(alignPanel.seqPanel.seqCanvas.getSize().height);
\r
459 if (viewport.getAlignment().getHeight() < 1)
\r
463 this.setVisible(false);
\r
465 catch (Exception ex)
\r
468 viewport.updateConservation();
\r
469 viewport.updateConsensus();
\r
470 alignPanel.repaint();
\r
474 protected void deleteGroups_actionPerformed(ActionEvent e)
\r
476 viewport.alignment.deleteAllGroups();
\r
477 viewport.setSelectionGroup(null);
\r
479 alignPanel.repaint();
\r
482 public void selectAllSequenceMenuItem_actionPerformed(ActionEvent e)
\r
484 SequenceGroup sg = new SequenceGroup();
\r
485 for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++)
\r
487 sg.addSequence(viewport.getAlignment().getSequenceAt(i), false);
\r
489 sg.setEndRes(viewport.alignment.getWidth());
\r
490 viewport.setSelectionGroup(sg);
\r
491 alignPanel.repaint();
\r
492 PaintRefresher.Refresh(null);
\r
495 public void deselectAllSequenceMenuItem_actionPerformed(ActionEvent e)
\r
497 viewport.setSelectionGroup(null);
\r
498 viewport.getColumnSelection().clear();
\r
499 viewport.setSelectionGroup(null);
\r
500 PaintRefresher.Refresh(null);
\r
503 public void invertSequenceMenuItem_actionPerformed(ActionEvent e)
\r
505 SequenceGroup sg = viewport.getSelectionGroup();
\r
506 for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++)
\r
508 sg.addOrRemove(viewport.getAlignment().getSequenceAt(i), false);
\r
511 PaintRefresher.Refresh(null);
\r
514 public void remove2LeftMenuItem_actionPerformed(ActionEvent e)
\r
516 ColumnSelection colSel = viewport.getColumnSelection();
\r
517 if (colSel.size() > 0)
\r
519 addHistoryItem(new HistoryItem("Remove Left", viewport.alignment,
\r
520 HistoryItem.HIDE));
\r
521 int min = colSel.getMin();
\r
522 viewport.getAlignment().trimLeft(min);
\r
523 colSel.compensateForEdit(0, min);
\r
525 if (viewport.getSelectionGroup() != null)
\r
527 viewport.getSelectionGroup().adjustForRemoveLeft(min);
\r
530 Vector groups = viewport.alignment.getGroups();
\r
531 for (int i = 0; i < groups.size(); i++)
\r
533 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
\r
534 if (!sg.adjustForRemoveLeft(min))
\r
536 viewport.alignment.deleteGroup(sg);
\r
540 alignPanel.repaint();
\r
544 public void remove2RightMenuItem_actionPerformed(ActionEvent e)
\r
546 ColumnSelection colSel = viewport.getColumnSelection();
\r
547 if (colSel.size() > 0)
\r
549 addHistoryItem(new HistoryItem("Remove Right", viewport.alignment,
\r
550 HistoryItem.HIDE));
\r
551 int max = colSel.getMax();
\r
552 viewport.getAlignment().trimRight(max);
\r
553 if (viewport.getSelectionGroup() != null)
\r
555 viewport.getSelectionGroup().adjustForRemoveRight(max);
\r
558 Vector groups = viewport.alignment.getGroups();
\r
559 for (int i = 0; i < groups.size(); i++)
\r
561 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
\r
562 if (!sg.adjustForRemoveRight(max))
\r
564 viewport.alignment.deleteGroup(sg);
\r
568 alignPanel.repaint();
\r
573 public void removeGappedColumnMenuItem_actionPerformed(ActionEvent e)
\r
575 addHistoryItem(new HistoryItem("Remove Gapped Columns",
\r
576 viewport.alignment,
\r
577 HistoryItem.HIDE));
\r
578 viewport.getAlignment().removeGaps();
\r
579 viewport.updateConservation();
\r
580 viewport.updateConsensus();
\r
581 alignPanel.repaint();
\r
584 public void removeAllGapsMenuItem_actionPerformed(ActionEvent e)
\r
586 addHistoryItem(new HistoryItem("Remove Gaps", viewport.alignment,
\r
587 HistoryItem.HIDE));
\r
594 int start=0, end = viewport.alignment.getWidth();
\r
596 if (viewport.getSelectionGroup() != null
\r
597 && viewport.getSelectionGroup().sequences != null
\r
598 && viewport.getSelectionGroup().sequences.size()>0)
\r
600 seqs = viewport.getSelectionGroup().sequences;
\r
601 start = viewport.getSelectionGroup().getStartRes();
\r
602 end = viewport.getSelectionGroup().getEndRes();
\r
605 seqs = viewport.alignment.getSequences();
\r
607 for (int i = 0; i <seqs.size(); i++)
\r
609 current = (SequenceI)seqs.elementAt(i);
\r
610 jSize = current.getLength();
\r
615 if (jalview.util.Comparison.isGap(current.getCharAt(j)))
\r
617 current.deleteCharAt(j);
\r
623 while(j < end && j < jSize) ;
\r
626 viewport.updateConservation();
\r
627 viewport.updateConsensus();
\r
628 alignPanel.repaint();
\r
632 public void findMenuItem_actionPerformed(ActionEvent e)
\r
634 Finder finder = new Finder(alignPanel);
\r
637 public void font_actionPerformed(ActionEvent e)
\r
639 Frame frame = new Frame();
\r
640 FontChooser fc = new FontChooser(alignPanel, frame);
\r
642 jalview.bin.JalviewLite.addFrame(frame, "Change Font", 440, 100);
\r
646 protected void fullSeqId_actionPerformed(ActionEvent e)
\r
648 viewport.setShowFullId(fullSeqId.getState());
\r
649 alignPanel.fontChanged();
\r
650 alignPanel.repaint();
\r
653 protected void colourTextMenuItem_actionPerformed(ActionEvent e)
\r
655 viewport.setColourText(colourTextMenuItem.getState());
\r
656 alignPanel.repaint();
\r
659 protected void wrapMenuItem_actionPerformed(ActionEvent e)
\r
661 viewport.setWrapAlignment(wrapMenuItem.getState());
\r
662 alignPanel.setWrapAlignment(wrapMenuItem.getState());
\r
663 scaleAbove.setEnabled(wrapMenuItem.getState());
\r
664 scaleLeft.setEnabled(wrapMenuItem.getState());
\r
665 scaleRight.setEnabled(wrapMenuItem.getState());
\r
666 alignPanel.repaint();
\r
669 protected void scaleAbove_actionPerformed(ActionEvent e)
\r
671 viewport.setScaleAboveWrapped(scaleAbove.getState());
\r
672 alignPanel.repaint();
\r
675 protected void scaleLeft_actionPerformed(ActionEvent e)
\r
677 viewport.setScaleLeftWrapped(scaleLeft.getState());
\r
678 alignPanel.repaint();
\r
681 protected void scaleRight_actionPerformed(ActionEvent e)
\r
683 viewport.setScaleRightWrapped(scaleRight.getState());
\r
684 alignPanel.repaint();
\r
687 public void viewBoxesMenuItem_actionPerformed(ActionEvent e)
\r
689 viewport.setShowBoxes(viewBoxesMenuItem.getState());
\r
690 alignPanel.repaint();
\r
693 public void viewTextMenuItem_actionPerformed(ActionEvent e)
\r
695 viewport.setShowText(viewTextMenuItem.getState());
\r
696 alignPanel.repaint();
\r
699 protected void renderGapsMenuItem_actionPerformed(ActionEvent e)
\r
701 viewport.setRenderGaps(renderGapsMenuItem.getState());
\r
702 alignPanel.repaint();
\r
705 public void annotationPanelMenuItem_actionPerformed(ActionEvent e)
\r
707 if (annotationPanelMenuItem.getState() && viewport.getWrapAlignment())
\r
709 annotationPanelMenuItem.setState(false);
\r
712 viewport.setShowAnnotation(annotationPanelMenuItem.getState());
\r
713 alignPanel.setAnnotationVisible(annotationPanelMenuItem.getState());
\r
716 public void overviewMenuItem_actionPerformed(ActionEvent e)
\r
718 if (alignPanel.overviewPanel != null)
\r
723 Frame frame = new Frame();
\r
724 OverviewPanel overview = new OverviewPanel(alignPanel);
\r
725 frame.add(overview);
\r
726 // +50 must allow for applet frame window
\r
727 jalview.bin.JalviewLite.addFrame(frame, "Overview " + this.getTitle(),
\r
728 overview.preferredSize().width,
\r
729 overview.preferredSize().height + 50);
\r
732 frame.addWindowListener(new WindowAdapter()
\r
734 public void windowClosing(WindowEvent e)
\r
736 alignPanel.setOverviewPanel(null);
\r
740 alignPanel.setOverviewPanel(overview);
\r
744 protected void noColourmenuItem_actionPerformed(ActionEvent e)
\r
746 changeColour(null);
\r
749 public void clustalColour_actionPerformed(ActionEvent e)
\r
751 abovePIDThreshold.setState(false);
\r
752 changeColour(new ClustalxColourScheme(viewport.alignment.getSequences(),
\r
753 viewport.alignment.getWidth()));
\r
756 public void zappoColour_actionPerformed(ActionEvent e)
\r
758 changeColour(new ZappoColourScheme());
\r
761 public void taylorColour_actionPerformed(ActionEvent e)
\r
763 changeColour(new TaylorColourScheme());
\r
766 public void hydrophobicityColour_actionPerformed(ActionEvent e)
\r
768 changeColour(new HydrophobicColourScheme());
\r
771 public void helixColour_actionPerformed(ActionEvent e)
\r
773 changeColour(new HelixColourScheme());
\r
776 public void strandColour_actionPerformed(ActionEvent e)
\r
778 changeColour(new StrandColourScheme());
\r
781 public void turnColour_actionPerformed(ActionEvent e)
\r
783 changeColour(new TurnColourScheme());
\r
786 public void buriedColour_actionPerformed(ActionEvent e)
\r
788 changeColour(new BuriedColourScheme());
\r
791 public void nucleotideColour_actionPerformed(ActionEvent e)
\r
793 changeColour(new NucleotideColourScheme());
\r
796 protected void applyToAllGroups_actionPerformed(ActionEvent e)
\r
798 viewport.setColourAppliesToAllGroups(applyToAllGroups.getState());
\r
801 void changeColour(ColourSchemeI cs)
\r
805 if (viewport.getAbovePIDThreshold())
\r
807 threshold = SliderPanel.setPIDSliderSource(alignPanel, cs, "Background");
\r
809 if (cs instanceof ResidueColourScheme)
\r
811 ( (ResidueColourScheme) cs).setThreshold(threshold);
\r
814 viewport.setGlobalColourScheme(cs);
\r
816 else if (cs instanceof ResidueColourScheme)
\r
818 ( (ResidueColourScheme) cs).setThreshold(0);
\r
821 if (viewport.getConservationSelected())
\r
823 ConservationColourScheme ccs = null;
\r
825 Alignment al = (Alignment) viewport.alignment;
\r
826 Conservation c = new Conservation("All",
\r
827 ResidueProperties.propHash, 3,
\r
828 al.getSequences(), 0,
\r
829 al.getWidth() - 1);
\r
832 c.verdict(false, viewport.ConsPercGaps);
\r
834 ccs = new ConservationColourScheme(c, cs);
\r
836 // MUST NOTIFY THE COLOURSCHEME OF CONSENSUS!
\r
837 ccs.setConsensus(viewport.vconsensus);
\r
838 viewport.setGlobalColourScheme(ccs);
\r
840 SliderPanel.setConservationSlider(alignPanel, ccs, "Background");
\r
845 // MUST NOTIFY THE COLOURSCHEME OF CONSENSUS!
\r
848 cs.setConsensus(viewport.vconsensus);
\r
850 viewport.setGlobalColourScheme(cs);
\r
853 if (viewport.getColourAppliesToAllGroups())
\r
855 Vector groups = viewport.alignment.getGroups();
\r
856 for (int i = 0; i < groups.size(); i++)
\r
858 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
\r
865 if (cs instanceof ClustalxColourScheme)
\r
867 ClustalxColourScheme cxs = (ClustalxColourScheme) cs;
\r
868 cxs.resetClustalX(viewport.alignment.getSequences(), viewport.alignment.getWidth());
\r
875 sg.cs = (ColourSchemeI) cs.getClass().newInstance();
\r
877 catch (Exception ex)
\r
879 ex.printStackTrace();
\r
884 if (viewport.getAbovePIDThreshold())
\r
886 if (sg.cs instanceof ResidueColourScheme)
\r
888 ( (ResidueColourScheme) sg.cs).setThreshold(threshold);
\r
891 sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0, sg.getWidth()));
\r
894 if (viewport.getConservationSelected())
\r
896 Conservation c = new Conservation("Group",
\r
897 ResidueProperties.propHash, 3,
\r
899 viewport.alignment.getWidth() - 1);
\r
901 c.verdict(false, viewport.ConsPercGaps);
\r
902 ConservationColourScheme ccs = new ConservationColourScheme(c, sg.cs);
\r
904 // MUST NOTIFY THE COLOURSCHEME OF CONSENSUS!
\r
905 ccs.setConsensus(AAFrequency.calculate(sg.sequences, 0, sg.getWidth()));
\r
910 // MUST NOTIFY THE COLOURSCHEME OF CONSENSUS!
\r
911 sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0, sg.getWidth()));
\r
917 if (alignPanel.getOverviewPanel() != null)
\r
919 alignPanel.getOverviewPanel().updateOverviewImage();
\r
922 alignPanel.repaint();
\r
925 protected void modifyPID_actionPerformed(ActionEvent e)
\r
927 if (viewport.getAbovePIDThreshold())
\r
929 SliderPanel.setPIDSliderSource(alignPanel, viewport.getGlobalColourScheme(),
\r
931 SliderPanel.showPIDSlider();
\r
935 protected void modifyConservation_actionPerformed(ActionEvent e)
\r
937 if (viewport.getConservationSelected())
\r
939 SliderPanel.setConservationSlider(alignPanel, viewport.globalColourScheme,
\r
941 SliderPanel.showConservationSlider();
\r
945 protected void conservationMenuItem_actionPerformed(ActionEvent e)
\r
947 viewport.setConservationSelected(conservationMenuItem.getState());
\r
949 viewport.setAbovePIDThreshold(false);
\r
950 abovePIDThreshold.setState(false);
\r
952 ColourSchemeI cs = viewport.getGlobalColourScheme();
\r
953 if (cs instanceof ConservationColourScheme)
\r
955 changeColour( ( (ConservationColourScheme) cs).cs);
\r
962 modifyConservation_actionPerformed(null);
\r
965 public void abovePIDThreshold_actionPerformed(ActionEvent e)
\r
967 viewport.setAbovePIDThreshold(abovePIDThreshold.getState());
\r
969 conservationMenuItem.setState(false);
\r
970 viewport.setConservationSelected(false);
\r
972 ColourSchemeI cs = viewport.getGlobalColourScheme();
\r
974 if (cs instanceof ConservationColourScheme)
\r
976 changeColour( ( (ConservationColourScheme) cs).cs);
\r
983 modifyPID_actionPerformed(null);
\r
986 public void userDefinedColour_actionPerformed(ActionEvent e)
\r
988 UserDefinedColours chooser = new UserDefinedColours(alignPanel, null);
\r
991 public void PIDColour_actionPerformed(ActionEvent e)
\r
993 changeColour(new PIDColourScheme());
\r
996 public void BLOSUM62Colour_actionPerformed(ActionEvent e)
\r
998 changeColour(new Blosum62ColourScheme());
\r
1001 public void sortPairwiseMenuItem_actionPerformed(ActionEvent e)
\r
1003 addHistoryItem(new HistoryItem("Pairwise Sort", viewport.alignment,
\r
1004 HistoryItem.SORT));
\r
1005 AlignmentSorter.sortByPID(viewport.getAlignment(),
\r
1006 viewport.getAlignment().getSequenceAt(0));
\r
1007 alignPanel.repaint();
\r
1010 public void sortIDMenuItem_actionPerformed(ActionEvent e)
\r
1012 addHistoryItem(new HistoryItem("ID Sort", viewport.alignment,
\r
1013 HistoryItem.SORT));
\r
1014 AlignmentSorter.sortByID(viewport.getAlignment());
\r
1015 alignPanel.repaint();
\r
1018 public void sortGroupMenuItem_actionPerformed(ActionEvent e)
\r
1020 addHistoryItem(new HistoryItem("Group Sort", viewport.alignment,
\r
1021 HistoryItem.SORT));
\r
1022 AlignmentSorter.sortByGroup(viewport.getAlignment());
\r
1023 alignPanel.repaint();
\r
1027 public void removeRedundancyMenuItem_actionPerformed(ActionEvent e)
\r
1029 RedundancyPanel sp = new RedundancyPanel(alignPanel);
\r
1030 Frame frame = new Frame();
\r
1032 jalview.bin.JalviewLite.addFrame(frame, "Redundancy threshold selection",
\r
1037 public void pairwiseAlignmentMenuItem_actionPerformed(ActionEvent e)
\r
1039 if (viewport.getSelectionGroup().getSize() > 1)
\r
1041 Frame frame = new Frame();
\r
1042 frame.add(new PairwiseAlignPanel(viewport));
\r
1043 jalview.bin.JalviewLite.addFrame(frame, "Pairwise Alignment", 600, 500);
\r
1047 public void PCAMenuItem_actionPerformed(ActionEvent e)
\r
1050 if ( (viewport.getSelectionGroup() != null &&
\r
1051 viewport.getSelectionGroup().getSize() < 4 &&
\r
1052 viewport.getSelectionGroup().getSize() > 0)
\r
1053 || viewport.getAlignment().getHeight() < 4)
\r
1060 PCAPanel pcaPanel = new PCAPanel(viewport, null);
\r
1061 Frame frame = new Frame();
\r
1062 frame.add(pcaPanel);
\r
1063 jalview.bin.JalviewLite.addFrame(frame, "Principal component analysis",
\r
1066 catch (java.lang.OutOfMemoryError ex)
\r
1072 public void averageDistanceTreeMenuItem_actionPerformed(ActionEvent e)
\r
1074 NewTreePanel("AV", "PID", "Average distance tree using PID");
\r
1077 public void neighbourTreeMenuItem_actionPerformed(ActionEvent e)
\r
1079 NewTreePanel("NJ", "PID", "Neighbour joining tree using PID");
\r
1082 protected void njTreeBlosumMenuItem_actionPerformed(ActionEvent e)
\r
1084 NewTreePanel("NJ", "BL", "Neighbour joining tree using BLOSUM62");
\r
1087 protected void avTreeBlosumMenuItem_actionPerformed(ActionEvent e)
\r
1089 NewTreePanel("AV", "BL", "Average distance tree using BLOSUM62PID");
\r
1092 void NewTreePanel(String type, String pwType, String title)
\r
1094 //are the sequences aligned?
\r
1095 if (!viewport.alignment.isAligned())
\r
1097 SequenceI current;
\r
1098 int Width = viewport.getAlignment().getWidth();
\r
1100 for (int i = 0; i < viewport.getAlignment().getSequences().size();
\r
1103 current = viewport.getAlignment().getSequenceAt(i);
\r
1105 if (current.getLength() < Width)
\r
1107 current.insertCharAt(Width - 1, viewport.getGapCharacter());
\r
1110 alignPanel.repaint();
\r
1114 final TreePanel tp;
\r
1115 if (viewport.getSelectionGroup() != null &&
\r
1116 viewport.getSelectionGroup().getSize() > 3)
\r
1118 tp = new TreePanel(viewport, viewport.getSelectionGroup().sequences, type,
\r
1120 0, viewport.alignment.getWidth());
\r
1124 tp = new TreePanel(viewport, viewport.getAlignment().getSequences(),
\r
1125 type, pwType, 0, viewport.alignment.getWidth());
\r
1128 addTreeMenuItem(tp, title);
\r
1130 jalview.bin.JalviewLite.addFrame(tp, title, 600, 500);
\r
1133 void addTreeMenuItem(final TreePanel treePanel, String title)
\r
1135 final MenuItem item = new MenuItem(title);
\r
1136 sortByTreeMenu.add(item);
\r
1137 item.addActionListener(new java.awt.event.ActionListener()
\r
1139 public void actionPerformed(ActionEvent e)
\r
1141 addHistoryItem(new HistoryItem("Sort", viewport.alignment,
\r
1142 HistoryItem.SORT));
\r
1143 AlignmentSorter.sortByTree(viewport.getAlignment(), treePanel.getTree());
\r
1144 alignPanel.repaint();
\r
1148 treePanel.addWindowListener(new WindowAdapter()
\r
1150 public void windowClosing(WindowEvent e)
\r
1152 sortByTreeMenu.remove(item);
\r
1157 protected void documentation_actionPerformed(ActionEvent e)
\r
1159 jalview.bin.JalviewLite.showURL("http://www.jalview.org/help.html");
\r
1162 protected void about_actionPerformed(ActionEvent e)
\r
1167 public void paint(Graphics g)
\r
1169 g.setColor(Color.white);
\r
1170 g.fillRect(0, 0, getSize().width, getSize().height);
\r
1171 g.setFont(new Font("Helvetica", Font.PLAIN, 12));
\r
1172 FontMetrics fm = g.getFontMetrics();
\r
1173 int fh = fm.getHeight();
\r
1175 g.setColor(Color.black);
\r
1176 g.setFont(new Font("Helvetica", Font.BOLD, 14));
\r
1177 g.drawString("JalView - Release 2.01", 200, y += fh);
\r
1178 g.setFont(new Font("Helvetica", Font.PLAIN, 12));
\r
1179 g.drawString("Authors: Michele Clamp, James Cuff, Steve Searle, Andrew Waterhouse, Jim Procter & Geoff Barton.",
\r
1181 g.drawString("Current development managed by Andrew Waterhouse; Barton Group, University of Dundee.",
\r
1184 "For any issues relating to Jalview, email help@jalview.org", x,
\r
1186 g.drawString("If you use JalView, please cite:", x, y += fh + 8);
\r
1187 g.drawString("\"Clamp, M., Cuff, J., Searle, S. M. and Barton, G. J. (2004), The Jalview Java Alignment Editor\"",
\r
1189 g.drawString("Bioinformatics, 2004 12;426-7.", x, y += fh);
\r
1193 Frame frame = new Frame();
\r
1194 frame.add(new AboutPanel());
\r
1195 jalview.bin.JalviewLite.addFrame(frame, "Jalview", 580, 200);
\r