User colours are case sensitive
authoramwaterhouse <Andrew Waterhouse>
Wed, 30 Aug 2006 16:08:36 +0000 (16:08 +0000)
committeramwaterhouse <Andrew Waterhouse>
Wed, 30 Aug 2006 16:08:36 +0000 (16:08 +0000)
src/jalview/gui/Jalview2XML.java
src/jalview/gui/UserDefinedColours.java
src/jalview/jbgui/GUserDefinedColours.java
src/jalview/schemes/UserColourScheme.java

index e65f37d..be03a9c 100755 (executable)
@@ -719,9 +719,21 @@ public class Jalview2XML
             for (int i = 0; i < colours.length; i++)
             {
                 jalview.schemabinding.version2.Colour col = new jalview.schemabinding.version2.Colour();
+                col.setName(ResidueProperties.aa[i]);
                 col.setRGB(jalview.util.Format.getHexString(colours[i]));
                 jbucs.addColour(col);
             }
+            if(ucs.getLowerCaseColours()!=null)
+            {
+              colours = ucs.getLowerCaseColours();
+              for (int i = 0; i < colours.length; i++)
+             {
+                 jalview.schemabinding.version2.Colour col = new jalview.schemabinding.version2.Colour();
+                 col.setName(ResidueProperties.aa[i].toLowerCase());
+                 col.setRGB(jalview.util.Format.getHexString(colours[i]));
+                 jbucs.addColour(col);
+             }
+            }
 
             id = "ucs" + userColours.indexOf(ucs);
             uc.setId(id);
@@ -748,16 +760,29 @@ public class Jalview2XML
             }
         }
 
-        int csize = colours.getUserColourScheme().getColourCount();
-        java.awt.Color[] newColours = new java.awt.Color[csize];
+        java.awt.Color[] newColours = new java.awt.Color[24];
 
-        for (int i = 0; i < csize; i++)
+        for (int i = 0; i < 24; i++)
         {
             newColours[i] = new java.awt.Color(Integer.parseInt(
                         colours.getUserColourScheme().getColour(i).getRGB(), 16));
         }
 
-        return new jalview.schemes.UserColourScheme(newColours);
+        jalview.schemes.UserColourScheme ucs =
+            new jalview.schemes.UserColourScheme(newColours);
+
+        if (colours.getUserColourScheme().getColourCount() > 24)
+        {
+          newColours = new java.awt.Color[23];
+          for (int i = 0; i < 23; i++)
+          {
+            newColours[i] = new java.awt.Color(Integer.parseInt(
+                colours.getUserColourScheme().getColour(i+24).getRGB(), 16));
+          }
+          ucs.setLowerCaseColours(newColours);
+        }
+
+        return ucs;
     }
 
     /**
index 8deec8e..2369049 100755 (executable)
@@ -53,6 +53,9 @@ public class UserDefinedColours extends GUserDefinedColours
     ColourSchemeI oldColourScheme;\r
     JInternalFrame frame;\r
     MCview.PDBCanvas pdbcanvas;\r
+    Vector upperCaseButtons;\r
+    Vector lowerCaseButtons;\r
+\r
 \r
     /**\r
      * Creates a new UserDefinedColours object.\r
@@ -63,63 +66,39 @@ public class UserDefinedColours extends GUserDefinedColours
     public UserDefinedColours(AlignmentPanel ap, SequenceGroup sg)\r
     {\r
         super();\r
-        frame = new JInternalFrame();\r
-        frame.setContentPane(this);\r
-        Desktop.addInternalFrame(frame, "User Defined Colours", 720, 370, true);\r
-\r
-        if (System.getProperty("os.name").startsWith("Mac"))\r
-        {\r
-            frame.setSize(760, 370);\r
-        }\r
-\r
-        if (sg != null)\r
-        {\r
-            frame.setTitle(frame.getTitle() + " (" + sg.getName() + ")");\r
-        }\r
-\r
-        colorChooser.getSelectionModel().addChangeListener(this);\r
+        lcaseColour.setEnabled(false);\r
 \r
         this.ap = ap;\r
         seqGroup = sg;\r
 \r
         if (seqGroup != null)\r
-        {\r
             oldColourScheme = seqGroup.cs;\r
-        }\r
         else\r
-        {\r
             oldColourScheme = ap.av.getGlobalColourScheme();\r
-        }\r
 \r
         if (oldColourScheme instanceof UserColourScheme)\r
         {\r
-              schemeName.setText( ( (UserColourScheme) oldColourScheme).getName());\r
-        }\r
-        for (int i = 0; i < 20; i++)\r
-        {\r
-            makeButton(ResidueProperties.aa2Triplet.get(ResidueProperties.aa[i]) +\r
-                "", ResidueProperties.aa[i]);\r
+          schemeName.setText( ( (UserColourScheme) oldColourScheme).getName());\r
+          if(( (UserColourScheme) oldColourScheme).getLowerCaseColours()!=null)\r
+          {\r
+            caseSensitive.setSelected(true);\r
+            lcaseColour.setEnabled(true);\r
+            resetButtonPanel(true);\r
+          }\r
+          else\r
+            resetButtonPanel(false);\r
         }\r
+        else\r
+           resetButtonPanel(false);\r
 \r
-        makeButton("B", "B");\r
-        makeButton("Z", "Z");\r
-        makeButton("X", "X");\r
-        makeButton("Gap", "-");\r
+        showFrame();\r
     }\r
 \r
     public UserDefinedColours(MCview.PDBCanvas pdb, ColourSchemeI oldcs)\r
     {\r
         super();\r
-        frame = new JInternalFrame();\r
-        frame.setContentPane(this);\r
-        Desktop.addInternalFrame(frame, "User Defined Colours", 720, 370, true);\r
         pdbcanvas = pdb;\r
 \r
-        if (System.getProperty("os.name").startsWith("Mac"))\r
-        {\r
-            frame.setSize(760, 370);\r
-        }\r
-\r
         colorChooser.getSelectionModel().addChangeListener(this);\r
 \r
         oldColourScheme = oldcs;\r
@@ -128,16 +107,98 @@ public class UserDefinedColours extends GUserDefinedColours
         {\r
               schemeName.setText( ( (UserColourScheme) oldColourScheme).getName());\r
         }\r
-        for (int i = 0; i < 20; i++)\r
-        {\r
-            makeButton(ResidueProperties.aa2Triplet.get(ResidueProperties.aa[i]) +\r
-                "", ResidueProperties.aa[i]);\r
-        }\r
 \r
-        makeButton("B", "B");\r
-        makeButton("Z", "Z");\r
-        makeButton("X", "X");\r
-        makeButton("Gap", "-");\r
+        resetButtonPanel(false);\r
+\r
+        showFrame();\r
+\r
+    }\r
+\r
+    void showFrame()\r
+    {\r
+      colorChooser.getSelectionModel().addChangeListener(this);\r
+      frame = new JInternalFrame();\r
+      frame.setContentPane(this);\r
+      Desktop.addInternalFrame(frame, "User Defined Colours", 720, 370, true);\r
+\r
+      if (seqGroup != null)\r
+            frame.setTitle(frame.getTitle() + " (" + seqGroup.getName() + ")");\r
+\r
+      if (System.getProperty("os.name").startsWith("Mac"))\r
+      {\r
+        frame.setSize(760, 370);\r
+      }\r
+    }\r
+\r
+    void resetButtonPanel(boolean caseSensitive)\r
+    {\r
+      buttonPanel.removeAll();\r
+\r
+\r
+      if(upperCaseButtons==null)\r
+        upperCaseButtons = new Vector();\r
+\r
+      JButton button;\r
+      String label;\r
+      for (int i = 0; i < 20; i++)\r
+      {\r
+        if(caseSensitive)\r
+          label = ResidueProperties.aa[i];\r
+        else\r
+          label = ResidueProperties.aa2Triplet.get\r
+              (ResidueProperties.aa[i]).toString();\r
+\r
+        button = makeButton(label,\r
+                              ResidueProperties.aa[i],\r
+                              upperCaseButtons, i);\r
+\r
+        buttonPanel.add(button);\r
+      }\r
+\r
+        buttonPanel.add(makeButton("B", "B", upperCaseButtons, 20));\r
+        buttonPanel.add(makeButton("Z", "Z", upperCaseButtons, 21));\r
+        buttonPanel.add(makeButton("X", "X", upperCaseButtons, 22));\r
+        buttonPanel.add(makeButton("Gap", "-", upperCaseButtons, 23));\r
+\r
+      if(!caseSensitive)\r
+      {\r
+        gridLayout.setRows(6);\r
+        gridLayout.setColumns(4);\r
+      }\r
+      else\r
+      {\r
+        gridLayout.setRows(7);\r
+        int cols = 7;\r
+        gridLayout.setColumns(cols+1);\r
+\r
+        if(lowerCaseButtons==null)\r
+          lowerCaseButtons = new Vector();\r
+\r
+\r
+          for (int i = 0; i < 20; i++)\r
+          {\r
+            int row = i / cols + 1;\r
+            int index = (row * cols) + i;\r
+            button = makeButton(\r
+                ResidueProperties.aa[i].toLowerCase(),\r
+                ResidueProperties.aa[i].toLowerCase(),\r
+                lowerCaseButtons,\r
+                i);\r
+\r
+            buttonPanel.add(button, index);\r
+          }\r
+      }\r
+\r
+\r
+      if(caseSensitive)\r
+      {\r
+        buttonPanel.add(makeButton("b", "b", lowerCaseButtons, 20));\r
+        buttonPanel.add(makeButton("z", "z", lowerCaseButtons, 21));\r
+        buttonPanel.add(makeButton("x", "x", lowerCaseButtons, 22));\r
+      }\r
+\r
+      buttonPanel.validate();\r
+      validate();\r
     }\r
 \r
 \r
@@ -150,13 +211,22 @@ public class UserDefinedColours extends GUserDefinedColours
     {\r
         if (selectedButtons != null)\r
         {\r
-          JButton button;\r
+          JButton button=null;\r
           for(int i=0; i<selectedButtons.size(); i++)\r
           {\r
             button = (JButton)selectedButtons.elementAt(i);\r
             button.setBackground(colorChooser.getColor());\r
             button.setForeground( button.getBackground().brighter().brighter().brighter());\r
           }\r
+          if(button==lcaseColour)\r
+          {\r
+            for(int i=0; i<lowerCaseButtons.size(); i++)\r
+            {\r
+              button = (JButton)lowerCaseButtons.elementAt(i);\r
+              button.setBackground(colorChooser.getColor());\r
+              button.setForeground( button.getBackground().brighter().brighter().brighter());\r
+            }\r
+          }\r
         }\r
     }\r
 \r
@@ -242,33 +312,53 @@ public class UserDefinedColours extends GUserDefinedColours
      * @param label DOCUMENT ME!\r
      * @param aa DOCUMENT ME!\r
      */\r
-    void makeButton(String label, String aa)\r
+    JButton makeButton(String label,\r
+                       String aa,\r
+                       Vector caseSensitiveButtons,\r
+                       int buttonIndex)\r
     {\r
-        final JButton button = new JButton();\r
-        Color col = Color.white;\r
+        final JButton button;\r
+        Color col;\r
 \r
-        try\r
+        if(buttonIndex<caseSensitiveButtons.size())\r
         {\r
-            col = oldColourScheme.findColour(aa, -1);\r
+          button = (JButton) caseSensitiveButtons.elementAt(buttonIndex);\r
+          col = button.getBackground();\r
         }\r
-        catch (Exception ex)\r
+        else\r
         {\r
-        //  ex.printStackTrace();\r
+          button = new JButton();\r
+          button.addMouseListener(new java.awt.event.MouseAdapter()\r
+          {\r
+            public void mouseClicked(MouseEvent e)\r
+            {\r
+              colourButtonPressed(e);\r
+            }\r
+          });\r
+\r
+          caseSensitiveButtons.addElement(button);\r
+\r
+          col = Color.white;\r
+\r
+          try\r
+          {\r
+            col = oldColourScheme.findColour(aa, -1);\r
+          }\r
+          catch (Exception ex)\r
+          {    }\r
         }\r
 \r
+        if(caseSensitive.isSelected())\r
+          button.setMargin(new java.awt.Insets(2,2,2,2));\r
+        else\r
+          button.setMargin(new java.awt.Insets(2,14,2,14));\r
+\r
         button.setBackground(col);\r
         button.setText(label);\r
         button.setForeground(col.darker().darker().darker());\r
-        button.setFont(new java.awt.Font("Verdana", 1, 10));\r
-        button.addMouseListener(new java.awt.event.MouseAdapter()\r
-            {\r
-                public void mouseClicked(MouseEvent e)\r
-                {\r
-                    colourButtonPressed(e);\r
-                }\r
-            });\r
+        button.setFont(new java.awt.Font("Verdana", Font.BOLD, 10));\r
 \r
-        buttonPanel.add(button, null);\r
+        return button;\r
     }\r
 \r
     /**\r
@@ -296,7 +386,7 @@ public class UserDefinedColours extends GUserDefinedColours
      */\r
     protected void applyButton_actionPerformed(ActionEvent e)\r
     {\r
-        UserColourScheme ucs = getSchemeFromGUI();\r
+        UserColourScheme ucs = getSchemeFromButtons();\r
         ucs.setName(schemeName.getText());\r
 \r
         if (seqGroup != null)\r
@@ -315,17 +405,31 @@ public class UserDefinedColours extends GUserDefinedColours
         }\r
     }\r
 \r
-    UserColourScheme getSchemeFromGUI()\r
+    UserColourScheme getSchemeFromButtons()\r
     {\r
+\r
       Color[] newColours = new Color[24];\r
 \r
       for (int i = 0; i < 24; i++)\r
       {\r
-        JButton button = (JButton) buttonPanel.getComponent(i);\r
+        JButton button = (JButton) upperCaseButtons.elementAt(i);\r
         newColours[i] = button.getBackground();\r
       }\r
 \r
       UserColourScheme ucs = new UserColourScheme(newColours);\r
+\r
+\r
+      if(caseSensitive.isSelected())\r
+      {\r
+        newColours = new Color[23];\r
+        for (int i = 0; i < 23; i++)\r
+        {\r
+          JButton button = (JButton) lowerCaseButtons.elementAt(i);\r
+          newColours[i] = button.getBackground();\r
+        }\r
+        ucs.setLowerCaseColours(newColours);\r
+      }\r
+\r
       if(ap!=null)\r
         ucs.setThreshold(0, ap.av.getIgnoreGapsConsensus());\r
 \r
@@ -342,6 +446,9 @@ public class UserDefinedColours extends GUserDefinedColours
      */\r
     protected void loadbutton_actionPerformed(ActionEvent e)\r
     {\r
+      upperCaseButtons = new Vector();\r
+      lowerCaseButtons = new Vector();\r
+\r
         JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty(\r
                     "LAST_DIRECTORY"), new String[] { "jc" },\r
                 new String[] { "Jalview User Colours" }, "Jalview User Colours");\r
@@ -367,11 +474,31 @@ public class UserDefinedColours extends GUserDefinedColours
             Color[] colors = ucs.getColours();\r
             schemeName.setText(ucs.getName());\r
 \r
-            for (int i = 0; i < colors.length; i++)\r
+            if(ucs.getLowerCaseColours()!=null)\r
+            {\r
+              caseSensitive.setSelected(true);\r
+              lcaseColour.setEnabled(true);\r
+              resetButtonPanel(true);\r
+              for (int i = 0; i < lowerCaseButtons.size(); i++)\r
+              {\r
+                JButton button = (JButton) lowerCaseButtons.elementAt(i);\r
+                button.setBackground(ucs.getLowerCaseColours()[i]);\r
+              }\r
+\r
+            }\r
+            else\r
+            {\r
+              caseSensitive.setSelected(false);\r
+              lcaseColour.setEnabled(false);\r
+              resetButtonPanel(false);\r
+            }\r
+\r
+            for (int i = 0; i < upperCaseButtons.size(); i++)\r
             {\r
-                JButton button = (JButton) buttonPanel.getComponent(i);\r
+                JButton button = (JButton) upperCaseButtons.elementAt(i);\r
                 button.setBackground(colors[i]);\r
             }\r
+\r
         }\r
     }\r
 \r
@@ -417,7 +544,6 @@ public class UserDefinedColours extends GUserDefinedColours
     {\r
          UserColourScheme ucs = null;\r
          Color[]  newColours = null;\r
-\r
         try\r
         {\r
             InputStreamReader in = new InputStreamReader(new FileInputStream(\r
@@ -430,17 +556,51 @@ public class UserDefinedColours extends GUserDefinedColours
                   = new org.exolab.castor.xml.Unmarshaller(jucs);\r
               jucs = (jalview.schemabinding.version2.JalviewUserColours) unmar.unmarshal( in );\r
 \r
-              newColours = new Color[jucs.getColourCount()];\r
+              newColours = new Color[24];\r
+\r
+              Color [] lowerCase = null;\r
+              boolean caseSensitive = false;\r
+\r
 \r
-            for (int i = 0; i < 24; i++)\r
+            String name;\r
+            int index;\r
+            for (int i = 0; i < jucs.getColourCount(); i++)\r
             {\r
-              newColours[i] = new Color(Integer.parseInt(\r
+              name =  jucs.getColour(i).getName();\r
+              if(ResidueProperties.aa3Hash.containsKey(name))\r
+              {\r
+                index = ((Integer)ResidueProperties.aa3Hash.get(name)).intValue();\r
+              }\r
+              else\r
+              {\r
+                index = ((Integer)ResidueProperties.aaHash.get(name)).intValue();\r
+              }\r
+              if(index == -1)\r
+                continue;\r
+\r
+              if(name.toLowerCase().equals(name))\r
+              {\r
+                if(lowerCase==null)\r
+                   lowerCase = new Color[23];\r
+                caseSensitive = true;\r
+                lowerCase[index] = new Color(Integer.parseInt(\r
                   jucs.getColour(i).getRGB(), 16));\r
+              }\r
+              else\r
+              {\r
+                newColours[index] = new Color(Integer.parseInt(\r
+                    jucs.getColour(i).getRGB(), 16));\r
+              }\r
             }\r
+\r
             if (newColours != null)\r
             {\r
               ucs = new UserColourScheme(newColours);\r
               ucs.setName( jucs.getSchemeName() );\r
+              if(caseSensitive)\r
+              {\r
+                ucs.setLowerCaseColours(lowerCase);\r
+              }\r
             }\r
 \r
         }\r
@@ -525,23 +685,26 @@ public class UserDefinedColours extends GUserDefinedColours
               defaultColours = defaultColours.concat(choice);\r
             }\r
 \r
-            userColourSchemes.put(schemeName.getText(), getSchemeFromGUI());\r
+            userColourSchemes.put(schemeName.getText(), getSchemeFromButtons());\r
 \r
             ap.alignFrame.updateUserColourMenu();\r
 \r
             jalview.bin.Cache.setProperty("USER_DEFINED_COLOURS", defaultColours);\r
 \r
-            jalview.binding.JalviewUserColours ucs = new jalview.binding.JalviewUserColours();\r
+            jalview.schemabinding.version2.JalviewUserColours ucs\r
+                = new jalview.schemabinding.version2.JalviewUserColours();\r
+\r
             ucs.setSchemeName(schemeName.getText());\r
             try\r
             {\r
                 PrintWriter out = new PrintWriter(new OutputStreamWriter(\r
                             new FileOutputStream(choice), "UTF-8"));\r
 \r
-                for (int i = 0; i < 24; i++)\r
+                for (int i = 0; i < buttonPanel.getComponentCount(); i++)\r
                 {\r
                     JButton button = (JButton) buttonPanel.getComponent(i);\r
-                    jalview.binding.Colour col = new jalview.binding.Colour();\r
+                    jalview.schemabinding.version2.Colour col\r
+                        = new jalview.schemabinding.version2.Colour();\r
                     col.setName(button.getText());\r
                     col.setRGB(jalview.util.Format.getHexString(\r
                             button.getBackground()));\r
@@ -679,4 +842,20 @@ public class UserDefinedColours extends GUserDefinedColours
         jalview.bin.Cache.applicationProperties.remove("USER_DEFINED_COLOURS");\r
 \r
     }\r
+\r
+    public void caseSensitive_actionPerformed(ActionEvent e)\r
+    {\r
+      resetButtonPanel(caseSensitive.isSelected());\r
+      lcaseColour.setEnabled(caseSensitive.isSelected());\r
+    }\r
+\r
+    public void lcaseColour_actionPerformed(ActionEvent e)\r
+    {\r
+      if(selectedButtons==null)\r
+        selectedButtons = new Vector();\r
+      else\r
+        selectedButtons.clear();\r
+      selectedButtons.add(lcaseColour);\r
+    }\r
+\r
 }\r
index 31bc09c..60ce4f4 100755 (executable)
@@ -22,7 +22,7 @@ import java.awt.*;
 import java.awt.event.*;\r
 \r
 import javax.swing.*;\r
-\r
+import java.awt.Dimension;\r
 \r
 /**\r
  * DOCUMENT ME!\r
@@ -35,7 +35,7 @@ public class GUserDefinedColours extends JPanel
     protected JColorChooser colorChooser = new JColorChooser();\r
     protected JPanel buttonPanel = new JPanel();\r
     protected GridLayout gridLayout = new GridLayout();\r
-    JPanel jPanel2 = new JPanel();\r
+    JPanel lowerPanel = new JPanel();\r
     protected JButton okButton = new JButton();\r
     protected JButton applyButton = new JButton();\r
     protected JButton loadbutton = new JButton();\r
@@ -46,8 +46,8 @@ public class GUserDefinedColours extends JPanel
   protected JTextField schemeName = new JTextField();\r
   BorderLayout borderLayout1 = new BorderLayout();\r
   JPanel panel1 = new JPanel();\r
-  JPanel jPanel1 = new JPanel();\r
-  JPanel jPanel3 = new JPanel();\r
+  JPanel okCancelPanel = new JPanel();\r
+  JPanel saveLoadPanel = new JPanel();\r
   BorderLayout borderLayout3 = new BorderLayout();\r
   GridBagLayout gridBagLayout1 = new GridBagLayout();\r
   BorderLayout borderLayout2 = new BorderLayout();\r
@@ -55,8 +55,10 @@ public class GUserDefinedColours extends JPanel
   BorderLayout borderLayout4 = new BorderLayout();\r
   JPanel jPanel4 = new JPanel();\r
   BorderLayout borderLayout5 = new BorderLayout();\r
-  JPanel jPanel6 = new JPanel();\r
   JLabel label = new JLabel();\r
+  JPanel casePanel = new JPanel();\r
+  protected JCheckBox caseSensitive = new JCheckBox();\r
+  protected JButton lcaseColour = new JButton();\r
   /**\r
      * Creates a new GUserDefinedColours object.\r
      */\r
@@ -82,7 +84,7 @@ public class GUserDefinedColours extends JPanel
         this.setLayout(borderLayout4);\r
         buttonPanel.setLayout(gridLayout);\r
         gridLayout.setColumns(4);\r
-        gridLayout.setRows(6);\r
+        gridLayout.setRows(5);\r
         okButton.setFont(new java.awt.Font("Verdana", 0, 11));\r
         okButton.setText("OK");\r
         okButton.addActionListener(new java.awt.event.ActionListener()\r
@@ -129,8 +131,8 @@ public class GUserDefinedColours extends JPanel
                 }\r
             });\r
         this.setBackground(new Color(212, 208, 223));\r
-        jPanel2.setOpaque(false);\r
-    jPanel2.setLayout(borderLayout3);\r
+    lowerPanel.setOpaque(false);\r
+    lowerPanel.setLayout(borderLayout3);\r
     colorChooser.setOpaque(false);\r
     jLabel1.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
     jLabel1.setText("Name");\r
@@ -145,38 +147,51 @@ public class GUserDefinedColours extends JPanel
     schemeName.setHorizontalAlignment(SwingConstants.CENTER);\r
     panel1.setLayout(flowLayout1);\r
     panel1.setOpaque(false);\r
-    jPanel1.setOpaque(false);\r
-    jPanel3.setOpaque(false);\r
+    okCancelPanel.setOpaque(false);\r
+    saveLoadPanel.setOpaque(false);\r
     jPanel4.setLayout(borderLayout5);\r
-    jPanel6.setBackground(Color.pink);\r
-    jPanel6.setMinimumSize(new Dimension(10, 70));\r
-    jPanel6.setOpaque(false);\r
-    jPanel6.setPreferredSize(new Dimension(10, 45));\r
-    jPanel6.setLayout(null);\r
     label.setFont(new java.awt.Font("Verdana", Font.ITALIC, 10));\r
     label.setOpaque(false);\r
     label.setPreferredSize(new Dimension(260, 34));\r
     label.setText(\r
         "<html>Save your colour scheme with a unique name and it will be added " +\r
         "to the Colour menu.</html>");\r
+    caseSensitive.setText("Case Sensitive");\r
+    caseSensitive.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent e)\r
+      {\r
+        caseSensitive_actionPerformed(e);\r
+      }\r
+    });\r
+    lcaseColour.setText("Lower Case Colour");\r
+    lcaseColour.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent e)\r
+      {\r
+        lcaseColour_actionPerformed(e);\r
+      }\r
+    });\r
 \r
-    jPanel3.add(savebutton);\r
-    jPanel3.add(loadbutton);\r
-    jPanel1.add(applyButton);\r
-    jPanel1.add(okButton);\r
-    jPanel1.add(cancelButton);\r
-    jPanel2.add(jPanel3, java.awt.BorderLayout.NORTH);\r
-    jPanel2.add(jPanel1, java.awt.BorderLayout.SOUTH);\r
+    saveLoadPanel.add(savebutton);\r
+    saveLoadPanel.add(loadbutton);\r
+    okCancelPanel.add(applyButton);\r
+    okCancelPanel.add(okButton);\r
+    okCancelPanel.add(cancelButton);\r
+    lowerPanel.add(saveLoadPanel, java.awt.BorderLayout.NORTH);\r
+    lowerPanel.add(okCancelPanel, java.awt.BorderLayout.SOUTH);\r
 \r
     namePanel.add(schemeName, java.awt.BorderLayout.CENTER);\r
     namePanel.add(jLabel1, java.awt.BorderLayout.WEST);\r
     panel1.add(namePanel, null);\r
     panel1.add(buttonPanel, null);\r
-    panel1.add(jPanel2, null);\r
+    panel1.add(casePanel);\r
+    casePanel.add(caseSensitive);\r
+    casePanel.add(lcaseColour);\r
+    panel1.add(lowerPanel, null);\r
     panel1.add(label);\r
 \r
     jPanel4.add(panel1, java.awt.BorderLayout.CENTER);\r
-    jPanel4.add(jPanel6, java.awt.BorderLayout.NORTH);\r
     this.add(jPanel4, java.awt.BorderLayout.CENTER);\r
     this.add(colorChooser, java.awt.BorderLayout.EAST);\r
   }\r
@@ -225,4 +240,14 @@ public class GUserDefinedColours extends JPanel
     protected void cancelButton_actionPerformed(ActionEvent e)\r
     {\r
     }\r
+\r
+    public void caseSensitive_actionPerformed(ActionEvent e)\r
+    {\r
+\r
+    }\r
+\r
+    public void lcaseColour_actionPerformed(ActionEvent e)\r
+    {\r
+\r
+    }\r
 }\r
index e5efb1a..95e9a32 100755 (executable)
@@ -24,6 +24,8 @@ import java.util.StringTokenizer;
 public class UserColourScheme\r
     extends ResidueColourScheme\r
 {\r
+  Color [] lowerCaseColours;\r
+\r
   protected String schemeName;\r
 \r
   public UserColourScheme()\r
@@ -54,6 +56,11 @@ public class UserColourScheme
     return colors;\r
   }\r
 \r
+  public Color[] getLowerCaseColours()\r
+  {\r
+    return lowerCaseColours;\r
+  }\r
+\r
   public void setName(String name)\r
   {\r
     schemeName = name;\r
@@ -127,7 +134,7 @@ public class UserColourScheme
   {\r
     StringTokenizer st = new StringTokenizer(paramValue, ";");\r
     StringTokenizer st2;\r
-    String token=null, colour, residues;\r
+    String token=null, colour, residues, residue;\r
     try{\r
       while (st.hasMoreElements())\r
       {\r
@@ -138,11 +145,32 @@ public class UserColourScheme
         st2 = new StringTokenizer(residues, " ,");\r
         while (st2.hasMoreTokens())\r
         {\r
+          token = st2.nextToken();\r
+          if(token.equalsIgnoreCase("lowerCase"))\r
+          {\r
+            if (lowerCaseColours == null)\r
+              lowerCaseColours = new Color[23];\r
+            for (int i = 0; i < 23; i++)\r
+              if (lowerCaseColours[i] == null)\r
+                lowerCaseColours[i] = getColourFromString(colour);\r
+\r
+              continue;\r
+          }\r
+\r
           int colIndex =\r
               ( (Integer) ResidueProperties.aaHash.\r
-               get(st2.nextToken())).intValue();\r
-\r
-          colors[colIndex] = getColourFromString(colour);\r
+               get(token)).intValue();\r
+\r
+          if(token.equals(token.toLowerCase()))\r
+          {\r
+            if(lowerCaseColours==null)\r
+            {\r
+              lowerCaseColours = new Color[23];\r
+            }\r
+            lowerCaseColours[colIndex] = getColourFromString(colour);\r
+          }\r
+          else\r
+            colors[colIndex] = getColourFromString(colour);\r
         }\r
       }\r
     }\r
@@ -154,4 +182,34 @@ public class UserColourScheme
 \r
   }\r
 \r
+\r
+\r
+  public Color findColour(String s, int j)\r
+  {\r
+      int index = ((Integer) (ResidueProperties.aaHash.get(s))).intValue();\r
+\r
+      if ((threshold == 0) || aboveThreshold(ResidueProperties.aa[index], j))\r
+      {\r
+        if(lowerCaseColours!=null && 'a' <= s.charAt(0) && s.charAt(0) <= 'z')\r
+          currentColour = lowerCaseColours[index];\r
+        else\r
+          currentColour = colors[index];\r
+      }\r
+      else\r
+      {\r
+          currentColour = Color.white;\r
+      }\r
+\r
+      if(conservationColouring)\r
+        applyConservation(j);\r
+\r
+\r
+      return currentColour;\r
+   }\r
+\r
+   public void setLowerCaseColours(Color [] lcolours)\r
+   {\r
+     lowerCaseColours = lcolours;\r
+   }\r
+\r
 }\r