Merge branch 'features/JAL-2360colourSchemeApplicability' into
[jalview.git] / src / jalview / gui / SliderPanel.java
index e28778c..b386dec 100755 (executable)
@@ -25,14 +25,16 @@ import jalview.jbgui.GSliderPanel;
 import jalview.schemes.CollectionColourSchemeI;
 import jalview.util.MessageManager;
 
-import java.awt.event.ActionEvent;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
+import java.beans.PropertyVetoException;
 
 import javax.swing.JInternalFrame;
 import javax.swing.JLayeredPane;
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
+import javax.swing.event.InternalFrameAdapter;
+import javax.swing.event.InternalFrameEvent;
 
 /**
  * DOCUMENT ME!
@@ -138,6 +140,7 @@ public class SliderPanel extends GSliderPanel
     else
     {
       sp = (SliderPanel) conservationSlider.getContentPane();
+      sp.slider.setValue(cs.getConservationInc());
       sp.cs = cs;
     }
 
@@ -159,28 +162,55 @@ public class SliderPanel extends GSliderPanel
   }
 
   /**
-   * DOCUMENT ME!
+   * Hides the PID slider panel if it is shown
    */
-  public static void showConservationSlider()
+  public static void hidePIDSlider()
   {
-    try
+    if (PIDSlider != null)
     {
-      PIDSlider.setClosed(true);
-      PIDSlider = null;
-    } catch (Exception ex)
+      try
+      {
+        PIDSlider.setClosed(true);
+        PIDSlider = null;
+      } catch (PropertyVetoException ex)
+      {
+      }
+    }
+  }
+
+  /**
+   * Hides the conservation slider panel if it is shown
+   */
+  public static void hideConservationSlider()
+  {
+    if (conservationSlider != null)
     {
+      try
+      {
+        conservationSlider.setClosed(true);
+        conservationSlider = null;
+      } catch (PropertyVetoException ex)
+      {
+      }
     }
+  }
+
+  /**
+   * DOCUMENT ME!
+   */
+  public static void showConservationSlider()
+  {
+    hidePIDSlider();
 
     if (!conservationSlider.isVisible())
     {
       Desktop.addInternalFrame(conservationSlider,
               conservationSlider.getTitle(), 420, 90, false);
       conservationSlider
-              .addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
+              .addInternalFrameListener(new InternalFrameAdapter()
               {
                 @Override
-                public void internalFrameClosed(
-                        javax.swing.event.InternalFrameEvent e)
+                public void internalFrameClosed(InternalFrameEvent e)
                 {
                   conservationSlider = null;
                 }
@@ -220,6 +250,7 @@ public class SliderPanel extends GSliderPanel
     {
       pid = (SliderPanel) PIDSlider.getContentPane();
       pid.cs = collectionColourScheme;
+      pid.slider.setValue(collectionColourScheme.getThreshold());
     }
 
     PIDSlider
@@ -244,29 +275,21 @@ public class SliderPanel extends GSliderPanel
    */
   public static void showPIDSlider()
   {
-    try
-    {
-      conservationSlider.setClosed(true);
-      conservationSlider = null;
-    } catch (Exception ex)
-    {
-    }
+    hideConservationSlider();
 
     if (!PIDSlider.isVisible())
     {
       Desktop.addInternalFrame(PIDSlider, PIDSlider.getTitle(), 420, 90,
               false);
       PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER);
-      PIDSlider
-              .addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
-              {
-                @Override
-                public void internalFrameClosed(
-                        javax.swing.event.InternalFrameEvent e)
-                {
-                  PIDSlider = null;
-                }
-              });
+      PIDSlider.addInternalFrameListener(new InternalFrameAdapter()
+      {
+        @Override
+        public void internalFrameClosed(InternalFrameEvent e)
+        {
+          PIDSlider = null;
+        }
+      });
       PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER);
     }
   }
@@ -338,7 +361,7 @@ public class SliderPanel extends GSliderPanel
    *          DOCUMENT ME!
    */
   @Override
-  public void valueField_actionPerformed(ActionEvent e)
+  public void valueField_actionPerformed()
   {
     try
     {