User colours
authoramwaterhouse <Andrew Waterhouse>
Wed, 17 Aug 2005 09:09:18 +0000 (09:09 +0000)
committeramwaterhouse <Andrew Waterhouse>
Wed, 17 Aug 2005 09:09:18 +0000 (09:09 +0000)
src/jalview/gui/PopupMenu.java
src/jalview/jbgui/GAlignFrame.java

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