import jalview.api.AlignmentViewPanel;
import jalview.api.analysis.ScoreModelI;
+import jalview.bin.ApplicationSingletonProvider;
+import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI;
import jalview.io.DataSourceType;
import jalview.io.FileParse;
import jalview.io.ScoreMatrixFile;
-import jalview.util.Platform;
import java.io.IOException;
import java.util.LinkedHashMap;
/**
* A class that can register and serve instances of ScoreModelI
*/
-public class ScoreModels
+public class ScoreModels implements ApplicationSingletonI
{
- private final ScoreMatrix BLOSUM62;
-
- private final ScoreMatrix PAM250;
-
- private final ScoreMatrix DNA;
-
- private static ScoreModels instance;
-
/**
* Answers the singleton instance of this class, with lazy initialisation
* (built-in score models are loaded on the first call to this method)
*/
public static ScoreModels getInstance()
{
- ScoreModels m = instance;
- @SuppressWarnings("unused")
- ThreadGroup g = null;
- if (Platform.isJS())
- {
- g = Thread.currentThread().getThreadGroup();
- /**
- * @j2sNative m = g._jalviewScoreModelsInstance;
- *
- */
- }
- if (m == null)
- {
- m = new ScoreModels();
- if (Platform.isJS())
- {
- /**
- * @j2sNative g._jalviewScoreModelsInstance = m;
- *
- */
- }
- else
- {
- instance = m;
- }
- }
- return m;
+ return (ScoreModels) ApplicationSingletonProvider.getInstance(ScoreModels.class);
}
- private Map<String, ScoreModelI> models;
-
/**
* Private constructor to enforce use of singleton. Registers Jalview's
* "built-in" score models:
registerScoreModel(new FeatureDistanceModel());
}
+ private final ScoreMatrix BLOSUM62;
+
+ private final ScoreMatrix PAM250;
+
+ private final ScoreMatrix DNA;
+
+ private Map<String, ScoreModelI> models;
+
/**
* Tries to load a score matrix from the given resource file, and if
* successful, registers it.
*/
public void reset()
{
- instance = new ScoreModels();
+ ApplicationSingletonProvider.removeInstance(this.getClass());
}
/**