JAL-3210 Improvements to eclipse detection. New src tree and SwingJS updated from...
[jalview.git] / src / jalview / analysis / AlignmentSorter.java
index e5038ba..8634db6 100755 (executable)
@@ -22,6 +22,8 @@ package jalview.analysis;
 
 import jalview.analysis.scoremodels.PIDModel;
 import jalview.analysis.scoremodels.SimilarityParams;
+import jalview.bin.ApplicationSingletonProvider;
+import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.AlignmentOrder;
@@ -29,7 +31,6 @@ import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
 import jalview.datamodel.SequenceNode;
-import jalview.util.Platform;
 import jalview.util.QuickSort;
 
 import java.util.ArrayList;
@@ -52,45 +53,31 @@ import java.util.List;
  * from the first tobesorted position in the alignment. e.g. (a,tb2,b,tb1,c,tb3
  * becomes a,tb1,tb2,tb3,b,c)
  */
-public class AlignmentSorter
+public class AlignmentSorter implements ApplicationSingletonI
 {
 
-  static AlignmentSorter instance;
+  private AlignmentSorter()
+  {
+    // private singleton
+  }
 
-  public static AlignmentSorter getInstance()
+  private static AlignmentSorter getInstance()
   {
+    return (AlignmentSorter) ApplicationSingletonProvider
+            .getInstance(AlignmentSorter.class);
+  }
 
-    // BH 2019.05.08 need to isolate static fields in JavaScript
+  /**
+   * types of feature ordering: Sort by score : average score - or total score -
+   * over all features in region Sort by feature label text: (or if null -
+   * feature type text) - numerical or alphabetical Sort by feature density:
+   * based on counts - ignoring individual text or scores for each feature
+   */
+  public static final String FEATURE_SCORE = "average_score";
 
-    AlignmentSorter i = instance;
-    @SuppressWarnings("unused")
-    ThreadGroup g = null;
-    if (Platform.isJS())
-    {
-      g = Thread.currentThread().getThreadGroup();
-      /**
-       * @j2sNative i = g._jalviewScoreModelsInstance;
-       * 
-       */
-    }
-    if (i == null)
-    {
-      i = new AlignmentSorter();
+  public static final String FEATURE_LABEL = "text";
 
-      if (Platform.isJS())
-      {
-        /**
-         * @j2sNative g._jalviewScoreModelsInstance = i;
-         * 
-         */
-      }
-      else
-      {
-        instance = i;
-      }
-    }
-    return i;
-  }
+  public static final String FEATURE_DENSITY = "density";
 
   /*
    * todo: refactor searches to follow a basic pattern: (search property, last
@@ -722,18 +709,6 @@ public class AlignmentSorter
   }
 
   /**
-   * types of feature ordering: Sort by score : average score - or total score -
-   * over all features in region Sort by feature label text: (or if null -
-   * feature type text) - numerical or alphabetical Sort by feature density:
-   * based on counts - ignoring individual text or scores for each feature
-   */
-  public static String FEATURE_SCORE = "average_score";
-
-  public static String FEATURE_LABEL = "text";
-
-  public static String FEATURE_DENSITY = "density";
-
-  /**
    * Sort sequences by feature score or density, optionally restricted by
    * feature types, feature groups, or alignment start/end positions.
    * <p>