Can be used by PDBViewer
authoramwaterhouse <Andrew Waterhouse>
Fri, 9 Dec 2005 13:35:03 +0000 (13:35 +0000)
committeramwaterhouse <Andrew Waterhouse>
Fri, 9 Dec 2005 13:35:03 +0000 (13:35 +0000)
src/jalview/gui/UserDefinedColours.java

index ec4ad55..089c8a9 100755 (executable)
@@ -52,6 +52,7 @@ public class UserDefinedColours extends GUserDefinedColours
     Vector selectedButtons;\r
     ColourSchemeI oldColourScheme;\r
     JInternalFrame frame;\r
+    MCview.PDBCanvas pdbcanvas;\r
 \r
     /**\r
      * Creates a new UserDefinedColours object.\r
@@ -106,6 +107,40 @@ public class UserDefinedColours extends GUserDefinedColours
         makeButton("Gap", "-");\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
+\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
+        }\r
+\r
+        makeButton("B", "B");\r
+        makeButton("Z", "Z");\r
+        makeButton("X", "X");\r
+        makeButton("Gap", "-");\r
+    }\r
+\r
+\r
     /**\r
      * DOCUMENT ME!\r
      *\r
@@ -269,10 +304,15 @@ public class UserDefinedColours extends GUserDefinedColours
             seqGroup.cs = ucs;\r
             ap.repaint();\r
         }\r
-        else\r
+        else if(ap!=null)\r
         {\r
             ap.alignFrame.changeColour(ucs);\r
         }\r
+        else if(pdbcanvas!=null)\r
+        {\r
+          pdbcanvas.pdb.setColours(ucs);\r
+          pdbcanvas.updateSeqColours();\r
+        }\r
     }\r
 \r
     UserColourScheme getSchemeFromGUI()\r
@@ -286,7 +326,9 @@ public class UserDefinedColours extends GUserDefinedColours
       }\r
 \r
       UserColourScheme ucs = new UserColourScheme(newColours);\r
-      ucs.setThreshold(0, ap.av.getIgnoreGapsConsensus());\r
+      if(ap!=null)\r
+        ucs.setThreshold(0, ap.av.getIgnoreGapsConsensus());\r
+\r
 \r
       return ucs;\r
     }\r
@@ -494,16 +536,23 @@ public class UserDefinedColours extends GUserDefinedColours
      */\r
     protected void cancelButton_actionPerformed(ActionEvent e)\r
     {\r
+      if (ap != null)\r
+      {\r
         if (seqGroup != null)\r
         {\r
-            seqGroup.cs = oldColourScheme;\r
+          seqGroup.cs = oldColourScheme;\r
         }\r
-        else\r
+        else if (ap != null)\r
         {\r
-            ap.av.setGlobalColourScheme(oldColourScheme);\r
+          ap.av.setGlobalColourScheme(oldColourScheme);\r
         }\r
-\r
         ap.repaint();\r
+      }\r
+\r
+      if(pdbcanvas!=null)\r
+      {\r
+        pdbcanvas.pdb.setColours(oldColourScheme);\r
+      }\r
 \r
         try\r
         {\r