JAL-2383 restore PID colour threshold from project; enable/disable
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 19 Jan 2017 16:37:02 +0000 (16:37 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 19 Jan 2017 16:37:02 +0000 (16:37 +0000)
modify PID/Conservation (and add to popup menus)

12 files changed:
resources/lang/Messages.properties
src/jalview/appletgui/APopupMenu.java
src/jalview/appletgui/AlignFrame.java
src/jalview/appletgui/RedundancyPanel.java
src/jalview/appletgui/SliderPanel.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/Jalview2XML.java
src/jalview/gui/PopupMenu.java
src/jalview/gui/RedundancyPanel.java
src/jalview/gui/SliderPanel.java
src/jalview/jbgui/GAlignFrame.java
src/jalview/jbgui/GSliderPanel.java

index d418c76..a86154c 100644 (file)
@@ -323,7 +323,7 @@ label.size = Size:
 label.style = Style:
 label.calculating = Calculating....
 label.modify_conservation_visibility = Modify conservation visibility
-label.colour_residues_above_occurence = Colour residues above % occurence
+label.colour_residues_above_occurence = Colour residues above % occurrence
 label.set_this_label_text = set this label text
 label.sequences_from = Sequences from {0}
 label.successfully_loaded_file  = Successfully loaded file {0}
index 8f7a15b..209ca22 100644 (file)
@@ -93,8 +93,6 @@ public class APopupMenu extends java.awt.PopupMenu implements
 
   protected MenuItem buriedColour = new MenuItem();
 
-  protected CheckboxMenuItem abovePIDColour = new CheckboxMenuItem();
-
   protected MenuItem userDefinedColour = new MenuItem();
 
   protected MenuItem PIDColour = new MenuItem();
@@ -103,8 +101,14 @@ public class APopupMenu extends java.awt.PopupMenu implements
 
   MenuItem noColourmenuItem = new MenuItem();
 
+  protected CheckboxMenuItem abovePIDColour = new CheckboxMenuItem();
+
+  MenuItem modifyPID = new MenuItem();
+
   protected CheckboxMenuItem conservationMenuItem = new CheckboxMenuItem();
 
+  MenuItem modifyConservation = new MenuItem();
+
   final AlignmentPanel ap;
 
   MenuItem unGroupMenuItem = new MenuItem();
@@ -248,7 +252,9 @@ public class APopupMenu extends java.awt.PopupMenu implements
         if (sg.cs != null)
         {
           abovePIDColour.setState(sg.cs.getThreshold() > 0);
+          modifyPID.setEnabled(abovePIDColour.getState());
           conservationMenuItem.setState(sg.cs.conservationApplied());
+          modifyConservation.setEnabled(conservationMenuItem.getState());
         }
       }
     }
@@ -589,6 +595,14 @@ public class APopupMenu extends java.awt.PopupMenu implements
     {
       noColourmenuItem_actionPerformed();
     }
+    else if (source == modifyConservation)
+    {
+      conservationMenuItem_itemStateChanged();
+    }
+    else if (source == modifyPID)
+    {
+      abovePIDColour_itemStateChanged();
+    }
     else if (source == unGroupMenuItem)
     {
       unGroupMenuItem_actionPerformed();
@@ -902,6 +916,14 @@ public class APopupMenu extends java.awt.PopupMenu implements
     nucleotideMenuItem.addActionListener(this);
     conservationMenuItem.addItemListener(this);
     abovePIDColour.addItemListener(this);
+    modifyPID.setLabel(MessageManager
+            .getString("label.modify_identity_threshold"));
+    modifyPID.addActionListener(this);
+    modifyConservation.setLabel(MessageManager
+            .getString("label.modify_conservation_threshold"));
+    modifyPID.setEnabled(abovePIDColour.getState());
+    modifyConservation.setEnabled(conservationMenuItem.getState());
+    modifyConservation.addActionListener(this);
     colourMenu.setLabel(MessageManager.getString("label.group_colour"));
     showBoxes.setLabel(MessageManager.getString("action.boxes"));
     showBoxes.setState(true);
@@ -957,7 +979,9 @@ public class APopupMenu extends java.awt.PopupMenu implements
     colourMenu.add(userDefinedColour);
     colourMenu.addSeparator();
     colourMenu.add(abovePIDColour);
+    colourMenu.add(modifyPID);
     colourMenu.add(conservationMenuItem);
+    colourMenu.add(modifyConservation);
 
     noColourmenuItem.setLabel(MessageManager.getString("label.none"));
     noColourmenuItem.addActionListener(this);
@@ -1119,11 +1143,11 @@ public class APopupMenu extends java.awt.PopupMenu implements
     else
     // remove PIDColouring
     {
+      SliderPanel.hidePIDSlider();
       sg.cs.setThreshold(0, ap.av.isIgnoreGapsConsensus());
     }
-
+    modifyPID.setEnabled(abovePIDColour.getState());
     refresh();
-
   }
 
   protected void userDefinedColour_actionPerformed()
@@ -1178,9 +1202,10 @@ public class APopupMenu extends java.awt.PopupMenu implements
     else
     // remove ConservationColouring
     {
+      SliderPanel.hideConservationSlider();
       sg.cs.setConservation(null);
     }
-
+    modifyConservation.setEnabled(conservationMenuItem.getState());
     refresh();
   }
 
index 86dc19b..2287979 100644 (file)
@@ -2678,26 +2678,43 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
 
   protected void conservationMenuItem_actionPerformed()
   {
-    viewport.setConservationSelected(conservationMenuItem.getState());
+    boolean selected = conservationMenuItem.getState();
+    modifyConservation.setEnabled(selected);
+    viewport.setConservationSelected(selected);
 
-    viewport.setAbovePIDThreshold(false);
-    abovePIDThreshold.setState(false);
+    // viewport.setAbovePIDThreshold(false);
+    // abovePIDThreshold.setState(false);
 
     changeColour(viewport.getGlobalColourScheme());
 
-    modifyConservation_actionPerformed();
+    if (selected)
+    {
+      modifyConservation_actionPerformed();
+    }
+    else
+    {
+      SliderPanel.hideConservationSlider();
+    }
   }
 
   public void abovePIDThreshold_actionPerformed()
   {
-    viewport.setAbovePIDThreshold(abovePIDThreshold.getState());
-
-    conservationMenuItem.setState(false);
-    viewport.setConservationSelected(false);
+    boolean selected = abovePIDThreshold.getState();
+    modifyPID.setEnabled(selected);
+    viewport.setAbovePIDThreshold(selected);
+    // conservationMenuItem.setState(false);
+    // viewport.setConservationSelected(false);
 
     changeColour(viewport.getGlobalColourScheme());
 
-    modifyPID_actionPerformed();
+    if (selected)
+    {
+      modifyPID_actionPerformed();
+    }
+    else
+    {
+      SliderPanel.hidePIDSlider();
+    }
   }
 
   public void sortPairwiseMenuItem_actionPerformed()
@@ -3519,9 +3536,11 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     nucleotideColour.addActionListener(this);
     modifyPID.setLabel(MessageManager
             .getString("label.modify_identity_threshold"));
+    modifyPID.setEnabled(abovePIDThreshold.getState());
     modifyPID.addActionListener(this);
     modifyConservation.setLabel(MessageManager
             .getString("label.modify_conservation_threshold"));
+    modifyConservation.setEnabled(conservationMenuItem.getState());
     modifyConservation.addActionListener(this);
     annotationColour.setLabel(MessageManager
             .getString("action.by_annotation"));
index 4aea837..6be416c 100644 (file)
@@ -74,9 +74,10 @@ public class RedundancyPanel extends SliderPanel implements Runnable,
 
     slider.addAdjustmentListener(new AdjustmentListener()
     {
+      @Override
       public void adjustmentValueChanged(AdjustmentEvent evt)
       {
-        valueField.setText(slider.getValue() + "");
+        valueField.setText(String.valueOf(slider.getValue()));
         sliderValueChanged();
       }
     });
@@ -104,6 +105,7 @@ public class RedundancyPanel extends SliderPanel implements Runnable,
    * 
    * @return DOCUMENT ME!
    */
+  @Override
   public void run()
   {
     label.setText(MessageManager.getString("label.calculating"));
@@ -172,6 +174,7 @@ public class RedundancyPanel extends SliderPanel implements Runnable,
 
   }
 
+  @Override
   public void applyButton_actionPerformed()
   {
     Vector del = new Vector();
@@ -230,6 +233,7 @@ public class RedundancyPanel extends SliderPanel implements Runnable,
 
   }
 
+  @Override
   public void undoButton_actionPerformed()
   {
     CommandI command = (CommandI) historyList.pop();
@@ -263,31 +267,38 @@ public class RedundancyPanel extends SliderPanel implements Runnable,
     }
   }
 
+  @Override
   public void windowOpened(WindowEvent evt)
   {
   }
 
+  @Override
   public void windowClosing(WindowEvent evt)
   {
     ap.idPanel.idCanvas.setHighlighted(null);
   }
 
+  @Override
   public void windowClosed(WindowEvent evt)
   {
   }
 
+  @Override
   public void windowActivated(WindowEvent evt)
   {
   }
 
+  @Override
   public void windowDeactivated(WindowEvent evt)
   {
   }
 
+  @Override
   public void windowIconified(WindowEvent evt)
   {
   }
 
+  @Override
   public void windowDeiconified(WindowEvent evt)
   {
   }
index 35c2a22..5ee665a 100644 (file)
@@ -38,6 +38,8 @@ import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.AdjustmentEvent;
 import java.awt.event.AdjustmentListener;
+import java.awt.event.FocusAdapter;
+import java.awt.event.FocusEvent;
 import java.awt.event.MouseEvent;
 import java.awt.event.MouseListener;
 import java.awt.event.WindowAdapter;
@@ -106,6 +108,7 @@ public class SliderPanel extends Panel implements ActionListener,
               conservationSlider.getTitle(), 420, 100);
       conservationSlider.addWindowListener(new WindowAdapter()
       {
+        @Override
         public void windowClosing(WindowEvent e)
         {
           conservationSlider = null;
@@ -165,6 +168,7 @@ public class SliderPanel extends Panel implements ActionListener,
               420, 100);
       PIDSlider.addWindowListener(new WindowAdapter()
       {
+        @Override
         public void windowClosing(WindowEvent e)
         {
           PIDSlider = null;
@@ -174,6 +178,17 @@ public class SliderPanel extends Panel implements ActionListener,
 
   }
 
+  public static void hidePIDSlider()
+  {
+    PIDSlider.setVisible(false);
+    PIDSlider = null;
+  }
+
+  public static void hideConservationSlider()
+  {
+    conservationSlider.setVisible(false);
+    conservationSlider = null;
+  }
   public SliderPanel(AlignmentPanel ap, int value, boolean forConserve,
           ColourSchemeI cs)
   {
@@ -200,7 +215,7 @@ public class SliderPanel extends Panel implements ActionListener,
     else
     {
       label.setText(MessageManager
-              .getString("label.colour_residues_above_occurence"));
+              .getString("label.colour_residues_above_occurrence"));
       slider.setMinimum(0);
       slider.setMaximum(100 + slider.getVisibleAmount());
       slider.setBlockIncrement(1);
@@ -261,6 +276,7 @@ public class SliderPanel extends Panel implements ActionListener,
     allGroupsCheck.setEnabled(b);
   }
 
+  @Override
   public void actionPerformed(ActionEvent evt)
   {
     if (evt.getSource() == applyButton)
@@ -277,6 +293,7 @@ public class SliderPanel extends Panel implements ActionListener,
     }
   }
 
+  @Override
   public void adjustmentValueChanged(AdjustmentEvent evt)
   {
     valueField.setText(slider.getValue() + "");
@@ -287,11 +304,11 @@ public class SliderPanel extends Panel implements ActionListener,
   {
     try
     {
-      int i = Integer.parseInt(valueField.getText());
+      int i = Integer.valueOf(valueField.getText());
       slider.setValue(i);
-    } catch (Exception ex)
+    } catch (NumberFormatException ex)
     {
-      valueField.setText(slider.getValue() + "");
+      valueField.setText(String.valueOf(slider.getValue()));
     }
   }
 
@@ -344,6 +361,16 @@ public class SliderPanel extends Panel implements ActionListener,
     valueField.setText("   ");
     valueField.addActionListener(this);
     valueField.setColumns(3);
+    valueField.addFocusListener(new FocusAdapter()
+    {
+      @Override
+      public void focusLost(FocusEvent e)
+      {
+        valueField_actionPerformed();
+        valueChanged(slider.getValue());
+      }
+    });
+    
     label.setFont(new java.awt.Font("Verdana", 0, 11));
     label.setText(MessageManager.getString("label.set_this_label_text"));
     jPanel1.setLayout(borderLayout1);
@@ -381,23 +408,28 @@ public class SliderPanel extends Panel implements ActionListener,
   {
   }
 
+  @Override
   public void mousePressed(MouseEvent evt)
   {
   }
 
+  @Override
   public void mouseReleased(MouseEvent evt)
   {
     ap.paintAlignment(true);
   }
 
+  @Override
   public void mouseClicked(MouseEvent evt)
   {
   }
 
+  @Override
   public void mouseEntered(MouseEvent evt)
   {
   }
 
+  @Override
   public void mouseExited(MouseEvent evt)
   {
   }
index 370e649..44a2318 100644 (file)
@@ -894,7 +894,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     padGapsMenuitem.setSelected(av.isPadGaps());
     colourTextMenuItem.setSelected(av.isShowColourText());
     abovePIDThreshold.setSelected(av.getAbovePIDThreshold());
+    modifyPID.setEnabled(abovePIDThreshold.isSelected());
     conservationMenuItem.setSelected(av.getConservationSelected());
+    modifyConservation.setEnabled(conservationMenuItem.isSelected());
     seqLimits.setSelected(av.getShowJVSuffix());
     idRightAlign.setSelected(av.isRightAlignIds());
     centreColumnLabelsMenuItem.setState(av.isCentreColumnLabels());
@@ -3498,12 +3500,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
 
   /**
    * DOCUMENT ME!
-   * 
-   * @param e
-   *          DOCUMENT ME!
    */
   @Override
-  protected void modifyPID_actionPerformed(ActionEvent e)
+  protected void modifyPID_actionPerformed()
   {
     if (viewport.getAbovePIDThreshold()
             && viewport.getGlobalColourScheme() != null)
@@ -3516,12 +3515,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
 
   /**
    * DOCUMENT ME!
-   * 
-   * @param e
-   *          DOCUMENT ME!
    */
   @Override
-  protected void modifyConservation_actionPerformed(ActionEvent e)
+  protected void modifyConservation_actionPerformed()
   {
     if (viewport.getConservationSelected()
             && viewport.getGlobalColourScheme() != null)
@@ -3533,41 +3529,45 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   }
 
   /**
-   * DOCUMENT ME!
-   * 
-   * @param e
-   *          DOCUMENT ME!
+   * Action on selecting or deselecting (Colour) By Conservation
    */
   @Override
-  protected void conservationMenuItem_actionPerformed(ActionEvent e)
+  protected void conservationMenuItem_actionPerformed()
   {
-    viewport.setConservationSelected(conservationMenuItem.isSelected());
-
-    viewport.setAbovePIDThreshold(false);
-    abovePIDThreshold.setSelected(false);
+    boolean selected = conservationMenuItem.isSelected();
+    modifyConservation.setEnabled(selected);
+    viewport.setConservationSelected(selected);
 
     changeColour(viewport.getGlobalColourScheme());
-
-    modifyConservation_actionPerformed(null);
+    if (selected)
+    {
+      modifyConservation_actionPerformed();
+    }
+    else
+    {
+      SliderPanel.hideConservationSlider();
+    }
   }
 
   /**
-   * DOCUMENT ME!
-   * 
-   * @param e
-   *          DOCUMENT ME!
+   * Action on selecting or deselecting (Colour) Above PID Threshold
    */
   @Override
-  public void abovePIDThreshold_actionPerformed(ActionEvent e)
+  public void abovePIDThreshold_actionPerformed()
   {
-    viewport.setAbovePIDThreshold(abovePIDThreshold.isSelected());
-
-    conservationMenuItem.setSelected(false);
-    viewport.setConservationSelected(false);
+    boolean selected = abovePIDThreshold.isSelected();
+    modifyPID.setEnabled(selected);
+    viewport.setAbovePIDThreshold(selected);
 
     changeColour(viewport.getGlobalColourScheme());
-
-    modifyPID_actionPerformed(null);
+    if (selected)
+    {
+      modifyPID_actionPerformed();
+    }
+    else
+    {
+      SliderPanel.hidePIDSlider();
+    }
   }
 
   /**
index 35db33f..d8537bb 100644 (file)
@@ -129,7 +129,6 @@ import java.util.jar.JarInputStream;
 import java.util.jar.JarOutputStream;
 
 import javax.swing.JInternalFrame;
-import javax.swing.JOptionPane;
 import javax.swing.SwingUtilities;
 
 import org.exolab.castor.xml.Marshaller;
@@ -4422,10 +4421,12 @@ public class Jalview2XML
 
     af.viewport.setShowAnnotation(view.getShowAnnotation());
     af.viewport.setAbovePIDThreshold(view.getPidSelected());
+    af.viewport.setThreshold(view.getPidThreshold());
 
     af.viewport.setColourText(view.getShowColourText());
 
     af.viewport.setConservationSelected(view.getConservationSelected());
+    af.viewport.setIncrement(view.getConsThreshold());
     af.viewport.setShowJVSuffix(view.getShowFullId());
     af.viewport.setRightAlignIds(view.getRightAlignIds());
     af.viewport.setFont(
@@ -4475,7 +4476,6 @@ public class Jalview2XML
 
       if (cs != null)
       {
-        cs.setThreshold(view.getPidThreshold(), true);
         cs.setConsensus(af.viewport.getSequenceConsensusHash());
       }
     }
index e36204c..3a99f9e 100644 (file)
@@ -110,8 +110,6 @@ public class PopupMenu extends JPopupMenu
 
   protected JRadioButtonMenuItem buriedColour = new JRadioButtonMenuItem();
 
-  protected JCheckBoxMenuItem abovePIDColour = new JCheckBoxMenuItem();
-
   protected JRadioButtonMenuItem userDefinedColour = new JRadioButtonMenuItem();
 
   protected JRadioButtonMenuItem PIDColour = new JRadioButtonMenuItem();
@@ -124,8 +122,14 @@ public class PopupMenu extends JPopupMenu
 
   JRadioButtonMenuItem noColourmenuItem = new JRadioButtonMenuItem();
 
+  protected JCheckBoxMenuItem abovePIDColour = new JCheckBoxMenuItem();
+
+  protected JMenuItem modifyPID = new JMenuItem();
+
   protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem();
 
+  protected JMenuItem modifyConservation = new JMenuItem();
+
   AlignmentPanel ap;
 
   JMenu sequenceMenu = new JMenu();
@@ -258,7 +262,7 @@ public class PopupMenu extends JPopupMenu
     {
       JMenuItem item = new JMenuItem(ff);
 
-      item.addActionListener(new java.awt.event.ActionListener()
+      item.addActionListener(new ActionListener()
       {
         @Override
         public void actionPerformed(ActionEvent e)
@@ -342,7 +346,7 @@ public class PopupMenu extends JPopupMenu
               menuItem.setText(MessageManager.formatMessage(
                       "label.2d_rna_structure_line",
                       new Object[] { aa.label }));
-              menuItem.addActionListener(new java.awt.event.ActionListener()
+              menuItem.addActionListener(new ActionListener()
               {
                 @Override
                 public void actionPerformed(ActionEvent e)
@@ -370,7 +374,7 @@ public class PopupMenu extends JPopupMenu
               menuItem.setText(MessageManager.formatMessage(
                       "label.2d_rna_sequence_name",
                       new Object[] { seq.getName() }));
-              menuItem.addActionListener(new java.awt.event.ActionListener()
+              menuItem.addActionListener(new ActionListener()
               {
                 @Override
                 public void actionPerformed(ActionEvent e)
@@ -391,7 +395,7 @@ public class PopupMenu extends JPopupMenu
 
       menuItem = new JMenuItem(
               MessageManager.getString("action.hide_sequences"));
-      menuItem.addActionListener(new java.awt.event.ActionListener()
+      menuItem.addActionListener(new ActionListener()
       {
         @Override
         public void actionPerformed(ActionEvent e)
@@ -407,7 +411,7 @@ public class PopupMenu extends JPopupMenu
         menuItem = new JMenuItem(MessageManager.formatMessage(
                 "label.represent_group_with",
                 new Object[] { seq.getName() }));
-        menuItem.addActionListener(new java.awt.event.ActionListener()
+        menuItem.addActionListener(new ActionListener()
         {
           @Override
           public void actionPerformed(ActionEvent e)
@@ -538,13 +542,15 @@ public class PopupMenu extends JPopupMenu
       {
         if (sg.cs.conservationApplied())
         {
-        conservationMenuItem.setSelected(true);
+          conservationMenuItem.setSelected(true);
         }
         if (sg.cs.getThreshold() > 0)
         {
           abovePIDColour.setSelected(true);
         }
       }
+      modifyConservation.setEnabled(conservationMenuItem.isSelected());
+      modifyPID.setEnabled(abovePIDColour.isSelected());
       displayNonconserved.setSelected(sg.getShowNonconserved());
       showText.setSelected(sg.getDisplayText());
       showColourText.setSelected(sg.getColourText());
@@ -668,8 +674,6 @@ public class PopupMenu extends JPopupMenu
 
   }
 
-
-
   /**
    * Add annotation types to 'Show annotations' and/or 'Hide annotations' menus.
    * "All" is added first, followed by a separator. Then add any annotation
@@ -785,7 +789,7 @@ public class PopupMenu extends JPopupMenu
     label = label.substring(1, label.length() - 1); // a, b, c
     final JMenuItem item = new JMenuItem(label);
     item.setToolTipText(calcId);
-    item.addActionListener(new java.awt.event.ActionListener()
+    item.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -967,7 +971,7 @@ public class PopupMenu extends JPopupMenu
     JMenuItem item = new JMenuItem(label);
     item.setToolTipText(MessageManager.formatMessage(
             "label.open_url_param", new Object[] { url }));
-    item.addActionListener(new java.awt.event.ActionListener()
+    item.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1044,7 +1048,7 @@ public class PopupMenu extends JPopupMenu
   {
     groupMenu.setText(MessageManager.getString("label.selection"));
     groupName.setText(MessageManager.getString("label.name"));
-    groupName.addActionListener(new java.awt.event.ActionListener()
+    groupName.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1055,7 +1059,7 @@ public class PopupMenu extends JPopupMenu
     sequenceMenu.setText(MessageManager.getString("label.sequence"));
     sequenceName.setText(MessageManager
             .getString("label.edit_name_description"));
-    sequenceName.addActionListener(new java.awt.event.ActionListener()
+    sequenceName.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1065,7 +1069,7 @@ public class PopupMenu extends JPopupMenu
     });
     chooseAnnotations.setText(MessageManager
             .getString("action.choose_annotations"));
-    chooseAnnotations.addActionListener(new java.awt.event.ActionListener()
+    chooseAnnotations.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1075,7 +1079,7 @@ public class PopupMenu extends JPopupMenu
     });
     sequenceDetails.setText(MessageManager
             .getString("label.sequence_details"));
-    sequenceDetails.addActionListener(new java.awt.event.ActionListener()
+    sequenceDetails.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1085,19 +1089,18 @@ public class PopupMenu extends JPopupMenu
     });
     sequenceSelDetails.setText(MessageManager
             .getString("label.sequence_details"));
-    sequenceSelDetails
-            .addActionListener(new java.awt.event.ActionListener()
-            {
-              @Override
-              public void actionPerformed(ActionEvent e)
-              {
-                sequenceSelectionDetails_actionPerformed();
-              }
-            });
+    sequenceSelDetails.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        sequenceSelectionDetails_actionPerformed();
+      }
+    });
     PIDColour.setFocusPainted(false);
     unGroupMenuItem
             .setText(MessageManager.getString("action.remove_group"));
-    unGroupMenuItem.addActionListener(new java.awt.event.ActionListener()
+    unGroupMenuItem.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1107,18 +1110,17 @@ public class PopupMenu extends JPopupMenu
     });
     createGroupMenuItem.setText(MessageManager
             .getString("action.create_group"));
-    createGroupMenuItem
-            .addActionListener(new java.awt.event.ActionListener()
-            {
-              @Override
-              public void actionPerformed(ActionEvent e)
-              {
-                createGroupMenuItem_actionPerformed();
-              }
-            });
+    createGroupMenuItem.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        createGroupMenuItem_actionPerformed();
+      }
+    });
 
     outline.setText(MessageManager.getString("action.border_colour"));
-    outline.addActionListener(new java.awt.event.ActionListener()
+    outline.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1385,7 +1387,9 @@ public class PopupMenu extends JPopupMenu
 
     colourMenu.addSeparator();
     colourMenu.add(abovePIDColour);
+    colourMenu.add(modifyPID);
     colourMenu.add(conservationMenuItem);
+    colourMenu.add(modifyConservation);
     editMenu.add(copy);
     editMenu.add(cut);
     editMenu.add(editSequence);
@@ -1404,7 +1408,7 @@ public class PopupMenu extends JPopupMenu
     jMenu1.add(outline);
     jMenu1.add(displayNonconserved);
     noColourmenuItem.setText(MessageManager.getString("label.none"));
-    noColourmenuItem.addActionListener(new java.awt.event.ActionListener()
+    noColourmenuItem.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1415,7 +1419,7 @@ public class PopupMenu extends JPopupMenu
 
     clustalColour.setText(MessageManager
             .getString("label.clustalx_colours"));
-    clustalColour.addActionListener(new java.awt.event.ActionListener()
+    clustalColour.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1424,7 +1428,7 @@ public class PopupMenu extends JPopupMenu
       }
     });
     zappoColour.setText(MessageManager.getString("label.zappo"));
-    zappoColour.addActionListener(new java.awt.event.ActionListener()
+    zappoColour.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1433,7 +1437,7 @@ public class PopupMenu extends JPopupMenu
       }
     });
     taylorColour.setText(MessageManager.getString("label.taylor"));
-    taylorColour.addActionListener(new java.awt.event.ActionListener()
+    taylorColour.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1443,17 +1447,16 @@ public class PopupMenu extends JPopupMenu
     });
     hydrophobicityColour.setText(MessageManager
             .getString("label.hydrophobicity"));
-    hydrophobicityColour
-            .addActionListener(new java.awt.event.ActionListener()
-            {
-              @Override
-              public void actionPerformed(ActionEvent e)
-              {
-                hydrophobicityColour_actionPerformed();
-              }
-            });
+    hydrophobicityColour.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        hydrophobicityColour_actionPerformed();
+      }
+    });
     helixColour.setText(MessageManager.getString("label.helix_propensity"));
-    helixColour.addActionListener(new java.awt.event.ActionListener()
+    helixColour.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1463,7 +1466,7 @@ public class PopupMenu extends JPopupMenu
     });
     strandColour.setText(MessageManager
             .getString("label.strand_propensity"));
-    strandColour.addActionListener(new java.awt.event.ActionListener()
+    strandColour.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1472,7 +1475,7 @@ public class PopupMenu extends JPopupMenu
       }
     });
     turnColour.setText(MessageManager.getString("label.turn_propensity"));
-    turnColour.addActionListener(new java.awt.event.ActionListener()
+    turnColour.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1481,7 +1484,7 @@ public class PopupMenu extends JPopupMenu
       }
     });
     buriedColour.setText(MessageManager.getString("label.buried_index"));
-    buriedColour.addActionListener(new java.awt.event.ActionListener()
+    buriedColour.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1489,19 +1492,9 @@ public class PopupMenu extends JPopupMenu
         buriedColour_actionPerformed();
       }
     });
-    abovePIDColour.setText(MessageManager
-            .getString("label.above_identity_percentage"));
-    abovePIDColour.addActionListener(new java.awt.event.ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        abovePIDColour_actionPerformed();
-      }
-    });
     userDefinedColour.setText(MessageManager
             .getString("action.user_defined"));
-    userDefinedColour.addActionListener(new java.awt.event.ActionListener()
+    userDefinedColour.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1511,7 +1504,7 @@ public class PopupMenu extends JPopupMenu
     });
     PIDColour
             .setText(MessageManager.getString("label.percentage_identity"));
-    PIDColour.addActionListener(new java.awt.event.ActionListener()
+    PIDColour.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1520,7 +1513,7 @@ public class PopupMenu extends JPopupMenu
       }
     });
     BLOSUM62Colour.setText(MessageManager.getString("label.blosum62"));
-    BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener()
+    BLOSUM62Colour.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -1530,33 +1523,87 @@ public class PopupMenu extends JPopupMenu
     });
     purinePyrimidineColour.setText(MessageManager
             .getString("label.purine_pyrimidine"));
-    purinePyrimidineColour
-            .addActionListener(new java.awt.event.ActionListener()
-            {
-              @Override
-              public void actionPerformed(ActionEvent e)
-              {
-                purinePyrimidineColour_actionPerformed();
-              }
-            });
+    purinePyrimidineColour.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        purinePyrimidineColour_actionPerformed();
+      }
+    });
 
     /*
-     * covariationColour.addActionListener(new java.awt.event.ActionListener() {
+     * covariationColour.addActionListener(new ActionListener() {
      * public void actionPerformed(ActionEvent e) {
      * covariationColour_actionPerformed(); } });
      */
+    abovePIDColour.setText(MessageManager
+            .getString("label.above_identity_percentage"));
+    abovePIDColour.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        abovePIDColour_actionPerformed();
+      }
+    });
+
+    modifyPID.setText(MessageManager
+            .getString("label.modify_identity_threshold"));
+    modifyPID.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        modifyPID_actionPerformed();
+      }
+    });
 
     conservationMenuItem.setText(MessageManager
             .getString("label.conservation"));
-    conservationMenuItem
-            .addActionListener(new java.awt.event.ActionListener()
-            {
-              @Override
-              public void actionPerformed(ActionEvent e)
-              {
-                conservationMenuItem_actionPerformed();
-              }
-            });
+    conservationMenuItem.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        conservationMenuItem_actionPerformed();
+      }
+    });
+
+    modifyConservation.setText(MessageManager
+            .getString("label.modify_conservation_threshold"));
+    modifyConservation.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        modifyConservation_actionPerformed();
+      }
+    });
+  }
+
+  protected void modifyConservation_actionPerformed()
+  {
+    SequenceGroup sg = getGroup();
+    if (sg.cs != null)
+    {
+      SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
+      SliderPanel.showConservationSlider();
+    }
+  }
+
+  protected void modifyPID_actionPerformed()
+  {
+    SequenceGroup sg = getGroup();
+    if (sg.cs != null)
+    {
+      // int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
+      // .getName());
+      // sg.cs.setThreshold(threshold, ap.av.isIgnoreGapsConsensus());
+      SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
+              .getName());
+      SliderPanel.showPIDSlider();
+    }
   }
 
   /**
@@ -1863,7 +1910,8 @@ public class PopupMenu extends JPopupMenu
       return;
     }
 
-    if (abovePIDColour.isSelected())
+    boolean selected = abovePIDColour.isSelected();
+    if (selected)
     {
       sg.cs.setConsensus(AAFrequency.calculate(
               sg.getSequences(ap.av.getHiddenRepSequences()),
@@ -1880,7 +1928,9 @@ public class PopupMenu extends JPopupMenu
     // remove PIDColouring
     {
       sg.cs.setThreshold(0, ap.av.isIgnoreGapsConsensus());
+      SliderPanel.hidePIDSlider();
     }
+    modifyPID.setEnabled(selected);
 
     refresh();
   }
@@ -1982,7 +2032,8 @@ public class PopupMenu extends JPopupMenu
       return;
     }
 
-    if (conservationMenuItem.isSelected())
+    boolean selected = conservationMenuItem.isSelected();
+    if (selected)
     {
       // JBPNote: Conservation name shouldn't be i18n translated
       Conservation c = new Conservation("Group", sg.getSequences(ap.av
@@ -2001,7 +2052,9 @@ public class PopupMenu extends JPopupMenu
     // remove ConservationColouring
     {
       sg.cs.setConservation(null);
+      SliderPanel.hideConservationSlider();
     }
+    modifyConservation.setEnabled(selected);
 
     refresh();
   }
index a9d2690..cbbcf70 100755 (executable)
@@ -82,6 +82,7 @@ public class RedundancyPanel extends GSliderPanel implements Runnable
 
     slider.addChangeListener(new ChangeListener()
     {
+      @Override
       public void stateChanged(ChangeEvent evt)
       {
         valueField.setText(slider.getValue() + "");
@@ -105,6 +106,7 @@ public class RedundancyPanel extends GSliderPanel implements Runnable
             false);
     frame.addInternalFrameListener(new InternalFrameAdapter()
     {
+      @Override
       public void internalFrameClosing(InternalFrameEvent evt)
       {
         ap.getIdPanel().getIdCanvas().setHighlighted(null);
@@ -125,6 +127,7 @@ public class RedundancyPanel extends GSliderPanel implements Runnable
    * 
    * @return DOCUMENT ME!
    */
+  @Override
   public void run()
   {
     JProgressBar progress = new JProgressBar();
@@ -207,6 +210,7 @@ public class RedundancyPanel extends GSliderPanel implements Runnable
    * @param e
    *          DOCUMENT ME!
    */
+  @Override
   public void applyButton_actionPerformed(ActionEvent e)
   {
     Vector del = new Vector();
@@ -271,6 +275,7 @@ public class RedundancyPanel extends GSliderPanel implements Runnable
    * @param e
    *          DOCUMENT ME!
    */
+  @Override
   public void undoButton_actionPerformed(ActionEvent e)
   {
     if (historyList == null || historyList.isEmpty())
@@ -297,22 +302,4 @@ public class RedundancyPanel extends GSliderPanel implements Runnable
     }
   }
 
-  /**
-   * DOCUMENT ME!
-   * 
-   * @param e
-   *          DOCUMENT ME!
-   */
-  public void valueField_actionPerformed(ActionEvent e)
-  {
-    try
-    {
-      int i = Integer.parseInt(valueField.getText());
-      slider.setValue(i);
-    } catch (Exception ex)
-    {
-      valueField.setText(slider.getValue() + "");
-    }
-  }
-
 }
index a381e8b..af77c48 100755 (executable)
@@ -25,9 +25,9 @@ import jalview.jbgui.GSliderPanel;
 import jalview.schemes.ColourSchemeI;
 import jalview.util.MessageManager;
 
-import java.awt.event.ActionEvent;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
+import java.beans.PropertyVetoException;
 import java.util.Iterator;
 
 import javax.swing.JInternalFrame;
@@ -91,6 +91,7 @@ public class SliderPanel extends GSliderPanel
 
     slider.addChangeListener(new ChangeListener()
     {
+      @Override
       public void stateChanged(ChangeEvent evt)
       {
         valueField.setText(slider.getValue() + "");
@@ -100,6 +101,7 @@ public class SliderPanel extends GSliderPanel
 
     slider.addMouseListener(new MouseAdapter()
     {
+      @Override
       public void mouseReleased(MouseEvent evt)
       {
         ap.paintAlignment(true);
@@ -157,6 +159,28 @@ public class SliderPanel extends GSliderPanel
     return sp.getValue();
   }
 
+  public static void hidePIDSlider()
+  {
+    try
+    {
+      PIDSlider.setClosed(true);
+      PIDSlider = null;
+    } catch (PropertyVetoException ex)
+    {
+    }
+  }
+
+  public static void hideConservationSlider()
+  {
+    try
+    {
+      conservationSlider.setClosed(true);
+      conservationSlider = null;
+    } catch (PropertyVetoException ex)
+    {
+    }
+  }
+
   /**
    * DOCUMENT ME!
    */
@@ -177,6 +201,7 @@ public class SliderPanel extends GSliderPanel
       conservationSlider
               .addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
               {
+                @Override
                 public void internalFrameClosed(
                         javax.swing.event.InternalFrameEvent e)
                 {
@@ -257,6 +282,7 @@ public class SliderPanel extends GSliderPanel
       PIDSlider
               .addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
               {
+                @Override
                 public void internalFrameClosed(
                         javax.swing.event.InternalFrameEvent e)
                 {
@@ -329,24 +355,6 @@ public class SliderPanel extends GSliderPanel
   /**
    * DOCUMENT ME!
    * 
-   * @param e
-   *          DOCUMENT ME!
-   */
-  public void valueField_actionPerformed(ActionEvent e)
-  {
-    try
-    {
-      int i = Integer.parseInt(valueField.getText());
-      slider.setValue(i);
-    } catch (NumberFormatException ex)
-    {
-      valueField.setText(slider.getValue() + "");
-    }
-  }
-
-  /**
-   * DOCUMENT ME!
-   * 
    * @param value
    *          DOCUMENT ME!
    */
@@ -365,6 +373,7 @@ public class SliderPanel extends GSliderPanel
     return Integer.parseInt(valueField.getText());
   }
 
+  @Override
   public void slider_mouseReleased(MouseEvent e)
   {
     if (ap.overviewPanel != null)
index dc17397..6530d3d 100755 (executable)
@@ -155,6 +155,8 @@ public class GAlignFrame extends JInternalFrame
 
   protected JMenuItem modifyConservation = new JMenuItem();
 
+  protected JMenuItem modifyPID = new JMenuItem();
+
   protected JMenu sortByTreeMenu = new JMenu();
 
   protected JMenu sort = new JMenu();
@@ -1118,7 +1120,7 @@ public class GAlignFrame extends JInternalFrame
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        conservationMenuItem_actionPerformed(e);
+        conservationMenuItem_actionPerformed();
       }
     });
     noColourmenuItem.setText(MessageManager.getString("label.none"));
@@ -1189,7 +1191,7 @@ public class GAlignFrame extends JInternalFrame
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        abovePIDThreshold_actionPerformed(e);
+        abovePIDThreshold_actionPerformed();
       }
     });
     showSeqFeatures.setText(MessageManager
@@ -1604,14 +1606,14 @@ public class GAlignFrame extends JInternalFrame
 
     });
 
-    JMenuItem modifyPID = new JMenuItem(
+    modifyPID = new JMenuItem(
             MessageManager.getString("label.modify_identity_threshold"));
     modifyPID.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        modifyPID_actionPerformed(e);
+        modifyPID_actionPerformed();
       }
     });
     modifyConservation.setText(MessageManager
@@ -1621,7 +1623,7 @@ public class GAlignFrame extends JInternalFrame
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        modifyConservation_actionPerformed(e);
+        modifyConservation_actionPerformed();
       }
     });
     sortByTreeMenu
@@ -2817,7 +2819,7 @@ public class GAlignFrame extends JInternalFrame
   {
   }
 
-  protected void conservationMenuItem_actionPerformed(ActionEvent e)
+  protected void conservationMenuItem_actionPerformed()
   {
   }
 
@@ -2833,7 +2835,7 @@ public class GAlignFrame extends JInternalFrame
   {
   }
 
-  protected void abovePIDThreshold_actionPerformed(ActionEvent e)
+  protected void abovePIDThreshold_actionPerformed()
   {
   }
 
@@ -2954,11 +2956,11 @@ public class GAlignFrame extends JInternalFrame
   {
   }
 
-  protected void modifyPID_actionPerformed(ActionEvent e)
+  protected void modifyPID_actionPerformed()
   {
   }
 
-  protected void modifyConservation_actionPerformed(ActionEvent e)
+  protected void modifyConservation_actionPerformed()
   {
   }
 
index 1362007..0c79c6c 100755 (executable)
@@ -28,6 +28,9 @@ import java.awt.Dimension;
 import java.awt.FlowLayout;
 import java.awt.GridLayout;
 import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.FocusAdapter;
+import java.awt.event.FocusEvent;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
 
@@ -105,6 +108,7 @@ public class GSliderPanel extends JPanel
     slider.setDoubleBuffered(true);
     slider.addMouseListener(new MouseAdapter()
     {
+      @Override
       public void mouseReleased(MouseEvent e)
       {
         slider_mouseReleased(e);
@@ -115,11 +119,20 @@ public class GSliderPanel extends JPanel
     valueField.setPreferredSize(new Dimension(50, 12));
     valueField.setText("");
     valueField.setHorizontalAlignment(SwingConstants.CENTER);
-    valueField.addActionListener(new java.awt.event.ActionListener()
+    valueField.addActionListener(new ActionListener()
     {
+      @Override
       public void actionPerformed(ActionEvent e)
       {
-        valueField_actionPerformed(e);
+        valueField_actionPerformed();
+      }
+    });
+    valueField.addFocusListener(new FocusAdapter()
+    {
+      @Override
+      public void focusLost(FocusEvent e)
+      {
+        valueField_actionPerformed();
       }
     });
     label.setFont(new java.awt.Font("Verdana", 0, 11));
@@ -134,6 +147,7 @@ public class GSliderPanel extends JPanel
     applyButton.setText(MessageManager.getString("action.apply"));
     applyButton.addActionListener(new java.awt.event.ActionListener()
     {
+      @Override
       public void actionPerformed(ActionEvent e)
       {
         applyButton_actionPerformed(e);
@@ -145,6 +159,7 @@ public class GSliderPanel extends JPanel
     undoButton.setText(MessageManager.getString("action.undo"));
     undoButton.addActionListener(new java.awt.event.ActionListener()
     {
+      @Override
       public void actionPerformed(ActionEvent e)
       {
         undoButton_actionPerformed(e);
@@ -157,6 +172,7 @@ public class GSliderPanel extends JPanel
             .getString("action.apply_all_groups"));
     allGroupsCheck.addActionListener(new java.awt.event.ActionListener()
     {
+      @Override
       public void actionPerformed(ActionEvent e)
       {
         allGroupsCheck_actionPerformed(e);
@@ -180,13 +196,18 @@ public class GSliderPanel extends JPanel
   }
 
   /**
-   * DOCUMENT ME!
-   * 
-   * @param e
-   *          DOCUMENT ME!
+   * Action on changing the slider text field value
    */
-  protected void valueField_actionPerformed(ActionEvent e)
+  protected void valueField_actionPerformed()
   {
+    try
+    {
+      int i = Integer.valueOf(valueField.getText());
+      slider.setValue(i);
+    } catch (NumberFormatException ex)
+    {
+      valueField.setText(String.valueOf(slider.getValue()));
+    }
   }
 
   /**