From a4685bdf439ef8c5b61593c9dbb574e884385a2b Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Wed, 17 Aug 2005 09:09:18 +0000 Subject: [PATCH] User colours --- src/jalview/gui/PopupMenu.java | 39 ++++++++++++++++++++--- src/jalview/jbgui/GAlignFrame.java | 61 ++++++++++++++++++++++++------------ 2 files changed, 76 insertions(+), 24 deletions(-) diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index 26fc93c..40c51cb 100755 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -339,6 +339,28 @@ public class PopupMenu extends JPopupMenu colourMenu.add(buriedColour); colourMenu.add(nucleotideMenuItem); colourMenu.add(userDefinedColour); + + if(jalview.gui.UserDefinedColours.getUserColourSchemes()!=null) + { + java.util.Enumeration userColours = jalview.gui.UserDefinedColours. + getUserColourSchemes().keys(); + + while (userColours.hasMoreElements()) + { + JMenuItem item = new JMenuItem(userColours. + nextElement().toString()); + item.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent evt) + { + userDefinedColour_actionPerformed(evt); + } + }); + colourMenu.add(item); + } + } + + colourMenu.addSeparator(); colourMenu.add(abovePIDColour); colourMenu.add(conservationMenuItem); @@ -423,7 +445,7 @@ public class PopupMenu extends JPopupMenu abovePIDColour_actionPerformed(e); } }); - userDefinedColour.setText("User Defined"); + userDefinedColour.setText("User Defined..."); userDefinedColour.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) @@ -621,9 +643,18 @@ public class PopupMenu extends JPopupMenu */ protected void userDefinedColour_actionPerformed(ActionEvent e) { - new UserDefinedColours(ap, getGroup()); - } - + SequenceGroup sg = getGroup(); + + if (e.getActionCommand().equals("User Defined...")) + new UserDefinedColours(ap, sg); + else + { + UserColourScheme udc = (UserColourScheme) UserDefinedColours. + getUserColourSchemes().get(e.getActionCommand()); + + sg.cs = udc; + } + } /** * DOCUMENT ME! * diff --git a/src/jalview/jbgui/GAlignFrame.java b/src/jalview/jbgui/GAlignFrame.java index 26e5326..345bcf5 100755 --- a/src/jalview/jbgui/GAlignFrame.java +++ b/src/jalview/jbgui/GAlignFrame.java @@ -23,7 +23,6 @@ import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; -import jalview.gui.*; import jalview.schemes.*; public class GAlignFrame @@ -115,25 +114,10 @@ public class GAlignFrame JMenu jMenu2 = new JMenu(); JMenuItem padGapsMenuitem = new JMenuItem(); JMenuItem ClustalRealign = new JMenuItem(); + protected ButtonGroup colours = new ButtonGroup(); public GAlignFrame() { - ButtonGroup colours = new ButtonGroup(); - colours.add(noColourmenuItem); - colours.add(clustalColour); - colours.add(zappoColour); - colours.add(taylorColour); - colours.add(hydrophobicityColour); - colours.add(helixColour); - colours.add(strandColour); - colours.add(turnColour); - colours.add(buriedColour); - colours.add(userDefinedColour); - colours.add(PIDColour); - colours.add(BLOSUM62Colour); - colours.add(nucleotideColour); - - setColourSelected(jalview.bin.Cache.getDefault("DEFAULT_COLOUR", "None")); try @@ -141,12 +125,10 @@ public class GAlignFrame jbInit(); setJMenuBar(alignFrameMenuBar); - JMenuItem item; - // dynamically fill save as menu with available formats for (int i = 0; i < jalview.io.FormatAdapter.formats.size(); i++) { - item = new JMenuItem( (String) jalview.io.FormatAdapter.formats. + JMenuItem item = new JMenuItem( (String) jalview.io.FormatAdapter.formats. elementAt( i)); item.addActionListener(new java.awt.event.ActionListener() @@ -164,6 +146,45 @@ public class GAlignFrame { } + + if(jalview.gui.UserDefinedColours.getUserColourSchemes()!=null) + { + java.util.Enumeration userColours = jalview.gui.UserDefinedColours. + getUserColourSchemes().keys(); + + while (userColours.hasMoreElements()) + { + JRadioButtonMenuItem radioItem = new JRadioButtonMenuItem(userColours. + nextElement().toString()); + radioItem.setName("USER_DEFINED"); + radioItem.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent evt) + { + userDefinedColour_actionPerformed(evt); + } + }); + colourMenu.insert(radioItem, 15); + colours.add(radioItem); + } + } + colours.add(noColourmenuItem); + colours.add(clustalColour); + colours.add(zappoColour); + colours.add(taylorColour); + colours.add(hydrophobicityColour); + colours.add(helixColour); + colours.add(strandColour); + colours.add(turnColour); + colours.add(buriedColour); + colours.add(userDefinedColour); + colours.add(PIDColour); + colours.add(BLOSUM62Colour); + colours.add(nucleotideColour); + + setColourSelected(jalview.bin.Cache.getDefault("DEFAULT_COLOUR", "None")); + + } public void setColourSelected(String defaultColour) -- 1.7.10.2