All colours added to Structure viewer
authoramwaterhouse <Andrew Waterhouse>
Fri, 9 Dec 2005 13:34:46 +0000 (13:34 +0000)
committeramwaterhouse <Andrew Waterhouse>
Fri, 9 Dec 2005 13:34:46 +0000 (13:34 +0000)
src/MCview/AppletPDBViewer.java
src/MCview/PDBCanvas.java
src/MCview/PDBChain.java
src/MCview/PDBViewer.java
src/MCview/PDBfile.java

index b2931ae..901297b 100755 (executable)
@@ -190,7 +190,7 @@ public class AppletPDBViewer extends Frame
       public void hydro_actionPerformed()\r
       {\r
         clearButtonGroup();\r
-        pdbcanvas.pdb.setHydrophobicityColours();\r
+       // pdbcanvas.pdb.setHydrophobicityColours();\r
         pdbcanvas.redrawneeded=true;\r
         pdbcanvas.repaint();\r
       }\r
index d5af60f..6014455 100755 (executable)
@@ -932,6 +932,8 @@ public class PDBCanvas extends JPanel implements MouseListener, MouseMotionListe
    Bond highlightBond1, highlightBond2;\r
    public void highlightRes(int ii)\r
   {\r
+    if( !seqColoursReady )\r
+      return;\r
 \r
     if (highlightRes != null\r
         && highlightRes.contains((ii-1) + ""))\r
index 0715b6a..fa4bbf9 100755 (executable)
@@ -228,44 +228,27 @@ public class PDBChain {
         }\r
     }\r
 \r
-    public void setHydrophobicityColours() {\r
-        float hydmin = (float) ResidueProperties.getHydmin();\r
-        float hydmax = (float) ResidueProperties.getHydmax();\r
-        double[] hyd = ResidueProperties.getHyd();\r
-\r
-        Hashtable AA3Hash = ResidueProperties.getAA3Hash();\r
 \r
+    public void setChainColours(jalview.schemes.ColourSchemeI cs)\r
+    {\r
+        Bond b;\r
         for (int i = 0; i < bonds.size(); i++) {\r
             try {\r
-                Bond b = (Bond) bonds.elementAt(i);\r
-\r
-                int atno = ((Integer) AA3Hash.get(b.at1.resName.toUpperCase())).intValue();\r
-                float red = ((float) hyd[atno] - hydmin) / (hydmax - hydmin);\r
-\r
-                if (red > (float) 1.0) {\r
-                    red = (float) 1.0;\r
-                }\r
-\r
-                if (red < (float) 0.0) {\r
-                    red = (float) 0.0;\r
-                }\r
+              b = (Bond) bonds.elementAt(i);\r
 \r
-                b.startCol = new Color(red, (float) 0.0, (float) 1.0 - red);\r
-                atno = ((Integer) AA3Hash.get(b.at2.resName.toUpperCase())).intValue();\r
+              ( (Bond) bonds.elementAt(i)).startCol = cs.findColour(\r
+                  ResidueProperties.aa[ ( (Integer) ResidueProperties.aa3Hash.\r
+                                         get(b.at1.resName)).intValue()]\r
+                  );\r
 \r
-                red = ((float) hyd[atno] - hydmin) / (hydmax - hydmin);\r
+              b.endCol = cs.findColour(\r
+                  ResidueProperties.aa[ ( (Integer) ResidueProperties.aa3Hash.\r
+                                         get(b.at2.resName)).intValue()]\r
+                  );\r
 \r
-                if (red > (float) 1.0) {\r
-                    red = (float) 1.0;\r
-                }\r
-\r
-                if (red < (float) 0.0) {\r
-                    red = (float) 0.0;\r
-                }\r
-\r
-                b.endCol = new Color(red, (float) 0.2, (float) 1.0 - red);\r
-            } catch (Exception e) {\r
-                Bond b = (Bond) bonds.elementAt(i);\r
+            } catch (Exception e)\r
+            {\r
+                b = (Bond) bonds.elementAt(i);\r
                 b.startCol = Color.gray;\r
                 b.endCol = Color.gray;\r
             }\r
index 817e59d..50a4a36 100755 (executable)
@@ -21,6 +21,7 @@ package MCview;
 import javax.swing.*;\r
 import java.awt.event.*;\r
 import jalview.datamodel.*;\r
+import jalview.schemes.*;\r
 import jalview.gui.*;\r
 import jalview.io.EBIFetchClient;\r
 import java.awt.event.ActionListener;\r
@@ -37,13 +38,7 @@ public class PDBViewer extends JInternalFrame implements Runnable
                    Sequence seq,\r
                    SeqCanvas seqcanvas)\r
   {\r
-\r
-    pdb = entry;\r
-    sequence = seq;\r
-\r
-    Thread worker = new Thread(this);\r
-    worker.start();\r
-\r
+    /*Uncomment this to modify in Jbuilder\r
     try\r
     {\r
       jbInit();\r
@@ -51,7 +46,14 @@ public class PDBViewer extends JInternalFrame implements Runnable
     catch (Exception ex)\r
     {\r
       ex.printStackTrace();\r
-    }\r
+    }*/\r
+\r
+\r
+    pdb = entry;\r
+    sequence = seq;\r
+\r
+    Thread worker = new Thread(this);\r
+    worker.start();\r
 \r
     pdbcanvas = new PDBCanvas(seqcanvas, seq);\r
 \r
@@ -79,6 +81,14 @@ public class PDBViewer extends JInternalFrame implements Runnable
 \r
       pdbcanvas.setPDBFile(pdbfile);\r
 \r
+      try\r
+      {\r
+        jbInit();\r
+      }\r
+      catch (Exception ex)\r
+      {\r
+        ex.printStackTrace();\r
+      }\r
     }\r
     catch (Exception ex)\r
     {\r
@@ -160,14 +170,6 @@ public class PDBViewer extends JInternalFrame implements Runnable
         charge_actionPerformed(e);\r
       }\r
     });\r
-    hydro.setText("Hydrophobicity");\r
-    hydro.addActionListener(new ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent e)\r
-      {\r
-        hydro_actionPerformed(e);\r
-      }\r
-    });\r
     chain.setText("By Chain");\r
     chain.addActionListener(new ActionListener()\r
     {\r
@@ -185,14 +187,6 @@ public class PDBViewer extends JInternalFrame implements Runnable
         seqButton_actionPerformed(e);\r
       }\r
     });\r
-    molecule.setText("By Molecule");\r
-    molecule.addActionListener(new ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent e)\r
-      {\r
-        molecule_actionPerformed(e);\r
-      }\r
-    });\r
     allchains.setSelected(true);\r
     allchains.setText("Show All Chains");\r
     allchains.addItemListener(new ItemListener()\r
@@ -202,27 +196,157 @@ public class PDBViewer extends JInternalFrame implements Runnable
         allchains_itemStateChanged(e);\r
       }\r
     });\r
+    zappo.setText("Zappo");\r
+    zappo.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent e)\r
+      {\r
+        zappo_actionPerformed(e);\r
+      }\r
+    });\r
+    taylor.setText("Taylor");\r
+    taylor.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent e)\r
+      {\r
+        taylor_actionPerformed(e);\r
+      }\r
+    });\r
+    hydro.setText("Hydro");\r
+    hydro.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent e)\r
+      {\r
+        hydro_actionPerformed(e);\r
+      }\r
+    });\r
+    helix.setText("Helix");\r
+    helix.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent e)\r
+      {\r
+        helix_actionPerformed(e);\r
+      }\r
+    });\r
+    strand.setText("Strand");\r
+    strand.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent e)\r
+      {\r
+        strand_actionPerformed(e);\r
+      }\r
+    });\r
+    turn.setText("Turn");\r
+    turn.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent e)\r
+      {\r
+        turn_actionPerformed(e);\r
+      }\r
+    });\r
+    buried.setText("Buried");\r
+    buried.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent e)\r
+      {\r
+        buried_actionPerformed(e);\r
+      }\r
+    });\r
+    user.setText("User Defined...");\r
+    user.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent e)\r
+      {\r
+        user_actionPerformed(e);\r
+      }\r
+    });\r
+    viewMenu.setText("View");\r
     jMenuBar1.add(fileMenu);\r
     jMenuBar1.add(coloursMenu);\r
+    jMenuBar1.add(viewMenu);\r
     fileMenu.add(saveMenu);\r
     fileMenu.add(mapping);\r
     saveMenu.add(png);\r
     saveMenu.add(eps);\r
     coloursMenu.add(seqButton);\r
     coloursMenu.add(chain);\r
-    coloursMenu.add(hydro);\r
     coloursMenu.add(charge);\r
-    coloursMenu.addSeparator();\r
-    coloursMenu.add(wire);\r
-    coloursMenu.add(depth);\r
-    coloursMenu.add(zbuffer);\r
-    coloursMenu.add(molecule);\r
-    coloursMenu.add(allchains);\r
+    coloursMenu.add(zappo);\r
+    coloursMenu.add(taylor);\r
+    coloursMenu.add(hydro);\r
+    coloursMenu.add(helix);\r
+    coloursMenu.add(strand);\r
+    coloursMenu.add(turn);\r
+    coloursMenu.add(buried);\r
+    coloursMenu.add(user);\r
     ButtonGroup bg = new ButtonGroup();\r
     bg.add(seqButton);\r
     bg.add(chain);\r
-    bg.add(hydro);\r
     bg.add(charge);\r
+    bg.add(zappo);\r
+    bg.add(taylor);\r
+    bg.add(hydro);\r
+    bg.add(helix);\r
+    bg.add(strand);\r
+    bg.add(turn);\r
+    bg.add(buried);\r
+    bg.add(user);\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
+        final JRadioButtonMenuItem radioItem = new JRadioButtonMenuItem(userColours.\r
+            nextElement().toString());\r
+        radioItem.setName("USER_DEFINED");\r
+        radioItem.addMouseListener(new MouseAdapter()\r
+            {\r
+              public void mousePressed(MouseEvent evt)\r
+              {\r
+                if(evt.isControlDown() || SwingUtilities.isRightMouseButton(evt))\r
+                {\r
+                  radioItem.removeActionListener(radioItem.getActionListeners()[0]);\r
+\r
+                  int option = JOptionPane.showInternalConfirmDialog(jalview.gui.Desktop.desktop,\r
+                      "Remove from default list?",\r
+                      "Remove user defined colour",\r
+                      JOptionPane.YES_NO_OPTION);\r
+                  if(option == JOptionPane.YES_OPTION)\r
+                  {\r
+                    jalview.gui.UserDefinedColours.removeColourFromDefaults(radioItem.getText());\r
+                    coloursMenu.remove(radioItem);\r
+                  }\r
+                  else\r
+                    radioItem.addActionListener(new ActionListener()\r
+                    {\r
+                      public void actionPerformed(ActionEvent evt)\r
+                      {\r
+                        user_actionPerformed(evt);\r
+                      }\r
+                    });\r
+                }\r
+              }\r
+            });\r
+        radioItem.addActionListener(new ActionListener()\r
+        {\r
+          public void actionPerformed(ActionEvent evt)\r
+          {\r
+            user_actionPerformed(evt);\r
+          }\r
+        });\r
+        coloursMenu.add(radioItem);\r
+        bg.add(radioItem);\r
+      }\r
+    }\r
+\r
+    viewMenu.add(wire);\r
+    viewMenu.add(depth);\r
+    viewMenu.add(zbuffer);\r
+    viewMenu.add(allchains);\r
   }\r
 \r
   JMenuBar jMenuBar1 = new JMenuBar();\r
@@ -235,12 +359,20 @@ public class PDBViewer extends JInternalFrame implements Runnable
   JCheckBoxMenuItem wire = new JCheckBoxMenuItem();\r
   JCheckBoxMenuItem depth = new JCheckBoxMenuItem();\r
   JCheckBoxMenuItem zbuffer = new JCheckBoxMenuItem();\r
+  JCheckBoxMenuItem allchains = new JCheckBoxMenuItem();\r
+\r
   JRadioButtonMenuItem charge = new JRadioButtonMenuItem();\r
-  JRadioButtonMenuItem hydro = new JRadioButtonMenuItem();\r
   JRadioButtonMenuItem chain = new JRadioButtonMenuItem();\r
   JRadioButtonMenuItem seqButton = new JRadioButtonMenuItem();\r
-  JCheckBoxMenuItem molecule = new JCheckBoxMenuItem();\r
-  JCheckBoxMenuItem allchains = new JCheckBoxMenuItem();\r
+  JRadioButtonMenuItem hydro = new JRadioButtonMenuItem();\r
+  JRadioButtonMenuItem taylor = new JRadioButtonMenuItem();\r
+  JRadioButtonMenuItem zappo = new  JRadioButtonMenuItem();\r
+  JRadioButtonMenuItem user = new JRadioButtonMenuItem();\r
+  JRadioButtonMenuItem buried = new JRadioButtonMenuItem();\r
+  JRadioButtonMenuItem turn = new JRadioButtonMenuItem();\r
+  JRadioButtonMenuItem strand = new JRadioButtonMenuItem();\r
+  JRadioButtonMenuItem helix = new JRadioButtonMenuItem();\r
+  JMenu viewMenu = new JMenu();\r
 \r
   /**\r
    * DOCUMENT ME!\r
@@ -290,7 +422,7 @@ public class PDBViewer extends JInternalFrame implements Runnable
   }\r
   public void charge_actionPerformed(ActionEvent e)\r
   {\r
-    clearButtonGroup();\r
+    pdbcanvas.bysequence = false;\r
     pdbcanvas.pdb.setChargeColours();\r
     pdbcanvas.redrawneeded=true;\r
     pdbcanvas.repaint();\r
@@ -298,15 +430,15 @@ public class PDBViewer extends JInternalFrame implements Runnable
 \r
   public void hydro_actionPerformed(ActionEvent e)\r
   {\r
-    clearButtonGroup();\r
-    pdbcanvas.pdb.setHydrophobicityColours();\r
+    pdbcanvas.bysequence = false;\r
+    pdbcanvas.pdb.setColours(new HydrophobicColourScheme());\r
     pdbcanvas.redrawneeded=true;\r
     pdbcanvas.repaint();\r
   }\r
 \r
   public void chain_actionPerformed(ActionEvent e)\r
   {\r
-    clearButtonGroup();\r
+    pdbcanvas.bysequence = false;\r
     pdbcanvas.pdb.setChainColours();\r
     pdbcanvas.redrawneeded=true;\r
     pdbcanvas.repaint();\r
@@ -342,16 +474,10 @@ public class PDBViewer extends JInternalFrame implements Runnable
 \r
   public void seqButton_actionPerformed(ActionEvent e)\r
   {\r
-    clearButtonGroup();\r
-    pdbcanvas.bysequence = seqButton.isSelected();\r
+    pdbcanvas.bysequence = true;\r
     pdbcanvas.updateSeqColours();\r
   }\r
 \r
-  void clearButtonGroup()\r
-  {\r
-   pdbcanvas.bysequence = false;\r
-   pdbcanvas.bymolecule = false;\r
-  }\r
 \r
   public void mapping_actionPerformed(ActionEvent e)\r
   {\r
@@ -364,4 +490,69 @@ public class PDBViewer extends JInternalFrame implements Runnable
   {\r
     pdbcanvas.setAllchainsVisible(allchains.getState());\r
   }\r
+\r
+  public void zappo_actionPerformed(ActionEvent e)\r
+  {\r
+    pdbcanvas.bysequence = false;\r
+    pdbcanvas.pdb.setColours(new ZappoColourScheme());\r
+    pdbcanvas.redrawneeded=true;\r
+    pdbcanvas.repaint();\r
+  }\r
+\r
+  public void taylor_actionPerformed(ActionEvent e)\r
+  {\r
+    pdbcanvas.bysequence = false;\r
+    pdbcanvas.pdb.setColours(new TaylorColourScheme());\r
+    pdbcanvas.redrawneeded=true;\r
+    pdbcanvas.repaint();\r
+  }\r
+\r
+  public void helix_actionPerformed(ActionEvent e)\r
+  {\r
+    pdbcanvas.bysequence = false;\r
+    pdbcanvas.pdb.setColours(new HelixColourScheme());\r
+    pdbcanvas.redrawneeded=true;\r
+    pdbcanvas.repaint();\r
+  }\r
+\r
+  public void strand_actionPerformed(ActionEvent e)\r
+  {\r
+    pdbcanvas.bysequence = false;\r
+    pdbcanvas.pdb.setColours(new StrandColourScheme());\r
+    pdbcanvas.redrawneeded=true;\r
+    pdbcanvas.repaint();\r
+  }\r
+\r
+  public void turn_actionPerformed(ActionEvent e)\r
+  {\r
+    pdbcanvas.bysequence = false;\r
+    pdbcanvas.pdb.setColours(new TurnColourScheme());\r
+    pdbcanvas.redrawneeded=true;\r
+    pdbcanvas.repaint();\r
+  }\r
+\r
+  public void buried_actionPerformed(ActionEvent e)\r
+  {\r
+    pdbcanvas.bysequence = false;\r
+    pdbcanvas.pdb.setColours(new BuriedColourScheme());\r
+    pdbcanvas.redrawneeded=true;\r
+    pdbcanvas.repaint();\r
+  }\r
+\r
+  public void user_actionPerformed(ActionEvent e)\r
+  {\r
+    if (e.getActionCommand().equals("User Defined..."))\r
+    {\r
+      new UserDefinedColours(pdbcanvas, null);\r
+    }\r
+    else\r
+    {\r
+      UserColourScheme udc = (UserColourScheme) UserDefinedColours.\r
+          getUserColourSchemes().get(e.getActionCommand());\r
+\r
+      pdbcanvas.pdb.setColours(udc);\r
+      pdbcanvas.redrawneeded=true;\r
+      pdbcanvas.repaint();\r
+    }\r
+  }\r
 }\r
index d7b7c97..26f1701 100755 (executable)
@@ -161,9 +161,9 @@ public class PDBfile extends jalview.io.FileParse {
         }\r
     }\r
 \r
-    public void setHydrophobicityColours() {\r
+    public void setColours(jalview.schemes.ColourSchemeI cs) {\r
         for (int i = 0; i < chains.size(); i++) {\r
-            ((PDBChain) chains.elementAt(i)).setHydrophobicityColours();\r
+            ((PDBChain) chains.elementAt(i)).setChainColours(cs);\r
         }\r
     }\r
 \r