JAL-2588 (and JAL-2610, JAL-2603) mid refactor
[jalview.git] / src / jalview / gui / SequenceRenderer.java
index 7a1e263..9874fd2 100755 (executable)
@@ -25,7 +25,6 @@ import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
 import jalview.renderer.ResidueShaderI;
 import jalview.renderer.seqfeatures.FeatureColourFinder;
-import jalview.util.Comparison;
 
 import java.awt.Color;
 import java.awt.FontMetrics;
@@ -41,8 +40,6 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
 
   boolean renderGaps = true;
 
-  SequenceGroup currentSequenceGroup = null;
-
   SequenceGroup[] allGroups = null;
 
   Color resBoxColour;
@@ -51,8 +48,6 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
 
   boolean monospacedFont;
 
-  boolean forOverview = false;
-
   /**
    * Creates a new SequenceRenderer object
    * 
@@ -88,7 +83,8 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
     // rate limiting step when rendering overview for lots of groups
     allGroups = av.getAlignment().findAllGroups(seq);
 
-    if (inCurrentSequenceGroup(i))
+    SequenceGroup currentSequenceGroup = inCurrentSequenceGroup(i);
+    if (currentSequenceGroup != null)
     {
       if (currentSequenceGroup.getDisplayBoxes())
       {
@@ -140,20 +136,7 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
   {
     if (shader.getColourScheme() != null)
     {
-      if (forOverview && Comparison.isGap(seq.getCharAt(i))
-              && !shader.getColourScheme().hasGapColour())
-      {
-        resBoxColour = Color.lightGray;
-      }
-      else
-      {
-        resBoxColour = shader.findColour(seq.getCharAt(i),
-              i, seq);
-      }
-    }
-    else if (forOverview && Comparison.isGap(seq.getCharAt(i)))
-    {
-      resBoxColour = Color.lightGray;
+      resBoxColour = shader.findColour(seq.getCharAt(i), i, seq);
     }
     else
     {
@@ -236,7 +219,8 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
 
       if (i < length)
       {
-        if (inCurrentSequenceGroup(i))
+        SequenceGroup currentSequenceGroup = inCurrentSequenceGroup(i);
+        if (currentSequenceGroup != null)
         {
           if (currentSequenceGroup.getDisplayBoxes())
           {
@@ -325,9 +309,7 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
       boolean srep = av.isDisplayReferenceSeq();
       boolean getboxColour = false;
       boolean isarep = av.getAlignment().getSeqrep() == seq;
-      boolean isgrep = currentSequenceGroup != null ? currentSequenceGroup
-              .getSeqrep() == seq : false;
-      char sr_c;
+
       for (int i = start; i <= end; i++)
       {
 
@@ -340,7 +322,8 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
           continue;
         }
 
-        if (inCurrentSequenceGroup(i))
+        SequenceGroup currentSequenceGroup = inCurrentSequenceGroup(i);
+        if (currentSequenceGroup != null)
         {
           if (!currentSequenceGroup.getDisplayText())
           {
@@ -372,6 +355,8 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
           {
             graphics.setColor(currentSequenceGroup.textColour);
           }
+          boolean isgrep = currentSequenceGroup != null
+                  ? currentSequenceGroup.getSeqrep() == seq : false;
           if (!isarep && !isgrep
                   && currentSequenceGroup.getShowNonconserved()) // todo
                                                                  // optimize
@@ -480,11 +465,11 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
    * 
    * @return DOCUMENT ME!
    */
-  boolean inCurrentSequenceGroup(int res)
+  SequenceGroup inCurrentSequenceGroup(int res)
   {
     if (allGroups == null)
     {
-      return false;
+      return null;
     }
 
     for (int i = 0; i < allGroups.length; i++)
@@ -492,13 +477,11 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
       if ((allGroups[i].getStartRes() <= res)
               && (allGroups[i].getEndRes() >= res))
       {
-        currentSequenceGroup = allGroups[i];
-
-        return true;
+        return (allGroups[i]);
       }
     }
 
-    return false;
+    return null;
   }
 
   /**