/******************** * 2004 Jalview Reengineered * Barton Group * Dundee University * * AM Waterhouse *******************/ package jalview.gui; import jalview.jbgui.GAlignFrame; import jalview.schemes.*; import jalview.datamodel.*; import jalview.analysis.*; import jalview.io.*; import java.awt.event.*; import java.awt.*; import javax.swing.*; public class AlignFrame extends GAlignFrame { AlignmentPanel alignPanel; AlignViewport viewport; public AlignFrame(AlignmentI al) { super(); viewport = new AlignViewport(al,true,true,true,false); alignPanel = new AlignmentPanel(this, viewport); getContentPane().add(alignPanel, java.awt.BorderLayout.CENTER); fontNameMenuItem.setText(viewport.getFont().getName()); fontSizeMenuItem.setText(viewport.getFont().getSize()+""); } protected void saveAs_actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(jalview.bin.Cache.LAST_DIRECTORY); chooser.setDialogTitle("Save Alignment to file - "+e.getActionCommand() +" format."); chooser.setToolTipText("Save"); int value = chooser.showSaveDialog(this); if(value == JFileChooser.APPROVE_OPTION) { String choice = chooser.getSelectedFile().getPath(); jalview.bin.Cache.LAST_DIRECTORY = choice; String output = FormatAdapter.get(e.getActionCommand(), viewport.getAlignment().getSequences()); try{ java.io.PrintWriter out = new java.io.PrintWriter( new java.io.FileWriter( choice ) ); out.println(output); out.close(); } catch(Exception ex){} } } protected void outputText_actionPerformed(ActionEvent e) { CutAndPasteTransfer cap = new CutAndPasteTransfer(false); JInternalFrame frame = new JInternalFrame(); cap.formatForOutput(); frame.setContentPane(cap); Desktop.addInternalFrame(frame, "Alignment output - "+e.getActionCommand(), 600, 500); cap.setText( FormatAdapter.get(e.getActionCommand(), viewport.getAlignment().getSequences())); } protected void htmlMenuItem_actionPerformed(ActionEvent e) { HTMLOutput htmlOutput = new HTMLOutput(viewport.getAlignment(), alignPanel.seqPanel.getColourScheme()); htmlOutput = null; } public void saveAsPostscriptMenuItem_actionPerformed(ActionEvent e) { } public void closeMenuItem_actionPerformed(ActionEvent e) { try{ this.setClosed(true); }catch(Exception ex){} } public void groupsMenuItem_actionPerformed(ActionEvent e) { } public void groupEditingMenuItem_actionPerformed(ActionEvent e) { } public void selectAllSequenceMenuItem_actionPerformed(ActionEvent e) { Selection sel = viewport.getSelection(); for (int i=0; i500) newHeight=500; Desktop.addInternalFrame(af, "Copied sequences", 700,newHeight); } public void deselectAllColumnsMenuItem_actionPerformed(ActionEvent e) { viewport.getColumnSelection().clear(); repaint(); } public void remove2LeftMenuItem_actionPerformed(ActionEvent e) { ColumnSelection colSel = viewport.getColumnSelection(); if (colSel.size() > 0) { int min = colSel.getMin(); viewport.getAlignment().trimLeft(min); colSel.compensateForEdit(0,min); alignPanel.RefreshPanels(); } } public void remove2RightMenuItem_actionPerformed(ActionEvent e) { ColumnSelection colSel = viewport.getColumnSelection(); if (colSel.size() > 0) { int max = colSel.getMax(); if(max>1) viewport.getAlignment().trimRight(max); alignPanel.RefreshPanels(); } } public void removeGappedColumnMenuItem_actionPerformed(ActionEvent e) { viewport.getAlignment().removeGaps(); alignPanel.RefreshPanels(); } public void removeAllGapsMenuItem_actionPerformed(ActionEvent e) { SequenceI current; int jSize; for (int i=0; i < viewport.getAlignment().getSequences().size();i++) { current = viewport.getAlignment().getSequenceAt(i); jSize = current.getLength(); for (int j=0; j < jSize; j++) if (current.getCharAt(j)=='-' || current.getCharAt(j)=='.' || current.getCharAt(j)==' ') { current.deleteCharAt(j); j--; jSize--; } } alignPanel.RefreshPanels(); } public void setGapCharMenuItem_actionPerformed(ActionEvent e) { String thisChar = "-"; String nextChar = "."; if(viewport.getGapCharacter().equals("-")) { thisChar = "."; nextChar = "-"; } setGapCharMenuItem.setText("Set gap character to \""+nextChar+"\""); viewport.setGapCharacter(thisChar); } public void fontNameMenuItem_actionPerformed(ActionEvent e) { String fonts[] = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); String selection = JOptionPane.showInputDialog(this, "Select font", "Font selection", JOptionPane.QUESTION_MESSAGE, null,fonts ,fontNameMenuItem.getText()).toString(); if(selection!=null) { fontNameMenuItem.setText(selection); SetFont(); } } public void fontSizeMenuItem_actionPerformed(ActionEvent e) { String selection = JOptionPane.showInputDialog(this, "Select font size", "Font size", JOptionPane.QUESTION_MESSAGE, null, new String[]{"1","2","4","6","8","10","12","14","16","18","20"} ,fontSizeMenuItem.getText()).toString(); if(selection!=null) { fontSizeMenuItem.setText(selection); SetFont(); } } public void fontStyleMenuItem_actionPerformed(ActionEvent e) { String selection = JOptionPane.showInputDialog(this, "Select font style", "Font style", JOptionPane.QUESTION_MESSAGE, null, new String[]{"plain", "bold", "italic"} ,fontStyleMenuItem.getText()).toString(); if(selection!=null) { fontStyleMenuItem.setText(selection); SetFont(); } } protected void colourTextMenuItem_actionPerformed(ActionEvent e) { viewport.setColourText( colourTextMenuItem.isSelected() ); alignPanel.RefreshPanels(); } void SetFont() { int style = java.awt.Font.PLAIN; if(fontStyleMenuItem.getText().equals("bold")) style = java.awt.Font.BOLD; else if(fontStyleMenuItem.getText().equals("italic")) style = java.awt.Font.ITALIC; viewport.setFont(new java.awt.Font(fontNameMenuItem.getText(), style, Integer.parseInt(fontSizeMenuItem.getText()))); alignPanel.RefreshPanels(); } public void viewBoxesMenuItem_actionPerformed(ActionEvent e) { viewport.setShowBoxes( viewBoxesMenuItem.isSelected() ); alignPanel.RefreshPanels(); } public void viewTextMenuItem_actionPerformed(ActionEvent e) { viewport.setShowText( viewTextMenuItem.isSelected() ); alignPanel.RefreshPanels(); } public void consensusGraphMenuItem_actionPerformed(ActionEvent e) { alignPanel.setGraphPanelVisible( consensusGraphMenuItem.isSelected() ); } public void clustalColour_actionPerformed(ActionEvent e) { // alignPanel.seqPanel.setColourScheme( new ClustalxColourScheme() ); } public void zappoColour_actionPerformed(ActionEvent e) { alignPanel.seqPanel.setColourScheme( new ZappoColourScheme() ); } public void taylorColour_actionPerformed(ActionEvent e) { alignPanel.seqPanel.setColourScheme( new TaylorColourScheme() ); } public void hydrophobicityColour_actionPerformed(ActionEvent e) { alignPanel.seqPanel.setColourScheme( new HydrophobicColourScheme() ); } public void helixColour_actionPerformed(ActionEvent e) { alignPanel.seqPanel.setColourScheme( new HelixColourScheme() ); } public void strandColour_actionPerformed(ActionEvent e) { alignPanel.seqPanel.setColourScheme( new StrandColourScheme() ); } public void turnColour_actionPerformed(ActionEvent e) { alignPanel.seqPanel.setColourScheme( new TurnColourScheme() ); } public void buriedColour_actionPerformed(ActionEvent e) { alignPanel.seqPanel.setColourScheme( new BuriedColourScheme() ); } public void conservationColour_actionPerformed(ActionEvent e) { } public void conservationColourIncMenuItem_actionPerformed(ActionEvent e) { } public void abovePIDColour_actionPerformed(ActionEvent e) { alignPanel.seqPanel.setColourScheme( new PIDColourScheme() ); } public void userDefinedColour_actionPerformed(ActionEvent e) { JInternalFrame frame = new JInternalFrame(); UserDefinedColours chooser = new UserDefinedColours( frame, alignPanel.seqPanel ); frame.setContentPane(chooser); Desktop.addInternalFrame(frame,"User defined colours", 450,540 ); frame.setResizable(false); frame.setIconifiable(false); frame.setMaximizable(false); } public void PIDColour_actionPerformed(ActionEvent e) { alignPanel.seqPanel.setColourScheme( new PIDColourScheme() ); } public void BLOSUM62Colour_actionPerformed(ActionEvent e) { alignPanel.seqPanel.setColourScheme( new Blosum62ColourScheme(viewport) ); } protected void schemeKeyMenuItem_actionPerformed(ActionEvent e) { ColourKey colourKey = new ColourKey( alignPanel.seqPanel.getColourScheme() ); Desktop.addInternalFrame(colourKey, "Colour scheme key", 400, 320); } public void sortPairwiseMenuItem_actionPerformed(ActionEvent e) { AlignmentSorter.sortByPID(viewport.getAlignment(), viewport.getAlignment().getSequenceAt(0)); alignPanel.RefreshPanels(); } public void sortIDMenuItem_actionPerformed(ActionEvent e) { AlignmentSorter.sortByID( viewport.getAlignment() ); alignPanel.RefreshPanels(); } public void sortGroupMenuItem_actionPerformed(ActionEvent e) { AlignmentSorter.sortGroups(viewport.getAlignment()); AlignmentSorter.sortGroups(viewport.getAlignment()); alignPanel.RefreshPanels(); } public void sortTreeOrderMenuItem_actionPerformed(ActionEvent e) { if(viewport.getCurrentTree()==null) return; AlignmentSorter.sortByTree(viewport.getAlignment(), viewport.getCurrentTree()); alignPanel.RefreshPanels(); } public void removeRedundancyMenuItem_actionPerformed(ActionEvent e) { } public void pairwiseAlignmentMenuItem_actionPerformed(ActionEvent e) { if(viewport.getSelection().size()<2) JOptionPane.showMessageDialog(this, "You must select at least 2 sequences.", "Invalid Selection", JOptionPane.WARNING_MESSAGE); else { JInternalFrame frame = new JInternalFrame(); frame.setContentPane(new PairwiseAlignPanel(viewport)); Desktop.addInternalFrame(frame, "Pairwise Alignment", 600, 500); } } public void PCAMenuItem_actionPerformed(ActionEvent e) { PCAPanel pcaPanel = new PCAPanel(viewport, null); JInternalFrame frame = new JInternalFrame(); frame.setContentPane(pcaPanel); Desktop.addInternalFrame(frame, "Principal component analysis", 400,400); } public void averageDistanceTreeMenuItem_actionPerformed(ActionEvent e) { NewTreePanel("AV", "PID", "Average distance tree using PID"); } public void neighbourTreeMenuItem_actionPerformed(ActionEvent e) { NewTreePanel("NJ", "PID", "Neighbour joining tree using PID"); } protected void njTreeBlosumMenuItem_actionPerformed(ActionEvent e) { NewTreePanel("NJ", "BL", "Neighbour joining tree using BLOSUM62"); } protected void avTreeBlosumMenuItem_actionPerformed(ActionEvent e) { NewTreePanel("AV", "BL", "Average distance tree using BLOSUM62PID"); } void NewTreePanel(String type, String pwType, String title) { JInternalFrame frame = new javax.swing.JInternalFrame(); TreePanel tp=null; if (viewport.getSelection() != null && viewport.getSelection().size() > 3) { tp = new TreePanel(viewport, viewport.getSelection().asVector(),type, pwType, viewport.getStartRes(), viewport.getEndRes()); } else { tp = new TreePanel(viewport, viewport.getAlignment().getSequences(), type, pwType, viewport.getStartRes(), viewport.getEndRes()); } frame.setContentPane(tp); Desktop.addInternalFrame(frame, title, 600, 500); } public void clustalAlignMenuItem_actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(this, "Jalview is currently being reengineered" +"\nwithin the Barton Group, Dundee University." +"\nThis will be available as a web service 2005", "Web service", JOptionPane.INFORMATION_MESSAGE); } }