JAL-3383 JAL-3253-applet Allows for possibility of a sequence caching
authorhansonr <hansonr@STO24954W.ad.stolaf.edu>
Mon, 29 Jul 2019 20:34:41 +0000 (15:34 -0500)
committerhansonr <hansonr@STO24954W.ad.stolaf.edu>
Mon, 29 Jul 2019 20:34:41 +0000 (15:34 -0500)
its colors for speed; not implemented

src/jalview/datamodel/Sequence.java
src/jalview/datamodel/SequenceI.java
src/jalview/renderer/OverviewResColourFinder.java

index ca2b6d4..4c46522 100755 (executable)
@@ -28,6 +28,7 @@ import jalview.util.DBRefUtils;
 import jalview.util.MapList;
 import jalview.util.StringUtils;
 
+import java.awt.Color;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.BitSet;
@@ -2127,4 +2128,21 @@ public class Sequence extends ASequence implements SequenceI
     // otherwise, sequence was completely hidden
     return 0;
   }
+
+  @Override
+  public Color getColor(int i)
+  {
+    return null;
+  }
+
+  @Override
+  public Color setColor(int i, Color c)
+  {
+    return c;
+  }
+
+  @Override
+  public void resetColors()
+  {
+  }
 }
index 933f332..5e2355d 100755 (executable)
@@ -25,6 +25,7 @@ import jalview.datamodel.features.SequenceFeaturesI;
 import jalview.util.MapList;
 import jalview.ws.params.InvalidArgumentException;
 
+import java.awt.Color;
 import java.util.BitSet;
 import java.util.Iterator;
 import java.util.List;
@@ -584,6 +585,11 @@ public interface SequenceI extends ASequenceI
    */
   public int firstResidueOutsideIterator(Iterator<int[]> it);
 
+  public Color getColor(int i);
+
+  public Color setColor(int i, Color c);
+
+  public void resetColors();
 
 }
 
index a497d92..ff52f1d 100644 (file)
@@ -81,30 +81,24 @@ public class OverviewResColourFinder extends ResidueColourFinder
   @Override
   public Color getBoxColour(ResidueShaderI shader, SequenceI seq, int i)
   {
-    Color resBoxColour = RESIDUE_COLOUR;
+    seq.resetColors();
+    Color c = seq.getColor(i);
+    if (c != null)
+    {
+      return c;
+    }
     char currentChar = seq.getCharAt(i);
-
     // In the overview window, gaps are coloured grey, unless the colour scheme
     // specifies a gap colour, in which case gaps honour the colour scheme
     // settings
-    if (shader.getColourScheme() != null)
+    boolean isGap = Comparison.isGap(currentChar);
+    if (shader.getColourScheme() == null)
     {
-      if (Comparison.isGap(currentChar)
-              && (!shader.getColourScheme().hasGapColour()))
-      {
-        resBoxColour = GAP_COLOUR;
-      }
-      else
-      {
-        resBoxColour = shader.findColour(currentChar, i, seq);
-      }
+      return seq.setColor(i, isGap ? GAP_COLOUR : RESIDUE_COLOUR);
     }
-    else if (Comparison.isGap(currentChar))
-    {
-      resBoxColour = GAP_COLOUR;
-    }
-
-    return resBoxColour;
+    return seq.setColor(i,
+            isGap && !shader.getColourScheme().hasGapColour() ? GAP_COLOUR
+                    : shader.findColour(currentChar, i, seq));
   }
 
   /**
@@ -113,21 +107,13 @@ public class OverviewResColourFinder extends ResidueColourFinder
    */
   @Override
   protected Color getResidueBoxColour(boolean showBoxes,
-          ResidueShaderI shader,
-          SequenceGroup[] allGroups, SequenceI seq, int i)
+          ResidueShaderI shader, SequenceGroup[] allGroups, SequenceI seq,
+          int i)
   {
-    ResidueShaderI currentShader;
     SequenceGroup currentSequenceGroup = getCurrentSequenceGroup(allGroups,
             i);
-    if (currentSequenceGroup != null)
-    {
-      currentShader = currentSequenceGroup.getGroupColourScheme();
-    }
-    else
-    {
-      currentShader = shader;
-    }
-
+    ResidueShaderI currentShader = (currentSequenceGroup == null ? shader
+            : currentSequenceGroup.getGroupColourScheme());
     return getBoxColour(currentShader, seq, i);
   }