use proper encoding for storing colour as user preference (JAL-234)
authorjprocter <jprocter@compbio.dundee.ac.uk>
Mon, 25 Jul 2011 16:05:57 +0000 (17:05 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Mon, 25 Jul 2011 16:05:57 +0000 (17:05 +0100)
src/jalview/bin/Cache.java
src/jalview/gui/Preferences.java
src/jalview/jbgui/GPreferences.java

index 09ebadd..f67377b 100755 (executable)
@@ -754,4 +754,15 @@ public class Cache
     }
     return (col==null) ? defcolour: col;
   }
+
+  /**
+   * store a colour as a Jalview user default property
+   * @param property
+   * @param colour     
+   */
+  public static void setColourProperty(String property, Color colour)
+  {
+    setProperty(property, jalview.util.Format
+          .getHexString(colour));
+  }
 }
index b92f9da..fac25e9 100755 (executable)
@@ -335,8 +335,8 @@ public class Preferences extends GPreferences
     Cache.applicationProperties.setProperty("SORT_ALIGNMENT", sortby
             .getSelectedItem().toString());
 
-    Cache.applicationProperties.setProperty("ANNOTATIONCOLOUR_MIN", minColour.getBackground().toString());
-    Cache.applicationProperties.setProperty("ANNOTATIONCOLOUR_MAX", maxColour.getBackground().toString());
+    Cache.setColourProperty("ANNOTATIONCOLOUR_MIN", minColour.getBackground());
+    Cache.setColourProperty("ANNOTATIONCOLOUR_MAX", maxColour.getBackground());
     
     if (epsRendering.getSelectedItem().equals("Prompt each time"))
     {
index 42ffa5d..9448065 100755 (executable)
@@ -242,18 +242,22 @@ public class GPreferences extends JPanel
   public void addtoLayout(JPanel panel, String tooltip, JComponent label, JComponent valBox)
   {
     JPanel laypanel = new JPanel(),labPanel=new JPanel(), valPanel=new JPanel();
-    laypanel.setSize(panel.getWidth(),33);
+    // laypanel.setSize(panel.getPreferredSize());
+    // laypanel.setLayout(null);
     labPanel.setBounds(new Rectangle(7, 7, 158, 23));
     valPanel.setBounds(new Rectangle(172, 7, 270,23));
-    labPanel.setLayout(new GridLayout());
-    valPanel.setLayout(new GridLayout());
+    //labPanel.setLayout(new GridLayout(1,1));
+    //valPanel.setLayout(new GridLayout(1,1));
     labPanel.add(label);
     valPanel.add(valBox);
     laypanel.add(labPanel);
     laypanel.add(valPanel);
-    panel.add(laypanel);
     valPanel.setToolTipText(tooltip);
     labPanel.setToolTipText(tooltip);
+    valBox.setToolTipText(tooltip);
+    panel.add(laypanel);
+    panel.validate();
+    
   }
   /**
    * Creates a new GPreferences object.
@@ -724,8 +728,12 @@ public class GPreferences extends JPanel
     visualTab.add(tooltipSettings);
     visualTab.add(jPanel2);
     addtoLayout(visual2Tab, "Default Colourscheme for alignment", colourLabel, colour);
-    addtoLayout(visual2Tab, "Default Minimum Colour for annotation shading", mincolourLabel,minColour);
-    addtoLayout(visual2Tab,"Default Maximum Colour for annotation shading", maxcolourLabel, maxColour);
+    JPanel annotationShding=new JPanel();
+    annotationShding.setBorder(new TitledBorder("Annotation Shading Default"));
+    annotationShding.setLayout(new GridLayout(1,2));
+    addtoLayout(annotationShding, "Default Minimum Colour for annotation shading", mincolourLabel,minColour);
+    addtoLayout(annotationShding,"Default Maximum Colour for annotation shading", maxcolourLabel, maxColour);
+    visual2Tab.add(annotationShding); // , FlowLayout.LEFT);
 
 //    visual2panel.add(minColour);
 //    visual2panel.add(maxColour);