JAL-3383 JAL-3253-applet additional efficiencies; FeatureStore
[jalview.git] / src / jalview / datamodel / Sequence.java
index 4c46522..4219c8e 100755 (executable)
@@ -28,7 +28,6 @@ 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;
@@ -1968,15 +1967,15 @@ public class Sequence extends ASequence implements SequenceI
 
     List<SequenceFeature> result = getFeatures().findFeatures(startPos,
             endPos, types);
-    if (datasetSequence != null)
-    {
-      result = datasetSequence.getFeatures().findFeatures(startPos, endPos,
-              types);
-    }
-    else
-    {
-      result = sequenceFeatureStore.findFeatures(startPos, endPos, types);
-    }
+    // if (datasetSequence != null)
+    // {
+    // result = datasetSequence.getFeatures().findFeatures(startPos, endPos,
+    // types);
+    // }
+    // else
+    // {
+    // result = sequenceFeatureStore.findFeatures(startPos, endPos, types);
+    // }
 
     /*
      * if end column is gapped, endPos may be to the right, 
@@ -2027,6 +2026,7 @@ public class Sequence extends ASequence implements SequenceI
   @Override
   public void sequenceChanged()
   {
+    argb = null;
     changeCount++;
   }
 
@@ -2129,20 +2129,53 @@ public class Sequence extends ASequence implements SequenceI
     return 0;
   }
 
+  private int[] argb;
+
   @Override
-  public Color getColor(int i)
+  public int getColor(int i)
   {
-    return null;
+    return argb == null ? 0 : argb[i];
   }
 
   @Override
-  public Color setColor(int i, Color c)
+  public int setColor(int i, int rgb)
   {
-    return c;
+    if (argb == null)
+    {
+      argb = new int[this.sequence.length];
+    }
+    return (argb[i] = rgb);
   }
 
   @Override
   public void resetColors()
   {
+    argb = null;
   }
+
+  /**
+   * @author Bob Hanson 2019.07.30
+   * 
+   *         allows passing the result ArrayList as a parameter to avoid
+   *         unnecessary construction
+   * @return result (JavaScript) or new ArrayList (Java -- see FeatureRender)
+   * 
+   */
+  @Override
+  public List<SequenceFeature> findFeatures(int column, String type,
+          List<SequenceFeature> result)
+  {
+    return getFeatures().findFeatures(findPosition(column - 1), type,
+            result);
+  }
+
+  /**
+   * allows early intervention for renderer if this returns false
+   */
+  @Override
+  public boolean hasFeatures(String type)
+  {
+    return getFeatures().hasFeatures(type);
+  }
+
 }