X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FPopupMenu.java;fp=src%2Fjalview%2Fgui%2FPopupMenu.java;h=7576173302b6b4a047bede07c19d114b9dcbfc3a;hb=588042b69abf8e60bcc950b24c283933c7dd422f;hp=7133e44472a6fdb6ca5da12c2a5881f4f8865834;hpb=5cd8e373c75fb348ecda4d94d8a46468fb92756d;p=jalview.git diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index 7133e44..7576173 100755 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -1,41 +1,43 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ - + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ package jalview.gui; -import jalview.datamodel.*; -import jalview.analysis.*; -import jalview.schemes.*; import java.awt.*; -import javax.swing.*; import java.awt.event.*; -import jalview.io.*; +import javax.swing.*; + import MCview.*; +import jalview.analysis.*; +import jalview.datamodel.*; +import jalview.io.*; +import jalview.schemes.*; -public class PopupMenu extends JPopupMenu +public class PopupMenu + extends JPopupMenu { JMenu groupMenu = new JMenu(); JMenuItem groupName = new JMenuItem(); protected JRadioButtonMenuItem clustalColour = new JRadioButtonMenuItem(); protected JRadioButtonMenuItem zappoColour = new JRadioButtonMenuItem(); protected JRadioButtonMenuItem taylorColour = new JRadioButtonMenuItem(); - protected JRadioButtonMenuItem hydrophobicityColour = new JRadioButtonMenuItem(); + protected JRadioButtonMenuItem hydrophobicityColour = new + JRadioButtonMenuItem(); protected JRadioButtonMenuItem helixColour = new JRadioButtonMenuItem(); protected JRadioButtonMenuItem strandColour = new JRadioButtonMenuItem(); protected JRadioButtonMenuItem turnColour = new JRadioButtonMenuItem(); @@ -46,8 +48,6 @@ public class PopupMenu extends JPopupMenu protected JRadioButtonMenuItem BLOSUM62Colour = new JRadioButtonMenuItem(); JRadioButtonMenuItem noColourmenuItem = new JRadioButtonMenuItem(); protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem(); - - AlignmentPanel ap; JMenu sequenceMenu = new JMenu(); JMenuItem sequenceName = new JMenuItem(); @@ -69,7 +69,6 @@ public class PopupMenu extends JPopupMenu // // If from the IDPanel, we must display the sequence menu ////////////////////////////////////////////////////////// - this.ap = ap; sequence = seq; @@ -89,57 +88,96 @@ public class PopupMenu extends JPopupMenu colours.add(BLOSUM62Colour); try - { jbInit(); } - catch(Exception e) - { e.printStackTrace(); } + { + jbInit(); + } + catch (Exception e) + { + e.printStackTrace(); + } SequenceGroup sg = ap.av.getSelectionGroup(); - if(sg!=null) + + if (sg != null) { groupName.setText(sg.getName()); - if(sg.cs instanceof ZappoColourScheme) + + if (sg.cs instanceof ZappoColourScheme) + { zappoColour.setSelected(true); - else if(sg.cs instanceof TaylorColourScheme) + } + else if (sg.cs instanceof TaylorColourScheme) + { taylorColour.setSelected(true); + } else if (sg.cs instanceof PIDColourScheme) + { PIDColour.setSelected(true); + } else if (sg.cs instanceof Blosum62ColourScheme) + { BLOSUM62Colour.setSelected(true); + } else if (sg.cs instanceof UserColourScheme) + { userDefinedColour.setSelected(true); + } else if (sg.cs instanceof HydrophobicColourScheme) + { hydrophobicityColour.setSelected(true); + } else if (sg.cs instanceof HelixColourScheme) + { helixColour.setSelected(true); + } else if (sg.cs instanceof StrandColourScheme) + { strandColour.setSelected(true); + } else if (sg.cs instanceof TurnColourScheme) + { turnColour.setSelected(true); + } else if (sg.cs instanceof BuriedColourScheme) + { buriedColour.setSelected(true); + } else if (sg.cs instanceof ClustalxColourScheme) + { clustalColour.setSelected(true); + } else + { noColourmenuItem.setSelected(true); + } if (sg.cs instanceof ConservationColourScheme) + { conservationMenuItem.setSelected(true); + } showText.setSelected(sg.getDisplayText()); showColourText.setSelected(sg.getColourText()); showBoxes.setSelected(sg.getDisplayBoxes()); } - if( !ap.av.alignment.getGroups().contains(sg)) + if (!ap.av.alignment.getGroups().contains(sg)) + { unGroupMenuItem.setVisible(false); + } else + { groupMenu.insertSeparator(3); + } - if(seq==null) - sequenceMenu.setVisible(false); - + if (seq == null) + { + sequenceMenu.setVisible(false); + } } - private void jbInit() throws Exception + + private void jbInit() + throws Exception { groupMenu.setText("Group"); groupMenu.setText("Define"); @@ -356,24 +394,24 @@ public class PopupMenu extends JPopupMenu } }); conservationMenuItem.setText("Conservation"); - conservationMenuItem.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - conservationMenuItem_actionPerformed(e); - } - }); - - - + conservationMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + conservationMenuItem_actionPerformed(e); + } + }); } void refresh() { SequenceGroup sg = getGroup(); - SuperGroup superG = ap.av.alignment.getSuperGroup( sg ); - if( superG !=null) - superG.setSuperGroupProperties( sg ); + SuperGroup superG = ap.av.alignment.getSuperGroup(sg); + + if (superG != null) + { + superG.setSuperGroupProperties(sg); + } ap.seqPanel.repaint(); } @@ -381,7 +419,8 @@ public class PopupMenu extends JPopupMenu protected void clustalColour_actionPerformed(ActionEvent e) { SequenceGroup sg = getGroup(); - sg.cs = new ClustalxColourScheme(sg.sequences, ap.av.alignment.getWidth()); + sg.cs = new ClustalxColourScheme(sg.sequences, + ap.av.alignment.getWidth()); refresh(); } @@ -397,7 +436,6 @@ public class PopupMenu extends JPopupMenu refresh(); } - protected void hydrophobicityColour_actionPerformed(ActionEvent e) { getGroup().cs = new HydrophobicColourScheme(); @@ -434,24 +472,28 @@ public class PopupMenu extends JPopupMenu refresh(); } - - protected void abovePIDColour_actionPerformed(ActionEvent e) { SequenceGroup sg = getGroup(); + if (abovePIDColour.isSelected()) { sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0, ap.av.alignment.getWidth())); - int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup().getName()); + + int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, + getGroup().getName()); + if (sg.cs instanceof ResidueColourScheme) - ( (ResidueColourScheme)sg. cs).setThreshold(threshold); + { + ( (ResidueColourScheme) sg.cs).setThreshold(threshold); + } else if (sg.cs instanceof ScoreColourScheme) + { ( (ScoreColourScheme) sg.cs).setThreshold(threshold); + } SliderPanel.showPIDSlider(); - - } else // remove PIDColouring { @@ -461,13 +503,11 @@ public class PopupMenu extends JPopupMenu } refresh(); - } - protected void userDefinedColour_actionPerformed(ActionEvent e) { - new UserDefinedColours( ap, getGroup()); + new UserDefinedColours(ap, getGroup()); } protected void PIDColour_actionPerformed(ActionEvent e) @@ -475,7 +515,7 @@ public class PopupMenu extends JPopupMenu SequenceGroup sg = getGroup(); sg.cs = new PIDColourScheme(); sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0, - ap.av.alignment.getWidth())); + ap.av.alignment.getWidth())); refresh(); } @@ -486,34 +526,32 @@ public class PopupMenu extends JPopupMenu sg.cs = new Blosum62ColourScheme(); sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0, - ap.av.alignment.getWidth())); + ap.av.alignment.getWidth())); refresh(); } - protected void noColourmenuItem_actionPerformed(ActionEvent e) { getGroup().cs = null; refresh(); } - protected void conservationMenuItem_actionPerformed(ActionEvent e) + protected void conservationMenuItem_actionPerformed(ActionEvent e) { SequenceGroup sg = getGroup(); - if(conservationMenuItem.isSelected()) + if (conservationMenuItem.isSelected()) { + Conservation c = new Conservation("Group", + ResidueProperties.propHash, 3, + sg.sequences, 0, + ap.av.alignment.getWidth()); - Conservation c = new Conservation("Group", - ResidueProperties.propHash, 3, - sg.sequences, 0, - ap.av.alignment.getWidth()); - - c.calculate(); - c.verdict(false, ap.av.ConsPercGaps); - ConservationColourScheme ccs = new ConservationColourScheme(c, sg.cs); + c.calculate(); + c.verdict(false, ap.av.ConsPercGaps); + ConservationColourScheme ccs = new ConservationColourScheme(c, sg.cs); sg.cs = ccs; @@ -522,45 +560,48 @@ public class PopupMenu extends JPopupMenu } else // remove ConservationColouring { - ConservationColourScheme ccs = (ConservationColourScheme)sg.cs; - sg.cs = ccs.cs; + ConservationColourScheme ccs = (ConservationColourScheme) sg.cs; + sg.cs = ccs.cs; } - refresh(); + refresh(); } - protected void groupName_actionPerformed(ActionEvent e) { SequenceGroup sg = getGroup(); - String reply = JOptionPane.showInternalInputDialog(Desktop.desktop, "Enter new group name", "Edit group name", JOptionPane.QUESTION_MESSAGE); - if(reply==null) + String reply = JOptionPane.showInternalInputDialog(Desktop.desktop, + "Enter new group name", "Edit group name", + JOptionPane.QUESTION_MESSAGE); + + if (reply == null) + { return; + } sg.setName(reply); groupName.setText(reply); } - protected void analyze_actionPerformed(ActionEvent e) { - CutAndPasteTransfer cap = new CutAndPasteTransfer(); - JInternalFrame frame = new JInternalFrame(); - frame.setContentPane(cap); - Desktop.addInternalFrame(frame, "Analyze this - ", 400, 300); - SequenceGroup sg = getGroup(); - StringBuffer sb = new StringBuffer(); - - for(int i=0; i