@Override
public ScoreModelI getInstance(AlignmentViewPanel view)
{
- FeatureDistanceModel instance;
+ FeatureDistanceModel model;
try
{
- instance = this.getClass().newInstance();
- instance.configureFromAlignmentView(view);
- return instance;
+ model = this.getClass().newInstance();
+ model.configureFromAlignmentView(view);
+ return model;
} catch (InstantiationException | IllegalAccessException e)
{
System.err.println("Error in " + getClass().getName()
import jalview.analysis.AlignmentSorter;
import jalview.analysis.scoremodels.ScoreModels;
import jalview.api.StructureSelectionManagerProvider;
+import jalview.datamodel.features.FeatureAttributes;
+import jalview.datamodel.features.FeatureSources;
import jalview.ext.ensembl.EnsemblInfo;
import jalview.fts.service.pdb.PDBFTSRestClient;
import jalview.fts.service.uniprot.UniProtFTSRestClient;
import jalview.gui.Desktop;
import jalview.httpserver.HttpServer;
+import jalview.io.FileFormats;
+import jalview.io.cache.AppCache;
import jalview.io.gff.SequenceOntologyFactory;
import jalview.rest.RestHandler;
import jalview.schemes.ColourSchemes;
// that is assigned by the class as part of a public static getInstance()
// call.
+ public AppCache appCache;
+
public ColourSchemes colourSchemes;
public Discoverer discoverer;
+ public FileFormats fileFormats;
+
public HttpServer httpServer;
public RestClient restClient;
public EnsemblInfo ensemblInfo;
+ public FeatureAttributes featureAttributes;
+
+ public FeatureSources featureSources;
+
public IdOrgSettings idOrgSettings;
public Jws2Discoverer j2s2discoverer;
*/
public IdentityHashMap<StructureSelectionManagerProvider, StructureSelectionManager> structureSelections;
+
}
package jalview.datamodel.features;
+import jalview.bin.Instance;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
Character, Number, Mixed
}
- private static FeatureAttributes instance = new FeatureAttributes();
+ public static FeatureAttributes getInstance()
+ {
+ Instance i = Instance.getInstance();
+ return (i.featureAttributes == null
+ ? i.featureAttributes = new FeatureAttributes()
+ : i.featureAttributes);
+ }
+
+ private FeatureAttributes()
+ {
+ attributes = new HashMap<>();
+ }
/*
* map, by feature type, of a map, by attribute name, of
}
/**
- * Answers the singleton instance of this class
- *
- * @return
- */
- public static FeatureAttributes getInstance()
- {
- return instance;
- }
-
- private FeatureAttributes()
- {
- attributes = new HashMap<>();
- }
-
- /**
* Answers the attribute names known for the given feature type, in
* alphabetical order (not case sensitive), or an empty set if no attributes
* are known. An attribute name is typically 'simple' e.g. "AC", but may be
package jalview.datamodel.features;
+import jalview.bin.Instance;
+
import java.util.HashMap;
import java.util.Map;
-/**
- * A singleton to hold metadata about feature attributes, keyed by a unique
- * feature source identifier
- *
- * @author gmcarstairs
- *
- */
public class FeatureSources
{
- private static FeatureSources instance = new FeatureSources();
-
- private Map<String, FeatureSourceI> sources;
- /**
- * Answers the singleton instance of this class
- *
- * @return
- */
public static FeatureSources getInstance()
{
- return instance;
+ Instance i = Instance.getInstance();
+ return (i.featureSources == null
+ ? i.featureSources = new FeatureSources()
+ : i.featureSources);
}
+ private Map<String, FeatureSourceI> sources;
+
private FeatureSources()
{
sources = new HashMap<>();
*/
package jalview.io;
+import jalview.bin.Instance;
+
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashMap;
*/
public class FileFormats
{
- private static FileFormats instance = new FileFormats();
-
/*
* A lookup map of file formats by upper-cased name
*/
public static FileFormats getInstance()
{
- return instance;
+ Instance i = Instance.getInstance();
+ return (i.fileFormats == null ? i.fileFormats = new FileFormats()
+ : i.fileFormats);
}
/**
*/
public synchronized void reset()
{
- formats = new LinkedHashMap<String, FileFormatI>();
- identifiable = new HashSet<FileFormatI>();
+ formats = new LinkedHashMap<>();
+ identifiable = new HashSet<>();
for (FileFormat format : FileFormat.values())
{
registerFileFormat(format, format.isIdentifiable());
*/
public List<String> getWritableFormats(boolean textOnly)
{
- List<String> l = new ArrayList<String>();
+ List<String> l = new ArrayList<>();
for (FileFormatI ff : formats.values())
{
if (ff.isWritable() && (!textOnly || ff.isTextFormat()))
*/
public List<String> getReadableFormats()
{
- List<String> l = new ArrayList<String>();
+ List<String> l = new ArrayList<>();
for (FileFormatI ff : formats.values())
{
if (ff.isReadable())
package jalview.io.cache;
import jalview.bin.Cache;
+import jalview.bin.Instance;
import java.util.Hashtable;
import java.util.LinkedHashSet;
/**
* A singleton class used for querying and persisting cache items.
*
+ *
* @author tcnofoegbu
*
*/
public class AppCache
{
+
+ public static AppCache getInstance()
+ {
+ Instance i = Instance.getInstance();
+ return (i.appCache == null ? i.appCache = new AppCache() : i.appCache);
+ }
+
+ private AppCache()
+ {
+ cacheItems = new Hashtable<>();
+ }
+
public static final String DEFAULT_LIMIT = "99";
public static final String CACHE_DELIMITER = ";";
- private static AppCache instance = null;
-
private static final String DEFAULT_LIMIT_KEY = ".DEFAULT_LIMIT";
private Hashtable<String, LinkedHashSet<String>> cacheItems;
- private AppCache()
- {
- cacheItems = new Hashtable<String, LinkedHashSet<String>>();
- }
-
/**
* Method to obtain all the cache items for a given cache key
*
LinkedHashSet<String> foundCache = cacheItems.get(cacheKey);
if (foundCache == null)
{
- foundCache = new LinkedHashSet<String>();
+ foundCache = new LinkedHashSet<>();
cacheItems.put(cacheKey, foundCache);
}
return foundCache;
}
/**
- * Returns a singleton instance of AppCache
- *
- * @return
- */
- public static AppCache getInstance()
- {
- if (instance == null)
- {
- instance = new AppCache();
- }
- return instance;
- }
-
- /**
* Method for persisting cache items for a given cache key
*
* @param cacheKey