From: gmungoc Date: Tue, 7 Feb 2017 15:59:37 +0000 (+0000) Subject: JAL-2401 Lower Case Colour toggleable, help text added X-Git-Tag: Release_2_10_3b1~358 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=e77ec70cef4efba54974739e86673925396f0e92;p=jalview.git JAL-2401 Lower Case Colour toggleable, help text added --- diff --git a/help/html/colourSchemes/user.html b/help/html/colourSchemes/user.html index 7239e4d..fb6c356 100755 --- a/help/html/colourSchemes/user.html +++ b/help/html/colourSchemes/user.html @@ -41,6 +41,9 @@ The Case Sensitive option allows you to choose distinct colours for upper and lower case residue codes.

+ The Lower Case Colour option allows you to apply a selected colour + to all lower case residues. +

Click Apply or OK to set your new colours on the active alignment window.
Click Cancel to undo your changes if you pressed the Apply diff --git a/src/jalview/gui/UserDefinedColours.java b/src/jalview/gui/UserDefinedColours.java index 6b4bd10..e6ff3c8 100755 --- a/src/jalview/gui/UserDefinedColours.java +++ b/src/jalview/gui/UserDefinedColours.java @@ -70,8 +70,6 @@ public class UserDefinedColours extends GUserDefinedColours implements SequenceGroup seqGroup; - ArrayList selectedButtons; - ColourSchemeI oldColourScheme; JInternalFrame frame; @@ -248,33 +246,34 @@ public class UserDefinedColours extends GUserDefinedColours implements } /** - * DOCUMENT ME! + * ChangeListener handler for when a colour is picked in the colour chooser. + * The action is to apply the colour to all selected buttons as their + * background colour. Foreground colour (text) is set to a lighter shade in + * order to highlight which buttons are selected. If 'Lower Case Colour' is + * active, then the colour is applied to all lower case buttons (as well as + * the Lower Case Colour button itself). * * @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 = selectedButtons.get(i); + button.setBackground(newColour); + button.setForeground(ColorUtils.brighterThan(newColour)); + } + if (button == lcaseColour) { - JButton button = null; - final Color newColour = colorChooser.getColor(); - for (int i = 0; i < selectedButtons.size(); i++) + button.setForeground(Color.black); + for (int i = 0; i < lowerCaseButtons.size(); i++) { - button = selectedButtons.get(i); + button = lowerCaseButtons.get(i); button.setBackground(newColour); - button.setForeground(ColorUtils.brighterThan(newColour)); - } - if (button == lcaseColour) - { - for (int i = 0; i < lowerCaseButtons.size(); i++) - { - button = lowerCaseButtons.get(i); - button.setBackground(newColour); - button.setForeground(ColorUtils.brighterThan(button - .getBackground())); - } + button.setForeground(ColorUtils.brighterThan(button.getBackground())); } } } @@ -299,11 +298,6 @@ public class UserDefinedColours extends GUserDefinedColours implements */ public void colourButtonPressed(MouseEvent e) { - if (selectedButtons == null) - { - selectedButtons = new ArrayList(); - } - JButton pressed = (JButton) e.getSource(); if (e.isShiftDown()) @@ -1026,21 +1020,32 @@ public class UserDefinedColours extends GUserDefinedColours implements @Override public void caseSensitive_actionPerformed(ActionEvent e) { - resetButtonPanel(caseSensitive.isSelected()); - lcaseColour.setEnabled(caseSensitive.isSelected()); + boolean selected = caseSensitive.isSelected(); + resetButtonPanel(selected); + lcaseColour.setEnabled(selected); + lcaseColour.setForeground(Color.GRAY); } + /** + * Action on clicking 'Lower case colour', which results in changing colour of + * all lower-case buttons when a colour is picked. A second click of the + * button turns off this behaviour. + */ @Override public void lcaseColour_actionPerformed(ActionEvent e) { - if (selectedButtons == null) + boolean enable = !selectedButtons.contains(lcaseColour); + selectedButtons.clear(); + if (enable) { - selectedButtons = new ArrayList(); + selectedButtons.add(lcaseColour); + lcaseColour.setForeground(lowerCaseButtons.get(0).getForeground()); + lcaseColour.setForeground(Color.black); } else { - selectedButtons.clear(); + lcaseColour.setBackground(Color.white); + lcaseColour.setForeground(Color.gray); } - selectedButtons.add(lcaseColour); } } diff --git a/src/jalview/jbgui/GUserDefinedColours.java b/src/jalview/jbgui/GUserDefinedColours.java index b5695b2..65d02df 100755 --- a/src/jalview/jbgui/GUserDefinedColours.java +++ b/src/jalview/jbgui/GUserDefinedColours.java @@ -32,6 +32,8 @@ import java.awt.GridBagLayout; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.List; import javax.swing.JButton; import javax.swing.JCheckBox; @@ -104,6 +106,8 @@ public class GUserDefinedColours extends JPanel protected JButton lcaseColour = new JButton(); + protected List selectedButtons; + /** * Creates a new GUserDefinedColours object. */ @@ -253,6 +257,8 @@ public class GUserDefinedColours extends JPanel colorChooser .setChooserPanels(new AbstractColorChooserPanel[] { choosers[0] }); } + + selectedButtons = new ArrayList(); } /**