+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.bin;
+
+import jalview.analysis.AlignmentSorter;
+import jalview.analysis.scoremodels.ScoreModels;
+import jalview.api.StructureSelectionManagerProvider;
+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.gff.SequenceOntologyI;
+import jalview.rest.RestHandler;
+import jalview.structure.StructureImportSettings;
+import jalview.structure.StructureSelectionManager;
+import jalview.urls.IdOrgSettings;
+import jalview.ws.SequenceFetcher;
+import jalview.ws.jws1.Discoverer;
+import jalview.ws.jws2.Jws2Discoverer;
+import jalview.ws.jws2.jabaws2.Jws2InstanceFactory;
+import jalview.ws.rest.RestClient;
+import jalview.ws.sifts.SiftsSettings;
+
+import java.awt.Color;
+import java.util.IdentityHashMap;
+
+/**
+ * a class to hold singleton instances so that they are not shared
+ *
+ * @author hansonr
+ *
+ */
+public class Instance {
+
+ private static Instance instance;
+
+ public static Instance getInstance()
+ {
+ Instance i;
+ @SuppressWarnings("unused")
+ ThreadGroup g = Thread.currentThread().getThreadGroup();
+ /**
+ * @j2sNative i = g._instance;
+ */
+ {
+ i = instance;
+ }
+ if (i == null)
+ {
+ i = instance = new Instance();
+ /**
+ * @j2sNative g._instance = i;
+ */
+ }
+ return i;
+ }
+
+ /**
+ * singleton instance of this class in Java only
+ */
+
+ public Jalview jalview;
+
+ public Desktop desktop;
+
+ public static Jalview getJalview()
+ {
+ Instance i = getInstance();
+ if (i.jalview == null)
+ {
+ new Jalview();
+ }
+ return i.jalview;
+ }
+
+ public static void setJalview(Jalview j)
+ {
+ getInstance().jalview = j;
+ }
+
+ public static Desktop getDesktop()
+ {
+ Instance i = getInstance();
+ return (i.desktop == null ? (i.desktop = new Desktop(true))
+ : i.desktop);
+ }
+
+ public static void setDesktop(Desktop d)
+ {
+ getInstance().desktop = d;
+ }
+
+ public Cache cache;
+
+ public AlignmentSorter alignmentSorter;
+
+ public Color[] rnaHelices = null;
+
+ public Discoverer discoverer;
+
+ public EnsemblInfo ensemblInfo;
+
+ public HttpServer httpServer;
+
+ public IdOrgSettings idOrgSettings;
+
+ public Jws2Discoverer j2s2discoverer;
+
+ public Jws2InstanceFactory jws2InstanceFactory;
+
+ public PDBFTSRestClient pdbFTSRestClient;
+
+ public RestClient restClient;
+
+ public RestHandler restHandler;
+
+ public ScoreModels scoreModels;
+
+ public SequenceFetcher sequenceFetcher;
+
+ public SequenceOntologyI sequenceOntology;
+
+ public SiftsSettings siftsSettings;
+
+ public StructureImportSettings structureImportSettings;
+
+ public UniProtFTSRestClient uniprotFTSRestClient;
+
+ public IdentityHashMap<StructureSelectionManagerProvider, StructureSelectionManager> structureSelections;
+
+}