JAL-1452 distinct colour preferences for nucleotide and protein
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 27 Feb 2015 14:45:09 +0000 (14:45 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 27 Feb 2015 14:45:09 +0000 (14:45 +0000)
src/jalview/gui/JvSwingUtils.java
src/jalview/gui/Preferences.java
src/jalview/jbgui/GPreferences.java

index 1cc8a92..114ce50 100644 (file)
@@ -22,8 +22,10 @@ package jalview.gui;
 
 import jalview.util.MessageManager;
 
+import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.Font;
+import java.awt.GridLayout;
 import java.awt.Rectangle;
 import java.awt.event.ActionListener;
 
@@ -123,14 +125,16 @@ public final class JvSwingUtils
   public static JPanel addtoLayout(JPanel panel, String tooltip,
           JComponent label, JComponent valBox)
   {
-    JPanel laypanel = new JPanel(), labPanel = new JPanel(), valPanel = new JPanel();
+    JPanel laypanel = new JPanel(new GridLayout(1, 2));
+    JPanel labPanel = new JPanel(new BorderLayout());
+    JPanel valPanel = new JPanel();
     // 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(1,1));
     // valPanel.setLayout(new GridLayout(1,1));
-    labPanel.add(label);
+    labPanel.add(label, BorderLayout.WEST);
     valPanel.add(valBox);
     laypanel.add(labPanel);
     laypanel.add(valPanel);
index c024b1c..881d02b 100755 (executable)
@@ -62,6 +62,12 @@ import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
 public class Preferences extends GPreferences
 {
 
+  public static final String DEFAULT_COLOUR = "DEFAULT_COLOUR";
+
+  public static final String DEFAULT_COLOUR_PROT = "DEFAULT_COLOUR_PROT";
+
+  public static final String DEFAULT_COLOUR_NUC = "DEFAULT_COLOUR_NUC";
+
   public static final String ADD_TEMPFACT_ANN = "ADD_TEMPFACT_ANN";
 
   public static final String ADD_SS_ANN = "ADD_SS_ANN";
@@ -267,10 +273,14 @@ public class Preferences extends GPreferences
      */
     for (int i = ColourSchemeProperty.FIRST_COLOUR; i <= ColourSchemeProperty.LAST_COLOUR; i++)
     {
-      colour.addItem(ColourSchemeProperty.getColourName(i));
+      protColour.addItem(ColourSchemeProperty.getColourName(i));
+      nucColour.addItem(ColourSchemeProperty.getColourName(i));
     }
-    String string = Cache.getDefault("DEFAULT_COLOUR", "None");
-    colour.setSelectedItem(string);
+    String oldProp = Cache.getDefault(DEFAULT_COLOUR, "None");
+    String newProp = Cache.getDefault(DEFAULT_COLOUR_PROT, null);
+    protColour.setSelectedItem(newProp != null ? newProp : oldProp);
+    newProp = Cache.getDefault(DEFAULT_COLOUR_NUC, null);
+    nucColour.setSelectedItem(newProp != null ? newProp : oldProp);
     minColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN",
             Color.orange));
     maxColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX",
@@ -452,7 +462,9 @@ public class Preferences extends GPreferences
     /*
      * Save Colours settings
      */
-    Cache.applicationProperties.setProperty("DEFAULT_COLOUR", colour
+    Cache.applicationProperties.setProperty(DEFAULT_COLOUR_PROT, protColour
+            .getSelectedItem().toString());
+    Cache.applicationProperties.setProperty(DEFAULT_COLOUR_NUC, nucColour
             .getSelectedItem().toString());
     Cache.setColourProperty("ANNOTATIONCOLOUR_MIN",
             minColour.getBackground());
index 3596619..071745c 100755 (executable)
@@ -156,7 +156,9 @@ public class GPreferences extends JPanel
 
   protected JPanel maxColour = new JPanel();
 
-  protected JComboBox<String> colour = new JComboBox<String>();
+  protected JComboBox<String> protColour = new JComboBox<String>();
+
+  protected JComboBox<String> nucColour = new JComboBox<String>();
 
   /*
    * Connections tab components
@@ -692,16 +694,30 @@ public class GPreferences extends JPanel
         maxColour_actionPerformed(maxColour);
       }
     });
-    colour.setFont(verdana11);
-    colour.setBounds(new Rectangle(172, 225, 155, 21));
-    JLabel colourLabel = new JLabel();
-    colourLabel.setFont(verdana11);
-    colourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
-    colourLabel.setText(MessageManager.getString("label.alignment_colour")
+
+    protColour.setFont(verdana11);
+    protColour.setBounds(new Rectangle(172, 225, 155, 21));
+    JLabel protColourLabel = new JLabel();
+    protColourLabel.setFont(verdana11);
+    protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
+    protColourLabel.setText(MessageManager
+            .getString("label.prot_alignment_colour") + " ");
+    JvSwingUtils.addtoLayout(coloursTab, MessageManager
+            .getString("label.default_colour_scheme_for_alignment"),
+            protColourLabel, protColour);
+
+    nucColour.setFont(verdana11);
+    nucColour.setBounds(new Rectangle(172, 240, 155, 21));
+    JLabel nucColourLabel = new JLabel();
+    nucColourLabel.setFont(verdana11);
+    nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
+    nucColourLabel.setText(MessageManager
+            .getString("label.nuc_alignment_colour")
             + " ");
     JvSwingUtils.addtoLayout(coloursTab, MessageManager
             .getString("label.default_colour_scheme_for_alignment"),
-            colourLabel, colour);
+            nucColourLabel, nucColour);
+
     JPanel annotationShding = new JPanel();
     annotationShding.setBorder(new TitledBorder(MessageManager
             .getString("label.annotation_shading_default")));