selection removed, now SelectionGroup does same job as id select and residue select
[jalview.git] / src / jalview / gui / UserDefinedColours.java
index 1a3fa86..a96cf52 100755 (executable)
@@ -18,23 +18,38 @@ public class UserDefinedColours extends GUserDefinedColours implements ChangeLis
   SequenceGroup seqGroup;\r
   JButton selectedButton;\r
   Vector oldColours = new Vector();\r
+  ColourSchemeI oldColourScheme;\r
   JInternalFrame frame;\r
 \r
+\r
   public UserDefinedColours(JInternalFrame f, AlignmentPanel ap, SequenceGroup sg)\r
   {\r
     super();\r
     colorChooser.getSelectionModel().addChangeListener(this);\r
     this.ap = ap;\r
     frame = f;\r
-   seqGroup = sg;\r
+    seqGroup = sg;\r
+\r
+\r
+      if (seqGroup != null)\r
+        oldColourScheme = seqGroup.cs;\r
+      else\r
+        oldColourScheme = ap.av.getGlobalColourScheme();\r
 \r
-    for(int i=0; i<20; i++)\r
-      makeButton(ResidueProperties.aa2Triplet.get( ResidueProperties.aa[i] )+"", ResidueProperties.aa[i]);\r
+      for (int i = 0; i < 20; i++)\r
+        makeButton(ResidueProperties.aa2Triplet.get(ResidueProperties.aa[i]) +\r
+                   "", ResidueProperties.aa[i]);\r
+\r
+      makeButton("B", "B");\r
+      makeButton("Z", "Z");\r
+      makeButton("X", "X");\r
+      makeButton("'.','-',' '", "-");\r
+\r
+      if(jalview.bin.Cache.getProperty("USER_DEFINED_COLOUR")!=null)\r
+      {\r
+        loadColour(jalview.bin.Cache.getProperty("USER_DEFINED_COLOUR"));\r
+      }\r
 \r
-    makeButton("B","B");\r
-    makeButton("Z","Z");\r
-    makeButton("X","X");\r
-    makeButton("'.','-',' '", "-");\r
 \r
   }\r
 \r
@@ -54,14 +69,11 @@ public class UserDefinedColours extends GUserDefinedColours implements ChangeLis
   {\r
     final JButton button = new JButton();\r
     Color col = Color.white;\r
-    ColourSchemeI cs = null;\r
-    if(seqGroup!=null)\r
-      cs = seqGroup.cs;\r
-    else\r
-      cs = ap.av.getGlobalColourScheme();\r
 \r
-    if(cs!=null)\r
-      col = cs.findColour( aa, -1, null);\r
+\r
+    try{\r
+      col = oldColourScheme.findColour(aa, -1, null);\r
+    }catch(Exception ex){}\r
 \r
     button.setBackground(  col );\r
     oldColours.addElement( col );\r
@@ -112,6 +124,7 @@ public class UserDefinedColours extends GUserDefinedColours implements ChangeLis
   protected void loadbutton_actionPerformed(ActionEvent e)\r
   {\r
     JFileChooser chooser = new JFileChooser(jalview.bin.Cache.getProperty("LAST_DIRECTORY"));\r
+    chooser.setFileView(new jalview.io.JalviewFileView());\r
     chooser.setDialogTitle("Load colour scheme");\r
     chooser.setToolTipText("Load");\r
     int value = chooser.showOpenDialog(this);\r
@@ -119,33 +132,39 @@ public class UserDefinedColours extends GUserDefinedColours implements ChangeLis
     {\r
       String choice = chooser.getSelectedFile().getPath();\r
       jalview.bin.Cache.setProperty("LAST_DIRECTORY",  choice);\r
+      loadColour(choice);\r
+    }\r
 \r
-      try{\r
-        BufferedReader in = new BufferedReader(new FileReader(choice));\r
-        for(int i=0; i<24; i++)\r
-        {\r
-          JButton button = (JButton)buttonPanel.getComponent(i);\r
-          Color c = new Color(Integer.parseInt(in.readLine()));\r
-          button.setBackground(c);\r
-        }\r
+  }\r
 \r
+  void loadColour(String file)\r
+  {\r
+    try\r
+    {\r
+      BufferedReader in = new BufferedReader(new FileReader(file));\r
+      for (int i = 0; i < 24; i++)\r
+      {\r
+        JButton button = (JButton) buttonPanel.getComponent(i);\r
+        Color c = new Color(Integer.parseInt(in.readLine()));\r
+        button.setBackground(c);\r
       }\r
-      catch(Exception ex)\r
-      {}\r
     }\r
+    catch (Exception ex)\r
+    {}\r
 \r
   }\r
 \r
   protected void savebutton_actionPerformed(ActionEvent e)\r
   {\r
     JFileChooser chooser = new JFileChooser(jalview.bin.Cache.getProperty("LAST_DIRECTORY"));\r
+    chooser.setFileView(new jalview.io.JalviewFileView());\r
     chooser.setDialogTitle("Save colour scheme");\r
     chooser.setToolTipText("Save");\r
     int value = chooser.showSaveDialog(this);\r
     if (value == JFileChooser.APPROVE_OPTION)\r
     {\r
       String choice = chooser.getSelectedFile().getPath();\r
-      jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);\r
+      jalview.bin.Cache.setProperty("USER_DEFINED_COLOUR", choice);\r
 \r
       try{\r
         PrintWriter out = new PrintWriter(new FileWriter(choice));\r