\r
public class PopupMenu extends JPopupMenu\r
{\r
- JMenuItem residueMenu = new JMenuItem();\r
JMenu groupMenu = new JMenu();\r
JMenuItem copyGroup = new JMenuItem();\r
JMenuItem moveGroup = new JMenuItem();\r
protected JRadioButtonMenuItem PIDColour = new JRadioButtonMenuItem();\r
protected JRadioButtonMenuItem BLOSUM62Colour = new JRadioButtonMenuItem();\r
JRadioButtonMenuItem noColourmenuItem = new JRadioButtonMenuItem();\r
- protected JMenuItem conservationColourIncMenuItem = new JMenuItem();\r
protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem();\r
\r
\r
- AlignViewport av;\r
- SeqPanel seqPanel;\r
+ AlignmentPanel ap;\r
+ JMenu sequenceMenu = new JMenu();\r
+ JMenuItem sequenceName = new JMenuItem();\r
+ JMenu residueMenu = new JMenu();\r
+ JMenuItem annotateResidue = new JMenuItem();\r
\r
- public PopupMenu(AlignViewport av, SeqPanel sp)\r
+ SequenceI sequence;\r
+\r
+ public PopupMenu(AlignmentPanel ap, SequenceI seq)\r
{\r
- this.av = av;\r
- seqPanel = sp;\r
+ ///////////////////////////////////////////////////////////\r
+ // If this is activated from the sequence panel, the user may want to\r
+ // edit or annotate a particular residue. Therefore display the residue menu\r
+ //\r
+ // If from the IDPanel, we must display the sequence menu\r
+ //////////////////////////////////////////////////////////\r
+\r
+ this.ap = ap;\r
+ sequence = seq;\r
\r
ButtonGroup colours = new ButtonGroup();\r
colours.add(noColourmenuItem);\r
colours.add(BLOSUM62Colour);\r
\r
try\r
- {\r
- jbInit();\r
- }\r
+ { jbInit(); }\r
catch(Exception e)\r
+ { e.printStackTrace(); }\r
+\r
+ SequenceGroup sg = ap.av.getRubberbandGroup();\r
+ if(sg!=null)\r
+ groupName.setText( sg.getName() );\r
+\r
+ if(seq!=null)\r
{\r
- e.printStackTrace();\r
+ residueMenu.setVisible(false);\r
+ sequenceName.setText( sequence.getName() );\r
}\r
+ else\r
+ sequenceMenu.setVisible(false);\r
\r
- SequenceGroup sg = av.getRubberbandGroup();\r
- groupName.setText( sg.getName() );\r
}\r
private void jbInit() throws Exception\r
{\r
- residueMenu.setText("Residue");\r
groupMenu.setText("Group");\r
copyGroup.setText("Copy region to new Alignment");\r
copyGroup.addActionListener(new java.awt.event.ActionListener()\r
groupAnnotation_actionPerformed(e);\r
}\r
});\r
+ sequenceMenu.setText("Sequence");\r
+ sequenceName.setText("sequenceName");\r
+ sequenceName.addActionListener(new java.awt.event.ActionListener()\r
+ {\r
+ public void actionPerformed(ActionEvent e)\r
+ {\r
+ sequenceName_actionPerformed(e);\r
+ }\r
+ });\r
+ residueMenu.setText("Residue");\r
+ annotateResidue.setText("annotate residue???");\r
+ PIDColour.setFocusPainted(false);\r
add(groupMenu);\r
- add(residueMenu);\r
+ this.add(sequenceMenu);\r
+ this.add(residueMenu);\r
groupMenu.add(defineMenu);\r
groupMenu.addSeparator();\r
groupMenu.add(copyGroup);\r
defineMenu.add(turnColour);\r
defineMenu.add(buriedColour);\r
defineMenu.add(userDefinedColour);\r
- defineMenu.addSeparator();\r
- defineMenu.add(conservationMenuItem);\r
- defineMenu.add(conservationColourIncMenuItem);\r
- defineMenu.addSeparator();\r
- defineMenu.add(abovePIDColour);\r
defineMenu.add(PIDColour);\r
defineMenu.add(BLOSUM62Colour);\r
+ defineMenu.addSeparator();\r
+ defineMenu.add(abovePIDColour);\r
+ defineMenu.add(conservationMenuItem);\r
+\r
+ sequenceMenu.add(sequenceName);\r
+ residueMenu.add(annotateResidue);\r
\r
noColourmenuItem.setText("None");\r
noColourmenuItem.setSelected(true);\r
}\r
});\r
\r
- clustalColour.setEnabled(false);\r
clustalColour.setSelected(false);\r
clustalColour.setText("Clustalx colours");\r
clustalColour.addActionListener(new java.awt.event.ActionListener()\r
buriedColour_actionPerformed(e);\r
}\r
});\r
- abovePIDColour.setEnabled(false);\r
abovePIDColour.setText("Above PID threshold only");\r
abovePIDColour.addActionListener(new java.awt.event.ActionListener()\r
{\r
userDefinedColour_actionPerformed(e);\r
}\r
});\r
- PIDColour.setEnabled(false);\r
- PIDColour.setText("By PID");\r
+ PIDColour.setText("Percentage Identity");\r
PIDColour.addActionListener(new java.awt.event.ActionListener()\r
{\r
public void actionPerformed(ActionEvent e)\r
PIDColour_actionPerformed(e);\r
}\r
});\r
- BLOSUM62Colour.setText("By BLOSUM62 score");\r
+ BLOSUM62Colour.setText("BLOSUM62 score");\r
BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener()\r
{\r
public void actionPerformed(ActionEvent e)\r
}\r
});\r
\r
- conservationColourIncMenuItem.setEnabled(false);\r
- conservationColourIncMenuItem.setText("Conservation Colour Increment");\r
- conservationColourIncMenuItem.addActionListener(new java.awt.event.ActionListener()\r
- {\r
- public void actionPerformed(ActionEvent e)\r
- {\r
- conservationColourIncMenuItem_actionPerformed(e);\r
- }\r
- });\r
\r
\r
}\r
\r
void refresh()\r
{\r
- seqPanel.seqCanvas.paintFlag=true;\r
- seqPanel.repaint();\r
+ ap.seqPanel.seqCanvas.paintFlag=true;\r
+ ap.seqPanel.repaint();\r
}\r
\r
protected void clustalColour_actionPerformed(ActionEvent e)\r
{\r
-\r
+ getGroup().cs = new ClustalxColourScheme();\r
+ refresh();\r
}\r
\r
protected void zappoColour_actionPerformed(ActionEvent e)\r
}\r
\r
\r
- protected void conservationColourIncMenuItem_actionPerformed(ActionEvent e)\r
- {\r
-\r
-}\r
/*\r
public void conservationColourIncMenuItem_actionPerformed(ActionEvent e)\r
{\r
\r
protected void abovePIDColour_actionPerformed(ActionEvent e)\r
{\r
+ SliderPanel sp = new SliderPanel(ap, 70, false, getGroup().cs );\r
+ JInternalFrame frame = new JInternalFrame();\r
+ frame.setContentPane(sp);\r
+ Desktop.addInternalFrame(frame, "Percentage Identity Threshold", 400,90);\r
+ frame.setMaximizable(false);\r
\r
}\r
\r
protected void userDefinedColour_actionPerformed(ActionEvent e)\r
{\r
JInternalFrame frame = new JInternalFrame();\r
- UserDefinedColours chooser = new UserDefinedColours( frame, seqPanel.parent, getGroup());\r
+ UserDefinedColours chooser = new UserDefinedColours( frame, ap, getGroup());\r
frame.setContentPane(chooser);\r
Desktop.addInternalFrame(frame,"User defined colours", 450,540 );\r
frame.setResizable(false);\r
\r
protected void BLOSUM62Colour_actionPerformed(ActionEvent e)\r
{\r
- getGroup().cs = new Blosum62ColourScheme(av);\r
+ getGroup().cs = new Blosum62ColourScheme(ap.av);\r
refresh();\r
}\r
\r
sg.setName(reply);\r
groupName.setText(reply);\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
- viewport.getSelection().clear();\r
- viewport.resetSeqLimits(alignPanel.seqPanel.seqCanvas.getHeight());\r
- alignPanel.RefreshPanels();\r
- }\r
-\r
- public void moveSelectedMenuItem_actionPerformed(ActionEvent e)\r
- {\r
- copySelectedMenuItem_actionPerformed(null);\r
- deleteSelectedMenuItem_actionPerformed(null);\r
- alignPanel.repaint();\r
- }\r
-\r
- public void copySelectedMenuItem_actionPerformed(ActionEvent e)\r
- {\r
- if(viewport.getSelection().size()==0)\r
- return;\r
\r
- SequenceI[] s = new Sequence[viewport.getSelection().size()];\r
- for (int i=0; i < viewport.getSelection().size(); i++) {\r
- s[i] = new Sequence(viewport.getSelection().sequenceAt(i));\r
- }\r
- AlignFrame af = new AlignFrame(new Alignment(s));\r
- int newHeight = s.length * af.viewport.getCharHeight() + 200;\r
- if(newHeight>500)\r
- newHeight=500;\r
- Desktop.addInternalFrame(af, "Copied sequences", 700,newHeight);\r
- }\r
-*/\r
protected void copyGroup_actionPerformed(ActionEvent e)\r
{\r
- SequenceGroup sg = av.getRubberbandGroup();\r
+ SequenceGroup sg = ap.av.getRubberbandGroup();\r
\r
SequenceI[] s = new Sequence[sg.sequences.size()];\r
for (int i=0; i < sg.sequences.size(); i++)\r
if (newHeight > 500)\r
newHeight = 500;\r
Desktop.addInternalFrame(af, "Copied sequences", 700, newHeight);\r
- }\r
+ }\r
\r
protected void moveGroup_actionPerformed(ActionEvent e)\r
{\r
+ SequenceGroup sg = ap.av.getRubberbandGroup();\r
+\r
+ SequenceI[] s = new Sequence[sg.sequences.size()];\r
+\r
+ for (int i=0; i < sg.sequences.size(); i++)\r
+ s[i] = new Sequence( sg.getSequenceAt(i));\r
+\r
+ AlignFrame af = new AlignFrame(new Alignment(s));\r
+ int newHeight = s.length * af.viewport.getCharHeight() + 200;\r
+ if(newHeight>500)\r
+ newHeight=500;\r
+ Desktop.addInternalFrame(af, "Copied sequences", 700,newHeight);\r
+\r
+\r
+ for (int i=0; i < sg.sequences.size(); i++)\r
+ ap.av.alignment.deleteSequence(sg.getSequenceAt(i));\r
+\r
+\r
+ ap.av.resetSeqLimits(ap.seqPanel.seqCanvas.getHeight());\r
+ ap.RefreshPanels();\r
+\r
\r
}\r
\r
protected void deleteSequences_actionPerformed(ActionEvent e)\r
{\r
- SequenceGroup sg = av.getRubberbandGroup();\r
+ SequenceGroup sg = ap.av.getRubberbandGroup();\r
for (int i=0;i < sg.sequences.size(); i++)\r
- av.getAlignment().deleteSequence(sg.getSequenceAt(i));\r
+ ap.av.getAlignment().deleteSequence(sg.getSequenceAt(i));\r
\r
- av.alignment.deleteGroup(sg);\r
- av.resetSeqLimits(seqPanel.seqCanvas.getHeight());\r
- seqPanel.parent.RefreshPanels();\r
+ ap.av.alignment.deleteGroup(sg);\r
+ ap.av.resetSeqLimits(ap.seqPanel.seqCanvas.getHeight());\r
+ ap.seqPanel.parent.RefreshPanels();\r
\r
}\r
\r
\r
SequenceGroup getGroup()\r
{\r
- SequenceGroup sg = av.getRubberbandGroup();\r
+ SequenceGroup sg = ap.av.getRubberbandGroup();\r
\r
// this method won't add a new group if it already exists\r
- av.alignment.addGroup(sg);\r
+ ap.av.alignment.addGroup(sg);\r
return sg;\r
}\r
+\r
+ void sequenceName_actionPerformed(ActionEvent e)\r
+ {\r
+ String id = sequence.getName();\r
+ String s = (String)JOptionPane.showInternalInputDialog(\r
+ ap,\r
+ "Edit sequence name",\r
+ "Edit sequence name",\r
+ JOptionPane.PLAIN_MESSAGE,\r
+ null,\r
+ null,\r
+ id);\r
+\r
+ if(s!=null)\r
+ {\r
+ sequence.setName(s);\r
+ ap.RefreshPanels();\r
+ }\r
+\r
+ }\r
}\r