JAL-3253-applet JAL-3397 switch back to original (MC) IS+NCList after
[jalview.git] / src / jalview / datamodel / features / SequenceFeatures.java
index 54102ce..cb2b8cc 100644 (file)
@@ -53,7 +53,31 @@ public class SequenceFeatures implements SequenceFeaturesI
    */
   private Map<String, FeatureStoreI> featureStore;
 
-  private static boolean useIntervalStore = !Platform.isJS();
+  /**
+   * original NCList-based IntervalStore
+   */
+  private final static int INTERVAL_STORE_NCLIST = 0;
+
+  /**
+   * linked-list deferred-sort IntervalStore - experimental only; unused
+   */
+  private final static int INTERVAL_STORE_LINKED_LIST_NO_PRESORT = 1;
+
+  /**
+   * linked-list IntervalStore option for JavaScript
+   */
+  private final static int INTERVAL_STORE_LINKED_LIST = -1;
+
+  /**
+   * mode for Java or JavaScript; can be set differently for testing, but
+   * default is LINKED_LIST for JalviewJS and NCLIST for Java
+   */
+  private final int INTERVAL_STORE_MODE = (
+  // true || //
+  Platform.isJS() ? //
+          INTERVAL_STORE_LINKED_LIST //
+          : INTERVAL_STORE_NCLIST//
+  );
 
   /**
    * Constructor
@@ -106,8 +130,16 @@ public class SequenceFeatures implements SequenceFeaturesI
 
   private FeatureStoreI newFeatureStore()
   {
-    // TODO Auto-generated method stub
-    return (useIntervalStore ? new FeatureStoreImpl() : new FeatureStoreJS());
+    switch (INTERVAL_STORE_MODE)
+    {
+    default:
+    case INTERVAL_STORE_NCLIST:
+      return new FeatureStoreImpl(true);
+    case INTERVAL_STORE_LINKED_LIST_NO_PRESORT:
+      return new FeatureStoreImpl(false);
+    case INTERVAL_STORE_LINKED_LIST:
+      return new FeatureStoreJS();
+    }
   }
 
   /**
@@ -120,6 +152,10 @@ public class SequenceFeatures implements SequenceFeaturesI
     List<SequenceFeature> result = new ArrayList<>();
     for (FeatureStoreI featureSet : varargToTypes(type))
     {
+      // System.err.println("SF findFeature " + System.currentTimeMillis()
+      // + " " + from + " " + to + " "
+      // + featureSet.getPositionalFeatures().get(0).type);
+      //
       result.addAll(featureSet.findOverlappingFeatures(from, to, null));
     }
     return result;
@@ -160,8 +196,8 @@ public class SequenceFeatures implements SequenceFeaturesI
       return new ArrayList<>();
     }
 
-    return getAllFeatures(featureTypes.toArray(new String[featureTypes
-            .size()]));
+    return getAllFeatures(
+            featureTypes.toArray(new String[featureTypes.size()]));
   }
 
   /**
@@ -226,7 +262,6 @@ public class SequenceFeatures implements SequenceFeaturesI
       return featureStore.values();
     }
 
-
     List<FeatureStoreI> types = new ArrayList<>();
     List<String> args = Arrays.asList(type);
     for (Entry<String, FeatureStoreI> featureType : featureStore.entrySet())
@@ -329,8 +364,8 @@ public class SequenceFeatures implements SequenceFeaturesI
 
     for (Entry<String, FeatureStoreI> featureType : featureStore.entrySet())
     {
-      Set<String> featureGroups = featureType.getValue().getFeatureGroups(
-              positionalFeatures);
+      Set<String> featureGroups = featureType.getValue()
+              .getFeatureGroups(positionalFeatures);
       for (String group : groups)
       {
         if (featureGroups.contains(group))
@@ -398,8 +433,9 @@ public class SequenceFeatures implements SequenceFeaturesI
   @Override
   public float getMinimumScore(String type, boolean positional)
   {
-    return featureStore.containsKey(type) ? featureStore.get(type)
-            .getMinimumScore(positional) : Float.NaN;
+    return featureStore.containsKey(type)
+            ? featureStore.get(type).getMinimumScore(positional)
+            : Float.NaN;
   }
 
   /**
@@ -408,8 +444,9 @@ public class SequenceFeatures implements SequenceFeaturesI
   @Override
   public float getMaximumScore(String type, boolean positional)
   {
-    return featureStore.containsKey(type) ? featureStore.get(type)
-            .getMaximumScore(positional) : Float.NaN;
+    return featureStore.containsKey(type)
+            ? featureStore.get(type).getMaximumScore(positional)
+            : Float.NaN;
   }
 
   /**
@@ -523,8 +560,6 @@ public class SequenceFeatures implements SequenceFeaturesI
   // Platform: timer mark 52.355 0.185 overviewrender 16000 pixels row:14
   // Platform: timer mark 53.829 0.186 overviewrender 16000 pixels row:14
 
-
-
   /**
    * @author Bob Hanson 2019.08.01
    */