JAL-2374 don’t search twice for containing group to assign to stretchGroup
[jalview.git] / src / jalview / appletgui / SeqPanel.java
index 1de7896..904e3ce 100644 (file)
@@ -1423,40 +1423,9 @@ public class SeqPanel extends Panel implements MouseMotionListener,
 
     stretchGroup = av.getSelectionGroup();
 
-    if (stretchGroup == null)
-    {
-      stretchGroup = av.getAlignment().findGroup(sequence);
-      if (stretchGroup != null && res > stretchGroup.getStartRes()
-              && res < stretchGroup.getEndRes())
-      {
-        av.setSelectionGroup(stretchGroup);
-      }
-      else
-      {
-        stretchGroup = null;
-      }
-    }
-
-    else if (!stretchGroup.getSequences(null).contains(sequence)
-            || stretchGroup.getStartRes() > res
-            || stretchGroup.getEndRes() < res)
+    if (stretchGroup == null || !stretchGroup.contains(sequence, res))
     {
-      stretchGroup = null;
-
-      SequenceGroup[] allGroups = av.getAlignment().findAllGroups(sequence);
-
-      if (allGroups != null)
-      {
-        for (int i = 0; i < allGroups.length; i++)
-        {
-          if (allGroups[i].getStartRes() <= res
-                  && allGroups[i].getEndRes() >= res)
-          {
-            stretchGroup = allGroups[i];
-            break;
-          }
-        }
-      }
+      stretchGroup = av.getAlignment().findGroup(sequence, res);
       av.setSelectionGroup(stretchGroup);
     }
 
@@ -1512,13 +1481,13 @@ public class SeqPanel extends Panel implements MouseMotionListener,
 
       if (av.getConservationSelected())
       {
-        SliderPanel.setConservationSlider(ap, av.getViewportColourScheme(),
-                "Background");
+        SliderPanel.setConservationSlider(ap, av.getResidueShading(),
+                ap.getViewName());
       }
       if (av.getAbovePIDThreshold())
       {
-        SliderPanel.setPIDSliderSource(ap, av.getViewportColourScheme(),
-                "Background");
+        SliderPanel.setPIDSliderSource(ap, av.getResidueShading(),
+                ap.getViewName());
       }
 
     }
@@ -1545,7 +1514,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
         SliderPanel.setConservationSlider(ap, stretchGroup.cs,
                 stretchGroup.getName());
       }
-      else
+      if (stretchGroup.cs.getThreshold() > 0)
       {
         SliderPanel.setPIDSliderSource(ap, stretchGroup.cs,
                 stretchGroup.getName());