JAL-2361 select colour menu item by matching its name to colour scheme
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 19 Dec 2016 10:44:31 +0000 (10:44 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 19 Dec 2016 10:44:31 +0000 (10:44 +0000)
name

src/jalview/gui/AlignFrame.java
src/jalview/gui/PopupMenu.java
src/jalview/gui/UserDefinedColours.java
src/jalview/jbgui/GAlignFrame.java

index 9aed70d..a88b11f 100644 (file)
@@ -880,7 +880,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
             .isApplicableTo(al));
     tcoffeeColour
             .setEnabled(new TCoffeeColourScheme(al).isApplicableTo(al));
-    RNAInteractionColour.setEnabled(nucleotide);
+    // RNAInteractionColour.setEnabled(nucleotide);
     showComplementMenuItem.setText(nucleotide ? MessageManager
             .getString("label.protein") : MessageManager
             .getString("label.nucleotide"));
@@ -3502,9 +3502,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   public void changeColour(ColourSchemeI cs)
   {
     // TODO: pull up to controller method
-
     if (cs != null)
     {
+      setColourSelected(cs.getSchemeName());
       // Make sure viewport is up to date w.r.t. any sliders
       if (viewport.getAbovePIDThreshold())
       {
@@ -3605,10 +3605,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   }
 
   /**
-   * DOCUMENT ME!
+   * Action on the user selecting either a named user-defined colour from the
+   * colour menu, or the option "User Defined" to create or load a new colour
+   * scheme.
    * 
    * @param e
-   *          DOCUMENT ME!
    */
   @Override
   public void userDefinedColour_actionPerformed(ActionEvent e)
@@ -3616,13 +3617,19 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     if (e.getActionCommand().equals(
             MessageManager.getString("action.user_defined")))
     {
+      /*
+       * User Defined... option; open panel to
+       * load / create / apply / save user defined colour
+       */
       new UserDefinedColours(alignPanel, null);
     }
     else
     {
+      /*
+       * User chose an existing user defined colour
+       */
       UserColourScheme udc = UserDefinedColours
               .getUserColourSchemes().get(e.getActionCommand());
-
       changeColour(udc);
     }
   }
index 0a133cf..ebcb062 100644 (file)
@@ -46,8 +46,10 @@ import jalview.schemes.AnnotationColourGradient;
 import jalview.schemes.Blosum62ColourScheme;
 import jalview.schemes.BuriedColourScheme;
 import jalview.schemes.ClustalxColourScheme;
+import jalview.schemes.ColourSchemeI;
 import jalview.schemes.HelixColourScheme;
 import jalview.schemes.HydrophobicColourScheme;
+import jalview.schemes.JalviewColourScheme;
 import jalview.schemes.NucleotideColourScheme;
 import jalview.schemes.PIDColourScheme;
 import jalview.schemes.PurinePyrimidineColourScheme;
@@ -63,6 +65,7 @@ import jalview.util.MessageManager;
 import jalview.util.UrlLink;
 
 import java.awt.Color;
+import java.awt.Component;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.util.Arrays;
@@ -246,7 +249,7 @@ public class PopupMenu extends JPopupMenu
     {
       JMenuItem item = new JMenuItem(ff);
 
-      item.addActionListener(new java.awt.event.ActionListener()
+      item.addActionListener(new ActionListener()
       {
         @Override
         public void actionPerformed(ActionEvent e)
@@ -330,7 +333,7 @@ public class PopupMenu extends JPopupMenu
               menuItem.setText(MessageManager.formatMessage(
                       "label.2d_rna_structure_line",
                       new Object[] { aa.label }));
-              menuItem.addActionListener(new java.awt.event.ActionListener()
+              menuItem.addActionListener(new ActionListener()
               {
                 @Override
                 public void actionPerformed(ActionEvent e)
@@ -358,7 +361,7 @@ public class PopupMenu extends JPopupMenu
               menuItem.setText(MessageManager.formatMessage(
                       "label.2d_rna_sequence_name",
                       new Object[] { seq.getName() }));
-              menuItem.addActionListener(new java.awt.event.ActionListener()
+              menuItem.addActionListener(new ActionListener()
               {
                 @Override
                 public void actionPerformed(ActionEvent e)
@@ -379,7 +382,7 @@ public class PopupMenu extends JPopupMenu
 
       menuItem = new JMenuItem(
               MessageManager.getString("action.hide_sequences"));
-      menuItem.addActionListener(new java.awt.event.ActionListener()
+      menuItem.addActionListener(new ActionListener()
       {
         @Override
         public void actionPerformed(ActionEvent e)
@@ -395,7 +398,7 @@ public class PopupMenu extends JPopupMenu
         menuItem = new JMenuItem(MessageManager.formatMessage(
                 "label.represent_group_with",
                 new Object[] { seq.getName() }));
-        menuItem.addActionListener(new java.awt.event.ActionListener()
+        menuItem.addActionListener(new ActionListener()
         {
           @Override
           public void actionPerformed(ActionEvent e)
@@ -464,67 +467,7 @@ public class PopupMenu extends JPopupMenu
       groupName.setText(MessageManager
               .getString("label.edit_name_and_description_current_group"));
 
-      if (sg.cs instanceof ZappoColourScheme)
-      {
-        zappoColour.setSelected(true);
-      }
-      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 if (sg.cs instanceof PurinePyrimidineColourScheme)
-      {
-        purinePyrimidineColour.setSelected(true);
-      }
-      else if (sg.cs instanceof NucleotideColourScheme)
-      {
-        nucleotideColour.setSelected(true);
-      }
-
-      /*
-       * else if (sg.cs instanceof CovariationColourScheme) {
-       * covariationColour.setSelected(true); }
-       */
-      else
-      {
-        noColourmenuItem.setSelected(true);
-      }
+      setColourSelected(sg.cs);
 
       if (sg.cs != null && sg.cs.conservationApplied())
       {
@@ -770,7 +713,7 @@ public class PopupMenu extends JPopupMenu
     label = label.substring(1, label.length() - 1); // a, b, c
     final JMenuItem item = new JMenuItem(label);
     item.setToolTipText(calcId);
-    item.addActionListener(new java.awt.event.ActionListener()
+    item.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -952,7 +895,7 @@ public class PopupMenu extends JPopupMenu
     JMenuItem item = new JMenuItem(label);
     item.setToolTipText(MessageManager.formatMessage(
             "label.open_url_param", new Object[] { url }));
-    item.addActionListener(new java.awt.event.ActionListener()
+    item.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1029,7 +972,7 @@ public class PopupMenu extends JPopupMenu
   {
     groupMenu.setText(MessageManager.getString("label.selection"));
     groupName.setText(MessageManager.getString("label.name"));
-    groupName.addActionListener(new java.awt.event.ActionListener()
+    groupName.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1040,7 +983,7 @@ public class PopupMenu extends JPopupMenu
     sequenceMenu.setText(MessageManager.getString("label.sequence"));
     sequenceName.setText(MessageManager
             .getString("label.edit_name_description"));
-    sequenceName.addActionListener(new java.awt.event.ActionListener()
+    sequenceName.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1050,7 +993,7 @@ public class PopupMenu extends JPopupMenu
     });
     chooseAnnotations.setText(MessageManager
             .getString("action.choose_annotations"));
-    chooseAnnotations.addActionListener(new java.awt.event.ActionListener()
+    chooseAnnotations.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1060,7 +1003,7 @@ public class PopupMenu extends JPopupMenu
     });
     sequenceDetails.setText(MessageManager
             .getString("label.sequence_details"));
-    sequenceDetails.addActionListener(new java.awt.event.ActionListener()
+    sequenceDetails.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1071,7 +1014,7 @@ public class PopupMenu extends JPopupMenu
     sequenceSelDetails.setText(MessageManager
             .getString("label.sequence_details"));
     sequenceSelDetails
-            .addActionListener(new java.awt.event.ActionListener()
+.addActionListener(new ActionListener()
             {
               @Override
               public void actionPerformed(ActionEvent e)
@@ -1082,7 +1025,7 @@ public class PopupMenu extends JPopupMenu
     PIDColour.setFocusPainted(false);
     unGroupMenuItem
             .setText(MessageManager.getString("action.remove_group"));
-    unGroupMenuItem.addActionListener(new java.awt.event.ActionListener()
+    unGroupMenuItem.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1093,7 +1036,7 @@ public class PopupMenu extends JPopupMenu
     createGroupMenuItem.setText(MessageManager
             .getString("action.create_group"));
     createGroupMenuItem
-            .addActionListener(new java.awt.event.ActionListener()
+.addActionListener(new ActionListener()
             {
               @Override
               public void actionPerformed(ActionEvent e)
@@ -1103,7 +1046,7 @@ public class PopupMenu extends JPopupMenu
             });
 
     outline.setText(MessageManager.getString("action.border_colour"));
-    outline.addActionListener(new java.awt.event.ActionListener()
+    outline.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1111,17 +1054,6 @@ public class PopupMenu extends JPopupMenu
         outline_actionPerformed();
       }
     });
-    nucleotideColour
-            .setText(MessageManager.getString("label.nucleotide"));
-    nucleotideColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        nucleotideMenuItem_actionPerformed();
-      }
-    });
-    colourMenu.setText(MessageManager.getString("label.group_colour"));
     showBoxes.setText(MessageManager.getString("action.boxes"));
     showBoxes.setState(true);
     showBoxes.addActionListener(new ActionListener()
@@ -1228,15 +1160,6 @@ public class PopupMenu extends JPopupMenu
         sequenceFeature_actionPerformed();
       }
     });
-    textColour.setText(MessageManager.getString("label.text_colour"));
-    textColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        textColour_actionPerformed();
-      }
-    });
     jMenu1.setText(MessageManager.getString("label.group"));
     pdbStructureDialog.setText(MessageManager
             .getString("label.show_pdbstruct_dialog"));
@@ -1348,8 +1271,27 @@ public class PopupMenu extends JPopupMenu
     jMenu1.add(showColourText);
     jMenu1.add(outline);
     jMenu1.add(displayNonconserved);
+
+    initColourMenu();
+  }
+
+  /**
+   * Constructs the entries for the colour menu
+   */
+  protected void initColourMenu()
+  {
+    colourMenu.setText(MessageManager.getString("label.group_colour"));
+    textColour.setText(MessageManager.getString("label.text_colour"));
+    textColour.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        textColour_actionPerformed();
+      }
+    });
     noColourmenuItem.setText(MessageManager.getString("label.none"));
-    noColourmenuItem.addActionListener(new java.awt.event.ActionListener()
+    noColourmenuItem.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1359,7 +1301,8 @@ public class PopupMenu extends JPopupMenu
     });
 
     clustalColour.setText(MessageManager.getString("label.clustalx"));
-    clustalColour.addActionListener(new java.awt.event.ActionListener()
+    clustalColour.setName(JalviewColourScheme.Clustal.toString());
+    clustalColour.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1368,7 +1311,8 @@ public class PopupMenu extends JPopupMenu
       }
     });
     zappoColour.setText(MessageManager.getString("label.zappo"));
-    zappoColour.addActionListener(new java.awt.event.ActionListener()
+    zappoColour.setName(JalviewColourScheme.Zappo.toString());
+    zappoColour.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1377,7 +1321,8 @@ public class PopupMenu extends JPopupMenu
       }
     });
     taylorColour.setText(MessageManager.getString("label.taylor"));
-    taylorColour.addActionListener(new java.awt.event.ActionListener()
+    taylorColour.setName(JalviewColourScheme.Taylor.toString());
+    taylorColour.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1388,16 +1333,18 @@ public class PopupMenu extends JPopupMenu
     hydrophobicityColour.setText(MessageManager
             .getString("label.hydrophobicity"));
     hydrophobicityColour
-            .addActionListener(new java.awt.event.ActionListener()
-            {
-              @Override
-              public void actionPerformed(ActionEvent e)
-              {
-                hydrophobicityColour_actionPerformed();
-              }
-            });
+            .setName(JalviewColourScheme.Hydrophobic.toString());
+    hydrophobicityColour.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        hydrophobicityColour_actionPerformed();
+      }
+    });
     helixColour.setText(MessageManager.getString("label.helix_propensity"));
-    helixColour.addActionListener(new java.awt.event.ActionListener()
+    helixColour.setName(JalviewColourScheme.Helix.toString());
+    helixColour.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1407,7 +1354,8 @@ public class PopupMenu extends JPopupMenu
     });
     strandColour.setText(MessageManager
             .getString("label.strand_propensity"));
-    strandColour.addActionListener(new java.awt.event.ActionListener()
+    strandColour.setName(JalviewColourScheme.Strand.toString());
+    strandColour.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1416,7 +1364,8 @@ public class PopupMenu extends JPopupMenu
       }
     });
     turnColour.setText(MessageManager.getString("label.turn_propensity"));
-    turnColour.addActionListener(new java.awt.event.ActionListener()
+    turnColour.setName(JalviewColourScheme.Turn.toString());
+    turnColour.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1425,7 +1374,8 @@ public class PopupMenu extends JPopupMenu
       }
     });
     buriedColour.setText(MessageManager.getString("label.buried_index"));
-    buriedColour.addActionListener(new java.awt.event.ActionListener()
+    buriedColour.setName(JalviewColourScheme.Buried.toString());
+    buriedColour.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1435,7 +1385,7 @@ public class PopupMenu extends JPopupMenu
     });
     abovePIDColour.setText(MessageManager
             .getString("label.above_identity_threshold"));
-    abovePIDColour.addActionListener(new java.awt.event.ActionListener()
+    abovePIDColour.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1445,7 +1395,8 @@ public class PopupMenu extends JPopupMenu
     });
     userDefinedColour.setText(MessageManager
             .getString("action.user_defined"));
-    userDefinedColour.addActionListener(new java.awt.event.ActionListener()
+    userDefinedColour.setName(JalviewColourScheme.UserDefined.toString());
+    userDefinedColour.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1455,7 +1406,8 @@ public class PopupMenu extends JPopupMenu
     });
     PIDColour
             .setText(MessageManager.getString("label.percentage_identity"));
-    PIDColour.addActionListener(new java.awt.event.ActionListener()
+    PIDColour.setName(JalviewColourScheme.PID.toString());
+    PIDColour.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1465,7 +1417,8 @@ public class PopupMenu extends JPopupMenu
     });
     BLOSUM62Colour
             .setText(MessageManager.getString("label.blosum62_score"));
-    BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener()
+    BLOSUM62Colour.setName(JalviewColourScheme.Blosum62.toString());
+    BLOSUM62Colour.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1473,19 +1426,31 @@ public class PopupMenu extends JPopupMenu
         BLOSUM62Colour_actionPerformed();
       }
     });
+    nucleotideColour.setText(MessageManager.getString("label.nucleotide"));
+    nucleotideColour.setName(JalviewColourScheme.Nucleotide.toString());
+    nucleotideColour.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        nucleotideMenuItem_actionPerformed();
+      }
+    });
     purinePyrimidineColour.setText(MessageManager
             .getString("label.purine_pyrimidine"));
-    purinePyrimidineColour
-            .addActionListener(new java.awt.event.ActionListener()
-            {
-              @Override
-              public void actionPerformed(ActionEvent e)
-              {
-                purinePyrimidineColour_actionPerformed();
-              }
-            });
+    purinePyrimidineColour.setName(JalviewColourScheme.PurinePyrimidine
+            .toString());
+    purinePyrimidineColour.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        purinePyrimidineColour_actionPerformed();
+      }
+    });
 
     tcoffeeColour.setText(MessageManager.getString("label.tcoffee_scores"));
+    tcoffeeColour.setName(JalviewColourScheme.TCoffee.toString());
     tcoffeeColour.addActionListener(new ActionListener()
     {
       @Override
@@ -1496,7 +1461,7 @@ public class PopupMenu extends JPopupMenu
     });
 
     /*
-     * covariationColour.addActionListener(new java.awt.event.ActionListener() {
+     * covariationColour.addActionListener(new ActionListener() {
      * public void actionPerformed(ActionEvent e) {
      * covariationColour_actionPerformed(); } });
      */
@@ -1514,13 +1479,15 @@ public class PopupMenu extends JPopupMenu
   }
 
   /**
-   * Adds items to the group colour sub-menu
+   * Builds the group colour sub-menu, including any user-defined colours which
+   * were loaded at startup or during the Jalview session
    */
   protected void buildColourMenu()
   {
     SequenceGroup sg = getGroup();
     colourMenu.removeAll();
     colourMenu.add(textColour);
+    colourMenu.addSeparator();
     colourMenu.add(noColourmenuItem);
     colourMenu.add(clustalColour);
     // in Java 8, isApplicableTo can be a static method on the interface
@@ -1556,13 +1523,24 @@ public class PopupMenu extends JPopupMenu
     tcoffeeColour
             .setEnabled(new TCoffeeColourScheme(sg).isApplicableTo(sg));
 
+    /*
+     * add some of these items to a ButtonGroup so their
+     * selection is mutually exclusive
+     */
+    ButtonGroup colours = new ButtonGroup();
+
+    /*
+     * add any user-defined colours loaded on startup or
+     * during the application session
+     */
     SortedMap<String, UserColourScheme> userColourSchemes = UserDefinedColours
             .getUserColourSchemes();
     if (userColourSchemes != null)
     {
       for (String userColour : userColourSchemes.keySet())
-    {
-        JMenuItem item = new JMenuItem(userColour);
+      {
+        JRadioButtonMenuItem item = new JRadioButtonMenuItem(userColour);
+        item.setName(userColour); // button name identifies selected colour
         item.addActionListener(new ActionListener()
         {
           @Override
@@ -1572,6 +1550,7 @@ public class PopupMenu extends JPopupMenu
           }
         });
         colourMenu.add(item);
+        colours.add(item);
       }
     }
     colourMenu.add(userDefinedColour);
@@ -1580,11 +1559,6 @@ public class PopupMenu extends JPopupMenu
     colourMenu.add(conservationMenuItem);
     colourMenu.add(abovePIDColour);
 
-    /*
-     * add some of these items to a ButtonGroup so their
-     * selection is mutually exclusive
-     */
-    ButtonGroup colours = new ButtonGroup();
     colours.add(noColourmenuItem);
     colours.add(clustalColour);
     colours.add(BLOSUM62Colour);
@@ -2436,4 +2410,36 @@ public class PopupMenu extends JPopupMenu
     }
   }
 
+  /**
+   * Marks as selected the colour menu item matching the given name, or the
+   * first item ('None') if no match is found
+   * 
+   * @param cs
+   */
+  protected void setColourSelected(ColourSchemeI cs)
+  {
+    noColourmenuItem.setSelected(true);
+    if (cs == null)
+    {
+      return;
+    }
+  
+    String schemeName = cs.getSchemeName();
+    /*
+     * look for a radio button with a name that matches the colour name
+     * (note the button text may not as it may be internationalised)
+     */
+    for (Component menuItem : colourMenu.getMenuComponents())
+    {
+      if (menuItem instanceof JRadioButtonMenuItem)
+      {
+        if (schemeName.equals(((JRadioButtonMenuItem) menuItem).getName()))
+        {
+          ((JRadioButtonMenuItem) menuItem).setSelected(true);
+          return;
+        }
+      }
+    }
+  }
+
 }
index 64e0e15..5cfff86 100755 (executable)
@@ -895,7 +895,7 @@ public class UserDefinedColours extends GUserDefinedColours implements
      */
     if (ap != null)
     {
-      ap.alignFrame.buildColourMenu();// updateUserColourMenu();
+      ap.alignFrame.buildColourMenu();
     }
   }
 
@@ -948,10 +948,11 @@ public class UserDefinedColours extends GUserDefinedColours implements
       {
         seqGroup.cs = oldColourScheme;
       }
-      else if (ap != null)
+      else
       {
         ap.av.setGlobalColourScheme(oldColourScheme);
       }
+      ap.alignFrame.changeColour(oldColourScheme);
       ap.paintAlignment(true);
     }
 
index b38fab4..fba0efa 100755 (executable)
@@ -37,6 +37,7 @@ import jalview.util.Platform;
 
 import java.awt.BorderLayout;
 import java.awt.Color;
+import java.awt.Component;
 import java.awt.GridLayout;
 import java.awt.Toolkit;
 import java.awt.event.ActionEvent;
@@ -67,8 +68,6 @@ import javax.swing.event.MenuListener;
 
 public class GAlignFrame extends JInternalFrame
 {
-  protected static final String USER_DEFINED_COLOUR_SCHEME = "USER_DEFINED";
-
   protected JMenuBar alignFrameMenuBar = new JMenuBar();
 
   protected JMenuItem closeMenuItem = new JMenuItem();
@@ -290,69 +289,35 @@ public class GAlignFrame extends JInternalFrame
     }
   }
 
-  public void setColourSelected(String defaultColour)
+  /**
+   * Marks as selected the colour menu item matching the given name, or the
+   * first item ('None') if no match is found
+   * 
+   * @param colourName
+   */
+  protected void setColourSelected(String colourName)
   {
-    JalviewColourScheme scheme = JalviewColourScheme.forName(defaultColour);
-    if (scheme == null)
+    noColourmenuItem.setSelected(true);
+    if (colourName == null)
     {
-      noColourmenuItem.setSelected(true);
       return;
     }
-    switch (scheme)
-    {
-
-    case Clustal:
-        clustalColour.setSelected(true);
-        break;
-    case Blosum62:
-        BLOSUM62Colour.setSelected(true);
-        break;
-    case PID:
-        PIDColour.setSelected(true);
-        break;
-    case Zappo:
-        zappoColour.setSelected(true);
-        break;
-    case Taylor:
-        taylorColour.setSelected(true);
-        break;
-    case Hydrophobic:
-        hydrophobicityColour.setSelected(true);
-        break;
-    case Helix:
-        helixColour.setSelected(true);
-        break;
-    case Strand:
-        strandColour.setSelected(true);
-        break;
-    case Turn:
-        turnColour.setSelected(true);
-        break;
-    case Buried:
-        buriedColour.setSelected(true);
-        break;
-    case Nucleotide:
-        nucleotideColour.setSelected(true);
-        break;
-    case TCoffee:
-        tcoffeeColour.setSelected(true);
-        break;
-    case PurinePyrimidine:
-        purinePyrimidineColour.setSelected(true);
-        break;
-    // case RNAInteraction:
-    // RNAInteractionColour.setSelected(true);
-    // break;
-    case RNAHelices:
-      rnahelicesColour.setSelected(true);
-      break;
-    case UserDefined:
-        userDefinedColour.setSelected(true);
-        break;
-      default:
-        noColourmenuItem.setSelected(true);
-        break;
+
+    /*
+     * look for a radio button with a name that matches the colour name
+     * (note the button text may not as it may be internationalised)
+     */
+    for (Component menuItem : colourMenu.getMenuComponents())
+    {
+      if (menuItem instanceof JRadioButtonMenuItem)
+      {
+        if (colourName.equals(((JRadioButtonMenuItem) menuItem).getName()))
+        {
+          ((JRadioButtonMenuItem) menuItem).setSelected(true);
+          return;
+        }
       }
+    }
   }
 
   private void jbInit() throws Exception
@@ -2056,7 +2021,7 @@ public class GAlignFrame extends JInternalFrame
       {
         final JRadioButtonMenuItem radioItem = new JRadioButtonMenuItem(
                 userColour);
-        radioItem.setName(USER_DEFINED_COLOUR_SCHEME);
+        radioItem.setName(userColour);
         radioItem.addMouseListener(new MouseAdapter()
         {
           @Override
@@ -2148,7 +2113,7 @@ public class GAlignFrame extends JInternalFrame
     colours.add(purinePyrimidineColour);
     // colours.add(covariationColour);
     colours.add(tcoffeeColour);
-    colours.add(RNAInteractionColour);
+    // colours.add(RNAInteractionColour);
     setColourSelected(Cache.getDefault(Preferences.DEFAULT_COLOUR,
             ResidueColourScheme.NONE));
 
@@ -2156,7 +2121,9 @@ public class GAlignFrame extends JInternalFrame
 
   /**
    * Constructs the entries on the Colour menu (but does not add them to the
-   * menu)
+   * menu). The 'name' property of each item is set to the canonical name of the
+   * corresponding colour scheme (may not match the display name), to allow
+   * selection of items by colour scheme name.
    */
   protected void initColourMenu()
   {
@@ -2183,6 +2150,7 @@ public class GAlignFrame extends JInternalFrame
     });
     clustalColour = new JRadioButtonMenuItem(
             MessageManager.getString("label.clustalx"));
+    clustalColour.setName(JalviewColourScheme.Clustal.toString());
     clustalColour.addActionListener(new ActionListener()
     {
       @Override
@@ -2193,6 +2161,7 @@ public class GAlignFrame extends JInternalFrame
     });
     zappoColour = new JRadioButtonMenuItem(
             MessageManager.getString("label.zappo"));
+    zappoColour.setName(JalviewColourScheme.Zappo.toString());
     zappoColour.addActionListener(new ActionListener()
     {
       @Override
@@ -2203,6 +2172,7 @@ public class GAlignFrame extends JInternalFrame
     });
     taylorColour = new JRadioButtonMenuItem(
             MessageManager.getString("label.taylor"));
+    taylorColour.setName(JalviewColourScheme.Taylor.toString());
     taylorColour.addActionListener(new ActionListener()
     {
       @Override
@@ -2214,6 +2184,8 @@ public class GAlignFrame extends JInternalFrame
     hydrophobicityColour = new JRadioButtonMenuItem(
             MessageManager
             .getString("label.hydrophobicity"));
+    hydrophobicityColour
+            .setName(JalviewColourScheme.Hydrophobic.toString());
     hydrophobicityColour.addActionListener(new ActionListener()
     {
       @Override
@@ -2224,6 +2196,7 @@ public class GAlignFrame extends JInternalFrame
     });
     helixColour = new JRadioButtonMenuItem(
             MessageManager.getString("label.helix_propensity"));
+    helixColour.setName(JalviewColourScheme.Helix.toString());
     helixColour.addActionListener(new ActionListener()
     {
       @Override
@@ -2235,6 +2208,7 @@ public class GAlignFrame extends JInternalFrame
     strandColour = new JRadioButtonMenuItem(
             MessageManager
             .getString("label.strand_propensity"));
+    strandColour.setName(JalviewColourScheme.Strand.toString());
     strandColour.addActionListener(new ActionListener()
     {
       @Override
@@ -2245,6 +2219,7 @@ public class GAlignFrame extends JInternalFrame
     });
     turnColour = new JRadioButtonMenuItem(
             MessageManager.getString("label.turn_propensity"));
+    turnColour.setName(JalviewColourScheme.Turn.toString());
     turnColour.addActionListener(new ActionListener()
     {
       @Override
@@ -2255,6 +2230,7 @@ public class GAlignFrame extends JInternalFrame
     });
     buriedColour = new JRadioButtonMenuItem(
             MessageManager.getString("label.buried_index"));
+    buriedColour.setName(JalviewColourScheme.Buried.toString());
     buriedColour.addActionListener(new ActionListener()
     {
       @Override
@@ -2266,6 +2242,7 @@ public class GAlignFrame extends JInternalFrame
     userDefinedColour = new JRadioButtonMenuItem(
             MessageManager
             .getString("action.user_defined"));
+    userDefinedColour.setName(JalviewColourScheme.UserDefined.toString());
     userDefinedColour.addActionListener(new ActionListener()
     {
       @Override
@@ -2276,6 +2253,7 @@ public class GAlignFrame extends JInternalFrame
     });
     PIDColour = new JRadioButtonMenuItem(
             MessageManager.getString("label.percentage_identity"));
+    PIDColour.setName(JalviewColourScheme.PID.toString());
     PIDColour.addActionListener(new ActionListener()
     {
       @Override
@@ -2286,6 +2264,7 @@ public class GAlignFrame extends JInternalFrame
     });
     BLOSUM62Colour = new JRadioButtonMenuItem(
             MessageManager.getString("label.blosum62_score"));
+    BLOSUM62Colour.setName(JalviewColourScheme.Blosum62.toString());
     BLOSUM62Colour.addActionListener(new ActionListener()
     {
       @Override
@@ -2296,6 +2275,7 @@ public class GAlignFrame extends JInternalFrame
     });
     nucleotideColour = new JRadioButtonMenuItem(
             MessageManager.getString("label.nucleotide"));
+    nucleotideColour.setName(JalviewColourScheme.Nucleotide.toString());
     nucleotideColour.addActionListener(new ActionListener()
     {
       @Override
@@ -2306,6 +2286,7 @@ public class GAlignFrame extends JInternalFrame
     });
     purinePyrimidineColour = new JRadioButtonMenuItem(
             MessageManager.getString("label.purine_pyrimidine"));
+    purinePyrimidineColour.setName(JalviewColourScheme.PurinePyrimidine.toString());
     purinePyrimidineColour.addActionListener(new ActionListener()
     {
       @Override
@@ -2317,6 +2298,7 @@ public class GAlignFrame extends JInternalFrame
 
     tcoffeeColour = new JRadioButtonMenuItem(
             MessageManager.getString("label.tcoffee_scores"));
+    tcoffeeColour.setName(JalviewColourScheme.TCoffee.toString());
     tcoffeeColour.setEnabled(false);
     tcoffeeColour.addActionListener(new ActionListener()
     {
@@ -2328,15 +2310,16 @@ public class GAlignFrame extends JInternalFrame
       }
     });
 
-    RNAInteractionColour = new JRadioButtonMenuItem("RNA Interaction type");
-    RNAInteractionColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        RNAInteractionColour_actionPerformed();
-      }
-    });
+    // RNAInteractionColour = new JRadioButtonMenuItem("RNA Interaction type");
+    // RNAInteractionColour.setName("RNA Interaction");
+    // RNAInteractionColour.addActionListener(new ActionListener()
+    // {
+    // @Override
+    // public void actionPerformed(ActionEvent e)
+    // {
+    // RNAInteractionColour_actionPerformed();
+    // }
+    // });
     /*
      * covariationColour = new JRadioButtonMenuItem("Covariation");
      * covariationColour.addActionListener(new ActionListener() { public void
@@ -2356,6 +2339,7 @@ public class GAlignFrame extends JInternalFrame
     });
     noColourmenuItem = new JRadioButtonMenuItem(
             MessageManager.getString("label.none"));
+    noColourmenuItem.setName("None");
     noColourmenuItem.addActionListener(new ActionListener()
     {
       @Override