JAL-2361 extract methods to (re-)build colour menu
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 12 Dec 2016 22:09:57 +0000 (22:09 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 12 Dec 2016 22:09:57 +0000 (22:09 +0000)
src/jalview/appletgui/APopupMenu.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/AppJmol.java
src/jalview/gui/PopupMenu.java
src/jalview/gui/UserDefinedColours.java
src/jalview/jbgui/GAlignFrame.java
src/jalview/jbgui/GStructureViewer.java
src/jalview/jbgui/GUserDefinedColours.java
test/jalview/io/Jalview2xmlTests.java

index 015734f..9080cdd 100644 (file)
@@ -66,6 +66,7 @@ import java.util.Collections;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.SortedMap;
 import java.util.TreeMap;
 import java.util.Vector;
 
@@ -412,7 +413,7 @@ public class APopupMenu extends java.awt.PopupMenu implements
      * Temporary store to hold distinct calcId / type pairs for the tooltip.
      * Using TreeMap means calcIds are shown in alphabetical order.
      */
-    Map<String, String> tipEntries = new TreeMap<String, String>();
+    SortedMap<String, String> tipEntries = new TreeMap<String, String>();
     final Map<SequenceI, List<AlignmentAnnotation>> candidates = new LinkedHashMap<SequenceI, List<AlignmentAnnotation>>();
     AlignmentI al = this.ap.av.getAlignment();
     AlignmentUtils.findAddableReferenceAnnotations(forSequences,
@@ -955,8 +956,7 @@ public class APopupMenu extends java.awt.PopupMenu implements
     noColourmenuItem.setLabel(MessageManager.getString("label.none"));
     noColourmenuItem.addActionListener(this);
 
-    clustalColour.setLabel(MessageManager
-            .getString("label.clustalx_colours"));
+    clustalColour.setLabel(MessageManager.getString("label.clustalx"));
     clustalColour.addActionListener(this);
     zappoColour.setLabel(MessageManager.getString("label.zappo"));
     zappoColour.addActionListener(this);
index df2a742..03e4534 100644 (file)
@@ -125,7 +125,6 @@ import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
 import java.awt.event.KeyAdapter;
 import java.awt.event.KeyEvent;
-import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
 import java.awt.print.PageFormat;
 import java.awt.print.PrinterJob;
@@ -146,7 +145,6 @@ import javax.swing.JInternalFrame;
 import javax.swing.JLayeredPane;
 import javax.swing.JMenu;
 import javax.swing.JMenuItem;
-import javax.swing.JRadioButtonMenuItem;
 import javax.swing.JScrollPane;
 import javax.swing.SwingUtilities;
 
@@ -856,6 +854,14 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     conservationMenuItem.setEnabled(!nucleotide);
     modifyConservation.setEnabled(!nucleotide);
     showGroupConservation.setEnabled(!nucleotide);
+    clustalColour.setEnabled(!nucleotide);
+    zappoColour.setEnabled(!nucleotide);
+    taylorColour.setEnabled(!nucleotide);
+    hydrophobicityColour.setEnabled(!nucleotide);
+    helixColour.setEnabled(!nucleotide);
+    strandColour.setEnabled(!nucleotide);
+    turnColour.setEnabled(!nucleotide);
+    buriedColour.setEnabled(!nucleotide);
     rnahelicesColour.setEnabled(nucleotide);
     nucleotideColour.setEnabled(nucleotide);
     purinePyrimidineColour.setEnabled(nucleotide);
@@ -863,9 +869,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     showComplementMenuItem.setText(nucleotide ? MessageManager
             .getString("label.protein") : MessageManager
             .getString("label.nucleotide"));
-    setColourSelected(jalview.bin.Cache.getDefault(
+    String selectedColourScheme = Cache.getDefault(
             nucleotide ? Preferences.DEFAULT_COLOUR_NUC
-                    : Preferences.DEFAULT_COLOUR_PROT, "None"));
+                    : Preferences.DEFAULT_COLOUR_PROT, "None");
+    setColourSelected(selectedColourScheme);
   }
 
   /**
@@ -3300,7 +3307,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   }
 
   @Override
-  public void textColour_actionPerformed(ActionEvent e)
+  public void textColour_actionPerformed()
   {
     new TextColourChooser().chooseColour(alignPanel, null);
   }
@@ -3312,7 +3319,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  protected void noColourmenuItem_actionPerformed(ActionEvent e)
+  protected void noColourmenuItem_actionPerformed()
   {
     changeColour(null);
   }
@@ -3324,7 +3331,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  public void clustalColour_actionPerformed(ActionEvent e)
+  public void clustalColour_actionPerformed()
   {
     changeColour(new ClustalxColourScheme(viewport.getAlignment(),
             viewport.getHiddenRepSequences()));
@@ -3337,7 +3344,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  public void zappoColour_actionPerformed(ActionEvent e)
+  public void zappoColour_actionPerformed()
   {
     changeColour(new ZappoColourScheme());
   }
@@ -3349,7 +3356,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  public void taylorColour_actionPerformed(ActionEvent e)
+  public void taylorColour_actionPerformed()
   {
     changeColour(new TaylorColourScheme());
   }
@@ -3361,7 +3368,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  public void hydrophobicityColour_actionPerformed(ActionEvent e)
+  public void hydrophobicityColour_actionPerformed()
   {
     changeColour(new HydrophobicColourScheme());
   }
@@ -3373,7 +3380,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  public void helixColour_actionPerformed(ActionEvent e)
+  public void helixColour_actionPerformed()
   {
     changeColour(new HelixColourScheme());
   }
@@ -3385,7 +3392,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  public void strandColour_actionPerformed(ActionEvent e)
+  public void strandColour_actionPerformed()
   {
     changeColour(new StrandColourScheme());
   }
@@ -3397,7 +3404,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  public void turnColour_actionPerformed(ActionEvent e)
+  public void turnColour_actionPerformed()
   {
     changeColour(new TurnColourScheme());
   }
@@ -3409,7 +3416,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  public void buriedColour_actionPerformed(ActionEvent e)
+  public void buriedColour_actionPerformed()
   {
     changeColour(new BuriedColourScheme());
   }
@@ -3421,25 +3428,25 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  public void nucleotideColour_actionPerformed(ActionEvent e)
+  public void nucleotideColour_actionPerformed()
   {
     changeColour(new NucleotideColourScheme());
   }
 
   @Override
-  public void purinePyrimidineColour_actionPerformed(ActionEvent e)
+  public void purinePyrimidineColour_actionPerformed()
   {
     changeColour(new PurinePyrimidineColourScheme());
   }
 
   /*
-   * public void covariationColour_actionPerformed(ActionEvent e) {
+   * public void covariationColour_actionPerformed() {
    * changeColour(new
    * CovariationColourScheme(viewport.getAlignment().getAlignmentAnnotation
    * ()[0])); }
    */
   @Override
-  public void annotationColour_actionPerformed(ActionEvent e)
+  public void annotationColour_actionPerformed()
   {
     new AnnotationColourChooser(viewport, alignPanel);
   }
@@ -3451,7 +3458,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   }
 
   @Override
-  public void rnahelicesColour_actionPerformed(ActionEvent e)
+  public void rnahelicesColour_actionPerformed()
   {
     new RNAHelicesColourChooser(viewport, alignPanel);
   }
@@ -3459,11 +3466,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   /**
    * DOCUMENT ME!
    * 
-   * @param e
-   *          DOCUMENT ME!
    */
   @Override
-  protected void applyToAllGroups_actionPerformed(ActionEvent e)
+  protected void applyToAllGroups_actionPerformed()
   {
     viewport.setColourAppliesToAllGroups(applyToAllGroups.isSelected());
   }
@@ -3513,7 +3518,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  protected void modifyPID_actionPerformed(ActionEvent e)
+  protected void modifyPID_actionPerformed()
   {
     if (viewport.getAbovePIDThreshold()
             && viewport.getGlobalColourScheme() != null)
@@ -3531,7 +3536,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  protected void modifyConservation_actionPerformed(ActionEvent e)
+  protected void modifyConservation_actionPerformed()
   {
     if (viewport.getConservationSelected()
             && viewport.getGlobalColourScheme() != null)
@@ -3549,7 +3554,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  protected void conservationMenuItem_actionPerformed(ActionEvent e)
+  protected void conservationMenuItem_actionPerformed()
   {
     viewport.setConservationSelected(conservationMenuItem.isSelected());
 
@@ -3558,7 +3563,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
 
     changeColour(viewport.getGlobalColourScheme());
 
-    modifyConservation_actionPerformed(null);
+    modifyConservation_actionPerformed();
   }
 
   /**
@@ -3568,7 +3573,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  public void abovePIDThreshold_actionPerformed(ActionEvent e)
+  public void abovePIDThreshold_actionPerformed()
   {
     viewport.setAbovePIDThreshold(abovePIDThreshold.isSelected());
 
@@ -3577,7 +3582,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
 
     changeColour(viewport.getGlobalColourScheme());
 
-    modifyPID_actionPerformed(null);
+    modifyPID_actionPerformed();
   }
 
   /**
@@ -3596,104 +3601,13 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     }
     else
     {
-      UserColourScheme udc = (UserColourScheme) UserDefinedColours
+      UserColourScheme udc = UserDefinedColours
               .getUserColourSchemes().get(e.getActionCommand());
 
       changeColour(udc);
     }
   }
 
-  public void updateUserColourMenu()
-  {
-
-    Component[] menuItems = colourMenu.getMenuComponents();
-    int iSize = menuItems.length;
-    for (int i = 0; i < iSize; i++)
-    {
-      if (menuItems[i].getName() != null
-              && menuItems[i].getName().equals("USER_DEFINED"))
-      {
-        colourMenu.remove(menuItems[i]);
-        iSize--;
-      }
-    }
-    if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null)
-    {
-      java.util.Enumeration userColours = jalview.gui.UserDefinedColours
-              .getUserColourSchemes().keys();
-
-      while (userColours.hasMoreElements())
-      {
-        final JRadioButtonMenuItem radioItem = new JRadioButtonMenuItem(
-                userColours.nextElement().toString());
-        radioItem.setName("USER_DEFINED");
-        radioItem.addMouseListener(new MouseAdapter()
-        {
-          @Override
-          public void mousePressed(MouseEvent evt)
-          {
-            if (evt.isPopupTrigger()) // Mac
-            {
-              offerRemoval(radioItem);
-            }
-          }
-
-          @Override
-          public void mouseReleased(MouseEvent evt)
-          {
-            if (evt.isPopupTrigger()) // Windows
-            {
-              offerRemoval(radioItem);
-            }
-          }
-
-          /**
-           * @param radioItem
-           */
-          void offerRemoval(final JRadioButtonMenuItem radioItem)
-          {
-            radioItem.removeActionListener(radioItem.getActionListeners()[0]);
-
-            int option = JvOptionPane.showInternalConfirmDialog(
-                    jalview.gui.Desktop.desktop, MessageManager
-                            .getString("label.remove_from_default_list"),
-                    MessageManager
-                            .getString("label.remove_user_defined_colour"),
-                    JvOptionPane.YES_NO_OPTION);
-            if (option == JvOptionPane.YES_OPTION)
-            {
-              jalview.gui.UserDefinedColours
-                      .removeColourFromDefaults(radioItem.getText());
-              colourMenu.remove(radioItem);
-            }
-            else
-            {
-              radioItem.addActionListener(new ActionListener()
-              {
-                @Override
-                public void actionPerformed(ActionEvent evt)
-                {
-                  userDefinedColour_actionPerformed(evt);
-                }
-              });
-            }
-          }
-        });
-        radioItem.addActionListener(new ActionListener()
-        {
-          @Override
-          public void actionPerformed(ActionEvent evt)
-          {
-            userDefinedColour_actionPerformed(evt);
-          }
-        });
-
-        colourMenu.insert(radioItem, 15);
-        colours.add(radioItem);
-      }
-    }
-  }
-
   /**
    * DOCUMENT ME!
    * 
@@ -3701,7 +3615,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  public void PIDColour_actionPerformed(ActionEvent e)
+  public void PIDColour_actionPerformed()
   {
     changeColour(new PIDColourScheme());
   }
@@ -3713,7 +3627,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  public void BLOSUM62Colour_actionPerformed(ActionEvent e)
+  public void BLOSUM62Colour_actionPerformed()
   {
     changeColour(new Blosum62ColourScheme());
   }
@@ -4353,7 +4267,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   }
 
   @Override
-  protected void tcoffeeColorScheme_actionPerformed(ActionEvent e)
+  protected void tcoffeeColorScheme_actionPerformed()
   {
     changeColour(new TCoffeeColourScheme(alignPanel.getAlignment()));
   }
@@ -5838,7 +5752,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     }
     AlignmentI cdna = new Alignment(cdnaSeqs.toArray(new SequenceI[cdnaSeqs
             .size()]));
-    AlignFrame alignFrame = new AlignFrame(cdna, AlignFrame.DEFAULT_WIDTH,
+    GAlignFrame alignFrame = new AlignFrame(cdna, AlignFrame.DEFAULT_WIDTH,
             AlignFrame.DEFAULT_HEIGHT);
     cdna.alignAs(alignment);
     String newtitle = "cDNA " + MessageManager.getString("label.for") + " "
index e2e54aa..aaa2397 100644 (file)
@@ -37,6 +37,7 @@ import jalview.schemes.PurinePyrimidineColourScheme;
 import jalview.schemes.StrandColourScheme;
 import jalview.schemes.TaylorColourScheme;
 import jalview.schemes.TurnColourScheme;
+import jalview.schemes.UserColourScheme;
 import jalview.schemes.ZappoColourScheme;
 import jalview.structures.models.AAStructureBindingModel;
 import jalview.util.MessageManager;
@@ -66,7 +67,6 @@ import javax.swing.JCheckBoxMenuItem;
 import javax.swing.JColorChooser;
 import javax.swing.JInternalFrame;
 import javax.swing.JMenu;
-import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 import javax.swing.JSplitPane;
 import javax.swing.SwingUtilities;
@@ -905,19 +905,32 @@ public class AppJmol extends StructureViewerBase
     setJalviewColourScheme(new PurinePyrimidineColourScheme());
   }
 
+  /**
+   * Action on either selecting a user-defined colour, or 'User Defined...'
+   */
   @Override
-  public void userColour_actionPerformed(ActionEvent actionEvent)
+  public void userColour_actionPerformed(ActionEvent e)
   {
-    userColour.setSelected(true);
-    new UserDefinedColours(this, null);
+    if (e.getActionCommand().equals(
+            MessageManager.getString("action.user_defined")))
+    {
+      userColour.setSelected(true);
+      new UserDefinedColours(this, null);
+    }
+    else
+    {
+      UserColourScheme udc = UserDefinedColours.getUserColourSchemes().get(
+              e.getActionCommand());
+      jmb.setJalviewColourScheme(udc);
+    }
   }
 
   @Override
   public void backGround_actionPerformed(ActionEvent actionEvent)
   {
-    java.awt.Color col = JColorChooser
-            .showDialog(this, MessageManager
-                    .getString("label.select_backgroud_colour"), null);
+    Color col = JColorChooser.showDialog(this,
+            MessageManager.getString("label.select_background_colour"),
+            null);
     if (col != null)
     {
       jmb.setBackgroundColour(col);
index e1b2560..0166e75 100644 (file)
@@ -71,6 +71,7 @@ import java.util.Hashtable;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.SortedMap;
 import java.util.TreeMap;
 import java.util.Vector;
 
@@ -79,7 +80,6 @@ import javax.swing.JCheckBoxMenuItem;
 import javax.swing.JColorChooser;
 import javax.swing.JMenu;
 import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
 import javax.swing.JPopupMenu;
 import javax.swing.JRadioButtonMenuItem;
 
@@ -1353,19 +1353,16 @@ public class PopupMenu extends JPopupMenu
     colourMenu.add(nucleotideMenuItem);
     if (ap.getAlignment().isNucleotide())
     {
-      // JBPNote - commented since the colourscheme isn't functional
       colourMenu.add(purinePyrimidineColour);
     }
-    colourMenu.add(userDefinedColour);
 
-    if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null)
+    SortedMap<String, UserColourScheme> userColourSchemes = UserDefinedColours
+            .getUserColourSchemes();
+    if (userColourSchemes != null)
     {
-      java.util.Enumeration userColours = jalview.gui.UserDefinedColours
-              .getUserColourSchemes().keys();
-
-      while (userColours.hasMoreElements())
-      {
-        JMenuItem item = new JMenuItem(userColours.nextElement().toString());
+      for (String userColour : userColourSchemes.keySet())
+    {
+        JMenuItem item = new JMenuItem(userColour);
         item.addActionListener(new ActionListener()
         {
           @Override
@@ -1377,6 +1374,7 @@ public class PopupMenu extends JPopupMenu
         colourMenu.add(item);
       }
     }
+    colourMenu.add(userDefinedColour);
 
     colourMenu.addSeparator();
     colourMenu.add(abovePIDColour);
@@ -1408,8 +1406,7 @@ public class PopupMenu extends JPopupMenu
       }
     });
 
-    clustalColour.setText(MessageManager
-            .getString("label.clustalx_colours"));
+    clustalColour.setText(MessageManager.getString("label.clustalx"));
     clustalColour.addActionListener(new java.awt.event.ActionListener()
     {
       @Override
@@ -1514,7 +1511,8 @@ public class PopupMenu extends JPopupMenu
         PIDColour_actionPerformed();
       }
     });
-    BLOSUM62Colour.setText(MessageManager.getString("label.blosum62"));
+    BLOSUM62Colour
+            .setText(MessageManager.getString("label.blosum62_score"));
     BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener()
     {
       @Override
@@ -1576,7 +1574,7 @@ public class PopupMenu extends JPopupMenu
      * Temporary store to hold distinct calcId / type pairs for the tooltip.
      * Using TreeMap means calcIds are shown in alphabetical order.
      */
-    Map<String, String> tipEntries = new TreeMap<String, String>();
+    SortedMap<String, String> tipEntries = new TreeMap<String, String>();
     final Map<SequenceI, List<AlignmentAnnotation>> candidates = new LinkedHashMap<SequenceI, List<AlignmentAnnotation>>();
     AlignmentI al = this.ap.av.getAlignment();
     AlignmentUtils.findAddableReferenceAnnotations(forSequences,
@@ -1896,7 +1894,7 @@ public class PopupMenu extends JPopupMenu
     }
     else
     {
-      UserColourScheme udc = (UserColourScheme) UserDefinedColours
+      UserColourScheme udc = UserDefinedColours
               .getUserColourSchemes().get(e.getActionCommand());
 
       sg.cs = udc;
index 0df23e0..3b6ebfa 100755 (executable)
@@ -26,15 +26,20 @@ import jalview.datamodel.SequenceGroup;
 import jalview.io.JalviewFileChooser;
 import jalview.io.JalviewFileView;
 import jalview.jbgui.GUserDefinedColours;
+import jalview.schemabinding.version2.Colour;
+import jalview.schemabinding.version2.JalviewUserColours;
 import jalview.schemes.ColourSchemeI;
 import jalview.schemes.ResidueProperties;
 import jalview.schemes.UserColourScheme;
 import jalview.util.ColorUtils;
+import jalview.util.Format;
 import jalview.util.MessageManager;
 
 import java.awt.Color;
 import java.awt.Font;
+import java.awt.Insets;
 import java.awt.event.ActionEvent;
+import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
 import java.io.File;
 import java.io.FileInputStream;
@@ -43,8 +48,10 @@ import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.util.ArrayList;
-import java.util.Hashtable;
+import java.util.List;
+import java.util.SortedMap;
 import java.util.StringTokenizer;
+import java.util.TreeMap;
 
 import javax.swing.JButton;
 import javax.swing.JInternalFrame;
@@ -61,35 +68,41 @@ import javax.swing.event.ChangeListener;
 public class UserDefinedColours extends GUserDefinedColours implements
         ChangeListener
 {
+  private static final Font VERDANA_BOLD_10 = new Font("Verdana", Font.BOLD, 10);
+
+  private static final String USER_DEFINED_COLOURS = "USER_DEFINED_COLOURS";
+
+  private static final String LAST_DIRECTORY = "LAST_DIRECTORY";
+
   private static final int MY_FRAME_HEIGHT = 420;
 
   private static final int MY_FRAME_WIDTH = 810;
 
   private static final int MY_FRAME_WIDTH_CASE_SENSITIVE = 970;
 
+  static SortedMap<String, UserColourScheme> userColourSchemes;
+
   AlignmentPanel ap;
 
   SequenceGroup seqGroup;
 
-  ArrayList<JButton> selectedButtons;
+  List<JButton> selectedButtons;
 
   ColourSchemeI oldColourScheme;
 
   JInternalFrame frame;
 
-  JalviewStructureDisplayI jmol;
+  JalviewStructureDisplayI structureViewer;
 
-  ArrayList<JButton> upperCaseButtons;
+  List<JButton> upperCaseButtons;
 
-  ArrayList<JButton> lowerCaseButtons;
+  List<JButton> lowerCaseButtons;
 
   /**
    * Creates a new UserDefinedColours object.
    * 
    * @param ap
-   *          DOCUMENT ME!
    * @param sg
-   *          DOCUMENT ME!
    */
   public UserDefinedColours(AlignmentPanel ap, SequenceGroup sg)
   {
@@ -131,11 +144,11 @@ public class UserDefinedColours extends GUserDefinedColours implements
     showFrame();
   }
 
-  public UserDefinedColours(JalviewStructureDisplayI jmol,
+  public UserDefinedColours(JalviewStructureDisplayI viewer,
           ColourSchemeI oldcs)
   {
     super();
-    this.jmol = jmol;
+    this.structureViewer = viewer;
 
     colorChooser.getSelectionModel().addChangeListener(this);
 
@@ -384,28 +397,35 @@ public class UserDefinedColours extends GUserDefinedColours implements
   }
 
   /**
-   * DOCUMENT ME!
+   * A helper method to update or make a colour button, whose background colour
+   * is the associated colour, and text colour a darker shade of the same. If
+   * the button is already in the list, then its text and margins are updated,
+   * if not then it is created and added. This method supports toggling between
+   * case-sensitive and case-insensitive button panels. The case-sensitive
+   * version has abbreviated button text in order to fit in more buttons.
    * 
    * @param label
-   *          DOCUMENT ME!
-   * @param aa
-   *          DOCUMENT ME!
+   * @param residue
+   * @param the
+   *          list of buttons
+   * @param buttonIndex
+   *          the button's position in the list
    */
-  JButton makeButton(String label, String aa,
-          ArrayList<JButton> caseSensitiveButtons, int buttonIndex)
+  JButton makeButton(String label, String residue,
+          List<JButton> buttons, int buttonIndex)
   {
     final JButton button;
     Color col;
 
-    if (buttonIndex < caseSensitiveButtons.size())
+    if (buttonIndex < buttons.size())
     {
-      button = caseSensitiveButtons.get(buttonIndex);
+      button = buttons.get(buttonIndex);
       col = button.getBackground();
     }
     else
     {
       button = new JButton();
-      button.addMouseListener(new java.awt.event.MouseAdapter()
+      button.addMouseListener(new MouseAdapter()
       {
         @Override
         public void mouseClicked(MouseEvent e)
@@ -414,14 +434,14 @@ public class UserDefinedColours extends GUserDefinedColours implements
         }
       });
 
-      caseSensitiveButtons.add(button);
+      buttons.add(button);
 
       col = Color.white;
       if (oldColourScheme != null)
       {
         try
         {
-          col = oldColourScheme.findColour(aa.charAt(0), -1, null);
+          col = oldColourScheme.findColour(residue.charAt(0), -1, null);
         } catch (Exception ex)
         {
         }
@@ -430,30 +450,29 @@ public class UserDefinedColours extends GUserDefinedColours implements
 
     if (caseSensitive.isSelected())
     {
-      button.setMargin(new java.awt.Insets(2, 2, 2, 2));
+      button.setMargin(new Insets(2, 2, 2, 2));
     }
     else
     {
-      button.setMargin(new java.awt.Insets(2, 14, 2, 14));
+      button.setMargin(new Insets(2, 14, 2, 14));
     }
 
     button.setOpaque(true); // required for the next line to have effect
     button.setBackground(col);
     button.setText(label);
     button.setForeground(ColorUtils.darkerThan(col));
-    button.setFont(new java.awt.Font("Verdana", Font.BOLD, 10));
+    button.setFont(VERDANA_BOLD_10);
 
     return button;
   }
 
   /**
-   * DOCUMENT ME!
-   * 
-   * @param e
-   *          DOCUMENT ME!
+   * On 'OK', check that at least one colour has been assigned to a residue (and
+   * if not issue a warning), and apply the chosen colour scheme and close the
+   * panel.
    */
   @Override
-  protected void okButton_actionPerformed(ActionEvent e)
+  protected void okButton_actionPerformed()
   {
     if (isNoSelectionMade())
     {
@@ -464,7 +483,7 @@ public class UserDefinedColours extends GUserDefinedColours implements
     }
     else
     {
-      applyButton_actionPerformed(null);
+      applyButton_actionPerformed();
 
       try
       {
@@ -493,13 +512,11 @@ public class UserDefinedColours extends GUserDefinedColours implements
   }
 
   /**
-   * DOCUMENT ME!
-   * 
-   * @param e
-   *          DOCUMENT ME!
+   * Applies the current colour scheme to the alignment, sequence group or
+   * structure view.
    */
   @Override
-  protected void applyButton_actionPerformed(ActionEvent e)
+  protected void applyButton_actionPerformed()
   {
     if (isNoSelectionMade())
     {
@@ -521,9 +538,9 @@ public class UserDefinedColours extends GUserDefinedColours implements
     {
       ap.alignFrame.changeColour(ucs);
     }
-    else if (jmol != null)
+    else if (structureViewer != null)
     {
-      jmol.setJalviewColourScheme(ucs);
+      structureViewer.setJalviewColourScheme(ucs);
     }
   }
 
@@ -598,8 +615,7 @@ public class UserDefinedColours extends GUserDefinedColours implements
     lowerCaseButtons = new ArrayList<JButton>();
 
     JalviewFileChooser chooser = new JalviewFileChooser(
-            Cache.getProperty("LAST_DIRECTORY"), "jc",
-            "Jalview User Colours");
+            Cache.getProperty(LAST_DIRECTORY), "jc", "Jalview User Colours");
     chooser.setFileView(new JalviewFileView());
     chooser.setDialogTitle(MessageManager
             .getString("label.load_colour_scheme"));
@@ -607,50 +623,42 @@ public class UserDefinedColours extends GUserDefinedColours implements
 
     int value = chooser.showOpenDialog(this);
 
-    if (value == JalviewFileChooser.APPROVE_OPTION)
+    if (value != JalviewFileChooser.APPROVE_OPTION)
     {
-      File choice = chooser.getSelectedFile();
-      jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice.getParent());
-      String defaultColours = jalview.bin.Cache.getDefault(
-              "USER_DEFINED_COLOURS", choice.getPath());
-      if (defaultColours.indexOf(choice.getPath()) == -1)
-      {
-        defaultColours = defaultColours.concat("|")
-                .concat(choice.getPath());
-      }
-
-      jalview.bin.Cache.setProperty("USER_DEFINED_COLOURS", defaultColours);
-
-      UserColourScheme ucs = loadColours(choice.getAbsolutePath());
-      Color[] colors = ucs.getColours();
-      schemeName.setText(ucs.getName());
-
-      if (ucs.getLowerCaseColours() != null)
-      {
-        caseSensitive.setSelected(true);
-        lcaseColour.setEnabled(true);
-        resetButtonPanel(true);
-        for (int i = 0; i < lowerCaseButtons.size(); i++)
-        {
-          JButton button = lowerCaseButtons.get(i);
-          button.setBackground(ucs.getLowerCaseColours()[i]);
-        }
+      return;
+    }
+    File choice = chooser.getSelectedFile();
+    Cache.setProperty(LAST_DIRECTORY, choice.getParent());
 
-      }
-      else
-      {
-        caseSensitive.setSelected(false);
-        lcaseColour.setEnabled(false);
-        resetButtonPanel(false);
-      }
+    UserColourScheme ucs = loadColours(choice.getAbsolutePath());
+    Color[] colors = ucs.getColours();
+    schemeName.setText(ucs.getName());
 
-      for (int i = 0; i < upperCaseButtons.size(); i++)
+    if (ucs.getLowerCaseColours() != null)
+    {
+      caseSensitive.setSelected(true);
+      lcaseColour.setEnabled(true);
+      resetButtonPanel(true);
+      for (int i = 0; i < lowerCaseButtons.size(); i++)
       {
-        JButton button = upperCaseButtons.get(i);
-        button.setBackground(colors[i]);
+        JButton button = lowerCaseButtons.get(i);
+        button.setBackground(ucs.getLowerCaseColours()[i]);
       }
+    }
+    else
+    {
+      caseSensitive.setSelected(false);
+      lcaseColour.setEnabled(false);
+      resetButtonPanel(false);
+    }
 
+    for (int i = 0; i < upperCaseButtons.size(); i++)
+    {
+      JButton button = upperCaseButtons.get(i);
+      button.setBackground(colors[i]);
     }
+
+    addNewColourScheme(choice.getPath());
   }
 
   /**
@@ -662,7 +670,7 @@ public class UserDefinedColours extends GUserDefinedColours implements
   {
     UserColourScheme ret = null;
 
-    String colours = jalview.bin.Cache.getProperty("USER_DEFINED_COLOURS");
+    String colours = Cache.getProperty(USER_DEFINED_COLOURS);
     if (colours != null)
     {
       if (colours.indexOf("|") > -1)
@@ -833,7 +841,7 @@ public class UserDefinedColours extends GUserDefinedColours implements
       userColourSchemes.remove(schemeName.getText());
     }
     JalviewFileChooser chooser = new JalviewFileChooser(
-            Cache.getProperty("LAST_DIRECTORY"), "jc",
+            Cache.getProperty(LAST_DIRECTORY), "jc",
             "Jalview User Colours");
 
     chooser.setFileView(new JalviewFileView());
@@ -846,47 +854,82 @@ public class UserDefinedColours extends GUserDefinedColours implements
     if (value == JalviewFileChooser.APPROVE_OPTION)
     {
       String choice = chooser.getSelectedFile().getPath();
-      String defaultColours = jalview.bin.Cache.getDefault(
-              "USER_DEFINED_COLOURS", choice);
-      if (defaultColours.indexOf(choice) == -1)
+      addNewColourScheme(choice);
+      saveToFile(choice);
+    }
+  }
+
+  /**
+   * Adds the current colour scheme to the Jalview properties file so it is
+   * loaded on next startup, and updates the Colour menu in the parent
+   * AlignFrame (if there is one). Note this action does not including applying
+   * the colour scheme.
+   * 
+   * @param filePath
+   */
+  protected void addNewColourScheme(String filePath)
+  {
+    /*
+     * update the delimited list of user defined colour files in
+     * Jalview property USER_DEFINED_COLOURS
+     */
+    String defaultColours = Cache
+            .getDefault(USER_DEFINED_COLOURS, filePath);
+    if (defaultColours.indexOf(filePath) == -1)
+    {
+      if (defaultColours.length() > 0)
       {
-        if (defaultColours.length() > 0)
-        {
-          defaultColours = defaultColours.concat("|");
-        }
-        defaultColours = defaultColours.concat(choice);
+        defaultColours = defaultColours.concat("|");
       }
+      defaultColours = defaultColours.concat(filePath);
+    }
+    Cache.setProperty(USER_DEFINED_COLOURS, defaultColours);
 
-      userColourSchemes.put(schemeName.getText(), getSchemeFromButtons());
-
-      ap.alignFrame.updateUserColourMenu();
-
-      jalview.bin.Cache.setProperty("USER_DEFINED_COLOURS", defaultColours);
-
-      jalview.schemabinding.version2.JalviewUserColours ucs = new jalview.schemabinding.version2.JalviewUserColours();
+    /*
+     * add to the cache in this object
+     */
+    userColourSchemes.put(schemeName.getText(), getSchemeFromButtons());
 
-      ucs.setSchemeName(schemeName.getText());
-      try
-      {
-        PrintWriter out = new PrintWriter(new OutputStreamWriter(
-                new FileOutputStream(choice), "UTF-8"));
+    /*
+     * update the Colour menu items
+     */
+    if (ap != null)
+    {
+      ap.alignFrame.buildColourMenu();// updateUserColourMenu();
+    }
+  }
 
-        for (int i = 0; i < buttonPanel.getComponentCount(); i++)
-        {
-          JButton button = (JButton) buttonPanel.getComponent(i);
-          jalview.schemabinding.version2.Colour col = new jalview.schemabinding.version2.Colour();
-          col.setName(button.getText());
-          col.setRGB(jalview.util.Format.getHexString(button
-                  .getBackground()));
-          ucs.addColour(col);
-        }
+  /**
+   * Saves the colour scheme to file in XML format
+   * 
+   * @param filePath
+   */
+  protected void saveToFile(String filePath)
+  {
+    /*
+     * build a Java model of colour scheme as XML, and 
+     * marshal to file
+     */
+    JalviewUserColours ucs = new JalviewUserColours();
+    ucs.setSchemeName(schemeName.getText());
+    try
+    {
+      PrintWriter out = new PrintWriter(new OutputStreamWriter(
+              new FileOutputStream(filePath), "UTF-8"));
 
-        ucs.marshal(out);
-        out.close();
-      } catch (Exception ex)
+      for (int i = 0; i < buttonPanel.getComponentCount(); i++)
       {
-        ex.printStackTrace();
+        JButton button = (JButton) buttonPanel.getComponent(i);
+        Colour col = new Colour();
+        col.setName(button.getText());
+        col.setRGB(Format.getHexString(button.getBackground()));
+        ucs.addColour(col);
       }
+      ucs.marshal(out);
+      out.close();
+    } catch (Exception ex)
+    {
+      ex.printStackTrace();
     }
   }
 
@@ -912,9 +955,9 @@ public class UserDefinedColours extends GUserDefinedColours implements
       ap.paintAlignment(true);
     }
 
-    if (jmol != null)
+    if (structureViewer != null)
     {
-      jmol.setJalviewColourScheme(oldColourScheme);
+      structureViewer.setJalviewColourScheme(oldColourScheme);
     }
 
     try
@@ -925,16 +968,14 @@ public class UserDefinedColours extends GUserDefinedColours implements
     }
   }
 
-  static Hashtable userColourSchemes;
-
-  public static Hashtable getUserColourSchemes()
+  public static SortedMap<String, UserColourScheme> getUserColourSchemes()
   {
     return userColourSchemes;
   }
 
   public static void initUserColourSchemes(String files)
   {
-    userColourSchemes = new Hashtable();
+    userColourSchemes = new TreeMap<String, UserColourScheme>();
 
     if (files == null || files.length() == 0)
     {
@@ -969,13 +1010,11 @@ public class UserDefinedColours extends GUserDefinedColours implements
     {
       if (coloursFound.toString().length() > 1)
       {
-        jalview.bin.Cache.setProperty("USER_DEFINED_COLOURS",
-                coloursFound.toString());
+        Cache.setProperty(USER_DEFINED_COLOURS, coloursFound.toString());
       }
       else
       {
-        jalview.bin.Cache.applicationProperties
-                .remove("USER_DEFINED_COLOURS");
+        Cache.applicationProperties.remove(USER_DEFINED_COLOURS);
       }
     }
   }
@@ -986,11 +1025,11 @@ public class UserDefinedColours extends GUserDefinedColours implements
     // In case colours can't be loaded, we'll remove them
     // from the default list here.
 
-    userColourSchemes = new Hashtable();
+    userColourSchemes = new TreeMap<String, UserColourScheme>();
 
     StringBuffer coloursFound = new StringBuffer();
     StringTokenizer st = new StringTokenizer(
-            jalview.bin.Cache.getProperty("USER_DEFINED_COLOURS"), "|");
+            Cache.getProperty(USER_DEFINED_COLOURS), "|");
 
     while (st.hasMoreElements())
     {
@@ -1015,13 +1054,11 @@ public class UserDefinedColours extends GUserDefinedColours implements
 
     if (coloursFound.toString().length() > 1)
     {
-      jalview.bin.Cache.setProperty("USER_DEFINED_COLOURS",
-              coloursFound.toString());
+      Cache.setProperty(USER_DEFINED_COLOURS, coloursFound.toString());
     }
     else
     {
-      jalview.bin.Cache.applicationProperties
-              .remove("USER_DEFINED_COLOURS");
+      Cache.applicationProperties.remove(USER_DEFINED_COLOURS);
     }
 
   }
index 981da3b..294596c 100755 (executable)
@@ -23,12 +23,16 @@ package jalview.jbgui;
 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
 import jalview.api.SplitContainerI;
 import jalview.bin.Cache;
+import jalview.gui.Desktop;
 import jalview.gui.JvOptionPane;
 import jalview.gui.JvSwingUtils;
 import jalview.gui.Preferences;
+import jalview.gui.UserDefinedColours;
 import jalview.io.FileFormat;
 import jalview.schemes.ColourSchemeProperty;
+import jalview.schemes.UserColourScheme;
 import jalview.util.MessageManager;
+import jalview.util.Platform;
 
 import java.awt.BorderLayout;
 import java.awt.Color;
@@ -62,6 +66,8 @@ 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();
@@ -72,9 +78,9 @@ public class GAlignFrame extends JInternalFrame
 
   protected JMenuItem webServiceNoServices;
 
-  public JCheckBoxMenuItem viewBoxesMenuItem = new JCheckBoxMenuItem();
+  protected JCheckBoxMenuItem viewBoxesMenuItem = new JCheckBoxMenuItem();
 
-  public JCheckBoxMenuItem viewTextMenuItem = new JCheckBoxMenuItem();
+  protected JCheckBoxMenuItem viewTextMenuItem = new JCheckBoxMenuItem();
 
   protected JMenu sortByAnnotScore = new JMenu();
 
@@ -82,58 +88,59 @@ public class GAlignFrame extends JInternalFrame
 
   protected JMenu outputTextboxMenu = new JMenu();
 
-  protected JRadioButtonMenuItem clustalColour = new JRadioButtonMenuItem();
+  protected JRadioButtonMenuItem textColour;
+
+  protected JRadioButtonMenuItem clustalColour;
 
-  protected JRadioButtonMenuItem zappoColour = new JRadioButtonMenuItem();
+  protected JRadioButtonMenuItem zappoColour;
 
-  protected JRadioButtonMenuItem taylorColour = new JRadioButtonMenuItem();
+  protected JRadioButtonMenuItem taylorColour;
 
-  protected JRadioButtonMenuItem hydrophobicityColour = new JRadioButtonMenuItem();
+  protected JRadioButtonMenuItem hydrophobicityColour;
 
-  protected JRadioButtonMenuItem helixColour = new JRadioButtonMenuItem();
+  protected JRadioButtonMenuItem helixColour;
 
-  protected JRadioButtonMenuItem strandColour = new JRadioButtonMenuItem();
+  protected JRadioButtonMenuItem strandColour;
 
-  protected JRadioButtonMenuItem turnColour = new JRadioButtonMenuItem();
+  protected JRadioButtonMenuItem turnColour;
 
-  protected JRadioButtonMenuItem buriedColour = new JRadioButtonMenuItem();
+  protected JRadioButtonMenuItem buriedColour;
 
-  protected JRadioButtonMenuItem userDefinedColour = new JRadioButtonMenuItem();
+  protected JRadioButtonMenuItem userDefinedColour;
 
-  protected JRadioButtonMenuItem PIDColour = new JRadioButtonMenuItem();
+  protected JRadioButtonMenuItem PIDColour;
 
-  protected JRadioButtonMenuItem BLOSUM62Colour = new JRadioButtonMenuItem();
+  protected JRadioButtonMenuItem BLOSUM62Colour;
 
-  protected JRadioButtonMenuItem nucleotideColour = new JRadioButtonMenuItem();
+  protected JRadioButtonMenuItem nucleotideColour;
 
-  protected JRadioButtonMenuItem purinePyrimidineColour = new JRadioButtonMenuItem();
+  protected JRadioButtonMenuItem purinePyrimidineColour;
 
-  protected JRadioButtonMenuItem RNAInteractionColour = new JRadioButtonMenuItem();
+  protected JRadioButtonMenuItem RNAInteractionColour;
 
-  // protected JRadioButtonMenuItem covariationColour = new
-  // JRadioButtonMenuItem();
+  // protected JRadioButtonMenuItem covariationColour;
 
-  protected JRadioButtonMenuItem tcoffeeColour = new JRadioButtonMenuItem();
+  protected JRadioButtonMenuItem tcoffeeColour;
 
-  public JCheckBoxMenuItem annotationPanelMenuItem = new JCheckBoxMenuItem();
+  protected JCheckBoxMenuItem annotationPanelMenuItem = new JCheckBoxMenuItem();
 
-  public JCheckBoxMenuItem colourTextMenuItem = new JCheckBoxMenuItem();
+  protected JCheckBoxMenuItem colourTextMenuItem = new JCheckBoxMenuItem();
 
-  public JCheckBoxMenuItem showNonconservedMenuItem = new JCheckBoxMenuItem();
+  protected JCheckBoxMenuItem showNonconservedMenuItem = new JCheckBoxMenuItem();
 
   protected JMenuItem undoMenuItem = new JMenuItem();
 
   protected JMenuItem redoMenuItem = new JMenuItem();
 
-  public JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem();
+  protected JCheckBoxMenuItem conservationMenuItem;
 
-  JRadioButtonMenuItem noColourmenuItem = new JRadioButtonMenuItem();
+  JRadioButtonMenuItem noColourmenuItem;
 
-  public JCheckBoxMenuItem wrapMenuItem = new JCheckBoxMenuItem();
+  protected JCheckBoxMenuItem wrapMenuItem = new JCheckBoxMenuItem();
 
-  public JCheckBoxMenuItem renderGapsMenuItem = new JCheckBoxMenuItem();
+  protected JCheckBoxMenuItem renderGapsMenuItem = new JCheckBoxMenuItem();
 
-  public JCheckBoxMenuItem abovePIDThreshold = new JCheckBoxMenuItem();
+  protected JCheckBoxMenuItem abovePIDThreshold;
 
   public JCheckBoxMenuItem showSeqFeatures = new JCheckBoxMenuItem();
 
@@ -143,17 +150,21 @@ public class GAlignFrame extends JInternalFrame
 
   JMenu pasteMenu = new JMenu();
 
-  public JCheckBoxMenuItem applyToAllGroups = new JCheckBoxMenuItem();
+  protected JCheckBoxMenuItem applyToAllGroups;
+
+  protected JCheckBoxMenuItem seqLimits = new JCheckBoxMenuItem();
+
+  protected JCheckBoxMenuItem scaleAbove = new JCheckBoxMenuItem();
 
-  public JCheckBoxMenuItem seqLimits = new JCheckBoxMenuItem();
+  protected JCheckBoxMenuItem scaleLeft = new JCheckBoxMenuItem();
 
-  public JCheckBoxMenuItem scaleAbove = new JCheckBoxMenuItem();
+  protected JCheckBoxMenuItem scaleRight = new JCheckBoxMenuItem();
 
-  public JCheckBoxMenuItem scaleLeft = new JCheckBoxMenuItem();
+  protected JMenuItem modifyPID;
 
-  public JCheckBoxMenuItem scaleRight = new JCheckBoxMenuItem();
+  protected JMenuItem modifyConservation;
 
-  protected JMenuItem modifyConservation = new JMenuItem();
+  protected JMenuItem annotationColour;
 
   protected JMenu sortByTreeMenu = new JMenu();
 
@@ -179,7 +190,7 @@ public class GAlignFrame extends JInternalFrame
 
   protected JMenuItem runGroovy = new JMenuItem();
 
-  protected JMenuItem rnahelicesColour = new JMenuItem();
+  protected JMenuItem rnahelicesColour;
 
   protected JCheckBoxMenuItem autoCalculate = new JCheckBoxMenuItem();
 
@@ -265,7 +276,7 @@ public class GAlignFrame extends JInternalFrame
       System.err.println(e.toString());
     }
 
-    if (!jalview.util.Platform.isAMac())
+    if (!Platform.isAMac())
     {
       closeMenuItem.setMnemonic('C');
       outputTextboxMenu.setMnemonic('T');
@@ -277,99 +288,101 @@ public class GAlignFrame extends JInternalFrame
       reload.setMnemonic('R');
     }
 
-    if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null)
-    {
-      java.util.Enumeration userColours = jalview.gui.UserDefinedColours
-              .getUserColourSchemes().keys();
-
-      while (userColours.hasMoreElements())
-      {
-        final JRadioButtonMenuItem radioItem = new JRadioButtonMenuItem(
-                userColours.nextElement().toString());
-        radioItem.setName("USER_DEFINED");
-        radioItem.addMouseListener(new MouseAdapter()
-        {
-          @Override
-          public void mousePressed(MouseEvent evt)
-          {
-            if (evt.isPopupTrigger()) // Mac
-            {
-              offerRemoval(radioItem);
-            }
-          }
-
-          @Override
-          public void mouseReleased(MouseEvent evt)
-          {
-            if (evt.isPopupTrigger()) // Windows
-            {
-              offerRemoval(radioItem);
-            }
-          }
-
-          /**
-           * @param radioItem
-           */
-          void offerRemoval(final JRadioButtonMenuItem radioItem)
-          {
-            radioItem.removeActionListener(radioItem.getActionListeners()[0]);
-
-            int option = JvOptionPane.showInternalConfirmDialog(
-                    jalview.gui.Desktop.desktop, MessageManager
-                            .getString("label.remove_from_default_list"),
-                    MessageManager
-                            .getString("label.remove_user_defined_colour"),
-                    JvOptionPane.YES_NO_OPTION);
-            if (option == JvOptionPane.YES_OPTION)
-            {
-              jalview.gui.UserDefinedColours
-                      .removeColourFromDefaults(radioItem.getText());
-              colourMenu.remove(radioItem);
-            }
-            else
-            {
-              radioItem.addActionListener(new ActionListener()
-              {
-                @Override
-                public void actionPerformed(ActionEvent evt)
-                {
-                  userDefinedColour_actionPerformed(evt);
-                }
-              });
-            }
-          }
-        });
-        radioItem.addActionListener(new ActionListener()
-        {
-          @Override
-          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);
-    colours.add(purinePyrimidineColour);
-    // colours.add(covariationColour);
-    colours.add(tcoffeeColour);
-    colours.add(RNAInteractionColour);
-    setColourSelected(jalview.bin.Cache.getDefault(
-            Preferences.DEFAULT_COLOUR, "None"));
+    // Map<String, UserColourScheme> userColourSchemes = UserDefinedColours
+    // .getUserColourSchemes();
+    // if (userColourSchemes != null)
+    // {
+    // int insertionPoint = findUserDefinedColourPosition();
+    // for (String userColour : userColourSchemes.keySet())
+    // {
+    // final JRadioButtonMenuItem radioItem = new JRadioButtonMenuItem(
+    // userColour);
+    // radioItem.setName(USER_DEFINED_COLOUR_SCHEME);
+    // radioItem.addMouseListener(new MouseAdapter()
+    // {
+    // @Override
+    // public void mousePressed(MouseEvent evt)
+    // {
+    // if (evt.isPopupTrigger()) // Mac
+    // {
+    // offerRemoval();
+    // }
+    // }
+    //
+    // @Override
+    // public void mouseReleased(MouseEvent evt)
+    // {
+    // if (evt.isPopupTrigger()) // Windows
+    // {
+    // offerRemoval();
+    // }
+    // }
+    //
+    // void offerRemoval()
+    // {
+    // radioItem.removeActionListener(radioItem.getActionListeners()[0]);
+    //
+    // int option = JvOptionPane.showInternalConfirmDialog(
+    // Desktop.desktop, MessageManager
+    // .getString("label.remove_from_default_list"),
+    // MessageManager
+    // .getString("label.remove_user_defined_colour"),
+    // JvOptionPane.YES_NO_OPTION);
+    // if (option == JvOptionPane.YES_OPTION)
+    // {
+    // UserDefinedColours.removeColourFromDefaults(radioItem
+    // .getText());
+    // colourMenu.remove(radioItem);
+    // }
+    // else
+    // {
+    // radioItem.addActionListener(new ActionListener()
+    // {
+    // @Override
+    // public void actionPerformed(ActionEvent evt)
+    // {
+    // userDefinedColour_actionPerformed(evt);
+    // }
+    // });
+    // }
+    // }
+    // });
+    // radioItem.addActionListener(new ActionListener()
+    // {
+    // @Override
+    // public void actionPerformed(ActionEvent evt)
+    // {
+    // userDefinedColour_actionPerformed(evt);
+    // }
+    // });
+    // colourMenu.insert(radioItem, insertionPoint);
+    // insertionPoint++;
+    // colours.add(radioItem);
+    // }
+    // }
+    //
+    // /*
+    // * add colours to a ButtonGroup to make their
+    // * selection mutually exclusive
+    // */
+    // 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);
+    // colours.add(purinePyrimidineColour);
+    // // colours.add(covariationColour);
+    // colours.add(tcoffeeColour);
+    // colours.add(RNAInteractionColour);
+    // setColourSelected(Cache.getDefault(Preferences.DEFAULT_COLOUR, "None"));
   }
 
   public void setColourSelected(String defaultColour)
@@ -471,6 +484,9 @@ public class GAlignFrame extends JInternalFrame
 
   private void jbInit() throws Exception
   {
+    initColourMenu();
+    buildColourMenu();
+
     JMenuItem saveAs = new JMenuItem(
             MessageManager.getString("action.save_as"));
     ActionListener al = new ActionListener()
@@ -481,6 +497,8 @@ public class GAlignFrame extends JInternalFrame
         saveAs_actionPerformed(e);
       }
     };
+
+    // FIXME getDefaultToolkit throws an exception in Headless mode
     KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit
             .getDefaultToolkit().getMenuShortcutKeyMask()
             | KeyEvent.SHIFT_MASK, false);
@@ -783,146 +801,7 @@ public class GAlignFrame extends JInternalFrame
     statusBar.setText(MessageManager.getString("label.status_bar"));
     outputTextboxMenu.setText(MessageManager
             .getString("label.out_to_textbox"));
-    clustalColour.setText(MessageManager.getString("label.clustalx"));
-    clustalColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        clustalColour_actionPerformed(e);
-      }
-    });
-    zappoColour.setText(MessageManager.getString("label.zappo"));
-    zappoColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        zappoColour_actionPerformed(e);
-      }
-    });
-    taylorColour.setText(MessageManager.getString("label.taylor"));
-    taylorColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        taylorColour_actionPerformed(e);
-      }
-    });
-    hydrophobicityColour.setText(MessageManager
-            .getString("label.hydrophobicity"));
-    hydrophobicityColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        hydrophobicityColour_actionPerformed(e);
-      }
-    });
-    helixColour.setText(MessageManager.getString("label.helix_propensity"));
-    helixColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        helixColour_actionPerformed(e);
-      }
-    });
-    strandColour.setText(MessageManager
-            .getString("label.strand_propensity"));
-    strandColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        strandColour_actionPerformed(e);
-      }
-    });
-    turnColour.setText(MessageManager.getString("label.turn_propensity"));
-    turnColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        turnColour_actionPerformed(e);
-      }
-    });
-    buriedColour.setText(MessageManager.getString("label.buried_index"));
-    buriedColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        buriedColour_actionPerformed(e);
-      }
-    });
-    userDefinedColour.setText(MessageManager
-            .getString("action.user_defined"));
-    userDefinedColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        userDefinedColour_actionPerformed(e);
-      }
-    });
-    PIDColour
-            .setText(MessageManager.getString("label.percentage_identity"));
-    PIDColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        PIDColour_actionPerformed(e);
-      }
-    });
-    BLOSUM62Colour
-            .setText(MessageManager.getString("label.blosum62_score"));
-    BLOSUM62Colour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        BLOSUM62Colour_actionPerformed(e);
-      }
-    });
-    nucleotideColour.setText(MessageManager.getString("label.nucleotide"));
-    nucleotideColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        nucleotideColour_actionPerformed(e);
-      }
-    });
-
-    purinePyrimidineColour.setText(MessageManager
-            .getString("label.purine_pyrimidine"));
-    purinePyrimidineColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        purinePyrimidineColour_actionPerformed(e);
-      }
-    });
 
-    RNAInteractionColour.setText("RNA Interaction type");
-    RNAInteractionColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        RNAInteractionColour_actionPerformed(e);
-      }
-    });
-    /*
-     * covariationColour.setText("Covariation");
-     * covariationColour.addActionListener(new ActionListener() { public void
-     * actionPerformed(ActionEvent e) { covariationColour_actionPerformed(e); }
-     * });
-     */
 
     JMenuItem avDistanceTreeBlosumMenuItem = new JMenuItem(
             MessageManager.getString("label.average_distance_bloslum62"));
@@ -1039,7 +918,8 @@ public class GAlignFrame extends JInternalFrame
         sortAnnotations_actionPerformed();
       }
     });
-    colourTextMenuItem.setText(MessageManager
+    colourTextMenuItem = new JCheckBoxMenuItem(
+            MessageManager
             .getString("label.colour_text"));
     colourTextMenuItem.addActionListener(new ActionListener()
     {
@@ -1111,25 +991,6 @@ public class GAlignFrame extends JInternalFrame
     };
     addMenuActionAndAccelerator(keyStroke, redoMenuItem, al);
 
-    conservationMenuItem.setText(MessageManager
-            .getString("action.by_conservation"));
-    conservationMenuItem.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        conservationMenuItem_actionPerformed(e);
-      }
-    });
-    noColourmenuItem.setText(MessageManager.getString("label.none"));
-    noColourmenuItem.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        noColourmenuItem_actionPerformed(e);
-      }
-    });
     wrapMenuItem.setText(MessageManager.getString("label.wrap"));
     wrapMenuItem.addActionListener(new ActionListener()
     {
@@ -1182,16 +1043,6 @@ public class GAlignFrame extends JInternalFrame
     };
     addMenuActionAndAccelerator(keyStroke, findMenuItem, al);
 
-    abovePIDThreshold.setText(MessageManager
-            .getString("label.above_identity_threshold"));
-    abovePIDThreshold.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        abovePIDThreshold_actionPerformed(e);
-      }
-    });
     showSeqFeatures.setText(MessageManager
             .getString("label.show_sequence_features"));
     showSeqFeatures.addActionListener(new ActionListener()
@@ -1337,28 +1188,6 @@ public class GAlignFrame extends JInternalFrame
       }
     });
 
-    nucleotideColour.setText(MessageManager.getString("label.nucleotide"));
-    nucleotideColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        nucleotideColour_actionPerformed(e);
-      }
-    });
-
-    tcoffeeColour.setText(MessageManager.getString("label.tcoffee_scores"));
-    tcoffeeColour.setEnabled(false);
-    tcoffeeColour.addActionListener(new ActionListener()
-    {
-
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        tcoffeeColorScheme_actionPerformed(e);
-      }
-    });
-
     JMenuItem deleteGroups = new JMenuItem(
             MessageManager.getString("action.undefine_groups"));
     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_U, Toolkit
@@ -1373,6 +1202,17 @@ public class GAlignFrame extends JInternalFrame
     };
     addMenuActionAndAccelerator(keyStroke, deleteGroups, al);
 
+    JMenuItem annotationColumn = new JMenuItem(
+            MessageManager.getString("action.select_by_annotation"));
+    annotationColumn.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        annotationColumn_actionPerformed(e);
+      }
+    });
+
     JMenuItem createGroup = new JMenuItem(
             MessageManager.getString("action.create_groups"));
     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_G, Toolkit
@@ -1470,16 +1310,6 @@ public class GAlignFrame extends JInternalFrame
     };
     addMenuActionAndAccelerator(keyStroke, pasteThis, al);
 
-    applyToAllGroups.setText(MessageManager
-            .getString("label.apply_colour_to_all_groups"));
-    applyToAllGroups.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        applyToAllGroups_actionPerformed(e);
-      }
-    });
     JMenuItem createPNG = new JMenuItem("PNG");
     createPNG.addActionListener(new ActionListener()
     {
@@ -1604,35 +1434,15 @@ public class GAlignFrame extends JInternalFrame
 
     });
 
-    JMenuItem modifyPID = new JMenuItem(
-            MessageManager.getString("label.modify_identity_threshold"));
-    modifyPID.addActionListener(new ActionListener()
+    sortByTreeMenu
+            .setText(MessageManager.getString("action.by_tree_order"));
+    sort.setText(MessageManager.getString("action.sort"));
+    sort.addMenuListener(new MenuListener()
     {
       @Override
-      public void actionPerformed(ActionEvent e)
+      public void menuSelected(MenuEvent e)
       {
-        modifyPID_actionPerformed(e);
-      }
-    });
-    modifyConservation.setText(MessageManager
-            .getString("label.modify_conservation_threshold"));
-    modifyConservation.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        modifyConservation_actionPerformed(e);
-      }
-    });
-    sortByTreeMenu
-            .setText(MessageManager.getString("action.by_tree_order"));
-    sort.setText(MessageManager.getString("action.sort"));
-    sort.addMenuListener(new MenuListener()
-    {
-      @Override
-      public void menuSelected(MenuEvent e)
-      {
-        buildTreeMenu();
+        buildTreeMenu();
       }
 
       @Override
@@ -1773,39 +1583,6 @@ public class GAlignFrame extends JInternalFrame
       }
     });
 
-    JMenuItem annotationColour = new JMenuItem(
-            MessageManager.getString("action.by_annotation"));
-    annotationColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        annotationColour_actionPerformed(e);
-      }
-    });
-
-    JMenuItem annotationColumn = new JMenuItem(
-            MessageManager.getString("action.select_by_annotation"));
-    annotationColumn.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        annotationColumn_actionPerformed(e);
-      }
-    });
-
-    rnahelicesColour.setText(MessageManager
-            .getString("action.by_rna_helixes"));
-    rnahelicesColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        rnahelicesColour_actionPerformed(e);
-      }
-    });
-
     JMenuItem associatedData = new JMenuItem(
             MessageManager.getString("label.load_features_annotations"));
     associatedData.addActionListener(new ActionListener()
@@ -2112,16 +1889,7 @@ public class GAlignFrame extends JInternalFrame
     tabbedPane.setToolTipText("<html><i>"
             + MessageManager.getString("label.rename_tab_eXpand_reGroup")
             + "</i></html>");
-    JMenuItem textColour = new JMenuItem(
-            MessageManager.getString("action.set_text_colour"));
-    textColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        textColour_actionPerformed(e);
-      }
-    });
+
     formatMenu.setText(MessageManager.getString("action.format"));
     JMenu selectMenu = new JMenu(MessageManager.getString("action.select"));
     idRightAlign.setText(MessageManager
@@ -2303,33 +2071,6 @@ public class GAlignFrame extends JInternalFrame
     autoAnnMenu.add(showGroupConsensus);
     annotationsMenu.add(autoAnnMenu);
 
-    colourMenu.add(applyToAllGroups);
-    colourMenu.add(textColour);
-    colourMenu.addSeparator();
-    colourMenu.add(noColourmenuItem);
-    colourMenu.add(clustalColour);
-    colourMenu.add(BLOSUM62Colour);
-    colourMenu.add(PIDColour);
-    colourMenu.add(zappoColour);
-    colourMenu.add(taylorColour);
-    colourMenu.add(hydrophobicityColour);
-    colourMenu.add(helixColour);
-    colourMenu.add(strandColour);
-    colourMenu.add(turnColour);
-    colourMenu.add(buriedColour);
-    colourMenu.add(nucleotideColour);
-    colourMenu.add(purinePyrimidineColour);
-    // colourMenu.add(RNAInteractionColour);
-    // colourMenu.add(covariationColour);
-    colourMenu.add(tcoffeeColour);
-    colourMenu.add(userDefinedColour);
-    colourMenu.addSeparator();
-    colourMenu.add(conservationMenuItem);
-    colourMenu.add(modifyConservation);
-    colourMenu.add(abovePIDThreshold);
-    colourMenu.add(modifyPID);
-    colourMenu.add(annotationColour);
-    colourMenu.add(rnahelicesColour);
 
     sort.add(sortIDMenuItem);
     sort.add(sortLengthMenuItem);
@@ -2402,6 +2143,410 @@ public class GAlignFrame extends JInternalFrame
     // selectMenu.add(listenToViewSelections);
   }
 
+  /**
+   * Rebuilds the Colour menu, including any user-defined colours which have
+   * been loaded either on startup or during the session
+   */
+  public void buildColourMenu()
+  {
+    colourMenu.removeAll();
+    colours = new ButtonGroup();
+
+    colourMenu.add(applyToAllGroups);
+    colourMenu.add(textColour);
+    colourMenu.addSeparator();
+    colourMenu.add(noColourmenuItem);
+    colourMenu.add(clustalColour);
+    colourMenu.add(BLOSUM62Colour);
+    colourMenu.add(PIDColour);
+    colourMenu.add(zappoColour);
+    colourMenu.add(taylorColour);
+    colourMenu.add(hydrophobicityColour);
+    colourMenu.add(helixColour);
+    colourMenu.add(strandColour);
+    colourMenu.add(turnColour);
+    colourMenu.add(buriedColour);
+    colourMenu.add(nucleotideColour);
+    colourMenu.add(purinePyrimidineColour);
+    // colourMenu.add(RNAInteractionColour);
+    // colourMenu.add(covariationColour);
+    colourMenu.add(tcoffeeColour);
+
+    /*
+     * add any user-defined colours
+     */
+    Map<String, UserColourScheme> userColourSchemes = UserDefinedColours
+            .getUserColourSchemes();
+    if (userColourSchemes != null)
+    {
+      for (String userColour : userColourSchemes.keySet())
+      {
+        final JRadioButtonMenuItem radioItem = new JRadioButtonMenuItem(
+                userColour);
+        radioItem.setName(USER_DEFINED_COLOUR_SCHEME);
+        radioItem.addMouseListener(new MouseAdapter()
+        {
+          @Override
+          public void mousePressed(MouseEvent evt)
+          {
+            if (evt.isPopupTrigger()) // Mac
+            {
+              offerRemoval();
+            }
+          }
+
+          @Override
+          public void mouseReleased(MouseEvent evt)
+          {
+            if (evt.isPopupTrigger()) // Windows
+            {
+              offerRemoval();
+            }
+          }
+
+          void offerRemoval()
+          {
+            radioItem.removeActionListener(radioItem.getActionListeners()[0]);
+
+            int option = JvOptionPane.showInternalConfirmDialog(
+                    Desktop.desktop, MessageManager
+                            .getString("label.remove_from_default_list"),
+                    MessageManager
+                            .getString("label.remove_user_defined_colour"),
+                    JvOptionPane.YES_NO_OPTION);
+            if (option == JvOptionPane.YES_OPTION)
+            {
+              UserDefinedColours.removeColourFromDefaults(radioItem
+                      .getText());
+              colourMenu.remove(radioItem);
+            }
+            else
+            {
+              radioItem.addActionListener(new ActionListener()
+              {
+                @Override
+                public void actionPerformed(ActionEvent evt)
+                {
+                  userDefinedColour_actionPerformed(evt);
+                }
+              });
+            }
+          }
+        });
+        radioItem.addActionListener(new ActionListener()
+        {
+          @Override
+          public void actionPerformed(ActionEvent evt)
+          {
+            userDefinedColour_actionPerformed(evt);
+          }
+        });
+        colourMenu.add(radioItem);
+        colours.add(radioItem);
+      }
+    }
+
+    colourMenu.add(userDefinedColour);
+    colourMenu.addSeparator();
+    colourMenu.add(conservationMenuItem);
+    colourMenu.add(modifyConservation);
+    colourMenu.add(abovePIDThreshold);
+    colourMenu.add(modifyPID);
+    colourMenu.add(annotationColour);
+    colourMenu.add(rnahelicesColour);
+
+    /*
+     * add colours to a ButtonGroup to make their 
+     * selection mutually exclusive
+     */
+    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);
+    colours.add(purinePyrimidineColour);
+    // colours.add(covariationColour);
+    colours.add(tcoffeeColour);
+    colours.add(RNAInteractionColour);
+    setColourSelected(Cache.getDefault(Preferences.DEFAULT_COLOUR, "None"));
+
+  }
+
+  /**
+   * Constructs the entries on the Colour menu (but does not add them to the
+   * menu)
+   */
+  protected void initColourMenu()
+  {
+    applyToAllGroups = new JCheckBoxMenuItem(
+            MessageManager.getString("label.apply_colour_to_all_groups"));
+    applyToAllGroups.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        applyToAllGroups_actionPerformed();
+      }
+    });
+
+    textColour = new JRadioButtonMenuItem(
+            MessageManager.getString("action.set_text_colour"));
+    textColour.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        textColour_actionPerformed();
+      }
+    });
+    clustalColour = new JRadioButtonMenuItem(
+            MessageManager.getString("label.clustalx"));
+    clustalColour.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        clustalColour_actionPerformed();
+      }
+    });
+    zappoColour = new JRadioButtonMenuItem(
+            MessageManager.getString("label.zappo"));
+    zappoColour.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        zappoColour_actionPerformed();
+      }
+    });
+    taylorColour = new JRadioButtonMenuItem(
+            MessageManager.getString("label.taylor"));
+    taylorColour.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        taylorColour_actionPerformed();
+      }
+    });
+    hydrophobicityColour = new JRadioButtonMenuItem(
+            MessageManager
+            .getString("label.hydrophobicity"));
+    hydrophobicityColour.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        hydrophobicityColour_actionPerformed();
+      }
+    });
+    helixColour = new JRadioButtonMenuItem(
+            MessageManager.getString("label.helix_propensity"));
+    helixColour.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        helixColour_actionPerformed();
+      }
+    });
+    strandColour = new JRadioButtonMenuItem(
+            MessageManager
+            .getString("label.strand_propensity"));
+    strandColour.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        strandColour_actionPerformed();
+      }
+    });
+    turnColour = new JRadioButtonMenuItem(
+            MessageManager.getString("label.turn_propensity"));
+    turnColour.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        turnColour_actionPerformed();
+      }
+    });
+    buriedColour = new JRadioButtonMenuItem(
+            MessageManager.getString("label.buried_index"));
+    buriedColour.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        buriedColour_actionPerformed();
+      }
+    });
+    userDefinedColour = new JRadioButtonMenuItem(
+            MessageManager
+            .getString("action.user_defined"));
+    userDefinedColour.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        userDefinedColour_actionPerformed(e);
+      }
+    });
+    PIDColour = new JRadioButtonMenuItem(
+            MessageManager.getString("label.percentage_identity"));
+    PIDColour.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        PIDColour_actionPerformed();
+      }
+    });
+    BLOSUM62Colour = new JRadioButtonMenuItem(
+            MessageManager.getString("label.blosum62_score"));
+    BLOSUM62Colour.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        BLOSUM62Colour_actionPerformed();
+      }
+    });
+    nucleotideColour = new JRadioButtonMenuItem(
+            MessageManager.getString("label.nucleotide"));
+    nucleotideColour.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        nucleotideColour_actionPerformed();
+      }
+    });
+    purinePyrimidineColour = new JRadioButtonMenuItem(
+            MessageManager.getString("label.purine_pyrimidine"));
+    purinePyrimidineColour.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        purinePyrimidineColour_actionPerformed();
+      }
+    });
+
+    tcoffeeColour = new JRadioButtonMenuItem(
+            MessageManager.getString("label.tcoffee_scores"));
+    tcoffeeColour.setEnabled(false);
+    tcoffeeColour.addActionListener(new ActionListener()
+    {
+
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        tcoffeeColorScheme_actionPerformed();
+      }
+    });
+
+    RNAInteractionColour = new JRadioButtonMenuItem("RNA Interaction type");
+    RNAInteractionColour.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        RNAInteractionColour_actionPerformed();
+      }
+    });
+    /*
+     * covariationColour = new JRadioButtonMenuItem("Covariation");
+     * covariationColour.addActionListener(new ActionListener() { public void
+     * actionPerformed(ActionEvent e) { covariationColour_actionPerformed(); }
+     * });
+     */
+
+    conservationMenuItem = new JCheckBoxMenuItem(
+            MessageManager
+            .getString("action.by_conservation"));
+    conservationMenuItem.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        conservationMenuItem_actionPerformed();
+      }
+    });
+    noColourmenuItem = new JRadioButtonMenuItem(
+            MessageManager.getString("label.none"));
+    noColourmenuItem.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        noColourmenuItem_actionPerformed();
+      }
+    });
+
+    abovePIDThreshold = new JCheckBoxMenuItem(
+            MessageManager.getString("label.above_identity_threshold"));
+    abovePIDThreshold.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        abovePIDThreshold_actionPerformed();
+      }
+    });
+    modifyPID = new JMenuItem(
+            MessageManager.getString("label.modify_identity_threshold"));
+    modifyPID.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        modifyPID_actionPerformed();
+      }
+    });
+    modifyConservation = new JMenuItem(
+            MessageManager
+            .getString("label.modify_conservation_threshold"));
+    modifyConservation.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        modifyConservation_actionPerformed();
+      }
+    });
+
+    annotationColour = new JMenuItem(
+            MessageManager.getString("action.by_annotation"));
+    annotationColour.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        annotationColour_actionPerformed();
+      }
+    });
+
+    rnahelicesColour = new JMenuItem(
+            MessageManager.getString("action.by_rna_helixes"));
+    rnahelicesColour.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        rnahelicesColour_actionPerformed();
+      }
+    });
+  }
+
   protected void selectHighlightedColumns_actionPerformed(
           ActionEvent actionEvent)
   {
@@ -2757,35 +2902,35 @@ public class GAlignFrame extends JInternalFrame
   {
   }
 
-  protected void clustalColour_actionPerformed(ActionEvent e)
+  protected void clustalColour_actionPerformed()
   {
   }
 
-  protected void zappoColour_actionPerformed(ActionEvent e)
+  protected void zappoColour_actionPerformed()
   {
   }
 
-  protected void taylorColour_actionPerformed(ActionEvent e)
+  protected void taylorColour_actionPerformed()
   {
   }
 
-  protected void hydrophobicityColour_actionPerformed(ActionEvent e)
+  protected void hydrophobicityColour_actionPerformed()
   {
   }
 
-  protected void helixColour_actionPerformed(ActionEvent e)
+  protected void helixColour_actionPerformed()
   {
   }
 
-  protected void strandColour_actionPerformed(ActionEvent e)
+  protected void strandColour_actionPerformed()
   {
   }
 
-  protected void turnColour_actionPerformed(ActionEvent e)
+  protected void turnColour_actionPerformed()
   {
   }
 
-  protected void buriedColour_actionPerformed(ActionEvent e)
+  protected void buriedColour_actionPerformed()
   {
   }
 
@@ -2793,31 +2938,31 @@ public class GAlignFrame extends JInternalFrame
   {
   }
 
-  protected void PIDColour_actionPerformed(ActionEvent e)
+  protected void PIDColour_actionPerformed()
   {
   }
 
-  protected void BLOSUM62Colour_actionPerformed(ActionEvent e)
+  protected void BLOSUM62Colour_actionPerformed()
   {
   }
 
-  protected void purinePyrimidineColour_actionPerformed(ActionEvent e)
+  protected void purinePyrimidineColour_actionPerformed()
   {
   }
 
-  protected void RNAInteractionColour_actionPerformed(ActionEvent e)
+  protected void RNAInteractionColour_actionPerformed()
   {
   }
 
   /*
-   * protected void covariationColour_actionPerformed(ActionEvent e) { }
+   * protected void covariationColour_actionPerformed() { }
    */
 
-  protected void noColourmenuItem_actionPerformed(ActionEvent e)
+  protected void noColourmenuItem_actionPerformed()
   {
   }
 
-  protected void conservationMenuItem_actionPerformed(ActionEvent e)
+  protected void conservationMenuItem_actionPerformed()
   {
   }
 
@@ -2833,7 +2978,7 @@ public class GAlignFrame extends JInternalFrame
   {
   }
 
-  protected void abovePIDThreshold_actionPerformed(ActionEvent e)
+  protected void abovePIDThreshold_actionPerformed()
   {
   }
 
@@ -2841,7 +2986,7 @@ public class GAlignFrame extends JInternalFrame
   {
   }
 
-  protected void nucleotideColour_actionPerformed(ActionEvent e)
+  protected void nucleotideColour_actionPerformed()
   {
   }
 
@@ -2877,7 +3022,7 @@ public class GAlignFrame extends JInternalFrame
   {
   }
 
-  protected void applyToAllGroups_actionPerformed(ActionEvent e)
+  protected void applyToAllGroups_actionPerformed()
   {
   }
 
@@ -2929,11 +3074,8 @@ public class GAlignFrame extends JInternalFrame
    * Template method to handle the 'Color T-Coffee scores' menu event.
    * <p>
    * Subclasses override this method to provide a custom action.
-   * 
-   * @param event
-   *          The raised event
    */
-  protected void tcoffeeColorScheme_actionPerformed(ActionEvent event)
+  protected void tcoffeeColorScheme_actionPerformed()
   {
 
   }
@@ -2954,11 +3096,11 @@ public class GAlignFrame extends JInternalFrame
   {
   }
 
-  protected void modifyPID_actionPerformed(ActionEvent e)
+  protected void modifyPID_actionPerformed()
   {
   }
 
-  protected void modifyConservation_actionPerformed(ActionEvent e)
+  protected void modifyConservation_actionPerformed()
   {
   }
 
@@ -3000,17 +3142,15 @@ public class GAlignFrame extends JInternalFrame
 
   }
 
-  public void annotationColour_actionPerformed(ActionEvent e)
+  public void annotationColour_actionPerformed()
   {
-
   }
 
   public void annotationColumn_actionPerformed(ActionEvent e)
   {
-
   }
 
-  public void rnahelicesColour_actionPerformed(ActionEvent e)
+  public void rnahelicesColour_actionPerformed()
   {
 
   }
@@ -3105,7 +3245,7 @@ public class GAlignFrame extends JInternalFrame
 
   }
 
-  public void textColour_actionPerformed(ActionEvent e)
+  public void textColour_actionPerformed()
   {
 
   }
index bd0f1de..daba592 100644 (file)
 package jalview.jbgui;
 
 import jalview.api.structures.JalviewStructureDisplayI;
+import jalview.gui.UserDefinedColours;
+import jalview.schemes.UserColourScheme;
 import jalview.util.MessageManager;
 
+import java.awt.BorderLayout;
 import java.awt.GridLayout;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.util.Map;
 
 import javax.swing.ButtonGroup;
 import javax.swing.JInternalFrame;
@@ -41,49 +45,53 @@ public abstract class GStructureViewer extends JInternalFrame implements
 {
   // private AAStructureBindingModel bindingModel;
 
-  protected JMenu savemenu = new JMenu();
+  protected JMenu savemenu;
 
-  protected JMenu viewMenu = new JMenu();
+  protected JMenu viewMenu;
 
-  protected JMenu chainMenu = new JMenu();
+  protected JMenu colourMenu;
 
-  protected JMenu viewerActionMenu = new JMenu();
+  protected JMenu chainMenu;
 
-  protected JMenuItem alignStructs = new JMenuItem();
+  protected JMenu viewerActionMenu;
 
-  protected JMenuItem fitToWindow = new JMenuItem();
+  protected JMenuItem alignStructs;
 
-  protected JRadioButtonMenuItem seqColour = new JRadioButtonMenuItem();
+  protected JMenuItem fitToWindow;
 
-  protected JRadioButtonMenuItem chainColour = new JRadioButtonMenuItem();
+  protected JRadioButtonMenuItem seqColour;
 
-  protected JRadioButtonMenuItem chargeColour = new JRadioButtonMenuItem();
+  protected JRadioButtonMenuItem chainColour;
 
-  protected JRadioButtonMenuItem zappoColour = new JRadioButtonMenuItem();
+  protected JRadioButtonMenuItem chargeColour;
 
-  protected JRadioButtonMenuItem taylorColour = new JRadioButtonMenuItem();
+  protected JRadioButtonMenuItem zappoColour;
 
-  protected JRadioButtonMenuItem hydroColour = new JRadioButtonMenuItem();
+  protected JRadioButtonMenuItem taylorColour;
 
-  protected JRadioButtonMenuItem strandColour = new JRadioButtonMenuItem();
+  protected JRadioButtonMenuItem hydroColour;
 
-  protected JRadioButtonMenuItem helixColour = new JRadioButtonMenuItem();
+  protected JRadioButtonMenuItem strandColour;
 
-  protected JRadioButtonMenuItem turnColour = new JRadioButtonMenuItem();
+  protected JRadioButtonMenuItem helixColour;
 
-  protected JRadioButtonMenuItem buriedColour = new JRadioButtonMenuItem();
+  protected JRadioButtonMenuItem turnColour;
 
-  protected JRadioButtonMenuItem purinePyrimidineColour = new JRadioButtonMenuItem();
+  protected JRadioButtonMenuItem buriedColour;
 
-  protected JRadioButtonMenuItem userColour = new JRadioButtonMenuItem();
+  protected JRadioButtonMenuItem nucleotideColour;
 
-  protected JRadioButtonMenuItem viewerColour = new JRadioButtonMenuItem();
+  protected JRadioButtonMenuItem purinePyrimidineColour;
 
-  protected JMenuItem helpItem = new JMenuItem();
+  protected JRadioButtonMenuItem userColour;
 
-  protected JLabel statusBar = new JLabel();
+  protected JRadioButtonMenuItem viewerColour;
 
-  protected JPanel statusPanel = new JPanel();
+  protected JMenuItem helpItem;
+
+  protected JLabel statusBar;
+
+  protected JPanel statusPanel;
 
   /**
    * Constructor
@@ -107,6 +115,7 @@ public abstract class GStructureViewer extends JInternalFrame implements
     JMenu fileMenu = new JMenu();
     fileMenu.setText(MessageManager.getString("action.file"));
 
+    savemenu = new JMenu();
     savemenu.setActionCommand(MessageManager.getString("action.save_image"));
     savemenu.setText(MessageManager.getString("action.save_as"));
 
@@ -153,10 +162,14 @@ public abstract class GStructureViewer extends JInternalFrame implements
         viewMapping_actionPerformed(actionEvent);
       }
     });
+
+    viewMenu = new JMenu();
     viewMenu.setText(MessageManager.getString("action.view"));
 
+    chainMenu = new JMenu();
     chainMenu.setText(MessageManager.getString("action.show_chain"));
 
+    fitToWindow = new JMenuItem();
     fitToWindow.setText(MessageManager.getString("label.fit_to_window"));
     fitToWindow.addActionListener(new ActionListener()
     {
@@ -167,7 +180,62 @@ public abstract class GStructureViewer extends JInternalFrame implements
       }
     });
 
-    JMenu colourMenu = new JMenu();
+    JMenu helpMenu = new JMenu();
+    helpMenu.setText(MessageManager.getString("action.help"));
+    helpItem = new JMenuItem();
+    helpItem.setText(MessageManager.getString("label.jmol_help"));
+    helpItem.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent actionEvent)
+      {
+        showHelp_actionPerformed(actionEvent);
+      }
+    });
+    alignStructs = new JMenuItem();
+    alignStructs
+            .setText(MessageManager.getString("label.align_structures"));
+    alignStructs.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent actionEvent)
+      {
+        alignStructs_actionPerformed(actionEvent);
+      }
+    });
+
+    viewerActionMenu = new JMenu(MessageManager.getString("label.jmol"));
+    viewerActionMenu.setVisible(false);
+    viewerActionMenu.add(alignStructs);
+    colourMenu = new JMenu();
+    buildColourMenu();
+    fileMenu.add(savemenu);
+    fileMenu.add(viewMapping);
+    savemenu.add(pdbFile);
+    savemenu.add(png);
+    savemenu.add(eps);
+    viewMenu.add(chainMenu);
+    helpMenu.add(helpItem);
+
+    menuBar.add(fileMenu);
+    menuBar.add(viewMenu);
+    menuBar.add(colourMenu);
+    menuBar.add(viewerActionMenu);
+    menuBar.add(helpMenu);
+
+    statusPanel = new JPanel();
+    statusPanel.setLayout(new GridLayout());
+    this.getContentPane().add(statusPanel, BorderLayout.SOUTH);
+    statusBar = new JLabel();
+    statusPanel.add(statusBar, null);
+  }
+
+  /**
+   * Builds the colour menu
+   */
+  protected void buildColourMenu()
+  {
+    colourMenu.removeAll();
     colourMenu.setText(MessageManager.getString("label.colours"));
 
     JMenuItem backGround = new JMenuItem();
@@ -181,6 +249,7 @@ public abstract class GStructureViewer extends JInternalFrame implements
         backGround_actionPerformed(actionEvent);
       }
     });
+    seqColour = new JRadioButtonMenuItem();
     seqColour.setSelected(false);
     seqColour.setText(MessageManager.getString("action.by_sequence"));
     seqColour.addActionListener(new ActionListener()
@@ -191,6 +260,7 @@ public abstract class GStructureViewer extends JInternalFrame implements
         seqColour_actionPerformed(actionEvent);
       }
     });
+    chainColour = new JRadioButtonMenuItem();
     chainColour.setText(MessageManager.getString("action.by_chain"));
     chainColour.addActionListener(new ActionListener()
     {
@@ -200,6 +270,7 @@ public abstract class GStructureViewer extends JInternalFrame implements
         chainColour_actionPerformed(actionEvent);
       }
     });
+    chargeColour = new JRadioButtonMenuItem();
     chargeColour.setText(MessageManager.getString("label.charge_cysteine"));
     chargeColour.addActionListener(new ActionListener()
     {
@@ -209,6 +280,7 @@ public abstract class GStructureViewer extends JInternalFrame implements
         chargeColour_actionPerformed(actionEvent);
       }
     });
+    zappoColour = new JRadioButtonMenuItem();
     zappoColour.setText(MessageManager.getString("label.zappo"));
     zappoColour.addActionListener(new ActionListener()
     {
@@ -218,6 +290,7 @@ public abstract class GStructureViewer extends JInternalFrame implements
         zappoColour_actionPerformed(actionEvent);
       }
     });
+    taylorColour = new JRadioButtonMenuItem();
     taylorColour.setText(MessageManager.getString("label.taylor"));
     taylorColour.addActionListener(new ActionListener()
     {
@@ -227,6 +300,7 @@ public abstract class GStructureViewer extends JInternalFrame implements
         taylorColour_actionPerformed(actionEvent);
       }
     });
+    hydroColour = new JRadioButtonMenuItem();
     hydroColour.setText(MessageManager.getString("label.hydrophobicity"));
     hydroColour.addActionListener(new ActionListener()
     {
@@ -236,6 +310,7 @@ public abstract class GStructureViewer extends JInternalFrame implements
         hydroColour_actionPerformed(actionEvent);
       }
     });
+    strandColour = new JRadioButtonMenuItem();
     strandColour.setText(MessageManager
             .getString("label.strand_propensity"));
     strandColour.addActionListener(new ActionListener()
@@ -246,6 +321,7 @@ public abstract class GStructureViewer extends JInternalFrame implements
         strandColour_actionPerformed(actionEvent);
       }
     });
+    helixColour = new JRadioButtonMenuItem();
     helixColour.setText(MessageManager.getString("label.helix_propensity"));
     helixColour.addActionListener(new ActionListener()
     {
@@ -255,6 +331,7 @@ public abstract class GStructureViewer extends JInternalFrame implements
         helixColour_actionPerformed(actionEvent);
       }
     });
+    turnColour = new JRadioButtonMenuItem();
     turnColour.setText(MessageManager.getString("label.turn_propensity"));
     turnColour.addActionListener(new ActionListener()
     {
@@ -264,6 +341,7 @@ public abstract class GStructureViewer extends JInternalFrame implements
         turnColour_actionPerformed(actionEvent);
       }
     });
+    buriedColour = new JRadioButtonMenuItem();
     buriedColour.setText(MessageManager.getString("label.buried_index"));
     buriedColour.addActionListener(new ActionListener()
     {
@@ -273,6 +351,17 @@ public abstract class GStructureViewer extends JInternalFrame implements
         buriedColour_actionPerformed(actionEvent);
       }
     });
+    nucleotideColour = new JRadioButtonMenuItem();
+    nucleotideColour.setText(MessageManager.getString("label.nucleotide"));
+    nucleotideColour.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent actionEvent)
+      {
+        nucleotideColour_actionPerformed(actionEvent);
+      }
+    });
+    purinePyrimidineColour = new JRadioButtonMenuItem();
     purinePyrimidineColour.setText(MessageManager
             .getString("label.purine_pyrimidine"));
     purinePyrimidineColour.addActionListener(new ActionListener()
@@ -283,7 +372,7 @@ public abstract class GStructureViewer extends JInternalFrame implements
         purinePyrimidineColour_actionPerformed(actionEvent);
       }
     });
-
+    userColour = new JRadioButtonMenuItem();
     userColour.setText(MessageManager.getString("action.user_defined"));
     userColour.addActionListener(new ActionListener()
     {
@@ -293,6 +382,7 @@ public abstract class GStructureViewer extends JInternalFrame implements
         userColour_actionPerformed(actionEvent);
       }
     });
+    viewerColour = new JRadioButtonMenuItem();
     viewerColour.setSelected(false);
     viewerColour
             .setText(MessageManager.getString("label.colour_with_jmol"));
@@ -307,40 +397,11 @@ public abstract class GStructureViewer extends JInternalFrame implements
       }
     });
 
-    JMenu helpMenu = new JMenu();
-    helpMenu.setText(MessageManager.getString("action.help"));
-    helpItem.setText(MessageManager.getString("label.jmol_help"));
-    helpItem.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent actionEvent)
-      {
-        showHelp_actionPerformed(actionEvent);
-      }
-    });
-    alignStructs
-            .setText(MessageManager.getString("label.align_structures"));
-    alignStructs.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent actionEvent)
-      {
-        alignStructs_actionPerformed(actionEvent);
-      }
-    });
-    viewerActionMenu.setText(MessageManager.getString("label.jmol"));
-    menuBar.add(fileMenu);
-    menuBar.add(viewMenu);
-    menuBar.add(colourMenu);
-    menuBar.add(viewerActionMenu);
-    viewerActionMenu.setVisible(false);
-    menuBar.add(helpMenu);
-    fileMenu.add(savemenu);
-    fileMenu.add(viewMapping);
-    savemenu.add(pdbFile);
-    savemenu.add(png);
-    savemenu.add(eps);
-    viewMenu.add(chainMenu);
+    /*
+     * add colour buttons to a group so their selection
+     * is mutually exclusive
+     */
+    ButtonGroup colourButtons = new ButtonGroup();
 
     colourMenu.add(seqColour);
     colourMenu.add(chainColour);
@@ -353,12 +414,34 @@ public abstract class GStructureViewer extends JInternalFrame implements
     colourMenu.add(turnColour);
     colourMenu.add(buriedColour);
     colourMenu.add(purinePyrimidineColour);
+
+    /*
+     * add any user-defined colours that are loaded
+     */
+    Map<String, UserColourScheme> userColourSchemes = UserDefinedColours
+            .getUserColourSchemes();
+    if (userColourSchemes != null)
+    {
+      for (String schemeName : userColourSchemes.keySet())
+      {
+        final JRadioButtonMenuItem radioItem = new JRadioButtonMenuItem(
+                schemeName);
+        radioItem.addActionListener(new ActionListener()
+        {
+          @Override
+          public void actionPerformed(ActionEvent evt)
+          {
+            userColour_actionPerformed(evt);
+          }
+        });
+        colourMenu.add(radioItem);
+        colourButtons.add(radioItem);
+      }
+    }
     colourMenu.add(userColour);
     colourMenu.add(viewerColour);
     colourMenu.add(backGround);
 
-    ButtonGroup colourButtons = new ButtonGroup();
-
     colourButtons.add(seqColour);
     colourButtons.add(chainColour);
     colourButtons.add(chargeColour);
@@ -372,13 +455,6 @@ public abstract class GStructureViewer extends JInternalFrame implements
     colourButtons.add(purinePyrimidineColour);
     colourButtons.add(userColour);
     colourButtons.add(viewerColour);
-
-    helpMenu.add(helpItem);
-    viewerActionMenu.add(alignStructs);
-
-    statusPanel.setLayout(new GridLayout());
-    this.getContentPane().add(statusPanel, java.awt.BorderLayout.SOUTH);
-    statusPanel.add(statusBar, null);
   }
 
   protected void fitToWindow_actionPerformed()
@@ -467,6 +543,11 @@ public abstract class GStructureViewer extends JInternalFrame implements
 
   }
 
+  public void nucleotideColour_actionPerformed(ActionEvent actionEvent)
+  {
+
+  }
+
   public void purinePyrimidineColour_actionPerformed(ActionEvent actionEvent)
   {
 
index b5695b2..65deb5e 100755 (executable)
@@ -135,24 +135,27 @@ public class GUserDefinedColours extends JPanel
     okButton.setText(MessageManager.getString("action.ok"));
     okButton.addActionListener(new java.awt.event.ActionListener()
     {
+      @Override
       public void actionPerformed(ActionEvent e)
       {
-        okButton_actionPerformed(e);
+        okButton_actionPerformed();
       }
     });
     applyButton.setFont(new java.awt.Font("Verdana", 0, 11));
     applyButton.setText(MessageManager.getString("action.apply"));
-    applyButton.addActionListener(new java.awt.event.ActionListener()
+    applyButton.addActionListener(new ActionListener()
     {
+      @Override
       public void actionPerformed(ActionEvent e)
       {
-        applyButton_actionPerformed(e);
+        applyButton_actionPerformed();
       }
     });
     loadbutton.setFont(new java.awt.Font("Verdana", 0, 11));
     loadbutton.setText(MessageManager.getString("action.load_scheme"));
     loadbutton.addActionListener(new java.awt.event.ActionListener()
     {
+      @Override
       public void actionPerformed(ActionEvent e)
       {
         loadbutton_actionPerformed(e);
@@ -162,6 +165,7 @@ public class GUserDefinedColours extends JPanel
     savebutton.setText(MessageManager.getString("action.save_scheme"));
     savebutton.addActionListener(new java.awt.event.ActionListener()
     {
+      @Override
       public void actionPerformed(ActionEvent e)
       {
         savebutton_actionPerformed(e);
@@ -171,6 +175,7 @@ public class GUserDefinedColours extends JPanel
     cancelButton.setText(MessageManager.getString("action.cancel"));
     cancelButton.addActionListener(new java.awt.event.ActionListener()
     {
+      @Override
       public void actionPerformed(ActionEvent e)
       {
         cancelButton_actionPerformed(e);
@@ -206,6 +211,7 @@ public class GUserDefinedColours extends JPanel
     caseSensitive.setText(MessageManager.getString("label.case_sensitive"));
     caseSensitive.addActionListener(new ActionListener()
     {
+      @Override
       public void actionPerformed(ActionEvent e)
       {
         caseSensitive_actionPerformed(e);
@@ -215,6 +221,7 @@ public class GUserDefinedColours extends JPanel
             .setText(MessageManager.getString("label.lower_case_colour"));
     lcaseColour.addActionListener(new ActionListener()
     {
+      @Override
       public void actionPerformed(ActionEvent e)
       {
         lcaseColour_actionPerformed(e);
@@ -257,21 +264,15 @@ public class GUserDefinedColours extends JPanel
 
   /**
    * DOCUMENT ME!
-   * 
-   * @param e
-   *          DOCUMENT ME!
    */
-  protected void okButton_actionPerformed(ActionEvent e)
+  protected void okButton_actionPerformed()
   {
   }
 
   /**
    * DOCUMENT ME!
-   * 
-   * @param e
-   *          DOCUMENT ME!
    */
-  protected void applyButton_actionPerformed(ActionEvent e)
+  protected void applyButton_actionPerformed()
   {
   }
 
index de12086..88f3fdd 100644 (file)
@@ -64,6 +64,7 @@ import org.testng.annotations.Test;
 public class Jalview2xmlTests extends Jalview2xmlBase
 {
 
+  @Override
   @BeforeClass(alwaysRun = true)
   public void setUpJvOptionPane()
   {
@@ -82,7 +83,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
     assertTrue("Didn't read input file " + inFile, af != null);
     int olddsann = countDsAnn(af.getViewport());
     assertTrue("Didn't find any dataset annotations", olddsann > 0);
-    af.rnahelicesColour_actionPerformed(null);
+    af.rnahelicesColour_actionPerformed();
     assertTrue(
             "Couldn't apply RNA helices colourscheme",
             af.getViewport().getGlobalColourScheme() instanceof jalview.schemes.RNAHelicesColour);