JAL-2446 optimised new method to find feature colour for overview
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 22 Mar 2017 16:52:09 +0000 (16:52 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 22 Mar 2017 16:52:09 +0000 (16:52 +0000)
src/jalview/renderer/seqfeatures/FeatureRenderer.java

index 705ea12..e62b225 100644 (file)
@@ -419,12 +419,6 @@ public class FeatureRenderer extends FeatureRendererModel
    */
   Color findFeatureColour(SequenceI seq, int pos)
   {
-    SequenceFeature[] sequenceFeatures = seq.getSequenceFeatures();
-    if (sequenceFeatures == null || sequenceFeatures.length == 0)
-    {
-      return null;
-    }
-  
     /*
      * check for new feature added while processing
      */
@@ -442,31 +436,10 @@ public class FeatureRenderer extends FeatureRendererModel
         continue;
       }
 
-      for (int sfindex = 0; sfindex < sequenceFeatures.length; sfindex++)
+      List<SequenceFeature> overlaps = seq.findFeatures(type, pos, pos);
+      for (SequenceFeature sequenceFeature : overlaps)
       {
-        SequenceFeature sequenceFeature = sequenceFeatures[sfindex];
-        if (!sequenceFeature.type.equals(type))
-        {
-          continue;
-        }
-
-        if (featureGroupNotShown(sequenceFeature))
-        {
-          continue;
-        }
-
-        /*
-         * check the column position is within the feature range
-         * (or is one of the two contact positions for a contact feature)
-         */
-        boolean featureIsAtPosition = sequenceFeature.begin <= pos
-                && sequenceFeature.end >= pos;
-        if (sequenceFeature.isContactFeature())
-        {
-          featureIsAtPosition = sequenceFeature.begin == pos
-                  || sequenceFeature.end == pos;
-        }
-        if (featureIsAtPosition)
+        if (!featureGroupNotShown(sequenceFeature))
         {
           return getColour(sequenceFeature);
         }