import java.awt.event.*;\r
import java.awt.*;\r
import javax.swing.*;\r
+import java.util.*;\r
\r
public class AlignFrame extends GAlignFrame\r
{\r
- AlignmentPanel alignPanel;\r
- AlignViewport viewport;\r
+ final AlignmentPanel alignPanel;\r
+ final AlignViewport viewport;\r
public AlignFrame(AlignmentI al)\r
{\r
super();\r
}catch(Exception ex){}\r
}\r
\r
- public void groupsMenuItem_actionPerformed(ActionEvent e)\r
+ ArrayList historyList = new ArrayList();\r
+ ArrayList redoList = new ArrayList();\r
+\r
+ void updateEditMenuBar()\r
{\r
+ if(historyList.size()>0)\r
+ {\r
+ undoMenuItem.setEnabled(true);\r
+ Object [] history = (Object[])historyList.get(0);\r
+ undoMenuItem.setText("Undo "+history[0]);\r
+ }\r
+ else\r
+ {\r
+ undoMenuItem.setEnabled(false);\r
+ undoMenuItem.setText("Undo");\r
+ }\r
\r
+ if(redoList.size()>0)\r
+ {\r
+ redoMenuItem.setEnabled(true);\r
+ Object [] history = (Object[])redoList.get(0);\r
+ redoMenuItem.setText("Redo "+history[0]);\r
+ }\r
+ else\r
+ {\r
+ redoMenuItem.setEnabled(false);\r
+ redoMenuItem.setText("Redo");\r
+ }\r
}\r
\r
- public void groupEditingMenuItem_actionPerformed(ActionEvent e)\r
+ public void addHistoryItem(String type)\r
+ {\r
+ // must make sure we add new sequence objects her, not refs to the existing sequences\r
+ redoList.clear();\r
+ SequenceI[] seq = new SequenceI[viewport.getAlignment().getHeight()];\r
+ for(int i=0; i<viewport.getAlignment().getHeight(); i++)\r
+ {\r
+ seq[i] = new Sequence( viewport.getAlignment().getSequenceAt(i).getName(),\r
+ viewport.getAlignment().getSequenceAt(i).getSequence());\r
+ }\r
+\r
+ historyList.add(0, new Object[]{type, seq} );\r
+ updateEditMenuBar();\r
+ }\r
+\r
+ protected void undoMenuItem_actionPerformed(ActionEvent e)\r
+ {\r
+ Object [] history = (Object[])historyList.remove(0);\r
+ // add the redo state before continuing!!\r
+ SequenceI[] seq = new SequenceI[viewport.getAlignment().getHeight()];\r
+ for (int i = 0; i < viewport.getAlignment().getHeight(); i++)\r
+ {\r
+ seq[i] = new Sequence(viewport.getAlignment().getSequenceAt(i).getName(),\r
+ viewport.getAlignment().getSequenceAt(i).\r
+ getSequence());\r
+ }\r
+ /////////\r
+\r
+ redoList.add(0, new Object[] {history[0], seq});\r
+\r
+ seq = (SequenceI[]) history[1];\r
+ viewport.setAlignment( new Alignment(seq) );\r
+ updateEditMenuBar();\r
+ alignPanel.RefreshPanels();\r
+ }\r
+\r
+\r
+ protected void redoMenuItem_actionPerformed(ActionEvent e)\r
+ {\r
+ Object [] history = (Object[])redoList.remove(0);\r
+ SequenceI[] seq = (SequenceI[]) history[1];\r
+ viewport.setAlignment( new Alignment(seq) );\r
+ updateEditMenuBar();\r
+ alignPanel.RefreshPanels();\r
+ }\r
+\r
+\r
+\r
+ public void groupsMenuItem_actionPerformed(ActionEvent e)\r
{\r
+ GroupEditor geditor = new GroupEditor(viewport, alignPanel);\r
+ JInternalFrame frame = new JInternalFrame();\r
+ frame.setContentPane(geditor);\r
+ Desktop.addInternalFrame(frame, "Group editor", 710, 410);\r
+ frame.setResizable(false);\r
+ }\r
\r
+ public void groupEditingMenuItem_actionPerformed(ActionEvent e)\r
+ {\r
+ viewport.setGroupEdit( groupEditingMenuItem.isSelected() );\r
}\r
\r
public void selectAllSequenceMenuItem_actionPerformed(ActionEvent e)\r
\r
public void deleteSelectedMenuItem_actionPerformed(ActionEvent e)\r
{\r
+ addHistoryItem("delete selection");\r
+\r
for (int i=0;i < viewport.getSelection().size(); i++)\r
viewport.getAlignment().deleteSequence(viewport.getSelection().sequenceAt(i));\r
\r
s[i] = new Sequence(viewport.getSelection().sequenceAt(i));\r
}\r
AlignFrame af = new AlignFrame(new Alignment(s));\r
-\r
int newHeight = s.length * af.viewport.getCharHeight() + 200;\r
if(newHeight>500)\r
newHeight=500;\r
\r
public void remove2LeftMenuItem_actionPerformed(ActionEvent e)\r
{\r
+ addHistoryItem("delete columns");\r
ColumnSelection colSel = viewport.getColumnSelection();\r
if (colSel.size() > 0)\r
{\r
\r
public void remove2RightMenuItem_actionPerformed(ActionEvent e)\r
{\r
+ addHistoryItem("delete columns");\r
ColumnSelection colSel = viewport.getColumnSelection();\r
if (colSel.size() > 0)\r
{\r
\r
public void removeGappedColumnMenuItem_actionPerformed(ActionEvent e)\r
{\r
+ addHistoryItem("delete gapped columns");\r
viewport.getAlignment().removeGaps();\r
alignPanel.RefreshPanels();\r
}\r
\r
public void removeAllGapsMenuItem_actionPerformed(ActionEvent e)\r
{\r
+ addHistoryItem("delete all gaps");\r
SequenceI current;\r
int jSize;\r
for (int i=0; i < viewport.getAlignment().getSequences().size();i++)\r
\r
}\r
\r
+ protected void wrapMenuItem_actionPerformed(ActionEvent e)\r
+ {\r
+ viewport.setWrapAlignment( wrapMenuItem.isSelected() );\r
+ alignPanel.setWrapAlignment( wrapMenuItem.isSelected() );\r
+ }\r
+\r
+\r
public void viewBoxesMenuItem_actionPerformed(ActionEvent e)\r
{\r
viewport.setShowBoxes( viewBoxesMenuItem.isSelected() );\r
\r
}catch(java.lang.OutOfMemoryError ex)\r
{\r
- JOptionPane.showMessageDialog(this, "Sequence alignment too large to\nproduce overview image!!",\r
+ JOptionPane.showMessageDialog(this, "Sequence alignment too large to\nproduce overview image!!"\r
+ +"\nTry reducing the font size.",\r
"Out of memory", JOptionPane.WARNING_MESSAGE);\r
}\r
\r
\r
}\r
\r
+ protected void noColourmenuItem_actionPerformed(ActionEvent e)\r
+ {\r
+ alignPanel.setColourScheme(null, false);\r
+ }\r
+\r
\r
public void clustalColour_actionPerformed(ActionEvent e)\r
{\r
\r
public void zappoColour_actionPerformed(ActionEvent e)\r
{\r
- alignPanel.setColourScheme( new ZappoColourScheme() );\r
+ alignPanel.setColourScheme( new ZappoColourScheme(), conservationMenuItem.isSelected() );\r
}\r
\r
public void taylorColour_actionPerformed(ActionEvent e)\r
{\r
- alignPanel.setColourScheme( new TaylorColourScheme() );\r
+ alignPanel.setColourScheme( new TaylorColourScheme(),conservationMenuItem.isSelected() );\r
}\r
\r
\r
public void hydrophobicityColour_actionPerformed(ActionEvent e)\r
{\r
- alignPanel.setColourScheme( new HydrophobicColourScheme() );\r
+ alignPanel.setColourScheme( new HydrophobicColourScheme(),conservationMenuItem.isSelected() );\r
}\r
\r
public void helixColour_actionPerformed(ActionEvent e)\r
{\r
- alignPanel.seqPanel.setColourScheme( new HelixColourScheme() );\r
+ alignPanel.setColourScheme( new HelixColourScheme(),conservationMenuItem.isSelected() );\r
}\r
\r
+\r
public void strandColour_actionPerformed(ActionEvent e)\r
{\r
- alignPanel.setColourScheme( new StrandColourScheme() );\r
+ alignPanel.setColourScheme( new StrandColourScheme() ,conservationMenuItem.isSelected() );\r
}\r
\r
+\r
public void turnColour_actionPerformed(ActionEvent e)\r
{\r
- alignPanel.setColourScheme( new TurnColourScheme() );\r
+ alignPanel.setColourScheme( new TurnColourScheme() ,conservationMenuItem.isSelected() );\r
}\r
\r
+\r
public void buriedColour_actionPerformed(ActionEvent e)\r
{\r
- alignPanel.setColourScheme( new BuriedColourScheme() );\r
+ alignPanel.setColourScheme( new BuriedColourScheme() ,conservationMenuItem.isSelected() );\r
}\r
\r
- public void conservationColour_actionPerformed(ActionEvent e)\r
- {\r
\r
+ protected void conservationMenuItem_actionPerformed(ActionEvent e)\r
+ {\r
+ alignPanel.setColourScheme ( alignPanel.seqPanel.getColourScheme(),conservationMenuItem.isSelected() );\r
+ conservationColourIncMenuItem.setEnabled( conservationMenuItem.isSelected() );\r
}\r
\r
+\r
+\r
public void conservationColourIncMenuItem_actionPerformed(ActionEvent e)\r
{\r
-\r
+ ConservationIncrementPanel cip = new ConservationIncrementPanel(viewport, alignPanel);\r
+ JInternalFrame frame = new JInternalFrame();\r
+ frame.setContentPane(cip);\r
+ Desktop.addInternalFrame(frame, "Conservation Colour Increment", 400,90);\r
+ frame.setMaximizable(false);\r
}\r
\r
\r
public void abovePIDColour_actionPerformed(ActionEvent e)\r
{\r
- alignPanel.setColourScheme( new PIDColourScheme() );\r
+ alignPanel.setColourScheme( new PIDColourScheme() ,conservationMenuItem.isSelected() );\r
}\r
\r
\r
\r
public void PIDColour_actionPerformed(ActionEvent e)\r
{\r
- alignPanel.setColourScheme( new PIDColourScheme() );\r
+ alignPanel.setColourScheme( new PIDColourScheme(),conservationMenuItem.isSelected() );\r
}\r
\r
+\r
public void BLOSUM62Colour_actionPerformed(ActionEvent e)\r
{\r
- alignPanel.setColourScheme( new Blosum62ColourScheme(viewport) );\r
+ alignPanel.setColourScheme( new Blosum62ColourScheme(viewport) ,conservationMenuItem.isSelected() );\r
}\r
\r
\r
+\r
protected void schemeKeyMenuItem_actionPerformed(ActionEvent e)\r
{\r
ColourKey colourKey = new ColourKey( alignPanel.seqPanel.getColourScheme() );\r
\r
public void sortPairwiseMenuItem_actionPerformed(ActionEvent e)\r
{\r
+ addHistoryItem("sort");\r
AlignmentSorter.sortByPID(viewport.getAlignment(), viewport.getAlignment().getSequenceAt(0));\r
alignPanel.RefreshPanels();\r
}\r
\r
public void sortIDMenuItem_actionPerformed(ActionEvent e)\r
{\r
+ addHistoryItem("sort");\r
AlignmentSorter.sortByID( viewport.getAlignment() );\r
alignPanel.RefreshPanels();\r
}\r
\r
public void sortGroupMenuItem_actionPerformed(ActionEvent e)\r
{\r
+ addHistoryItem("sort");\r
AlignmentSorter.sortGroups(viewport.getAlignment());\r
AlignmentSorter.sortGroups(viewport.getAlignment());\r
alignPanel.RefreshPanels();\r
\r
public void sortTreeOrderMenuItem_actionPerformed(ActionEvent e)\r
{\r
+ addHistoryItem("sort");\r
if(viewport.getCurrentTree()==null)\r
return;\r
\r
return;\r
}\r
\r
- PCAPanel pcaPanel = new PCAPanel(viewport, null);\r
- JInternalFrame frame = new JInternalFrame();\r
- frame.setContentPane(pcaPanel);\r
- Desktop.addInternalFrame(frame, "Principal component analysis", 400,400);\r
+ try{\r
+ PCAPanel pcaPanel = new PCAPanel(viewport, null);\r
+ JInternalFrame frame = new JInternalFrame();\r
+ frame.setContentPane(pcaPanel);\r
+ Desktop.addInternalFrame(frame, "Principal component analysis", 400, 400);\r
+ }catch(java.lang.OutOfMemoryError ex)\r
+ {\r
+ JOptionPane.showMessageDialog(this, "Too many sequences selected\nfor Principal Component Analysis!!",\r
+ "Out of memory", JOptionPane.WARNING_MESSAGE);\r
+ }\r
+\r
+\r
}\r
\r
public void averageDistanceTreeMenuItem_actionPerformed(ActionEvent e)\r