Merge branch 'JAL-1360_Branch' into Release_2_8_2_Branch
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 18 Sep 2014 13:16:21 +0000 (14:16 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 18 Sep 2014 13:16:21 +0000 (14:16 +0100)
25 files changed:
help/html/calculations/consensus.html
help/html/calculations/structureconsensus.html
help/html/colourSchemes/abovePID.html
help/html/colourSchemes/blosum.html
help/html/colourSchemes/buried.html
help/html/colourSchemes/clustal.html
help/html/colourSchemes/conservation.html
help/html/colourSchemes/helix.html
help/html/colourSchemes/hydrophobic.html
help/html/colourSchemes/nucleotide.html
help/html/colourSchemes/pid.html
help/html/colourSchemes/purinepyrimidine.html
help/html/colourSchemes/strand.html
help/html/colourSchemes/taylor.html
help/html/colourSchemes/turn.html
help/html/colourSchemes/user.html
help/html/colourSchemes/userDefined_java6.gif [new file with mode: 0644]
help/html/colourSchemes/userDefined_java7.gif [new file with mode: 0644]
help/html/colourSchemes/zappo.html
help/html/features/groovy.html
help/html/webServices/dbreffetcher.html
src/jalview/gui/UserDefinedColours.java
src/jalview/jbgui/GUserDefinedColours.java
src/jalview/util/ColorUtils.java
test/jalview/util/ColorUtilsTest.java [new file with mode: 0644]

index 6df11da..bc42278 100644 (file)
@@ -37,7 +37,7 @@ clipboard.
 <p><strong>Sequence logo</strong></p>
        By clicking on the label you can also activate the sequence logo. It
        indicates the relative amount of residues per column which can be
-       estimated by it's size in the logo. The tooltip of a column gives the
+       estimated by its size in the logo. The tooltip of a column gives the
        exact numbers for all occuring residues.
        <br />If columns of the alignment are very diverse, then it can
        sometimes be difficult to see the sequence logo - in this case, right
index 097068d..6e797b1 100755 (executable)
@@ -40,7 +40,7 @@ similar to a sequence logo but counts the numbers of base pairs. There
 are two residues per column, the actual column and the interacting
 base. The opening bracket is always the one on the left side.<br>
 Like sequence logos the relative amount of a specific base pair can be
-estimated by it's size in the logo. The tool tip of a column gives the
+estimated by its size in the logo. The tool tip of a column gives the
 exact numbers for all occurring valid base pairs.
 </p>
 </body>
index e609972..74dd665 100755 (executable)
@@ -30,7 +30,7 @@ td {
 </head>
 
 <body>
-<p> <em>Colouring above a percentage identity threshold</em></p>
+<p> <strong>Colouring above a percentage identity threshold</strong></p>
 <p> Selecting this option causes the colour scheme to be applied to only those
   residues that occur in that column more than a certain percentage of the time.
   For instance selecting the threshold to be 100 will only colour those columns
index 6749d4e..338ca55 100755 (executable)
@@ -31,7 +31,7 @@ td {
 
 <body>
 
-<p><em>Blosum62</a></em> </p>
+<p><strong>Blosum62</a></strong> </p>
 <p>Gaps are coloured white. If a residue matches the consensus sequence residue
   at that position it is coloured dark blue. If it does not match the consensus
   residue but the 2 residues have a positive Blosum62 score, it is coloured light
index 1373404..5943d36 100755 (executable)
@@ -30,7 +30,7 @@ td {
 </head>
 
 <body>
-<p><em>Buried index</em></p>
+<p><strong>Buried index</strong></p>
 <div align="center">
   <table width="400" border="1">
     <tr>
index b95a348..33455dc 100755 (executable)
@@ -30,7 +30,7 @@ td {
 </head>
 
 <body>
-<p><em>Clustal X Colour Scheme</em></p>
+<p><strong>Clustal X Colour Scheme</strong></p>
   <p>This is an emulation of the default colourscheme used for alignments in 
   Clustal X, a graphical interface for the ClustalW multiple sequence alignment
     program. Each residue in the alignment is assigned a colour if the 
index 8866435..5ceba85 100755 (executable)
@@ -21,7 +21,7 @@
  -->
 <head><title>Colouring by Conservation</title></head>
 <body>
-<p><em>Colouring by Conservation</em></p>
+<p><strong>Colouring by Conservation</strong></p>
 <p>This is an approach to alignment colouring which highlights
   regions of an alignment where physicochemical properties are
   conserved. It is based on the one used in
index e4142c1..8c698c0 100755 (executable)
@@ -30,7 +30,7 @@ td {
 </head>
 
 <body>
-<p><em>Helix Propensity</em> </p>
+<p><strong>Helix Propensity</strong> </p>
 <div align="center">
   <table width="400" border="1">
     <tr>
index 288a2d1..6b4cf2d 100755 (executable)
@@ -30,7 +30,7 @@ td {
 </head>
 
 <body>
-<p><em>Hydrophobicity</em></p>
+<p><strong>Hydrophobicity</strong></p>
 <p>According to the hydrophobicity table of Kyte, J., and Doolittle, R.F., J.
   Mol. Biol. 1157, 105-132, 1982. The most hydrophobic residues according to this
   table are coloured red and the most hydrophilic ones are coloured blue.</p>
index 601230b..065c818 100755 (executable)
@@ -30,7 +30,7 @@ td {
 </head>
 
 <body>
-<p><em>Nucleotide Colours</em></p>
+<p><strong>Nucleotide Colours</strong></p>
 <div align="center">
   <table width="200" border="1">
     <tr>
index f90fde9..47b992a 100755 (executable)
@@ -30,7 +30,7 @@ td {
 </head>
 
 <body>
-<p><em>PID Colours</em><br>
+<p><strong>PID Colours</strong><br>
   <br>
   The PID option colours the residues (boxes and/or text) according to the percentage
   of the residues in each column that agree with the consensus sequence. Only
index 6655392..4337d48 100644 (file)
@@ -30,7 +30,7 @@ td {
 </head>
 
 <body>
-<p><em>Purine/Pyrimidine Colours</em></p>
+<p><strong>Purine/Pyrimidine Colours</strong></p>
 <div align="center">
   <table width="200" border="1">
     <tr>
index a653c8e..fe7c469 100755 (executable)
@@ -30,7 +30,7 @@ td {
 </head>
 
 <body>
-<p><em>Strand propensity</em></p>
+<p><strong>Strand propensity</strong></p>
 <div align="center">
   <table width="400" border="1">
     <tr>
index 268915d..a5c4f05 100755 (executable)
@@ -30,7 +30,7 @@ td {
 </head>
 
 <body>
-<p><em><a name="taylor">Taylor</a></em></p>
+<p><strong><a name="taylor">Taylor</a></strong></p>
 <p>These colours were invented by Willie Taylor and an entertaining description
   of their birth can be found in Protein Engineering, Vol 10 , 743-746 (1997)</p>
 <div align="center">
index ec65d6f..87dbe37 100755 (executable)
@@ -30,7 +30,7 @@ td {
 </head>
 
 <body>
-<p><em>Turn propensity</em></p>
+<p><strong>Turn propensity</strong></p>
 <div align="center">
   <table width="400" border="1">
     <tr>
index 5774306..5eacca9 100755 (executable)
  -->
 <head><title>User Defined Colours</title></head>
 <body>
-<p><em>User Defined Colours</em></p>
-<p><img src="userDefined.gif" width="719" height="368"> </p>
+<p><strong>User Defined Colours</strong></p>
+<p><img src="userDefined_java6.gif" width="815" height="402"> </p>
 <p>You may define any number of new colour schemes, each with a unique name. <br>
   <br>
-  Each of the residues in a new colour scheme may be assigned a new user defined 
-  colour. <br>
-  <br>
-  Click &quot;Apply&quot; or &quot;OK&quot; to set your new colours on the active 
-  alignment window. </p>
-<p>Click &quot;Cancel&quot; to undo your changes if you pressed the &quot;Apply&quot; 
-  button. <br>
-  <br>
-  If you save your colour scheme with a unique name the colour scheme name will 
-  be added to the &quot;Colour&quot; menu on each new alignment window.<br>
+  Each of the residues in a colour scheme may be assigned any chosen colour. <br>
+  Select one or more residues, then select the desired colour.<br/>
+  Use Ctrl-click to select multiple residues, or click then Shift-click to select a block.<br/>
+  Note that the currently selected buttons are highlighted by a lighter text colour.
+  <p>
+  The <strong>Case Sensitive</strong> option allows you to choose distinct colours for upper and
+  lower case residue codes.
+  <p>
+  Click <strong>Apply</strong> or <strong>OK</strong> to set your new colours on the active 
+  alignment window.<br/>
+   Click <strong>Cancel</strong> to undo your changes if you pressed the <strong>Apply</strong> 
+  button.
+  </p>
+  If you save your colour scheme with a unique name, the colour scheme name will 
+  be added to the <strong>Colour</strong> menu on each new alignment window.<br>
   <br>
   Any saved colour schemes will be automatically loaded the next time you use 
-  Jalview.</p>
+  Jalview.
+  <br><br>
+  <em>Note: the screenshot shows the appearance when running Java version 6. For Java 7 (from Jalview 2.8.2) only the Swatches colour chooser is
+  currently supported (for reasons of available screen space).</em>
+  <p/>
 </body>
 </html>
diff --git a/help/html/colourSchemes/userDefined_java6.gif b/help/html/colourSchemes/userDefined_java6.gif
new file mode 100644 (file)
index 0000000..d737e80
Binary files /dev/null and b/help/html/colourSchemes/userDefined_java6.gif differ
diff --git a/help/html/colourSchemes/userDefined_java7.gif b/help/html/colourSchemes/userDefined_java7.gif
new file mode 100644 (file)
index 0000000..f0ced11
Binary files /dev/null and b/help/html/colourSchemes/userDefined_java7.gif differ
index 01d2b37..db025c0 100755 (executable)
@@ -30,7 +30,7 @@ td {
 </head>
 
 <body>
-<p><em>Zappo Colours</em><br>
+<p><strong>Zappo Colours</strong><br>
   <br>
   The residues are coloured according to their physicochemical properties as
   follows: </p>
index 4185cc7..6559fd1 100644 (file)
@@ -44,7 +44,7 @@
                The jars are obtained from the <em>embedded</em> directory within the
                <a href="http://dist.codehaus.org/groovy/distributions">groovy
                        distribution</a>. The easiest way of adding them to the Jalview classpath
-               is to download and build jalview from it's source distribution, and
+               is to download and build jalview from its source distribution, and
                then add the groovy-all-*.jar to the lib directory whose path is given
                in the java.ext.dirs property.
        </p>
index 382991b..ad42153 100644 (file)
@@ -45,7 +45,7 @@ of ID queries from the ID string of each sequence in the alignment. It
 then tries to query a subset of all the databases it can access in order to match
 the alignment sequence to any records retrieved from the database. If a
 match is found, then the sequence is annotated with that database's
-reference, and any cross-references that it's records contain.</p>
+reference, and any cross-references that its records contain.</p>
 <p><strong>The Sequence Identification Process</strong><br>
 The method of accession id discovery is derived from the method which
 earlier Jalview versions used for Uniprot sequence feature retrieval,
index f719d27..43c648e 100755 (executable)
@@ -27,6 +27,7 @@ import jalview.jbgui.GUserDefinedColours;
 import jalview.schemes.ColourSchemeI;
 import jalview.schemes.ResidueProperties;
 import jalview.schemes.UserColourScheme;
+import jalview.util.ColorUtils;
 import jalview.util.MessageManager;
 
 import java.awt.Color;
@@ -39,9 +40,9 @@ import java.io.FileOutputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
+import java.util.ArrayList;
 import java.util.Hashtable;
 import java.util.StringTokenizer;
-import java.util.Vector;
 
 import javax.swing.JButton;
 import javax.swing.JInternalFrame;
@@ -50,19 +51,26 @@ import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
 
 /**
- * DOCUMENT ME!
+ * This panel allows the user to assign colours to Amino Acid residue codes, and
+ * save the colour scheme.
  * 
- * @author $author$
- * @version $Revision$
+ * @author Andrew Waterhouse
+ * @author Mungo Carstairs
  */
 public class UserDefinedColours extends GUserDefinedColours implements
         ChangeListener
 {
+  private static final int MY_FRAME_HEIGHT = 420;
+
+  private static final int MY_FRAME_WIDTH = 810;
+
+  private static final int MY_FRAME_WIDTH_CASE_SENSITIVE = 970;
+
   AlignmentPanel ap;
 
   SequenceGroup seqGroup;
 
-  Vector selectedButtons;
+  ArrayList<JButton> selectedButtons;
 
   ColourSchemeI oldColourScheme;
 
@@ -70,9 +78,9 @@ public class UserDefinedColours extends GUserDefinedColours implements
 
   JalviewStructureDisplayI jmol;
 
-  Vector upperCaseButtons;
+  ArrayList<JButton> upperCaseButtons;
 
-  Vector lowerCaseButtons;
+  ArrayList<JButton> lowerCaseButtons;
 
   /**
    * Creates a new UserDefinedColours object.
@@ -122,7 +130,8 @@ public class UserDefinedColours extends GUserDefinedColours implements
     showFrame();
   }
 
-  public UserDefinedColours(JalviewStructureDisplayI jmol, ColourSchemeI oldcs)
+  public UserDefinedColours(JalviewStructureDisplayI jmol,
+          ColourSchemeI oldcs)
   {
     super();
     this.jmol = jmol;
@@ -148,18 +157,13 @@ public class UserDefinedColours extends GUserDefinedColours implements
     frame = new JInternalFrame();
     frame.setContentPane(this);
     Desktop.addInternalFrame(frame,
-            MessageManager.getString("label.user_defined_colours"), 720,
-            370, true);
+            MessageManager.getString("label.user_defined_colours"),
+            MY_FRAME_WIDTH, MY_FRAME_HEIGHT, true);
 
     if (seqGroup != null)
     {
       frame.setTitle(frame.getTitle() + " (" + seqGroup.getName() + ")");
     }
-
-    if (new jalview.util.Platform().isAMac())
-    {
-      frame.setSize(760, 370);
-    }
   }
 
   void resetButtonPanel(boolean caseSensitive)
@@ -168,7 +172,7 @@ public class UserDefinedColours extends GUserDefinedColours implements
 
     if (upperCaseButtons == null)
     {
-      upperCaseButtons = new Vector();
+      upperCaseButtons = new ArrayList<JButton>();
     }
 
     JButton button;
@@ -209,7 +213,7 @@ public class UserDefinedColours extends GUserDefinedColours implements
 
       if (lowerCaseButtons == null)
       {
-        lowerCaseButtons = new Vector();
+        lowerCaseButtons = new ArrayList<JButton>();
       }
 
       for (int i = 0; i < 20; i++)
@@ -230,6 +234,15 @@ public class UserDefinedColours extends GUserDefinedColours implements
       buttonPanel.add(makeButton("x", "x", lowerCaseButtons, 22));
     }
 
+    // JAL-1360 widen the frame dynamically to accommodate case-sensitive AA
+    // codes
+    if (this.frame != null)
+    {
+      int newWidth = caseSensitive ? MY_FRAME_WIDTH_CASE_SENSITIVE
+              : MY_FRAME_WIDTH;
+      this.frame.setSize(newWidth, this.frame.getHeight());
+    }
+
     buttonPanel.validate();
     validate();
   }
@@ -240,42 +253,55 @@ public class UserDefinedColours extends GUserDefinedColours implements
    * @param evt
    *          DOCUMENT ME!
    */
+  @Override
   public void stateChanged(ChangeEvent evt)
   {
     if (selectedButtons != null)
     {
       JButton button = null;
+      final Color newColour = colorChooser.getColor();
       for (int i = 0; i < selectedButtons.size(); i++)
       {
-        button = (JButton) selectedButtons.elementAt(i);
-        button.setBackground(colorChooser.getColor());
-        button.setForeground(button.getBackground().brighter().brighter()
-                .brighter());
+        button = selectedButtons.get(i);
+        button.setBackground(newColour);
+        button.setForeground(ColorUtils.brighterThan(newColour));
       }
       if (button == lcaseColour)
       {
         for (int i = 0; i < lowerCaseButtons.size(); i++)
         {
-          button = (JButton) lowerCaseButtons.elementAt(i);
-          button.setBackground(colorChooser.getColor());
-          button.setForeground(button.getBackground().brighter().brighter()
-                  .brighter());
+          button = lowerCaseButtons.get(i);
+          button.setBackground(newColour);
+          button.setForeground(ColorUtils.brighterThan(button
+                  .getBackground()));
         }
       }
     }
   }
 
   /**
-   * DOCUMENT ME!
+   * Performs actions when a residue button is clicked. This manages the button
+   * selection set (highlighted by brighter foreground text).
+   * <p>
+   * On select button(s) with Ctrl/click or Shift/click: set button foreground
+   * text to brighter than background.
+   * <p>
+   * On unselect button(s) with Ctrl/click on selected, or click to release
+   * current selection: reset foreground text to darker than background.
+   * <p>
+   * Simple click: clear selection (resetting foreground to darker); set clicked
+   * button foreground to brighter
+   * <p>
+   * Finally, synchronize the colour chooser to the colour of the first button
+   * in the selected set.
    * 
    * @param e
-   *          DOCUMENT ME!
    */
   public void colourButtonPressed(MouseEvent e)
   {
     if (selectedButtons == null)
     {
-      selectedButtons = new Vector();
+      selectedButtons = new ArrayList<JButton>();
     }
 
     JButton pressed = (JButton) e.getSource();
@@ -285,8 +311,7 @@ public class UserDefinedColours extends GUserDefinedColours implements
       JButton start, end = (JButton) e.getSource();
       if (selectedButtons.size() > 0)
       {
-        start = (JButton) selectedButtons
-                .elementAt(selectedButtons.size() - 1);
+        start = selectedButtons.get(selectedButtons.size() - 1);
       }
       else
       {
@@ -318,7 +343,8 @@ public class UserDefinedColours extends GUserDefinedColours implements
         JButton button = (JButton) buttonPanel.getComponent(b);
         if (!selectedButtons.contains(button))
         {
-          button.setForeground(button.getBackground().brighter().brighter());
+          button.setForeground(ColorUtils.brighterThan(button
+                  .getBackground()));
           selectedButtons.add(button);
         }
       }
@@ -327,32 +353,32 @@ public class UserDefinedColours extends GUserDefinedColours implements
     {
       for (int b = 0; b < selectedButtons.size(); b++)
       {
-        JButton button = (JButton) selectedButtons.elementAt(b);
-        button.setForeground(button.getBackground().darker().darker());
+        JButton button = selectedButtons.get(b);
+        button.setForeground(ColorUtils.darkerThan(button.getBackground()));
       }
       selectedButtons.clear();
-      pressed.setForeground(pressed.getBackground().brighter().brighter());
-      selectedButtons.addElement(pressed);
+      pressed.setForeground(ColorUtils.brighterThan(pressed.getBackground()));
+      selectedButtons.add(pressed);
 
     }
     else if (e.isControlDown())
     {
       if (selectedButtons.contains(pressed))
       {
-        pressed.setForeground(pressed.getBackground().darker().darker());
+        pressed.setForeground(ColorUtils.darkerThan(pressed.getBackground()));
         selectedButtons.remove(pressed);
       }
       else
       {
-        pressed.setForeground(pressed.getBackground().brighter().brighter());
-        selectedButtons.addElement(pressed);
+        pressed.setForeground(ColorUtils.brighterThan(pressed
+                .getBackground()));
+        selectedButtons.add(pressed);
       }
     }
 
     if (selectedButtons.size() > 0)
     {
-      colorChooser.setColor(((JButton) selectedButtons.elementAt(0))
-              .getBackground());
+      colorChooser.setColor((selectedButtons.get(0)).getBackground());
     }
   }
 
@@ -364,15 +390,15 @@ public class UserDefinedColours extends GUserDefinedColours implements
    * @param aa
    *          DOCUMENT ME!
    */
-  JButton makeButton(String label, String aa, Vector caseSensitiveButtons,
-          int buttonIndex)
+  JButton makeButton(String label, String aa,
+          ArrayList<JButton> caseSensitiveButtons, int buttonIndex)
   {
     final JButton button;
     Color col;
 
     if (buttonIndex < caseSensitiveButtons.size())
     {
-      button = (JButton) caseSensitiveButtons.elementAt(buttonIndex);
+      button = caseSensitiveButtons.get(buttonIndex);
       col = button.getBackground();
     }
     else
@@ -380,13 +406,14 @@ public class UserDefinedColours extends GUserDefinedColours implements
       button = new JButton();
       button.addMouseListener(new java.awt.event.MouseAdapter()
       {
+        @Override
         public void mouseClicked(MouseEvent e)
         {
           colourButtonPressed(e);
         }
       });
 
-      caseSensitiveButtons.addElement(button);
+      caseSensitiveButtons.add(button);
 
       col = Color.white;
       if (oldColourScheme != null)
@@ -409,9 +436,10 @@ public class UserDefinedColours extends GUserDefinedColours implements
       button.setMargin(new java.awt.Insets(2, 14, 2, 14));
     }
 
+    button.setOpaque(true); // required for the next line to have effect
     button.setBackground(col);
     button.setText(label);
-    button.setForeground(col.darker().darker().darker());
+    button.setForeground(ColorUtils.darkerThan(col));
     button.setFont(new java.awt.Font("Verdana", Font.BOLD, 10));
 
     return button;
@@ -423,6 +451,7 @@ public class UserDefinedColours extends GUserDefinedColours implements
    * @param e
    *          DOCUMENT ME!
    */
+  @Override
   protected void okButton_actionPerformed(ActionEvent e)
   {
     applyButton_actionPerformed(null);
@@ -441,6 +470,7 @@ public class UserDefinedColours extends GUserDefinedColours implements
    * @param e
    *          DOCUMENT ME!
    */
+  @Override
   protected void applyButton_actionPerformed(ActionEvent e)
   {
     UserColourScheme ucs = getSchemeFromButtons();
@@ -468,7 +498,7 @@ public class UserDefinedColours extends GUserDefinedColours implements
 
     for (int i = 0; i < 24; i++)
     {
-      JButton button = (JButton) upperCaseButtons.elementAt(i);
+      JButton button = upperCaseButtons.get(i);
       newColours[i] = button.getBackground();
     }
 
@@ -479,7 +509,7 @@ public class UserDefinedColours extends GUserDefinedColours implements
       newColours = new Color[23];
       for (int i = 0; i < 23; i++)
       {
-        JButton button = (JButton) lowerCaseButtons.elementAt(i);
+        JButton button = lowerCaseButtons.get(i);
         newColours[i] = button.getBackground();
       }
       ucs.setLowerCaseColours(newColours);
@@ -499,10 +529,11 @@ public class UserDefinedColours extends GUserDefinedColours implements
    * @param e
    *          DOCUMENT ME!
    */
+  @Override
   protected void loadbutton_actionPerformed(ActionEvent e)
   {
-    upperCaseButtons = new Vector();
-    lowerCaseButtons = new Vector();
+    upperCaseButtons = new ArrayList<JButton>();
+    lowerCaseButtons = new ArrayList<JButton>();
 
     JalviewFileChooser chooser = new JalviewFileChooser(
             jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[]
@@ -540,7 +571,7 @@ public class UserDefinedColours extends GUserDefinedColours implements
         resetButtonPanel(true);
         for (int i = 0; i < lowerCaseButtons.size(); i++)
         {
-          JButton button = (JButton) lowerCaseButtons.elementAt(i);
+          JButton button = lowerCaseButtons.get(i);
           button.setBackground(ucs.getLowerCaseColours()[i]);
         }
 
@@ -554,7 +585,7 @@ public class UserDefinedColours extends GUserDefinedColours implements
 
       for (int i = 0; i < upperCaseButtons.size(); i++)
       {
-        JButton button = (JButton) upperCaseButtons.elementAt(i);
+        JButton button = upperCaseButtons.get(i);
         button.setBackground(colors[i]);
       }
 
@@ -679,7 +710,7 @@ public class UserDefinedColours extends GUserDefinedColours implements
 
         jalview.binding.JalviewUserColours jucs = new jalview.binding.JalviewUserColours();
 
-        jucs = (jalview.binding.JalviewUserColours) jucs.unmarshal(in);
+        jucs = jucs.unmarshal(in);
 
         newColours = new Color[jucs.getColourCount()];
 
@@ -713,6 +744,7 @@ public class UserDefinedColours extends GUserDefinedColours implements
    * @param e
    *          DOCUMENT ME!
    */
+  @Override
   protected void savebutton_actionPerformed(ActionEvent e)
   {
     if (schemeName.getText().trim().length() < 1)
@@ -729,7 +761,7 @@ public class UserDefinedColours extends GUserDefinedColours implements
     {
       int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
               MessageManager.formatMessage(
-                      "label.colour_scheme_exists_overwrite", new String[]
+                      "label.colour_scheme_exists_overwrite", new Object[]
                       { schemeName.getText(), schemeName.getText() }),
               MessageManager.getString("label.duplicate_scheme_name"),
               JOptionPane.YES_NO_OPTION);
@@ -804,6 +836,7 @@ public class UserDefinedColours extends GUserDefinedColours implements
    * @param e
    *          DOCUMENT ME!
    */
+  @Override
   protected void cancelButton_actionPerformed(ActionEvent e)
   {
     if (ap != null)
@@ -933,17 +966,19 @@ public class UserDefinedColours extends GUserDefinedColours implements
 
   }
 
+  @Override
   public void caseSensitive_actionPerformed(ActionEvent e)
   {
     resetButtonPanel(caseSensitive.isSelected());
     lcaseColour.setEnabled(caseSensitive.isSelected());
   }
 
+  @Override
   public void lcaseColour_actionPerformed(ActionEvent e)
   {
     if (selectedButtons == null)
     {
-      selectedButtons = new Vector();
+      selectedButtons = new ArrayList<JButton>();
     }
     else
     {
@@ -951,5 +986,4 @@ public class UserDefinedColours extends GUserDefinedColours implements
     }
     selectedButtons.add(lcaseColour);
   }
-
 }
index 1cc1f11..7a485fd 100755 (executable)
@@ -25,7 +25,9 @@ import jalview.util.MessageManager;
 
 import java.awt.*;
 import java.awt.event.*;
+
 import javax.swing.*;
+import javax.swing.colorchooser.AbstractColorChooserPanel;
 
 /**
  * DOCUMENT ME!
@@ -227,6 +229,13 @@ public class GUserDefinedColours extends JPanel
     jPanel4.add(panel1, java.awt.BorderLayout.CENTER);
     this.add(jPanel4, java.awt.BorderLayout.CENTER);
     this.add(colorChooser, java.awt.BorderLayout.EAST);
+    
+    AbstractColorChooserPanel[] choosers = colorChooser.getChooserPanels();
+    // JAL-1360 larger JColorChooser in Java 7 overwrites AA panel; restrict to swatch picker only
+    if (choosers.length > 3) {
+       // Java 7 default has 5 options rather than 3 for choosing colours; keep the first only
+       colorChooser.setChooserPanels(new AbstractColorChooserPanel[]{choosers[0]});
+    }
   }
 
   /**
index f108da1..fd76086 100644 (file)
@@ -59,4 +59,28 @@ public class ColorUtils
 
   }
 
+  /**
+   * Returns a colour three shades darker. Note you can't guarantee that
+   * brighterThan reverses this, as darkerThan may result in black.
+   * 
+   * @param col
+   * @return
+   */
+  public static Color darkerThan(Color col)
+  {
+    return col == null ? null : col.darker().darker().darker();
+  }
+
+  /**
+   * Returns a colour three shades brighter. Note you can't guarantee that
+   * darkerThan reverses this, as brighterThan may result in white.
+   * 
+   * @param col
+   * @return
+   */
+  public static Color brighterThan(Color col)
+  {
+    return col == null ? null : col.brighter().brighter().brighter();
+  }
+
 }
diff --git a/test/jalview/util/ColorUtilsTest.java b/test/jalview/util/ColorUtilsTest.java
new file mode 100644 (file)
index 0000000..da2e6ca
--- /dev/null
@@ -0,0 +1,42 @@
+package jalview.util;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.awt.Color;
+
+import org.junit.Test;
+
+public class ColorUtilsTest
+{
+
+  Color paleColour = new Color(97, 203, 111); // pale green
+
+  Color midColour = new Color(135, 57, 41); // mid red
+
+  Color darkColour = new Color(11, 30, 50); // dark blue
+
+  @Test
+  public void testDarkerThan()
+  {
+    assertEquals("Wrong darker shade", new Color(32, 69, 37),
+            ColorUtils.darkerThan(paleColour));
+    assertEquals("Wrong darker shade", new Color(45, 18, 13),
+            ColorUtils.darkerThan(midColour));
+    assertEquals("Wrong darker shade", new Color(2, 9, 16),
+            ColorUtils.darkerThan(darkColour));
+    assertNull(ColorUtils.darkerThan(null));
+  }
+
+  @Test
+  public void testBrighterThan()
+  {
+    assertEquals("Wrong brighter shade", new Color(255, 255, 255), // white
+            ColorUtils.brighterThan(paleColour));
+    assertEquals("Wrong brighter shade", new Color(255, 164, 117),
+            ColorUtils.brighterThan(midColour));
+    assertEquals("Wrong brighter shade", new Color(30, 85, 144),
+            ColorUtils.brighterThan(darkColour));
+    assertNull(ColorUtils.brighterThan(null));
+  }
+}