Merge branch 'features/JAL-2360colourSchemeApplicability' into
[jalview.git] / src / jalview / appletgui / SliderPanel.java
index 5ee665a..2aa010f 100644 (file)
@@ -21,7 +21,7 @@
 package jalview.appletgui;
 
 import jalview.datamodel.SequenceGroup;
-import jalview.schemes.ColourSchemeI;
+import jalview.schemes.CollectionColourSchemeI;
 import jalview.util.MessageManager;
 
 import java.awt.BorderLayout;
@@ -53,27 +53,29 @@ public class SliderPanel extends Panel implements ActionListener,
 
   boolean forConservation = true;
 
-  ColourSchemeI cs;
+  CollectionColourSchemeI cs;
 
   static Frame conservationSlider;
 
   static Frame PIDSlider;
 
   public static int setConservationSlider(AlignmentPanel ap,
-          ColourSchemeI cs, String source)
+          CollectionColourSchemeI collectionColourSchemeI, String source)
   {
     SliderPanel sp = null;
 
     if (conservationSlider == null)
     {
-      sp = new SliderPanel(ap, cs.getConservationInc(), true, cs);
+      sp = new SliderPanel(ap,
+              collectionColourSchemeI.getConservationInc(), true,
+              collectionColourSchemeI);
       conservationSlider = new Frame();
       conservationSlider.add(sp);
     }
     else
     {
       sp = (SliderPanel) conservationSlider.getComponent(0);
-      sp.cs = cs;
+      sp.cs = collectionColourSchemeI;
     }
 
     conservationSlider
@@ -119,20 +121,20 @@ public class SliderPanel extends Panel implements ActionListener,
 
   }
 
-  public static int setPIDSliderSource(AlignmentPanel ap, ColourSchemeI cs,
-          String source)
+  public static int setPIDSliderSource(AlignmentPanel ap,
+          CollectionColourSchemeI ccs, String source)
   {
     SliderPanel pid = null;
     if (PIDSlider == null)
     {
-      pid = new SliderPanel(ap, 50, false, cs);
+      pid = new SliderPanel(ap, ccs.getThreshold(), false, ccs);
       PIDSlider = new Frame();
       PIDSlider.add(pid);
     }
     else
     {
       pid = (SliderPanel) PIDSlider.getComponent(0);
-      pid.cs = cs;
+      pid.cs = ccs;
     }
     PIDSlider
             .setTitle(MessageManager.formatMessage(
@@ -178,19 +180,31 @@ public class SliderPanel extends Panel implements ActionListener,
 
   }
 
+  /**
+   * Hides the PID slider panel if it is shown
+   */
   public static void hidePIDSlider()
   {
-    PIDSlider.setVisible(false);
-    PIDSlider = null;
+    if (PIDSlider != null)
+    {
+      PIDSlider.setVisible(false);
+      PIDSlider = null;
+    }
   }
 
+  /**
+   * Hides the Conservation slider panel if it is shown
+   */
   public static void hideConservationSlider()
   {
-    conservationSlider.setVisible(false);
-    conservationSlider = null;
+    if (conservationSlider != null)
+    {
+      conservationSlider.setVisible(false);
+      conservationSlider = null;
+    }
   }
   public SliderPanel(AlignmentPanel ap, int value, boolean forConserve,
-          ColourSchemeI cs)
+          CollectionColourSchemeI collectionColourSchemeI)
   {
     try
     {
@@ -200,7 +214,7 @@ public class SliderPanel extends Panel implements ActionListener,
       e.printStackTrace();
     }
     this.ap = ap;
-    this.cs = cs;
+    this.cs = collectionColourSchemeI;
     forConservation = forConserve;
     undoButton.setVisible(false);
     applyButton.setVisible(false);
@@ -235,7 +249,7 @@ public class SliderPanel extends Panel implements ActionListener,
       return;
     }
 
-    ColourSchemeI toChange = cs;
+    CollectionColourSchemeI toChange = cs;
     Iterator<SequenceGroup> allGroups = null;
 
     if (allGroupsCheck.getState())